/* Music Academy: shared look. Two looks (Pakdad: paper, ink and terracotta; or black and white), each light or dark.
   Light or dark follows the browser unless the player picks one (html[data-mode="light"|"dark"], set in the toolbox). */
:root {
  --bg: #fbfaf9; --paper: #ffffff; --ink: #17161a; --muted: #66646e; --line: #e6e2dd;
  --accent: #b6431c; --accent-soft: rgba(182, 67, 28, .09); --on-accent: #ffffff;
  --good: #2f7d4f; --good-soft: #e3f1e8; --bad: #be123c; --bad-soft: #fde4ea; --warn: #b7791f;
  --shadow: 0 1px 2px rgba(23, 22, 26, .05), 0 4px 6px -2px rgba(23, 22, 26, .05), 0 12px 28px -8px rgba(23, 22, 26, .10);
  --key-held: #f1bfa8; --key-held-black: #b6431c; --wood: #f4ece2; --fretwire: #a8a29a; --string: #8d877f;
  color-scheme: light;
  --radius: 16px; --tap: 44px;
  --tile: color-mix(in srgb, var(--accent) 11%, var(--paper));
}
:root[data-mode="dark"] {
    --bg: #111013; --paper: #1b1a1c; --ink: #edeaea; --muted: #a3a0a8; --line: #2e2c30;
    --accent: #ef8a5f; --accent-soft: rgba(239, 138, 95, .14); --on-accent: #17161a;
    --good: #5fcf8e; --good-soft: #15291d; --bad: #fb7185; --bad-soft: #3a1820; --warn: #f2b45a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 6px -2px rgba(0, 0, 0, .4), 0 12px 28px -8px rgba(0, 0, 0, .5);
    --key-held: #f1bfa8; --key-held-black: #ef8a5f; --wood: #221d19; --fretwire: #5c5650; --string: #8d877f;
    color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-mode="light"]) {
    --bg: #111013; --paper: #1b1a1c; --ink: #edeaea; --muted: #a3a0a8; --line: #2e2c30;
    --accent: #ef8a5f; --accent-soft: rgba(239, 138, 95, .14); --on-accent: #17161a;
    --good: #5fcf8e; --good-soft: #15291d; --bad: #fb7185; --bad-soft: #3a1820; --warn: #f2b45a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 6px -2px rgba(0, 0, 0, .4), 0 12px 28px -8px rgba(0, 0, 0, .5);
    --key-held: #f1bfa8; --key-held-black: #ef8a5f; --wood: #221d19; --fretwire: #5c5650; --string: #8d877f;
    color-scheme: dark;
  }
}
/* Black & white: paper and ink only. Right and wrong keep a quiet green and red, since they carry meaning. */
:root[data-theme="mono"] {
  --bg: #ffffff; --paper: #ffffff; --ink: #000000; --muted: #555555; --line: #d4d4d4;
  --accent: #000000; --accent-soft: rgba(0, 0, 0, .07); --on-accent: #ffffff; --warn: #8a6a00;
  --shadow: 0 0 0 1px #d4d4d4; --key-held: #c8c8c8; --key-held-black: #5a5a5a; --wood: #ffffff; --fretwire: #9a9a9a; --string: #777777;
  color-scheme: light;
}
:root[data-theme="mono"][data-mode="dark"] {
    --bg: #000000; --paper: #000000; --ink: #ffffff; --muted: #a8a8a8; --line: #3a3a3a;
    --accent: #ffffff; --accent-soft: rgba(255, 255, 255, .13); --on-accent: #000000; --warn: #e0c060;
    --shadow: 0 0 0 1px #3a3a3a; --key-held: #8a8a8a; --key-held-black: #cfcfcf; --wood: #000000; --fretwire: #555555; --string: #888888;
    color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="mono"]:not([data-mode="light"]) {
    --bg: #000000; --paper: #000000; --ink: #ffffff; --muted: #a8a8a8; --line: #3a3a3a;
    --accent: #ffffff; --accent-soft: rgba(255, 255, 255, .13); --on-accent: #000000; --warn: #e0c060;
    --shadow: 0 0 0 1px #3a3a3a; --key-held: #8a8a8a; --key-held-black: #cfcfcf; --wood: #000000; --fretwire: #555555; --string: #888888;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 16px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; -webkit-font-smoothing: antialiased; color: var(--ink); background: var(--bg);
  display: flex; flex-direction: column; -webkit-tap-highlight-color: transparent;
}
#app { display: flex; flex-direction: column; min-height: 100%; }
a { color: var(--accent); }
button { font: inherit; color: inherit; }

