/* Colours follow 日课: warm paper by day, a dim warm ground by night. Every colour is a variable, so the dark set is a swap. */
:root {
  --paper: #f1ece2; --card: #faf6ed; --ink: #2b2721; --soft: #6b6455; --line: #d9d0be; --wash: #ebe3d3;
  --accent: #a8552a; --accent-ink: #fff8f0; --go: #a8552a; --go-ink: #fff8f0;
  --good: #2f6b4f; --bad: #9c3b2e; --good-wash: #e3ede5; --bad-wash: #f3e3df;
  --root: #2f5d8a; --fifth: #6a4c93; --locked: #b9b09e; --mark-text: #fff8f0;
  --serif: "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", serif;
  --sans: -apple-system, "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  --radius: 14px;
}
/* Dark: text a step below full brightness on a ground a step above black, and no large bright fills, to ease long reading.
   Marks on the fretboard are light here, so their labels turn dark. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --paper: #1b1a16; --card: #24221c; --ink: #d9d3c5; --soft: #9e9684; --line: #38342a; --wash: #2c2921;
    --accent: #cf8f62; --accent-ink: #1b140c; --go: #7d5237; --go-ink: #f1e8db;
    --good: #7fbd9c; --bad: #dc8d80; --good-wash: #212d26; --bad-wash: #33231f;
    --root: #7fa9d4; --fifth: #b9a0dc; --locked: #5a5446; --mark-text: #1b140c; color-scheme: dark; }
}
:root[data-theme="dark"] { --paper: #1b1a16; --card: #24221c; --ink: #d9d3c5; --soft: #9e9684; --line: #38342a; --wash: #2c2921;
  --accent: #cf8f62; --accent-ink: #1b140c; --go: #7d5237; --go-ink: #f1e8db;
  --good: #7fbd9c; --bad: #dc8d80; --good-wash: #212d26; --bad-wash: #33231f;
  --root: #7fa9d4; --fifth: #b9a0dc; --locked: #5a5446; --mark-text: #1b140c; color-scheme: dark; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
/* clip, not hidden: nothing may scroll sideways at 375px, and sticky elements still work */
html, body { overflow-x: clip; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.75 var(--sans); }
main { max-width: 680px; margin: 0 auto; padding: calc(16px + env(safe-area-inset-top)) 16px calc(160px + env(safe-area-inset-bottom)); }
h1 { font: 700 28px/1.35 var(--serif); margin: 4px 0 14px; letter-spacing: .01em; }
h2 { font: 600 14px/1.4 var(--sans); color: var(--soft); margin: 28px 0 10px; letter-spacing: .1em; }
h3 { font: 600 13px/1.4 var(--sans); color: var(--soft); margin: 0 0 6px; letter-spacing: .12em; }
p { margin: 0 0 14px; }
a { color: var(--accent); }
/* every button is at least a fingertip: 44 × 44 */
button { font: inherit; color: inherit; cursor: pointer; min-width: 44px; min-height: 44px; }
img, svg { max-width: 100%; }
.note { color: var(--soft); font-size: 15px; }
.loading { margin-top: 30vh; text-align: center; }

/* ── choices ───────────────────────────────────────── */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.chip { background: var(--card); border: 1.5px solid var(--line); border-radius: 999px; padding: 7px 18px; font-weight: 600; font-size: 15px; }
.chip small { font-weight: 400; color: var(--soft); }
.chip[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); color: var(--accent); }
.pill { background: var(--card); border: 1.5px solid var(--line); border-radius: 99px; padding: 7px 16px; font-size: 15px; font-weight: 600; }
.pill.strong { background: var(--go); border-color: var(--go); color: var(--go-ink); }
.quiet { background: none; border: 0; color: var(--soft); text-decoration: underline; padding: 8px; }
.stat { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 1px solid var(--line); padding: 12px 0; }
.stat b { font: 700 22px var(--serif); }
.stat small { color: var(--soft); margin-left: 8px; }

/* ── the fretboard and the notation (SVG strings drawn in currentColor) ── */
svg.fretboard, svg.notation { display: block; height: auto; color: var(--ink); }
svg.fretboard .cell { cursor: pointer; }
.mark.dot { color: var(--accent); }
.mark.right { color: var(--good); }
.mark.wrong { color: var(--bad); }
.mark.root { color: var(--root); }
.mark.third { color: var(--accent); }
.mark.fifth { color: var(--fifth); }
.mark-label { fill: var(--mark-text); font-weight: 700; }

