/*
  Layout: one column sized for a screen on the music desk at arm's length. The course map is a keyboard
  on its side, one white key per stop, with black keys between them in the real two-and-three pattern.
  Colour comes from inside a piano: black lacquer (page), ivory key tops (anything you read music on),
  the red felt strip behind the keys (where you are, and the bed the on-screen keyboard sits on),
  and brass (points, pins and the main action).
  Type: Atkinson Hyperlegible Next. Note letters have to stay distinct at a distance (B and 8, C and G,
  D and O), and this face was drawn by the Braille Institute for exactly that. Noto Music supplies the
  clefs and rests because it carries the Unicode music symbols.
  Dials: ENERGY 2 / RHYTHM 2 / MOTION 2. Motion is limited to key presses, the beat pulse and the
  progress keys filling in.
*/
:root {
  --lacquer: #16110f;
  --lacquer-2: #211a17;
  --lacquer-3: #2e2521;
  --edge: #3d322c;
  --ivory: #f2eadb;
  --ivory-lit: #fff8ea;
  --ivory-shade: #cfc4b0;
  --ink: #0b0807;
  --felt: #8e1c28;
  --felt-hi: #b3293b;
  --felt-tint: #ead3cd;
  --brass: #d1ab55;
  --brass-ink: #6f5313;
  --on-brass: #0b0807;
  --text: #f2eadb;
  --text-2: #c2b6a2;
  --text-3: #988c79;
  --right: #8fc79a;
  --right-ink: #2b6537;
  --right-tint: #d5e8d3;
  --wrong: #f2948e;
  --wrong-ink: #9c2b25;
  --wrong-tint: #f3d1cd;
  --late-ink: #7d5200;
  --late-tint: #f1dfb8;
  --font: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-music: "Noto Music", "Apple Symbols", "Segoe UI Symbol", serif;
  --radius: 8px;
  --gutter: max(16px, env(safe-area-inset-left, 0px));
  --gutter-r: max(16px, env(safe-area-inset-right, 0px));
  color-scheme: dark;
}
:root[data-look="walnut"] { --lacquer: #24170f; --lacquer-2: #321f15; --lacquer-3: #452e20; --edge: #5a3d2b; }
:root[data-look="white"] {
  --lacquer: #f3efe7; --lacquer-2: #ffffff; --lacquer-3: #e2dbcd; --edge: #cbc1af;
  --text: #16110f; --text-2: #4b4239; --text-3: #6a5f53;
  --brass: #7d5e17; --on-brass: #ffffff; --right: #2b6537; --wrong: #9c2b25;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
/* no double-tap zoom on iPad, so quick taps on keys and buttons register as taps; pinch zoom still works */
html { touch-action: manipulation; -webkit-text-size-adjust: 100%; }
body {
  background: var(--lacquer);
  color: var(--text);
  font: 400 17px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
h1, h2, h3 { line-height: 1.2; text-wrap: balance; margin: 0; }
h1 { font-size: clamp(1.6rem, 4.5vw, 2.1rem); font-weight: 800; }
h2 { font-size: 1.2rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0; }
a { color: inherit; }
button, select, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--brass); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
.booting { padding: 40px var(--gutter); color: var(--text-2); }
.lead { font-size: 1.08rem; color: var(--text); max-width: 62ch; }
.sub { color: var(--text-2); font-size: 0.95rem; max-width: 62ch; }
.muted { color: var(--text-3); }
.small { font-size: 0.85rem; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row.tight { gap: 6px; }
.row.spread { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.stack { display: grid; gap: 18px; }
.stack > * { min-width: 0; }
.status { font-size: 0.95rem; color: var(--text-2); }
.status.good { color: var(--right); }
.status.bad { color: var(--wrong); }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: var(--radius);
  border: 1px solid var(--edge); background: var(--lacquer-2); color: var(--text);
  font-weight: 700; cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--text-3); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.primary { background: var(--brass); border-color: var(--brass); color: var(--on-brass); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 0.92rem; }
.btn.danger { color: var(--wrong); border-color: var(--wrong); }
.kbd { display: inline-grid; place-items: center; min-width: 1.5em; height: 1.5em; border-radius: 4px; border: 1px solid var(--edge); font-size: 0.75rem; color: var(--text-3); }

/* ---- shell ---- */
.app-shell { min-height: 100dvh; display: flex; flex-direction: column; }
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: var(--lacquer); border-bottom: 4px solid var(--felt); }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 30; background: var(--lacquer); }
.top-inner { max-width: 980px; margin: 0 auto; padding: 12px var(--gutter-r) 10px var(--gutter); display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; }
.brand { font-weight: 800; font-size: 1.3rem; text-decoration: none; letter-spacing: 0.01em; }
.stats-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-left: auto; }
.stat { display: inline-flex; align-items: center; gap: 6px; font-size: 0.92rem; color: var(--text-2); text-decoration: none; white-space: nowrap; }
.stat strong { color: var(--text); font-size: 1.05rem; }
.stat.pins strong, .stat.boost { color: var(--brass); }
.goalbar { width: 54px; height: 8px; border-radius: 0 0 3px 3px; background: var(--lacquer-3); overflow: hidden; }
.goalbar i { display: block; height: 100%; background: var(--brass); }
.weekkeys { display: inline-flex; gap: 2px; }
.wk { width: 16px; height: 22px; border-radius: 0 0 3px 3px; background: var(--lacquer-3); color: var(--text-3); font-size: 0.62rem; display: grid; place-items: end center; padding-bottom: 1px; }
.wk.on { background: var(--brass); color: var(--on-brass); }
.wk.rest { background: var(--edge); color: var(--text); }
.wk.today { box-shadow: inset 0 0 0 2px var(--felt-hi); }
.chip { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 12px; border-radius: 18px; border: 1px solid var(--edge); background: var(--lacquer-2); color: var(--text-2); font-size: 0.88rem; font-weight: 700; cursor: pointer; white-space: nowrap; }
.chip.live { color: var(--text); border-color: var(--right); }
.chip.blink { background: var(--lacquer-3); }
.lvl { display: none; gap: 2px; align-items: flex-end; height: 14px; }
.chip.mic .lvl { display: inline-flex; }
.lvl i { width: 3px; background: var(--edge); }
.lvl i:nth-child(1) { height: 5px; } .lvl i:nth-child(2) { height: 9px; } .lvl i:nth-child(3) { height: 14px; }
.lvl i.on { background: var(--right); }
.tabs { display: flex; justify-content: center; gap: 2px; padding: 0 var(--gutter-r) 0 var(--gutter); background: var(--lacquer); border-bottom: 1px solid var(--edge); overflow-x: auto; }
.tab { padding: 12px 14px 10px; text-decoration: none; color: var(--text-2); font-weight: 700; border-bottom: 3px solid transparent; white-space: nowrap; }
.tab.on { color: var(--text); border-bottom-color: var(--brass); }
.page { width: 100%; max-width: 760px; margin: 0 auto; padding: 24px var(--gutter-r) 96px var(--gutter); flex: 1; }
@media (max-width: 720px) {
  .tabs { position: fixed; bottom: 0; left: 0; right: 0; top: auto; z-index: 25; border-top: 1px solid var(--edge); border-bottom: 0; padding-bottom: env(safe-area-inset-bottom, 0px); justify-content: space-between; }
  .tab { flex: 1; text-align: center; padding: 12px 4px; font-size: 0.85rem; border-bottom: 0; border-top: 3px solid transparent; }
  .tab.on { border-top-color: var(--brass); }
  .stats-row { margin-left: 0; width: 100%; }
}
@media (max-width: 420px) { .weekkeys { display: none; } }

