/* =============================================================================
   IBA Availability Form — index.html page styles
   Sections: Password Screen (legacy) | Main Form Card | Instructions & Legend |
   Calendar | Scheduled Events | Summary | Submit | Modal | Time Ranges & Notes |
   Tool Selector | Progress Bar | Status Popup | Summary Delete | Validation |
   Submission Overlay | Responsive Mobile | Edit Mode Banner | Month Navigation |
   Read-Only Banner & Calendar | Submission History | Edit-Mode Calendar |
   Back to Edit | Bottom Sheet | Copy-from-Month | Save Template | Templates List |
   Cell Copy/Paste | History Copy | Templates Toolbar Btn | Responsive Tablet |
   Responsive Desktop | Desktop Hover | Desktop Sheet-as-Modal
   Requires: tokens.css, base.css, components.css
   ============================================================================= */

/* =============================================================================
   Password Screen (legacy)
   ============================================================================= */

.password-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
}

.password-card {
    background: var(--bg-surface);
    border-radius: var(--radius-xl);
    padding: var(--space-8);
    max-width: 400px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow-card);
    border: 0.5px solid var(--border-hairline);
}

.password-card h2 {
    font-size: var(--text-title2);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-2);
    letter-spacing: -0.022em;
}

.password-info {
    color: var(--cta-blue);
    font-weight: 600;
    font-size: var(--text-subhead);
    margin-bottom: var(--space-2);
}

.password-hint {
    color: var(--text-muted);
    font-size: var(--text-footnote);
    margin-bottom: var(--space-6);
}

.password-input-container {
    display: flex;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
}

.password-input-container input {
    flex: 1;
    padding: var(--space-3) var(--space-4);
    background: var(--bg-surface-2);
    border: 0.5px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: var(--text-subhead);
    font-family: var(--font-sans);
    text-align: center;
    letter-spacing: 2px;
    transition: border-color var(--transition-fast);
}

.password-input-container input:focus {
    outline: none;
    border-color: var(--cta-blue);
    box-shadow: 0 0 0 4px var(--cta-blue-light);
}

.password-input-container input.error {
    border-color: var(--color-danger);
    animation: shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes shake {
    10%, 90% { transform: translateX(-1px); }
    20%, 80% { transform: translateX(2px); }
    30%, 50%, 70% { transform: translateX(-4px); }
    40%, 60% { transform: translateX(4px); }
}

.password-input-container input::placeholder {
    color: var(--text-muted);
    letter-spacing: normal;
}

.password-toggle {
    padding: var(--space-3) var(--space-4);
    background: var(--bg-surface-2);
    border: 0.5px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: var(--text-footnote);
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    min-height: var(--touch-target-sm);
}

.password-toggle:hover {
    background: var(--bg-surface-3);
    color: var(--text-primary);
}

.password-error {
    color: var(--color-danger);
    font-size: var(--text-footnote);
    margin-bottom: var(--space-4);
}

.password-screen .submit-btn {
    margin-top: var(--space-2);
}

/* =============================================================================
   Main Form Card
   ============================================================================= */

.main-form {
    background: var(--bg-surface);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    box-shadow: var(--shadow-card);
    border: 0.5px solid var(--border-hairline);
}

header {
    text-align: center;
    margin-bottom: var(--space-6);
    padding-bottom: var(--space-5);
    border-bottom: 0.5px solid var(--border-subtle);
}

header h1 {
    font-size: var(--text-title1);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-4);
    letter-spacing: -0.022em;
}

.logo-container {
    margin-bottom: var(--space-4);
}

.header-logo {
    max-width: 120px;
    height: auto;
    opacity: 0.9;
}

.musician-info, .month-info {
    display: flex;
    justify-content: center;
    gap: var(--space-2);
    margin-bottom: var(--space-2);
    font-size: var(--text-subhead);
}

.label {
    color: var(--text-muted);
}

.value {
    color: var(--text-link);
    font-weight: 600;
}

/* =============================================================================
   Instructions & Legend
   ============================================================================= */

.instructions {
    background: var(--bg-surface-2);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    margin-bottom: var(--space-6);
}

.instructions p {
    font-size: var(--text-footnote);
    margin-bottom: var(--space-3);
    color: var(--text-secondary);
}

.legend {
    display: flex;
    gap: var(--space-4);
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-footnote);
    color: var(--text-secondary);
}

.status-dot {
    width: 14px;
    height: 14px;
    border-radius: var(--radius-xs);
}

.status-dot.available {
    background: var(--color-success);
}

.status-dot.unavailable {
    background: var(--color-danger);
}

.status-dot.partial {
    background: var(--color-warning);
}

/* =============================================================================
   Calendar
   ============================================================================= */

.calendar-container {
    background: var(--bg-surface-2);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    margin-bottom: var(--space-6);
    border: 0.5px solid var(--border-hairline);
}

.calendar-header {
    font-size: var(--text-title3);
    font-weight: 600;
    margin-bottom: var(--space-4);
    color: var(--text-primary);
    letter-spacing: -0.022em;
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-bottom: var(--space-2);
}

.calendar-weekdays div {
    text-align: center;
    font-size: var(--text-caption2);
    font-weight: 600;
    color: var(--text-muted);
    padding: var(--space-2) 0;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-surface-hover);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
    min-height: var(--touch-target);
    border: 1.5px solid transparent;
}

.calendar-day:hover {
    background: rgba(128, 128, 128, 0.14);
    transform: scale(1.04);
}

.calendar-day:active {
    transform: scale(0.96);
}

.calendar-day.empty {
    background: transparent;
    cursor: default;
}

.calendar-day.empty:hover {
    transform: none;
}

.calendar-day .day-number {
    font-size: var(--text-footnote);
    font-weight: 500;
    color: var(--text-primary);
}

.calendar-day .day-indicator {
    position: absolute;
    bottom: 4px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
}

.calendar-day.available {
    background: var(--color-success-light);
    border-color: var(--color-success);
}

.calendar-day.available .day-indicator {
    background: var(--color-success);
}

.calendar-day.unavailable {
    background: var(--color-danger-light);
    border-color: var(--color-danger);
}

.calendar-day.unavailable .day-indicator {
    background: var(--color-danger);
}

.calendar-day.partial {
    background: var(--color-warning-light);
    border-color: var(--color-warning);
}

.calendar-day.partial .day-indicator {
    background: var(--color-warning);
}

.calendar-day.has-notes::after {
    content: '';
    position: absolute;
    top: 4px;
    right: 4px;
    width: 5px;
    height: 5px;
    background: var(--cta-blue);
    border-radius: 50%;
}

/* =============================================================================
   Scheduled Events Section
   ============================================================================= */

.scheduled-events-section,
.change-requests-section {
    background: var(--bg-surface-2);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    margin-bottom: var(--space-6);
    border: 0.5px solid var(--border-hairline);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-3);
}