/* ── a practice set ────────────────────────────────── */
.studybar { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 12px; align-items: center; margin-bottom: 6px; }
.studybar .tag { grid-column: 1 / -1; justify-self: start; }
.close { background: none; border: 0; font-size: 28px; line-height: 1; color: var(--soft); padding: 0 6px; }
.meter { height: 6px; border-radius: 99px; background: var(--wash); overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.tag { display: inline-block; font-size: 13px; letter-spacing: .08em; color: var(--accent); border: 1px solid currentColor; border-radius: 999px;
  padding: 1px 11px; margin: 0 0 8px; }
.count { color: var(--soft); font-size: 13px; min-width: 3em; text-align: right; }
.ask { font: 700 19px/1.5 var(--serif); margin: 0 0 8px; }
.ask b { color: var(--accent); }
.answers { display: grid; gap: 8px; margin: 12px 0 4px; }
.cols-2 { grid-template-columns: repeat(2, 1fr); } .cols-3 { grid-template-columns: repeat(3, 1fr); } .cols-4 { grid-template-columns: repeat(4, 1fr); }
.answers[hidden] { display: none; }
.answer { position: relative; background: var(--card); border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 4px; min-height: 52px;
  font-weight: 600; font-size: 16px; line-height: 1.3; }
.answer kbd { display: none; position: absolute; top: 3px; left: 6px; font: 11px var(--sans); color: var(--soft); }
@media (hover: hover) and (pointer: fine) { .answer kbd { display: block; } .answer:not(:disabled):hover { border-color: var(--accent); } }
.answer.right { border-color: var(--good); background: var(--good-wash); color: var(--good); }
.answer.wrong { border-color: var(--bad); background: var(--bad-wash); color: var(--bad); }
.answer:disabled { cursor: default; }
.answers .self { font-size: 15px; }
.verdict { font: 700 18px/1.5 var(--serif); margin: 10px 0 8px; min-height: 1.5em; }
.verdict.good { color: var(--good); } .verdict.bad { color: var(--bad); }
.verdict:empty { min-height: 0; margin: 0; }
.verdict { scroll-margin: 12px 0 calc(110px + env(safe-area-inset-bottom)); }   /* clear of the fixed bar when scrolled to */
.chips.listen { margin: 10px 0 0; }
.after .chips { margin: 0; }

/* the board: tall and tappable on a phone; one only looked at is shrunk to fit the screen */
/* the board shrinks to its drawing, so the string and fret numbers around it line up in percent */
.board { position: relative; width: fit-content; max-width: 100%; margin: 6px auto; }
.board-svg svg { display: block; }
.board.compact .board-svg svg { width: auto; max-height: 50vh; }
.string-nos { font-size: 11px; color: var(--soft); pointer-events: none; }
.string-nos.across { position: relative; height: 16px; }
.string-nos.across span { position: absolute; top: 0; transform: translateX(-50%); }
.string-nos.down { position: absolute; left: 0; top: 0; bottom: 0; width: 30px; }
.string-nos.down span { position: absolute; left: 2px; transform: translateY(-50%); }
.board:not(.tappable) .cell { cursor: default; }
.fret-nos { position: relative; height: 16px; font-size: 11px; color: var(--soft); }
.fret-nos span { position: absolute; top: 0; transform: translateX(-50%); }
.notes-figure { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px 10px; margin: 4px 0; }
.switch { display: flex; justify-content: flex-end; gap: 4px; margin-bottom: 2px; }
.mini { min-height: 32px; min-width: 44px; padding: 2px 8px; font-size: 13px; border-radius: 99px; border: 1px solid var(--line); background: none; color: var(--soft); }
.mini[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); font-weight: 700; }
.score svg { margin: 0 auto; }
.score-holder { overflow-x: auto; }
.solfege { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 6px 0 0; }
.solfege span { background: var(--wash); border-radius: 8px; padding: 2px 9px; font-weight: 600; }

/* summary */
.finish { margin-top: 6vh; }
.opened { margin: 4px 0 14px; padding-left: 1.3em; }
.misses ul { list-style: none; padding: 0; margin: 0; }
.misses li { display: flex; gap: 10px; align-items: center; border-bottom: 1px solid var(--line); padding: 8px 0; font-size: 15px; }
.misses li b { color: var(--good); white-space: nowrap; }
.misses li .mini { flex: none; }
.misses .where { color: var(--soft); }
.big { font: 700 24px/1.4 var(--serif); margin: 0 0 10px; }
.block { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 16px 0 12px; }
.block.good { border-left: 4px solid var(--good); }
.block > :last-child { margin-bottom: 0; }

/* ── cards ─────────────────────────────────────────── */
.lead { font-size: 17px; line-height: 1.85; }
.lead b { color: var(--accent); }
.card-figure { margin: 8px 0 10px; }
.card-figure figcaption { color: var(--soft); font-size: 13px; text-align: center; }
.card-figure .score { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; cursor: pointer; }
.explore { border-top: 1px solid var(--line); margin-top: 22px; }
.explore-info { font-weight: 600; min-height: 1.75em; margin: 6px 0 4px; position: sticky; top: 0; z-index: 2; background: var(--paper); padding: 6px 0; }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: 14px; color: var(--soft); margin: 0 0 10px; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-left: 8px; background: currentColor; }
.swatch:first-child { margin-left: 0; }
.swatch.root { color: var(--root); } .swatch.third { color: var(--accent); } .swatch.fifth { color: var(--fifth); }
.how { padding-left: 1.3em; } .how li { margin-bottom: 6px; }
.back { text-decoration: none; font-size: 15px; }

