/* ===== HSK 自测 · 配色保留自彩色 PDF ===== */
:root {
  --hsk1: #27AE60; --hsk2: #2980B9; --hsk3: #E67E22; --hsk4: #C0392B;
  --hsk1-soft: #e7f7ee; --hsk2-soft: #e7f1f9; --hsk3-soft: #fdf0e6; --hsk4-soft: #f9e9e7;
  --ink: #1a1a1a; --ink-2: #555; --ink-3: #888; --line: #ececec;
  --bg: #f5f6f8; --card: #ffffff; --accent: #2c3e50;
  --ok: #27AE60; --bad: #C0392B;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 6px 18px rgba(0,0,0,.05);
  --radius: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--ink);
  line-height: 1.5; -webkit-font-smoothing: antialiased;
}
.kai { font-family: "Kaiti SC","Kaiti","KaiTi","STKaiti","楷体",serif; }

#app { max-width: 760px; margin: 0 auto; min-height: 100vh; padding: 0 16px 64px; }

/* ---- Top bar ---- */
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(245,246,248,.9);
  backdrop-filter: blur(8px); display: flex; align-items: center; gap: 10px;
  padding: 14px 2px 12px; margin-bottom: 4px; }
.topbar h1 { font-size: 17px; margin: 0; font-weight: 700; flex: 1; }
.back-btn { border: none; background: #fff; color: var(--ink-2); border-radius: 10px;
  width: 38px; height: 38px; font-size: 18px; cursor: pointer; box-shadow: var(--shadow); flex: none; }
.back-btn:active { transform: scale(.94); }
.pill { font-size: 12px; color: var(--ink-3); background: #fff; padding: 6px 12px;
  border-radius: 999px; box-shadow: var(--shadow); }

/* ---- Home ---- */
.hero { text-align: center; padding: 18px 0 6px; }
.hero .big { font-size: 52px; line-height: 1; letter-spacing: 4px; }
.hero .sub { color: var(--ink-3); font-size: 13px; margin-top: 8px; }
.hero .counts { display: flex; gap: 6px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }

.section-label { font-size: 12px; color: var(--ink-3); text-transform: uppercase;
  letter-spacing: .08em; margin: 22px 4px 10px; font-weight: 600; }

.scope-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; }
.scope-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.scope-row + .scope-row { margin-top: 14px; }
.scope-row > .lab { font-size: 13px; color: var(--ink-2); width: 52px; flex: none; font-weight: 600; }

.chip { border: 1.5px solid var(--line); background: #fff; color: var(--ink-2);
  padding: 7px 14px; border-radius: 999px; font-size: 13px; cursor: pointer; font-weight: 600;
  transition: all .12s; user-select: none; }
.chip:active { transform: scale(.95); }
.chip.on { color: #fff; border-color: transparent; }
.chip.lv1.on { background: var(--hsk1); } .chip.lv2.on { background: var(--hsk2); }
.chip.lv3.on { background: var(--hsk3); } .chip.lv4.on { background: var(--hsk4); }
.chip.lv1 { border-color: var(--hsk1); color: var(--hsk1); }
.chip.lv2 { border-color: var(--hsk2); color: var(--hsk2); }
.chip.lv3 { border-color: var(--hsk3); color: var(--hsk3); }
.chip.lv4 { border-color: var(--hsk4); color: var(--hsk4); }
.chip.unit.on { background: var(--accent); }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 16px; cursor: pointer; border: none; text-align: left; transition: transform .12s;
  display: flex; flex-direction: column; gap: 4px; position: relative; overflow: hidden; }
.tile:active { transform: translateY(2px) scale(.99); }
.tile .ic { font-size: 26px; }
.tile .tt { font-size: 16px; font-weight: 700; margin-top: 4px; }
.tile .dd { font-size: 12px; color: var(--ink-3); }
.tile::after { content: ""; position: absolute; right: -18px; top: -18px; width: 60px; height: 60px;
  border-radius: 50%; opacity: .08; background: var(--accent); }
.tile.t1::after { background: var(--hsk1); } .tile.t2::after { background: var(--hsk2); }
.tile.t3::after { background: var(--hsk3); } .tile.t4::after { background: var(--hsk4); }
.tile.wide { grid-column: 1 / -1; flex-direction: row; align-items: center; gap: 14px; }
.tile.wide .ic { font-size: 28px; }

/* ---- Badges ---- */
.badge { display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff; padding: 2px 7px; border-radius: 6px;
  letter-spacing: .02em; flex: none; }
.b1 { background: var(--hsk1); } .b2 { background: var(--hsk2); }
.b3 { background: var(--hsk3); } .b4 { background: var(--hsk4); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

/* ---- Browse ---- */
.search { width: 100%; border: 1.5px solid var(--line); border-radius: 12px; padding: 11px 14px;
  font-size: 15px; outline: none; background: #fff; }
.search:focus { border-color: var(--accent); }
.char-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px; margin-bottom: 12px; border-left: 5px solid var(--line); }
.char-card.l1 { border-left-color: var(--hsk1); } .char-card.l2 { border-left-color: var(--hsk2); }
.char-card.l3 { border-left-color: var(--hsk3); } .char-card.l4 { border-left-color: var(--hsk4); }
.char-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 8px; }
.char-head .ch { font-size: 40px; line-height: 1; }
.char-head .py { font-size: 16px; color: var(--ink-2); font-weight: 600; }
.char-head .gl { font-size: 13px; color: var(--ink-3); }
.char-head .spk { margin-left: auto; }
.word-row { display: flex; align-items: baseline; gap: 8px; padding: 5px 0; border-top: 1px dashed var(--line); }
.word-row .w { font-size: 18px; min-width: 0; }
.word-row .wpy { font-size: 13px; color: var(--ink-2); }
.word-row .wen { font-size: 12px; color: var(--ink-3); margin-left: auto; text-align: right; }

