/* ============================================================================
   shell.css — ONE SHELL for every page except the home (owner, 16 Nov 2026:
   "consistency across all pages", "idiot proof", fewer words).
   Loaded LAST on every inner page, so it restyles the existing markup without
   touching content or wording. Rules:
   - Same dark MWT header everywhere (matches the home), white logo, gradient hairline.
   - Controls become a single row of compact icon buttons; text labels stay for
     screen readers (font-size:0 + aria-labels already present) - nothing is removed.
   - The figure (the thing you play) gets the space: header is ~45% shorter on phones.
   - Ear training keeps its identity with a teal accent line, not a different header.
   - Coral stays the one "this makes sound / is clickable" cue (CLAUDE.md).
   ========================================================================== */

body header.site, html.v2h body header.site, body.ear-mode header.site {
  background:
    radial-gradient(60% 140% at 85% 0%, rgba(124,58,237,.55), rgba(124,58,237,0) 70%),
    radial-gradient(40% 120% at 0% 100%, rgba(245,158,11,.16), rgba(245,158,11,0) 70%),
    linear-gradient(#0F0F1A, #08080F);
  color: #fff; position: relative; padding: 14px clamp(16px, 4vw, 40px) 18px;
}
body header.site::after {               /* MWT signature: gradient hairline */
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
  background: linear-gradient(90deg, #7C3AED, #F59E0B);
}
body.ear-mode header.site::after { background: linear-gradient(90deg, #1F72AA, #7C3AED); }

/* lockup: white logo, no white tile, one-line name */
body header.site .lockup { flex-wrap: nowrap; gap: 8px; margin: 0 0 12px; align-items: center; }
body header.site .lockup .logo { background: none; padding: 0; }
body header.site .lockup .logo img { width: 34px; height: 34px; content: url("../assets/brand/mwt-logo-white.png"); }
body header.site .lockup .mark small { display: none; }
body header.site .lockup .mark b { font-size: 15px; white-space: nowrap; }
body header.site .beta { background: none; border: 1px solid rgba(252,211,77,.6); color: #FCD34D; padding: 2px 7px; }

/* every control: the same compact pill */
body header.site .all-lessons,
body header.site .midi-chip,
body header.site .acct-head,
body header.site .snd-group {
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.16); border-radius: 999px;
  color: #fff; min-height: 40px;
}
body header.site .all-lessons { margin-left: auto; display: inline-flex; align-items: center; padding-top: 0; padding-bottom: 0; }
body header.site .midi-chip, body header.site .acct-head { display: inline-flex; align-items: center; }
body header.site .all-lessons:hover,
body header.site .midi-chip:hover:not(:disabled),
body header.site .acct-head:hover { background: rgba(255,255,255,.18); }

/* titles: kicker small, title big, sub calm */
body header.site .brand { font: 700 11px Inter, "Inter Fallback", system-ui, sans-serif; letter-spacing: .14em; color: #FCD34D; margin: 0 0 4px; }
body header.site h1 { font-size: clamp(22px, 4.2vw, 32px); }
body header.site p { color: #D6D2EC; }

/* fonts: Arial leftovers become the house sans */
.f-token, header.site .beta, header.site .lockup .mark small { font-family: Inter, "Inter Fallback", system-ui, sans-serif; }

/* formula bar never wraps one token onto its own line (seen on 2.4, 390px) */
.formula-bar { flex-wrap: nowrap; gap: 3px; }
@media (max-width: 420px) { .f-token { min-width: 0; padding: 6px 7px; font-size: 15px; } .f-dot { display: none; } }

/* ---------- phones: icon-only controls, figure gets the room ---------- */
@media (max-width: 640px) {
  body header.site { padding: 10px 14px 14px; }
  body header.site .lockup { margin-bottom: 10px; }
  body header.site .lockup .mark { display: none; }          /* logo alone = home */
  body header.site .all-lessons { margin: 0 0 0 auto; padding: 0 12px; font-size: 0; }
  body header.site .all-lessons::before { content: "← Lessons"; font-size: 13px; font-weight: 700; }
  body header.site .midi-chip { font-size: 0; padding: 0 11px; margin: 0; }
  body header.site .midi-chip::before { content: "🎹"; font-size: 16px; }
  body header.site .acct-head { margin: 0; padding: 0 12px; font-size: 13px; }
  body header.site .snd-text, body header.site .pref-text { display: none; }
  body header.site .beta { display: none; }
  body header.site p#lesson-sub { font-size: 13px; margin-top: 4px; }
}

/* WCAG AA: white text on a FILLED coral button needs the deep coral (benchmark 16 Nov: 3.87:1 on #D85A30) */
.meter-seg-btn.on, .drone-seg-btn.on, .drone-play { background-color: var(--coral-deep, #B4441F) !important; border-color: var(--coral-deep, #B4441F) !important; }

/* Ear-training levels that are not open yet (page audit 16 Nov): calm, readable, not clickable */
.ear-level-btn.ear-level-locked { opacity: .55; cursor: default; filter: grayscale(.4); }

/* Studio 3D art bands (17 Nov): one rendered plate under the header on ear training and account,
   and on the Lesson-locked gate. Purely decorative (aria-hidden), never covers controls. */
.art-band { display: block; background: #0B0B14; line-height: 0; }
.art-band img { display: block; width: 100%; height: clamp(150px, 23vw, 300px); object-fit: cover; object-position: center 60%; }
.art-band-light { background: #E9E5FB; }
.lock-gate-art { display: block; margin: -8px -8px 18px; border-radius: 14px; overflow: hidden; background: #0B0B14; line-height: 0; }
.lock-gate-art img { display: block; width: 100%; height: clamp(140px, 22vw, 240px); object-fit: cover; }

/* ---------- Tools page to the metronome-app standard (17 Nov page audit) ----------
   Benchmarks: Click, Tempo (Frozen Ape), Tick, Nova: one large tempo readout, one large play
   control, tap tempo beside the number, everything on one screen. Desktop used a 720px column
   with an empty right half; now two tool cards sit side by side. Coral = anything that sounds
   (CLAUDE.md signal colour), so Start is coral, not violet. */
@media (min-width: 1000px) {
  html:not([data-board="on"]) #tools { max-width: 1160px; display: grid; grid-template-columns: 1fr 1fr; gap: 0 22px; align-items: start; }
  html:not([data-board="on"]) #tools > .board-bar { grid-column: 1 / -1; }
  html:not([data-board="on"]) #tools > .keys-card, html:not([data-board="on"]) #tools > .scale-card, html:not([data-board="on"]) #tools > .circle-card { grid-column: 1 / -1; }
}
.meter-tempo { justify-content: center; }
.metro-num { font-size: 52px !important; width: 3.2em; padding: 6px 4px; border-radius: 14px; background: #fff; letter-spacing: -.02em; }
.metro-slider { width: 100%; max-width: 420px; display: block; margin: 8px auto 4px; accent-color: var(--coral); }
.metro-btn { min-width: 220px; min-height: 56px; font-size: 20px; background: var(--coral-deep, #B94A23); box-shadow: 0 4px 0 #8A3415; }
.metro-btn:hover { filter: brightness(1.06); }
.metro-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #8A3415; }
.meter-tap { min-height: 48px; padding: 0 22px; font-size: 16px; }

/* ---------- Repertoire: earned cards must look earned, locked ones quiet (collection standard,
   Duolingo achievements "trophies on a shelf") ---------- */
.rep-lux.rep-lux-locked { filter: grayscale(.85); opacity: .58; box-shadow: none; border: 1.5px dashed #CFC8EA; }
.rep-lux.rep-lux-locked:hover { transform: none; }
.rep-lux:not(.rep-lux-locked) { box-shadow: 0 0 0 2px rgba(245,158,11,.55), 0 14px 30px -12px rgba(124,58,237,.45); }
/* Repertoire: the degree table (degree, solfa, note, function) was clipped at 240px card width
   ("Toni", "Supe"). Cards get room for all four columns; the table shrinks a touch to fit. */
.rep-lux-grid { grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)) !important; }
.rep-lux table { width: 100%; table-layout: auto; font-size: 13px; }
.rep-lux th, .rep-lux td { padding-left: 4px; padding-right: 4px; }
/* Your progress (learner's own view, 16 Nov 2026). Calm: ticks and counts, no percentages, no red. */
.pv-host { max-width: 640px; margin: 0 auto 48px; padding: 0 16px; }
.pv-card { background: #fff; border: 1px solid var(--lav, #EEEDFE); border-radius: 16px; padding: 20px; }
.pv-mod { margin-top: 18px; }
.pv-mod-h { font-size: 1rem; color: var(--violet, #7C3AED); margin: 0 0 6px; }
.pv-list { list-style: none; padding: 0; margin: 0; }
.pv-item { display: flex; align-items: center; gap: 10px; min-height: 44px; border-bottom: 1px solid var(--soft, #F4F3FB); }
.pv-item a { color: var(--ink, #2C2C2A); }
.pv-mark { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--lav, #EEEDFE); font-weight: 700; color: #fff; flex: none; }
.pv-done .pv-mark { background: var(--violet, #7C3AED); border-color: var(--violet, #7C3AED); }
.pv-tag { font-size: .8rem; color: #5B5B66; margin-left: auto; }
.pv-next { margin: 10px 0 4px; display: inline-block; }
.pv-tick { color: var(--violet, #7C3AED); font-weight: 700; }

/* ==========================================================================
   Lesson player fits one screen (owner 18 Nov 2026: "on my laptop it doesn't
   fit into the screen"). Industry pattern (Duolingo, Brilliant, Khan): the
   card fills the window under the header, the figure scales to the space left,
   and the Back / Continue bar is pinned to the bottom so the primary action is
   always visible, on laptops and phones alike. Teach (projector) mode keeps
   its own large sizing; only the pinned bar applies there.
   ========================================================================== */
body.lesson-player main#lesson {
  display: flex; flex-direction: column;
  min-height: calc(100vh - var(--hdr, 0px)); min-height: calc(100dvh - var(--hdr, 0px));
  padding-top: 14px; padding-bottom: 0;
}
/* The module pre-check hides the lesson with the hidden attribute (assessment.js); the display:flex
   above outranks the browser's [hidden] rule, so the lesson card and its Continue stayed on screen
   under the pre-check and could move the lesson on behind it. */
body.lesson-player main#lesson[hidden] { display: none; }
body.lesson-player .card-stage { min-height: 0; flex: 1 0 auto; }
body.lesson-player .card-nav {
  position: sticky; bottom: 0; z-index: 20;
  margin: 10px -20px 0; padding: 10px 20px calc(10px + env(safe-area-inset-bottom, 0px));
  background: rgba(255,255,255,.96); border-top: 1px solid #ECEAF6;
}
@supports (backdrop-filter: blur(6px)) { body.lesson-player .card-nav { background: rgba(255,255,255,.85); backdrop-filter: blur(6px); } }
body.lesson-player .site-foot { margin-top: 0; }

/* Figures never take more height than the window can spare (SVGs keep their
   shape: the box shrinks and the drawing scales inside it, clicks still map). */
body.lesson-player:not(.teach) .card-figure svg { max-height: max(150px, calc(100dvh - var(--hdr, 0px) - 360px)); }

/* Short windows (laptops, landscape tablets): compact header and card. */
@media (min-width: 641px) and (max-height: 860px) {
  body.lesson-player:not(.teach) header.site { padding-top: 10px; padding-bottom: 12px; }
  body.lesson-player:not(.teach) header.site .lockup { margin-bottom: 6px; }
  body.lesson-player:not(.teach) header.site .brand { margin-bottom: 2px; }
  body.lesson-player:not(.teach) header.site h1 { font-size: 24px; }
  body.lesson-player:not(.teach) header.site p#lesson-sub { display: none; }
  body.lesson-player:not(.teach) .card-top { margin: 0 0 4px; }
  body.lesson-player:not(.teach) .card-guide video,
  body.lesson-player:not(.teach) .card-guide img,
  body.lesson-player:not(.teach) .card-guide .paver-svg { width: 76px; height: 76px; border-radius: 18px; --paver-size: 76px; }
  body.lesson-player:not(.teach) .card-say { font-size: 20px; margin-top: 14px; }
  body.lesson-player:not(.teach) .replay-row { margin-top: 8px; }
}
@media (min-width: 641px) and (max-height: 640px) {
  body.lesson-player:not(.teach) header.site .brand { display: none; }
  body.lesson-player:not(.teach) .card-guide video,
  body.lesson-player:not(.teach) .card-guide img,
  body.lesson-player:not(.teach) .card-guide .paver-svg { width: 64px; height: 64px; border-radius: 16px; --paver-size: 64px; }
}
/* Phones: the pinned bar sits in the thumb zone; keep it slim. */
@media (max-width: 640px) {
  body.lesson-player .card-nav { margin-left: -20px; margin-right: -20px; padding-top: 8px; }
  /* P7 phone sweep (18 Nov): on 14 teaching screens the instruction line ran under the pinned bar
     at 390x750. Same compact header the laptop already gets: the subtitle goes (the title stays),
     tighter header and card spacing. Teach mode keeps its own sizing. */
  body.lesson-player:not(.teach) header.site { padding-top: 10px; padding-bottom: 10px; }
  body.lesson-player:not(.teach) header.site .lockup { margin-bottom: 6px; }
  body.lesson-player:not(.teach) header.site h1 { font-size: 22px; }
  body.lesson-player:not(.teach) header.site p#lesson-sub { display: none; }
  body.lesson-player:not(.teach) main#lesson { padding-top: 8px; }
  body.lesson-player:not(.teach) .card-top { margin: 0 0 6px; }
  body.lesson-player:not(.teach) .card-say { margin-top: 10px; }
}

/* Paver beside the line he is "saying" (laptops and up), not stacked above the
   figure: the guide-and-speech layout learners know from Duolingo-style players,
   and it gives the figure back ~80px of height. Phones keep the stacked layout. */
@media (min-width: 641px) {
  body.lesson-player:not(.teach) .card-stage:has(> .card-guide:not([hidden])) {
    display: grid; justify-content: center; align-content: center; column-gap: 16px;
    grid-template-columns: auto minmax(0, 620px); width: 100%;
    grid-template-areas: "fig fig" "flag flag" "guide say" "notes notes" "replay replay";
  }
  body.lesson-player:not(.teach) .card-stage:has(> .card-guide:not([hidden])) > .card-figure { grid-area: fig; contain: inline-size; justify-self: stretch; }
  body.lesson-player:not(.teach) .card-stage:has(> .card-guide:not([hidden])) > .teach-flag { grid-area: flag; }
  body.lesson-player:not(.teach) .card-stage:has(> .card-guide:not([hidden])) > .card-guide { grid-area: guide; margin: 14px 0 0; align-self: center; }
  body.lesson-player:not(.teach) .card-stage:has(> .card-guide:not([hidden])) > .card-say { grid-area: say; text-align: left; margin: 14px 0 0; max-width: none; }
  body.lesson-player:not(.teach) .card-stage:has(> .card-guide:not([hidden])) > .teach-notes { grid-area: notes; }
  body.lesson-player:not(.teach) .card-stage:has(> .card-guide:not([hidden])) > .replay-row { grid-area: replay; }
  body.lesson-player:not(.teach) .card-say { max-width: 700px; }
}
/* Practice and quick checks (owner ruling 20 Nov, approach A): Paver stays beside the question.
   Wide screens: Paver to the left of the exercise, top-aligned. Phones: small, centred above it. */
@media (min-width: 641px) {
  body.lesson-player:not(.teach) .card-stage.ex-mode:has(> .card-guide:not([hidden])) {
    grid-template-areas: "guide fig" "flag flag" "notes notes" "replay replay"; align-items: start;
  }
  body.lesson-player:not(.teach) .card-stage.ex-mode:has(> .card-guide:not([hidden])) > .card-guide { margin: 6px 0 0; align-self: start; }
}
/* Short windows: one header line for the lesson (kicker sits beside the title). */
@media (min-width: 641px) and (max-height: 860px) {
  body.lesson-player:not(.teach) header.site { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 14px; }
  body.lesson-player:not(.teach) header.site .lockup { flex: 1 0 100%; }
  body.lesson-player:not(.teach) header.site .brand { order: 2; margin: 0; }
  body.lesson-player:not(.teach) header.site h1 { order: 1; font-size: 22px; }
}

/* The end-of-lesson "Your week" plan is a long panel that stays put while the
   line changes step by step. The changing line goes ABOVE it, so each new line
   is seen without scrolling; the panel below can scroll under the pinned bar. */
body.lesson-player:not(.teach) .card-stage:has(.practice-panel) { justify-content: flex-start; }
body.lesson-player:not(.teach) .card-stage:has(.practice-panel) > .card-say { order: -1; margin: 4px auto 14px; }
/* Two practice cards fill the row instead of leaving an empty third column. */
@media (min-width: 641px) { body.lesson-player .practice-panel .strands { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); } }
/* Very short windows (≤ 700px tall, e.g. 1366×768 laptops with browser bars):
   give interactive keyboards a little less height so the line still fits. */
@media (min-width: 641px) and (max-height: 700px) {
  body.lesson-player:not(.teach) .card-figure svg { max-height: max(120px, calc(100dvh - var(--hdr, 0px) - 420px)); }
  body.lesson-player:not(.teach) .card-figure .hint-btn { margin-top: 6px; }
}

/* Live Paver (preview): on phones he also stands beside the line, smaller, so he is
   on every screen without pushing the figure down. */
@media (max-width: 640px) {
  body.lesson-player:not(.teach) .card-stage:has(> .card-guide.live:not([hidden])) {
    display: grid; justify-content: center; align-content: center; column-gap: 10px;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas: "fig fig" "flag flag" "guide say" "notes notes" "replay replay";
  }
  .card-stage:has(> .card-guide.live:not([hidden])) > .card-figure { grid-area: fig; contain: inline-size; justify-self: stretch; }
  .card-stage:has(> .card-guide.live:not([hidden])) > .teach-flag { grid-area: flag; }
  .card-stage:has(> .card-guide.live:not([hidden])) > .card-guide { grid-area: guide; margin: 14px 0 0; align-self: center; }
  .card-stage:has(> .card-guide.live:not([hidden])) > .card-say { grid-area: say; text-align: left; margin: 14px 0 0; }
  .card-stage:has(> .card-guide.live:not([hidden])) > .teach-notes { grid-area: notes; }
  .card-stage:has(> .card-guide.live:not([hidden])) > .replay-row { grid-area: replay; }
  .card-guide.live .paver-svg { --paver-size: 60px; }
}
/* Phones in practice: Paver stands just above the question (top left, small), so he is there while
   the learner answers without pushing the keyboard down much. */
@media (max-width: 640px) {
  body.lesson-player:not(.teach) .card-stage.ex-mode:has(> .card-guide.live:not([hidden])) {
    grid-template-columns: minmax(0, 1fr); grid-template-areas: "guide" "fig" "flag" "notes" "replay"; align-content: start;
  }
  body.lesson-player:not(.teach) .card-stage.ex-mode:has(> .card-guide.live:not([hidden])) > .card-guide { justify-self: start; margin: 0 0 -6px 4px; }
}
@media (min-width: 641px) and (max-height: 700px) {
  body.lesson-player:not(.teach) main#lesson { padding-top: 8px; }
}

/* ==========================================================================
   Curtain Call: end-of-lesson celebration (js/curtain.js). Dark MWT brand
   surface (#0F0F1A, approved for brand moments), so gold is allowed here;
   Continue uses the approved AA-safe MWT gradient CTA.
   ========================================================================== */
body.cc-open { overflow: hidden; }
.cc { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(80% 70% at 50% 35%, #3B1A7A 0%, #1A1033 55%, #0F0F1A 100%);
  opacity: 0; transition: opacity .25s ease; font-family: Inter, "Inter Fallback", system-ui, sans-serif; color: #fff; }
.cc.in { opacity: 1; } .cc.out { opacity: 0; }
.cc-confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.cc-skip { position: absolute; top: 14px; right: 16px; z-index: 2; font: 600 14px Inter, "Inter Fallback", system-ui, sans-serif; color: #D6D2EC;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.18); border-radius: 999px; padding: 8px 16px; cursor: pointer; }
.cc-skip:hover { background: rgba(255,255,255,.16); }
.cc-stage { position: relative; z-index: 1; width: min(640px, 92vw); text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.cc-title { margin: 0; font-size: clamp(28px, 5vw, 40px); font-weight: 800; letter-spacing: -.01em;
  transform: scale(.6); opacity: 0; transition: transform .45s cubic-bezier(.3,1.6,.5,1), opacity .2s; }
.cc.in .cc-title { transform: scale(1); opacity: 1; transition-delay: .25s; }
.cc-cast { display: flex; align-items: flex-end; justify-content: center; gap: 4px; min-height: 140px; }
.cc-slot { animation: cc-drop .55s cubic-bezier(.3,1.5,.55,1) both; }
@keyframes cc-drop { from { transform: translateY(-140%); opacity: 0; } 60% { opacity: 1; } to { transform: none; opacity: 1; } }
.cc-encore { position: relative; width: min(520px, 90vw); height: 96px; }
.cc-staff { position: absolute; inset: 14px 0 14px 0; display: flex; flex-direction: column; justify-content: space-between; }
.cc-staff i { display: block; height: 2px; background: rgba(196,181,253,.38); border-radius: 2px; }
.cc-note { position: absolute; width: 18px; height: 13px; margin-left: -9px; border-radius: 50%; background: #D85A30;
  transform: rotate(-20deg); box-shadow: 0 0 12px rgba(216,90,48,.8); animation: cc-note .32s cubic-bezier(.3,1.6,.5,1) both; }
@keyframes cc-note { from { transform: translateY(-60px) rotate(-20deg) scale(.4); opacity: 0; } to { transform: rotate(-20deg); opacity: 1; } }
.cc-count { position: absolute; right: -8px; top: -30px; font: 800 34px Inter, "Inter Fallback", system-ui, sans-serif; color: #F59E0B; text-shadow: 0 0 18px rgba(245,158,11,.5); }
.cc-count.pop { animation: cc-pop .22s ease-out; }
@keyframes cc-pop { 40% { transform: scale(1.35); } }
.cc-cards { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.cc-card { min-width: 132px; padding: 14px 16px 12px; border-radius: 16px; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.16);
  transform: perspective(500px) rotateX(80deg) translateY(10px); opacity: 0; transition: transform .45s cubic-bezier(.3,1.4,.5,1), opacity .25s; }
.cc-card.in { transform: none; opacity: 1; }
.cc-card-val { font: 800 30px Inter, "Inter Fallback", system-ui, sans-serif; color: #fff; }
.cc-card-lbl { font: 600 12px Inter, "Inter Fallback", system-ui, sans-serif; letter-spacing: .1em; text-transform: uppercase; color: #C4B5FD; margin-top: 2px; }
.cc-go { margin-top: 6px; font: 700 17px Inter, "Inter Fallback", system-ui, sans-serif; color: #fff; border: 0; border-radius: 12px; padding: 13px 34px; cursor: pointer;
  background: linear-gradient(90deg, #6D28D9, #B45309); box-shadow: 0 6px 20px rgba(109,40,217,.45); }
.cc-go:disabled { opacity: .35; cursor: default; }
.cc-go:focus-visible, .cc-skip:focus-visible { outline: 3px solid #FCD34D; outline-offset: 3px; }
.cc-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
@media (max-height: 640px) { .cc-cast { min-height: 100px; } .cc-encore { height: 70px; } .cc-card { min-width: 104px; padding: 10px 12px; } .cc-card-val { font-size: 24px; } }
@media (prefers-reduced-motion: reduce) { .cc, .cc-title, .cc-card, .cc-slot { transition: none; animation: none; } .cc-title { transform: none; opacity: 1; } .cc-card { transform: none; opacity: 1; } }
@media (max-width: 480px) {
  .cc-cast { gap: 0; }
  .cc-slot .paver-svg { width: 62px; height: 62px; }
  .cc-slot.lead .paver-svg { width: 100px; height: 100px; }
  .cc-cards { gap: 8px; flex-wrap: nowrap; }
  .cc-card { min-width: 0; flex: 1; padding: 10px 6px; }
  .cc-card-val { font-size: 24px; }
  .cc-card-lbl { font-size: 10px; letter-spacing: .06em; }
  .cc-count { right: 0; }
}

/* Phones: give the lesson keyboard the full width (side margins 20px -> 8px,
   figure padding 8px -> 2px) so the smallest key grows from 24px to about 27px
   (WCAG 2.2 target size; quality cycle 18 Nov late). */
@media (max-width: 480px) {
  body.lesson-player main { padding-left: 8px; padding-right: 8px; }
  body.lesson-player .card-figure.kb { padding-left: 2px; padding-right: 2px; }
  body.lesson-player .card-nav { margin-left: -8px; margin-right: -8px; padding-left: 12px; padding-right: 12px; }
}
/* P7 phone sweep: the semitone counter's big number is the one HTML figure left that does not
   scale with the window; a little smaller on phones (still the largest thing in the figure). */
@media (max-width: 640px) {
  body.lesson-player:not(.teach) .count-num { font-size: 38px; }
  body.lesson-player:not(.teach) .count-holder { margin: 0 auto 4px; }
}
/* WCAG 1.4.10 reflow check at 320px (18 Nov): the header row was 20px too narrow, so "Sign in" was
   cut to an ellipsis on every page. On the narrowest phones "← Lessons" shows as the arrow alone
   (its full name stays for screen readers: the link text is hidden visually, not removed). */
@media (max-width: 360px) {
  body header.site .all-lessons { padding: 0 13px; }
  body header.site .all-lessons::before { content: "←"; font-size: 16px; }
  body header.site .acct-head { flex-shrink: 0; max-width: none; }
}
/* Short phones (360x640 class, 18 Nov sweep: 31 screens put the line under the pinned bar). A smaller
   guide gives the line more width (fewer lines), slightly tighter line spacing and table rows.
   Text stays 18px, above the 16px body minimum. */
@media (max-width: 640px) and (max-height: 720px) {
  body.lesson-player:not(.teach) .card-guide video,
  body.lesson-player:not(.teach) .card-guide img,
  body.lesson-player:not(.teach) .card-guide .paver-svg { width: 60px; height: 60px; border-radius: 14px; --paver-size: 60px; }
  body.lesson-player:not(.teach) .card-say { font-size: 18px; line-height: 1.4; }
  body.lesson-player:not(.teach) .reftable td { padding-top: 5px; padding-bottom: 5px; }
  body.lesson-player:not(.teach) .key-badge { margin-bottom: 4px; }
}
/* P7 (CLS, 18 Nov): these pages build their content by script, so the footer painted near the top and
   then jumped down (Repertoire CLS 0.31 on a phone). Reserve a screen for the content up front. */
main#repertoire, main#practice, main#ear, main#assessment, main#account, main#tools { min-height: 100vh; min-height: 100dvh; }

/* ---------- Cast Stories (js/stories.js): the end of every lesson, after Curtain Call ----------
   Same dark stage as Curtain Call so the two read as one sequence. One line per card, a progress strip
   on top, tap zones left and right, the host large in the middle. Coral marks what sounds (the notes
   and keys in the effects), gold only on this dark surface. */
.st { position: fixed; inset: 0; z-index: 1001; display: flex; flex-direction: column; align-items: center;
  background: radial-gradient(80% 70% at 50% 35%, #3B1A7A 0%, #1A1033 55%, #0F0F1A 100%);
  opacity: 0; transition: opacity .25s ease; font-family: Inter, "Inter Fallback", system-ui, sans-serif; color: #fff;
  padding: max(12px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); overflow: hidden; }
.st.in { opacity: 1; } .st.out { opacity: 0; }
.st-bars { display: flex; gap: 5px; width: min(560px, 100%); margin-top: 4px; }
.st-bars i { flex: 1; height: 4px; border-radius: 4px; background: rgba(255,255,255,.22); overflow: hidden; }
.st-bars b { display: block; height: 100%; background: #fff; transform-origin: left center; transform: scaleX(0); }
.st-top { display: flex; align-items: center; gap: 8px; width: min(560px, 100%); margin-top: 10px; position: relative; z-index: 3; }
.st-chip { flex: 1; font-weight: 700; font-size: 13px; letter-spacing: .12em; text-transform: uppercase; color: #C4B5FD; }
.st-pause, .st-skip { font: 600 14px Inter, "Inter Fallback", system-ui, sans-serif; color: #E9E5FA; background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.2); border-radius: 999px; min-height: 36px; padding: 0 14px; cursor: pointer; }
.st-pause { width: 40px; padding: 0; }
.st-pause:hover, .st-skip:hover { background: rgba(255,255,255,.18); }
.st-zone { position: absolute; top: 90px; bottom: 0; z-index: 1; background: transparent; border: 0; cursor: pointer; padding: 0; }
.st-prev { left: 0; width: 30%; } .st-next { right: 0; width: 70%; }
.st-zone:focus-visible { outline: 3px solid #FCD34D; outline-offset: -6px; border-radius: 18px; }
.st-pause:focus-visible, .st-skip:focus-visible, .st-go:focus-visible, .st-alt:focus-visible { outline: 3px solid #FCD34D; outline-offset: 3px; }
.st-stage { position: relative; z-index: 2; pointer-events: none; flex: 1; width: min(560px, 100%);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center; }
.st-stage a, .st-stage button { pointer-events: auto; }
.st-cast { position: relative; height: 170px; width: 100%; display: flex; justify-content: center; align-items: flex-end; }
.st-host { position: absolute; bottom: 0; animation: st-in .5s cubic-bezier(.3,1.4,.5,1) both; }
.st-host.out { animation: st-out .4s ease-in both; }
.st.back .st-host { animation-name: st-in-back; } .st.back .st-host.out { animation-name: st-out-back; }
@keyframes st-in { from { transform: translateX(60px) scale(.8); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes st-out { to { transform: translateX(-90px) scale(.85); opacity: 0; } }
@keyframes st-in-back { from { transform: translateX(-60px) scale(.8); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes st-out-back { to { transform: translateX(90px) scale(.85); opacity: 0; } }
.st-line { margin: 0; font-size: clamp(21px, 4.6vw, 28px); line-height: 1.38; font-weight: 700; letter-spacing: -.005em; max-width: 30ch; min-height: 3.2em; }
.st-w { display: inline-block; animation: st-word .38s ease-out both; }
@keyframes st-word { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.st-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.st.kind-check .st-line { color: #FDE68A; }
/* effects: the part that sounds is coral */
.st-fx { height: 64px; display: flex; align-items: center; justify-content: center; }
.st-fx:empty { height: 0; }
.st-note { width: 22px; height: 16px; border-radius: 50%; background: #D85A30; margin: 0 14px; box-shadow: 0 0 18px rgba(216,90,48,.7); opacity: 0; }
.fx-hear .n1 { animation: st-note .5s ease-out both; transform: translateY(14px); }
.fx-hear .n2 { animation: st-note2 .5s ease-out .52s both; }
@keyframes st-note { from { opacity: 0; transform: translateY(26px) scale(.6); } to { opacity: 1; transform: translateY(14px); } }
@keyframes st-note2 { from { opacity: 0; transform: translateY(0) scale(.6); } to { opacity: 1; transform: translateY(-14px); } }
.st-fx svg { height: 56px; width: auto; }
.st-fx .w { fill: #F4F3FB; stroke: #2C2C2A; stroke-width: .6; } .st-fx .b { fill: #1B1030; }
.fx-play .w { animation: st-key 2.4s ease-in-out infinite; }
.fx-play .w1 { animation-delay: .3s; } .fx-play .w2 { animation-delay: .6s; } .fx-play .w3 { animation-delay: .9s; } .fx-play .w4 { animation-delay: 1.2s; }
.fx-play .w5, .fx-play .w6 { animation: none; }
.fx-acc .w0 { fill: #D85A30; } .fx-acc .w2, .fx-acc .w4 { animation: st-key 1.6s ease-in-out infinite; } .fx-acc .w4 { animation-delay: .8s; }
@keyframes st-key { 0%, 30%, 100% { fill: #F4F3FB; } 10% { fill: #D85A30; } }
.st-fx .ring-bg { fill: none; stroke: rgba(255,255,255,.18); stroke-width: 5; }
.st-fx .ring { fill: none; stroke: #F59E0B; stroke-width: 5; stroke-linecap: round; stroke-dasharray: 164; stroke-dashoffset: 164; transform: rotate(-90deg); transform-origin: 32px 32px; animation: st-ring 1.6s ease-in-out .2s forwards; }
.st-fx .tick { fill: none; stroke: #F59E0B; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 40; stroke-dashoffset: 40; animation: st-tick .35s ease-out 1.75s forwards; }
@keyframes st-ring { to { stroke-dashoffset: 0; } } @keyframes st-tick { to { stroke-dashoffset: 0; } }
.st.paused .st-fx *, .st.held .st-fx *, .st.paused .st-w, .st.held .st-w { animation-play-state: paused; }
.st-extra { display: flex; flex-direction: column; align-items: center; gap: 12px; width: 100%; }
.st-card { width: min(340px, 100%); border-radius: 22px; padding: 18px 18px 16px; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.16); }
.st-card-k { font-weight: 700; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: #C4B5FD; }
.st-card-t { font-weight: 800; font-size: 24px; margin-top: 4px; }
.st-card-s { margin-top: 10px; display: flex; justify-content: center; }
.st-card-s b { display: block; font-size: 40px; font-weight: 800; color: #F59E0B; line-height: 1.05; }
.st-card-s span { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: #C4B5FD; }
.st-go { font: 700 17px Inter, "Inter Fallback", system-ui, sans-serif; color: #fff; border: 0; border-radius: 12px; padding: 14px 34px; cursor: pointer;
  background: linear-gradient(90deg, #6D28D9, #B45309); box-shadow: 0 6px 20px rgba(109,40,217,.45); min-height: 48px; }
.st-more { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.st-alt { font: 600 15px Inter, "Inter Fallback", system-ui, sans-serif; color: #fff; text-decoration: none; background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.24); border-radius: 999px; padding: 10px 16px; min-height: 44px; display: inline-flex; align-items: center; cursor: pointer; }
.st-alt:hover { background: rgba(255,255,255,.18); }
@media (max-height: 700px) { .st-cast { height: 130px; } .st-cast .paver-svg { width: 118px; height: 118px; } .st-fx { height: 50px; } .st-card-s b { font-size: 32px; } }
@media (prefers-reduced-motion: reduce) { .st, .st-host, .st-w, .st-note, .st-fx * { animation: none !important; transition: none; } .st-note { opacity: 1; } }
.st:focus { outline: none; }

/* Page hosts (js/cast-host.js): a friend on its own page. Phones: a fixed-height spot above the content
   (reserved, so nothing shifts). Wide screens: the free margin, bottom right, out of the content's way. */
.cast-dock { height: 84px; display: flex; justify-content: center; align-items: flex-end; margin-top: 8px; pointer-events: none; }
@media (min-width: 900px) {
  .cast-dock { position: fixed; right: max(24px, calc((100vw - 1100px) / 2)); bottom: 20px; height: auto; margin: 0; z-index: 5; }
}
@media print { .cast-dock { display: none; } }