.section-header h2 {
    font-size: var(--text-subhead);
    font-weight: 600;
    color: var(--text-primary);
}

.events-count-badge {
    background: var(--cta-blue-light);
    color: var(--cta-blue);
    font-size: var(--text-caption1);
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-variant-numeric: tabular-nums;
}

.scheduled-events-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.empty-events,
.empty-requests {
    color: var(--text-muted);
    text-align: center;
    font-size: var(--text-footnote);
    padding: var(--space-3) 0;
}

.event-card {
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    border: 0.5px solid var(--border-hairline);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-3);
    transition: background var(--transition-fast);
}

.event-card:hover {
    background: var(--bg-surface-hover);
}

.event-card-info {
    flex: 1;
    min-width: 0;
}

.event-card-title {
    font-size: var(--text-footnote);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.event-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    font-size: var(--text-caption1);
    color: var(--text-muted);
}

.event-card-meta span {
    display: flex;
    align-items: center;
    gap: 3px;
}

.event-change-btn {
    flex-shrink: 0;
    padding: var(--space-2) var(--space-3);
    background: var(--color-warning-light);
    border: 0.5px solid rgba(255, 159, 10, 0.25);
    border-radius: var(--radius-sm);
    color: var(--color-warning);
    font-size: var(--text-caption1);
    font-weight: 500;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    min-height: 30px;
}

.event-change-btn:hover {
    background: rgba(255, 159, 10, 0.2);
}

.event-change-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.event-change-btn.has-request {
    background: var(--bg-surface-3);
    border-color: var(--border-subtle);
    color: var(--text-muted);
    cursor: default;
}

/* Calendar scheduled event indicator */
.calendar-day.has-event::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 6px;
    height: 6px;
    background: var(--cta-blue);
    border-radius: 50%;
}

.status-dot.scheduled {
    background: var(--cta-blue);
}

.status-dot.draft-event {
    background: var(--color-warning);
}

/* Draft event indicator — amber dot instead of blue */
.calendar-day.has-event.draft-event-only::before {
    background: var(--color-warning);
}

/* Draft event card badge. Note: app.js also emits .event-card-draft on the
   card container — deliberately unstyled; the draft state is conveyed by this
   badge and the amber calendar dot. */
.event-status-badge {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.05em;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    margin-right: 6px;
    vertical-align: middle;
}

.event-status-badge.draft {
    background: var(--color-warning-light);
    color: var(--color-warning-dark);
}

/* Change Requests */
.change-requests-link {
    margin-top: var(--space-3);
    border-top: 0.5px solid var(--border-hairline);
    padding-top: var(--space-3);
}

.view-requests-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    background: transparent;
    border: 0.5px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: var(--text-footnote);
    font-weight: 500;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all var(--transition-fast);
    min-height: var(--touch-target-sm);
}

.view-requests-btn:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

.pending-badge {
    background: var(--color-warning);
    color: #000;
    font-size: var(--text-caption2);
    font-weight: 700;
    padding: 1px 6px;
    border-radius: var(--radius-full);
    min-width: 18px;
    text-align: center;
}

.collapse-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-xs);
    transition: all var(--transition-fast);
}

.collapse-btn:hover {
    color: var(--text-primary);
    background: var(--bg-surface-hover);
}

.change-requests-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.request-card {
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    border: 0.5px solid var(--border-hairline);
}

.request-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-2);
}

.request-card-title {
    font-size: var(--text-footnote);
    font-weight: 500;
    color: var(--text-primary);
}

.request-status-badge {
    font-size: var(--text-caption2);
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-full);
}

.request-status-badge.pending {
    background: var(--color-warning-light);
    color: var(--color-warning);
}

.request-status-badge.approved {
    background: var(--color-success-light);
    color: var(--color-success);
}

.request-status-badge.denied {
    background: var(--color-danger-light);
    color: var(--color-danger);
}

.request-card-meta {
    font-size: var(--text-caption1);
    color: var(--text-muted);
    margin-bottom: var(--space-1);
}

.request-card-reason {
    font-size: var(--text-caption1);
    color: var(--text-secondary);
    line-height: 1.4;
}

.request-card-response {
    margin-top: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--cta-blue-light);
    border-radius: var(--radius-sm);
    font-size: var(--text-caption1);
    color: var(--text-secondary);
}

.request-card-response strong {
    color: var(--cta-blue);
    font-weight: 600;
}

/* Change Request Modal */
.change-request-event-info {
    background: var(--bg-surface-2);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    margin-bottom: var(--space-4);
    border: 0.5px solid var(--border-hairline);
}

.event-info-row {
    display: flex;
    gap: var(--space-3);
    padding: var(--space-1) 0;
    font-size: var(--text-footnote);
}

.event-info-label {
    color: var(--text-muted);
    min-width: 50px;
}

.event-info-value {
    color: var(--text-primary);
    font-weight: 500;
}

.cr-disclaimer {
    font-size: var(--text-caption1);
    color: var(--text-muted);
    margin-top: var(--space-3);
    line-height: 1.4;
}

.required {
    color: var(--color-danger);
}

/* =============================================================================
   Summary Section
   ============================================================================= */

.summary-section {
    margin-bottom: var(--space-6);
}

.summary-section h2 {
    font-size: var(--text-subhead);
    font-weight: 600;
    margin-bottom: var(--space-3);
    color: var(--text-primary);
}

.availability-summary {
    background: var(--bg-surface-2);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    max-height: 200px;
    overflow-y: auto;
    border: 0.5px solid var(--border-hairline);
}

.empty-summary {
    color: var(--text-muted);
    text-align: center;
    font-size: var(--text-footnote);
}

.summary-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: var(--space-2) 0;
    border-bottom: 0.5px solid var(--border-hairline);
    font-size: var(--text-footnote);
}

.summary-item:last-child {
    border-bottom: none;
}

.summary-date {
    font-weight: 500;
    min-width: 100px;
    color: var(--text-primary);
}

.summary-status {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
}

.summary-status .status-badge {
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: var(--text-caption2);
    font-weight: 500;
}

.summary-status .status-badge.available {
    background: var(--color-success-light);
    color: var(--color-success);
}

.summary-status .status-badge.unavailable {
    background: var(--color-danger-light);
    color: var(--color-danger);
}

.summary-status .status-badge.partial {
    background: var(--color-warning-light);
    color: var(--color-warning);
}

.summary-times {
    font-size: var(--text-caption2);
    color: var(--text-muted);
}

.summary-notes {
    font-size: var(--text-caption2);
    color: var(--cta-blue);
    font-style: italic;
}

/* =============================================================================
   Submit Section
   ============================================================================= */

.submit-section {
    text-align: center;
}

