:root {
    --ink: #1f2b26;
    --muted: #6d7771;
    --line: #e7e9e6;
    --surface: #ffffff;
    --wash: #f5f6f2;
    --accent: #667b68;
    --accent-dark: #3f5546;
    --accent-soft: #e8eee7;
    --warm: #c99d74;
    --danger: #9e5b58;
    --shadow: 0 14px 40px rgba(31,43,38,.08);
}

* { box-sizing: border-box; }
html { font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--ink); background: var(--wash); }
body { margin: 0; }
button, a { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.shell { min-height: 100vh; }
.topbar { height: 76px; padding: 0 4vw; display: flex; align-items: center; justify-content: space-between; background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; backdrop-filter: blur(12px); }
.brand { display: flex; gap: 12px; align-items: center; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: var(--ink); color: white; font-family: Georgia, serif; font-size: 21px; }
.brand strong, .brand small { display: block; }
.brand small { color: var(--muted); font-size: 12px; margin-top: 1px; }
nav { display: flex; gap: 24px; font-size: 14px; }
nav a:hover { color: var(--accent-dark); }
main { width: min(1500px, 94vw); margin: 0 auto; padding: 48px 0 80px; }

.hero-row, .admin-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 32px; margin-bottom: 32px; }
.eyebrow { color: var(--accent); text-transform: uppercase; letter-spacing: .16em; font-weight: 700; font-size: 12px; margin: 0 0 10px; }
h1 { font-family: Georgia, "Times New Roman", serif; font-size: clamp(34px, 4vw, 58px); font-weight: 500; letter-spacing: -.03em; margin: 0; }
h1:focus { outline: none; }
.intro { color: var(--muted); font-size: 16px; margin: 12px 0 0; }
.user-pill { display: flex; align-items: center; gap: 10px; padding: 9px 14px 9px 9px; border: 1px solid var(--line); background: white; border-radius: 999px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-dark); font-weight: 700; }
.user-pill small, .user-pill strong { display: block; }
.user-pill small { color: var(--muted); font-size: 10px; }
.user-pill strong { font-size: 13px; margin-top: 1px; }

.schedule-shell { background: var(--surface); border-radius: 22px; box-shadow: var(--shadow); overflow: hidden; }
.week-picker { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 20px; border-bottom: 1px solid var(--line); }
.icon-button { width: 42px; height: 42px; border-radius: 50%; background: white; border: 1px solid var(--line); font-size: 20px; }
.icon-button:hover { background: var(--wash); }
.week-title { min-width: 210px; border: 0; background: transparent; text-align: center; }
.week-title small, .week-title strong { display: block; }
.week-title small { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .12em; }
.week-title strong { margin-top: 4px; font-size: 17px; }
.week-choices { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; padding: 14px 20px; background: var(--wash); border-bottom: 1px solid var(--line); }
.week-choice { border: 1px solid var(--line); background: white; border-radius: 12px; padding: 10px; }
.week-choice span, .week-choice strong { display: block; }
.week-choice span { color: var(--muted); font-size: 10px; }
.week-choice strong { font-size: 12px; margin-top: 3px; }
.week-choice.active { border-color: var(--accent); background: var(--accent-soft); }

