:root {
    --cw-bg: rgba(255, 255, 255, 0.65); /* More transparent */
    --cw-text: #2d3436;
    --cw-text-secondary: #636e72;
    --cw-primary: #0984e3;
    --cw-primary-light: #e3f2fd;
    --cw-border: #dfe6e9;
    --cw-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --cw-radius: 12px;
    --cw-cell-size: 36px;
}

.cw-container {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--cw-bg);
    border: 1px solid var(--cw-border);
    border-radius: var(--cw-radius);
    padding: 20px;
    width: 360px; /* Fixed optimal width */
    max-width: 100%;
    box-shadow: var(--cw-shadow);
    user-select: none;
}

.cw-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 0;
}

.cw-selectors {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
    flex-grow: 1;
}

.cw-btn-nav {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--cw-text-secondary);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 14px;
}

.cw-btn-nav:hover {
    background-color: #fff;
    color: var(--cw-primary);
    border-color: var(--cw-primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transform: translateY(-1px);
}

.cw-btn-nav:active {
    transform: translateY(0);
}

.cw-btn-nav:focus {
    outline: none;
    box-shadow: 0 0 0 3px var(--cw-primary-light);
}

/* ... existing styles ... */

.cw-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    /* grid-auto-rows removed to let content dictate, or we keep it to ensure spacing */
    grid-auto-rows: 40px; /* Slightly taller to accommodate the cell */
}

.cw-days-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px; /* MATCH GRID GAP to align perfectly */
    margin-bottom: 12px;
    text-align: center;
    font-weight: bolder;
}

/* The Grid Cell Wrapper - ensures the cell itself can be a fixed circle centered */
/* Actually, we can just make the cell centered and fixed size */

.cw-day-cell {
    /* To make it a perfect circle, we give it fixed W/H and margin auto */
    width: 36px;
    height: 36px;
    margin: auto;
    
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 14px;
    font-weight: 500;
    color: var(--cw-text);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.cw-header .cw-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-color: #f8f9fa;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 8px 30px 8px 12px; /* Extra padding on right for arrow */
    font-size: 15px;
    font-weight: 600;
    color: var(--cw-text);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left; /* Align text left usually looks better with arrow on right */
    
    /* Custom SVG Arrow */
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23636e72' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 16px;
}

.cw-day-cell:hover:not(.cw-empty):not(.cw-selected) {
    background-color: #f1f3f5;
    color: var(--cw-primary);
}

.cw-day-cell.cw-today {
    color: var(--cw-primary);
    font-weight: 700;
}
.cw-day-cell.cw-today::after {
    content: '';
    position: absolute;
    bottom: 4px;
    width: 4px;
    height: 4px;
    background-color: var(--cw-primary);
    border-radius: 50%;
}

.cw-day-cell.cw-selected {
    background-color: var(--cw-primary);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 4px 6px rgba(9, 132, 227, 0.3);
}

/* Marked Dates Style (Distinct from Selected) */
.cw-day-cell.cw-marked:not(.cw-selected) {
    background-color: var(--cw-primary-light); /* Light Blue Background */
    color: var(--cw-primary);
    font-weight: 600;
}

/* Range Selection Styles */
.cw-range-start {
    background-color: var(--cw-primary);
    color: #fff;
    border-radius: 50% 0 0 50%; /* Left rounded */
}
/* When start is also end (single day in range mode) or start and end are same */
.cw-range-start.cw-range-end {
    border-radius: 50%;
}

.cw-range-end {
    background-color: var(--cw-primary);
    color: #fff;
    border-radius: 0 50% 50% 0; /* Right rounded */
}

.cw-range-in-between {
    background-color: var(--cw-primary-light);
    color: var(--cw-primary);
    border-radius: 0; /* Rectangular strip */
    font-weight: 600;
}

/* Ensure empty cells don't break the grid flow visual */
.cw-day-cell.cw-empty {
    cursor: default;
}

/* Helper for date text z-index if needed later, currently cell is wrapper */
.cw-date-text {
    z-index: 2;
}

/* Range Info Text */
.cw-range-info {
    text-align: center;
    margin-top: 15px;
    font-size: 13px;
    color: var(--cw-primary);
    font-weight: 500;
}

/* Hover Preview Styles */
.cw-range-hover-preview {
    background-color: #e3f2fd; /* Lighter than primary-light */
    color: var(--cw-primary);
    border-radius: 0;
}

.cw-range-hover-end {
    background-color: var(--cw-primary-light); /* Semi-selected look */
    color: var(--cw-primary);
    border-radius: 0 50% 50% 0; /* Right rounded like end */
}

/* Disabled Date Styles */
.cw-disabled {
    background-color: #f5f5f5;
    color: #ccc;
    cursor: not-allowed;
    pointer-events: none; /* Prevent all mouse events */
}

/* --- Responsive Sizing --- */

/* Default (md) is already defined above, but we can enforce it explicitly or let it fallback */
/* width: 360px, cell: 36px */

.cw-container.cw-size-lg {
    width: 420px;
    padding: 25px;
    --cw-cell-size: 44px;
    font-size: 16px;
}
.cw-container.cw-size-lg .cw-day-cell {
    width: 44px;
    height: 44px;
    font-size: 16px;
}
.cw-container.cw-size-lg .cw-grid, 
.cw-container.cw-size-lg .cw-days-header {
    grid-auto-rows: 48px;
}

.cw-container.cw-size-xl {
    width: 540px;
    padding: 30px;
    --cw-cell-size: 56px;
    font-size: 18px;
}
.cw-container.cw-size-xl .cw-day-cell {
    width: 56px;
    height: 56px;
    font-size: 18px;
}
.cw-container.cw-size-xl .cw-grid, 
.cw-container.cw-size-xl .cw-days-header {
    grid-auto-rows: 60px;
}

.cw-container.cw-size-2xl {
    width: 680px;
    padding: 40px;
    --cw-cell-size: 72px;
    font-size: 20px;
}
.cw-container.cw-size-2xl .cw-day-cell {
    width: 72px;
    height: 72px;
    font-size: 20px;
}
.cw-container.cw-size-2xl .cw-grid, 
.cw-container.cw-size-2xl .cw-days-header {
    grid-auto-rows: 80px;
}

/* Full Width / Fluid */
.cw-container.cw-size-auto,
.cw-container.cw-size-full {
    width: 100%;
    max-width: 100%;
}
.cw-container.cw-size-auto .cw-day-cell, 
.cw-container.cw-size-full .cw-day-cell {
    width: 100%; /* Fill the grid cell */
    height: auto;
    aspect-ratio: 1 / 1; /* Keep it square */
    max-width: 46px; /* Prevent being too huge on large screens */
    margin: 0 auto;
}
.cw-container.cw-size-auto .cw-grid,
.cw-container.cw-size-full .cw-grid {
     grid-auto-rows: auto; /* Let aspect-ratio dictate height */
     gap: 8px;
}

.cw-container.cw-size-auto .cw-header,
.cw-container.cw-size-full .cw-header {
    padding: 0 10px;
}

/* Frameless Mode */
.cw-container.cw-frameless {
    background: transparent;
    border: none;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    padding: 0; /* Remove padding to be truly minimal */
}

