/* Kwantum Theory course. Tiers: 1 Early Years (playful), 2 Initial-Grade 2 (friendly), 3 Grades 3-5 (clean), 4 Grades 6-8 (serious). */
:root {
  --bg: #F4F6F9; --surface: #FFFFFF; --ink: #0F1726; --muted: #4A5568; --line: #D9DEE6; --chip: #E9EDF3; --hover: #EEF2F7;
  --th: #1E3A8A; --acc: #1E3A8A; --acc-ink: #FFFFFF; --good: #13795B; --good-bg: #E3F5EE; --bad: #B42318; --bad-bg: #FDECEA; --warn: #9A5B06; --warn-bg: #FFF4DE;
  --hl: #E0522D; --staff: #0F1726;
  --r: 10px; --r-lg: 16px;
  --font: "Lexend", "Schibsted Grotesk", "Helvetica Neue", Arial, sans-serif;
  --font-head: var(--font);
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0B111C; --surface: #121A28; --ink: #E9EDF4; --muted: #A4AEC0; --line: #263247; --chip: #1B2536; --hover: #172131;
    --th: #8FA8F5; --acc: #6F8EF0; --acc-ink: #0B111C; --good: #4ACB98; --good-bg: #0F2A22; --bad: #FF8A80; --bad-bg: #331615; --warn: #F5B849; --warn-bg: #2E2410;
    --hl: #FF8A65; --staff: #E9EDF4; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0B111C; --surface: #121A28; --ink: #E9EDF4; --muted: #A4AEC0; --line: #263247; --chip: #1B2536; --hover: #172131;
  --th: #8FA8F5; --acc: #6F8EF0; --acc-ink: #0B111C; --good: #4ACB98; --good-bg: #0F2A22; --bad: #FF8A80; --bad-bg: #331615; --warn: #F5B849; --warn-bg: #2E2410;
  --hl: #FF8A65; --staff: #E9EDF4; color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg, #F4F6F9); color: var(--ink, #0F1726); font-family: var(--font); font-size: 17px; line-height: 1.55; }
button, select, input { font: inherit; color: inherit; }
a { color: var(--acc); }
:focus-visible { outline: 3px solid var(--acc); outline-offset: 2px; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 12px 16px 64px; }

/* top row: small, straight to content */
.th-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 4px 0 16px; }
.th-tile { width: 44px; height: 44px; border-radius: 6px; background: var(--th-tile, #1E3A8A); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 19px; flex: none; position: relative; }
.th-tile small { position: absolute; top: 2px; left: 4px; font-size: 9px; font-weight: 500; opacity: .8; font-family: var(--mono); }
.th-name { font-weight: 700; font-size: 20px; line-height: 1.1; font-family: var(--font-head); }
.th-name span { display: block; font-size: 13px; font-weight: 500; color: var(--muted); font-family: var(--font); }
.th-levels { margin-left: auto; display: flex; gap: 4px; flex-wrap: wrap; }
.th-levels a { text-decoration: none; color: var(--muted); font-size: 13px; padding: 4px 9px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); }
.th-levels a[aria-current] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.th-prog { height: 6px; background: var(--chip); border-radius: 99px; overflow: hidden; width: 100%; }
.th-prog i { display: block; height: 100%; background: var(--good); border-radius: 99px; transition: width .4s; }

/* unit tiles */
.units { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.unit { text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: var(--r); padding: 14px; cursor: pointer; display: flex; flex-direction: column; gap: 8px; min-height: 150px; transition: transform .12s, box-shadow .12s; }
.unit:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(15, 23, 38, .08); }
.unit .sym { width: 52px; height: 52px; border-radius: 6px; background: var(--uc, var(--th)); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 22px; position: relative; }
.unit .sym small { position: absolute; top: 2px; left: 4px; font-size: 9px; font-family: var(--mono); font-weight: 500; opacity: .85; }
.unit h3 { margin: 0; font-size: 17px; line-height: 1.25; font-family: var(--font-head); }
.unit p { margin: 0; font-size: 14px; color: var(--muted); line-height: 1.4; flex: 1; }
.unit .bar { height: 5px; background: var(--chip); border-radius: 99px; overflow: hidden; }
.unit .bar i { display: block; height: 100%; background: var(--good); }
.unit .st { font-size: 12px; color: var(--muted); font-family: var(--mono); }
.unit.wide { grid-column: 1 / -1; flex-direction: row; align-items: center; min-height: 0; }
.unit.wide .sym { background: var(--ink); color: var(--bg); }
.unit.wide div { flex: 1; }
.foot-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 28px; flex-wrap: wrap; }
.foot-nav a { text-decoration: none; border: 1px solid var(--line); background: var(--surface); border-radius: var(--r); padding: 10px 14px; color: var(--ink); font-size: 15px; }
.foot-nav a span { display: block; font-size: 12px; color: var(--muted); }