.submit-note {
    font-size: var(--text-caption1);
    color: var(--text-muted);
    margin-top: var(--space-3);
}

/* =============================================================================
   Modal - Frosted Glass
   ============================================================================= */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
    padding: var(--space-5);
}

.modal-content {
    background: var(--bg-surface);
    border: 0.5px solid var(--border-hairline);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-modal);
    animation: modal-enter 350ms var(--ease-bounce);
}

@keyframes modal-enter {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(8px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-content.small {
    max-width: 350px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-4) var(--space-5);
    border-bottom: 0.5px solid var(--border-subtle);
}

.modal-header h3 {
    font-size: var(--text-subhead);
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 22px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    width: var(--touch-target-sm);
    height: var(--touch-target-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.modal-close:hover {
    color: var(--text-primary);
    background: var(--bg-surface-hover);
}

.modal-body {
    padding: var(--space-5);
}

.modal-date {
    font-size: var(--text-subhead);
    font-weight: 600;
    color: var(--cta-blue);
    margin-bottom: var(--space-5);
    text-align: center;
}

.modal-footer {
    display: flex;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    border-top: 0.5px solid var(--border-subtle);
}

.modal-btn {
    flex: 1;
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-sm);
    font-size: var(--text-footnote);
    font-weight: 500;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all var(--transition-normal);
    min-height: var(--touch-target-sm);
}

.modal-btn.secondary {
    background: rgba(128, 128, 128, 0.12);
    backdrop-filter: blur(8px);
    border: 0.5px solid rgba(128, 128, 128, 0.2);
    color: var(--text-primary);
}

.modal-btn.secondary:hover {
    background: rgba(128, 128, 128, 0.18);
}

.modal-btn.primary {
    background: linear-gradient(180deg, #3b8df8 0%, #0071e3 100%);
    border: none;
    color: #ffffff;
    box-shadow: inset 0 0.5px 0 rgba(255,255,255,0.2);
}

.modal-btn.primary:hover:not(:disabled) {
    filter: brightness(1.1);
}

.modal-btn.primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    filter: saturate(0.5);
}

.notes-validation-msg {
    margin-top: var(--space-2);
    font-size: var(--text-caption1);
    color: var(--color-danger);
    line-height: 1.4;
}

.notes-validation-msg.hidden {
    display: none;
}

/* =============================================================================
   Time Ranges & Notes
   ============================================================================= */

.time-ranges-container label,
.notes-container label {
    display: block;
    font-size: var(--text-footnote);
    font-weight: 500;
    margin-bottom: var(--space-2);
    color: var(--text-secondary);
}

.time-range-item {
    display: flex;
    gap: var(--space-2);
    align-items: center;
    margin-bottom: var(--space-3);
}

.time-range-item input[type="time"] {
    flex: 1;
    padding: var(--space-2) var(--space-3);
    background: var(--bg-surface-2);
    border: 0.5px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: var(--text-footnote);
    font-family: var(--font-sans);
    min-height: var(--touch-target-sm);
    transition: border-color var(--transition-fast);
}

.time-range-item input[type="time"]:focus {
    outline: none;
    border-color: var(--cta-blue);
    box-shadow: 0 0 0 4px var(--cta-blue-light);
}

.time-range-item span {
    color: var(--text-muted);
    font-size: var(--text-footnote);
}

.time-range-item .remove-range {
    background: var(--color-danger-light);
    border: none;
    color: var(--color-danger);
    width: var(--touch-target-sm);
    height: var(--touch-target-sm);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 16px;
    transition: background var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.time-range-item .remove-range:hover {
    background: rgba(255, 59, 48, 0.25);
}

.add-range-btn {
    width: 100%;
    padding: var(--space-3);
    background: var(--cta-blue-light);
    border: 1px dashed rgba(0, 113, 227, 0.3);
    border-radius: var(--radius-sm);
    color: var(--cta-blue);
    font-size: var(--text-footnote);
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all var(--transition-fast);
    min-height: var(--touch-target-sm);
}

.add-range-btn:hover {
    background: rgba(0, 113, 227, 0.18);
}

/* Notes */
.notes-container {
    margin-top: var(--space-5);
}

.notes-container textarea {
    width: 100%;
    padding: var(--space-3);
    background: var(--bg-surface-2);
    border: 0.5px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: var(--text-footnote);
    font-family: var(--font-sans);
    resize: vertical;
    min-height: 80px;
    transition: border-color var(--transition-fast);
    line-height: 1.47;
}

.notes-container textarea:focus {
    outline: none;
    border-color: var(--cta-blue);
    box-shadow: 0 0 0 4px var(--cta-blue-light);
}

.notes-container textarea::placeholder {
    color: var(--text-muted);
}

/* =============================================================================
   Tool Selector - Segmented Control Style
   ============================================================================= */

.tool-selector {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3);
    margin-top: var(--space-4);
    padding: var(--space-3);
    background: var(--bg-surface-2);
    border-radius: var(--radius-md);
    border: 0.5px solid var(--border-hairline);
    overflow: hidden;
}

.tool-label {
    font-size: var(--text-footnote);
    color: var(--text-muted);
    white-space: nowrap;
    font-weight: 500;
}

.tool-buttons {
    display: flex;
    gap: 2px;
    background: rgba(128, 128, 128, 0.1);
    border-radius: var(--radius-sm);
    padding: 2px;
}

.tool-btn {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-2) var(--space-3);
    background: transparent;
    border: none;
    border-radius: var(--radius-xs);
    color: var(--text-secondary);
    font-size: var(--text-footnote);
    font-family: var(--font-sans);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-normal);
    min-height: 32px;
}

.tool-btn:hover {
    background: rgba(128, 128, 128, 0.08);
    color: var(--text-primary);
}

.tool-btn.active {
    background: var(--bg-surface);
    color: var(--text-primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
}

.tool-btn .tool-icon {
    font-size: var(--text-footnote);
}

.select-all-btn {
    padding: var(--space-2) var(--space-4);
    background: linear-gradient(180deg, #40c463 0%, #2ea44f 100%);
    border: none;
    border-radius: var(--radius-sm);
    color: #ffffff;
    font-size: var(--text-footnote);
    font-weight: 600;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all var(--transition-normal);
    white-space: nowrap;
    min-height: var(--touch-target-sm);
    box-shadow: inset 0 0.5px 0 rgba(255,255,255,0.2);
}

.select-all-btn:hover {
    filter: brightness(1.1);
}

.select-all-btn:active {
    transform: scale(0.98);
}

.bulk-action-buttons {
    display: flex;
    gap: var(--space-2);
    margin-top: 0;
    flex-basis: 100%;
}

.clear-all-btn {
    padding: var(--space-2) var(--space-4);
    background: rgba(128, 128, 128, 0.12);
    border: 0.5px solid rgba(128, 128, 128, 0.2);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: var(--text-footnote);
    font-weight: 500;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all var(--transition-normal);
    white-space: nowrap;
    min-height: var(--touch-target-sm);
}

.clear-all-btn:hover {
    background: var(--color-danger-light);
    border-color: rgba(255, 59, 48, 0.3);
    color: var(--color-danger);
}

.tool-btn .status-dot {
    width: 8px;
    height: 8px;
}

/* Tool active cursor on calendar */
.calendar-days.tool-active .calendar-day:not(.empty) {
    cursor: crosshair;
}

.calendar-days.tool-active .calendar-day:not(.empty):hover {
    transform: scale(1.04);
}

/* =============================================================================
   Progress Bar
   ============================================================================= */

.progress-bar-container {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-top: var(--space-4);
}

.progress-bar {
    flex: 1;
    height: 6px;
    background: var(--bg-surface-3);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--cta-blue) 0%, var(--color-success) 100%);
    border-radius: 3px;
    transition: width var(--transition-slow);
    width: 0%;
}