.spk { border: none; background: transparent; cursor: pointer; font-size: 16px; opacity: .6; padding: 2px 4px; }
.spk:hover { opacity: 1; }

/* ---- Flashcard ---- */
.stage { display: flex; flex-direction: column; align-items: center; gap: 18px; padding-top: 8px; }
.progress { width: 100%; height: 6px; background: #e9eaee; border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .35s; }
.flashcard { width: 100%; min-height: 320px; perspective: 1400px; cursor: pointer; }
.fc-inner { position: relative; width: 100%; min-height: 320px; transition: transform .5s;
  transform-style: preserve-3d; }
.fc-inner.flipped { transform: rotateY(180deg); }
.fc-face { position: absolute; inset: 0; backface-visibility: hidden; background: var(--card);
  border-radius: 20px; box-shadow: var(--shadow); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px; padding: 24px; }
.fc-face.back { transform: rotateY(180deg); }
.fc-face .lvtag { position: absolute; top: 16px; left: 16px; }
.fc-face .spk { position: absolute; top: 12px; right: 12px; font-size: 22px; opacity: .55; }
.fc-face .main { font-size: 64px; line-height: 1.1; text-align: center; }
.fc-face .main.small { font-size: 34px; }
.fc-face .py { font-size: 24px; color: var(--ink-2); font-weight: 600; }
.fc-face .en { font-size: 17px; color: var(--ink-3); text-align: center; }
.fc-hint { font-size: 12px; color: var(--ink-3); }

.row-btns { display: flex; gap: 12px; width: 100%; }
.btn { flex: 1; border: none; border-radius: 14px; padding: 15px; font-size: 16px; font-weight: 700;
  cursor: pointer; box-shadow: var(--shadow); transition: transform .1s; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost { background: #fff; color: var(--ink-2); }
.btn.good { background: var(--ok); color: #fff; }
.btn.bad { background: var(--bad); color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }

/* ---- Quiz (MCQ / recognition / dictation) ---- */
.q-card { background: var(--card); border-radius: 20px; box-shadow: var(--shadow);
  padding: 26px 20px; text-align: center; width: 100%; position: relative; }
.q-card .lvtag { position: absolute; top: 14px; left: 14px; }
.q-card .spk { position: absolute; top: 12px; right: 12px; font-size: 22px; }
.q-prompt { font-size: 14px; color: var(--ink-3); margin-bottom: 12px; }
.q-main { font-size: 46px; line-height: 1.15; }
.q-main.small { font-size: 26px; font-weight: 600; }
.q-sub { font-size: 16px; color: var(--ink-2); margin-top: 6px; }
.options { display: flex; flex-direction: column; gap: 10px; width: 100%; margin-top: 4px; }
.opt { border: 1.5px solid var(--line); background: #fff; border-radius: 14px; padding: 14px 16px;
  font-size: 16px; cursor: pointer; text-align: left; transition: all .12s; color: var(--ink);
  display: flex; align-items: center; gap: 10px; }
.opt:active { transform: scale(.99); }
.opt .k { width: 22px; height: 22px; border-radius: 6px; background: #eef0f3; color: var(--ink-3);
  font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex: none; }
.opt.correct { border-color: var(--ok); background: var(--hsk1-soft); }
.opt.correct .k { background: var(--ok); color: #fff; }
.opt.wrong { border-color: var(--bad); background: var(--hsk4-soft); }
.opt.wrong .k { background: var(--bad); color: #fff; }
.opt:disabled { cursor: default; }

.answer-box { display: flex; gap: 10px; margin-top: 4px; }
.answer-box input { flex: 1; border: 1.5px solid var(--line); border-radius: 14px; padding: 14px 16px;
  font-size: 22px; outline: none; text-align: center; }
.answer-box input:focus { border-color: var(--accent); }
.feedback { text-align: center; font-size: 15px; padding: 10px; border-radius: 12px; font-weight: 600; }
.feedback.ok { color: var(--ok); background: var(--hsk1-soft); }
.feedback.no { color: var(--bad); background: var(--hsk4-soft); }
.scorebar { display: flex; gap: 16px; justify-content: center; font-size: 13px; color: var(--ink-2); }
.scorebar b { color: var(--ink); }

/* ---- Results ---- */
.result { text-align: center; padding: 20px 0; }
.result .ring { font-size: 64px; font-weight: 800; }
.result .msg { color: var(--ink-2); margin-top: 6px; }
.review-item { display: flex; align-items: baseline; gap: 10px; background: #fff; border-radius: 12px;
  padding: 10px 14px; margin-bottom: 8px; box-shadow: var(--shadow); }
.review-item .w { font-size: 20px; }
.review-item .py { font-size: 13px; color: var(--ink-2); }
.review-item .en { font-size: 12px; color: var(--ink-3); margin-left: auto; text-align: right; }

.empty { text-align: center; color: var(--ink-3); padding: 48px 0; font-size: 14px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--accent);
  color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 14px; box-shadow: var(--shadow);
  opacity: 0; transition: opacity .3s; pointer-events: none; z-index: 50; }
.toast.show { opacity: 1; }

@media (max-width: 480px) {
  .hero .big { font-size: 44px; }
  .fc-face .main { font-size: 54px; }
}
