/* 中文之路 — ink & rice-paper, vermilion seal */
:root {
  --paper: #f6f3ec; --paper-2: #fffdf8; --ink: #1d1b19; --ink-2: #4a4540; --muted: #857d74;
  --line: #e2dccf; --line-2: #cfc6b5; --seal: #c8322a; --seal-soft: #f6dcd6; --jade: #2f7a63; --jade-soft: #d9ece4;
  --gold: #b07d1f; --gold-soft: #f3e6c8; --shadow: 0 1px 2px rgba(40,30,20,.06), 0 8px 24px -12px rgba(40,30,20,.18);
  --grid: rgba(200,50,42,.18);
  --f-body: "Be Vietnam Pro", "Noto Sans SC", system-ui, sans-serif;
  --f-disp: "Noto Serif", "Noto Serif SC", Georgia, serif;
  --f-hz: "Noto Serif SC", "Songti SC", serif;
  --r: 14px; color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --paper: #151413; --paper-2: #1e1c1a; --ink: #ece6dc; --ink-2: #c4bcb0; --muted: #8e867b;
  --line: #2e2b28; --line-2: #3d3934; --seal: #e0554a; --seal-soft: #3a1f1c; --jade: #5cb898; --jade-soft: #1d332b;
  --gold: #d9a948; --gold-soft: #3a2f19; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px -12px rgba(0,0,0,.6);
  --grid: rgba(224,85,74,.22); color-scheme: dark; } }
:root[data-theme="dark"] {
  --paper: #151413; --paper-2: #1e1c1a; --ink: #ece6dc; --ink-2: #c4bcb0; --muted: #8e867b;
  --line: #2e2b28; --line-2: #3d3934; --seal: #e0554a; --seal-soft: #3a1f1c; --jade: #5cb898; --jade-soft: #1d332b;
  --gold: #d9a948; --gold-soft: #3a2f19; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px -12px rgba(0,0,0,.6);
  --grid: rgba(224,85,74,.22); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.6 var(--f-body); color: var(--ink); background: var(--paper); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
h1, h2, h3 { font-family: var(--f-disp); font-weight: 700; line-height: 1.25; margin: 0 0 .6em; letter-spacing: -.01em; }
h1 { font-size: clamp(26px, 4vw, 36px); } h2 { font-size: 20px; } h3 { font-size: 17px; }
a { color: var(--seal); }
.muted { color: var(--muted); } .small { font-size: 13px; }
:focus-visible { outline: 2px solid var(--seal); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--seal-soft); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; padding: 24px 14px; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 22px; background: var(--paper); }
.brand { display: flex; gap: 12px; align-items: center; padding: 0 8px; }
.seal { width: 44px; height: 44px; flex: none; background: var(--seal); color: #fff; font: 900 13px/1.05 var(--f-hz); display: grid; place-items: center; text-align: center; border-radius: 6px; transform: rotate(-4deg); box-shadow: inset 0 0 0 2px rgba(255,255,255,.25); }
.brand-name { font: 600 18px var(--f-hz); }
.brand-sub { font-size: 12px; color: var(--muted); }
nav { display: flex; flex-direction: column; gap: 2px; }
nav button { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border: 0; background: none; color: var(--ink-2); font: 500 14px var(--f-body); border-radius: 10px; cursor: pointer; text-align: left; transition: background .15s, color .15s; }
nav button i { font: normal 400 17px var(--f-hz); width: 26px; height: 26px; display: grid; place-items: center; border-radius: 6px; color: var(--muted); transition: all .2s; }
nav button:hover { background: var(--paper-2); color: var(--ink); }
nav button.active { background: var(--paper-2); color: var(--ink); box-shadow: var(--shadow); }
nav button.active i { background: var(--seal); color: #fff; }
.theme-toggle { margin-top: auto; border: 1px solid var(--line-2); background: none; color: var(--ink-2); padding: 8px 12px; border-radius: 999px; cursor: pointer; font: 500 13px var(--f-body); }
.theme-toggle .moon { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: none; } :root[data-theme="dark"] .theme-toggle .moon { display: inline; }

main { padding: 40px clamp(16px, 4vw, 56px) 80px; max-width: 1180px; width: 100%; min-width: 0; }
.tab { display: none; }
.tab.active { display: block; animation: rise .35s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.page-head { margin-bottom: 24px; }
.page-head p.muted { max-width: 60ch; margin: 0; }
.eyebrow { font: 500 12px var(--f-body); letter-spacing: .12em; text-transform: uppercase; color: var(--seal); margin: 0 0 6px; }

/* ---------- primitives ---------- */
.panel { background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--r); padding: 22px; box-shadow: var(--shadow); margin-bottom: 18px; min-width: 0; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.center { justify-content: center; }
.btn, button.btn { background: var(--ink); color: var(--paper); border: 0; padding: 10px 18px; border-radius: 10px; font: 600 14px var(--f-body); cursor: pointer; transition: transform .1s, opacity .15s; }
.btn:hover { opacity: .88; } .btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: progress; }
.btn.seal-btn { background: var(--seal); color: #fff; }
.ghost { background: none; border: 1px solid var(--line-2); color: var(--ink-2); padding: 7px 12px; border-radius: 9px; cursor: pointer; font: 500 13px var(--f-body); }
.ghost:hover { border-color: var(--ink-2); color: var(--ink); }
.tag { display: inline-block; font-size: 12px; font-weight: 500; padding: 2px 9px; border-radius: 999px; background: var(--seal-soft); color: var(--seal); white-space: nowrap; }
.tag.g { background: var(--jade-soft); color: var(--jade); }
.tag.y { background: var(--gold-soft); color: var(--gold); }
input, select, textarea { font: 14px var(--f-body); color: var(--ink); background: var(--paper); border: 1px solid var(--line-2); border-radius: 10px; padding: 9px 12px; min-width: 0; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--seal); box-shadow: 0 0 0 3px var(--seal-soft); }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin-bottom: 16px; align-items: center; }
.check { display: flex; gap: 6px; align-items: center; font-size: 14px; }
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; }
.list th { text-align: left; font: 500 12px var(--f-body); color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding: 8px 10px; border-bottom: 1px solid var(--line-2); }
.list td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.list tr:last-child td { border-bottom: 0; }
.list .hz { font: 500 22px var(--f-hz); cursor: pointer; }
.list .hz:hover { color: var(--seal); }
.empty { text-align: center; padding: 28px 12px; color: var(--muted); }
.empty .hz-big { font: 400 40px var(--f-hz); color: var(--line-2); display: block; }
kbd { font: 500 11px var(--f-body); border: 1px solid var(--line-2); border-bottom-width: 2px; padding: 1px 6px; border-radius: 5px; background: var(--paper-2); }