/* unit view */
.crumb { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.crumb button.back { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 6px 12px; cursor: pointer; font-size: 14px; }
.crumb h2 { margin: 0; font-size: 22px; font-family: var(--font-head); }
.tabs { display: inline-flex; border: 1px solid var(--line); border-radius: 99px; padding: 3px; background: var(--surface); margin-left: auto; }
.tabs button { border: 0; background: none; padding: 6px 14px; border-radius: 99px; cursor: pointer; font-size: 14px; color: var(--muted); }
.tabs button[aria-selected="true"] { background: var(--ink); color: var(--bg); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; max-width: 820px; margin: 0 auto; }
.card h3 { margin: 0 0 8px; font-size: 21px; line-height: 1.25; font-family: var(--font-head); }
.card p { margin: 8px 0; }
.card .lead { font-size: 18px; }
.dots { display: flex; gap: 6px; justify-content: center; margin: 14px 0 0; flex-wrap: wrap; }
.dots b { width: 9px; height: 9px; border-radius: 50%; background: var(--line); }
.dots b.on { background: var(--ink); }
.dots b.done { background: var(--good); }
.nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 18px; }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: var(--r); padding: 10px 16px; cursor: pointer; font-size: 16px; display: inline-flex; align-items: center; gap: 8px; }
.btn:hover { background: var(--hover); }
.btn.pri { background: var(--acc); border-color: var(--acc); color: var(--acc-ink); font-weight: 600; }
.btn.pri:hover { filter: brightness(1.08); }
.btn.rec { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn[disabled] { opacity: .45; cursor: default; }
.btn svg { width: 18px; height: 18px; flex: none; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 10px 0; }
.tip { border-left: 4px solid var(--warn); background: var(--warn-bg); padding: 10px 14px; border-radius: 0 var(--r) var(--r) 0; margin: 12px 0; font-size: 15px; }
.tip b:first-child { display: block; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--warn); }
.note-box { background: var(--chip); border-radius: var(--r); padding: 10px 14px; margin: 10px 0; font-size: 15px; }
.mem { font-weight: 700; color: var(--acc); }
.kbd-k { display: inline-block; border: 1px solid var(--line); border-radius: 4px; padding: 0 6px; font-family: var(--mono); font-size: 14px; background: var(--chip); }
table.tt { border-collapse: collapse; width: 100%; margin: 10px 0; font-size: 15px; }
table.tt th, table.tt td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: middle; }
table.tt th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.sym-cell { font-family: "Bravura", serif; font-size: 28px; line-height: 1; }

/* notation */
.stv { margin: 10px 0; color: var(--staff); }
.stv svg.kws { margin: 0 auto; }
svg.kws { fill: var(--staff); stroke: var(--staff); }
svg.kws [fill]:not([fill="none"]) { fill: var(--staff); }
svg.kws [stroke]:not([stroke="none"]) { stroke: var(--staff); }
svg.kws text { fill: var(--staff); }
svg.kws .kws-ann { font-family: var(--font); font-size: 12px; font-weight: 500; fill: var(--staff); }
svg.kws .kws-now path, svg.kws .kws-now text { fill: var(--hl) !important; stroke: var(--hl) !important; }
svg.kws .kws-ghosthead { fill: var(--acc); opacity: .35; }
svg.kws .kws-placed { fill: var(--acc); }
svg.kws .kws-good { fill: var(--good); }
svg.kws .kws-bad { fill: var(--bad); }
svg.kws .kws-ledger { stroke: var(--staff); stroke-width: 1.2; }
.kws-picker { cursor: crosshair; }

