:root {
  --bg: #f7f3ec;
  --paper: #fffdf8;
  --ink: #1f1d1a;
  --muted: #6b655c;
  --line: #e3dccf;
  --accent: #1f5f5b;
  --accent-ink: #fff;
  --melody: #d9622b;
  --acc: #2f6db0;
  --good: #1f7a4d;
  --bad: #b3261e;
  --miss: #9a948a;
  --lane: rgba(0, 0, 0, .05);
  --grid: rgba(0, 0, 0, .09);
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.05);
  --tab-h: 58px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16150f; --paper: #211f19; --ink: #f1ece2; --muted: #a59e91; --line: #39352c;
    --accent: #5bb5ad; --accent-ink: #0f1513; --melody: #f08a55; --acc: #6aa2e6; --good: #5cc48d; --bad: #f2867e; --miss: #6f6a61;
    --lane: rgba(255,255,255,.05); --grid: rgba(255,255,255,.08);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: .4em 0 .3em; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 1.2em 0 .4em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin: .5rem 0; }
.row.center { justify-content: center; }
.row.wrap { flex-wrap: wrap; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* shell */
#app { min-height: 100dvh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; padding: calc(env(safe-area-inset-top) + 8px) 14px 8px; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; text-decoration: none; color: var(--ink); display: flex; align-items: center; gap: .35rem; }
.logo { font-size: 1.4rem; line-height: 1; font-family: "Noto Music", "Bravura", "Segoe UI Symbol", "Apple Symbols", serif; }
.top-right { display: flex; align-items: center; gap: .5rem; }
.gear { text-decoration: none; font-size: 1.25rem; color: var(--ink); padding: 4px 6px; }
#view { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 8px 14px calc(var(--tab-h) + 24px + env(safe-area-inset-bottom)); outline: none; }
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); display: flex; background: var(--paper); border-top: 1px solid var(--line); z-index: 5; }
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-decoration: none; color: var(--muted); font-size: .78rem; gap: 2px; }
.tabbar a span { font-size: 1.15rem; line-height: 1; }
.tabbar a[aria-current="page"] { color: var(--accent); font-weight: 600; }
#app.focus .tabbar { display: none; }
#app.focus #view { padding-bottom: calc(20px + env(safe-area-inset-bottom)); }