.desktop-week-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); min-height: 460px; }
.day-column { min-width: 0; padding: 16px 10px 22px; border-right: 1px solid var(--line); background: #fff; }
.day-column:last-child { border-right: 0; }
.day-column > header { display: flex; align-items: baseline; justify-content: space-between; padding: 0 4px 14px; text-transform: capitalize; }
.day-column > header span { color: var(--muted); font-size: 12px; }
.day-column > header strong { font-size: 20px; font-weight: 500; }
.empty-day { color: #a2aaa5; font-size: 12px; padding: 22px 4px; text-align: center; }

.class-card { border: 1px solid var(--line); border-radius: 14px; margin-bottom: 10px; overflow: hidden; background: white; transition: transform .15s ease, box-shadow .15s ease; }
.class-card:hover { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(31,43,38,.07); }
.time-block { padding: 10px 12px 0; display: flex; gap: 6px; align-items: baseline; }
.time-block strong { font-size: 17px; }
.time-block span { color: var(--muted); font-size: 11px; }
.class-content { padding: 8px 12px 12px; }
.class-topline { display: flex; gap: 8px; justify-content: space-between; align-items: flex-start; }
.class-card h2 { font-size: 14px; line-height: 1.2; margin: 0; }
.class-card p { font-size: 10px; color: var(--muted); margin: 4px 0 0; line-height: 1.35; }
.status { flex: 0 0 auto; font-size: 9px; padding: 4px 6px; border-radius: 999px; color: var(--accent-dark); background: var(--accent-soft); }
.status.almost-full { background: #f5eadf; color: #7b5838; }
.class-meta { display: flex; gap: 5px; color: var(--muted); font-size: 9px; margin-top: 10px; }
.book-button { display: block; text-align: center; width: 100%; margin-top: 10px; border: 0; border-radius: 9px; padding: 8px 10px; background: var(--ink); color: white; font-size: 11px; font-weight: 700; }
.book-button:hover { background: var(--accent-dark); }
.book-button.booked { background: var(--accent-soft); color: var(--accent-dark); }
.class-card.cancelled { opacity: .55; background: #fafafa; }
.cancelled-status { color: var(--danger); background: #f7e9e7; }

.mobile-day-picker, .mobile-day-list { display: none; }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: var(--ink); color: white; padding: 12px 18px; border-radius: 999px; box-shadow: var(--shadow); z-index: 50; font-size: 13px; }

.reconnect-notice { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px; background: rgba(245,246,242,.94); text-align: center; }
.reconnect-notice[hidden] { display: none; }
.reconnect-notice p { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 24px; }

.primary-action { border: 0; background: var(--ink); color: white; border-radius: 12px; padding: 12px 18px; font-weight: 700; opacity: .45; }
.admin-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 18px; }
.admin-card { background: white; border: 1px solid var(--line); border-radius: 18px; padding: 20px; box-shadow: 0 8px 26px rgba(31,43,38,.04); }
.admin-card-head { display: flex; justify-content: space-between; gap: 20px; }
.admin-day { font-size: 10px; color: var(--accent); font-weight: 800; text-transform: uppercase; letter-spacing: .12em; }
.admin-card h2 { margin: 5px 0 4px; font-size: 20px; }
.admin-card p { margin: 0; color: var(--muted); font-size: 13px; }
.capacity-pill { background: var(--wash); border-radius: 999px; padding: 6px 10px; height: fit-content; font-size: 11px; }
.admin-next-dates { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 16px; }
.admin-next-dates > p { font-size: 11px; margin-bottom: 10px; }
.date-toggle-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.date-toggle { border: 1px solid var(--line); background: var(--accent-soft); color: var(--accent-dark); border-radius: 12px; padding: 10px 6px; }
.date-toggle strong, .date-toggle span, .date-toggle small { display: block; }
.date-toggle strong { font-size: 18px; }
.date-toggle span { font-size: 10px; text-transform: uppercase; }
.date-toggle small { font-size: 9px; margin-top: 5px; }
.date-toggle.off { background: #f7e9e7; color: var(--danger); text-decoration: line-through; }
.admin-note { margin-top: 18px; border-left: 4px solid var(--warm); background: #fffaf5; padding: 16px 18px; border-radius: 10px; }
.admin-note p { margin: 5px 0 0; color: var(--muted); }

@media (max-width: 900px) {
    main { width: min(100% - 28px, 760px); padding-top: 28px; }
    .topbar { height: 66px; padding: 0 16px; }
    nav { gap: 12px; flex-wrap: wrap; justify-content: flex-end; font-size: 12px; }
    .hero-row { align-items: flex-start; margin-bottom: 22px; }
    .user-pill { display: none; }
    h1 { font-size: 38px; }
    .intro { font-size: 14px; }
    .schedule-shell { margin: 0 -14px; border-radius: 20px 20px 0 0; box-shadow: none; border-top: 1px solid var(--line); }
    .desktop-week-grid { display: none; }
    .week-picker { position: relative; background: white; padding: 13px 10px; gap: 8px; }
    .week-choices { grid-template-columns: 1fr; padding: 10px 14px; }
    .week-choice { text-align: left; display: flex; align-items: center; justify-content: space-between; }
    .week-choice span, .week-choice strong { display: inline; margin: 0; }
    .mobile-day-picker { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; padding: 12px 10px; border-bottom: 1px solid var(--line); overflow-x: auto; background: white; }
    .day-chip { min-width: 0; min-height: 52px; touch-action: manipulation; border: 1px solid transparent; background: transparent; border-radius: 14px; padding: 8px 2px; color: var(--muted); }
    .day-chip span, .day-chip strong { display: block; text-transform: capitalize; }
    .day-chip span { font-size: 10px; }
    .day-chip strong { font-size: 17px; margin-top: 5px; color: var(--ink); }
    .day-chip.active { background: var(--ink); color: white; }
    .day-chip.active strong { color: white; }
    .mobile-day-list { display: block; padding: 18px 14px 40px; background: var(--wash); min-height: 420px; }
    .mobile-date-heading { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; text-transform: capitalize; }
    .mobile-date-heading span { color: var(--muted); font-size: 12px; }
    .mobile-date-heading strong { font-size: 15px; }
    .class-card { display: grid; grid-template-columns: 66px 1fr; border-radius: 16px; margin-bottom: 12px; }
    .time-block { display: block; border-right: 1px solid var(--line); padding: 16px 10px; }
    .time-block strong, .time-block span { display: block; }
    .time-block strong { font-size: 18px; }
    .time-block span { margin-top: 3px; }
    .class-content { padding: 14px; }
    .class-card h2 { font-size: 16px; }
    .class-card p { font-size: 11px; }
    .class-meta { font-size: 10px; }
    .book-button { padding: 10px; font-size: 12px; }
    .mobile-empty { text-align: center; color: var(--muted); padding: 64px 20px; }
    .mobile-empty > span { font-size: 30px; }
    .mobile-empty strong { display: block; margin-top: 10px; color: var(--ink); }
    .mobile-empty p { margin: 5px 0 0; }
    .admin-heading { align-items: flex-start; }
    .admin-grid { grid-template-columns: 1fr; }
}

[hidden] { display: none !important; }
button:disabled { cursor: default; opacity: .5; }
button, select { touch-action: manipulation; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--warm); outline-offset: 3px; }
.week-title { min-width: 0; flex: 1; max-width: 330px; }
.week-title select { width: 100%; min-height: 44px; border: 1px solid var(--line); background: white; border-radius: 10px; color: var(--ink); font: inherit; padding: 8px; }
.icon-button { flex-shrink: 0; }
.primary-action { opacity: 1; }
.secondary-action { display: inline-block; border: 1px solid var(--accent); color: var(--accent-dark); background: white; border-radius: 10px; padding: 10px 14px; margin-top: 12px; }
.action-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.action-row .secondary-action { margin-top: 0; }
.account-panel { max-width: 560px; margin: 0 auto; padding: 28px; background: white; border-radius: 20px; overflow-wrap: anywhere; }
.account-panel h1 { font-size: 38px; }
.account-panel a { color: var(--accent-dark); text-decoration: underline; }
.form-stack { display: flex; flex-direction: column; gap: 10px; }
.form-stack input:not([type=checkbox]), .form-grid input, .form-grid select, .form-grid textarea { width: 100%; padding: 10px 12px; min-height: 44px; border: 1px solid #a6afa8; border-radius: 8px; font: inherit; background: white; color: var(--ink); }
.form-stack input[type=checkbox] { width: 18px; height: 18px; }
.form-stack label, .form-grid label { font-size: 14px; font-weight: 600; }
.form-stack .checkbox-label { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.form-stack button { margin-top: 10px; }
.form-help { color: var(--muted); font-size: 12px; font-weight: 400; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid label { display: grid; gap: 6px; }
.full-width { grid-column: 1 / -1; }
.editor-panel { margin-bottom: 28px; }
.validation-summary-errors, .validation-message, .field-validation-error { color: var(--danger); }
.profile-photo { width: 100px; height: 100px; border-radius: 50%; object-fit: cover; margin: 15px 0; }
.history-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 16px; margin-top: 18px; }
.history-grid .booking-state { margin: 16px 0; color: var(--accent-dark); }
.lesson-details { max-width: 760px; margin: 0 auto; overflow-wrap: anywhere; }
.lesson-details > .secondary-action { margin: 0 0 24px; }
.lesson-details > .admin-card { margin-top: 20px; }
.lesson-information p + p { margin-top: 12px; }
.lesson-information .booking-state { color: var(--accent-dark); }
.lesson-description { white-space: pre-wrap; }
.participant-names { padding-left: 20px; margin: 16px 0 0; }
.participant-names li { padding: 6px 0; }
.install-app { position: fixed; right: 16px; bottom: 16px; z-index: 30; padding: 12px 16px; border: 0; border-radius: 12px; background: var(--accent-dark); color: white; }
.offline-notice { position: fixed; bottom: 0; left: 0; right: 0; z-index: 60; background: #fff0ce; padding: 16px; text-align: center; }
.toast { max-width: calc(100% - 28px); width: max-content; border-radius: 12px; }
.booking-filters { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.booking-filters label { display: grid; gap: 6px; font-size: 13px; }
.booking-filters input { min-height: 44px; max-width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px; font: inherit; }
.booking-filters .secondary-action { margin: 0; }
.booking-period { color: var(--muted); }
.booking-roster { margin-bottom: 16px; scroll-margin-top: 90px; }
.booking-roster summary { cursor: pointer; line-height: 1.6; }
.roster-heading { display: inline; }
.roster-heading strong { font-size: 18px; }
.roster-heading > span, .roster-counts { display: block; font-size: 13px; color: var(--muted); }
.roster-counts { color: var(--accent-dark); }
.booking-table { width: 100%; border-collapse: collapse; margin-top: 18px; text-align: left; font-size: 14px; }
.booking-table th, .booking-table td { padding: 12px 8px; border-top: 1px solid var(--line); vertical-align: top; }
.booking-table th { color: var(--muted); font-size: 12px; }
.booking-table td a, .booking-table td small { display: block; margin-top: 4px; overflow-wrap: anywhere; }
.booking-table td small { color: var(--muted); }
.booking-table td a { color: var(--accent-dark); text-decoration: underline; }
.admin-card .roster-empty { margin-top: 16px; }
.user-search { max-width: 560px; margin-bottom: 24px; }
.user-role-card p { overflow-wrap: anywhere; }
.admin-card .teacher-assignment { margin-top: 8px; }
.teacher-lessons { margin: 28px 0 36px; padding-bottom: 28px; border-bottom: 1px solid var(--line); }
.teacher-actions { margin-top: 18px; }
.teacher-lesson h3 { margin: 0 0 8px; font-size: 20px; }
.teacher-lesson { overflow-wrap: anywhere; }
.lesson-pagination { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 16px; margin-top: 20px; }
.lesson-pagination .secondary-action { margin-top: 0; }
.teacher-history { margin-top: 0; }
.impersonation-banner { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding: 16px 4vw; background: #fff0ce; border-bottom: 1px solid var(--warm); overflow-wrap: anywhere; }
.impersonation-banner small { display: block; margin-top: 4px; }
.impersonation-banner .secondary-action { margin: 0; }
.booking-page h1 { margin-top: 0; }
.booking-description { color: var(--muted); line-height: 1.6; margin: 0 0 24px; }
.booking-page .form-stack { margin-bottom: 24px; }
.booking-page select { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid #a6afa8; border-radius: 8px; font: inherit; background: white; color: var(--ink); }
.booking-options { margin: 0; padding: 0; border: 0; min-width: 0; }
.booking-options legend { margin-bottom: 12px; font-weight: 700; }
.booking-option-list { display: flex; flex-direction: column; gap: 24px; }
.booking-period-option { display: flex; flex-direction: column; gap: 0; }
.booking-options label { display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; }
.booking-options input[type=radio] { width: 18px; height: 18px; margin: 0; accent-color: var(--accent-dark); flex-shrink: 0; }
.booking-options input[type=date] { width: calc(100% - 28px); margin: 0 0 0 28px; min-width: 0; min-height: 44px; border: 1px solid #a6afa8; border-radius: 8px; padding: 10px; font: inherit; color: var(--ink); background: white; }
.booking-options .booking-end-label { margin: 12px 0 6px 28px; }
.booking-options input[type=date]:focus-visible { outline-offset: -3px; }
.booking-options .form-help { margin: 8px 0 0 28px; }
.booking-page-actions { flex-direction: column; align-items: stretch; margin-top: 24px; text-align: center; }
.booking-page-actions button, .booking-page-actions a { min-height: 44px; text-decoration: none; }
.booking-page-actions .primary-action { color: white; }
@media (max-width: 600px) {
    .topbar { height: auto; min-height: 66px; padding: 10px 14px; gap: 12px; }
    .brand { gap: 6px; }
    .brand strong { font-size: 14px; }
    .brand-mark { width: 30px; height: 30px; flex-shrink: 0; }
    .brand small { display: none; }
    .form-grid { grid-template-columns: 1fr; }
    .account-panel { padding: 20px 16px; }
    .admin-heading { flex-direction: column; gap: 18px; }
    .booking-roster { padding: 16px; }
    .booking-table thead { display: none; }
    .booking-table, .booking-table tbody, .booking-table tr { display: block; }
    .booking-table tr { border-top: 1px solid var(--line); padding: 8px 0; }
    .booking-table td { display: grid; grid-template-columns: 85px minmax(0, 1fr); gap: 8px; padding: 6px 0; border: 0; }
    .booking-table td::before { content: attr(data-label); color: var(--muted); font-size: 12px; }
}

.participant-picker { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin: 1rem 0; }
.participant-picker select { max-width: 100%; padding: .65rem; border: 1px solid #c6cfc6; border-radius: .5rem; font: inherit; background: white; }
