/* VM CHINESE — giao diện tối kiểu bảng chỉ số của VM STUDY (refrag): thanh bên trái, khung tối, nút đỏ. */
:root {
  --bg: #0c0d10; --bg2: #101116; --surface: #14151a; --surface2: #1c1d24; --surface3: #262830;
  --line: #262830; --ink: #eceef3; --muted: #8d909d; --gold0: #f5b84a;
  /* MỘT màu chủ đạo: base.html ghi đè --acc / --acc-ink theo màu người dùng chọn; mọi màu nhấn khác suy ra từ nó */
  --acc: #e3132b; --acc-ink: #fff;
  --red: var(--acc); --red2: color-mix(in srgb, var(--acc) 62%, #fff); --accent: var(--acc); --gold: color-mix(in srgb, var(--acc) 42%, #fff);
  --acc-bg: color-mix(in srgb, var(--acc) 17%, var(--surface)); --acc-bg2: color-mix(in srgb, var(--acc) 10%, var(--bg));
  --acc-line: color-mix(in srgb, var(--acc) 40%, var(--surface)); --acc-soft: color-mix(in srgb, var(--acc) 22%, transparent);
  --ok: #3ccf8e; --warn: var(--gold0); --bad: #ff5d5d; --t1: #4aa3ff; --t2: #3ccf8e; --t3: var(--gold0); --t4: #ff5d5d; --t5: #9b9daa;
  --side: 236px; --radius: 12px;
  --font: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --han: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", "Heiti TC", sans-serif;
  --kai: "BiauKai", "DFKai-SB", "TW-Kai", "Kaiti TC", "STKaiti", "Noto Serif TC", var(--han);
  --sab: env(safe-area-inset-bottom, 0px); --sat: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { overflow-x: clip; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.55 var(--font); }
a { color: inherit; }
h1 { font-size: 26px; line-height: 1.2; margin: 0 0 6px; font-weight: 800; letter-spacing: -.01em; }
h2 { font-size: 18px; margin: 0 0 12px; font-weight: 700; }
h3 { margin: 0 0 8px; font-size: 15.5px; font-weight: 700; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .ok { color: var(--ok); } .warn { color: var(--warn); } .bad { color: var(--bad); }
.row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.sp { flex: 1; }
.han { font-family: var(--han); }
.ico { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- thanh bên ---------- */
.side { position: fixed; inset: 0 auto 0 0; width: var(--side); background: #0f1014; border-right: 1px solid var(--line); z-index: 50;
  display: flex; flex-direction: column; padding: calc(14px + var(--sat)) 12px 14px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; padding: 4px 6px 14px; }
.brand-mark { width: 40px; height: 40px; border-radius: 11px; background: var(--red); display: grid; place-items: center; font: 800 24px var(--kai); color: var(--acc-ink); }
.brand b { display: block; font-size: 16px; letter-spacing: .03em; }
.brand small { display: block; color: var(--muted); font-size: 11.5px; }
.acct { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line);
  text-decoration: none; margin-bottom: 12px; }
.acct .av { width: 32px; height: 32px; border-radius: 50%; background: var(--surface3); display: grid; place-items: center; font-weight: 800; color: var(--gold); }
.acct b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px; }
.acct small { color: var(--muted); font-size: 12px; }
.lv { display: inline-block; padding: 1px 7px; border-radius: 6px; background: var(--acc-bg); color: var(--red2); font-weight: 700; font-size: 11.5px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: 9px; text-decoration: none; color: #c3c5ce; font-size: 14.5px; position: relative; }
.nav a:hover { background: var(--surface); color: #fff; }
.nav a.on { background: var(--surface2); color: #fff; font-weight: 600; }
.nav a.on::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--red); }
.nav .badge { margin-left: auto; background: var(--red); color: var(--acc-ink); font-size: 11px; font-weight: 700; border-radius: 99px; padding: 0 7px; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding-top: 14px; }
.side-btns { display: flex; gap: 6px; }
.ibtn { width: 38px; height: 36px; border-radius: 9px; border: 0; background: var(--surface2); color: var(--ink); display: grid; place-items: center; cursor: pointer; text-decoration: none; }
.ibtn:hover { background: var(--surface3); }
.side-tog, .side-veil, .topm { display: none; }
main { margin-left: var(--side); padding: 26px 32px 90px; min-height: 100vh; max-width: calc(var(--side) + 1500px); }
.foot { margin-left: var(--side); padding: 18px 32px calc(26px + var(--sab)); color: var(--muted); font-size: 12.5px; border-top: 1px solid var(--line); }
.foot a { color: var(--ink); }
@media (max-width: 960px) {
  .side { transform: translateX(-100%); transition: transform .22s; box-shadow: 0 0 40px rgba(0, 0, 0, .6); }
  html.side-open .side { transform: none; }
  .side-veil { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 45; opacity: 0; pointer-events: none; transition: opacity .2s; }
  html.side-open .side-veil { opacity: 1; pointer-events: auto; }
  .topm { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 40; background: rgba(12, 13, 16, .92); -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); padding: calc(8px + var(--sat)) 14px 8px; }
  .topm .brand { padding: 0; } .topm .brand-mark { width: 32px; height: 32px; font-size: 19px; border-radius: 9px; }
  main { margin-left: 0; padding: 18px 14px 80px; }
  .foot { margin-left: 0; padding: 18px 14px calc(26px + var(--sab)); }
}

/* ---------- nút, thẻ, form ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 0; border-radius: 9px; padding: 10px 16px; background: var(--red);
  color: var(--acc-ink); font: 600 14px var(--font); text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { filter: brightness(1.1); }
.btn:disabled { opacity: .5; cursor: progress; }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn.lg { padding: 13px 22px; font-size: 15.5px; }
.btn.ghost { background: var(--surface2); color: var(--ink); }
.btn.line { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--surface3); }
.btn.teal { background: var(--accent); }
.btn.block { width: 100%; }
.btn .ico { width: 18px; height: 18px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card + .card, .mt { margin-top: 16px; }
.card.narrow { max-width: 460px; margin: 30px auto; }
.hd { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.hd p { margin: 0; }
.sec-hd { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.sec-hd h2 { margin: 0; }
.alert { background: var(--acc-bg); border: 1px solid var(--acc-line); color: color-mix(in srgb, var(--acc) 22%, #fff); padding: 10px 14px; border-radius: 9px; margin: 10px 0; }
.alert.ok { background: #102a20; border-color: #1f5a40; color: #c5f2dc; }
.alert.info { background: #121d2a; border-color: #23405f; color: #cfe3ff; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; min-width: 0; }
.field > span { font-size: 13px; color: var(--muted); }
input, select, textarea { background: var(--bg2); border: 1px solid var(--line); color: var(--ink); border-radius: 8px; padding: 9px 11px; font: 16px var(--font); min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 1px solid var(--red); border-color: var(--red); }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--red); }
.check { display: flex; align-items: center; gap: 9px; cursor: pointer; }
.check.field { flex-direction: row; flex-wrap: wrap; align-items: center; }
.check.field > input[type=checkbox] { flex: none; }
.fgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 14px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 99px; background: var(--surface2); font-size: 13px; text-decoration: none;
  color: #d4d6de; white-space: nowrap; border: 0; cursor: pointer; font-family: var(--font); }
.chip:hover { background: var(--surface3); color: #fff; }
.chip.on { background: var(--red); color: var(--acc-ink); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.seg { display: inline-flex; background: var(--surface2); border-radius: 9px; padding: 3px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; color: var(--muted); font: 600 13px var(--font); padding: 7px 12px; border-radius: 7px; cursor: pointer; }
.seg button.on { background: var(--surface3); color: var(--ink); }
.bar { height: 6px; border-radius: 9px; background: var(--surface3); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--red); border-radius: 9px; transition: width .5s; }
.bar i.ok { background: var(--ok); }
.toast { position: fixed; left: 50%; bottom: calc(24px + var(--sab)); transform: translateX(-50%); background: #22242c; border: 1px solid var(--line); color: #fff;
  padding: 10px 16px; border-radius: 10px; z-index: 90; box-shadow: 0 10px 30px rgba(0, 0, 0, .5); max-width: calc(100vw - 30px); }
.toast.bad { border-color: var(--acc-line); background: var(--acc-bg); }
.netbar { background: var(--acc-bg); color: var(--gold); padding: 6px 14px; text-align: center; font-size: 13px; margin-left: var(--side); }
@media (max-width: 960px) { .netbar { margin-left: 0; } }
.empty { text-align: center; padding: 40px 10px; color: var(--muted); }
.kbd { display: inline-block; min-width: 20px; padding: 0 5px; border-radius: 5px; background: var(--surface3); font: 600 11.5px var(--font); text-align: center; color: #c9cbd3; }

/* ---------- chữ Hán + phiên âm ---------- */
.hz { display: inline-flex; flex-direction: column; align-items: center; line-height: 1.1; margin: 0 1px; vertical-align: bottom; }
.hz .py, .hz .zy { font-size: max(11px, .36em); color: var(--gold); white-space: nowrap; font-family: var(--font); letter-spacing: .02em; min-height: 1.1em; }
.hz .zy { font-family: var(--han); }
.hz .ch { font-family: var(--han); }
.kai { font-family: var(--kai); }
.kai[data-kai] { display: inline-block; width: 1em; height: 1em; line-height: 1; }
.kai-svg { display: block; width: 1em; height: 1em; fill: currentColor; }
.hz .ch.kai[data-kai] { margin: .08em 0; }
body.phon-zhuyin .hz .py, body.phon-pinyin .hz .zy { display: none; }
.t1 { color: var(--t1) !important; } .t2 { color: var(--t2) !important; } .t3 { color: var(--t3) !important; } .t4 { color: var(--t4) !important; } .t5 { color: var(--t5) !important; }
.tone-col .hz .ch.t1 { color: var(--t1); }
.sayb { border: 0; background: var(--surface2); color: var(--ink); width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center; cursor: pointer; flex: none; }
.sayb:hover { background: var(--red); color: var(--acc-ink); }
.sayb .ico { width: 17px; height: 17px; }
.sayb.on { background: var(--red); color: var(--acc-ink); animation: pulse 1s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px var(--acc-soft); } }

/* ---------- bảng điều khiển ---------- */
.dash { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
.metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.mc { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; cursor: pointer; position: relative; text-align: left; color: inherit; font: inherit; }
.mc:hover { border-color: var(--surface3); background: #17181e; }
.mc-l { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.mc-v { font-size: 34px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; margin-top: 6px; }
.mc-v small { font-size: 14px; color: var(--muted); font-weight: 600; margin-left: 4px; }
.mc-d { font-size: 12.5px; margin-top: 2px; }
.mc-d.up { color: var(--ok); } .mc-d.down { color: var(--bad); } .mc-d.flat { color: var(--muted); }
.mc svg.spark { width: 100%; height: 44px; margin-top: 10px; display: block; }
.mc .bar { margin-top: 10px; }
.rt { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.rt-hd { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.streak { display: inline-flex; align-items: center; gap: 6px; color: var(--gold); font-weight: 800; font-size: 18px; }
.streak .ico { stroke: var(--gold); }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 8px 0 14px; text-align: center; }
.week div { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11.5px; color: var(--muted); }
.week i { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--surface3); display: grid; place-items: center; }
.week .done i { background: var(--red); border-color: var(--red); }
.week .done i::after { content: "✓"; color: var(--acc-ink); font-style: normal; font-weight: 800; font-size: 13px; }
.week .part i { border-color: var(--red); background: var(--acc-soft); }
.week .rest i { border-style: dashed; }
.week .today { color: #fff; font-weight: 700; }
.tasks { display: flex; flex-direction: column; gap: 6px; }
.task { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; background: var(--bg2); border: 1px solid var(--line); }
.task .tk { width: 24px; height: 24px; border-radius: 7px; border: 2px solid var(--surface3); background: transparent; cursor: pointer; display: grid; place-items: center; color: transparent; flex: none; padding: 0; }
.task.done .tk { background: var(--red); border-color: var(--red); color: var(--acc-ink); }
.task .tk .ico { width: 15px; height: 15px; stroke-width: 3; }
.task .tt { flex: 1; min-width: 0; }
.task .tt b { display: block; font-weight: 600; font-size: 14px; }
.task.done .tt b { color: var(--muted); text-decoration: line-through; }
.task .tt small { color: var(--muted); font-size: 12px; }
.task .go { color: var(--muted); text-decoration: none; font-size: 13px; white-space: nowrap; }
.task .go:hover { color: #fff; }
.auto { color: var(--accent); font-size: 11px; font-weight: 700; }
.lvl { display: flex; flex-direction: column; gap: 10px; }
.lvl-r { display: grid; grid-template-columns: 52px minmax(0, 1fr) 70px; gap: 10px; align-items: center; font-size: 13px; }
.lvl-r b { font-size: 13px; }
.lvl-r .muted { text-align: right; font-variant-numeric: tabular-nums; }
.wod { display: flex; align-items: center; gap: 16px; }
.wod .big { font-size: 52px; font-family: var(--han); line-height: 1.15; }
.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 13px); grid-auto-columns: 13px; justify-content: start; gap: 3px; overflow-x: auto; padding-bottom: 4px; }
.heat i { width: 13px; height: 13px; border-radius: 3px; background: var(--surface3); }
.heat i.h1 { background: var(--acc-line); } .heat i.h2 { background: color-mix(in srgb, var(--acc) 62%, var(--surface)); } .heat i.h3 { background: color-mix(in srgb, var(--acc) 82%, var(--surface)); } .heat i.h4 { background: var(--red2); }
.detail { margin-top: 14px; }
.wk-bars { display: flex; align-items: flex-end; gap: 8px; height: 120px; margin: 12px 0 6px; position: relative; }
.wk-bars div { flex: 1; background: var(--surface3); border-radius: 6px 6px 2px 2px; position: relative; min-height: 2px; }
.wk-bars div.hit { background: var(--red); }
.wk-bars div span { position: absolute; top: -18px; left: 0; right: 0; text-align: center; font-size: 11px; color: var(--muted); }
.wk-bars .tgt { position: absolute; left: 0; right: 0; border-top: 2px dashed var(--gold); height: 0; }
@media (max-width: 1180px) { .dash { grid-template-columns: 1fr; } }
@media (max-width: 560px) { .metrics { grid-template-columns: 1fr 1fr; gap: 10px; } .mc { padding: 13px; } .mc-v { font-size: 27px; } .wod .big { font-size: 42px; } }

/* ---------- từ vựng ---------- */
.lvtabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.lvtab { display: flex; flex-direction: column; gap: 3px; padding: 10px 14px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); text-decoration: none; min-width: 120px; }
.lvtab b { font-size: 15px; } .lvtab small { color: var(--muted); font-size: 12px; }
.lvtab.on { border-color: var(--red); background: var(--acc-bg2); }
.lvtab .bar { height: 4px; margin-top: 4px; }
.wgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.wc { background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: 12px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; text-align: left; color: inherit; font: inherit; position: relative; }
.wc:hover { border-color: var(--surface3); background: #17181e; }
.wc .hzw { font-size: 30px; }
.wc .vi { font-size: 13px; color: #cfd1d9; }
.wc .hv { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.wc .st { position: absolute; top: 9px; right: 9px; width: 9px; height: 9px; border-radius: 50%; }
.wc .st.known { background: var(--ok); } .wc .st.learning { background: var(--gold); }
.topic-h { margin: 22px 0 10px; display: flex; align-items: baseline; gap: 10px; }
.topic-h h3 { margin: 0; }

/* ---------- hộp thoại ---------- */
dialog.dlg { border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 40px); }
dialog.dlg::backdrop { background: rgba(0, 0, 0, .6); }
.dlg-b { padding: 20px; overflow-y: auto; max-height: calc(100vh - 60px); }
.dlg-x { position: absolute; top: 10px; right: 10px; }
.wd-big { font-size: 64px; text-align: center; margin: 6px 0 4px; }
.wd-line { text-align: center; color: var(--gold); font-size: 18px; }
.wd-vi { text-align: center; font-size: 17px; margin: 6px 0; }
.wd-chars { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.wd-chars a { display: flex; flex-direction: column; align-items: center; text-decoration: none; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.wd-chars a b { font-size: 26px; font-family: var(--han); font-weight: 400; }
.wd-chars a small { color: var(--muted); font-size: 11.5px; }

/* ---------- ôn thẻ ---------- */
.flash { max-width: 640px; margin: 0 auto; }
.fc { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; min-height: 340px; display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 26px 18px; text-align: center; position: relative; cursor: pointer; user-select: none; -webkit-user-select: none; }
.fc .tagn { position: absolute; top: 12px; left: 12px; }
.fc .lvl-tag { position: absolute; top: 12px; right: 12px; }
.fc .fc-h { font-size: 86px; line-height: 1.15; font-family: var(--han); }
.fc .fc-h .hz .py, .fc .fc-h .hz .zy { font-size: 20px; }
.fc .fc-hint { color: var(--muted); font-size: 13px; margin-top: 14px; }
.fc .fc-back { margin-top: 10px; }
.fc .fc-vi { font-size: 21px; margin-top: 8px; }
.fc .fc-hv { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .05em; }
.grades { display: flex; justify-content: center; margin-top: 14px; }
.grades .next { min-width: 220px; background: var(--red); color: var(--acc-ink); }
.grades button { border: 0; border-radius: 11px; padding: 12px 6px; font: 700 15px var(--font); cursor: pointer; color: #fff; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.grades button small { font-weight: 500; font-size: 11.5px; opacity: .85; }
.g0 { background: #7a1824; } .g1 { background: #6b4a12; } .g2 { background: #135e45; } .g3 { background: #1b4b7a; }
.fc-prog { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; color: var(--muted); font-size: 13px; }
.fc-prog .bar { flex: 1; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 700; background: var(--surface3); }
.pill.new { background: var(--acc-bg); color: var(--gold); }
.pill.red { background: var(--acc-bg); color: var(--red2); }

/* ---------- phát âm ---------- */
.zytab { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.zyc { background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: 10px 6px 8px; text-align: center; cursor: pointer; color: inherit; font: inherit; }
.zyc:hover, .zyc.on { border-color: var(--red); }
.zyc b { display: block; font-size: 30px; font-family: var(--han); font-weight: 400; line-height: 1.2; }
.zyc small { display: block; color: var(--gold); font-size: 13px; }
.zyc em { display: block; font-style: normal; color: var(--muted); font-size: 11.5px; }
.zytip { margin-top: 10px; min-height: 24px; position: sticky; bottom: calc(10px + var(--sab)); z-index: 5; box-shadow: 0 8px 24px rgba(0,0,0,.5); }
.tones { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.tonec { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; cursor: pointer; text-align: left; color: inherit; font: inherit; }
.tonec svg { width: 100%; height: 46px; display: block; margin: 6px 0; }
.tonec b { font-size: 15px; } .tonec p { font-size: 12.5px; color: var(--muted); margin: 0; }
.tq { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 10px 0; }
.tq .opts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; width: 100%; max-width: 520px; }
.tq .opts button { border: 1px solid var(--line); background: var(--surface2); color: var(--ink); border-radius: 12px; padding: 12px 6px; cursor: pointer; font: 600 15px var(--font); }
.tq .opts button b { display: block; font-size: 28px; font-family: var(--han); font-weight: 400; }
.tq .opts button.right { background: #135e45; border-color: var(--ok); }
.tq .opts button.wrong { background: color-mix(in srgb, var(--bad) 28%, var(--surface)); border-color: var(--bad); }
.speak { display: flex; flex-direction: column; gap: 10px; }
.sp-row { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 11px; background: var(--surface); border: 1px solid var(--line); flex-wrap: wrap; }
.sp-row .sp-zh { font-size: 28px; flex: 1; min-width: 200px; }
.sp-row .sp-vi { color: var(--muted); font-size: 13px; }
.sp-res { width: 100%; font-size: 14px; }
.sp-res .hit { color: var(--ok); } .sp-res .miss { color: var(--bad); text-decoration: underline; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs button { border: 0; background: transparent; color: var(--muted); font: 600 14.5px var(--font); padding: 10px 14px; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: #fff; border-color: var(--red); }

/* ---------- viết chữ ---------- */
.wr { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.wr-main { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.tz { position: relative; width: min(380px, 86vw); aspect-ratio: 1; background: #f7f3ea; border-radius: 12px; touch-action: none; }
.tz svg.grid { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.tz .hw { position: absolute; inset: 0; }
.tz .hw svg { width: 100%; height: 100%; display: block; }
.wr-info { text-align: center; }
.wr-info .big { font-size: 22px; }
.wr-modes { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.wr-msg { min-height: 24px; text-align: center; }
.chpick { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 6px; max-height: 60vh; overflow-y: auto; padding-right: 4px; }
.chpick button { border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 9px; font: 22px var(--han); padding: 6px 0; cursor: pointer; position: relative; }
.chpick button.on { border-color: var(--red); background: var(--acc-bg2); }
.chpick button.done::after { content: ""; position: absolute; top: 4px; right: 4px; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.strokes-row { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.strokes-row .stp { width: 54px; height: 54px; background: #f7f3ea; border-radius: 8px; }
@media (max-width: 960px) { .wr { grid-template-columns: 1fr; } .chpick { max-height: 240px; } }

/* ---------- luyện nét ---------- */
.stg { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.stc { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: flex; gap: 12px; }
.stc .nm { font-size: 40px; font-family: var(--kai); line-height: 1; color: var(--gold); }
.rules { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.rule { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.rule .ex { font-size: 28px; font-family: var(--han); }

/* ---------- ngữ pháp ---------- */
.gl { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.gi { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 13px 14px; text-decoration: none; display: flex; flex-direction: column; gap: 4px; }
.gi:hover { border-color: var(--surface3); background: #17181e; }
.gi code { font: 13px var(--han); color: var(--gold); }
.gi .sc { font-size: 12px; }
.pattern { font: 600 17px var(--han); color: var(--gold); background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.ex-list { display: flex; flex-direction: column; gap: 10px; }
.ex { display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: 11px; background: var(--bg2); border: 1px solid var(--line); }
.ex .z { font-size: 30px; line-height: 1.2; }
.ex .v { color: var(--muted); font-size: 13.5px; margin-top: 4px; }
.qz { display: flex; flex-direction: column; gap: 14px; }
.qz-q { background: var(--bg2); border: 1px solid var(--line); border-radius: 11px; padding: 14px; }
.qz-o { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.qz-o button { text-align: left; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 9px; padding: 10px 12px; font: 18px var(--han); cursor: pointer; }
.qz-o button.right { border-color: var(--ok); background: #10291f; } .qz-o button.wrong { border-color: var(--bad); background: var(--acc-bg); }
.why { font-size: 13.5px; margin-top: 8px; }
.ord-pool, .ord-ans { display: flex; flex-wrap: wrap; gap: 6px; min-height: 48px; padding: 8px; border-radius: 9px; }
.ord-ans { background: var(--surface); border: 1px dashed var(--surface3); }
.ord-pool button, .ord-ans button { border: 1px solid var(--line); background: var(--surface2); color: var(--ink); border-radius: 8px; padding: 6px 12px; font: 20px var(--han); cursor: pointer; }
.tip { background: #121d2a; border: 1px solid #23405f; border-radius: 10px; padding: 10px 14px; color: #cfe3ff; font-size: 14px; }
.explain p { font-size: 15px; }

/* ---------- lịch học ---------- */
.plan { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 18px; align-items: start; }
.ed-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) 150px 70px 74px 30px; gap: 8px; align-items: center; padding: 8px; border-radius: 10px; background: var(--bg2); border: 1px solid var(--line); margin-bottom: 6px; }
.ed-row input, .ed-row select { padding: 7px 8px; font-size: 14px; width: 100%; }
.ed-wd { grid-column: 2 / -1; display: flex; gap: 4px; flex-wrap: wrap; }
.ed-wd button { border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 7px; padding: 3px 9px; font: 600 12px var(--font); cursor: pointer; }
.ed-wd button.on { background: var(--red); color: var(--acc-ink); border-color: var(--red); }
.ed-mv { display: flex; flex-direction: column; gap: 2px; }
.ed-mv button, .ed-del { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 0; }
.ed-mv .ico, .ed-del .ico { width: 16px; height: 16px; }
@media (max-width: 1100px) { .plan { grid-template-columns: 1fr; } }
@media (max-width: 640px) {
  .ed-row { grid-template-columns: 24px minmax(0, 1fr) 30px; }
  .ed-row .ed-kind, .ed-row .ed-num, .ed-row .ed-min { grid-column: 2 / 3; }
  .tones { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tq .opts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; color: var(--muted); font-weight: 600; padding: 7px 8px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.welcome { max-width: 980px; }
.hero-cn { display: grid; grid-template-columns: 1fr 260px; gap: 20px; align-items: center; background: linear-gradient(135deg, var(--acc-bg2), #0f1014 60%); border: 1px solid var(--line); border-radius: 16px; padding: 28px; }
.hero-cn h1 { font-size: 34px; } .hero-cn .bigzh { font: 120px/1 var(--kai); color: var(--red); text-align: center; }
.feat { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-top: 18px; }
.feat a { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; text-decoration: none; display: flex; gap: 12px; }
.feat a .ico { width: 26px; height: 26px; stroke: var(--red2); }
@media (max-width: 760px) { .hero-cn { grid-template-columns: 1fr; } .hero-cn .bigzh { font-size: 80px; } }

/* ---- Chiết tự ---- */
.ct { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 18px; align-items: start; }
.ct-main { position: sticky; top: 18px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.ct-svg { width: 100%; max-width: 300px; aspect-ratio: 1; background: #f7f3ea; border-radius: 12px; display: grid; place-items: center; }
.ct-svg svg { width: 92%; height: 92%; }
.ct-fallback { font-size: 180px; color: #1d1d1f; }
.ct-hz path { transition: opacity .2s; }
.ct-hz path.dim { opacity: .13; }
.pc0 { --pc: #e3132b; } .pc1 { --pc: #1677ff; } .pc2 { --pc: #12a150; } .pc3 { --pc: #c77700; } .pc4 { --pc: #8e44ad; } .pcx { --pc: #555; }
.ct-hz path { fill: var(--pc); }
.ct-name { display: flex; align-items: center; gap: 14px; }
.ct-big { font-size: 46px; line-height: 1; }
.hvn { color: var(--gold, #f0c060); font-weight: 600; text-transform: lowercase; }
.hvn.big { font-size: 22px; text-transform: none; }
.ct-side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.ct-side h3 { margin: 0 0 10px; }
.ct-formula { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 34px; margin: 10px 0 6px; }
.ct-formula .plus { color: var(--muted); font-size: 24px; }
.ct-part { display: inline-grid; place-items: center; min-width: 54px; height: 54px; padding: 0 6px; border-radius: 10px; background: var(--surface2); border: 2px solid var(--pc); color: var(--pc); text-decoration: none; cursor: pointer; }
.ct-part.hl, .ct-pc.hl { box-shadow: 0 0 0 3px var(--pc); }
.ct-ex { font-size: 15.5px; line-height: 1.6; margin: 8px 0 0; }
.ct-parts { display: flex; flex-direction: column; gap: 10px; }
.ct-pc { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; background: var(--surface2); cursor: pointer; }
.ct-pc .sw { width: 6px; align-self: stretch; border-radius: 3px; background: var(--pc); flex: none; }
.ct-pc a { color: var(--ink); text-decoration: none; }
.ct-pc .han { font-size: 24px; }
.ct-fam { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; }
.ct-fam a { display: flex; flex-direction: column; align-items: center; padding: 6px 2px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--ink); text-decoration: none; }
.ct-fam a:hover { border-color: var(--red); }
.ct-fam b { font-size: 26px; font-weight: 400; }
.ct-fam small { color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.ct-words { display: flex; flex-direction: column; gap: 8px; }
.ct-w { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rg { margin: 18px 0; }
.rg-h { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.rg-r { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 10px; background: var(--red); color: var(--acc-ink); font-size: 28px; text-decoration: none; }
@media (max-width: 960px) { .ct { grid-template-columns: 1fr; } .ct-main { position: static; } }
.wd-ch { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.wd-chars .wd-ch a.small { background: none; border: 0; padding: 0; color: var(--muted); font-size: 12px; }
.wr-ct { margin-top: 6px; font-size: 13.5px; max-width: 520px; }
.wr-ct a { color: var(--ink); text-decoration: none; border-bottom: 1px dashed var(--line); }

/* ---- màu giao diện ---- */
.swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.swatches button { width: 34px; height: 34px; border-radius: 50%; border: 2px solid transparent; background: var(--c); cursor: pointer; box-shadow: inset 0 0 0 2px rgba(0,0,0,.25); }
.swatches button.on { border-color: var(--ink); box-shadow: 0 0 0 2px var(--bg) inset; }
.swatches input[type=color] { width: 40px; height: 34px; padding: 0; border: 1px solid var(--line); border-radius: 9px; background: var(--surface2); cursor: pointer; }
.swatches .reset { width: auto; height: 34px; border-radius: 9px; background: var(--surface2); color: var(--ink); padding: 0 12px; font: 500 13px var(--font); box-shadow: none; }
.upd-st { margin-top: 10px; font-size: 13.5px; }
.ibtn.upd.busy .ico { animation: spin 1.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.pub-st { padding: 10px 12px; border-radius: 10px; background: var(--surface2); font-size: 14px; }
.pub-url { margin: 8px 0; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; word-break: break-all; }
.pub-url a { font-weight: 600; color: var(--ink); }
.pub-key { margin-top: 12px; }
.pub-key ol { padding-left: 20px; line-height: 1.6; }