/* ── lists: today and free practice ─────────────────── */
.rows { display: grid; gap: 8px; }
.row { display: grid; grid-template-columns: 28px 1fr auto; gap: 12px; align-items: center; text-align: left; width: 100%;
  background: var(--card); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.row b { display: block; font-weight: 600; }
.row small { display: block; color: var(--soft); font-size: 14px; line-height: 1.45; }
.row .more { color: var(--soft); font-size: 22px; }
.tick { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.row.done .tick { background: var(--good); border-color: var(--good); color: var(--card); }
.row.done b { color: var(--soft); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ── the map ───────────────────────────────────────── */
.tracks { display: grid; gap: 4px 12px; }
.track h2 { margin-top: 18px; }
.node { display: block; width: 100%; text-align: left; border-radius: 12px; padding: 9px 12px; margin: 0 0 8px; border: 1.5px solid var(--line);
  background: var(--card); line-height: 1.4; }
.node b { display: block; font-weight: 600; font-size: 15px; }
.node small { font-size: 12px; color: var(--soft); }
.node-locked { color: var(--soft); background: transparent; border-style: dashed; border-color: var(--locked); }
.node-open { border-color: var(--accent); }
.node-open small { color: var(--accent); font-weight: 700; }
.node-learned { border-color: var(--good); background: var(--good-wash); }
.node-learned small { color: var(--good); font-weight: 700; }
.node-mastered { border-color: var(--good); background: var(--good); color: var(--card); }
.node-mastered small { color: var(--card); font-weight: 700; }
.swatch.node-locked { background: none; border: 1.5px dashed var(--locked); color: transparent; }
.swatch.node-open { background: none; border: 2px solid var(--accent); color: transparent; }
.swatch.node-learned { background: var(--good-wash); border: 2px solid var(--good); color: transparent; }
.swatch.node-mastered { background: var(--good); color: var(--good); }
@media (min-width: 760px) {
  .tracks { grid-template-columns: repeat(4, 1fr); }
}

/* ── the button bar and the tabs ───────────────────── */
.bar { position: fixed; left: 0; right: 0; bottom: calc(60px + env(safe-area-inset-bottom)); padding: 14px 16px 12px;
  background: linear-gradient(transparent, var(--paper) 28%); display: flex; justify-content: center; align-items: center; gap: 10px; z-index: 5; }
body:has(#tabs[hidden]) .bar { bottom: env(safe-area-inset-bottom); }
.bar[hidden] { display: none; }
.go { width: 100%; max-width: 644px; border: 0; border-radius: var(--radius); padding: 14px; font-weight: 600; font-size: 18px;
  background: var(--go); color: var(--go-ink); }
.go:disabled { background: var(--line); color: var(--soft); }
.bar .quiet { white-space: nowrap; }
#tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); z-index: 6; }
#tabs[hidden] { display: none; }
#tabs button { flex: 1; background: none; border: 0; padding: 8px 0 9px; font-size: 13px; color: var(--soft);
  display: flex; flex-direction: column; align-items: center; gap: 1px; }
#tabs .icon { font-size: 18px; line-height: 1.2; }
#tabs button[aria-current="page"] { color: var(--accent); font-weight: 700; }
/* a new version is ready: a pill at the top, over the page, never in the way of the × that ends a set */
.update { position: fixed; top: calc(8px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 7;
  max-width: calc(100% - 140px); white-space: nowrap; border: 0; border-radius: 99px; padding: 8px 16px; font-size: 14px; font-weight: 600;
  background: var(--ink); color: var(--paper); box-shadow: 0 4px 14px rgb(0 0 0 / .18); }
.update:disabled { opacity: .7; }

/* ── login ─────────────────────────────────────────── */
form.login { margin-top: 18vh; }
.logo { font: 700 36px/1.2 var(--serif); letter-spacing: .16em; margin: 0 0 6px; }
form.login input { width: 100%; font: inherit; font-size: 16px; padding: 13px 16px; border-radius: var(--radius); border: 1.5px solid var(--line);
  background: var(--card); color: var(--ink); margin: 14px 0; }
.error { color: var(--bad); min-height: 1.75em; margin-top: 10px; }

@media (min-width: 760px) {
  main:has(.tracks) { max-width: 960px; }
  body { font-size: 17px; }
  main { padding-top: 36px; }
}
