/* Tone Lab. One reading column. Lesson screens: progress bar → phrase card → practice (graph, record, result) → nav.
   Minibus-green accent; tone colours 1–6 match the phrasebook. */
:root{
  --bg:#F2F4F1; --surface:#FFFFFF; --ink:#17201B; --muted:#5B6760; --line:#DCE2DD; --grid:#E3E8E4;
  --accent:#0B6E4F; --accent-ink:#FFFFFF; --accent-soft:#E1EFE8; --rec:#C8262F; --warn-soft:#FFF4DC;
  --good:#11804F; --mid:#A36F00; --bad:#C8262F;
  --t1:#B8132B; --t2:#C2570C; --t3:#7A6A00; --t4:#1F6FB2; --t5:#6D3FB5; --t6:#2F7A4A;
  --you:#17201B;
  --f-han:"Noto Serif HK","PingFang HK","Microsoft JhengHei",serif;
  --f-body:"Atkinson Hyperlegible",system-ui,-apple-system,sans-serif;
  --f-mono:"JetBrains Mono",ui-monospace,Menlo,monospace;
  color-scheme:light;
}
@media (prefers-color-scheme:dark){:root{
  --bg:#0F1512; --surface:#18201C; --ink:#E6ECE8; --muted:#97A39C; --line:#2A3530; --grid:#25302B;
  --accent:#3FBF8C; --accent-ink:#06130D; --accent-soft:#1D3229; --rec:#FF5A5F; --warn-soft:#2E2715;
  --good:#3CCB8A; --mid:#E3B341; --bad:#FF6B6F;
  --t1:#FF7A8A; --t2:#FF9E5E; --t3:#E3CB4A; --t4:#6AB4F5; --t5:#B793F5; --t6:#6ED394;
  --you:#E6ECE8; color-scheme:dark}}
*{box-sizing:border-box}
[hidden]{display:none!important}
body{margin:0;background:var(--bg);color:var(--ink);font-family:var(--f-body);font-size:16px;line-height:1.5}
.wrap{max-width:720px;margin:0 auto;padding:20px max(16px,env(safe-area-inset-left)) 48px}
#view{display:flex;flex-direction:column;gap:14px}
a{color:inherit;text-decoration:none}
button{font:inherit;color:inherit;cursor:pointer}
:focus-visible{outline:3px solid var(--accent);outline-offset:2px}
.t1{color:var(--t1)}.t2{color:var(--t2)}.t3{color:var(--t3)}.t4{color:var(--t4)}.t5{color:var(--t5)}.t6{color:var(--t6)}
.good{color:var(--good)}.mid{color:var(--mid)}.bad{color:var(--bad)}
.kind{font-family:var(--f-mono);font-size:12px;letter-spacing:.06em;text-transform:uppercase;color:var(--muted);font-weight:600}
.lead{margin:0;font-size:18px;max-width:60ch}
.fine{margin:0;font-size:13px;color:var(--muted)}
.center{text-align:center}
.grow{flex:1}
.note{margin-bottom:14px;padding:12px 14px;border:1px solid var(--line);border-radius:10px;background:var(--surface);font-size:14px;color:var(--muted)}
.note b{color:var(--ink)}
.foot{font-size:13px;color:var(--muted);margin:28px 0 0;max-width:70ch}

/* buttons */
.btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;border:0;border-radius:999px;padding:10px 18px;font-weight:700;background:var(--accent-soft);color:var(--accent)}
.btn.primary{background:var(--accent);color:var(--accent-ink);padding:12px 22px}
.btn.ghost{background:transparent;border:1px solid var(--line);color:var(--ink)}
.btn.small{padding:6px 12px;font-size:13px}
.btn.round{width:52px;height:52px;padding:0;background:var(--accent);color:var(--accent-ink)}
.link{border:0;background:none;color:var(--accent);font-weight:700;padding:0;text-decoration:underline;font-size:14px}
.chip{flex:none;border:1px solid var(--line);background:var(--surface);border-radius:999px;padding:6px 12px;font-size:14px;white-space:nowrap}
.chip[aria-pressed="true"]{background:var(--accent);border-color:var(--accent);color:var(--accent-ink)}
.chips{display:flex;gap:6px;overflow-x:auto;scrollbar-width:none}
.actions{display:flex;flex-wrap:wrap;gap:8px}
.navrow{display:flex;gap:10px;align-items:center;justify-content:space-between;flex-wrap:wrap}
.selfq{flex:1;font-weight:700;min-width:180px}

/* cards */
.card{background:var(--surface);border:1px solid var(--line);border-radius:16px;padding:18px;display:flex;flex-direction:column;gap:16px}
h2{margin:0;font-size:24px}
h3{margin:2px 0 0;font-size:18px}

/* home */
.top{display:flex;justify-content:space-between;align-items:flex-start;gap:12px}
.eyebrow{font-family:var(--f-mono);font-size:12px;letter-spacing:.08em;text-transform:uppercase;color:var(--accent)}
h1{font-family:var(--f-han);font-size:clamp(28px,6vw,38px);margin:4px 0 2px;line-height:1.15}
h1 span{font-family:var(--f-body);font-size:.55em;color:var(--muted);font-weight:400;margin-left:6px}
.sub{margin:0;color:var(--muted);max-width:52ch}
.stars,.bstars{font-family:var(--f-mono);font-weight:600;color:var(--mid);white-space:nowrap}
.stars{font-size:20px;padding-top:6px}
.hero{display:flex;align-items:center;gap:12px;background:var(--accent);color:var(--accent-ink);border-radius:16px;padding:18px 20px}
.hero .kind{color:inherit;opacity:.85}
.hero.warn{background:var(--warn-soft);color:var(--ink);border:1px solid var(--line)}
.hero.warn .kind{color:var(--mid);opacity:1}
.hero.done{background:var(--surface);color:var(--ink);border:1px solid var(--line)}
.hero.done .kind{color:var(--muted)}
.htitle{font-size:22px;font-weight:700;line-height:1.25}
.hsub{opacity:.9;max-width:52ch}
.hero .go{margin-left:auto;font-size:28px}
.lessons{display:flex;flex-direction:column;gap:8px}
.lesson{display:grid;grid-template-columns:40px minmax(0,1fr) auto;grid-template-areas:"num lt ladder" "num ls lstate";gap:2px 12px;align-items:center;background:var(--surface);border:1px solid var(--line);border-radius:14px;padding:12px 14px}
.lesson:hover{border-color:var(--accent)}
.lesson.due{border-color:var(--mid)}
.lesson .num{grid-area:num;width:36px;height:36px;border-radius:50%;display:grid;place-items:center;background:var(--accent-soft);color:var(--accent);font-family:var(--f-mono);font-weight:600}
.lesson .lt{grid-area:lt;font-weight:700}
.lesson .ls{grid-area:ls;font-size:13px;color:var(--muted)}
.ladder{grid-area:ladder;display:flex;gap:3px;justify-self:end}
.ladder i,.pip{display:inline-block;width:18px;height:6px;border-radius:3px;background:var(--line)}
.ladder i.on,.pip.on{background:var(--accent)}
.lstate{grid-area:lstate;font-size:12px;color:var(--muted);justify-self:end;font-family:var(--f-mono);text-align:right}
.lstate.due{color:var(--mid);font-weight:600}
.tools{display:grid;grid-template-columns:repeat(auto-fit,minmax(190px,1fr));gap:8px}
.tools a{background:var(--surface);border:1px solid var(--line);border-radius:14px;padding:12px 14px;display:flex;flex-direction:column}
.tools a:hover{border-color:var(--accent)}
.tools span{font-size:13px;color:var(--muted)}

/* in-lesson top bar */
.bar{display:flex;align-items:center;gap:12px}
.back{width:36px;height:36px;border-radius:50%;display:grid;place-items:center;border:1px solid var(--line);background:var(--surface);font-size:18px;flex:none}
.btitle{font-weight:700;flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.prog{height:6px;border-radius:3px;background:var(--grid);overflow:hidden}
.prog i{display:block;height:100%;background:var(--accent);transition:width .3s}

/* intro */
.intro p{margin:0;max-width:62ch}
.steps-note{font-size:14px;color:var(--muted)}
.intro .btn.primary{align-self:flex-start}

/* phrase card */
.phrase{display:flex;flex-direction:column;gap:14px}
.phead{display:flex;justify-content:space-between;gap:14px;align-items:flex-start}
.han{font-family:var(--f-han);font-weight:700;font-size:clamp(34px,8vw,48px);line-height:1.2;letter-spacing:.02em}
.jp{font-family:var(--f-mono);font-size:17px;margin-top:2px}
.jp sup,.mj sup,.wj sup,.tj sup,.sj sup,.ij sup{font-size:.72em;font-weight:600;margin:0 3px 0 1px}
.en{font-size:19px;font-weight:700;margin-top:4px}
.play{display:flex;flex-direction:column;align-items:center;gap:6px;flex:none}
.words{display:flex;flex-wrap:wrap;gap:6px}
.word{border:1px solid var(--line);background:var(--bg);border-radius:10px;padding:6px 10px;display:flex;flex-direction:column;align-items:flex-start;text-align:left}
.word:hover{border-color:var(--accent)}
.wh{font-family:var(--f-han);font-size:19px;line-height:1.3}
.wj{font-family:var(--f-mono);font-size:12px;color:var(--muted)}
.wg{font-size:13px}
.explain{display:flex;flex-direction:column;gap:10px;background:var(--accent-soft);border-radius:12px;padding:14px 16px}
.explain p{margin:0;max-width:64ch}
.lbl{display:block;font-family:var(--f-mono);font-size:11px;letter-spacing:.06em;text-transform:uppercase;color:var(--accent);font-weight:600;margin-bottom:2px}
.sayit{display:flex;flex-direction:column;gap:8px;border-top:1px solid var(--line);padding-top:14px}

/* recall prompt */
.prompt{text-align:center;padding:8px 0}
.ask{color:var(--muted)}
.pen{font-size:clamp(24px,6vw,32px);font-weight:700;line-height:1.25}
#reveal{border-top:1px solid var(--line);padding-top:14px}

/* practice widget */
.pw{display:flex;flex-direction:column;gap:12px}
.graph{width:100%;height:auto;display:block;background:var(--bg);border-radius:12px}
.graph text{font-family:var(--f-mono);font-size:11px;fill:var(--muted)}
.graph .gl{stroke:var(--line);stroke-width:1.2}
.graph .gl.faint{stroke:var(--grid)}
.graph .target{fill:none;stroke-width:18;stroke-opacity:.3;stroke-linecap:round;stroke-linejoin:round}
.graph .you{fill:none;stroke:var(--you);stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round}
.graph .youdot,.graph .dot{fill:var(--you)}
.graph .lab.han{font-family:var(--f-han);font-size:20px;fill:var(--ink)}
.graph .lab.jp{font-size:12px;font-weight:600}
.graph .lab.jp.t1{fill:var(--t1)}.graph .lab.jp.t2{fill:var(--t2)}.graph .lab.jp.t3{fill:var(--t3)}.graph .lab.jp.t4{fill:var(--t4)}.graph .lab.jp.t5{fill:var(--t5)}.graph .lab.jp.t6{fill:var(--t6)}
.graph .lab{font-size:20px}
.graph .cap{font-size:11px}
.recrow{display:flex;align-items:center;gap:14px}
.rec{width:60px;height:60px;border-radius:50%;border:3px solid var(--rec);background:var(--surface);display:grid;place-items:center;flex:none}
.rec span{width:26px;height:26px;border-radius:50%;background:var(--rec);transition:all .15s}
.rec.on span{border-radius:5px;width:20px;height:20px}
.rec.on{animation:pulse 1.2s infinite}
@keyframes pulse{50%{box-shadow:0 0 0 8px color-mix(in srgb,var(--rec) 20%,transparent)}}
.recinfo{display:flex;flex-direction:column;gap:6px;flex:1;min-width:0}
.status{font-size:14px;color:var(--muted)}
.meter{width:90px;height:6px;border-radius:3px;background:var(--grid);overflow:hidden}
.meter i{display:block;height:100%;width:0;background:var(--accent)}
.res{display:flex;flex-direction:column;gap:12px}
.rmsg{background:var(--warn-soft);border-radius:10px;padding:12px 14px}
.rtop{display:flex;gap:14px;align-items:stretch;flex-wrap:wrap}
.score{display:flex;flex-direction:column;justify-content:center;align-items:center;min-width:96px;padding:8px 10px;border-radius:12px;background:var(--bg)}
.score b{font-family:var(--f-mono);font-size:32px;line-height:1}
.score span{font-size:12px;color:var(--muted)}
.sylrow{display:flex;flex-wrap:wrap;gap:6px;flex:1}
.syl{display:flex;flex-direction:column;align-items:center;gap:2px;padding:6px 8px;border-radius:10px;background:var(--bg);min-width:54px}
.syl .sh{font-family:var(--f-han);font-size:20px;line-height:1.2;color:var(--ink)}
.syl .sj{font-family:var(--f-mono);font-size:11px;color:var(--ink)}
.syl i{display:block;width:100%;height:4px;border-radius:2px;background:linear-gradient(90deg,currentColor var(--v),var(--grid) var(--v))}
.syl .sv{font-family:var(--f-mono);font-size:11px}
.tips{margin:0;padding-left:20px;display:flex;flex-direction:column;gap:4px;max-width:64ch}

/* conversation */
.chat{gap:12px}
.msg{display:flex;flex-direction:column;gap:4px;max-width:86%}
.msg.them{align-self:flex-start;align-items:flex-start}
.msg.you{align-self:flex-end;align-items:flex-end}
.who{font-size:12px;color:var(--muted);font-family:var(--f-mono)}
.bubble{border-radius:16px;padding:10px 14px;display:flex;flex-direction:column;gap:2px}
.them .bubble{background:var(--bg);border:1px solid var(--line);border-top-left-radius:4px}
.you .bubble{background:var(--accent-soft);border-top-right-radius:4px;align-items:flex-end;text-align:right}
.msg.past{opacity:.75;max-width:70%}
.msg.past .bubble{padding:6px 12px}
.mh{font-family:var(--f-han);font-size:22px;font-weight:700}
.past .mh{font-size:17px}
.mj{font-family:var(--f-mono);font-size:14px}
.me{font-size:15px}
.you .me{font-weight:700}
.mnote{font-size:13px;color:var(--muted);margin-top:4px;max-width:50ch}

/* done */
.done{align-items:center;text-align:center}
.done .big{font-family:var(--f-han);font-size:48px;font-weight:700;color:var(--accent);line-height:1}
.done .stats{display:flex;gap:24px;flex-wrap:wrap;justify-content:center}
.done .stats div{display:flex;flex-direction:column;align-items:center}
.done .stats b{font-family:var(--f-mono);font-size:28px;display:flex;gap:3px;align-items:center;min-height:40px}
.done .stats span{font-size:13px;color:var(--muted)}
.done p{max-width:48ch;margin:0}

/* calibration */
.calword{display:flex;align-items:center;gap:16px;flex-wrap:wrap}
.calword .han{font-size:56px}
.presets{display:flex;gap:8px;margin-top:8px}
details summary{cursor:pointer;color:var(--accent);font-weight:700}

/* gym */
.gymtop{display:flex;justify-content:space-between;gap:12px;align-items:flex-start}
.gymtop .phrase{flex:1}
.tshape{display:flex;flex-direction:column;align-items:center;font-size:12px;color:var(--muted);font-family:var(--f-mono)}
.tshape svg{width:90px;height:46px}
.items{display:flex;flex-wrap:wrap;gap:8px;align-items:center}
.item{border:1px solid var(--line);background:var(--bg);border-radius:10px;padding:6px 10px;display:flex;flex-direction:column;align-items:center;min-width:60px}
.item[aria-current="true"]{border-color:var(--accent);background:var(--accent-soft)}
.ih{font-family:var(--f-han);font-size:22px;line-height:1.2}
.ij,.ib{font-family:var(--f-mono);font-size:11px}
.ib{color:var(--muted)}

/* progress */
.phead2{display:flex;justify-content:space-between;align-items:flex-start;gap:8px}
.ptable{width:100%;border-collapse:collapse;font-size:14px}
.ptable th{text-align:left;font-weight:600;font-size:12px;color:var(--muted);padding:4px 6px;border-bottom:1px solid var(--line)}
.ptable td{padding:8px 6px;border-bottom:1px solid var(--grid);font-variant-numeric:tabular-nums;vertical-align:middle}
.th{font-family:var(--f-han);font-size:17px}
.tj{font-family:var(--f-mono);font-size:12px;color:var(--muted)}
.spark{width:90px;height:24px;display:block}
.spark polyline{fill:none;stroke:var(--accent);stroke-width:2}
.spark .gl.faint{stroke:var(--grid);stroke-dasharray:2 2}

@media (max-width:520px){
  .ptable th:nth-child(4),.ptable td:nth-child(4),.ptable th:nth-child(5),.ptable td:nth-child(5){display:none}
  .msg{max-width:100%}
}
@media (prefers-reduced-motion:reduce){*{animation:none!important;transition:none!important}}

/* sound check (Jyutping model, beta) */
.sound{border:1px dashed var(--line);border-radius:12px;padding:12px 14px;display:flex;flex-direction:column;gap:8px}
.sound .heard{font-family:var(--f-body)}
.sound .heard b{font-family:var(--f-mono);font-weight:600}
.sctable{border-collapse:collapse;font-size:14px}
.sctable th{font-size:12px;color:var(--muted);font-weight:600;text-align:center;padding:2px 10px}
.sctable td{padding:4px 10px;text-align:center;font-family:var(--f-mono)}
.sctable td:first-child{text-align:left}
.sctable .ok{color:var(--good);font-weight:700}.sctable .no{color:var(--bad);font-weight:700}
.modelbox{display:flex;flex-direction:column;gap:6px;font-size:14px}
.modelbox select{font:inherit;margin-left:6px}

/* units on home */
.uhead{display:flex;flex-direction:column;gap:2px;margin:10px 2px 4px}
.uhead h2{font-size:21px}
.uhead p{max-width:60ch}
.lesson .num{font-size:12px}

/* listening round */
.listenbtns{display:flex;align-items:center;justify-content:center;gap:10px;margin-top:10px}
.btn.round.big{width:72px;height:72px}
.btn.round.big svg{width:26px;height:26px}
.choices{display:grid;grid-template-columns:1fr 1fr;gap:10px}
@media (max-width:480px){.choices{grid-template-columns:1fr}}
.choice{border:2px solid var(--line);background:var(--bg);border-radius:12px;padding:14px 12px;font-weight:700;text-align:center;min-height:56px}
.choice:hover:not([disabled]){border-color:var(--accent)}
.choice.right{border-color:var(--good);background:color-mix(in srgb,var(--good) 14%,var(--surface))}
.choice.wrong{border-color:var(--bad);background:color-mix(in srgb,var(--bad) 12%,var(--surface))}
.choice[disabled]{cursor:default}
.lfb{display:flex;flex-direction:column;gap:8px;border-radius:12px;padding:12px 14px;background:var(--bg)}
.lfb.good>b{color:var(--good)}.lfb.bad>b{color:var(--bad)}