.progress-text {
    font-size: var(--text-caption1);
    color: var(--text-muted);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* =============================================================================
   Status Selection Popup
   ============================================================================= */

.status-popup {
    position: fixed;
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: var(--z-popup);
    min-width: 180px;
    overflow: hidden;
    border: 0.5px solid var(--border-subtle);
    animation: modal-enter 200ms var(--ease-bounce);
}

.status-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-3) var(--space-4);
    border-bottom: 0.5px solid var(--border-subtle);
}

.status-popup-header span {
    font-size: var(--text-footnote);
    font-weight: 600;
    color: var(--text-primary);
}

.popup-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 16px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-xs);
    transition: all var(--transition-fast);
}

.popup-close:hover {
    color: var(--text-primary);
    background: var(--bg-surface-hover);
}

.status-popup-options {
    display: flex;
    flex-direction: column;
}

.status-option {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: var(--text-footnote);
    font-family: var(--font-sans);
    cursor: pointer;
    transition: background var(--transition-fast);
    text-align: left;
    min-height: var(--touch-target);
}

.status-option:hover {
    background: var(--bg-surface-hover);
}

.status-option.available:hover {
    background: var(--color-success-light);
}

.status-option.unavailable:hover {
    background: var(--color-danger-light);
}

.status-option.partial:hover {
    background: var(--color-warning-light);
}

.status-option.clear:hover {
    background: var(--bg-surface-hover);
}

.status-dot.clear {
    background: var(--text-muted);
}

/* =============================================================================
   Summary Delete Button
   ============================================================================= */

.summary-item-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex: 1;
}

.summary-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    padding: 0 0 0 var(--space-2);
    line-height: 1;
    transition: color var(--transition-fast);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-xs);
}

.summary-delete:hover {
    color: var(--color-danger);
    background: var(--color-danger-light);
}

/* =============================================================================
   Validation Warning
   ============================================================================= */

.validation-warning {
    background: var(--color-warning-light);
    border: 1px solid rgba(255, 159, 10, 0.25);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    margin-bottom: var(--space-4);
    font-size: var(--text-footnote);
    color: var(--color-warning);
}

.validation-warning ul {
    margin: var(--space-2) 0 0 var(--space-5);
}

.validation-warning li {
    margin: var(--space-1) 0;
}

/* Incomplete Partial Indicator */
.calendar-day.partial.incomplete {
    animation: pulse-warning 2s ease-in-out infinite;
}

@keyframes pulse-warning {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(255, 159, 10, 0.3);
    }
    50% {
        box-shadow: 0 0 0 5px rgba(255, 159, 10, 0);
    }
}

/* =============================================================================
   Submission Loading Overlay
   ============================================================================= */

.submission-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-overlay);
}

.submission-overlay-content {
    text-align: center;
    padding: var(--space-10);
    max-width: 400px;
}

.submission-overlay-content .spinner.large {
    width: 48px;
    height: 48px;
    border-width: 3px;
    margin: 0 auto var(--space-8);
}

.submission-overlay-content h2 {
    color: var(--text-primary);
    font-size: var(--text-title2);
    margin-bottom: var(--space-4);
    font-weight: 600;
    letter-spacing: -0.022em;
}

.submission-message {
    color: var(--text-secondary);
    font-size: var(--text-subhead);
    margin-bottom: var(--space-5);
}

.submission-warning {
    color: var(--color-warning);
    font-size: var(--text-footnote);
    font-weight: 500;
    padding: var(--space-3) var(--space-5);
    background: var(--color-warning-light);
    border: 1px solid rgba(255, 159, 10, 0.25);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-6);
}

.submission-progress {
    margin-top: var(--space-5);
}

.progress-dots {
    display: flex;
    justify-content: center;
    gap: var(--space-2);
}

.progress-dots .dot {
    width: 8px;
    height: 8px;
    background: var(--cta-blue);
    border-radius: 50%;
    animation: dotPulse 1.4s ease-in-out infinite;
}

.progress-dots .dot:nth-child(1) { animation-delay: 0s; }
.progress-dots .dot:nth-child(2) { animation-delay: 0.2s; }
.progress-dots .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.4;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* =============================================================================
   Responsive - Mobile First
   ============================================================================= */

@media (max-width: 480px) {
    .container {
        padding: var(--space-3);
    }

    .main-form {
        padding: var(--space-4);
    }

    header h1 {
        font-size: var(--text-title3);
    }

    .legend {
        flex-direction: column;
        gap: var(--space-2);
    }

    .calendar-day {
        min-height: 40px;
    }

    .calendar-day .day-number {
        font-size: var(--text-caption1);
    }

    .tool-selector {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-2);
    }

    .tool-buttons {
        width: 100%;
        flex-wrap: wrap; /* five tools don't fit one row on phones — wrap, don't clip */
    }

    .tool-btn {
        /* 30% basis fits three per row; five tools wrap into a 3+2 layout */
        flex: 1 1 30%;
        justify-content: center;
        padding: var(--space-2);
    }

    .bulk-action-buttons {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .select-all-btn,
    .clear-all-btn {
        flex: 1;
        padding: var(--space-3) var(--space-4);
    }

    .read-only-content {
        flex-wrap: wrap;
    }

    .back-to-current-btn {
        margin-left: 0;
        margin-top: var(--space-2);
        width: 100%;
        text-align: center;
    }
}

/* Very small phones (<=360px): let calendar cells shrink below the 40px floor
   so seven columns fit without horizontal scroll */
@media (max-width: 360px) {
    .calendar-day {
        min-height: 0;
    }

    .calendar-days,
    .calendar-weekdays {
        gap: 3px;
    }
}

/* =============================================================================
   Edit Mode Banner
   ============================================================================= */

