:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1c2430;
  --muted: #5d6b7e;
  --line: #dde3ea;
  --brand: #1f4e8c;
  --brand-soft: #e6eef9;
  --ok: #1d7a46;
  --ok-soft: #e3f4ea;
  --bad: #b3261e;
  --bad-soft: #fbe9e7;
  --warn: #8a5a00;
  --warn-soft: #fff4dc;
  --chip: #eef1f5;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11151b;
    --card: #1a2029;
    --text: #e6eaf0;
    --muted: #9aa6b6;
    --line: #2c3542;
    --brand: #7fb0ff;
    --brand-soft: #1d2b40;
    --ok: #6fd39b;
    --ok-soft: #173327;
    --bad: #ff8a80;
    --bad-soft: #3a1f1d;
    --warn: #f3c46b;
    --warn-soft: #3a2f17;
    --chip: #252d38;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #11151b; --card: #1a2029; --text: #e6eaf0; --muted: #9aa6b6; --line: #2c3542;
  --brand: #7fb0ff; --brand-soft: #1d2b40; --ok: #6fd39b; --ok-soft: #173327; --bad: #ff8a80;
  --bad-soft: #3a1f1d; --warn: #f3c46b; --warn-soft: #3a2f17; --chip: #252d38; --shadow: none;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.65 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--brand); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { line-height: 1.35; margin: 0 0 .6em; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.12rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .7em; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.hide { display: none !important; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px; height: 52px;
  background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; color: var(--text); white-space: nowrap; }
.nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  padding: 6px 10px; border-radius: 8px; color: var(--muted); white-space: nowrap; font-size: .95rem;
}
.nav a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.main { max-width: 980px; margin: 0 auto; padding: 18px 16px 80px; }
.loading { padding: 40px 0; text-align: center; color: var(--muted); }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.grid { display: grid; gap: 12px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 720px) {
  .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 420px) {
  .grid.cols-2 { grid-template-columns: minmax(0, 1fr); }
}
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.kpi .label { font-size: .82rem; color: var(--muted); }
.kpi .value { font-size: 1.45rem; font-weight: 700; line-height: 1.3; }
.kpi .sub { font-size: .8rem; color: var(--muted); }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); cursor: pointer; font-weight: 600; min-height: 42px;
}
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
:root[data-theme="dark"] .btn.primary { color: #0b1626; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.primary { color: #0b1626; } }
.btn.danger { color: var(--bad); }
.btn.small { padding: 5px 10px; min-height: 32px; font-size: .88rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.block { width: 100%; }

.chip {
  display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px;
  background: var(--chip); color: var(--muted); font-size: .8rem; white-space: nowrap;
}
.chip.brand { background: var(--brand-soft); color: var(--brand); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.pick {
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card);
  cursor: pointer; font-size: .9rem;
}
.pick.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); font-weight: 600; }

label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: .88rem; color: var(--muted); margin-bottom: 4px; }
input[type="text"], input[type="password"], input[type="number"], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card);
}
input[type="file"] { max-width: 100%; }
textarea { min-height: 160px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .86rem; }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.check input { width: 18px; height: 18px; }

.notice { padding: 10px 14px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-size: .9rem; margin-bottom: 12px; }
.notice.info { background: var(--brand-soft); color: var(--brand); }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.notice.bad { background: var(--bad-soft); color: var(--bad); }

.progress { height: 6px; background: var(--chip); border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--brand); }

.q-head { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.q-no { font-weight: 700; margin-right: 4px; }
.q-stem { font-size: 1.04rem; margin-bottom: 14px; white-space: normal; word-break: break-word; }
.q-stem .material { display: block; background: var(--chip); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }
.options { display: grid; gap: 8px; }
.opt {
  display: flex; gap: 10px; align-items: flex-start; text-align: left; width: 100%;
  padding: 11px 14px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--card); cursor: pointer;
}
.opt .key {
  flex: none; width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid var(--line);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem;
}
.opt.multi .key { border-radius: 6px; }
.opt.sel { border-color: var(--brand); background: var(--brand-soft); }
.opt.sel .key { background: var(--brand); border-color: var(--brand); color: var(--card); }
.opt.right { border-color: var(--ok); background: var(--ok-soft); }
.opt.right .key { background: var(--ok); border-color: var(--ok); color: var(--card); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.wrong .key { background: var(--bad); border-color: var(--bad); color: var(--card); }
.opt[disabled] { cursor: default; }
.opt-text { flex: 1; word-break: break-word; }

.feedback { margin-top: 14px; border-top: 1px dashed var(--line); padding-top: 14px; }
.verdict { font-size: 1.1rem; font-weight: 700; margin-bottom: 6px; }
.verdict.ok { color: var(--ok); }
.verdict.bad { color: var(--bad); }
.fb-sec { margin-top: 10px; }
.fb-sec h4 { margin: 0 0 3px; font-size: .86rem; color: var(--muted); font-weight: 600; }
.fb-sec ul { margin: 0; padding-left: 1.2em; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.bar-row { display: grid; grid-template-columns: minmax(90px, 220px) 1fr 76px; gap: 10px; align-items: center; font-size: .9rem; margin: 6px 0; }
.bar { height: 10px; background: var(--chip); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--brand); }
.bar > i.low { background: var(--bad); }
.bar > i.mid { background: var(--warn); }
.bar > i.high { background: var(--ok); }
.bar-row .num { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
@media (max-width: 520px) { .bar-row { grid-template-columns: 1fr 100px; } .bar-row .bar { grid-column: 1 / -1; grid-row: 2; } }

table.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th, .tbl td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tbl th { color: var(--muted); font-weight: 600; font-size: .82rem; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl-wrap { overflow-x: auto; }
.tbl-wrap .tbl { min-width: 520px; }

.list-item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-item .title { font-weight: 600; }

.timer { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.1rem; }
.timer.low { color: var(--bad); }
.exam-bar {
  position: sticky; top: 52px; z-index: 10; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.navgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 6px; margin-top: 10px; }
.navgrid button {
  height: 36px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); cursor: pointer; font-size: .85rem;
}
.navgrid button.done { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }
.navgrid button.cur { outline: 2px solid var(--brand); }
.navgrid button.mark { box-shadow: inset 0 -3px 0 var(--warn); }
.navgrid button.right { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.navgrid button.wrong { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.section-title { font-weight: 700; color: var(--muted); font-size: .9rem; margin: 2px 0 8px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; max-width: 90vw; font-size: .92rem;
}
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 40; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-box { background: var(--card); border-radius: var(--radius); padding: 18px; width: 100%; max-width: 620px; max-height: 88vh; overflow: auto; }
.login-wrap { min-height: 80vh; display: flex; align-items: center; justify-content: center; }
.login-card { width: 100%; max-width: 380px; }
pre.code { background: var(--chip); padding: 10px 12px; border-radius: 10px; overflow-x: auto; font-size: .82rem; white-space: pre-wrap; word-break: break-all; }
details > summary { cursor: pointer; color: var(--brand); }
.countdown { font-size: 2rem; font-weight: 800; color: var(--brand); line-height: 1.1; }
.notes-block { margin-top: 8px; padding: 8px 10px; background: var(--chip); border-radius: 8px; }
.notes-sec { margin-top: 4px; font-size: .88rem; }
.notes-sum { font-size: 1.02rem; }
.ai-content { margin-top: 6px; font-size: .92rem; }
.ai-content ul { margin: 0; padding-left: 1.2em; }
.ai-content p { margin: 4px 0; }
.ai-content h4 { margin: 0; font-size: .95rem; }
