:root {
  --bg: #f5f2ea; --panel: #fffdf8; --ink: #1b1a17; --muted: #6e695e; --line: #e3ddd0;
  --brand: #0f7a5f; --brand-soft: #d9efe7; --brand-ink: #ffffff;
  --good: #1f8a4c; --good-soft: #dcf1e4; --bad: #c2352b; --bad-soft: #f8dfdc;
  --warn: #a86a00; --warn-soft: #f7ebcf; --zh: #c8372d; --vi: #d19a00;
  --shadow: 0 1px 0 rgba(0,0,0,.04), 0 8px 24px rgba(40,30,10,.07);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131412; --panel: #1d1f1c; --ink: #eeeae1; --muted: #a29c90; --line: #33352f;
    --brand: #3fbf95; --brand-soft: #16332a; --brand-ink: #08130f;
    --good: #4cc47f; --good-soft: #15301f; --bad: #ff6b5e; --bad-soft: #3a1b18;
    --warn: #f0b44c; --warn-soft: #3a2d12; --zh: #ff7a6e; --vi: #f5c542;
    --shadow: 0 8px 24px rgba(0,0,0,.35);
  }
}
:root[data-theme="dark"] {
  --bg: #131412; --panel: #1d1f1c; --ink: #eeeae1; --muted: #a29c90; --line: #33352f;
  --brand: #3fbf95; --brand-soft: #16332a; --brand-ink: #08130f;
  --good: #4cc47f; --good-soft: #15301f; --bad: #ff6b5e; --bad-soft: #3a1b18;
  --warn: #f0b44c; --warn-soft: #3a2d12; --zh: #ff7a6e; --vi: #f5c542;
  --shadow: 0 8px 24px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.6 "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
button { font: inherit; color: inherit; }
button:focus-visible, a:focus-visible, textarea:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { text-decoration: none; color: var(--brand); font-weight: 800; font-size: 22px; letter-spacing: .3px; display: flex; align-items: baseline; gap: 10px; }
.brand span { color: var(--muted); font-weight: 400; font-size: 12px; letter-spacing: 0; }
.stats { display: flex; gap: 8px; font-size: 14px; font-variant-numeric: tabular-nums; }
.stats span { background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; white-space: nowrap; }

.wrap { max-width: 680px; margin: 0 auto; padding: 22px 16px 60px; }
h1 { font-size: 28px; line-height: 1.25; margin: 0 0 8px; }
h2 { font-size: 18px; margin: 26px 0 12px; }
.sub { color: var(--muted); margin: 0 0 20px; }
.muted { color: var(--muted); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 20px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 14px; padding: 14px 18px;
  font-weight: 700; font-size: 17px; cursor: pointer; background: var(--brand); color: var(--brand-ink); width: 100%; }
.btn.ghost { background: transparent; color: var(--ink); border: 2px solid var(--line); }
.btn:disabled { opacity: .5; cursor: default; }
.link { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: 14px; }

/* 选择身份 */
.who { display: grid; gap: 14px; margin-top: 22px; }
.who button { text-align: left; background: var(--panel); border: 2px solid var(--line); border-radius: 18px; padding: 20px; cursor: pointer; box-shadow: var(--shadow); }
.who button:hover { border-color: var(--brand); }
.who .flag { font-size: 30px; }
.who b { display: block; font-size: 20px; margin-top: 6px; }
.who small { color: var(--muted); font-size: 14px; }
.how { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 26px; font-size: 14px; color: var(--muted); }
.how b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 2px; }