.edit-mode-banner {
    background: var(--cta-blue-light);
    border: 0.5px solid rgba(10, 132, 255, 0.25);
    border-radius: var(--radius-lg);
    padding: var(--space-3) var(--space-4);
    margin-bottom: var(--space-4);
}

.edit-mode-content {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
}

.edit-mode-icon {
    font-size: 18px;
    line-height: 1;
    flex-shrink: 0;
    margin-top: 1px;
}

.edit-mode-content strong {
    display: block;
    font-size: var(--text-footnote);
    font-weight: 600;
    color: var(--cta-blue);
    margin-bottom: 2px;
}

.edit-mode-content p {
    font-size: var(--text-caption1);
    color: var(--text-secondary);
    line-height: 1.4;
    margin: 0;
}

/* =============================================================================
   Month Navigation
   ============================================================================= */

/* Second .calendar-header definition is intentional: adds flex layout for the
   month-nav buttons on top of the typography rules in the Calendar section.
   Do not merge the two blocks — later one must win for the nav layout. */
.calendar-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-4);
}

.month-nav-btn {
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-full);
    transition: all var(--transition-fast);
    min-width: var(--touch-target-sm);
    min-height: var(--touch-target-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.month-nav-btn:hover:not(:disabled) {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

.month-nav-btn:active:not(:disabled) {
    transform: scale(0.92);
}

.month-nav-btn:disabled {
    opacity: 0.2;
    cursor: default;
}

/* =============================================================================
   Read-Only Banner
   ============================================================================= */

.read-only-banner {
    background: rgba(113, 113, 122, 0.12);
    border: 0.5px solid rgba(113, 113, 122, 0.25);
    border-radius: var(--radius-lg);
    padding: var(--space-3) var(--space-4);
    margin-bottom: var(--space-4);
}

.read-only-content {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.read-only-icon {
    font-size: 18px;
    line-height: 1;
    flex-shrink: 0;
}

.read-only-content strong {
    display: block;
    font-size: var(--text-footnote);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1px;
}

.read-only-content p {
    font-size: var(--text-caption1);
    color: var(--text-muted);
    line-height: 1.4;
    margin: 0;
}

.back-to-current-btn {
    margin-left: auto;
    flex-shrink: 0;
    padding: var(--space-2) var(--space-3);
    background: var(--cta-blue-light);
    border: 0.5px solid rgba(0, 113, 227, 0.25);
    border-radius: var(--radius-sm);
    color: var(--cta-blue);
    font-size: var(--text-caption1);
    font-weight: 600;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.back-to-current-btn:hover {
    background: rgba(0, 113, 227, 0.2);
}

/* =============================================================================
   Read-Only Calendar State
   ============================================================================= */

.calendar-days.read-only .calendar-day:not(.empty) {
    cursor: default;
    opacity: 0.85;
}

.calendar-days.read-only .calendar-day:not(.empty):hover {
    transform: none;
    background: var(--bg-surface-hover);
}

.calendar-days.read-only .calendar-day.available:hover {
    background: var(--color-success-light);
}

.calendar-days.read-only .calendar-day.unavailable:hover {
    background: var(--color-danger-light);
}

.calendar-days.read-only .calendar-day.partial:hover {
    background: var(--color-warning-light);
}

/* =============================================================================
   Submission History Section
   ============================================================================= */

.submission-history-section {
    background: var(--bg-surface-2);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    margin-top: var(--space-4);
    border: 0.5px solid var(--border-hairline);
}

.submission-history-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.empty-history {
    color: var(--text-muted);
    text-align: center;
    font-size: var(--text-footnote);
    padding: var(--space-3) 0;
}

.history-card {
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    border: 0.5px solid var(--border-hairline);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.history-card:hover {
    background: var(--bg-surface-hover);
}

.history-card.active {
    border-color: var(--cta-blue);
    background: var(--cta-blue-light);
}

.history-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-1);
}

.history-card-month {
    font-size: var(--text-footnote);
    font-weight: 600;
    color: var(--text-primary);
}

.history-card-date {
    font-size: var(--text-caption2);
    color: var(--text-muted);
}

.history-card-stats {
    display: flex;
    gap: var(--space-3);
    font-size: var(--text-caption1);
    color: var(--text-secondary);
}

.history-stat {
    display: flex;
    align-items: center;
    gap: 4px;
}

.history-stat .status-dot {
    width: 6px;
    height: 6px;
}

/* =============================================================================
   Calendar Scheduled Date Styles (Edit Mode)
   ============================================================================= */

.calendar-day.has-event.requires-request {
    border-left: 2px solid var(--cta-blue);
}

.calendar-day.has-event.draft-event-only.requires-request {
    border-left: 2px solid var(--color-warning);
}

.calendar-day.has-event .event-indicator-label {
    position: absolute;
    bottom: 1px;
    left: 0;
    right: 0;
    font-size: 8px;
    text-align: center;
    color: var(--cta-blue);
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* =============================================================================
   Back to Edit Button (Success Screen)
   ============================================================================= */

.back-to-edit-btn {
    margin-top: var(--space-5);
    padding: var(--space-3) var(--space-6);
    background: var(--cta-blue);
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    font-size: var(--text-subhead);
    font-weight: 600;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all var(--transition-fast);
    min-height: var(--touch-target);
}

.back-to-edit-btn:hover {
    background: var(--cta-blue-hover);
}

.back-to-edit-btn:active {
    transform: scale(0.98);
}

/* =============================================================================
   Bottom Sheet Component
   ============================================================================= */

.bottom-sheet-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: var(--z-sheet-overlay);
    opacity: 0;
    visibility: hidden;
    transition: opacity 300ms var(--ease-out), visibility 300ms var(--ease-out);
    -webkit-tap-highlight-color: transparent;
}

.bottom-sheet-overlay.active {
    opacity: 1;
    visibility: visible;
}

.bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: var(--z-sheet);
    background: var(--bg-surface);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.4);
    max-height: 85vh;
    transform: translateY(100%);
    transition: transform 350ms var(--ease-out);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    -webkit-overflow-scrolling: touch;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.bottom-sheet.active {
    transform: translateY(0);
}

.bottom-sheet-handle {
    display: flex;
    justify-content: center;
    padding: var(--space-3) 0 var(--space-2);
    cursor: grab;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.bottom-sheet-handle::after {
    content: '';
    width: 36px;
    height: 5px;
    background: var(--bg-surface-3);
    border-radius: var(--radius-full);
}

.bottom-sheet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 var(--space-5) var(--space-3);
    flex-shrink: 0;
}

.bottom-sheet-header h3 {
    font-size: var(--text-title3);
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.022em;
}

.bottom-sheet-close {
    background: var(--bg-surface-2);
    border: none;
    color: var(--text-muted);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    cursor: pointer;
    transition: all var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}

.bottom-sheet-close:active {
    background: var(--bg-surface-3);
    color: var(--text-primary);
}

.bottom-sheet-body {
    padding: 0 var(--space-5) var(--space-5);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
    min-height: 0;
}

.bottom-sheet-footer {
    padding: var(--space-4) var(--space-5);
    border-top: 0.5px solid var(--border-subtle);
    flex-shrink: 0;
    display: flex;
    gap: var(--space-3);
    padding-bottom: calc(var(--space-4) + env(safe-area-inset-bottom, 0px));
}

.bottom-sheet-footer .sheet-btn {
    flex: 1;
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-sm);
    font-size: var(--text-subhead);
    font-weight: 600;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all var(--transition-normal);
    min-height: var(--touch-target);
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.sheet-btn.secondary {
    background: rgba(128, 128, 128, 0.12);
    border: 0.5px solid rgba(128, 128, 128, 0.2);
    color: var(--text-primary);
}

.sheet-btn.secondary:active {
    background: rgba(128, 128, 128, 0.2);
}

.sheet-btn.primary {
    background: linear-gradient(180deg, #3b8df8 0%, #0071e3 100%);
    border: none;
    color: #ffffff;
    box-shadow: inset 0 0.5px 0 rgba(255,255,255,0.2), 0 1px 3px rgba(0,0,0,0.2);
}

.sheet-btn.primary:active {
    filter: brightness(0.95);
    transform: scale(0.98);
}

.sheet-btn.primary:disabled {
    background: var(--bg-surface-3);
    color: var(--text-muted);
    cursor: not-allowed;
    box-shadow: none;
}

.sheet-btn.danger {
    background: var(--color-danger-light);
    border: 0.5px solid rgba(255, 59, 48, 0.25);
    color: var(--color-danger);
}

.sheet-btn.danger:active {
    background: rgba(255, 59, 48, 0.25);
}

/* =============================================================================
   Copy-from-Month Bottom Sheet
   ============================================================================= */

.copy-month-preview {
    background: var(--bg-surface-2);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    margin-bottom: var(--space-4);
    border: 0.5px solid var(--border-hairline);
    text-align: center;
}

.copy-month-name {
    font-size: var(--text-title3);
    font-weight: 600;
    color: var(--cta-blue);
    margin-bottom: var(--space-2);
}

.copy-month-desc {
    font-size: var(--text-footnote);
    color: var(--text-secondary);
    line-height: 1.5;
}

/* =============================================================================
   Save Template Bottom Sheet
   ============================================================================= */

.template-name-input {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    background: var(--bg-surface-2);
    border: 0.5px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: var(--text-subhead);
    font-family: var(--font-sans);
    min-height: var(--touch-target);
    transition: border-color var(--transition-fast);
    margin-bottom: var(--space-4);
}

.template-name-input:focus {
    outline: none;
    border-color: var(--cta-blue);
    box-shadow: 0 0 0 4px var(--cta-blue-light);
}

.template-name-input::placeholder {
    color: var(--text-muted);
}

.template-default-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) 0;
    margin-bottom: var(--space-4);
}

.template-default-toggle label {
    font-size: var(--text-footnote);
    color: var(--text-secondary);
    font-weight: 500;
}

.toggle-switch {
    position: relative;
    width: 51px;
    height: 31px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-surface-3);
    border-radius: var(--radius-full);
    transition: background var(--transition-normal);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 27px;
    height: 27px;
    left: 2px;
    bottom: 2px;
    background: #ffffff;
    border-radius: 50%;
    transition: transform var(--transition-normal);
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--color-success);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