/* ---------- home ---------- */
.hero { display: grid; grid-template-columns: 1fr auto; gap: 28px; align-items: end; padding-bottom: 28px; margin-bottom: 28px; border-bottom: 1px solid var(--line); }
.quote { font: 400 clamp(30px, 5vw, 52px)/1.15 var(--f-hz); letter-spacing: .04em; margin-bottom: 10px; }
.quote-vi { font: italic 500 15px var(--f-disp); color: var(--ink-2); margin-bottom: 18px; }
.goal-line { font-size: 15px; color: var(--ink-2); }
.countdown { text-align: right; }
.countdown b { display: block; font: 700 clamp(48px, 7vw, 76px)/1 var(--f-disp); color: var(--seal); letter-spacing: -.03em; }
.countdown span { font-size: 13px; color: var(--muted); }
.kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 22px; }
.kpi { background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: flex; gap: 12px; align-items: center; box-shadow: var(--shadow); min-width: 0; }
.ring { width: 54px; height: 54px; flex: none; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 5; }
.ring .bg { stroke: var(--line); }
.ring .fg { stroke: var(--seal); stroke-linecap: round; transition: stroke-dashoffset 1s cubic-bezier(.2,.8,.2,1); }
.kpi.jade .fg { stroke: var(--jade); } .kpi.gold .fg { stroke: var(--gold); }
.kpi b { font: 700 22px/1.1 var(--f-disp); display: block; }
.kpi b small { font-size: 13px; color: var(--muted); font-weight: 500; }
.kpi-txt > span { font-size: 12.5px; color: var(--muted); line-height: 1.35; display: block; }
.tasks { padding: 0; list-style: none; margin: 12px 0 18px; }
.tasks li { padding: 9px 0 9px 26px; position: relative; border-bottom: 1px dashed var(--line); }
.tasks li::before { content: ""; position: absolute; left: 4px; top: 16px; width: 8px; height: 8px; border: 2px solid var(--seal); border-radius: 50%; }
.session { display: grid; gap: 6px; margin-bottom: 18px; }
.session div { display: grid; grid-template-columns: 64px 1fr; gap: 10px; padding: 8px 10px; border-radius: 8px; background: var(--paper); }
.session b { font-family: var(--f-disp); color: var(--seal); }
.roadmap { list-style: none; padding: 0; margin: 0; display: grid; gap: 0; }
.roadmap li { display: grid; grid-template-columns: 22px 120px 1fr; gap: 12px; align-items: start; padding: 10px 0; position: relative; }
.roadmap li::before { content: ""; position: absolute; left: 10px; top: 0; bottom: 0; width: 2px; background: var(--line); }
.roadmap .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--paper-2); border: 2px solid var(--line-2); margin: 5px 0 0 5px; position: relative; z-index: 1; }
.roadmap li.done .dot { background: var(--ink-2); border-color: var(--ink-2); }
.roadmap li.done { color: var(--muted); }
.roadmap li.now .dot { background: var(--seal); border-color: var(--seal); box-shadow: 0 0 0 4px var(--seal-soft); }
.roadmap li.now { font-weight: 600; }
.roadmap .when { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- flashcards ---------- */
.card-wrap { max-width: 560px; margin: 0 auto; text-align: center; }
.progress-bar { height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; }
.progress-bar div { height: 100%; background: var(--seal); width: 0; transition: width .4s ease; }
.progress { font-size: 13px; color: var(--muted); margin: 10px 0 18px; min-height: 1.6em; }
.flash-scene { perspective: 1400px; margin-bottom: 22px; }
.flash { position: relative; height: 430px; transform-style: preserve-3d; transition: transform .7s cubic-bezier(.3,1.3,.5,1); cursor: pointer; border-radius: 20px; }
.flash.flipped { transform: rotateY(180deg); cursor: default; }
.flash.done { cursor: default; }
.face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; background: var(--paper-2); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; gap: 6px; }
.face.back { transform: rotateY(180deg); }
.mizi { position: relative; width: 190px; height: 190px; display: grid; place-items: center; border: 1.5px solid var(--grid); margin-bottom: 10px;
  background:
    linear-gradient(var(--grid), var(--grid)) center/100% 1px no-repeat,
    linear-gradient(var(--grid), var(--grid)) center/1px 100% no-repeat,
    linear-gradient(45deg, transparent calc(50% - .5px), var(--grid) 50%, transparent calc(50% + .5px)),
    linear-gradient(-45deg, transparent calc(50% - .5px), var(--grid) 50%, transparent calc(50% + .5px)); }