/* 首页 */
.review { display: flex; align-items: center; gap: 14px; background: var(--brand-soft); border: 0; }
.review .n { font-size: 34px; font-weight: 800; color: var(--brand); font-variant-numeric: tabular-nums; min-width: 48px; text-align: center; }
.review .txt { flex: 1; }
.review .txt b { display: block; }
.review .btn { width: auto; padding: 10px 18px; }
.levels { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.lv { background: var(--panel); border: 2px solid var(--line); border-radius: 14px; padding: 8px 4px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 1px; }
.lv b { font-size: 16px; white-space: nowrap; }
.lv small { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.lv:hover { border-color: var(--brand); }
.lv[aria-selected="true"] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.lv[aria-selected="true"] small { color: var(--brand-ink); opacity: .8; }
.lv-desc { margin: 12px 0 14px; }
.lv-desc p { margin: 0; font-size: 15px; }
.lv-desc small { color: var(--muted); font-size: 12px; }
h3 { font-size: 15px; margin: 18px 0 10px; color: var(--muted); font-weight: 600; }
.pack { margin-top: 14px; }
.pack .ph { display: flex; align-items: center; gap: 12px; }
.pack .ph .ic { font-size: 26px; }
.pack .ph div { flex: 1; min-width: 0; }
.pack .ph b { display: block; font-size: 17px; }
.pack .ph small { color: var(--muted); font-size: 13px; }
.btn.sm { width: auto; padding: 9px 14px; font-size: 14px; border-radius: 12px; white-space: nowrap; }
.pack .bar { margin: 12px 0 4px; }
.pack details { margin-top: 8px; }
.pack summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 6px; margin-top: 10px; max-height: 260px; overflow-y: auto; }
.g { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 6px 0; font-size: 12px; cursor: pointer; font-variant-numeric: tabular-nums; }
.g.part { background: var(--brand-soft); border-color: var(--brand); }
.g.full { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.src { margin-top: 8px; font-size: 12px; color: var(--muted); }
.src a { color: inherit; }
.credits { font-size: 12px; color: var(--muted); line-height: 1.6; margin-top: 18px; text-align: center; }
.credits a { color: inherit; }
.units { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.unit { text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px; cursor: pointer; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; transition: transform .12s, border-color .12s; }
.unit:hover { transform: translateY(-2px); border-color: var(--brand); }
.unit .ic { font-size: 26px; }
.unit b { font-size: 17px; }
.unit .alt { color: var(--muted); font-size: 13px; }
.bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 6px; }
.bar i { display: block; height: 100%; background: var(--brand); border-radius: 3px; transition: width .4s; }
.unit .pct { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.foot { margin-top: 30px; display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }

/* 练习 */
.lesson-top { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.lesson-top .x { background: none; border: 0; font-size: 22px; color: var(--muted); cursor: pointer; padding: 4px 8px; line-height: 1; }
.lesson-top .bar { flex: 1; height: 10px; border-radius: 5px; margin: 0; }
.kind { font-size: 13px; font-weight: 700; color: var(--brand); letter-spacing: .5px; margin-bottom: 6px; }
.prompt { font-size: 26px; font-weight: 700; line-height: 1.4; margin-bottom: 4px; }
.prompt-py { color: var(--muted); font-size: 15px; margin-bottom: 18px; }
.opts { display: grid; gap: 10px; margin-top: 18px; }
.opt { text-align: left; background: var(--panel); border: 2px solid var(--line); border-radius: 14px; padding: 14px 16px; cursor: pointer; font-size: 17px; line-height: 1.45; }
.opt small { display: block; color: var(--muted); font-size: 13px; }
.opt:hover:not(:disabled) { border-color: var(--brand); }
.opt.right { border-color: var(--good); background: var(--good-soft); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt:disabled { cursor: default; }
textarea { width: 100%; min-height: 96px; resize: vertical; font: inherit; font-size: 19px; padding: 14px 16px; border-radius: 14px;
  border: 2px solid var(--line); background: var(--panel); color: var(--ink); margin-top: 14px; }
textarea:focus { border-color: var(--brand); outline: none; }
.tip { font-size: 13px; color: var(--muted); margin-top: 6px; }
.actions { display: grid; gap: 10px; margin-top: 16px; }

.result { margin-top: 18px; border-radius: 16px; padding: 16px 18px; }
.result.ok { background: var(--good-soft); } .result.close { background: var(--warn-soft); } .result.no { background: var(--bad-soft); }
.result .head { font-size: 20px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.result.ok .head { color: var(--good); } .result.close .head { color: var(--warn); } .result.no .head { color: var(--bad); }
.result .lvl { font-size: 14px; font-weight: 600; margin-left: auto; opacity: .85; }
.flags { margin: 8px 0 0; padding-left: 18px; font-size: 14px; }
.answer { margin-top: 12px; padding-top: 12px; border-top: 1px dashed color-mix(in srgb, var(--ink) 20%, transparent); }
.answer .lbl { font-size: 12px; color: var(--muted); }
.answer .t { font-size: 20px; font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.answer .py { color: var(--muted); font-size: 14px; }
.note { margin-top: 10px; font-size: 14px; line-height: 1.6; }
.note::before { content: "💡 "; }
.say { border: 0; background: var(--panel); border-radius: 999px; width: 34px; height: 34px; cursor: pointer; font-size: 16px; flex: none; box-shadow: var(--shadow); }

.done { text-align: center; }
.done .big { font-size: 56px; margin: 10px 0; }
.done .nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 20px 0; }
.done .nums div { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.done .nums b { display: block; font-size: 26px; font-variant-numeric: tabular-nums; }
.done .nums span { font-size: 13px; color: var(--muted); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--ink); color: var(--bg); padding: 10px 16px;
  border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.loading { text-align: center; color: var(--muted); padding: 60px 0; }

@media (max-width: 560px) {
  .brand span { display: none; }
  h1 { font-size: 24px; }
  .units, .how { grid-template-columns: 1fr; }
  .levels { grid-template-columns: repeat(3, 1fr); }
  .prompt { font-size: 22px; }
  .done .big { font-size: 44px; }
}