/* keyboard */
.kb { margin: 10px auto; max-width: 100%; overflow-x: auto; }
.kb svg { display: block; margin: 0 auto; touch-action: manipulation; }
.kb .w { fill: #fff; stroke: #556; stroke-width: 1; cursor: pointer; }
.kb .b { fill: #1b2230; stroke: #000; cursor: pointer; }
.kb .w.mark { fill: #FFD9A8; } .kb .b.mark { fill: #E07B26; }
.kb .w.down { fill: #BFD0FF; } .kb .b.down { fill: #3F5BD9; }
.kb .w.good { fill: #BDEBD6; } .kb .b.good { fill: #13795B; }
.kb .w.bad { fill: #F8C7C2; } .kb .b.bad { fill: #B42318; }
.kb text { font-family: var(--font); font-size: 12px; pointer-events: none; fill: #334; }
.kb text.on-b { fill: #fff; font-size: 10px; }

/* questions */
.q-meta { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); font-family: var(--mono); margin-bottom: 6px; }
.q-prompt { font-size: 19px; font-weight: 600; margin: 4px 0 10px; }
.opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin: 12px 0; }
.opts.letters { grid-template-columns: repeat(7, 1fr); }
.opts.stack { grid-template-columns: 1fr; }
.opt { border: 2px solid var(--line); background: var(--surface); border-radius: var(--r); padding: 12px 10px; cursor: pointer; font-size: 17px; text-align: center; min-height: 52px; transition: border-color .1s, background .1s; }
.opt:hover:not([disabled]) { border-color: var(--acc); }
.opt.good { border-color: var(--good); background: var(--good-bg); }
.opt.bad { border-color: var(--bad); background: var(--bad-bg); }
.opt[disabled] { cursor: default; }
.opt .stv { margin: 0; pointer-events: none; }
.opt.has-stave { padding: 6px; }
.fb { border-radius: var(--r); padding: 12px 14px; margin: 10px 0; font-size: 16px; }
.fb.good { background: var(--good-bg); border-left: 4px solid var(--good); }
.fb.bad { background: var(--bad-bg); border-left: 4px solid var(--bad); }
.fb b.h { display: block; }
.hint { background: var(--chip); border-radius: var(--r); padding: 10px 14px; font-size: 15px; margin: 8px 0; }
.score-big { font-size: 48px; font-weight: 700; line-height: 1; margin: 8px 0; font-family: var(--font-head); }
.breakdown { list-style: none; padding: 0; margin: 12px 0; }
.breakdown li { display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); padding: 8px 0; gap: 8px; }

/* listen back */
.lb { border: 1px dashed var(--line); border-radius: var(--r); padding: 12px; margin: 12px 0; }
.lb-h { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.meter { height: 8px; background: var(--chip); border-radius: 99px; overflow: hidden; margin: 8px 0; }
.meter i { display: block; height: 100%; width: 0; background: var(--acc); transition: width .05s; }
.timeline { position: relative; height: 54px; background: var(--chip); border-radius: var(--r); margin: 10px 0; overflow: hidden; }
.timeline .exp { position: absolute; top: 8px; width: 3px; height: 38px; background: var(--muted); border-radius: 2px; opacity: .5; }
.timeline .hit { position: absolute; top: 14px; width: 14px; height: 26px; margin-left: -7px; border-radius: 7px; }
.timeline .hit.ok { background: var(--good); } .timeline .hit.near { background: var(--warn); } .timeline .hit.off { background: var(--bad); }
.timeline .beat { position: absolute; bottom: 2px; font-size: 10px; color: var(--muted); font-family: var(--mono); margin-left: -3px; }
canvas.pitch { width: 100%; height: 180px; background: var(--chip); border-radius: var(--r); display: block; margin: 10px 0; }
.countin { font-size: 40px; font-weight: 700; text-align: center; min-height: 52px; color: var(--acc); }

/* early years picture answers */
.pic { display: block; margin: 0 auto; width: 92px; height: 92px; }
.big-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; margin: 14px 0; }
.big-opts .opt { padding: 14px; font-size: 20px; font-weight: 600; border-width: 3px; border-radius: 22px; }
.big-play { width: 110px; height: 110px; border-radius: 50%; border: 0; background: var(--acc); color: var(--acc-ink); display: grid; place-items: center; margin: 8px auto; cursor: pointer; box-shadow: 0 6px 0 rgba(0,0,0,.15); }
.big-play svg { width: 48px; height: 48px; }
.big-play:active { transform: translateY(3px); box-shadow: 0 3px 0 rgba(0,0,0,.15); }
.ta-row { display: flex; gap: 16px; justify-content: center; align-items: flex-end; flex-wrap: wrap; margin: 16px 0; min-height: 90px; }
.ta { display: flex; flex-direction: column; align-items: center; gap: 4px; font-weight: 700; font-size: 18px; }
.ta i { display: block; width: 44px; height: 44px; border-radius: 50%; background: var(--acc); }
.ta.ti i { width: 30px; height: 30px; background: #E0852D; }
.ta.sh i { background: transparent; border: 3px dashed var(--muted); }
.ta.now i { transform: scale(1.25); background: var(--hl); transition: transform .08s; }
.ta-pair { display: flex; gap: 6px; align-items: flex-end; }
.balloon { width: 60px; height: 72px; border-radius: 50% 50% 48% 48%; background: #E0522D; margin: 10px auto; transition: transform .08s; transform-origin: bottom center; position: relative; }
.balloon::after { content: ""; position: absolute; left: 50%; bottom: -40px; width: 2px; height: 40px; background: var(--muted); }
.sticker { display: inline-grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: #FFD34D; color: #5A3B00; font-weight: 800; font-size: 13px; transform: rotate(-8deg); box-shadow: 0 3px 0 rgba(0,0,0,.15); }

/* ---------- tiers ---------- */
body[data-tier="1"] { --r: 18px; --r-lg: 28px; font-size: 19px; }
body[data-tier="1"] { --bg: #FFF8EC; --surface: #FFFFFF; --line: #F0DFC2; --chip: #FFF0D6; --acc: #6A4BD8; --acc-ink: #fff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) body[data-tier="1"] { --bg: #17131F; --surface: #221B2E; --line: #3A3049; --chip: #2B2238; --acc: #A58BFF; --acc-ink: #17131F; } }
:root[data-theme="dark"] body[data-tier="1"] { --bg: #17131F; --surface: #221B2E; --line: #3A3049; --chip: #2B2238; --acc: #A58BFF; --acc-ink: #17131F; }
body[data-tier="1"] .units { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
body[data-tier="1"] .unit { border-width: 3px; align-items: center; text-align: center; padding: 18px; min-height: 190px; }
body[data-tier="1"] .unit .sym { width: 86px; height: 86px; border-radius: 50%; font-size: 30px; }
body[data-tier="1"] .unit .sym small { display: none; }
body[data-tier="1"] .unit h3 { font-size: 21px; }
body[data-tier="1"] .card { border-width: 3px; padding: 24px; }
body[data-tier="1"] .card h3 { font-size: 26px; text-align: center; }
body[data-tier="1"] .card p { text-align: center; }
body[data-tier="1"] .btn { border-radius: 99px; padding: 12px 20px; font-size: 18px; }
body[data-tier="1"] .q-prompt { text-align: center; font-size: 22px; }
body[data-tier="1"] .opt { border-radius: 22px; }

body[data-tier="2"] { --r: 14px; --r-lg: 20px; }
body[data-tier="2"] .unit { border-width: 2px; }
body[data-tier="2"] .unit .sym { border-radius: 12px; }

body[data-tier="3"] { --r: 8px; --r-lg: 10px; font-size: 16.5px; }

body[data-tier="4"] { --r: 4px; --r-lg: 6px; font-size: 16.5px; --font-head: "Source Serif 4", Georgia, "Times New Roman", serif; }
body[data-tier="4"] { --bg: #F5F3EE; --surface: #FFFEFB; --line: #DCD6CA; --chip: #ECE8DF; --acc: #1E3A8A; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) body[data-tier="4"] { --bg: #11120F; --surface: #191A16; --line: #33352D; --chip: #23251F; --acc: #9DB2F2; } }
:root[data-theme="dark"] body[data-tier="4"] { --bg: #11120F; --surface: #191A16; --line: #33352D; --chip: #23251F; --acc: #9DB2F2; }
body[data-tier="4"] .unit { min-height: 130px; box-shadow: none; }
body[data-tier="4"] .unit:hover { transform: none; border-color: var(--ink); box-shadow: none; }
body[data-tier="4"] .unit .sym { background: transparent; color: var(--ink); border: 1.5px solid var(--ink); border-radius: 2px; }
body[data-tier="4"] .unit h3, body[data-tier="4"] .card h3 { font-weight: 600; }
body[data-tier="4"] .card h3 { font-size: 24px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
body[data-tier="4"] .card .num { font-family: var(--mono); font-size: 12px; color: var(--muted); display: block; }
body[data-tier="4"] .tip { border-left-color: var(--ink); background: var(--chip); }
body[data-tier="4"] .tip b:first-child { color: var(--ink); }

@media (max-width: 560px) {
  .opts.letters { grid-template-columns: repeat(4, 1fr); }
  .card { padding: 14px; }
  .tabs { margin-left: 0; }
  .th-levels { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) { .unit, .th-prog i { transition: none; } }
@media print { .th-levels, .tabs, .nav, .foot-nav { display: none; } }
.unit.wide .sym { flex: none; }
body[data-tier="1"] .unit.wide { flex-direction: row; text-align: left; min-height: 0; align-items: center; }
body[data-tier="1"] .unit.wide .sym { width: 64px; height: 64px; }
body[data-tier="1"] .card .lead { text-align: center; }
.timeline:empty { display: none; }
svg.kws .kws-hl path, svg.kws .kws-hl text, svg.kws .kws-hl rect { fill: var(--hl) !important; stroke: var(--hl) !important; }