.big-hz { font: 400 clamp(72px, 18vw, 120px)/1 var(--f-hz); white-space: nowrap; }
.big-hz.long { font-size: clamp(44px, 11vw, 72px); }
.face .hint { font-size: 13px; color: var(--muted); }
.back .big-hz { font-size: 64px; }
.py { font: 500 26px var(--f-disp); color: var(--seal); }
.mean { font-size: 20px; font-weight: 600; }
.stamp { position: absolute; top: 18px; right: 18px; border: 2px solid var(--seal); color: var(--seal); font: 600 12px var(--f-body); padding: 2px 8px; border-radius: 4px; transform: rotate(6deg); }
.trap-note { margin-top: 6px; }
.grade-again { background: var(--seal) !important; color: #fff !important; }
.grade-good { background: var(--jade) !important; color: #fff !important; }
.grade-easy { background: var(--gold) !important; color: #fff !important; }
.grade-hard { background: var(--ink-2) !important; color: var(--paper) !important; }
.keys { font-size: 12px; color: var(--muted); margin-top: 22px; }
.celebrate { font: 400 80px/1 var(--f-hz); color: var(--seal); }

/* ---------- tones ---------- */
.tone-box { text-align: center; padding: 36px 22px; }
.play { width: 120px; height: 120px; border-radius: 50%; border: 0; background: var(--seal); color: #fff; font: 600 16px var(--f-body); cursor: pointer; box-shadow: 0 0 0 8px var(--seal-soft); margin-bottom: 26px; transition: transform .15s; }
.play:hover { transform: scale(1.04); } .play:active { transform: scale(.96); }
#toneChoices button { font: 500 24px var(--f-disp); min-width: 92px; padding: 14px 18px; border-radius: 12px; border: 1.5px solid var(--line-2); background: var(--paper); color: var(--ink); cursor: pointer; transition: all .15s; }
#toneChoices button:hover { border-color: var(--ink-2); transform: translateY(-2px); }
#toneChoices button.ok { background: var(--jade); border-color: var(--jade); color: #fff; }
#toneChoices button.bad { background: var(--seal); border-color: var(--seal); color: #fff; animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.tone-result { min-height: 1.6em; margin-top: 18px; font-size: 16px; }
.score { font: 700 18px var(--f-disp); color: var(--ink-2); margin-top: 6px; }
.sandhi { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.sandhi li { display: grid; grid-template-columns: 150px 1fr; gap: 12px; padding: 10px 12px; background: var(--paper); border-radius: 10px; }
.sandhi span { color: var(--seal); font-weight: 600; font-size: 14px; }

/* ---------- vocab ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input { flex: 1 1 260px; }
details.add summary { cursor: pointer; font-weight: 600; color: var(--seal); list-style: none; }
details.add[open] summary { margin-bottom: 14px; }
td.box { white-space: nowrap; }
.trap-btn { border: 0; background: none; cursor: pointer; font-size: 16px; padding: 4px 8px; border-radius: 8px; color: var(--line-2); }
.trap-btn.on { color: var(--gold); background: var(--gold-soft); }

/* ---------- radicals ---------- */
.rad-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.rad { background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; text-align: center; transition: transform .2s, box-shadow .2s; }
.rad:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.rad .r { font: 400 52px/1.2 var(--f-hz); margin: 6px 0; }
.rad .meta { font-size: 13px; color: var(--ink-2); }
.rad .ex { font: 500 20px var(--f-hz); margin-top: 6px; background: none; border: 0; color: var(--ink); cursor: pointer; padding: 2px 8px; border-radius: 6px; }
.rad .ex:hover { color: var(--seal); background: var(--seal-soft); }

/* ---------- tutor ---------- */
.chat { background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); display: flex; flex-direction: column; height: min(72vh, 760px); margin-bottom: 18px; overflow: hidden; }
.chat-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.tutor-id { display: flex; gap: 12px; align-items: center; min-width: 0; }
.avatar { width: 40px; height: 40px; flex: none; border-radius: 50%; background: var(--seal); color: #fff; display: grid; place-items: center; font: 600 18px var(--f-hz); }
.chat-log { flex: 1; overflow-y: auto; padding: 20px 18px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 82%; padding: 11px 15px; border-radius: 16px; line-height: 1.6; overflow-wrap: anywhere; animation: rise .25s ease both; }
.msg.user { align-self: flex-end; background: var(--ink); color: var(--paper); border-bottom-right-radius: 4px; white-space: pre-wrap; }
.msg.assistant { align-self: flex-start; background: var(--paper); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.error { align-self: flex-start; background: var(--seal-soft); color: var(--seal); }
.msg.thinking { color: var(--muted); }
.msg.thinking::after { content: ""; display: inline-block; width: 1em; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }
.md p { margin: 0 0 .6em; } .md p:last-child { margin-bottom: 0; }
.md ul, .md ol { margin: .2em 0 .6em; padding-left: 1.3em; }
.md h4 { font: 700 15px var(--f-disp); margin: .6em 0 .3em; }
.md code { font-size: .92em; background: var(--line); padding: 1px 5px; border-radius: 4px; }
.usage { font-size: 11.5px; color: var(--muted); margin-top: 8px; padding-top: 7px; border-top: 1px dashed var(--line-2); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 10px 18px 0; scrollbar-width: none; }
.chips button { flex: none; border: 1px solid var(--line-2); background: var(--paper); color: var(--ink-2); padding: 6px 12px; border-radius: 999px; font: 13px var(--f-body); cursor: pointer; }
.chips button:hover { border-color: var(--seal); color: var(--seal); }
.chat-form { display: flex; gap: 8px; padding: 12px 18px 16px; }
.chat-form textarea { flex: 1; resize: none; }

/* ---------- resources ---------- */
.res-group a { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.res-group a:last-child { border-bottom: 0; }
.res-group a:hover { color: var(--seal); }
.res-group a::after { content: "↗"; color: var(--muted); }


/* ---------- P0: stroke order / Hán Việt / levels / writing ---------- */
.hw-row { display: flex; gap: 6px; justify-content: center; cursor: pointer; }
.hw-box, .mizi-bg { position: relative; display: grid; place-items: center; border: 1.5px solid var(--grid);
  background:
    linear-gradient(var(--grid), var(--grid)) center/100% 1px no-repeat,
    linear-gradient(var(--grid), var(--grid)) center/1px 100% no-repeat,
    linear-gradient(45deg, transparent calc(50% - .5px), var(--grid) 50%, transparent calc(50% + .5px)),
    linear-gradient(-45deg, transparent calc(50% - .5px), var(--grid) 50%, transparent calc(50% + .5px)); }
.hw-fallback { font-family: var(--f-hz); line-height: 1; }
.hv { margin-top: 4px; font-size: 14px; }
.hv-line { display: flex; gap: 6px; align-items: center; justify-content: center; flex-wrap: wrap; }
.link-btn { border: 0; background: none; color: var(--seal); font: 500 13px var(--f-body); cursor: pointer; padding: 2px 6px; border-radius: 6px; }
.link-btn:hover { background: var(--seal-soft); }
.hv-edit { display: flex; gap: 6px; justify-content: center; }
.hv-edit input { width: 150px; padding: 6px 10px; }
.hv-edit .btn { padding: 6px 12px; }
.lvbars { display: grid; gap: 8px; }
.lvbar { display: grid; grid-template-columns: 30px 56px 1fr auto; gap: 12px; align-items: center; border: 0; background: none; padding: 6px 4px; border-radius: 10px; cursor: pointer; color: var(--ink); font: 14px var(--f-body); text-align: left; transition: background .15s, transform .15s; }
.lvbar:hover { background: var(--paper); transform: translateX(3px); }
.lv-seal { width: 28px; height: 28px; display: grid; place-items: center; background: var(--seal); color: #fff; font: 600 14px var(--f-hz); border-radius: 5px; transform: rotate(-4deg); }
.lv-name { font-weight: 600; }
.lv-track { height: 8px; background: var(--line); border-radius: 8px; overflow: hidden; }
.lv-track span { display: block; height: 100%; background: linear-gradient(90deg, var(--seal), var(--gold)); border-radius: 8px; transition: width 1.1s cubic-bezier(.2,.8,.2,1); }
.lv-num { font: 700 14px var(--f-disp); font-variant-numeric: tabular-nums; }
.lv-num small { color: var(--muted); font-weight: 500; }
.lv-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.lv-chip { position: relative; overflow: hidden; border: 1px solid var(--line-2); background: var(--paper-2); color: var(--ink-2); border-radius: 999px; padding: 6px 14px; font: 500 13px var(--f-body); cursor: pointer; display: flex; gap: 6px; align-items: baseline; transition: border-color .15s, transform .15s; }
.lv-chip small { color: var(--muted); font-size: 11px; position: relative; }
.lv-chip i { position: absolute; left: 0; bottom: 0; height: 2px; background: var(--jade); }
.lv-chip:hover { border-color: var(--ink-2); transform: translateY(-1px); }
.lv-chip.on { background: var(--seal); border-color: var(--seal); color: #fff; }
.lv-chip.on small { color: rgba(255,255,255,.8); }
.pager { margin-top: 14px; }
.pager button:disabled { opacity: .4; cursor: default; }
.tone-opts { display: flex; gap: 10px; align-items: center; justify-content: center; margin-bottom: 18px; }
.write-stage { position: relative; overflow: hidden; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.write-info .mean { font-size: 18px; }
.write-chars { display: flex; gap: 6px; font: 400 28px var(--f-hz); }
.write-chars span { color: var(--line-2); } .write-chars .cur { color: var(--seal); } .write-chars .done { color: var(--jade); }
.write-pad { width: min(300px, 80vw); aspect-ratio: 1; touch-action: none; background-color: var(--paper); border-radius: 4px; }
.ok-t { color: var(--jade); font-weight: 600; } .bad-t { color: var(--seal); font-weight: 600; }
.stroke-dialog { border: 1px solid var(--line); border-radius: 20px; background: var(--paper-2); color: var(--ink); padding: 28px; box-shadow: var(--shadow); max-width: min(560px, 92vw); text-align: center; }
.stroke-dialog::backdrop { background: rgba(20,15,10,.45); backdrop-filter: blur(2px); }
.stroke-dialog[open] { animation: pop .3s cubic-bezier(.3,1.3,.5,1) both; }
.sd-close { position: absolute; top: 12px; right: 12px; }
.sd-meta { margin: 14px 0; display: grid; gap: 2px; }
.sd-hw { flex-wrap: wrap; }
@keyframes pop { from { opacity: 0; transform: scale(.94) translateY(8px); } }

/* ---------- motion layer ---------- */
/* nav: vệt mực quét dưới mục đang chọn */
nav button span { position: relative; }
nav button span::after { content: ""; position: absolute; left: 0; right: 0; bottom: -3px; height: 2px; background: var(--seal); border-radius: 2px; transform: scaleX(0); transform-origin: left; transition: transform .35s cubic-bezier(.2,.8,.2,1); }
nav button.active span::after { transform: scaleX(1); }
nav button:active { transform: scale(.97); }
.btn, .ghost, .link-btn { transition: transform .12s, opacity .15s, background .15s, border-color .15s, box-shadow .15s; }
.btn:hover { box-shadow: 0 6px 16px -8px rgba(40,30,20,.5); transform: translateY(-1px); }
.ghost:active, .link-btn:active { transform: scale(.96); }
/* tab vào: mờ + nhô lên (rise đã có); stagger cho thẻ/dòng */
.tab.active .kpi, .tab.active .rad, .tab.active .lvbar, .tab.active > .panel, .tab.active .two > .panel { animation: rise .5s cubic-bezier(.2,.8,.2,1) both; }
.kpi:nth-child(2) { animation-delay: .05s !important; } .kpi:nth-child(3) { animation-delay: .1s !important; }
.kpi:nth-child(4) { animation-delay: .15s !important; } .kpi:nth-child(5) { animation-delay: .2s !important; }
.lvbar:nth-child(n) { animation-delay: calc(.2s + var(--i, 0) * .04s); }
.rad:nth-child(-n+30) { animation-delay: .02s; }
.rad:nth-child(3n+1) { animation-delay: .04s !important; } .rad:nth-child(3n+2) { animation-delay: .09s !important; } .rad:nth-child(3n) { animation-delay: .14s !important; }
.list tr { animation: rowIn .35s ease both; }
.list tr:nth-child(2) { animation-delay: .02s; } .list tr:nth-child(3) { animation-delay: .04s; } .list tr:nth-child(4) { animation-delay: .06s; }
.list tr:nth-child(5) { animation-delay: .08s; } .list tr:nth-child(6) { animation-delay: .1s; } .list tr:nth-child(7) { animation-delay: .12s; }
.list tr:nth-child(8) { animation-delay: .14s; } .list tr:nth-child(n+9) { animation-delay: .16s; }
@keyframes rowIn { from { opacity: 0; transform: translateY(4px); } }
.ring .fg { transition: stroke-dashoffset 1.2s cubic-bezier(.2,.8,.2,1); }
/* flashcards: chia bài / trượt ra / đóng dấu */
.flash.deal-in { animation: dealIn .45s cubic-bezier(.2,.9,.3,1.1) both; }
@keyframes dealIn { from { opacity: 0; transform: translateX(40px) rotate(3deg) scale(.96); } }
.flash.out-right { transform: rotateY(180deg) translateX(-120%) rotate(-6deg) !important; opacity: 0; transition: transform .42s ease-in, opacity .42s ease-in; }
.flash.out-left { transform: rotateY(180deg) translateX(120%) rotate(6deg) !important; opacity: 0; transition: transform .42s ease-in, opacity .42s ease-in; }
.flash.shake-out { animation: shakeOut .52s ease-in both; }
@keyframes shakeOut { 0% { transform: rotateY(180deg); } 15% { transform: rotateY(180deg) translateX(8px); } 30% { transform: rotateY(180deg) translateX(-8px); } 45% { transform: rotateY(180deg) translateX(6px); } 60% { transform: rotateY(180deg); opacity: 1; } 100% { transform: rotateY(180deg) translateY(30px); opacity: 0; } }
.grade-stamp { position: absolute; z-index: 5; top: 50%; left: 50%; width: 110px; height: 110px; margin: -55px 0 0 -55px; display: grid; place-items: center; font: 900 60px/1 var(--f-hz); color: #fff; background: var(--jade); border-radius: 12px; transform: rotateY(180deg) rotate(-8deg); box-shadow: 0 0 0 6px var(--jade-soft); animation: stamp .35s cubic-bezier(.2,1.6,.4,1) both; pointer-events: none; }
.grade-stamp.easy { background: var(--gold); box-shadow: 0 0 0 6px var(--gold-soft); }
@keyframes stamp { from { opacity: 0; transform: rotateY(180deg) rotate(-8deg) scale(2.2); } }
.flash-scene, .write-stage { position: relative; }
.confetti { position: absolute; inset: -20px 0 0; pointer-events: none; overflow: hidden; z-index: 20; }
.confetti span { position: absolute; top: -40px; animation: fall 2.2s cubic-bezier(.3,.6,.5,1) both; }
.confetti .c-seal { width: 30px; height: 30px; display: grid; place-items: center; background: var(--seal); color: #fff; font: 900 16px var(--f-hz); border-radius: 4px; }
.confetti .c-petal { color: var(--seal); font-size: 14px; opacity: .8; }
@keyframes fall { from { transform: translate(0, 0) rotate(0); opacity: 0; } 10% { opacity: 1; } to { transform: translate(var(--dx), 480px) rotate(var(--rot)); opacity: 0; } }
/* tone: nút nghe gợn sóng khi phát, đúng = vết mực ngọc */
.play { position: relative; }
.play.playing::before, .play.playing::after { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--seal); animation: ripple 1.2s ease-out infinite; pointer-events: none; }
.play.playing::after { animation-delay: .4s; }
@keyframes ripple { from { transform: scale(1); opacity: .7; } to { transform: scale(1.7); opacity: 0; } }
#toneChoices button { position: relative; }
#toneChoices button.ok::after { content: ""; position: absolute; inset: -6px; border-radius: 16px; background: radial-gradient(circle, var(--jade) 0 40%, transparent 70%); opacity: 0; animation: splash .6s ease-out; pointer-events: none; z-index: -1; }
@keyframes splash { 0% { transform: scale(.4); opacity: .6; } 100% { transform: scale(1.5); opacity: 0; } }
/* chat */
.msg.user { animation: slideL .3s cubic-bezier(.2,.8,.2,1) both; }
.msg.assistant { animation: slideR .3s cubic-bezier(.2,.8,.2,1) both; }
@keyframes slideL { from { opacity: 0; transform: translateX(14px); } }
@keyframes slideR { from { opacity: 0; transform: translateX(-14px); } }
.msg.thinking::after { content: none; }
.ink-dots { display: inline-flex; gap: 4px; margin-right: 6px; vertical-align: middle; }
.ink-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-2); animation: inkDot 1.2s ease-in-out infinite; }
.ink-dots i:nth-child(2) { animation-delay: .15s; } .ink-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes inkDot { 0%, 60%, 100% { transform: translateY(0) scale(.8); opacity: .4; } 30% { transform: translateY(-4px) scale(1); opacity: 1; } }
.chips button { transition: transform .15s, border-color .15s, color .15s, box-shadow .15s; }
.chips button:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
/* luyện viết: thắng */
.write-pad.win { animation: winPulse .6s ease-out; }
@keyframes winPulse { 0% { box-shadow: 0 0 0 0 var(--jade); } 100% { box-shadow: 0 0 0 18px transparent; } }
@media (max-width: 820px) { .lvbar { grid-template-columns: 30px 50px 1fr; } .lv-num { grid-column: 2 / 4; } }

/* ---------- responsive ---------- */
@media (max-width: 1000px) { .kpis { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: sticky; top: 0; z-index: 10; height: auto; flex-direction: row; align-items: center; padding: 10px 16px; gap: 10px; border-right: 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
  .brand-sub { display: none; }
  .theme-toggle { margin: 0 0 0 auto; }
  nav { order: 3; width: 100%; flex-direction: row; overflow-x: auto; scrollbar-width: none; }
  nav button { flex: none; padding: 7px 10px; }
  nav button i { display: none; }
  main { padding: 24px 16px 60px; }
  .two { grid-template-columns: 1fr; }
  .hero { grid-template-columns: 1fr; }
  .countdown { text-align: left; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .flash { height: 340px; }
  .mizi { width: 150px; height: 150px; }
  .msg { max-width: 92%; }
  .sandhi li, .roadmap li { grid-template-columns: 1fr; gap: 2px; }
  .roadmap li { padding-left: 30px; } .roadmap .dot { position: absolute; left: 0; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.toolbar input[type="checkbox"] { flex: none; }
.toolbar .check { white-space: nowrap; }
.list .hz { white-space: nowrap; }

/* =====================================================================
   Consistency layer — một thang khoảng cách, một độ rộng, một chiều cao control
   ===================================================================== */
:root { --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --content: 1080px; --focus-w: 600px; --ctl-h: 40px; --r-sm: 10px; }

/* khung nội dung: căn giữa, mọi tab cùng độ rộng */
main { max-width: none; padding: var(--s7) clamp(16px, 4vw, 48px) 96px; }
main > .tab { max-width: var(--content); margin-inline: auto; }
.page-head { margin-bottom: var(--s6); }
.page-head h1 { margin-bottom: var(--s2); }
.page-head p.muted { margin-top: var(--s2); }
.eyebrow { margin-bottom: var(--s2); }

/* panel & lưới: cùng padding, cùng khoảng cách */
.panel { padding: var(--s5); margin-bottom: var(--s5); }
.panel > h2, .panel > h3 { margin-bottom: var(--s4); }
.panel > .eyebrow + h3 { margin-top: 0; }
.two { gap: var(--s5); align-items: stretch; margin-bottom: var(--s5); }
.two > .panel { margin-bottom: 0; display: flex; flex-direction: column; }
.two > .panel > .btn:last-child { margin-top: auto; align-self: flex-start; }

/* control cao đều */
input:not([type="checkbox"]), select, .btn, button.btn, .ghost { min-height: var(--ctl-h); }
.ghost { padding: 0 var(--s4); display: inline-flex; align-items: center; gap: var(--s2); }
.btn, button.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); padding: 0 var(--s5); }
select { padding-right: 32px; }
.toolbar { gap: var(--s3); margin-bottom: var(--s4); }
.toolbar select { flex: 0 0 auto; }
.grid-form { gap: var(--s3); margin-bottom: var(--s5); grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.grid-form .btn { width: 100%; }
.row { gap: var(--s3); }

/* bảng luôn nằm trong thẻ giấy */
#vocab .table-wrap { background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: var(--s2) var(--s4); }
.list th { padding: var(--s3) var(--s3); }
.list td { padding: var(--s3); vertical-align: middle; }
.list td small, .list td .muted { display: block; }
details.add { padding: var(--s4) var(--s5); }
.lv-chips { gap: var(--s2); margin-bottom: var(--s4); }
.pager { margin-top: var(--s5); }

/* ---------- Tổng quan ---------- */
.hero { gap: var(--s6); padding-bottom: var(--s6); margin-bottom: var(--s6); }
.quote-vi { margin-bottom: var(--s4); }
.kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--s4); margin-bottom: var(--s5); }
.kpi { padding: var(--s4) var(--s5) var(--s4) var(--s4); justify-content: space-between; align-items: center; gap: var(--s3); min-height: 104px; }
.kpi-txt { display: flex; flex-direction: column; gap: var(--s1); min-width: 0; }
.kpi-txt > span { font-size: 12.5px; color: var(--muted); line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi b { font: 700 30px/1 var(--f-disp); font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi b small { font-size: 13px; margin-left: 2px; }
.kpi .ring { width: 44px; height: 44px; }
.lvbars { gap: var(--s1); }
.lvbar { grid-template-columns: 28px 64px 1fr 96px; padding: var(--s2); }
.lv-num { text-align: right; }
.tasks { margin: var(--s3) 0 var(--s5); }
.session { gap: var(--s2); margin-bottom: var(--s5); }
.session div { padding: var(--s3); grid-template-columns: 72px 1fr; }
.roadmap li { grid-template-columns: 22px 128px 1fr; padding: var(--s2) 0; }

/* ---------- chế độ tập trung (flashcard / luyện viết / thanh điệu) ---------- */
.card-wrap { max-width: var(--focus-w); }
.tone-box { max-width: var(--focus-w); margin-inline: auto; }
#tones > .panel:not(.tone-box) { max-width: var(--focus-w); margin-inline: auto; }
#tones .page-head, #cards .page-head, #write .page-head { text-align: center; }
#tones .page-head p.muted, #write .page-head p.muted { margin-inline: auto; }
#write .toolbar { justify-content: center; }
.progress { margin: var(--s3) 0 var(--s5); }
.flash-scene { margin-bottom: var(--s5); }
#cardActions { gap: var(--s3); }
#cardActions .btn { min-width: 108px; }
.keys { margin-top: var(--s5); }
.sandhi li { grid-template-columns: 140px 1fr; padding: var(--s3) var(--s4); }

/* ---------- Bộ thủ ---------- */
.rad-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: var(--s4); }
.rad { padding: var(--s4); display: flex; flex-direction: column; align-items: center; gap: var(--s1); }

/* ---------- Gia sư ---------- */
.chat { height: calc(100vh - 230px); min-height: 520px; max-height: 860px; margin-bottom: 0; }
.chat-head { padding: var(--s4) var(--s5); }
.chat-log { padding: var(--s5); gap: var(--s4); }
.chips { padding: var(--s3) var(--s5) 0; }
.chat-form { padding: var(--s3) var(--s5) var(--s5); gap: var(--s3); align-items: stretch; }
.chat-form .btn { min-width: 88px; }
.msg { max-width: min(720px, 85%); }

/* ---------- Tài liệu ---------- */
.res-group a { padding: var(--s3) 0; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 820px) {
  main { padding: var(--s5) var(--s4) 72px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi b { font-size: 24px; }
  .panel { padding: var(--s4); }
  .two { gap: var(--s4); }
  .lvbar { grid-template-columns: 28px 56px 1fr; }
  .chat { height: calc(100vh - 210px); min-height: 440px; }
  .chat-head, .chat-log, .chat-form { padding-inline: var(--s4); }
  .chips { padding-inline: var(--s4); }
}

/* bảng từ vựng: cột cố định, nghĩa tiếng Anh gọn 2 dòng */
#vocabTable th:nth-child(1), #vocabTable td:nth-child(1) { width: 1%; white-space: nowrap; }
#vocabTable td:nth-child(2), #vocabTable td:nth-child(4) { white-space: nowrap; }
#vocabTable th:nth-child(5), #vocabTable td:nth-child(5),
#vocabTable th:nth-child(6), #vocabTable td:nth-child(6),
#vocabTable th:nth-child(7), #vocabTable td:nth-child(7) { width: 1%; white-space: nowrap; text-align: center; }
#vocabTable td:nth-child(3) { min-width: 240px; }
#vocabTable td:nth-child(3) .small { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 2px; }
#vocabTable tr:hover td { background: var(--paper); }

/* biến điệu: nhãn cố định bên trái, nội dung chảy tự nhiên */
.sandhi li { display: block; padding: var(--s3) var(--s4) var(--s3) calc(140px + var(--s4) * 2); position: relative; }
.sandhi li > span:first-child { position: absolute; left: var(--s4); top: var(--s3); width: 140px; }
@media (max-width: 820px) { .sandhi li { padding-left: var(--s4); } .sandhi li > span:first-child { position: static; display: block; width: auto; } }

/* bộ thủ: tên + nghĩa xếp 2 dòng, chữ ví dụ cố định đáy thẻ */
.rad-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.rad .meta { display: flex; flex-direction: column; gap: 2px; font-size: 13px; line-height: 1.35; min-height: 2.7em; }
.rad .meta b { font-size: 14px; color: var(--ink); }
.rad .meta span { color: var(--muted); }
.rad .ex { margin-top: auto; padding-top: var(--s2); font-size: 18px; letter-spacing: .08em; }
.rad .tag { align-self: center; }

/* form trong nhật ký: nút chiếm trọn hàng cuối */
.two .grid-form .btn { grid-column: 1 / -1; }

/* tài liệu: 3 cột đều */
#res .two { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

/* =====================================================================
   Điện thoại: bảng → thẻ
   ===================================================================== */
@media (max-width: 720px) {
  /* ô chỉ số thứ 5 trải hết hàng, khỏi lẻ loi */
  .kpis .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }

  /* bỏ khung bảng, mỗi dòng là một thẻ */
  #vocab .table-wrap { background: none; border: 0; box-shadow: none; padding: 0; overflow: visible; }
  #vocabTable, #vocabTable tbody { display: block; }
  #vocabTable tr:first-child:has(th) { display: none; }
  #vocabTable tr {
    display: grid; grid-template-columns: auto 1fr auto; grid-template-areas:
      "hz py  lv"
      "hz hv  st"
      "mn mn  tr";
    column-gap: var(--s3); row-gap: var(--s1); align-items: center;
    background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--r);
    box-shadow: var(--shadow); padding: var(--s3) var(--s4); margin-bottom: var(--s3);
  }
  #vocabTable tr:hover td { background: none; }
  #vocabTable td { display: block; padding: 0; border: 0; width: auto !important; min-width: 0 !important; text-align: left !important; }
  #vocabTable td:nth-child(1) { grid-area: hz; font-size: 34px; padding-right: var(--s2); }
  #vocabTable td:nth-child(2) { grid-area: py; color: var(--seal); font-weight: 600; }
  #vocabTable td:nth-child(3) { grid-area: mn; border-top: 1px dashed var(--line); padding-top: var(--s2); margin-top: var(--s1); }
  #vocabTable td:nth-child(4) { grid-area: hv; font-size: 13px; color: var(--ink-2); }
  #vocabTable td:nth-child(4)::before { content: "Hán Việt · "; color: var(--muted); }
  #vocabTable td:nth-child(4):empty { display: none; }
  #vocabTable td:nth-child(5) { grid-area: lv; justify-self: end; }
  #vocabTable td:nth-child(5) .tag::before { content: "HSK "; }
  #vocabTable td:nth-child(6) { grid-area: st; justify-self: end; }
  #vocabTable td:nth-child(7) { grid-area: tr; justify-self: end; align-self: end; }
  #vocabTable td.empty { grid-column: 1 / -1; }
  #vocabTable tr:has(td.empty) { display: block; }

  /* nhật ký & error log: mỗi dòng một thẻ nhỏ, nhãn cột lấy từ header */
  #logTable tr:first-child:has(th), #errorTable tr:first-child:has(th) { display: none; }
  #logTable, #logTable tbody, #errorTable, #errorTable tbody { display: block; }
  #logTable tr, #errorTable tr { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s3); padding: var(--s3) 0; border-bottom: 1px solid var(--line); }
  #logTable td, #errorTable td { padding: 0; border: 0; }
  #logTable td:last-child, #errorTable td:nth-child(2) { flex-basis: 100%; }

  /* thanh lọc cấp: cuộn ngang thay vì xuống 3 dòng */
  .lv-chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-inline: calc(var(--s4) * -1); padding-inline: var(--s4); }
  .lv-chip { flex: none; }
  .toolbar > * { flex: 1 1 100%; }
  #vocabCount { flex-basis: auto; }

  /* thẻ flashcard & nút chấm vừa ngón tay */
  #cardActions { display: grid; grid-template-columns: repeat(2, 1fr); width: 100%; }
  #cardActions .btn { min-width: 0; min-height: 48px; }
  #cardActions > :only-child, #cardActions > .ghost { grid-column: 1 / -1; }
  .keys { display: none; }
  .chat-head { flex-wrap: wrap; }
  #usageSummary { display: none; }
}

/* =====================================================================
   Lộ trình hôm nay · 今日之路
   ===================================================================== */
.nav-group { margin: var(--s4) 0 var(--s1); padding: 0 10px; font: 600 10.5px var(--f-body); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
nav button.step-done i { background: var(--jade-soft); color: var(--jade); }
.section-label { display: flex; align-items: center; gap: var(--s3); margin: var(--s6) 0 var(--s4); font: 600 12px var(--f-body); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.section-label::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.journey { padding: var(--s6); background:
  radial-gradient(120% 80% at 100% 0%, var(--seal-soft) 0, transparent 55%), var(--paper-2); }
.journey-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s5); margin-bottom: var(--s5); }
.journey-head h2 { font-size: 24px; margin-bottom: var(--s1); }
.journey-head p.muted { margin: 0; }
.journey-head .btn { flex: none; min-height: 48px; padding: 0 var(--s6); font-size: 15px; }

.journey-map { position: relative; max-width: 680px; margin: 0 auto; }
.jn-road { position: absolute; left: 50%; top: 0; width: 120px; height: 100%; transform: translateX(-50%); overflow: visible; }
.jn-road path { fill: none; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.road-bg { stroke: var(--line-2); stroke-width: 3; stroke-dasharray: 2 7; }
.road-fg { stroke: var(--seal); stroke-width: 4; stroke-dasharray: 100; stroke-dashoffset: 100; animation: roadDraw 1.4s .3s cubic-bezier(.5,0,.2,1) forwards; }
@keyframes roadDraw { to { stroke-dashoffset: calc(100 - var(--p)); } }

.jn-list { list-style: none; margin: 0; padding: 0; position: relative; display: grid; gap: var(--s3); }
.jn { display: grid; grid-template-columns: 1fr 72px 1fr; align-items: center; gap: var(--s4); min-height: 84px;
  opacity: 0; animation: jnIn .5s cubic-bezier(.2,.8,.2,1) forwards; animation-delay: calc(.35s + var(--i) * .16s); }
@keyframes jnIn { from { opacity: 0; transform: translateY(12px) scale(.96); } to { opacity: 1; transform: none; } }
.jn-node { grid-column: 2; justify-self: center; width: 64px; height: 64px; border-radius: 50%; border: 0; padding: 0; cursor: pointer;
  background: var(--paper-2); box-shadow: 0 0 0 3px var(--line-2), var(--shadow); display: grid; place-items: center; transition: transform .2s, box-shadow .2s; }
.jn-node:hover { transform: scale(1.08); }
.jn-seal { font: 600 26px var(--f-hz); color: var(--muted); }
.jn-txt { display: flex; flex-direction: column; gap: 2px; }
.jn.l .jn-txt { grid-column: 3; grid-row: 1; }
.jn.r .jn-txt { grid-column: 1; grid-row: 1; text-align: right; }
.jn-step { font: 600 11px var(--f-body); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.jn-txt b { font-size: 16px; }
.jn.done .jn-node { background: var(--jade); box-shadow: 0 0 0 3px var(--jade-soft), var(--shadow); }
.jn.done .jn-seal { color: #fff; font-family: var(--f-body); font-weight: 700; }
.jn.done .jn-txt b { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--jade); }
.jn.now .jn-node { width: 76px; height: 76px; background: var(--seal); box-shadow: 0 0 0 6px var(--seal-soft), 0 10px 24px -8px var(--seal); animation: nodePulse 2.4s ease-in-out infinite; }
.jn.now .jn-seal { color: #fff; font-size: 32px; }
.jn.now .jn-step { color: var(--seal); }
.jn.now .jn-txt b { font-size: 18px; }
@keyframes nodePulse { 0%, 100% { box-shadow: 0 0 0 6px var(--seal-soft), 0 10px 24px -8px var(--seal); } 50% { box-shadow: 0 0 0 14px transparent, 0 10px 24px -8px var(--seal); } }

/* thanh lộ trình mini trên đầu mỗi trang hoạt động */
.jbar { display: flex; align-items: center; justify-content: center; gap: 0; margin: 0 auto var(--s5); max-width: var(--focus-w); }
.jb { display: flex; flex-direction: column; align-items: center; gap: 4px; border: 0; background: none; cursor: pointer; padding: 0; color: var(--muted); min-width: 0; }
.jb span { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font: 500 14px var(--f-hz); background: var(--paper-2); box-shadow: 0 0 0 2px var(--line-2); transition: transform .2s; }
.jb em { font: 500 11px var(--f-body); font-style: normal; white-space: nowrap; max-width: 92px; overflow: hidden; text-overflow: ellipsis; }
.jb:hover span { transform: scale(1.1); }
.jb.done span { background: var(--jade); color: #fff; box-shadow: 0 0 0 2px var(--jade-soft); font-family: var(--f-body); font-weight: 700; }
.jb.here span { background: var(--seal); color: #fff; box-shadow: 0 0 0 4px var(--seal-soft); transform: scale(1.12); }
.jb.here em { color: var(--seal); font-weight: 600; }
.jb-line { flex: 1; height: 2px; min-width: 12px; margin: 0 4px 18px; background: repeating-linear-gradient(90deg, var(--line-2) 0 4px, transparent 4px 8px); }
.next-step { min-height: 48px !important; padding: 0 var(--s5) !important; animation: nextIn .5s .2s cubic-bezier(.2,1.4,.4,1) both; }
.next-step span { font-family: var(--f-hz); }
@keyframes nextIn { from { opacity: 0; transform: translateY(10px) scale(.95); } }
#toneNext { margin-top: var(--s4); }

/* hiện dần khi cuộn */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity .6s ease, transform .6s cubic-bezier(.2,.8,.2,1); }
.reveal.in { opacity: 1; transform: none; }

/* chuyển trang có hướng (View Transitions) */
::view-transition-old(root) { animation: vtOut .28s cubic-bezier(.4,0,1,1) both; }
::view-transition-new(root) { animation: vtIn .42s cubic-bezier(0,0,.2,1) both; }
@keyframes vtOut { to { opacity: 0; transform: translateX(var(--vt-out, -28px)); } }
@keyframes vtIn { from { opacity: 0; transform: translateX(var(--vt-in, 36px)); } }
:root[data-dir="back"] { --vt-out: 28px; --vt-in: -36px; }
.side { view-transition-name: sidebar; }
::view-transition-old(sidebar), ::view-transition-new(sidebar) { animation: none; }
.tab.active { animation: none; }

@media (max-width: 820px) {
  .nav-group { display: none; }
  .journey { padding: var(--s5) var(--s4); }
  .journey-head { flex-direction: column; }
  .journey-head .btn { width: 100%; }
  .jn { grid-template-columns: 64px 1fr; }
  .jn-node, .jn.now .jn-node { grid-column: 1; }
  .jn.l .jn-txt, .jn.r .jn-txt { grid-column: 2; text-align: left; }
  .jn-road { left: 32px; width: 40px; }
  .jb em { display: none; }
}
@media (prefers-reduced-motion: reduce) { .jn { opacity: 1; } .road-fg { stroke-dashoffset: calc(100 - var(--p)); } .reveal { opacity: 1; transform: none; } }

/* =====================================================================
   Luyện viết · Apple Pencil
   ===================================================================== */
.write-pad { width: min(340px, 82vw); -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: none; }
.write-pad svg { display: block; }
/* iPad / màn hình cảm ứng lớn: khung viết to, dễ đặt bút */
@media (pointer: coarse) and (min-width: 700px), (any-pointer: fine) and (min-width: 700px) and (hover: none) {
  .write-pad { width: min(520px, 62vh, 86vw); }
  #write .card-wrap { max-width: 640px; }
}
@media (pointer: coarse) { button, .btn, .ghost, select, input { touch-action: manipulation; } }
.free-wrap { display: flex; flex-direction: column; align-items: center; gap: var(--s3); }
.free-wrap[hidden], .write-pad[hidden], #writeHint[hidden] { display: none !important; }
.free-pad { position: relative; overflow: hidden; }
.free-pad canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.free-model { position: absolute; inset: 0; display: grid; place-items: center; font: 400 calc(var(--pad, 340px) * .78)/1 var(--f-hz); color: var(--seal); opacity: 0; transition: opacity .35s; pointer-events: none; }
.free-pad { --pad: min(340px, 82vw); }
@media (pointer: coarse) and (min-width: 700px) { .free-pad { --pad: min(520px, 62vh, 86vw); } }
.free-model.faint { opacity: .08; color: var(--ink); }
.free-model.show { opacity: .32; color: var(--seal); }
/* nút gạt chế độ */
.seg { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--paper); }
.seg button { border: 0; background: none; color: var(--ink-2); font: 500 13px var(--f-body); padding: 0 var(--s3); min-height: 34px; border-radius: 9px; cursor: pointer; transition: background .2s, color .2s; }
.seg button.on { background: var(--ink); color: var(--paper); }
#write .toolbar { row-gap: var(--s2); }

/* thanh điều khiển âm thanh nổi */
.player { position: fixed; z-index: 50; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translate(-50%, 16px); opacity: 0;
  display: flex; align-items: center; gap: var(--s2); padding: 6px 6px 6px 14px; border-radius: 999px;
  background: var(--ink); color: var(--paper); box-shadow: 0 12px 30px -10px rgba(0,0,0,.5); transition: opacity .2s, transform .25s cubic-bezier(.2,.8,.2,1); }
.player.on { opacity: 1; transform: translate(-50%, 0); }
.player[hidden] { display: none; }
.pl-label { font: 500 13px var(--f-body); min-width: 72px; }
.pl-btn { width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer; font-size: 15px; background: rgba(255,255,255,.12); color: inherit; display: grid; place-items: center; transition: background .15s, transform .1s; }
.pl-btn:hover { background: rgba(255,255,255,.22); } .pl-btn:active { transform: scale(.92); }
.pl-stop { background: var(--seal); color: #fff; } .pl-stop:hover { background: var(--seal); filter: brightness(1.1); }
.pl-wave { display: inline-flex; gap: 2px; align-items: flex-end; height: 14px; }
.pl-wave i { width: 3px; background: var(--seal); border-radius: 2px; animation: wave .9s ease-in-out infinite; }
.pl-wave i:nth-child(2) { animation-delay: .15s; } .pl-wave i:nth-child(3) { animation-delay: .3s; } .pl-wave i:nth-child(4) { animation-delay: .45s; }
.player.paused .pl-wave i { animation-play-state: paused; opacity: .5; }
@keyframes wave { 0%, 100% { height: 4px; } 50% { height: 14px; } }

.account{font-size:13px;padding:8px 12px;line-height:1.6}
.account a{color:inherit}