/* ---------- top bar ---------- */
.bar {
  display: flex; align-items: center; gap: 14px; padding: 10px max(14px, env(safe-area-inset-right)) 10px max(14px, env(safe-area-inset-left));
  background: var(--paper); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; flex-wrap: wrap;
}
.bar .home { font-size: 30px; line-height: 1; text-decoration: none; color: var(--muted); padding: 0 6px 4px; }
.bar h1 { font-size: 18px; margin: 0; font-weight: 650; white-space: nowrap; letter-spacing: -.01em; }
.hud { display: flex; gap: 14px; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 15px; flex-wrap: wrap; }
.hud b { color: var(--ink); }
.tools { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.icon { border: 1px solid var(--line); background: transparent; border-radius: 10px; width: 38px; height: 36px; cursor: pointer; font-size: 17px; }
.icon:hover { background: var(--bg); }
.midi { display: flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: transparent; border-radius: 10px; height: 36px; padding: 0 10px; cursor: pointer; font-size: 13px; color: var(--muted); max-width: 210px; }
.midi .midi-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.midi .dot { width: 9px; height: 9px; border-radius: 50%; background: #9ca3af; flex: none; }
.midi[data-state="ready"] .dot { background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .2); }
.midi[data-state="unsupported"] .dot, .midi[data-state="denied"] .dot { background: #f59e0b; }

/* ---------- the drill ---------- */
.stage { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 18px 14px 20px; width: 100%; max-width: 1100px; margin: 0 auto; }
.prompt { font-size: 21px; font-weight: 600; text-align: center; min-height: 1.5em; }
.prompt small { display: block; font-size: 15px; font-weight: 400; color: var(--muted); }
.card {
  background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px 18px; max-width: 100%;
  color: var(--ink); display: flex; justify-content: center; overflow-x: auto;
}
.card:empty { display: none; }
.staff { height: clamp(170px, 34vh, 330px); width: auto; max-width: 100%; display: block; fill: currentColor; }
.staff.small { height: clamp(120px, 22vh, 200px); }
.staff .label { font: 650 17px system-ui, sans-serif; fill: currentColor; }
.staff .sublabel { font: italic 500 15px Georgia, serif; fill: var(--muted); }
.staff .mark { fill: var(--accent-soft); }
.feedback { min-height: 1.6em; font-size: 17px; text-align: center; opacity: 0; transition: opacity .15s; }
.feedback.show { opacity: 1; }
.feedback.ok { color: var(--good); }
.feedback.bad { color: var(--bad); }
.feedback.info { color: var(--muted); }
.feedback .big { font-size: 24px; font-weight: 700; }

/* answer buttons */
.answers { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.choices { display: grid; grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr)); gap: 10px; width: 100%; max-width: 760px; }
.choice {
  position: relative; border: 1px solid var(--line); background: var(--paper); border-radius: 12px; padding: 14px 10px; cursor: pointer;
  font-size: 19px; font-weight: 600; box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; gap: 2px;
  transition: transform .06s, background .15s;
}
.choice:active { transform: translateY(1px); }
.choice:hover { border-color: var(--accent); }
.choice::before { content: attr(data-i); position: absolute; top: 4px; left: 8px; font-size: 11px; color: var(--muted); font-weight: 500; }
.choice-sub { font-size: 13px; font-weight: 400; color: var(--muted); }
.choice.right { background: var(--good-soft); border-color: var(--good); color: var(--good); }
.choice.wrong { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.choice[disabled] { cursor: default; }
@media (max-width: 640px) { .choices { grid-template-columns: repeat(min(var(--cols, 4), 4), minmax(0, 1fr)); } .choice { font-size: 17px; padding: 12px 4px; } }

.row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.btn { border: 1px solid var(--line); background: var(--paper); border-radius: 10px; padding: 9px 16px; cursor: pointer; font-weight: 600; box-shadow: var(--shadow); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 86%, #000); }
.btn.ghost { box-shadow: none; background: transparent; }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .45; cursor: default; }
kbd { font: 12px ui-monospace, monospace; border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; background: var(--paper); }
.muted { color: var(--muted); }

/* ---------- on-screen keyboard ---------- */
.keys { padding: 6px max(8px, env(safe-area-inset-left)) max(8px, env(safe-area-inset-bottom)); overflow-x: auto; overflow-y: hidden; background: var(--paper); border-top: 1px solid var(--line); touch-action: pan-x; flex: none; }
.no-keyboard .keys { display: none; }
.keyboard { display: block; height: clamp(86px, 16vh, 150px); width: auto; max-width: none; margin: 0 auto; user-select: none; -webkit-user-select: none; touch-action: none; }
.key { cursor: pointer; transition: fill .05s; }
.key.white { fill: #fff; stroke: #b8b4aa; stroke-width: 1; }
.key.black { fill: #23262d; }
.key.held { fill: var(--key-held); }
.key.black.held { fill: var(--key-held-black); }
.key.good { fill: #a7dcbb; }
.key.black.good { fill: #2f7d4f; }
.key.bad { fill: #f9a8bb; }
.key.black.bad { fill: #be123c; }
.key.hint { fill: #fde68a; }
.key.black.hint { fill: #d97706; }
.key-label { font: 10px system-ui, sans-serif; fill: #8a8578; pointer-events: none; }

/* ---------- dialogs ---------- */
dialog.sheet { border: none; border-radius: 18px; padding: 22px; width: min(620px, calc(100vw - 24px)); max-height: calc(100vh - 40px); background: var(--paper); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
dialog.sheet::backdrop { background: rgba(15, 15, 25, .45); }
dialog h2 { margin: 0 0 12px; font-size: 20px; }
.sheet-body { overflow-y: auto; max-height: calc(100vh - 200px); }
.sheet-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.field { margin: 0 0 16px; }
.field-label { font-weight: 600; margin-bottom: 6px; font-size: 15px; }
.hint { color: var(--muted); font-size: 13px; margin-top: 4px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { border: 1px solid var(--line); background: transparent; border-radius: 9px; padding: 6px 11px; cursor: pointer; font-size: 14px; }
.seg button.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.range { display: flex; gap: 12px; align-items: center; }
.range input { flex: 1; accent-color: var(--accent); }
.range .num { min-width: 7em; font-variant-numeric: tabular-nums; }
table.stats { width: 100%; border-collapse: collapse; font-size: 15px; }
table.stats th { text-align: left; color: var(--muted); font-weight: 500; border-bottom: 1px solid var(--line); padding: 4px 6px; }
table.stats td { padding: 5px 6px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
table.stats td.good { color: var(--good); }
table.stats td.bad { color: var(--bad); }
.prompt .symbol { display: block; font-size: 46px; font-weight: 750; letter-spacing: .5px; margin: 6px 0 2px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- pieces ---------- */
.stage.wide { max-width: 1180px; align-items: stretch; }
.lib-intro h2 { margin: 0 0 4px; font-size: 24px; letter-spacing: -.02em; }
.lib-intro p { margin: 0; }
.lib-level { margin: 22px 0 10px; font-size: 13px; color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: .06em; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.pcard { padding: 16px 18px; border-radius: var(--radius); background: var(--paper); box-shadow: var(--shadow); text-decoration: none; color: inherit; border: 1px solid transparent; display: flex; flex-direction: column; gap: 3px; transition: border-color .15s; }
.pcard:hover { border-color: var(--accent); }
.pcard-title { font-weight: 650; font-size: 17px; letter-spacing: -.01em; }
.pcard-by { color: var(--muted); font-size: 13px; }
.pcard-meta { font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--muted); }
.pcard p { margin: 6px 0 0; font-size: 14px; }
.pcard-best { margin-top: auto; padding-top: 6px; font-size: 13px; color: var(--accent); font-weight: 650; }
.phead .back { text-decoration: none; font-size: 14px; }
.phead h2 { margin: 6px 0 2px; font-size: 24px; letter-spacing: -.02em; }
.pabout { margin: 6px 0 0; }
.controls { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; padding: 14px 18px; background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); }
.ctl { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ctl > span:first-child { font-size: 12px; color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: .05em; min-width: 4.2em; }
.ctl.tempo input { width: 170px; accent-color: var(--accent); }
.ctl.tempo .num { font-variant-numeric: tabular-nums; min-width: 8em; }
.ctl.go { width: 100%; gap: 16px; }
.tgl { display: flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }
.tgl input { accent-color: var(--accent); width: 16px; height: 16px; }
.btn.big { font-size: 17px; padding: 11px 24px; }
.pstatus { color: var(--muted); font-size: 15px; }
.countin { font-size: 32px; font-weight: 800; color: var(--accent); }
.score-card { display: block; padding: 8px 14px; overflow: visible; }
.staff.score { width: 100%; height: auto; max-width: none; }
.score .ev.dim { opacity: .35; }
.score .ev.cur { color: var(--accent); }
.score .ev.good { color: var(--good); }
.score .ev.off { color: var(--warn); }
.score .ev.bad { color: var(--bad); }
.score .playhead { fill: var(--accent); opacity: 0; transition: opacity .2s; }
.score .playhead.on { opacity: .15; }
.score .barno { font: 13px ui-sans-serif, system-ui, sans-serif; fill: var(--muted); }
.result-card { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 18px 22px; margin-top: 4px; }
.big-score { font-size: 42px; font-weight: 800; color: var(--accent); letter-spacing: -.02em; line-height: 1.1; }
.result-card ul { margin: 0; padding-left: 18px; }
.advice { font-weight: 650; margin: 4px 0; }

/* ---------- metronome ---------- */
.metro, .timing { width: 100%; max-width: 660px; display: flex; flex-direction: column; gap: 14px; padding: 20px 22px; align-items: stretch; }
.timing h3 { margin: 0; }
.timing p { margin: 0; }
.bpm-row { display: flex; align-items: center; justify-content: center; gap: 22px; }
.bpm { font-size: 68px; font-weight: 750; line-height: 1; text-align: center; font-variant-numeric: tabular-nums; min-width: 3.2em; letter-spacing: -.03em; }
.bpm small { display: block; font-size: 13px; font-weight: 500; color: var(--muted); margin-top: 6px; letter-spacing: 0; }
.btn.round { width: 52px; height: 52px; border-radius: 50%; font-size: 26px; padding: 0; }
.metro input[type=range] { accent-color: var(--accent); }
.beats { display: flex; justify-content: center; gap: 14px; min-height: 26px; }
.beats span { width: 22px; height: 22px; border-radius: 50%; background: var(--line); transition: background .05s, transform .05s; }
.beats span.first { box-shadow: inset 0 0 0 2px var(--accent); }
.beats span.on { background: var(--accent); transform: scale(1.15); }
.beats.silent span { background: transparent; box-shadow: inset 0 0 0 2px var(--line); }
.gap-label { text-align: center; color: var(--accent); font-weight: 650; min-height: 1.4em; }
.last-hit { font-size: 36px; font-weight: 750; text-align: center; font-variant-numeric: tabular-nums; }
.last-hit small { font-size: 15px; font-weight: 500; color: var(--muted); }
.last-hit.good { color: var(--good); }
.last-hit.ok { color: var(--warn); }
.last-hit.bad { color: var(--bad); }
.strip { position: relative; height: 36px; border-radius: 9px; background: var(--bg); border: 1px solid var(--line); overflow: hidden; }
.strip-band { position: absolute; left: calc(50% - 8.333%); width: 16.667%; top: 0; bottom: 0; background: var(--good-soft); }
.strip-mid { position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; background: var(--accent); transform: translateX(-1px); z-index: 1; }
.strip .hit { position: absolute; top: 50%; width: 11px; height: 11px; border-radius: 50%; background: var(--ink); transform: translate(-50%, -50%); z-index: 2; }
.tstats { font-size: 14px; text-align: center; }
.pad { width: 100%; padding: 28px; border-radius: 16px; border: 2px dashed var(--line); background: transparent; font-size: 18px; font-weight: 650; color: var(--muted); cursor: pointer; touch-action: manipulation; -webkit-user-select: none; user-select: none; }
.pad:active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.cal { justify-content: flex-start; align-items: center; }
.score .finger { font: italic 650 13px Georgia, "Times New Roman", serif; fill: currentColor; }
.score .ev.dim .finger { opacity: .8; }
.imslp { display: inline-block; margin-top: 6px; font-size: 14px; }
.card.score-card { width: 100%; }
.rhythm-card { max-width: 1100px; }
.pcard.import { cursor: pointer; text-align: left; font: inherit; border: 1.5px dashed var(--line); background: transparent; box-shadow: none; }
.pcard.import:hover { border-color: var(--accent); }
.plinks { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.linkbtn { background: none; border: none; padding: 0; color: var(--accent); cursor: pointer; font-size: 14px; text-decoration: underline; text-underline-offset: 3px; }
.linkbtn.danger { color: var(--bad); }
input.text { width: 100%; font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink); }
ul.report { margin: 4px 0 12px; padding-left: 18px; font-size: 14px; }
.score-card.preview { max-height: 260px; overflow: hidden; padding: 4px 8px; }

/* ---------- guitar ---------- */
.board { width: 100%; max-width: 1000px; overflow-x: auto; }
.fretboard { display: block; width: 100%; min-width: 420px; margin: 0 auto; height: auto; background: var(--wood); border-radius: 10px; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.fretboard .fret { stroke: var(--fretwire); stroke-width: 2; }
.fretboard .nut { stroke: var(--ink); stroke-width: 6; }
.fretboard .string { stroke: var(--string); }
.fretboard .inlay { fill: var(--line); }
.fretboard .fretno { font: 11px ui-sans-serif, system-ui, sans-serif; fill: var(--muted); }
.fretboard .hit { fill: transparent; cursor: pointer; }
.fretboard .hit:hover { fill: var(--accent-soft); }
.fretboard .mark { pointer-events: none; }
.fretboard .mark circle { fill: var(--accent); }
.fretboard .mark text { font: 700 12px ui-sans-serif, system-ui, sans-serif; fill: var(--on-accent); }
.fretboard .mark.good circle { fill: var(--good); }
.fretboard .mark.bad circle { fill: var(--bad); }
.fretboard .mark.hint circle { fill: var(--warn); }
.fretboard .mark.soft circle { fill: var(--paper); stroke: var(--line); stroke-width: 1.5; }
.fretboard .mark.soft text { fill: var(--ink); font-weight: 600; }
.diagram { display: block; height: auto; max-width: 100%; margin: 0 auto; }
.diagram .fret, .diagram .string { stroke: var(--ink); stroke-width: 1.2; }
.diagram .nut { stroke: var(--ink); stroke-width: 5; }
.diagram .dot { fill: var(--accent); }
.diagram .dfinger { font: 700 11px ui-sans-serif, system-ui, sans-serif; fill: var(--on-accent); }
.diagram .dopen { fill: none; stroke: var(--ink); stroke-width: 1.5; }
.diagram .dmute { font: 16px ui-sans-serif, system-ui, sans-serif; fill: var(--muted); }
.diagram .dname { font: 700 15px ui-sans-serif, system-ui, sans-serif; fill: var(--ink); }
.diagram .dbase { font: 12px ui-sans-serif, system-ui, sans-serif; fill: var(--muted); }
.score .tabclef { font: 700 16px Georgia, serif; fill: currentColor; }
.score .tabnum { font: 700 14px ui-sans-serif, system-ui, sans-serif; fill: currentColor; }
.score .tabbg { fill: var(--paper); }
.score .elabel { font: 700 15px ui-sans-serif, system-ui, sans-serif; fill: var(--accent); }
.btn.small { padding: 6px 12px; font-size: 14px; }
.levels { margin-bottom: -4px; }
.micbtn[data-state="ready"] .dot { background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .2); animation: kit-pulse 1.6s infinite; }
@keyframes kit-pulse { 50% { opacity: .5; } }

/* tuner */
.tuner { width: 100%; max-width: 560px; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 22px; transition: box-shadow .2s; }
.tuner.intune { box-shadow: 0 0 0 3px var(--good), var(--shadow); }
.tuner-note { font-size: 72px; font-weight: 800; line-height: 1; letter-spacing: -.02em; }
.tuner-note small { font-size: 26px; color: var(--muted); font-weight: 600; }
.tuner-hz { font-variant-numeric: tabular-nums; min-height: 1.4em; }
.tuner-gauge svg { width: min(360px, 90vw); height: auto; display: block; }
.tuner-gauge .arc { fill: none; stroke: var(--line); stroke-width: 10; stroke-linecap: round; }
.tuner-gauge .arc-good { fill: none; stroke: var(--good); stroke-width: 10; }
.tuner-gauge .tick { stroke: var(--muted); stroke-width: 2; }
.tuner-gauge .ticklabel { font: 11px ui-sans-serif, system-ui, sans-serif; fill: var(--muted); }
.tuner-gauge .needle { stroke: var(--accent); stroke-width: 4; stroke-linecap: round; transition: transform .12s; }
.tuner-gauge circle { fill: var(--accent); }
.tuner-msg { font-size: 18px; font-weight: 650; text-align: center; min-height: 1.5em; }
.tuner.intune .tuner-msg { color: var(--good); }
.tuner-strings { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.tstring { display: flex; flex-direction: column; align-items: center; min-width: 54px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); cursor: pointer; }
.tstring b { font-size: 20px; }
.tstring small { color: var(--muted); font-size: 11px; }
.tstring.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.tstring.hit { background: var(--accent-soft); }
.tuner-settings { width: 100%; max-width: 560px; padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; }
input.a4 { width: 80px; }

/* strumming */
.arrows { display: flex; gap: 8px; justify-content: center; font-size: 40px; font-weight: 700; line-height: 1; }
.arrows span { width: 1.2em; text-align: center; border-radius: 10px; color: var(--ink); padding: 4px 0; }
.arrows span.gap { color: var(--line); }
.arrows span.on { background: var(--accent-soft); color: var(--accent); }

/* chord changes */
.changes { display: flex; gap: 40px; align-items: flex-end; justify-content: center; flex-wrap: wrap; }
.changes .now, .changes .next { text-align: center; }
.changes .next { opacity: .7; }
.bigcount { font-size: 44px; font-weight: 800; text-align: center; color: var(--accent); }
.bigcount small { font-size: 16px; color: var(--muted); font-weight: 500; }
.barlog { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; max-width: 900px; }
.barlog .bar { padding: 4px 10px; border-radius: 8px; font-weight: 650; font-size: 14px; border: 1px solid var(--line); }
.barlog .bar.good { background: var(--good-soft); color: var(--good); border-color: var(--good); }
.barlog .bar.bad { background: var(--bad-soft); color: var(--bad); border-color: var(--bad); }
.barlog .bar.none { color: var(--muted); }

/* =====================================================================
   Friendlier, touch-first layer: icons, top bar, toolbox, home page.
   ===================================================================== */
.ico { display: block; flex: none; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 18px; border-radius: 12px; touch-action: manipulation; }
.btn.big { min-height: 54px; font-size: 18px; padding: 12px 26px; border-radius: 14px; }
.seg button { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 8px 14px; border-radius: 10px; touch-action: manipulation; }
.row.left { justify-content: flex-start; }
select.text { min-height: 44px; font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink); }

/* top bar */
.bar { min-height: 64px; gap: 10px; flex-wrap: nowrap; padding: 8px max(10px, env(safe-area-inset-right)) 8px max(10px, env(safe-area-inset-left)); }
.bar h1 { font-size: 19px; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.iconbtn { position: relative; flex: none; width: 46px; height: 46px; border-radius: 14px; border: 1px solid transparent; background: transparent; color: var(--ink); display: grid; place-items: center; cursor: pointer; text-decoration: none; touch-action: manipulation; }
.iconbtn:hover { background: var(--accent-soft); }
.iconbtn.on { color: var(--accent); background: var(--accent-soft); }
.iconbtn.back { color: var(--muted); }
.iconbtn.status::after { content: ''; position: absolute; right: 7px; top: 7px; width: 10px; height: 10px; border-radius: 50%; background: #9ca3af; border: 2px solid var(--paper); }
.iconbtn.status[data-state="ok"]::after { background: #22c55e; }
.iconbtn.status[data-state="warn"]::after { background: #f59e0b; }
.tools { gap: 2px; }
.hud { gap: 6px; flex-wrap: nowrap; overflow: hidden; min-width: 0; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 5px 11px 5px 8px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); font-size: 14px; white-space: nowrap; }
.chip b { color: var(--ink); font-weight: 650; font-variant-numeric: tabular-nums; }
.chip .ico { color: var(--muted); }
.chip.hot, .chip.hot .ico { color: var(--accent); border-color: var(--accent); }
@media (max-width: 820px) { .chip.wide { display: none; } }
@media (max-width: 620px) { .hud .chip:nth-child(n+3) { display: none; } .bar h1 { font-size: 17px; } }

/* drills: room for the corner button, bigger targets */
.stage { padding: 20px 16px 110px; gap: 16px; }
.prompt { font-size: clamp(20px, 2.4vw, 26px); }
.choice { min-height: 60px; font-size: 20px; border-radius: 14px; touch-action: manipulation; }
.controls { gap: 14px 24px; padding: 16px 18px; border-radius: 18px; }
@media (pointer: coarse) {
  .choice { min-height: 66px; }
  .choice::before { display: none; }
  .seg button { min-height: 46px; padding: 10px 16px; }
  .keyboard { height: clamp(110px, 19vh, 200px); }
  .iconbtn { width: 50px; height: 50px; }
}
@media (max-width: 700px) {
  dialog.sheet { margin: auto auto 0; width: 100%; max-width: 100%; border-radius: 22px 22px 0 0; padding-bottom: calc(22px + env(safe-area-inset-bottom)); }
}

/* the corner button and its panel */
.fab { position: fixed; z-index: 40; right: max(18px, env(safe-area-inset-right)); bottom: calc(var(--fab-bottom, 0px) + max(18px, env(safe-area-inset-bottom)));
  width: 64px; height: 64px; border-radius: 50%; border: none; background: var(--accent); color: var(--on-accent); box-shadow: 0 8px 24px rgba(0, 0, 0, .28);
  display: grid; place-items: center; cursor: pointer; transition: transform .15s, bottom .2s; touch-action: manipulation; }
.fab:active { transform: scale(.93); }
.fab-dot { position: absolute; top: 5px; right: 5px; width: 14px; height: 14px; border-radius: 50%; border: 3px solid var(--accent); background: #22c55e; display: none; }
.fab.live .fab-dot { display: block; }
.fab.ticking::before { content: ''; position: absolute; inset: -4px; border-radius: 50%; border: 3px solid var(--accent); animation: fab-pulse 1s ease-out infinite; }
@keyframes fab-pulse { from { opacity: .8; transform: scale(.96); } to { opacity: 0; transform: scale(1.3); } }
.tb-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(10, 10, 20, .32); opacity: 0; transition: opacity .2s; }
.tb-backdrop.open { opacity: 1; }
.tb { position: fixed; z-index: 51; right: max(14px, env(safe-area-inset-right)); bottom: calc(var(--fab-bottom, 0px) + 96px);
  width: min(460px, calc(100vw - 28px)); max-height: min(80vh, calc(100vh - var(--fab-bottom, 0px) - 120px));
  display: flex; flex-direction: column; background: var(--paper); color: var(--ink); border: 1px solid var(--line); border-radius: 24px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, .32); transform: translateY(18px) scale(.98); opacity: 0; transition: transform .2s, opacity .2s; }
.tb.open { transform: none; opacity: 1; }
@media (max-width: 640px) { .tb { left: 0; right: 0; bottom: 0; width: 100%; max-height: 90vh; border-radius: 24px 24px 0 0; } }
.tb-tabs { display: flex; align-items: center; gap: 4px; padding: 10px 10px 8px; border-bottom: 1px solid var(--line); }
.tb-tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; min-height: 58px; padding: 8px 4px; border: none; border-radius: 14px; background: transparent; color: var(--muted); font-size: 12.5px; font-weight: 650; cursor: pointer; touch-action: manipulation; }
.tb-tab.on { color: var(--accent); background: var(--accent-soft); }
.tb-body { overflow-y: auto; padding: 14px 14px calc(18px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; overscroll-behavior: contain; }
.tb-card { border: 1px solid var(--line); border-radius: 18px; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.tb-card-head { display: flex; align-items: center; gap: 10px; color: var(--accent); }
.tb-card-head h3 { margin: 0; font-size: 16px; color: var(--ink); }
.tb-card p { margin: 0; }
.tb-status { font-weight: 650; color: var(--muted); }
.tb-status.ok { color: var(--good); }
.tb-status.warn { color: var(--warn); }
.tb-live { display: flex; align-items: center; gap: 8px; min-height: 46px; padding: 10px 12px; border-radius: 12px; background: var(--bg); color: var(--muted); }
.tb-live b { color: var(--ink); font-size: 18px; }
.tb-live .ico { color: var(--good); }
.tb-live.flash { animation: tb-flash .6s; }
@keyframes tb-flash { from { background: var(--good-soft); } }
.meter { height: 10px; border-radius: 6px; background: var(--bg); border: 1px solid var(--line); overflow: hidden; }
.meter span { display: block; height: 100%; width: 0; background: var(--good); transition: width .06s; }
.tb-field { display: flex; flex-direction: column; gap: 6px; }
.tb-field > span { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.tb-count { font-weight: 650; min-height: 1.4em; }
.tb-link { display: flex; align-items: center; gap: 8px; padding: 8px 4px; font-weight: 650; text-decoration: none; }
.tb .bpm { font-size: 56px; }
.tb .pad { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 24px; }
.tb .beats span { width: 20px; height: 20px; }

/* home */
body.homepage { overflow-y: auto; }
.home-bar .brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 700; font-size: 19px; letter-spacing: -.01em; }
.home-bar .brand img { width: 38px; height: 38px; border-radius: 10px; }
.home-bar .tools { margin-left: auto; }
.home { width: 100%; max-width: 1120px; margin: 0 auto; padding: 24px max(18px, env(safe-area-inset-left)) 130px; display: flex; flex-direction: column; gap: 24px; }
.hello h1 { margin: 0 0 4px; font-size: clamp(26px, 4vw, 36px); letter-spacing: -.02em; }
.hello p { margin: 0 0 18px; }
.instr { display: inline-flex; gap: 4px; padding: 5px; border-radius: 20px; background: var(--paper); border: 1px solid var(--line); box-shadow: var(--shadow); }
.instr-btn { display: flex; align-items: center; gap: 10px; min-height: 54px; padding: 10px 24px; border: none; border-radius: 16px; background: transparent; color: var(--muted); font-size: 17px; font-weight: 650; cursor: pointer; touch-action: manipulation; }
.instr-btn.on { background: var(--accent); color: var(--on-accent); }
.continue { display: flex; align-items: center; gap: 16px; padding: 14px 18px; border-radius: 22px; background: var(--accent); color: var(--on-accent); text-decoration: none; box-shadow: var(--shadow); }
.continue .dicon { width: 58px; height: 58px; background: rgba(255, 255, 255, .18); color: var(--on-accent); }
.continue-text { display: flex; flex-direction: column; min-width: 0; }
.continue-text small { font-size: 12.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; opacity: .85; }
.continue-text b { font-size: 21px; }
.continue-stats { margin-left: auto; font-size: 14px; opacity: .92; text-align: right; }
.today { margin: 0; }
.dsection h2 { margin: 0 0 12px 2px; font-size: 13px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.dgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 14px; }
.dcard { display: flex; align-items: flex-start; gap: 16px; min-height: 124px; padding: 18px; border-radius: 22px; background: var(--paper); color: var(--ink); text-decoration: none; border: 1px solid transparent; box-shadow: var(--shadow); transition: transform .1s, border-color .15s; touch-action: manipulation; }
.dcard:hover { border-color: var(--accent); }
.dcard:active { transform: scale(.985); }
.dicon { flex: none; display: grid; place-items: center; width: 68px; height: 68px; border-radius: 20px; background: var(--tile); color: var(--accent); }
.dtext { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.dtext b { font-size: 18px; letter-spacing: -.01em; }
.dabout { color: var(--muted); font-size: 14.5px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.dstat { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 13px; color: var(--muted); }
.pill { padding: 2px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); font-weight: 650; }
.pill.good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.pill.new { background: var(--tile); color: var(--accent); border-color: transparent; }
.card.block { display: block; padding: 18px 20px; }
.card.block h2 { display: flex; align-items: center; gap: 10px; margin: 0 0 6px; font-size: 18px; }
.card.block h2 .ico { color: var(--accent); }
.card.block p { margin: 0 0 14px; }
.home footer { color: var(--muted); font-size: 13px; line-height: 1.6; }
.support { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border: 1px dashed var(--line); border-radius: 16px; }
.support[hidden] { display: none; }
.support p { flex: 1; margin: 0; color: var(--muted); font-size: 14.5px; }
.support-icon { flex: none; color: var(--accent); display: grid; }
.support .btn { flex: none; text-decoration: none; }
@media (max-width: 560px) { .support { flex-wrap: wrap; } .support p { flex-basis: calc(100% - 40px); } .support .btn { width: 100%; justify-content: center; } }
@media (max-width: 560px) { .continue-stats { display: none; } .instr { display: flex; } .instr-btn { flex: 1; justify-content: center; padding: 10px; } }
#sections { display: flex; flex-direction: column; gap: 30px; }
.home-bar .tools .label { margin-left: 4px; }
.iconbtn.wide { width: auto; padding: 0 14px 0 10px; gap: 8px; display: inline-flex; align-items: center; font-weight: 650; }
@media (max-width: 600px) { .iconbtn.wide .label { display: none; } .iconbtn.wide { width: 46px; padding: 0; justify-content: center; } }
.tgl { min-height: 44px; padding: 0 4px; }
.tgl input { width: 22px; height: 22px; }
input[type=range] { min-height: 32px; }

/* ---------- the chord book ---------- */
.cb { gap: 18px; }
.cb-pick { display: flex; flex-direction: column; gap: 12px; }
.cb-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.cb-instr .instr-btn { min-height: 48px; padding: 8px 18px; }
.cb-search { flex: 1; min-width: 220px; display: flex; align-items: center; gap: 8px; padding: 0 14px; min-height: 54px; border: 1px solid var(--line); border-radius: 18px; background: var(--paper); box-shadow: var(--shadow); color: var(--muted); }
.cb-search:focus-within { border-color: var(--accent); }
.cb-search input.text { border: none; background: transparent; font-size: 18px; padding: 10px 0; outline: none; }
.cb-search input.bad { color: var(--bad); }
.cb-heard { color: var(--muted); font-size: 14.5px; margin: -4px 4px 0; }
.cb-heard:empty { display: none; }
.cb-choices { display: flex; flex-direction: column; gap: 12px; }
.cb-roots { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 6px; }
.cb-root { min-height: 50px; padding: 4px 2px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); font-size: 18px; font-weight: 700; cursor: pointer; touch-action: manipulation; }
.cb-root.black { background: var(--bg); font-size: 13.5px; font-weight: 650; line-height: 1.15; }
.cb-root.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
@media (max-width: 760px) { .cb-roots { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.cb-types { display: flex; flex-direction: column; gap: 10px; }
.cb-tg { display: flex; flex-direction: column; gap: 6px; }
.cb-tg-name { margin-left: 2px; font-size: 12.5px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.cb-tgroup { display: flex; flex-wrap: wrap; gap: 6px; }
.cb-type { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; min-width: 78px; min-height: 52px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); text-align: left; cursor: pointer; touch-action: manipulation; }
.cb-type b { font-size: 17px; line-height: 1.2; }
.cb-type small { font-size: 11.5px; line-height: 1.2; color: var(--muted); }
.cb-type.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.cb-type.on small { color: inherit; opacity: .85; }
.cb-head { flex-direction: column; justify-content: flex-start; gap: 12px; padding: 16px 20px; overflow: visible; }
.cb-title { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.cb-title h2 { margin: 0; font-size: clamp(34px, 5vw, 48px); line-height: 1.05; letter-spacing: -.02em; }
.cb-full { margin-top: 4px; color: var(--muted); font-size: 15px; }
.cb-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.cb-actions-row { display: flex; flex-wrap: wrap; gap: 8px; }
.cb-notes-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; }
.cb-tones { display: flex; flex-wrap: wrap; gap: 8px; }
.cb-tone { display: flex; flex-direction: column; align-items: center; min-width: 60px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg); color: var(--ink); cursor: pointer; touch-action: manipulation; }
.cb-tone b { font-size: 22px; line-height: 1.15; }
.cb-tone small { color: var(--muted); font-weight: 650; }
.cb-tone em { font-style: normal; font-size: 11.5px; color: var(--muted); }
.cb-tone.root { border-color: var(--accent); background: var(--accent-soft); }
.cb-tone.bass { border-style: dashed; cursor: default; }
.cb-staff { flex: 1; min-width: 140px; max-width: 220px; }
.cb-staff .staff.score { max-height: 125px; }
.cb-jump { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.cb-jump .chip { color: var(--ink); text-decoration: none; cursor: pointer; min-height: 38px; }
.cb-jump .chip .ico { color: var(--accent); }
.cb-hand-wrap { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.cb-body { display: flex; flex-direction: column; gap: 28px; }
.cb-sec { scroll-margin-top: 84px; }
.cb-sec h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 2px; font-size: 20px; }
.cb-sec h3 .ico { color: var(--accent); }
.cb-sec > p { margin: 0 0 12px; font-size: 14.5px; }
.cb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.cb-grid.gtr { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.cb-card { flex-direction: column; justify-content: flex-start; gap: 8px; padding: 12px 14px 14px; overflow: visible; }
.cb-card header { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.cb-card header > div { display: flex; flex-direction: column; min-width: 0; }
.cb-card header b { font-size: 16.5px; }
.cb-card header .muted { font-size: 13.5px; }
.cb-card .iconbtn { flex: none; }
.cb-kbwrap svg { display: block; width: 100%; height: auto; max-height: 124px; }
.cb-kb .k { cursor: pointer; }
.cb-kb .k.white { fill: #fff; stroke: #b8b4aa; stroke-width: 1; }
.cb-kb .k.black { fill: #23262d; }
.cb-kb .k.white.on { fill: var(--key-held); }
.cb-kb .k.black.on { fill: var(--key-held-black); }
.cb-kb .kf { pointer-events: none; }
.cb-kb .kf circle { fill: var(--accent); stroke: #fff; stroke-width: 1; }
.cb-kb .kf text { font: 700 10.5px ui-sans-serif, system-ui, sans-serif; fill: var(--on-accent); }
.cb-kb .kf.lh circle { fill: #fff; stroke: var(--accent); stroke-width: 2.2; }
.cb-kb .kf.lh text { fill: #17161a; }
.cb-kb .kl { font: 9px system-ui, sans-serif; fill: var(--muted); }
.cb-lower { display: grid; grid-template-columns: minmax(84px, 34%) 1fr; align-items: center; gap: 12px; }
.cb-score .staff.score { width: 100%; height: auto; max-height: 140px; }
.cb-hands { display: flex; flex-direction: column; gap: 8px; }
.cb-hand-line { display: flex; flex-direction: column; line-height: 1.3; }
.cb-hand-line small { font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.cb-hand-line b { font-size: 16px; }
.cb-fing { color: var(--muted); font-size: 14px; }
.cb-gbody { display: flex; align-items: center; gap: 6px; }
.cb-gbody .cb-boxwrap { flex: 1; min-width: 0; }
.cb-tab { flex: none; width: 70px; }
.cb-tab .staff.score { width: 100%; height: auto; }
.cb-boxwrap { cursor: pointer; }
.cb-box { width: 100%; max-width: 210px; }
.cb-box .dot { fill: var(--ink); }
.cb-box .dot.root { fill: var(--accent); }
.cb-box .dfinger { fill: var(--paper); font-size: 11.5px; }
.cb-box .dfinger.root { fill: var(--on-accent); }
.cb-box .dopen.root { stroke: var(--accent); stroke-width: 2.6; }
.cb-box .dnote { font: 600 11.5px ui-sans-serif, system-ui, sans-serif; fill: var(--muted); }
.cb-box .dnote.bass { font-weight: 800; fill: var(--ink); }
.cb-foot { font-size: 14px; }
/* phones: each group of chord types is one row to swipe along */
@media (max-width: 560px) {
  .cb-head { padding: 14px; }
  .cb-actions { align-items: flex-start; }
  .cb-tgroup { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 0 16px 4px; scrollbar-width: none; }
  .cb-type { flex: none; }
}