/* ---- course map ---- */
.path { display: grid; gap: 14px; }
.section { border: 1px solid var(--edge); border-radius: var(--radius); background: var(--lacquer-2); overflow: hidden; }
.section > summary { list-style: none; cursor: pointer; padding: 16px 18px; display: grid; grid-template-columns: auto 1fr auto; gap: 2px 12px; align-items: baseline; }
.section > summary::-webkit-details-marker { display: none; }
.section-n { color: var(--brass); font-weight: 800; font-size: 0.9rem; }
.section-title { font-weight: 800; font-size: 1.2rem; }
.section-goal { grid-column: 1 / -1; color: var(--text-2); font-size: 0.92rem; }
.tag { font-size: 0.78rem; color: var(--text-2); border: 1px solid var(--edge); border-radius: 12px; padding: 2px 10px; white-space: nowrap; }
.section.later > summary { opacity: 0.8; }
.section-body { padding: 4px 0 18px; border-top: 1px solid var(--edge); }
.testout { margin: 14px 18px 4px; padding: 12px 14px; border: 1px dashed var(--edge); border-radius: var(--radius); display: grid; gap: 8px; }
.unit { padding: 18px 18px 6px; }
.unit.later { padding: 10px 18px; }
.unit.later .unit-head h3 { color: var(--text-2); font-weight: 700; }
.unit-head { display: grid; gap: 2px; margin-bottom: 10px; }
.unit-n { color: var(--text-3); font-size: 0.82rem; font-weight: 700; }
.unit-head p { color: var(--text-2); font-size: 0.92rem; }
.unit.later .unit-head { margin-bottom: 0; }
.keys { list-style: none; margin: 0; padding: 0; border-left: 10px solid var(--felt); border-radius: 4px 0 0 4px; }
.keys li { position: relative; }
.lkey {
  /* The left of each white key is left clear, like the back of a real key, so the black keys never cover text. */
  width: 100%; min-height: 64px; display: grid; grid-template-columns: 1fr auto; grid-template-areas: "kind state" "title state";
  align-items: center; column-gap: 12px; row-gap: 0;
  padding: 10px 14px 10px 84px; border: 0; border-bottom: 1px solid var(--ivory-shade);
  background: var(--ivory); color: var(--ink); text-align: left; cursor: pointer;
  border-radius: 0 7px 7px 0; transition: transform 120ms ease, background 120ms ease;
}
.lkey:hover:not(.locked) { background: var(--ivory-lit); }
.lkey.current { background: var(--ivory-lit); transform: translateX(6px); box-shadow: inset 0 -5px 0 var(--felt); }
.lkey.locked { background: var(--lacquer-3); color: var(--text-3); border-bottom-color: var(--lacquer); cursor: default; }
.kkind { grid-area: kind; font-size: 0.78rem; font-weight: 800; color: var(--brass-ink); letter-spacing: 0.02em; }
.lkey.locked .kkind { color: var(--text-3); }
.ktitle { grid-area: title; font-weight: 700; min-width: 0; line-height: 1.3; }
.kstate { grid-area: state; font-size: 0.85rem; font-weight: 700; color: var(--text-3); white-space: nowrap; }
.kstate.done { color: var(--right-ink); }
.kstate.go { background: var(--brass); color: var(--on-brass); padding: 4px 12px; border-radius: 6px; }
.lkey.locked .kstate { color: var(--text-3); }
.bkey { position: absolute; left: 0; bottom: -13px; width: 64px; height: 26px; background: var(--ink); border-radius: 0 4px 4px 0; z-index: 2; pointer-events: none; box-shadow: inset -3px -2px 0 #2b2420; }
.lkey.song .kkind, .lkey.recital .kkind { color: var(--felt); }

/* ---- shared panels ---- */
.panel { border: 1px solid var(--edge); border-radius: var(--radius); background: var(--lacquer-2); padding: 18px; display: grid; gap: 10px; }
.rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; background: var(--edge); border: 1px solid var(--edge); border-radius: var(--radius); overflow: hidden; }
.rows li { display: flex; gap: 14px; align-items: center; justify-content: space-between; padding: 14px 16px; background: var(--lacquer-2); }
.rows li > div:first-child { min-width: 0; }
.rows li p { color: var(--text-2); font-size: 0.92rem; }
.rows li.locked h3 { color: var(--text-3); }
.panel .rows { border: 0; }
.score-chip { font-size: 0.85rem; font-weight: 700; color: var(--brass); white-space: nowrap; }
.songsec { display: grid; gap: 10px; }
.quests { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.quests li { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center; }
.qtext { display: grid; }
.qtext span { color: var(--brass); font-size: 0.85rem; font-weight: 700; }
.qbar { grid-column: 1 / -1; height: 12px; background: var(--lacquer-3); border-radius: 0 0 4px 4px; overflow: hidden; }
.qbar i { display: block; height: 100%; background: var(--brass); }
.quests li.done .qbar i { background: var(--right); }
.qnum { font-size: 0.9rem; color: var(--text-2); }
.pinbal { color: var(--brass); }
.statgrid { margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1px; background: var(--edge); border: 1px solid var(--edge); border-radius: var(--radius); overflow: hidden; }
.statgrid div { background: var(--lacquer-2); padding: 12px 14px; }
.statgrid dt { font-size: 0.82rem; color: var(--text-2); }
.statgrid dd { margin: 0; font-size: 1.4rem; font-weight: 800; }
.badges { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.badges li { padding: 12px; border: 1px dashed var(--edge); border-radius: var(--radius); display: grid; gap: 2px; color: var(--text-3); font-size: 0.88rem; }
.badges li strong { color: var(--text-2); font-size: 0.95rem; }
.badges li.earned { border-style: solid; border-color: var(--brass); color: var(--text-2); }
.badges li.earned strong { color: var(--text); }
.badges em { font-style: normal; color: var(--brass); font-size: 0.8rem; }
.chart svg { display: block; max-height: 120px; }
.chart .bar { fill: var(--text-3); }
.chart .bar.last { fill: var(--brass); }
.chart .grid { stroke: var(--edge); stroke-width: 1; }
.chart .axis { fill: var(--text-3); font-size: 9px; }
.field { display: grid; gap: 6px; }
.field label { font-weight: 700; }
.field select, .field input[type="range"] { max-width: 360px; }
select { min-height: 40px; padding: 0 10px; border-radius: 6px; border: 1px solid var(--edge); background: var(--lacquer); }
input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--brass); }
input[type="range"] { accent-color: var(--brass); }
.stack.narrow { max-width: 620px; }