.template-pattern-preview {
    background: var(--bg-surface-2);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    border: 0.5px solid var(--border-hairline);
}

.template-pattern-preview h4 {
    font-size: var(--text-caption1);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-2);
}

.pattern-day {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) 0;
    font-size: var(--text-footnote);
    color: var(--text-secondary);
}

.pattern-day .day-label {
    min-width: 40px;
    font-weight: 600;
    color: var(--text-primary);
}

.pattern-day .status-badge {
    padding: 1px 6px;
    border-radius: var(--radius-full);
    font-size: var(--text-caption2);
    font-weight: 500;
}

/* =============================================================================
   Templates List Bottom Sheet
   ============================================================================= */

.template-list-empty {
    text-align: center;
    padding: var(--space-8) var(--space-4);
    color: var(--text-muted);
}

.template-list-empty-icon {
    font-size: 48px;
    margin-bottom: var(--space-3);
    opacity: 0.4;
}

.template-list-empty p {
    font-size: var(--text-footnote);
    line-height: 1.5;
}

.template-list-item {
    background: var(--bg-surface-2);
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-4);
    margin-bottom: var(--space-2);
    border: 0.5px solid var(--border-hairline);
    cursor: pointer;
    transition: all var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}

.template-list-item:active {
    background: var(--bg-surface-3);
}

.template-list-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-1);
}

.template-list-item-name {
    font-size: var(--text-subhead);
    font-weight: 600;
    color: var(--text-primary);
}

.template-default-badge {
    font-size: var(--text-caption2);
    font-weight: 600;
    padding: 1px 6px;
    border-radius: var(--radius-full);
    background: var(--cta-blue-light);
    color: var(--cta-blue);
}

.template-list-item-pattern {
    font-size: var(--text-caption1);
    color: var(--text-muted);
    line-height: 1.4;
}

.template-list-item .delete-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    min-width: 36px;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: color var(--transition-fast), background var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}

.template-list-item .delete-btn:hover,
.template-list-item .delete-btn:active {
    color: var(--color-danger);
    background: rgba(255, 59, 48, 0.12);
}

.template-list-divider {
    display: flex;
    align-items: center;
    margin: var(--space-4) 0;
    color: var(--text-muted);
    font-size: var(--text-caption1);
    font-weight: 500;
}

.template-list-divider::before,
.template-list-divider::after {
    content: '';
    flex: 1;
    height: 0.5px;
    background: var(--border-subtle);
}

.template-list-divider span {
    padding: 0 var(--space-3);
}

.copy-past-month-btn {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    background: var(--bg-surface-2);
    border: 0.5px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: var(--text-footnote);
    font-weight: 500;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all var(--transition-fast);
    min-height: var(--touch-target);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    -webkit-tap-highlight-color: transparent;
}

.copy-past-month-btn:active {
    background: var(--bg-surface-3);
    color: var(--text-primary);
}

/* =============================================================================
   Cell Copy/Paste Mode
   ============================================================================= */

/* Paste mode source cell */
.calendar-day.paste-source {
    border: 2px dashed var(--cta-blue) !important;
    box-shadow: 0 0 0 3px var(--cta-blue-light);
}

/* Paste mode target cells */
.calendar-days.paste-mode .calendar-day:not(.empty):not(.paste-source) {
    cursor: cell;
}

