:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #f0eee8;
  --line: #e2dfd6;
  --text: #22211f;
  --muted: #6d6a62;
  --accent: #2f5d50;
  --accent-soft: #e3ece8;
  --ok: #2e7d4f;
  --ok-soft: #e2f1e7;
  --bad: #b8433a;
  --bad-soft: #f7e3e0;
  --warn: #9a6b12;
  --warn-soft: #f6ecd6;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 2px 8px rgba(0,0,0,.04);
  --font: -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #181a19;
    --surface: #212423;
    --surface-2: #2a2e2c;
    --line: #363b39;
    --text: #e8e6e1;
    --muted: #9c9a93;
    --accent: #7fbfa9;
    --accent-soft: #263a33;
    --ok: #74c493;
    --ok-soft: #1f3528;
    --bad: #e58a80;
    --bad-soft: #3d2522;
    --warn: #d9b26a;
    --warn-soft: #3a3020;
    --shadow: none;
  }
  .q-content img, .solution img { background: #fff; border-radius: 6px; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.65; }
a { color: var(--accent); text-decoration: none; }
button { font: inherit; color: inherit; }
h1, h2, h3 { line-height: 1.3; margin: 0 0 .6em; }
h1 { font-size: 22px; } h2 { font-size: 18px; } h3 { font-size: 16px; }

.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 20px; padding: 0 20px; height: 54px;
  background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; color: var(--text); white-space: nowrap; }
#nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
#nav a { padding: 6px 12px; border-radius: 8px; color: var(--muted); white-space: nowrap; }
#nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
main { max-width: 1040px; margin: 0 auto; padding: 24px 20px 80px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
@media (max-width: 760px) { .g2, .g3 { grid-template-columns: 1fr; } .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); } main { padding: 16px 16px 80px; } .topbar { padding: 0 16px; gap: 12px; } }
.stack > * + * { margin-top: 16px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.kpi .v { font-size: 26px; font-weight: 700; }
.kpi .l { color: var(--muted); font-size: 13px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 16px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.primary { color: #10201b; } }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { border: none; background: none; cursor: pointer; padding: 4px 8px; border-radius: 6px; color: var(--muted); }
.icon-btn:hover { background: var(--surface-2); }

.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 14px; }
.pill.on { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .pill.on { color: #10201b; } }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); font-size: 13px; color: var(--muted); }
.chip.link { cursor: pointer; color: var(--accent); background: var(--accent-soft); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip .x { cursor: pointer; opacity: .6; }

.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input[type=text], input[type=search], textarea, select { width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
textarea { min-height: 90px; resize: vertical; line-height: 1.6; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

.bar { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); }
.bar.ok > i { background: var(--ok); } .bar.bad > i { background: var(--bad); } .bar.warn > i { background: var(--warn); }

/* 题目 */
.quiz-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.progress { flex: 1; }
.q-content { font-size: 16px; }
.q-content img, .solution img { max-width: 100%; height: auto; }
.q-content p { margin: .4em 0; }
.opts { display: grid; gap: 10px; margin-top: 16px; }
.opts.letters { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.opt { display: flex; gap: 10px; align-items: flex-start; text-align: left; padding: 12px 14px; border-radius: 10px; border: 1.5px solid var(--line);
  background: var(--surface); cursor: pointer; }
.opts.letters .opt { justify-content: center; font-size: 20px; font-weight: 700; }
.opt .k { font-weight: 700; color: var(--muted); }
.opt:hover:not(:disabled) { border-color: var(--accent); }
.opt.right { border-color: var(--ok); background: var(--ok-soft); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt:disabled { cursor: default; }
.verdict { font-weight: 700; }
.verdict.ok { color: var(--ok); } .verdict.bad { color: var(--bad); }
.solution { border-left: 3px solid var(--accent); padding-left: 14px; }
.insight { background: var(--accent-soft); border-radius: 8px; padding: 10px 14px; font-size: 14px; }
.insight b { color: var(--accent); }
.kbd { font-family: ui-monospace, Menlo, monospace; font-size: 12px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; color: var(--muted); }
.navbtns { display: flex; justify-content: space-between; gap: 10px; margin-top: 16px; }
.star { font-size: 18px; color: var(--muted); }
.star.on { color: #d8a118; }

/* 卡片 markdown */
.md p { margin: .5em 0; }
.md ul, .md ol { padding-left: 1.4em; margin: .4em 0; }
.md li { margin: .15em 0; }
.md table { border-collapse: collapse; margin: .6em 0; font-size: 14px; }
.md th, .md td { border: 1px solid var(--line); padding: 4px 10px; }
.md strong { color: var(--text); }
.md h3 { margin-top: 1em; }
.oneliner { background: var(--warn-soft); color: var(--text); border-radius: 8px; padding: 10px 14px; font-weight: 600; }

/* 考点页 */
.split { display: grid; grid-template-columns: 300px minmax(0,1fr); gap: 16px; align-items: start; }
.sidebar { position: sticky; top: 70px; max-height: calc(100vh - 90px); overflow: auto; padding: 12px; }
.sidebar .grp { font-size: 12px; color: var(--muted); margin: 12px 4px 4px; }
.sidebar .it { display: flex; justify-content: space-between; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 14px; }
.sidebar .it:hover { background: var(--surface-2); }
.sidebar .it.on { background: var(--accent-soft); color: var(--accent); }
@media (max-width: 760px) { .split { grid-template-columns: 1fr; } .sidebar { position: static; max-height: 320px; } }

.list-item { padding: 12px 0; border-top: 1px solid var(--line); }
.list-item:first-child { border-top: none; }
.daybars { display: flex; align-items: flex-end; gap: 3px; height: 90px; }
.daybars .d { flex: 1; background: var(--accent-soft); border-radius: 3px 3px 0 0; position: relative; min-height: 2px; }
.daybars .d i { position: absolute; bottom: 0; left: 0; right: 0; background: var(--accent); border-radius: 3px 3px 0 0; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; color: var(--muted); font-weight: 500; padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.t td { padding: 7px 8px; border-bottom: 1px solid var(--line); }
table.t tr.click { cursor: pointer; } table.t tr.click:hover td { background: var(--surface-2); }

.flash { min-height: 260px; }
.empty { text-align: center; padding: 40px 0; color: var(--muted); }

.drawer[hidden] { display: none; }
.drawer { position: fixed; inset: 0; z-index: 30; }
.drawer-bg { position: absolute; inset: 0; background: rgba(0,0,0,.3); }
.drawer-panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(560px, 100%); background: var(--surface); overflow: auto; padding: 24px; box-shadow: -4px 0 20px rgba(0,0,0,.1); }
.drawer-x { position: absolute; top: 14px; right: 14px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 8px 16px; border-radius: 8px; z-index: 40; font-size: 14px; }
.toast[hidden] { display: none; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { padding: 8px 14px; border: none; background: none; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
details > summary { cursor: pointer; color: var(--muted); }

/* 进度条（做对 / 做错 / 未做） */
.seg { display: flex; width: 100%; border-radius: 4px; overflow: hidden; background: var(--surface-2); }
.seg i { display: block; height: 100%; }
.seg i.ok { background: var(--ok); } .seg i.bad { background: var(--bad); }
.legend { gap: 16px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line); margin-right: 4px; vertical-align: middle; }
.dot.ok { background: var(--ok); border-color: var(--ok); } .dot.bad { background: var(--bad); border-color: var(--bad); }
.g5 { grid-template-columns: repeat(5, minmax(0,1fr)); }
@media (max-width: 760px) { .g5 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
.bank-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.card.bank { text-align: left; cursor: pointer; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.card.bank:hover { border-color: var(--accent); }
.card.bank.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.topic-table { max-height: 440px; overflow: auto; }
.topic-table th { position: sticky; top: 0; background: var(--surface); }
.topic-table tr.sel td { background: var(--accent-soft); }
table.t .num { text-align: right; width: 64px; white-space: nowrap; }
.pill .cnt { opacity: .65; margin-left: 2px; font-size: 12px; }
.pill:disabled { opacity: .45; cursor: default; }
.practice .field { min-width: 180px; flex: 1; }
.startbar { position: sticky; bottom: 12px; z-index: 5; box-shadow: 0 4px 16px rgba(0,0,0,.08); }
.qdots { display: flex; flex-wrap: wrap; gap: 4px; margin: -4px 0 4px; }
.qd { width: 26px; height: 22px; font-size: 11px; border-radius: 5px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); cursor: pointer; padding: 0; }
.qd.ok { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.qd.bad { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.qd.cur { outline: 2px solid var(--accent); outline-offset: 1px; font-weight: 700; color: var(--text); }