/* buttons & chips */
.btn { appearance: none; border: 1px solid var(--line); background: var(--paper); color: var(--ink); border-radius: 999px; padding: .6rem 1rem; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: .35rem; min-height: 44px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.big { padding: .8rem 1.4rem; font-size: 1.05rem; min-height: 52px; }
.btn.small { min-height: 34px; padding: .3rem .8rem; font-size: .9rem; }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn:disabled { opacity: .5; }
.chip { appearance: none; border: 1px solid var(--line); background: var(--paper); color: var(--ink); border-radius: 999px; padding: .3rem .7rem; font: inherit; font-size: .85rem; cursor: pointer; min-height: 34px; }
.chip.toggle[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip.toggle[aria-pressed="true"]::before { content: "✓ "; }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
select, input[type=range] { font: inherit; }
select { padding: .35rem .5rem; border-radius: 8px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); min-height: 38px; }
label { font-size: .9rem; display: inline-flex; align-items: center; gap: .4rem; }
label.check { display: flex; margin: .6rem 0; }

/* cards & path */
.hero { padding: 1rem 0 .3rem; }
.hero h1 { font-size: 1.7rem; line-height: 1.15; }
.card { display: flex; flex-direction: column; gap: 2px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; text-decoration: none; color: var(--ink); box-shadow: var(--shadow); margin: .6rem 0; }
.card b { font-size: 1.1rem; }
.card span { color: var(--muted); font-size: .92rem; }
.card .eyebrow { text-transform: uppercase; letter-spacing: .06em; font-size: .72rem; font-weight: 700; color: var(--accent); }
.card.next { border: 2px solid var(--accent); }
.card.due { border: 2px dashed var(--melody); }
.card.due .eyebrow { color: var(--melody); }
.path { list-style: none; padding: 0; margin: 1rem 0; }
.unit { margin-bottom: 1.1rem; }
.unit-head { display: flex; gap: .7rem; align-items: flex-start; }
.unit-head h2 { margin: 0; }
.unit-head p { margin: .1rem 0 .3rem; color: var(--muted); font-size: .9rem; }
.unit-n { flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--ink); color: var(--bg); display: grid; place-items: center; font-weight: 700; font-size: .9rem; margin-top: 2px; }
.unit ul { list-style: none; padding: 0 0 0 14px; margin: 0 0 0 14px; border-left: 2px solid var(--line); }
.lesson-link { display: flex; align-items: center; gap: .7rem; padding: .55rem .4rem; text-decoration: none; color: var(--ink); border-radius: 10px; }
.lesson-link:hover { background: var(--paper); }
.lesson-link .node { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--line); background: var(--paper); font-weight: 700; margin-left: -32px; }
.lesson-link.done .node { background: var(--good); border-color: var(--good); color: #fff; }
.lesson-link.is-next .node { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.lesson-link .lt { display: flex; flex-direction: column; font-weight: 600; }
.lesson-link small { font-weight: 400; color: var(--muted); }
.songlist { list-style: none; padding: 0; }
.songlist small { margin-top: .2rem; }

/* lesson runner */
.lesson-top { display: flex; align-items: center; gap: .7rem; position: sticky; top: 56px; background: var(--bg); padding: .4rem 0; z-index: 3; }
.lesson-top .x { text-decoration: none; font-size: 1.2rem; color: var(--muted); padding: 4px 8px; }
.lesson-top .bar { flex: 1; height: 10px; border-radius: 999px; background: var(--line); overflow: hidden; }
.lesson-top .bar span { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s; }
.lesson-top .count { font-size: .85rem; color: var(--muted); min-width: 2.5em; text-align: right; }
.drill-title { font-size: 1.25rem; margin: .5rem 0; }
.learn-body { font-size: 1.08rem; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.lead { font-size: 1.05rem; }
.prompt { text-align: center; margin: .6rem 0; }
.bigname { font-size: 4rem; font-weight: 800; line-height: 1; letter-spacing: -.02em; min-height: 0; }
.bigname:empty { display: none; }
.chordname { color: var(--acc); }
.prompt .sub { color: var(--muted); }
.mini-staff { max-width: 260px; margin: 0 auto; }
.dstatus { text-align: center; min-height: 1.5em; font-weight: 500; }
.dots { display: flex; gap: 6px; justify-content: center; margin: .4rem 0; }
.dots span { width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.dots span.done { background: var(--good); }
.dots span.cur { background: var(--accent); transform: scale(1.3); }
.options, .choice { display: grid; gap: .5rem; margin: .8rem 0; }
.opt { appearance: none; text-align: left; border: 2px solid var(--line); background: var(--paper); color: var(--ink); border-radius: 12px; padding: .8rem 1rem; font: inherit; font-size: 1.05rem; cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.opt small { color: var(--muted); font-size: .85rem; }
.opt.right { border-color: var(--good); background: color-mix(in srgb, var(--good) 10%, var(--paper)); }
.opt.wrong { border-color: var(--bad); color: var(--bad); }
.pad { display: block; width: 100%; height: 120px; border-radius: 20px; border: 2px solid var(--line); background: var(--paper); font: 800 1.6rem system-ui; color: var(--muted); margin: .6rem 0; touch-action: none; }
.pad.hit { background: var(--accent); color: var(--accent-ink); }
.pad[hidden] { display: none; }
.beatrow { display: flex; gap: 4px; justify-content: center; flex-wrap: wrap; }
.beatrow span { width: 42px; height: 42px; border-radius: 10px; border: 2px solid var(--line); display: grid; place-items: center; font-weight: 700; font-size: .8rem; }
.beatrow span.now { border-color: var(--accent); }
.beatrow span.ok { background: var(--good); color: #fff; border-color: var(--good); }
.beatrow span.off { border-style: dashed; border-color: var(--melody); }
.done-card { text-align: center; padding: 2rem 0; }
.big-check { width: 84px; height: 84px; margin: 0 auto; border-radius: 50%; background: var(--good); color: #fff; font-size: 3rem; display: grid; place-items: center; }

/* keyboard */
.kbwrap { margin: .5rem 0; }
.kb { position: relative; height: clamp(90px, 14vh, 170px); user-select: none; -webkit-user-select: none; touch-action: none; }
.kbwrap.small .kb { height: 100px; }
.key { position: absolute; top: 0; padding: 0; margin: 0; font: inherit; border: 1px solid #8a847a; cursor: pointer; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.key.white { height: 100%; background: #fffefb; border-radius: 0 0 6px 6px; z-index: 1; color: #333; }
.key.black { height: 62%; background: #24221e; border-color: #000; border-radius: 0 0 4px 4px; z-index: 2; color: #fff; }
.key .klabel { font-size: .62rem; color: #7d776d; margin-bottom: 4px; }
.key .khint { font-size: .7rem; font-weight: 800; margin-bottom: 18px; pointer-events: none; }
.key.black .khint { margin-bottom: 6px; }
.key.hint-m { background: color-mix(in srgb, var(--melody) 45%, #fffefb); }
.key.black.hint-m { background: color-mix(in srgb, var(--melody) 70%, #24221e); }
.key.hint-a { background: color-mix(in srgb, var(--acc) 40%, #fffefb); }
.key.black.hint-a { background: color-mix(in srgb, var(--acc) 70%, #24221e); }
.key.down { filter: brightness(.85); transform: translateY(1px); }
.key.good { box-shadow: inset 0 -6px 0 var(--good); }
.key.bad { box-shadow: inset 0 -6px 0 var(--bad); }
.key.bad::after { content: "✗"; position: absolute; top: 4px; font-size: .7rem; color: var(--bad); }
.key.black.bad::after { color: #ffb4ab; }

/* player */
.player { display: flex; flex-direction: column; gap: .3rem; }
.pcontrols .seg { display: flex; background: var(--paper); border: 1px solid var(--line); border-radius: 999px; padding: 3px; margin: .3rem 0; }
.seg button { flex: 1; appearance: none; border: 0; background: none; color: var(--ink); font: inherit; font-weight: 600; font-size: .9rem; padding: .5rem .2rem; border-radius: 999px; cursor: pointer; min-height: 40px; }
.seg button[aria-selected="true"] { background: var(--ink); color: var(--bg); }
.tempo input { width: 120px; }
.pnotice { background: color-mix(in srgb, var(--acc) 10%, var(--paper)); border: 1px solid color-mix(in srgb, var(--acc) 35%, var(--line)); border-radius: 10px; padding: .1rem .8rem; font-size: .88rem; }
.pnotice p { margin: .45rem 0; }
.sheet { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px; max-height: 32vh; overflow-y: auto; overscroll-behavior: contain; }
.opts summary { cursor: pointer; font-size: .9rem; color: var(--muted); padding: .3rem .2rem; }
.opts[open] summary { color: var(--ink); }
.sheet[hidden], .rollwrap[hidden] { display: none; }
.leadsheet { width: 100%; height: auto; display: block; }
.leadsheet .staff { stroke: var(--ink); stroke-width: 1; opacity: .75; }
.leadsheet .barline { stroke: var(--ink); stroke-width: 1.2; }
.leadsheet .barline.end { stroke-width: 3; }
.leadsheet .barnum { font-size: 8px; fill: var(--muted); }
.leadsheet .clef { font-size: 44px; fill: var(--ink); font-family: "Noto Music", "Bravura", "Segoe UI Symbol", "Apple Symbols", serif; }
.leadsheet .timesig { font: 800 14px system-ui; fill: var(--ink); }
.leadsheet .chordsym { font: 700 15px system-ui, sans-serif; fill: var(--acc); }
.leadsheet .head { fill: var(--ink); stroke: var(--ink); stroke-width: 1.2; }
.leadsheet .head.open { fill: var(--paper); stroke-width: 1.8; }
.leadsheet .stem, .leadsheet .flag { stroke: var(--ink); stroke-width: 1.3; fill: var(--ink); }
.leadsheet .dot, .leadsheet .rest { fill: var(--ink); }
.leadsheet .qrest { fill: none; stroke: var(--ink); stroke-width: 2.2; }
.leadsheet .acc { font-size: 14px; fill: var(--ink); }
.leadsheet .notename { font: 600 10px system-ui; fill: var(--muted); }
.leadsheet .mark { font: 800 11px system-ui; }
.leadsheet .note.current .head { fill: var(--melody); stroke: var(--melody); }
.leadsheet .note.current .head.open { fill: color-mix(in srgb, var(--melody) 30%, var(--paper)); }
.leadsheet .note.ok .head { fill: var(--good); stroke: var(--good); }
.leadsheet .note.ok .mark { fill: var(--good); }
.leadsheet .note.miss .head { fill: var(--bad); stroke: var(--bad); }
.leadsheet .note.miss .mark { fill: var(--bad); }
.leadsheet .note.off .head { fill: var(--melody); stroke: var(--melody); }
.leadsheet .note.off .mark { fill: var(--melody); }
.leadsheet .playhead { stroke: var(--accent); stroke-width: 2.5; opacity: .8; }
.rollwrap { height: clamp(120px, 21vh, 300px); background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; overflow: hidden; margin-bottom: -.5rem; }
.roll { width: 100%; height: 100%; display: block; }
.rollwrap:not([hidden]) + .kbwrap { margin-top: 0; }
.pstatus { min-height: 1.5em; text-align: center; font-weight: 600; }
.pactions { display: flex; gap: .5rem; justify-content: center; flex-wrap: wrap; position: sticky; bottom: calc(var(--tab-h) + 8px + env(safe-area-inset-bottom)); padding: .3rem 0; }
#app.focus .pactions { bottom: calc(8px + env(safe-area-inset-bottom)); }
.results { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: .2rem 1rem .6rem; }
.results h3 { margin: .6rem 0 .3rem; }
.metrics { list-style: none; padding: 0; margin: .4rem 0; }
.metrics li { padding: .25rem 0; }
.metrics .mi { display: inline-block; width: 1.4em; text-align: center; color: var(--muted); }
.tip { background: color-mix(in srgb, var(--accent) 10%, var(--paper)); border-radius: 10px; padding: .6rem .8rem; }
.note { font-size: .9rem; color: var(--accent); font-weight: 600; }
.big-ok { font-weight: 600; }
.screen-top { display: flex; align-items: center; gap: .6rem; }
.screen-top h1 { flex: 1; font-size: 1.25rem; margin: .3rem 0; }
.back { text-decoration: none; font-weight: 600; }

/* jam */
.jam-now { text-align: center; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem; }
.jam-chord { font-size: clamp(4rem, 22vw, 7rem); font-weight: 800; line-height: 1; color: var(--acc); }
.jam-next { color: var(--muted); }
.jam-bar { display: flex; justify-content: center; gap: 6px; margin-top: .4rem; min-height: 28px; }
.jam-bar span { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-size: .8rem; font-weight: 700; }
.jam-bar span.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.jam-strip { display: flex; gap: 3px; margin: .6rem 0; overflow-x: auto; }
.jam-strip span { min-width: 34px; text-align: center; padding: .35rem .2rem; border-radius: 8px; background: var(--paper); border: 1px solid var(--line); font-weight: 700; font-size: .9rem; }
.jam-strip span.on { background: var(--acc); color: #fff; border-color: var(--acc); }

/* progress & settings */
.skills, .reviews { list-style: none; padding: 0; }
.skills li, .reviews li { display: flex; justify-content: space-between; gap: .5rem; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.lvl { font-size: .8rem; font-weight: 700; padding: .1rem .55rem; border-radius: 999px; border: 1px solid var(--line); white-space: nowrap; }
.lvl-unseen { color: var(--muted); }
.lvl-introduced { border-style: dashed; }
.lvl-guided { border-color: var(--acc); color: var(--acc); }
.lvl-independent, .lvl-retained, .lvl-transferred { background: var(--good); border-color: var(--good); color: #fff; }
.attempts { width: 100%; border-collapse: collapse; font-size: .85rem; }
.attempts th, .attempts td { text-align: left; padding: .35rem .3rem; border-bottom: 1px solid var(--line); }
.attempts tr.invalid td { color: var(--muted); font-style: italic; }
.settings section { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: .2rem 1rem .8rem; margin: .8rem 0; }
.vol { display: flex; justify-content: space-between; margin: .4rem 0; }
.vol input { width: 55%; }
.meter { margin: .5rem 0; }
.meter .lvl { height: 10px; border-radius: 99px; background: var(--line); overflow: hidden; padding: 0; border: 0; }
.meter .lvl span { display: block; height: 100%; width: 0; background: var(--good); transition: width .08s; }
.error { color: var(--bad); }

dialog.welcome { border: 0; border-radius: 18px; padding: 1.2rem; max-width: 420px; width: calc(100% - 28px); background: var(--bg); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog.welcome::backdrop { background: rgba(0,0,0,.45); }

@media (min-width: 700px) {
  .bigname { font-size: 5rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}


/* ---------- camera overlay ---------- */
.camwrap { height: clamp(200px, 36vh, 440px); margin: .3rem 0; }
.camwrap[hidden], .rollwrap.off { display: none; }
.cam { position: relative; width: 100%; height: 100%; background: #000; border-radius: var(--radius); overflow: hidden; }
.cam video, .cam canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.cam canvas { touch-action: none; }
.cam.aligning canvas { cursor: grab; }
.cam-bar { position: absolute; top: 6px; left: 6px; right: 6px; display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; pointer-events: none; }
.cam-bar .chip, .cam-bar select { pointer-events: auto; background: rgba(0,0,0,.6); color: #fff; border-color: rgba(255,255,255,.4); }
.cam-bar .chip.done { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.cam-bar [hidden] { display: none; }
.cam-align { display: inline-flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.cam-align label { color: #fff; font-size: .8rem; text-shadow: 0 1px 2px #000; pointer-events: auto; }
.cam-align select { min-height: 30px; padding: .1rem .3rem; }
.cam-msg { position: absolute; left: 6px; right: 6px; top: 44px; color: #fff; font-size: .8rem; text-shadow: 0 1px 2px #000; pointer-events: none; }
.cam-msg:empty { display: none; }
.cam.aligning .cam-msg { background: rgba(0,0,0,.55); border-radius: 8px; padding: .25rem .5rem; }

/* ---------- input popover, top bar extras ---------- */
#input-chip { display: inline-flex; align-items: center; gap: .3rem; }
#input-chip .caret { font-size: .7rem; color: var(--muted); }
.lvl-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--good); transition: transform .08s; }
.popover { position: fixed; top: calc(env(safe-area-inset-top) + 52px); right: 10px; z-index: 20; width: min(340px, calc(100vw - 20px)); max-height: calc(100dvh - 70px); overflow: auto; background: var(--paper); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 12px 40px rgba(0,0,0,.25); padding: .7rem; }
.popover[hidden] { display: none; }
.pop-title { font-weight: 700; margin: .1rem .2rem .5rem; }
.pop-opt { appearance: none; width: 100%; display: flex; gap: .6rem; align-items: flex-start; text-align: left; border: 2px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 12px; padding: .55rem .7rem; margin-bottom: .4rem; font: inherit; cursor: pointer; }
.pop-opt .pi { font-size: 1.3rem; line-height: 1.2; }
.pop-opt small { display: block; color: var(--muted); font-size: .8rem; }
.pop-opt.sel { border-color: var(--accent); }
.pop-status { font-size: .88rem; margin: .4rem .2rem; }
.pop-foot { font-size: .85rem; margin: .4rem .2rem 0; }
.rotate-tip { display: flex; align-items: center; justify-content: space-between; gap: .5rem; background: color-mix(in srgb, var(--accent) 14%, var(--paper)); padding: .45rem .8rem; font-size: .88rem; border-bottom: 1px solid var(--line); }
.rotate-tip[hidden] { display: none; }
.rotate-tip button { appearance: none; border: 0; background: none; color: var(--ink); font-size: 1rem; padding: 4px 8px; cursor: pointer; }
button.gear { appearance: none; border: 0; background: none; cursor: pointer; font: inherit; font-size: 1.2rem; }
button.gear[hidden] { display: none; }
.skip-step { appearance: none; border: 0; background: none; color: var(--muted); font: inherit; font-size: .85rem; cursor: pointer; padding: 4px 6px; }
.skip-step[hidden] { display: none; }

/* ---------- landscape phones: everything on one screen ---------- */
@media (orientation: landscape) and (max-height: 600px) {
  .topbar { padding: calc(env(safe-area-inset-top) + 2px) 12px 2px; }
  .brand { font-size: .95rem; }
  .popover { top: 44px; }
  #app.focus { height: 100dvh; min-height: 0; }
  #app.focus #view { max-width: none; flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 4px max(10px, env(safe-area-inset-right)) calc(4px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); overflow: hidden; }
  #app.focus .screen { flex: 1; min-height: 0; display: flex; flex-direction: column; }
  #app.focus .screen > p.muted { display: none; }
  .screen-top h1 { font-size: 1rem; margin: 0; }
  .screen-top .btn.small { min-height: 28px; }
  .lesson-top { position: static; padding: 0 0 2px; }
  #app.focus .lesson-step { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: auto; }
  .lesson-step > .drill-title { margin: 0 0 .2rem; font-size: 1rem; }
  .pbox, .jbox { flex: 1; min-height: 0; display: flex; flex-direction: column; }

  /* song player: notation + controls on the left, falling notes + keys on the right */
  .player { flex: 1; min-height: 0; display: grid; gap: 4px 12px;
    grid-template-columns: minmax(260px, 44%) 1fr;
    grid-template-rows: auto auto minmax(0, 1fr) auto auto auto;
    grid-template-areas: "controls roll" "notice roll" "sheet roll" "sheet kb" "status kb" "actions kb"; }
  .player:has(.rollwrap[hidden]) { grid-template-rows: auto auto minmax(0, 1fr) auto; grid-template-areas: "controls sheet" "notice sheet" "status sheet" "actions kb"; }
  .player:has(.sheet[hidden]) { grid-template-rows: auto auto minmax(0, 1fr) auto; grid-template-areas: "controls roll" "notice roll" "status roll" "actions kb"; }
  .pcontrols { grid-area: controls; }
  .pcontrols .seg { margin: 0; }
  .seg button { min-height: 32px; padding: .25rem .2rem; font-size: .8rem; }
  .pnotice { grid-area: notice; font-size: .78rem; max-height: 4.5em; overflow: auto; }
  .pnotice p { margin: .2rem 0; }
  .sheet { grid-area: sheet; max-height: none; min-height: 0; }
  .rollwrap { grid-area: roll; height: auto; min-height: 0; margin: 0; border-radius: var(--radius) var(--radius) 0 0; }
  .player .camwrap { grid-area: roll; height: auto; min-height: 0; margin: 0; }
  .drill > .camwrap { grid-column: 2; grid-row: 1 / span 9; height: 72dvh; margin: 0; }
  .drill.has-cam > .kbwrap { display: none; }
  .player .kbwrap { grid-area: kb; margin: 0; height: 32dvh; align-self: end; }
  .player .kb { height: 100%; }
  .pstatus { grid-area: status; font-size: .85rem; text-align: left; align-self: start; }
  .pactions, #app.focus .pactions { grid-area: actions; position: static; padding: 0; justify-content: flex-start; align-self: end; }
  .pactions .btn.big { min-height: 44px; padding: .5rem 1rem; font-size: .95rem; }
  .results { grid-area: sheet; z-index: 2; overflow: auto; min-height: 0; margin: 0; }
  .player:has(.rollwrap[hidden]) .results { grid-area: sheet; }
  .metrics li { padding: .1rem 0; font-size: .9rem; }
  .tip { padding: .4rem .6rem; font-size: .9rem; margin: .4rem 0; }

  /* exercises: prompt on the left, keyboard on the right */
  .drill { display: grid; grid-template-columns: minmax(220px, 40%) 1fr; gap: 0 14px; align-items: start; }
  .drill > * { grid-column: 1; }
  .drill > .kbwrap, .drill > .options, .drill > .pad { grid-column: 2; grid-row: 1 / span 9; align-self: end; margin: 0; }
  .drill > .options { align-self: center; }
  .drill .kb, .kbwrap.small .kb { height: 42dvh; }
  .drill-title { margin: 0 0 .2rem; }
  .bigname { font-size: 3rem; }
  .learn-body { font-size: .95rem; padding: .6rem .8rem; }
  .pad { height: 42dvh; }
  .done-card { padding: .5rem 0; }

  /* jam: big chord left, keys right */
  .jam { display: grid; grid-template-columns: minmax(230px, 36%) 1fr; gap: 6px 14px; flex: 1; min-height: 0; align-content: start;
    grid-template-areas: "now strip" "now kb" "toggles kb" "tempo actions"; }
  .jam > .jam-now { grid-area: now; padding: .3rem; }
  .jam > .jam-strip { grid-area: strip; margin: 0; }
  .jam > .kbwrap { grid-area: kb; margin: 0; }
  .jam > .tip { display: none; }
  .jam > .row { grid-area: toggles; margin: 0; gap: .3rem; }
  .jam > .row .chip { min-height: 30px; padding: .15rem .55rem; font-size: .8rem; }
  .jam > .tempo { grid-area: tempo; }
  .jam > .pactions { grid-area: actions; justify-content: flex-end; }
  .jam .kb { height: 44dvh; }
  .jam-chord { font-size: 3.6rem; }
  .jam-bar { margin-top: .2rem; }
  .jam .tip { font-size: .85rem; }
}
