/* Học tiếng Trung — giao diện tối giản: nền trắng ngà, xanh ngọc nhạt, một màu nhấn xanh đậm. */
:root {
  --bg: #fbf8f1;
  --surface: #fffdf8;
  --surface-2: #f4f0e6;
  --jade: #e3f1ec;
  --jade-2: #cfe5dc;
  --ink: #1c2925;
  --muted: #5b6863;
  --line: #e2dccf;
  --accent: #0b5d4b;
  --accent-hover: #084a3c;
  --accent-ink: #fffdf7;
  --accent-soft: #dcefe8;
  --grid: rgba(11, 93, 75, .16);
  --ok: #1d7347;
  --ok-soft: #e1f2e7;
  --bad: #a83f2e;
  --bad-soft: #f8e5e0;
  --warn: #8a5d0c;
  --warn-soft: #f8eedb;
  --shadow: 0 1px 2px rgba(28, 41, 37, .06), 0 4px 16px rgba(28, 41, 37, .05);
  --radius: 14px;
  --radius-sm: 10px;
  --font-vi: "Times New Roman", Times, "Liberation Serif", "Nimbus Roman", serif;
  --font-zh: "Noto Serif SC", "Noto Serif CJK SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", "Songti TC", serif;
  --tabbar-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111916;
    --surface: #18221e;
    --surface-2: #1e2a25;
    --jade: #1c2b26;
    --jade-2: #24382f;
    --ink: #e8eeea;
    --muted: #a0b0a9;
    --line: #2b3a34;
    --accent: #5fc4a5;
    --accent-hover: #7dd3b8;
    --accent-ink: #0c1512;
    --accent-soft: #1f3a31;
    --grid: rgba(95, 196, 165, .18);
    --ok: #6fcf97;
    --ok-soft: #1d3326;
    --bad: #f08c78;
    --bad-soft: #3a2420;
    --warn: #e7b65a;
    --warn-soft: #362c18;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font-vi); font-size: 18px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.zh { font-family: var(--font-zh); font-weight: 500; letter-spacing: .02em; }
.py { font-family: var(--font-vi); color: var(--muted); }
.vi { color: var(--ink); }
.muted { color: var(--muted); }
.small { font-size: 15px; }
.tiny { font-size: 13.5px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hidden { display: none !important; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .4em; font-weight: 700; }
h1 { font-size: 26px; } h2 { font-size: 22px; } h3 { font-size: 19px; }
p { margin: 0 0 .7em; }
ul { margin: 0; padding-left: 1.2em; }
li { margin: .25em 0; }

/* ---------- Khung app ---------- */
.app-header {
  position: sticky; top: 0; z-index: 20; background: var(--bg); background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(1.2) blur(8px); -webkit-backdrop-filter: saturate(1.2) blur(8px);
  border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top);
}
.header-inner { max-width: 1000px; margin: 0 auto; display: flex; align-items: center; gap: 12px; padding: 10px 16px; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; min-width: 0; }
.brand-logo { width: 36px; height: 36px; flex: none; }
.brand-name { font-weight: 700; font-size: 20px; white-space: nowrap; }
.brand-sub { font-size: 13.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-nav { display: none; margin-left: auto; gap: 4px; }
.top-nav button { border: 0; background: none; padding: 10px 14px; border-radius: 999px; cursor: pointer; min-height: 44px; color: var(--muted); font-size: 17px; }
.top-nav button[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.top-nav button:hover { color: var(--ink); }
.icon-btn {
  border: 1px solid var(--line); background: var(--surface); width: 44px; height: 44px; border-radius: 12px;
  display: inline-grid; place-items: center; cursor: pointer; flex: none; color: var(--ink);
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.icon-btn svg, .btn svg, .tab svg { width: 22px; height: 22px; }
.header-inner .icon-btn { margin-left: auto; }
main { max-width: 900px; margin: 0 auto; padding: 18px 16px calc(var(--tabbar-h) + 28px + env(safe-area-inset-bottom)); }
.view { animation: fade .18s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.app-footer { text-align: center; color: var(--muted); font-size: 14px; padding: 24px 0 4px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tab { border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: var(--tabbar-h); cursor: pointer; color: var(--muted); font-size: 13.5px; }
.tab[aria-current="page"] { color: var(--accent); font-weight: 700; }
.tab[aria-current="page"] svg { stroke-width: 2.2; }

@media (min-width: 860px) {
  .top-nav { display: flex; }
  .header-inner .icon-btn { margin-left: 8px; }
  .tabbar { display: none; }
  main { padding-bottom: 40px; }
}

/* ---------- Thành phần ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card + .card, .stack > * + * { margin-top: 14px; }
.card-jade { background: var(--jade); border-color: var(--jade-2); box-shadow: none; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 26px 0 10px; }
.section-title h2 { margin: 0; font-size: 20px; }
.eyebrow { font-size: 14px; color: var(--muted); letter-spacing: .02em; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.grow { flex: 1; min-width: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 10px 20px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 17px;
  text-decoration: none; color: var(--ink); -webkit-tap-highlight-color: transparent;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
.btn-quiet { border-color: transparent; background: transparent; color: var(--accent); }
.btn-quiet:hover { background: var(--accent-soft); border-color: transparent; }
.btn-danger { color: var(--bad); }
.btn-danger:hover { border-color: var(--bad); }
.btn-block { width: 100%; }
.btn-lg { min-height: 56px; font-size: 19px; padding: 12px 26px; }
.btn-sm { min-height: 44px; padding: 6px 14px; font-size: 16px; }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 14px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.chip-accent { background: var(--accent-soft); color: var(--accent); }
.chip-ok { background: var(--ok-soft); color: var(--ok); }
.chip-warn { background: var(--warn-soft); color: var(--warn); }

.seg { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 4px; flex-wrap: wrap; }
.seg button { border: 0; background: none; min-height: 40px; min-width: 44px; padding: 6px 14px; border-radius: 9px; cursor: pointer; color: var(--muted); font-size: 16px; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--accent); font-weight: 700; box-shadow: var(--shadow); }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 48px; cursor: pointer; }
.switch input { appearance: none; -webkit-appearance: none; width: 50px; height: 30px; border-radius: 999px; background: var(--line); position: relative; cursor: pointer; flex: none; transition: background .15s; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(20px); }

.notice { border-radius: var(--radius-sm); padding: 12px 14px; background: var(--warn-soft); color: var(--warn); font-size: 16px; }
.notice-info { background: var(--jade); color: var(--ink); }
.notice a { color: inherit; font-weight: 700; }

.empty { text-align: center; color: var(--muted); padding: 30px 12px; }
.empty .zh { font-size: 40px; color: var(--accent); display: block; margin-bottom: 6px; opacity: .8; }

input[type="search"], input[type="text"], select {
  width: 100%; min-height: 48px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; background: var(--surface);
}
input:focus, select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- Hôm nay ---------- */
.hero { padding: 22px; }
.hero h1 { font-size: 24px; margin-bottom: 4px; }
.plan-list { list-style: none; padding: 0; margin: 14px 0 18px; }
.plan-list li { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px dashed var(--jade-2); margin: 0; }
.plan-list li:first-child { border-top: 0; }
.plan-dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); color: var(--accent); flex: none; font-size: 14px; font-weight: 700; border: 1.5px solid var(--accent); }
.plan-list li.done .plan-dot { background: var(--accent); color: var(--accent-ink); }
.plan-list li.done .plan-text { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--jade-2); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; text-align: center; }
.stat b { display: block; font-size: 26px; line-height: 1.2; color: var(--accent); }
.stat span { font-size: 14px; color: var(--muted); }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end; height: 120px; padding-top: 6px; }
.week-col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.week-bar { width: 100%; max-width: 32px; border-radius: 6px 6px 3px 3px; background: var(--accent); min-height: 3px; }
.week-bar.zero { background: var(--line); }
.week-col small { font-size: 12.5px; color: var(--muted); }
.week-col .v { font-size: 12.5px; color: var(--ink); }
.goal-line { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.goal-line > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.phase-track { display: flex; gap: 6px; margin-top: 10px; }
.phase-track span { flex: 1; height: 6px; border-radius: 99px; background: var(--line); }
.phase-track span.on { background: var(--accent); }

/* ---------- Lộ trình ---------- */
.unit { margin-top: 22px; }
.unit h3 { font-size: 16px; color: var(--muted); font-weight: 400; letter-spacing: .03em; margin-bottom: 8px; }
.lesson-row {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; padding: 12px 14px; min-height: 64px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; margin-top: 8px;
}
.lesson-row:hover { border-color: var(--accent); }
.lesson-no { width: 40px; height: 40px; flex: none; border-radius: 10px; display: grid; place-items: center; font-weight: 700; background: var(--surface-2); color: var(--muted); }
.lesson-row.done .lesson-no { background: var(--accent); color: var(--accent-ink); }
.lesson-row.active .lesson-no { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1.5px var(--accent); }
.lesson-title { font-size: 17.5px; line-height: 1.3; }
.lesson-meta { font-size: 14px; color: var(--muted); }

/* ---------- Chữ Hán, ô chữ 米 ---------- */
.mi-word { display: inline-flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.mi {
  --s: 84px; width: var(--s); height: var(--s); display: grid; place-items: center; position: relative;
  border: 1.5px solid var(--grid); border-radius: 6px; background-color: var(--surface);
  background-image:
    linear-gradient(to right, transparent calc(50% - .5px), var(--grid) calc(50% - .5px), var(--grid) calc(50% + .5px), transparent calc(50% + .5px)),
    linear-gradient(to bottom, transparent calc(50% - .5px), var(--grid) calc(50% - .5px), var(--grid) calc(50% + .5px), transparent calc(50% + .5px)),
    linear-gradient(45deg, transparent calc(50% - .6px), var(--grid) calc(50% - .6px), var(--grid) calc(50% + .6px), transparent calc(50% + .6px)),
    linear-gradient(-45deg, transparent calc(50% - .6px), var(--grid) calc(50% - .6px), var(--grid) calc(50% + .6px), transparent calc(50% + .6px));
  font-family: var(--font-zh); font-size: calc(var(--s) * .62); line-height: 1; color: var(--ink);
}
.mi-sm { --s: 58px; }
.word-face { text-align: center; padding: 8px 0; }
.word-face .py-big { font-size: 24px; color: var(--accent); margin-bottom: 10px; letter-spacing: .02em; }
.word-face .vi-big { font-size: 21px; margin-top: 12px; }
.spoken { display: inline-block; margin-top: 4px; font-size: 15px; color: var(--warn); background: var(--warn-soft); padding: 2px 10px; border-radius: 99px; }
.sent { padding: 10px 0; border-top: 1px solid var(--line); }
.sent:first-child { border-top: 0; }
.sent .zh { font-size: 26px; line-height: 1.45; display: block; }
.sent .py { font-size: 16.5px; display: block; }
.sent .vi { font-size: 16.5px; display: block; color: var(--muted); }
.sent-main { display: flex; gap: 10px; align-items: flex-start; }
.sent-main .grow { min-width: 0; }
.hide-py .py.optional { display: none; }

.speak-btn { border: 1px solid var(--line); background: var(--surface); width: 44px; height: 44px; border-radius: 50%; display: inline-grid; place-items: center; cursor: pointer; color: var(--accent); flex: none; }
.speak-btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.speak-btn.playing { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.speak-btn svg { width: 20px; height: 20px; }
.add-btn { border: 1px solid var(--line); background: var(--surface); min-height: 44px; min-width: 44px; padding: 0 10px; border-radius: 22px; cursor: pointer; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; font-size: 14px; flex: none; }
.add-btn svg { width: 18px; height: 18px; }
.add-btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-soft); }
.voice-tag { font-size: 12.5px; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; }

.pattern { font-size: 19px; background: var(--jade); border-radius: var(--radius-sm); padding: 12px 14px; margin: 8px 0 12px; border-left: 4px solid var(--accent); }
.pattern .zh { font-size: 21px; }
.points li { margin: .4em 0; }
.mistakes li::marker { content: "✗  "; color: var(--bad); }

/* ---------- Hội thoại ---------- */
.dialog { display: flex; flex-direction: column; gap: 12px; }
.bubble-row { display: flex; gap: 10px; align-items: flex-end; }
.bubble-row.b { flex-direction: row-reverse; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); flex: none; font-weight: 700; font-size: 15px; }
.bubble-row.b .avatar { background: var(--accent-soft); color: var(--accent); }
.bubble { background: var(--surface); border: 1px solid var(--line); border-radius: 16px 16px 16px 4px; padding: 10px 14px; max-width: 82%; min-width: 0; }
.bubble-row.b .bubble { border-radius: 16px 16px 4px 16px; background: var(--jade); border-color: var(--jade-2); }
.bubble .zh { font-size: 23px; display: block; line-height: 1.45; }
.bubble .py, .bubble .vi { font-size: 15.5px; display: block; }
.bubble .vi { color: var(--muted); }
.bubble.veiled .zh, .bubble.veiled .py, .bubble.veiled .vi { filter: blur(7px); user-select: none; }
.bubble-tools { display: flex; gap: 6px; margin-top: 6px; align-items: center; flex-wrap: wrap; }

/* ---------- Phiên học (chế độ tập trung) ---------- */
.focus { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: flex; flex-direction: column; }
.focus-top { border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top); background: var(--bg); }
.focus-top-inner { max-width: 760px; margin: 0 auto; display: flex; align-items: center; gap: 10px; padding: 8px 16px; min-height: 60px; }
.steps { display: flex; gap: 6px; flex: 1; min-width: 0; overflow: hidden; }
.step { flex: 1; min-width: 0; }
.step i { display: block; height: 6px; border-radius: 99px; background: var(--line); }
.step.on i { background: var(--accent); opacity: .45; }
.step.cur i { background: var(--accent); opacity: 1; }
.step span { display: block; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 3px; }
.step.cur span { color: var(--accent); font-weight: 700; }
.timer { font-size: 14.5px; color: var(--muted); white-space: nowrap; padding: 4px 10px; border-radius: 99px; background: var(--surface-2); }
.timer.over { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.focus-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.focus-body-inner { max-width: 760px; margin: 0 auto; padding: 20px 16px 28px; }
.focus-actions { border-top: 1px solid var(--line); background: var(--bg); padding-bottom: env(safe-area-inset-bottom); }
.focus-actions-inner { max-width: 760px; margin: 0 auto; padding: 12px 16px; display: flex; gap: 10px; }
.focus-actions-inner > .btn { flex: 1; }
.counter { font-size: 14.5px; color: var(--muted); margin-bottom: 8px; }
.prompt { font-size: 15px; color: var(--muted); text-align: center; margin-top: 4px; }
.flash { text-align: center; padding: 18px 8px 8px; }
.flash .zh-sent { font-family: var(--font-zh); font-size: 32px; line-height: 1.45; }
.flash .vi-front { font-size: 26px; line-height: 1.35; }
.reveal { margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--line); }
.rates { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; width: 100%; }
.rate { border: 1px solid var(--line); background: var(--surface); border-radius: 12px; min-height: 60px; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 6px 4px; font-size: 16px; line-height: 1.2; }
.rate small { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.rate:hover { border-color: var(--accent); }
.rate.again { color: var(--bad); }
.rate.good { border-color: var(--accent); color: var(--accent); font-weight: 700; }
kbd { font-family: var(--font-vi); font-size: 12px; border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; color: var(--muted); }

.banner { margin-bottom: 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: space-between; }

/* ---------- Bài tập ---------- */
.ex-q { font-size: 19px; margin-bottom: 14px; }
.ex-zh { font-family: var(--font-zh); font-size: 30px; line-height: 1.5; text-align: center; margin: 6px 0 14px; }
.opts { display: grid; gap: 10px; }
.opt { text-align: left; border: 1.5px solid var(--line); background: var(--surface); border-radius: 12px; padding: 12px 16px; min-height: 56px; cursor: pointer; font-size: 18px; display: flex; align-items: center; gap: 12px; }
.opt:hover:not(:disabled) { border-color: var(--accent); }
.opt .key { width: 26px; height: 26px; border-radius: 7px; background: var(--surface-2); display: grid; place-items: center; font-size: 13px; color: var(--muted); flex: none; }
.opt.has-zh .txt { font-family: var(--font-zh); font-size: 23px; }
.opt.correct { border-color: var(--ok); background: var(--ok-soft); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt:disabled { cursor: default; }
.listen-box { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 6px 0 18px; }
.listen-big { width: 84px; height: 84px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; cursor: pointer; }
.listen-big svg { width: 38px; height: 38px; }
.tray { min-height: 70px; border: 1.5px dashed var(--jade-2); border-radius: 12px; padding: 10px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; background: var(--jade); }
.tray.empty-tray::before { content: attr(data-hint); color: var(--muted); font-size: 15px; padding: 0 6px; }
.bank { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; min-height: 56px; }
.tok { border: 1.5px solid var(--line); background: var(--surface); border-radius: 10px; min-height: 52px; min-width: 52px; padding: 4px 14px; cursor: pointer; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.15; }
.tok .zh { font-size: 24px; }
.tok .py { font-size: 12.5px; }
.tok:hover { border-color: var(--accent); }
.tray .tok { background: var(--surface); }
.fill-row { display: flex; gap: 8px; margin-top: 12px; }
.fill-row input { flex: 1; font-size: 20px; }
.feedback { border-radius: 12px; padding: 14px 16px; margin-top: 16px; }
.feedback.ok { background: var(--ok-soft); }
.feedback.bad { background: var(--bad-soft); }
.feedback.near { background: var(--warn-soft); }
.feedback h3 { margin-bottom: 4px; font-size: 18px; }
.feedback.ok h3 { color: var(--ok); }
.feedback.bad h3 { color: var(--bad); }
.feedback.near h3 { color: var(--warn); }
.feedback .zh { font-size: 21px; }
.checklist { list-style: none; padding: 0; }
.checklist label { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; min-height: 44px; cursor: pointer; border-top: 1px solid var(--line); }
.checklist li:first-child label { border-top: 0; }
.checklist input { width: 22px; height: 22px; margin-top: 3px; accent-color: var(--accent); flex: none; }

/* ---------- Hình minh họa ---------- */
.tone-svg { width: 100%; max-width: 520px; height: auto; display: block; margin: 0 auto; }
.tone-svg text { font-family: var(--font-vi); fill: var(--muted); font-size: 13px; }
.tone-svg .lvl { stroke: var(--line); stroke-width: 1; }
.tone-svg .curve { fill: none; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.tone-keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px; }
.tone-key { border: 1.5px solid var(--line); background: var(--surface); border-radius: 12px; padding: 8px 4px; cursor: pointer; text-align: center; min-height: 64px; }
.tone-key .zh { font-size: 26px; display: block; line-height: 1.2; }
.tone-key:hover { border-color: var(--accent); }
.tbl { width: 100%; border-collapse: collapse; font-size: 16px; }
.tbl th, .tbl td { border-bottom: 1px solid var(--line); padding: 8px 6px; text-align: left; vertical-align: top; }
.tbl th { font-weight: 700; color: var(--muted); font-size: 14.5px; }
.ini-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.ini { border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 8px 10px; cursor: pointer; text-align: left; min-height: 64px; display: flex; gap: 10px; align-items: center; }
.ini:hover { border-color: var(--accent); }
.ini b { font-size: 22px; color: var(--accent); min-width: 34px; }
.ini .zh { font-size: 22px; }
.ini small { display: block; color: var(--muted); font-size: 13px; line-height: 1.3; }
.group-label { font-size: 14px; color: var(--muted); margin: 14px 0 6px; }
.finals { display: flex; flex-wrap: wrap; gap: 6px; }
.finals span { background: var(--surface-2); border-radius: 8px; padding: 2px 10px; font-size: 17px; }
.num-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; }
.num { border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 8px 4px; cursor: pointer; text-align: center; min-height: 80px; }
.num b { display: block; font-size: 14px; color: var(--muted); }
.num .zh { font-size: 28px; display: block; line-height: 1.2; }
.num .py { font-size: 14px; }
.num:hover { border-color: var(--accent); }

/* ---------- Sổ tay, tài liệu ---------- */
.search-bar { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 640px) { .search-bar { grid-template-columns: 1fr 240px; } }
.note-row { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.note-row:first-child { border-top: 0; }
.note-row .zh { font-size: 25px; line-height: 1.3; }
.note-row .py { font-size: 15.5px; }
.note-row .vi { font-size: 16px; }
.note-row .meta { font-size: 13.5px; color: var(--muted); }
.res { display: block; }
.res h3 { margin-bottom: 2px; }
.res dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 10px 0 12px; font-size: 16px; }
.res dt { color: var(--muted); }
.res dd { margin: 0; }
.ext::after { content: " ↗"; }

/* ---------- Hộp thoại, thông báo ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(10, 20, 16, .42); z-index: 80; display: flex; align-items: flex-end; justify-content: center; animation: fadeIn .15s; }
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  background: var(--bg); width: 100%; max-width: 620px; max-height: 92vh; overflow-y: auto; border-radius: 18px 18px 0 0;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); box-shadow: 0 -8px 30px rgba(0,0,0,.15);
}
@media (min-width: 700px) { .modal-back { align-items: center; } .modal { border-radius: 18px; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.modal-head h2 { margin: 0; }
.set-group { border-top: 1px solid var(--line); padding: 14px 0; }
.set-group:first-of-type { border-top: 0; }
.set-group > .label { font-weight: 700; margin-bottom: 8px; display: block; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + 18px + env(safe-area-inset-bottom)); z-index: 90; background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 12px; font-size: 16px; max-width: calc(100% - 32px); box-shadow: 0 6px 24px rgba(0,0,0,.2); animation: fade .2s; }
@media (min-width: 860px) { .toast { bottom: 28px; } }

.onboard { max-width: 560px; margin: 0 auto; text-align: center; padding-top: 12px; }
.onboard .logo-lg { width: 88px; height: 88px; margin: 0 auto 10px; display: block; }
.choice-cards { display: grid; gap: 10px; text-align: left; margin: 10px 0 18px; }
.choice-card { border: 1.5px solid var(--line); background: var(--surface); border-radius: 14px; padding: 12px 16px; cursor: pointer; min-height: 56px; display: flex; gap: 12px; align-items: center; text-align: left; }
.choice-card > span { display: block; }
.choice-card[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.choice-card b { display: block; }
.choice-card small { color: var(--muted); font-size: 14.5px; }
.minutes-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 10px 0 18px; }
.minutes-pick button { border: 1.5px solid var(--line); background: var(--surface); border-radius: 14px; min-height: 76px; cursor: pointer; }
.minutes-pick button b { display: block; font-size: 26px; color: var(--accent); }
.minutes-pick button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }

@media (max-width: 420px) {
  body { font-size: 17.5px; }
  .mi { --s: 72px; }
  .mi-sm { --s: 50px; }
  .rate { font-size: 15px; }
  .step span { display: none; }
  .stat b { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print {
  .app-header, .tabbar, .focus-actions { display: none; }
}
.r-hide-py .py { display: none; }
.r-hide-vi .vi { display: none; }
@media (hover: none) { kbd { display: none; } }
.note-row .nr-zh { font-size: 26px; line-height: 1.3; min-width: 4.4em; flex: none; }
.note-row.is-sent { flex-wrap: wrap; }
.note-row.is-sent .nr-zh { min-width: 0; flex: 1 1 100%; font-size: 22px; }
@media (max-width: 420px) { .note-row .nr-zh { min-width: 3.4em; font-size: 24px; } }

/* ---------- Luyện viết ---------- */
.mi-pad { touch-action: none; cursor: crosshair; border-radius: 10px; margin: 6px auto 0; -webkit-user-select: none; user-select: none; }
.mi-pad svg { display: block; }
.w-practice { text-align: center; }
.w-head { display: flex; align-items: center; justify-content: center; gap: 14px; }
.w-py { font-size: 24px; color: var(--accent); line-height: 1.2; }
.w-vi { font-size: 18px; }
.w-stages { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin: 12px 0 4px; }
.w-msg { min-height: 1.5em; margin: 10px 0 6px; font-size: 16px; color: var(--muted); }
.w-tools { justify-content: center; }
.w-note { margin: 12px 0 0; text-align: left; border-top: 1px dashed var(--line); padding-top: 10px; }
.w-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.w-card { display: flex; gap: 12px; align-items: center; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 8px 12px 8px 8px; font-size: 16px; text-align: left; }
.w-mini { border: 0; background: none; padding: 0; cursor: pointer; flex: none; border-radius: 8px; }
.w-mini .mi-pad { margin: 0; cursor: pointer; }
.w-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.w-tile { border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 10px 6px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 44px; }
.w-tile:hover, .w-card:hover { border-color: var(--accent); }
.w-tile .py { font-size: 15px; }
button.nr-zh { border: 0; background: none; padding: 0; text-align: left; cursor: pointer; color: inherit; border-radius: 6px; }
button.nr-zh:hover { color: var(--accent); }
