/* ==========================================================================
   Music Lesson Scheduler — mobile-first, high-contrast styles
   ========================================================================== */
:root {
  --bg: #f4f3ef;
  --card: #ffffff;
  --ink: #14171f;
  --ink-2: #474c59;
  --muted: #6b7080;
  --line: #dcdad3;
  --accent: #1f3a93;
  --accent-ink: #ffffff;
  --accent-soft: #e6ebfa;
  --gold: #8a5a00;
  --gold-bg: #fff3d6;
  --gold-line: #e9b949;
  --ok: #156a3a;
  --ok-bg: #e2f4e8;
  --danger: #b4231b;
  --danger-bg: #fde8e6;
  --disabled: #c9c7c0;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(20, 23, 31, .06), 0 8px 24px rgba(20, 23, 31, .06);
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1116;
    --card: #181b23;
    --ink: #f3f4f7;
    --ink-2: #c9ccd6;
    --muted: #9095a3;
    --line: #2d313c;
    --accent: #8fa8ff;
    --accent-ink: #0f1116;
    --accent-soft: #1e2640;
    --gold: #ffcf66;
    --gold-bg: #2e2510;
    --gold-line: #a37a1f;
    --ok: #6fd69a;
    --ok-bg: #12291c;
    --danger: #ff8a80;
    --danger-bg: #331614;
    --disabled: #3a3e49;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 16px 16px calc(32px + env(safe-area-inset-bottom));
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 12px 20px;
  border: 2px solid transparent; border-radius: 999px;
  font-weight: 650; font-size: 16px; line-height: 1.2;
  background: var(--accent); color: var(--accent-ink);
  transition: transform .06s ease, opacity .15s ease, background .15s ease;
}
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn--block { width: 100%; }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--gold { background: var(--gold-line); color: #1d1500; }
.btn--small { min-height: 40px; padding: 8px 14px; font-size: 15px; }
.link-btn { background: none; border: 0; padding: 8px 4px; color: var(--accent); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; min-height: 40px; }

/* ---------- Header ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.brand { font-weight: 800; letter-spacing: -.01em; font-size: 15px; color: var(--ink-2); text-transform: uppercase; }
.hello { margin: 2px 0 0; font-size: 24px; line-height: 1.2; font-weight: 800; letter-spacing: -.02em; }

/* ---------- Cards / layout ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  min-width: 0;
}
.card h2 { margin: 0 0 4px; font-size: 18px; letter-spacing: -.01em; }
.card .sub { margin: 0; color: var(--muted); font-size: 14px; }

.layout { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); grid-template-areas: "summary" "book" "lessons"; }
.area-summary { grid-area: summary; }
.area-book { grid-area: book; }
.area-lessons { grid-area: lessons; }

@media (min-width: 900px) {
  .app { padding: 32px 24px 48px; }
  .layout {
    grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
    grid-template-areas: "summary book" "lessons book";
    grid-template-rows: auto 1fr;
    align-items: start;
  }
  .area-book { position: sticky; top: 16px; }
}

/* ---------- Login ---------- */
.login { min-height: calc(100vh - 64px); display: grid; place-items: center; }
.login .card { width: 100%; max-width: 420px; padding: 28px 24px; }
.login h1 { margin: 8px 0 6px; font-size: 28px; line-height: 1.15; letter-spacing: -.02em; }
.login p { margin: 0 0 20px; color: var(--ink-2); }
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field label { font-weight: 650; font-size: 15px; }
.input {
  width: 100%; min-height: 52px; padding: 12px 14px;
  border: 2px solid var(--line); border-radius: var(--radius-sm);
  background: var(--card); font-size: 17px;
}
.input:focus { border-color: var(--accent); outline: none; }
.input--code { text-transform: uppercase; letter-spacing: .08em; font-weight: 700; font-size: 20px; text-align: center; }
textarea.input { min-height: 84px; resize: vertical; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 15px; color: var(--ink-2); }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }
.error { background: var(--danger-bg); color: var(--danger); border-radius: var(--radius-sm); padding: 12px 14px; font-weight: 600; font-size: 15px; margin-bottom: 16px; }
.demo-note { margin-top: 16px; font-size: 14px; color: var(--muted); text-align: center; }
.demo-note code { background: var(--accent-soft); color: var(--accent); padding: 2px 6px; border-radius: 6px; font-weight: 700; }

/* ---------- Summary ---------- */
.credits { display: flex; align-items: baseline; gap: 8px; margin: 12px 0 4px; }
.credits__big { font-size: 44px; font-weight: 850; line-height: 1; letter-spacing: -.03em; }
.credits__of { font-size: 17px; color: var(--ink-2); font-weight: 600; }
.pips { display: flex; gap: 6px; margin: 12px 0 0; }
.pip { flex: 1; height: 10px; border-radius: 99px; background: var(--accent); }
.pip--used { background: var(--disabled); }
.makeup-pill {
  margin-top: 16px; padding: 12px 14px; border-radius: var(--radius-sm);
  display: flex; align-items: center; gap: 10px; font-size: 15px; line-height: 1.35;
}
.makeup-pill--on { background: var(--gold-bg); border: 2px solid var(--gold-line); color: var(--gold); font-weight: 650; }
.makeup-pill--off { background: transparent; border: 1px dashed var(--line); color: var(--muted); }