.calendar-days.paste-mode .calendar-day:not(.empty):not(.paste-source):active {
    transform: scale(0.92);
}

/* Paste flash animation */
.calendar-day.paste-flash {
    animation: paste-flash 500ms var(--ease-out);
}

@keyframes paste-flash {
    0% {
        box-shadow: 0 0 0 0 var(--cta-blue-glow);
    }
    50% {
        box-shadow: 0 0 0 8px var(--cta-blue-glow);
    }
    100% {
        box-shadow: 0 0 0 0 transparent;
    }
}

/* Floating Paste Toolbar */
.paste-toolbar {
    position: fixed;
    bottom: calc(var(--space-6) + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    z-index: var(--z-toolbar);
    background: var(--bg-surface);
    border: 0.5px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: var(--space-3) var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    width: calc(100% - var(--space-8));
    max-width: 400px;
    opacity: 0;
    visibility: hidden;
    transition: transform 300ms var(--ease-out), opacity 300ms var(--ease-out), visibility 300ms var(--ease-out);
}

.paste-toolbar.active {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    visibility: visible;
}

.paste-toolbar-info {
    font-size: var(--text-footnote);
    color: var(--text-secondary);
    text-align: center;
    padding-bottom: var(--space-2);
    border-bottom: 0.5px solid var(--border-hairline);
}

.paste-toolbar-info strong {
    color: var(--cta-blue);
}

.paste-toolbar-actions {
    display: flex;
    gap: var(--space-2);
}

.paste-toolbar-actions button {
    flex: 1;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    font-size: var(--text-footnote);
    font-weight: 500;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all var(--transition-fast);
    min-height: var(--touch-target-sm);
    -webkit-tap-highlight-color: transparent;
    border: none;
}

.paste-apply-all-btn {
    background: var(--cta-blue-light);
    color: var(--cta-blue);
}

.paste-apply-all-btn:active {
    background: rgba(0, 113, 227, 0.2);
}

.paste-done-btn {
    background: var(--color-success-light);
    color: var(--color-success);
}

.paste-done-btn:active {
    background: rgba(52, 199, 89, 0.2);
}

/* =============================================================================
   History Card Copy Button
   ============================================================================= */

.history-card-actions {
    margin-top: var(--space-2);
    padding-top: var(--space-2);
    border-top: 0.5px solid var(--border-hairline);
}

.history-copy-btn {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    background: var(--cta-blue-light);
    border: 0.5px solid rgba(0, 113, 227, 0.2);
    border-radius: var(--radius-sm);
    color: var(--cta-blue);
    font-size: var(--text-caption1);
    font-weight: 600;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all var(--transition-fast);
    min-height: var(--touch-target-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-1);
    -webkit-tap-highlight-color: transparent;
}

.history-copy-btn:active {
    background: rgba(0, 113, 227, 0.2);
}

/* =============================================================================
   Templates Button in Toolbar
   ============================================================================= */

.templates-toolbar-btn {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-2) var(--space-3);
    background: rgba(128, 128, 128, 0.12);
    border: 0.5px solid rgba(128, 128, 128, 0.2);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: var(--text-footnote);
    font-weight: 500;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    min-height: var(--touch-target-sm);
    -webkit-tap-highlight-color: transparent;
}

.templates-toolbar-btn:active {
    background: rgba(128, 128, 128, 0.2);
    color: var(--text-primary);
}

/* Save Template Button */
.save-template-btn {
    width: 100%;
    padding: var(--space-3) var(--space-5);
    background: rgba(128, 128, 128, 0.12);
    border: 0.5px solid rgba(128, 128, 128, 0.2);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: var(--text-footnote);
    font-weight: 500;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all var(--transition-fast);
    min-height: var(--touch-target);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    margin-top: var(--space-3);
    -webkit-tap-highlight-color: transparent;
}

.save-template-btn:active {
    background: rgba(128, 128, 128, 0.2);
    color: var(--text-primary);
}

/* =============================================================================
   Responsive — Tablet (481px–768px)
   ============================================================================= */

@media (min-width: 481px) {
    /* Container: more breathing room on tablet */
    .container {
        max-width: 700px;
        padding: var(--space-6);
    }

    /* Calendar: slightly larger cells */
    .calendar-day {
        min-height: 48px;
    }

    .calendar-day .day-number {
        font-size: var(--text-footnote);
    }

    /* Calendar weekday labels: full names on tablet+ */
    .calendar-weekdays div {
        font-size: var(--text-caption1);
    }

    /* Tool selector: single row with more room */
    .tool-selector {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
    }

    /* Bulk action buttons: inline row */
    .bulk-action-buttons {
        flex-basis: auto;
    }

    /* Modal: slightly wider */
    .modal-content {
        max-width: 440px;
    }

    /* Main form: more padding */
    .main-form {
        padding: var(--space-8);
    }

    /* Header: larger title */
    header h1 {
        font-size: var(--text-title1);
    }

    /* Summary: expand scrollable area */
    .availability-summary {
        max-height: 280px;
    }
}

/* =============================================================================
   Responsive — Desktop (769px+)
   ============================================================================= */

@media (min-width: 769px) {
    /* Main form container: wide layout */
    .container {
        max-width: 900px;
        padding: var(--space-8);
    }

    /* Main form card */
    .main-form {
        padding: var(--space-10);
    }

    /* Header layout: larger font, more bottom spacing */
    header {
        margin-bottom: var(--space-8);
    }

    header h1 {
        font-size: var(--text-title1);
    }

    /* Calendar: bigger cells with more padding */
    .calendar-container {
        padding: var(--space-6);
    }

    .calendar-days {
        gap: 6px;
    }

    .calendar-weekdays {
        gap: 6px;
    }

    .calendar-day {
        min-height: 56px;
        border-radius: var(--radius-md);
    }

    .calendar-day .day-number {
        font-size: var(--text-subhead);
    }

    .calendar-day .day-indicator {
        width: 6px;
        height: 6px;
    }

    /* Tool selector: full horizontal row on desktop */
    .tool-selector {
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        gap: var(--space-4);
        padding: var(--space-4);
    }

    .tool-label {
        font-size: var(--text-footnote);
        white-space: nowrap;
    }

    .tool-buttons {
        flex-shrink: 0;
    }

    .tool-btn {
        padding: var(--space-2) var(--space-4);
        font-size: var(--text-footnote);
        gap: var(--space-2);
    }

    /* Bulk action buttons: inline with tool row */
    .bulk-action-buttons {
        flex-basis: auto;
        margin-top: 0;
        flex: 1;
        justify-content: flex-end;
    }

    /* Scheduled events: 2-column grid when there are many */
    .scheduled-events-list {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-3);
    }

    /* Change requests: also 2-column */
    .change-requests-list {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-3);
    }

    /* Summary: taller scrollable area */
    .availability-summary {
        max-height: 360px;
    }

    /* Modals: wider on desktop */
    .modal-content {
        max-width: 500px;
    }

    .modal-content.small {
        max-width: 420px;
    }

    /* Submit button: centered, not full-width */
    .submit-btn {
        width: auto;
        min-width: 260px;
        padding: var(--space-3) var(--space-10);
    }

    .submit-section {
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .save-template-btn {
        width: auto;
        min-width: 260px;
        padding: var(--space-3) var(--space-8);
    }

    /* Progress bar: more compact */
    .progress-bar-container {
        margin-top: var(--space-5);
    }

    /* Section cards: more padding */
    .scheduled-events-section,
    .change-requests-section,
    .submission-history-section {
        padding: var(--space-6);
    }

    /* Paste toolbar: slightly wider */
    .paste-toolbar {
        max-width: 480px;
    }
}