/* ---- lesson ---- */
.lesson { min-height: 100dvh; display: flex; flex-direction: column; }
.lesson-top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10; display: flex; align-items: center; gap: 12px; padding: 10px var(--gutter-r) 10px var(--gutter); background: var(--lacquer); flex-wrap: wrap; }
.progress { flex: 1 1 200px; display: flex; gap: 3px; min-width: 140px; }
.pk { flex: 1; height: 14px; background: var(--lacquer-3); border-radius: 0 0 4px 4px; transition: background 200ms ease; }
.pk.on { background: var(--brass); }
.combo { font-weight: 800; color: var(--text-2); min-width: 0; }
.combo.hot { color: var(--brass); }
.timer { font-weight: 800; color: var(--text-2); }
.timer.big { font-size: 1.4rem; color: var(--text); }
.songlabel { font-weight: 800; color: var(--brass); flex: 1; }
.stage { flex: 1; display: flex; padding: 12px var(--gutter-r) 12px var(--gutter); }
.stage-inner { width: 100%; max-width: 680px; margin: 0 auto; display: grid; gap: 16px; align-content: start; }
.stage-inner.wide { max-width: 1000px; }
.stage-body { display: grid; gap: 14px; }
.stage-body > * { min-width: 0; }
.prompt { outline: none; }
.deck { position: sticky; bottom: 0; background: var(--lacquer); padding: 0 0 env(safe-area-inset-bottom, 0px); }
.deck.hidden-kb .felt, .deck.hidden-kb .keyhint { display: none; }
.hintline { min-height: 1.5em; padding: 6px var(--gutter-r) 6px var(--gutter); text-align: center; color: var(--text-2); font-weight: 700; }
.hintline.warn { color: var(--wrong); }
.felt { background: var(--felt); padding: 8px max(10px, env(safe-area-inset-right, 0px)) 12px max(10px, env(safe-area-inset-left, 0px)); }
.keyhint { text-align: center; font-size: 0.8rem; color: var(--text-3); padding: 6px var(--gutter); }
@media (pointer: coarse) { .keyhint { display: none; } }