/* ---------- Tabs ---------- */
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 6px; background: var(--bg); border-radius: 999px; margin-bottom: 18px; border: 1px solid var(--line); }
.tab {
  min-height: 48px; border: 0; border-radius: 999px; background: transparent;
  font-weight: 700; font-size: 15px; color: var(--ink-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 6px 10px;
}
.tab[aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.tab--locked { color: var(--muted); opacity: .7; }
.tab--makeup-on { color: var(--gold); }
.tab--makeup-on[aria-selected="true"] { background: var(--gold-bg); color: var(--gold); box-shadow: inset 0 0 0 2px var(--gold-line); }
.badge { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 99px; background: var(--gold-line); color: #1d1500; font-size: 13px; font-weight: 800; }

.panel-head { margin-bottom: 14px; }
.panel-head h2 { font-size: 20px; }

/* ---------- Calendar ---------- */
.cal { user-select: none; }
.cal__nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal__title { font-weight: 800; font-size: 17px; }
.icon-btn { width: 44px; height: 44px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); display: grid; place-items: center; font-size: 20px; font-weight: 700; }
.icon-btn:disabled { opacity: .3; cursor: not-allowed; }
.cal__grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal__dow { text-align: center; font-size: 12px; font-weight: 700; color: var(--muted); padding: 4px 0; text-transform: uppercase; }
.day {
  position: relative; aspect-ratio: 1 / 1; min-height: 42px; width: 100%;
  border: 2px solid transparent; border-radius: 12px; background: var(--accent-soft);
  color: var(--ink); font-weight: 750; font-size: 16px; padding: 0;
  display: grid; place-items: center;
}
.day::after { content: ""; position: absolute; bottom: 6px; left: 50%; width: 5px; height: 5px; margin-left: -2.5px; border-radius: 99px; background: var(--accent); }
.day:disabled { background: transparent; color: var(--disabled); cursor: not-allowed; font-weight: 500; }
.day:disabled::after { display: none; }
.day--sel { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.day--sel::after { background: var(--accent-ink); }
.day--today { border-color: var(--ink-2); }
.day--empty { visibility: hidden; }
.cal__legend { margin-top: 10px; font-size: 13px; color: var(--muted); display: flex; gap: 14px; flex-wrap: wrap; }
.cal__legend i { display: inline-block; width: 12px; height: 12px; border-radius: 4px; background: var(--accent-soft); vertical-align: -1px; margin-right: 6px; border: 1px solid var(--accent); }

/* ---------- Slots ---------- */
.slots-wrap { margin-top: 20px; }
.slots-wrap h3 { margin: 0 0 10px; font-size: 16px; }
.slots { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.slot {
  min-height: 52px; border-radius: var(--radius-sm); border: 2px solid var(--accent);
  background: var(--card); color: var(--accent); font-weight: 750; font-size: 15px; padding: 6px;
}
.slot:hover { background: var(--accent-soft); }
.hint { font-size: 14px; color: var(--muted); margin: 10px 0 0; }

@media (min-width: 1100px) {
  .book-body { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 24px; align-items: start; }
  .book-body .slots-wrap { margin-top: 0; }
  .slots { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- Empty / locked states ---------- */
.empty { text-align: center; padding: 28px 12px; color: var(--ink-2); }
.empty__icon { font-size: 36px; line-height: 1; margin-bottom: 8px; }
.empty h3 { margin: 0 0 6px; font-size: 18px; color: var(--ink); }
.empty p { margin: 0 auto; max-width: 34ch; font-size: 15px; }

.skeleton { display: grid; gap: 8px; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.skeleton span { aspect-ratio: 1; border-radius: 12px; background: var(--line); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.loading-text { text-align: center; color: var(--muted); font-size: 14px; margin: 12px 0 0; }

/* ---------- Lessons list ---------- */
.lessons { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 10px; }
.lesson { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; display: grid; gap: 8px; }
.lesson__top { display: flex; justify-content: space-between; gap: 10px; align-items: start; }
.lesson__date { font-weight: 800; font-size: 16px; }
.lesson__time { color: var(--ink-2); font-size: 15px; }
.lesson__loc { font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.chip { display: inline-block; font-size: 12px; font-weight: 800; padding: 3px 9px; border-radius: 99px; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.chip--regular { background: var(--accent-soft); color: var(--accent); }
.chip--makeup { background: var(--gold-bg); color: var(--gold); }
.chip--done { background: var(--ok-bg); color: var(--ok); }
.chip--cancelled { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.chip--forfeited { background: var(--danger-bg); color: var(--danger); }
.late-note { font-size: 13px; color: var(--muted); line-height: 1.4; }
details.past { margin-top: 14px; }
details.past summary { cursor: pointer; font-weight: 700; min-height: 44px; display: flex; align-items: center; color: var(--ink-2); }
.lesson--past { opacity: .8; }

/* ---------- Sheet (bottom sheet on mobile, modal on desktop) ---------- */
.sheet { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet[hidden] { display: none; }
.sheet__backdrop { position: absolute; inset: 0; background: rgba(10, 12, 18, .55); animation: fade .2s ease; }
.sheet__panel {
  position: relative; width: 100%; max-height: 92vh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--card); border-radius: 22px 22px 0 0;
  padding: 10px 20px calc(20px + env(safe-area-inset-bottom));
  animation: up .25s cubic-bezier(.2, .8, .2, 1);
}
.sheet__grip { width: 44px; height: 5px; border-radius: 99px; background: var(--line); margin: 0 auto 12px; }
.sheet h2 { margin: 0 0 4px; font-size: 22px; letter-spacing: -.02em; }
.sheet .summary { background: var(--accent-soft); border-radius: var(--radius-sm); padding: 14px; margin: 14px 0 18px; font-weight: 650; }
.sheet .summary--gold { background: var(--gold-bg); color: var(--gold); }
.sheet .summary small { display: block; font-weight: 500; color: var(--ink-2); margin-top: 2px; }
.sheet-actions { display: grid; gap: 10px; margin-top: 18px; }
@media (min-width: 640px) {
  .sheet { align-items: center; padding: 24px; }
  .sheet__panel { max-width: 520px; border-radius: 22px; padding: 24px 28px 28px; }
  .sheet__grip { display: none; }
  .sheet-actions { grid-template-columns: 1fr 1fr; }
  .sheet-actions .btn:first-child { order: 2; }
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

/* Location radio cards */
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { font-weight: 750; margin-bottom: 8px; padding: 0; }
.radio-cards { display: grid; gap: 8px; }
.radio-card { position: relative; display: flex; gap: 12px; align-items: center; min-height: 60px; padding: 12px 14px; border: 2px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; }
.radio-card input { position: absolute; opacity: 0; pointer-events: none; }
.radio-card__dot { flex: none; width: 22px; height: 22px; border-radius: 99px; border: 2px solid var(--muted); display: grid; place-items: center; }
.radio-card__icon { font-size: 22px; flex: none; }
.radio-card__text { display: grid; line-height: 1.3; }
.radio-card__text strong { font-size: 15px; }
.radio-card__text span { font-size: 13px; color: var(--muted); }
.radio-card.is-checked { border-color: var(--accent); background: var(--accent-soft); }
.radio-card.is-checked .radio-card__dot { border-color: var(--accent); }
.radio-card.is-checked .radio-card__dot::after { content: ""; width: 10px; height: 10px; border-radius: 99px; background: var(--accent); }
.radio-card:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.reveal { margin-top: 12px; }

.success { text-align: center; padding: 8px 0; }
.success__icon { width: 64px; height: 64px; margin: 6px auto 12px; border-radius: 99px; background: var(--ok-bg); color: var(--ok); display: grid; place-items: center; font-size: 32px; font-weight: 900; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 60;
  max-width: 480px; margin: 0 auto; padding: 14px 16px; border-radius: var(--radius-sm);
  background: var(--ink); color: var(--bg); font-weight: 600; box-shadow: var(--shadow);
  animation: up .2s ease;
}
.toast--error { background: var(--danger); color: #fff; }

.spinner { width: 18px; height: 18px; border: 3px solid currentColor; border-right-color: transparent; border-radius: 99px; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Embedded in an auto-height iframe (Squarespace) ---------- */
.embedded .sheet { position: absolute; top: 0; left: 0; right: 0; bottom: auto; align-items: flex-start; padding: var(--anchor, 16px) 12px 24px; }
.embedded .sheet__panel { max-height: none; border-radius: 22px; max-width: 520px; }
.embedded .sheet__grip { display: none; }
.embedded .toast { position: absolute; bottom: auto; }
details.past summary { list-style: none; }
details.past summary::-webkit-details-marker { display: none; }
details.past summary::before { content: "▸"; margin-right: 8px; }
details.past[open] summary::before { content: "▾"; }

/* Slots grouped by hour (5-minute start times) */
.slot-group { margin-bottom: 14px; }
.slot-group__label { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 6px; }
.slot-group .slots { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.slot-group .slot { min-height: 46px; font-size: 15px; padding: 4px; }
@media (min-width: 1100px) { .slot-group .slots { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.req { font-weight: 600; font-size: 13px; color: var(--danger); }
.input--error { border-color: var(--danger) !important; }