/* =============================================================================
   Desktop Hover States — pointer devices only
   ============================================================================= */

@media (hover: hover) and (min-width: 769px) {
    /* Calendar day hover: subtle lift on desktop */
    .calendar-day:not(.empty):hover {
        background: rgba(128, 128, 128, 0.18);
        transform: scale(1.03);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    }

    /* Status-colored hover states on desktop */
    .calendar-day.available:hover {
        background: rgba(52, 199, 89, 0.2);
    }

    .calendar-day.unavailable:hover {
        background: rgba(255, 59, 48, 0.2);
    }

    .calendar-day.partial:hover {
        background: rgba(255, 159, 10, 0.2);
    }

    /* Tool buttons: more visible hover */
    .tool-btn:hover {
        background: rgba(128, 128, 128, 0.12);
        color: var(--text-primary);
    }

    /* Template list item hover */
    .template-list-item:hover {
        background: var(--bg-surface-3);
        border-color: var(--border-color);
    }

    /* History card hover */
    .history-card:hover {
        background: var(--bg-surface-hover);
        border-color: var(--border-color);
    }

    /* Buttons: hover state */
    .copy-past-month-btn:hover {
        background: var(--bg-surface-3);
        color: var(--text-primary);
    }

    .templates-toolbar-btn:hover {
        background: rgba(128, 128, 128, 0.18);
        color: var(--text-primary);
    }

    .save-template-btn:hover {
        background: rgba(128, 128, 128, 0.18);
        color: var(--text-primary);
    }

    .history-copy-btn:hover {
        background: rgba(0, 113, 227, 0.2);
    }
}

/* =============================================================================
   Desktop — Bottom Sheet as Modal (non-hover fallback for keyboard/pointer)
   ============================================================================= */

@media (min-width: 769px) {
    /* Ensure overlay covers full viewport for modal behavior */
    .bottom-sheet-overlay {
        background: rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(16px) saturate(180%);
        -webkit-backdrop-filter: blur(16px) saturate(180%);
    }

    /* Bottom sheet: centered modal layout */
    .bottom-sheet {
        top: 50%;
        bottom: auto;
        left: 50%;
        right: auto;
        width: calc(100% - var(--space-8));
        max-width: 520px;
        max-height: 80vh;
        border-radius: var(--radius-xl);
        transform: translate(-50%, calc(-50% + 20px));
        transition: transform 350ms var(--ease-out), opacity 350ms var(--ease-out), visibility 350ms var(--ease-out);
        opacity: 0;
        visibility: hidden;
    }

    .bottom-sheet.active {
        transform: translate(-50%, -50%);
        opacity: 1;
        visibility: visible;
    }

    /* Hide mobile drag handle on desktop */
    .bottom-sheet-handle {
        display: none;
    }

    /* Bottom sheet footer: no safe-area padding on desktop */
    .bottom-sheet-footer {
        padding-bottom: var(--space-4);
    }

    /* Sheet header: slightly more padding */
    .bottom-sheet-header {
        padding: var(--space-4) var(--space-6) var(--space-3);
    }

    .bottom-sheet-body {
        padding: 0 var(--space-6) var(--space-6);
    }

    .bottom-sheet-footer {
        padding: var(--space-4) var(--space-6);
    }
}

/* =============================================================================
   Desktop Two-Column Layout (1024px+)
   #main-form becomes a grid: full-width header + banners, calendar column,
   sticky rail (.form-rail wraps the adjacent summary + submit sections).
   DOM order is unchanged; rows are assigned explicitly so hidden sections
   (display:none) collapse without leaving grid holes (row-gap stays 0 —
   vertical rhythm comes from the sections' own margins).
   ============================================================================= */

@media (min-width: 1024px) {
    .container {
        max-width: 1240px;
    }

    .main-form {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 380px;
        column-gap: var(--space-8);
        row-gap: 0;
        align-items: start;
    }

    .main-form > header {
        grid-column: 1 / -1;
        grid-row: 1;
    }

    /* Banners surface at the top, full width (mobile keeps source order) */
    .edit-mode-banner {
        grid-column: 1 / -1;
        grid-row: 2;
    }

    .read-only-banner {
        grid-column: 1 / -1;
        grid-row: 3;
    }

    .instructions {
        grid-column: 1;
        grid-row: 4;
    }

    .calendar-container {
        grid-column: 1;
        grid-row: 5;
    }

    .scheduled-events-section {
        grid-column: 1;
        grid-row: 6;
    }

    .change-requests-section {
        grid-column: 1;
        grid-row: 7;
    }

    /* Sticky rail: summary + submit stay in view while scrolling the calendar.
       Spans the content rows so its height never stretches a single row. */
    .form-rail {
        grid-column: 2;
        grid-row: 4 / 8;
        align-self: start;
        position: sticky;
        top: var(--space-6);
        max-height: calc(100vh - var(--space-12));
        overflow-y: auto;
    }

    .submission-history-section {
        grid-column: 1 / -1;
        grid-row: 8;
    }

    /* Rail content: full-width actions, calmer scroll area */
    .form-rail .submit-btn,
    .form-rail .save-template-btn {
        width: 100%;
    }

    .form-rail .availability-summary {
        max-height: none;
    }

    /* Tool selector: the column is narrower than the 769px single-column
       layout assumed — let the bulk actions wrap to their own row */
    .tool-selector {
        flex-wrap: wrap;
    }

    .bulk-action-buttons {
        justify-content: flex-start;
    }

    /* Calendar: larger grid in the wide column */
    .calendar-days,
    .calendar-weekdays {
        gap: 8px;
    }

    .calendar-day {
        min-height: 64px;
    }

    /* Modals: a touch wider on large screens */
    .modal-content {
        max-width: 540px;
    }

    /* Toasts: top-right on desktop (mobile keeps top-center) */
    .toast-container {
        left: auto;
        right: var(--space-6);
        transform: none;
        width: 380px;
        align-items: stretch;
    }
}