.kb { position: relative; height: clamp(110px, 22vh, 190px); max-width: 1000px; margin: 0 auto; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.kb .key { -webkit-tap-highlight-color: transparent; }
.key { position: absolute; top: 0; padding: 0; border: 0; cursor: pointer; }
.key.white { height: 100%; background: var(--ivory); border-right: 1px solid #8f8571; border-radius: 0 0 6px 6px; display: flex; align-items: flex-end; justify-content: center; }
.key.black { height: 62%; background: var(--ink); border-radius: 0 0 4px 4px; z-index: 2; box-shadow: inset 0 -4px 0 #2b2420; }
.klabel { font-size: 0.78rem; font-weight: 700; color: #5b5244; padding-bottom: 6px; pointer-events: none; }
.key.white.teach { background: var(--felt-tint); box-shadow: inset 0 -8px 0 var(--felt); }
.key.black.teach { background: var(--felt-hi); }
.key.white.guide { background: var(--felt-tint); box-shadow: inset 0 -8px 0 var(--felt); }
.key.black.guide { background: var(--felt-hi); }
.key.white.target { box-shadow: inset 0 -8px 0 var(--brass); }
.key.black.target { box-shadow: inset 0 -8px 0 var(--brass); }
.key.white.down, .key.white.played { background: var(--brass); }
.key.black.down, .key.black.played { background: #8a6a1f; }
.key.missed { background: var(--wrong-tint) !important; }
.key.black.missed { background: var(--wrong-ink) !important; }

.card.ivory { background: var(--ivory); color: var(--ink); border-radius: var(--radius); padding: 10px 12px; }
.staffbox svg { display: block; height: clamp(150px, 30vh, 250px); width: auto; max-width: 100%; margin: 0 auto; }
.scorebox { overflow-x: auto; }
.scorebox svg.score { display: block; width: 100%; height: auto; max-height: 36vh; min-width: 280px; }
.scorebox svg.strip { display: block; height: 64px; width: auto; margin: 4px 0; }
.staffbox.rhythmbox svg { height: clamp(90px, 16vh, 130px); }
.gapbox { fill: none; stroke: var(--felt); stroke-width: 1.5; stroke-dasharray: 3 2; }
.gapq { fill: var(--felt); font: 800 14px var(--font); }
.hidden-rhythm { padding: 30px 10px; text-align: center; font-weight: 700; }
.bigletter { font-size: clamp(5rem, 18vw, 8.5rem); font-weight: 800; text-align: center; line-height: 1; color: var(--text); }
.teach, .cardbody { display: grid; gap: 14px; }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.btn.choice { min-height: 56px; justify-content: flex-start; font-size: 1.1rem; padding: 6px 14px; text-align: left; }
.btn.choice:has(.choice-svg) { background: var(--ivory); color: var(--ink); border-color: var(--ivory-shade); flex-direction: column; align-items: stretch; padding: 8px; min-height: 0; }
.btn.choice:has(.choice-svg) .kbd { align-self: flex-start; color: #5b5244; border-color: var(--ivory-shade); }
.choice-svg svg { display: block; height: 70px; width: 100%; }
.btn.wrongpick { border-color: var(--wrong) !important; box-shadow: inset 0 0 0 2px var(--wrong); }
.listen { justify-self: start; }
.pairs { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pairs-col { display: grid; gap: 10px; align-content: start; }
.btn.pair { min-height: 70px; background: var(--ivory); color: var(--ink); border-color: var(--ivory-shade); padding: 6px; }
.btn.pair svg { height: 104px; width: auto; max-width: 100%; }
.btn.namepair { background: var(--lacquer-2); color: var(--text); border-color: var(--edge); font-size: 1.3rem; }
.btn.pair.sel { box-shadow: inset 0 0 0 3px var(--felt); }
.btn.pair.matched { opacity: 0.45; box-shadow: inset 0 0 0 2px var(--right); }
.slots { display: flex; flex-wrap: wrap; gap: 8px; }
.slot { min-width: 64px; min-height: 64px; display: grid; place-items: center; border: 2px dashed var(--edge); border-radius: var(--radius); font-size: 1.6rem; font-weight: 800; }
.slot svg { height: 60px; width: auto; background: var(--ivory); border-radius: 6px; }
.cards { display: flex; flex-wrap: wrap; gap: 10px; }
.btn.notecard { min-width: 72px; min-height: 72px; background: var(--ivory); color: var(--ink); border-color: var(--ivory-shade); font-size: 1.6rem; padding: 4px 10px; }
.btn.notecard svg { height: 64px; width: auto; }
.btn.notecard:disabled { opacity: 0.3; }
.dots { display: flex; gap: 10px; justify-content: center; }
.dotmark { width: 26px; height: 34px; border-radius: 0 0 5px 5px; background: var(--lacquer-3); }
.dotmark.ok { background: var(--brass); }
.minikey .mk-w { fill: var(--ivory); stroke: var(--ink); stroke-width: 1; }
.minikey .mk-b { fill: var(--ink); }
.minikey .on { fill: var(--felt); }
.picker .pick { fill: transparent; cursor: pointer; }
.picker .pick:hover { fill: rgba(142, 28, 40, 0.18); }
.beatlights { display: flex; gap: 6px; justify-content: center; }
.beatlights span { width: 34px; height: 46px; border-radius: 0 0 6px 6px; background: var(--lacquer-3); }
.beatlights span.on { background: var(--brass); }
.beatlights.counting span.on { background: var(--felt-hi); }
.tappad { width: 100%; min-height: 120px; border-radius: var(--radius); border: 0; background: var(--ivory); color: var(--ink); font-weight: 800; font-size: 1.1rem; cursor: pointer; touch-action: manipulation; }
.tappad.hit { background: var(--brass); }
.pulse { width: 110px; height: 110px; margin: 0 auto; border-radius: 50%; background: var(--lacquer-3); }
.pulse.on { animation: pulse 260ms ease-out; background: var(--brass); }
.pulse.on.counting { background: var(--felt-hi); }
@keyframes pulse { from { transform: scale(1.12); } to { transform: scale(1); } }
.dyn { display: flex; gap: 20px; justify-content: center; font-family: var(--font-music); }
.dynmark { font-size: 3rem; font-style: italic; font-weight: 800; color: var(--brass); font-family: Georgia, "Times New Roman", serif; }

.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; padding: 0 0 env(safe-area-inset-bottom, 0px); }
.sheet-inner { max-width: 760px; margin: 0 auto; background: var(--lacquer-2); border: 1px solid var(--edge); border-bottom: 0; border-radius: 12px 12px 0 0; padding: 18px var(--gutter-r) 20px var(--gutter); display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; justify-content: space-between; }
.sheet-inner.good { border-top: 5px solid var(--right); }
.sheet-inner.bad { border-top: 5px solid var(--wrong); }
.sheet-inner.good h2 { color: var(--right); }
.sheet-inner.bad h2 { color: var(--wrong); }
.sheet-text { display: grid; gap: 4px; min-width: 0; flex: 1 1 280px; }
.sheet-actions { display: flex; gap: 8px; }
.why { color: var(--text-2); font-size: 0.95rem; }
.confirm, .overlay { position: fixed; inset: 0; z-index: 60; background: rgba(5, 3, 2, 0.72); display: grid; place-items: center; padding: 16px; }
.confirm-box { background: var(--lacquer-2); border: 1px solid var(--edge); border-radius: 12px; padding: 22px; display: grid; gap: 12px; max-width: 420px; }
.overlay { place-items: start center; overflow-y: auto; }
.overlay-box { background: var(--lacquer); border: 1px solid var(--edge); border-radius: 12px; padding: 20px; width: min(720px, 100%); }

/* ---- music drawing ---- */
.score .staff, .score .bar, .score .ledger { stroke: var(--ink); stroke-width: 1; }
.score .ledger { stroke-width: 1.2; }
.score .barthick { fill: var(--ink); }
.score .glyph, .score .timesig { fill: var(--ink); }
.score .timesig { font-family: var(--font); font-weight: 800; }
.score .ev { color: var(--ink); }
.score .ev .head, .score .ev .beam, .score .ev .flag, .score .ev .glyph, .score .ev .dot, .score .ev .tie, .score .ev .rest { fill: currentColor; }
.score .ev .head.hollow { fill: none; stroke: currentColor; stroke-width: 1.7; }
.score .ev .head.whole { stroke-width: 2.3; }
.score .ev .stem, .score .ev .ledger { stroke: currentColor; stroke-width: 1.3; }
.score .inhead { fill: var(--ivory); font-weight: 800; font-family: var(--font); }
.score .ev.st-now { color: var(--felt); }
.score .ev.st-done { color: var(--right-ink); }
.score .ev.st-miss { color: var(--wrong-ink); }
.score .ev.st-early, .score .ev.st-late { color: var(--late-ink); }
.score .ev.st-gap { opacity: 0; }
.strip .box { fill: var(--ivory-lit); stroke: var(--ivory-shade); stroke-width: 1.5; }
.strip .box.rest { fill: none; stroke-dasharray: 4 3; }
.strip .boxlabel { font: 800 24px var(--font); fill: var(--ink); }
.strip .restlabel { font-size: 13px; font-weight: 700; fill: #5b5244; }
.strip .boxsub { font: 700 12px var(--font); fill: #5b5244; }
.strip .hold { stroke: var(--ink); stroke-width: 2; stroke-linecap: round; opacity: 0.5; }
.strip .bar { stroke: var(--ink); stroke-width: 1.5; }
.strip .st-now .box { fill: var(--felt); stroke: var(--felt); }
.strip .st-now .boxlabel, .strip .st-now .boxsub { fill: var(--ivory); }
.strip .st-now .hold { stroke: var(--ivory); }
.strip .st-done .box { fill: var(--right-tint); stroke: var(--right-ink); }
.strip .st-miss .box { fill: var(--wrong-tint); stroke: var(--wrong-ink); }
.strip .st-early .box, .strip .st-late .box { fill: var(--late-tint); stroke: var(--late-ink); }

/* ---- song mode ---- */
.songstrip { position: relative; overflow: hidden; background: var(--ivory); border-radius: var(--radius); padding: 8px 0; }
.songinner { will-change: transform; }
.songinner svg { display: block; }
.playhead { position: absolute; top: 0; bottom: 0; left: 25%; width: 3px; background: var(--felt); opacity: 0.85; }
.songcontrols { display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: center; color: var(--text-2); }
.songcontrols label { display: inline-flex; align-items: center; gap: 8px; }
.songresults { display: grid; gap: 12px; padding: 16px; border: 1px solid var(--edge); border-radius: var(--radius); background: var(--lacquer-2); }
.bigscore { display: flex; align-items: baseline; gap: 10px; }
.bigscore .num { font-size: 3.2rem; font-weight: 800; color: var(--brass); }
.stats { display: flex; flex-wrap: wrap; gap: 10px 28px; margin: 0; }
.stats dt { font-size: 0.85rem; color: var(--text-2); }
.stats dd { margin: 0; font-size: 1.3rem; font-weight: 800; }

/* ---- setup and onboarding ---- */
.setup { display: grid; gap: 16px; }
.soundcheck { display: grid; gap: 12px; }
.sc-prompt { font-size: 1.3rem; }
.sc-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.sc-steps li { display: grid; padding: 6px 10px; border: 1px solid var(--edge); border-radius: 0 0 6px 6px; font-weight: 800; min-width: 64px; }
.sc-steps li span { font-weight: 400; font-size: 0.75rem; color: var(--text-3); }
.sc-steps li.now { border-color: var(--felt-hi); box-shadow: inset 0 -4px 0 var(--felt-hi); }
.sc-steps li.ok { border-color: var(--right); color: var(--right); }
.sc-steps li.bad { border-color: var(--wrong); color: var(--wrong); }
.sc-felt { border-radius: var(--radius); }
.sc-summary { margin: 0; padding-left: 20px; display: grid; gap: 6px; color: var(--text-2); max-width: 62ch; }
.sc-good { color: var(--right); }
.sc-warn { color: var(--brass); }
.diag { display: grid; gap: 8px; padding-top: 12px; border-top: 1px solid var(--edge); }
.checklist { margin: 0; padding-left: 20px; display: grid; gap: 6px; color: var(--text-2); font-size: 0.95rem; max-width: 62ch; }
.miclive { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center; }
.meter { position: relative; height: 14px; background: var(--lacquer-3); border-radius: 0 0 4px 4px; overflow: hidden; }
.meter .fill { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--right); }
.meter .gate { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--felt-hi); }
.micread { display: flex; gap: 10px; align-items: baseline; }
.micnote { font-size: 1.8rem; font-weight: 800; min-width: 2.5ch; }
.micnote.empty { font-size: 0.95rem; font-weight: 700; color: var(--text-3); }
.cents { color: var(--text-2); font-size: 0.9rem; }
.onboard-wrap, .done-wrap { min-height: 100dvh; display: grid; place-items: start center; padding: 48px var(--gutter-r) 48px var(--gutter); }
.onboard { width: min(680px, 100%); display: grid; gap: 18px; }
.hero-title { font-size: clamp(2.6rem, 9vw, 4rem); border-bottom: 6px solid var(--felt); padding-bottom: 8px; }
.bigchoices { display: grid; gap: 10px; }
.btn.bigchoice { min-height: 76px; flex-direction: column; align-items: flex-start; justify-content: center; padding: 12px 18px; text-align: left; gap: 2px; }
.btn.bigchoice span { font-weight: 400; color: var(--text-2); }
.btn.bigchoice.suggested { border-color: var(--brass); }
.done-screen { width: min(620px, 100%); display: grid; gap: 22px; }
.rewards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--edge); border: 1px solid var(--edge); border-radius: var(--radius); overflow: hidden; }
.reward { background: var(--lacquer-2); padding: 14px; display: grid; }
.reward .num { font-size: 2rem; font-weight: 800; color: var(--brass); }
.reward span:last-child { color: var(--text-2); font-size: 0.9rem; }
.notes { margin: 0; padding-left: 20px; color: var(--text-2); display: grid; gap: 4px; }
.timedbox { min-height: 160px; display: grid; place-items: center; }
.timedbox .bigletter { color: var(--ink); }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(80px + env(safe-area-inset-bottom, 0px)); z-index: 80; background: var(--ivory); color: var(--ink); padding: 12px 18px; border-radius: var(--radius); font-weight: 700; max-width: min(92vw, 520px); }

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