:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --line: #e3e6ea;
  --text: #1f2329;
  --muted: #6b7280;
  --accent: #2f6feb;
  --accent-soft: #eaf1fe;
  --ok: #1a9e5c;
  --ok-soft: #e8f7ef;
  --bad: #d94040;
  --bad-soft: #fdecec;
  --warn: #b8791a;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 14px/1.65 -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
}

#app { display: flex; height: 100vh; overflow: hidden; }

/* ---------- 侧栏 ---------- */
.sidebar {
  width: 292px; flex: 0 0 292px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  transition: width .25s ease, flex-basis .25s ease;
  overflow: hidden;
}
.sidebar.collapsed {
  width: 44px; flex: 0 0 44px;
}
.sidebar.collapsed .brand-text,
.sidebar.collapsed .brand small,
.sidebar.collapsed .side-tabs,
.sidebar.collapsed .side-body {
  display: none;
}
.sidebar.collapsed .brand {
  padding: 12px 8px;
  justify-content: center;
}
.sidebar.collapsed .btn-collapse { display: none; }
.sidebar.collapsed .btn-expand { display: flex; }
.sidebar:not(.collapsed) .btn-expand { display: none; }

.brand {
  padding: 16px 18px 12px;
  font-size: 15px; font-weight: 600;
  letter-spacing: .3px;
  display: flex; align-items: center; gap: 8px;
  position: relative;
}
.brand-text { flex: 1; }
.brand small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); margin-top: 2px; }
.btn-collapse, .btn-expand {
  width: 28px; height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  flex-shrink: 0;
}
.btn-collapse:hover, .btn-expand:hover { background: #f1f3f6; color: var(--text); }

.side-tabs { display: flex; gap: 4px; padding: 0 12px 10px; }
.side-tabs button {
  flex: 1; padding: 7px 0; font-size: 13px;
  border: 1px solid var(--line); background: #fff; color: var(--muted);
  border-radius: 8px; cursor: pointer;
}
.side-tabs button.on { background: var(--accent-soft); color: var(--accent); border-color: #c9dcfd; font-weight: 500; }

.side-body { flex: 1; overflow-y: auto; padding: 0 12px 20px; }

/* 返回主站（沿用 grandbull.icu 主站 .primary-action 的墨绿配色） */
.back-home {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin: 0 12px 10px;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 6px;
  background: #17211b;
  color: #fff;
  font-size: 13px; font-weight: 700;
  text-decoration: none;
  transition: background .15s ease;
}
.back-home:hover { background: #2d7d5f; }
.sidebar.collapsed .back-home { display: none; }

.filter-box { margin-bottom: 12px; }
.filter-box label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.filter-box select {
  width: 100%; padding: 6px 8px; font-size: 13px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text);
}

.sec-list { display: flex; flex-direction: column; gap: 4px; }
.sec-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 8px; cursor: pointer;
  border: 1px solid transparent;
}
.sec-item:hover { background: #f7f8fa; }
.sec-item.on { background: var(--accent-soft); border-color: #c9dcfd; }
.sec-item .nm { flex: 1; font-size: 13px; }
.sec-item .ct { font-size: 12px; color: var(--muted); }
.bar { height: 4px; border-radius: 2px; background: #eceef1; overflow: hidden; margin-top: 4px; }
.bar > i { display: block; height: 100%; background: var(--accent); }
.sec-item .mini { width: 100%; }

/* ---------- 主区 ---------- */
.main { flex: 1; overflow-y: auto; padding: 22px 28px 60px; }

.empty { color: var(--muted); text-align: center; margin-top: 90px; font-size: 13px; }

.qbar {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 14px; flex-wrap: wrap;
}
.qbar .pos { font-size: 13px; color: var(--muted); }
.qbar .spacer { flex: 1; }

/* ---------- 单套题计时 ---------- */
.timer-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--text);
  background: #fff; border: 1px solid var(--line);
  border-radius: 999px; padding: 4px 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.timer-chip b { font-weight: 600; }
.timer-chip.paused {
  color: var(--warn); border-color: #f0d9b5; background: #fff8ec;
}
.qbar .btn { white-space: nowrap; }

#timerMask {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(110, 115, 122, 0.45);
  backdrop-filter: blur(2px);
  display: none; align-items: center; justify-content: center;
  cursor: pointer;
}
#timerMask.show { display: flex; }
.tm-card {
  background: #fff; border-radius: 16px;
  padding: 26px 40px; text-align: center;
  box-shadow: 0 12px 44px rgba(20, 30, 50, 0.22);
  pointer-events: none;
}
.tm-card .tm-ico { font-size: 34px; line-height: 1; }
.tm-card .tm-tip { font-size: 15px; font-weight: 600; margin-top: 10px; }
.tm-card .tm-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

.btn {
  padding: 7px 14px; font-size: 13px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--text);
}
.btn:hover { border-color: #c8ccd2; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #2560d0; }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn:disabled { opacity: .45; cursor: default; }

.material {
  background: #fbfbfc; border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px;
  max-height: 260px; overflow-y: auto;
}
.material h4 {
  margin: 0 0 6px; font-size: 12px; font-weight: 500; color: var(--muted);
  letter-spacing: .4px;
}
.material p { margin: 0; font-size: 13px; color: #3a3f47; line-height: 1.8; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 20px;
}
.stem { font-size: 15px; line-height: 1.8; margin-bottom: 14px; }
/* 语句填入题的横线占位（注意别用 .blank：会撞答题卡 .cell.blank 状态类） */
.blank-line {
  display: inline-block;
  min-width: 130px;
  height: 1em;
  border-bottom: 1px solid currentColor;
  margin: 0 4px;
  vertical-align: -2px;
}
.stem .tag {
  display: inline-block; font-size: 11px; color: var(--muted);
  background: #f2f3f5; border-radius: 5px; padding: 1px 7px; margin-left: 8px;
  vertical-align: 2px;
}

.opts { display: flex; flex-direction: column; gap: 8px; }
.opt {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 8px; cursor: pointer; background: #fff;
  font-size: 14px; line-height: 1.6;
}
.opt:hover { border-color: #b9c2ce; background: #fafbfc; }
.opt .k {
  flex: 0 0 22px; height: 22px; border-radius: 50%;
  border: 1px solid #cfd4db; display: flex; align-items: center;
  justify-content: center; font-size: 12px; color: var(--muted);
}
.opt.picked { border-color: var(--accent); background: var(--accent-soft); }
.opt.picked .k { border-color: var(--accent); background: var(--accent); color: #fff; }
.opt.right { border-color: var(--ok); background: var(--ok-soft); }
.opt.right .k { border-color: var(--ok); background: var(--ok); color: #fff; }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.wrong .k { border-color: var(--bad); background: var(--bad); color: #fff; }

.result { margin-top: 14px; font-size: 13px; }
.result .verdict { font-weight: 600; }
.result .verdict.ok { color: var(--ok); }
.result .verdict.bad { color: var(--bad); }
.result .meta { color: var(--muted); margin-top: 4px; font-size: 12px; }

.navrow { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }

/* ---------- 统计 ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.stat {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px;
}
.stat .lb { font-size: 12px; color: var(--muted); }
.stat .vl { font-size: 24px; font-weight: 600; margin-top: 4px; }
.stat .vl.small { font-size: 16px; }

h2.sect { font-size: 15px; font-weight: 600; margin: 26px 0 10px; }
h2.sect:first-child { margin-top: 0; }

table.tb { width: 100%; border-collapse: collapse; font-size: 13px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.tb th, table.tb td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--line); }
table.tb th { font-weight: 500; color: var(--muted); font-size: 12px; background: #fafbfc; }
table.tb tr:last-child td { border-bottom: none; }
table.tb td.num { font-variant-numeric: tabular-nums; }

.wrong-list { display: flex; flex-direction: column; gap: 8px; }
.wrong-item {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; cursor: pointer;
}
.wrong-item:hover { border-color: #b9c2ce; }
.wrong-item .t { font-size: 13px; }
.wrong-item .m { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---------- 分层导航 ---------- */
.hint { color: var(--muted); font-size: 12px; padding: 8px 2px; }

.book-group { margin-bottom: 14px; }
.book-hd {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 8px; border-radius: 8px; cursor: pointer;
  background: #f7f8fa; border: 1px solid var(--line);
}
.book-hd:hover { background: #f1f3f6; }
.book-hd .caret { font-size: 11px; color: var(--muted); width: 10px; }
.book-hd .nm { flex: 1; font-size: 13px; font-weight: 500; }
.book-hd .ct {
  font-size: 11px; color: var(--muted);
  background: #fff; border: 1px solid var(--line);
  border-radius: 9px; padding: 0 7px;
}
.book-meta { font-size: 11px; color: var(--muted); padding: 5px 10px 7px; }
.book-meta .bar { margin-top: 5px; }
.sec-list { display: flex; flex-direction: column; gap: 3px; padding-left: 8px; }
.sec-item.all { border: 1px dashed #cfd6e0; }
.sec-item.all .nm { color: var(--accent); }

h3.sub {
  font-size: 13px; font-weight: 500; color: var(--muted);
  margin: 16px 0 8px;
}
.mastery-book { margin-top: 14px; }
.opt .miss { color: #9aa1ab; font-style: normal; font-size: 13px; }

/* ---------- 题本内独立筛选 ---------- */
.book-filters {
  display: flex; flex-wrap: wrap; gap: 4px;
  padding: 0 8px 7px 8px;
}
.mini-sel {
  flex: 1 1 100%; max-width: 100%;
  font-size: 11px; padding: 3px 6px;
  border: 1px solid var(--line); border-radius: 6px;
  background: #fff; color: var(--text);
}
.mini-sel:focus { outline: none; border-color: #b9c2ce; }
.mini-clr {
  font-size: 11px; padding: 3px 9px;
  border: 1px solid var(--line); border-radius: 6px;
  background: #fff; color: var(--accent); cursor: pointer;
}
.mini-clr:hover { background: var(--accent-soft); }

/* ---------- 答题卡（右侧浮层） ---------- */
#app.sheet-open .main { padding-right: 376px; }

.sheet {
  position: fixed; top: 0; right: 0; bottom: 0; width: 360px;
  background: #fff; border-left: 1px solid var(--line);
  box-shadow: -6px 0 22px rgba(20, 30, 50, .06);
  display: flex; flex-direction: column; z-index: 40;
}
.sheet-hd {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px 12px;
}
.sheet-title { flex: 1; font-size: 15px; font-weight: 600; }
.sheet-progress {
  background: var(--accent-soft); color: var(--accent);
  border-radius: 999px; padding: 4px 13px;
  font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.sheet-actions { display: flex; gap: 10px; padding: 0 16px 12px; }
.sheet-actions button {
  flex: 1; padding: 10px 0; font-size: 14px; border: none;
  border-radius: 10px; cursor: pointer;
}
.btn-redo { background: #eaf1fe; color: #2f6feb; }
.btn-redo:hover { background: #dde9fd; }
.btn-wrong { background: #fdecec; color: #d94040; }
.btn-wrong:hover { background: #fbdcdc; }
.btn-wrong:disabled { background: #f4f5f7; color: #a8aeb8; cursor: default; }

.sheet-legend {
  display: flex; flex-wrap: wrap; gap: 14px;
  padding: 0 16px 12px; border-bottom: 1px solid var(--line);
}
.sheet-legend span {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--muted);
}
.sheet-legend i {
  width: 14px; height: 14px; border-radius: 4px;
  border: 2px solid #cfd4db; background: #fff; display: block;
}
.sheet-legend i.cur { background: #2f6feb; border-color: #2f6feb; }
.sheet-legend i.ans { border-color: #2f6feb; }
.sheet-legend i.ok { border-color: #1a9e5c; background: #e8f7ef; }
.sheet-legend i.bad { border-color: #d94040; background: #fdecec; }

.sheet-body { flex: 1; overflow-y: auto; padding: 14px 16px 24px; }
.sheet-group { margin-bottom: 18px; }
.sheet-group-hd {
  display: flex; align-items: baseline; gap: 8px;
  margin-bottom: 9px;
}
.sheet-group-hd .nm { flex: 1; font-size: 13px; color: var(--muted); }
.sheet-group-hd .rng { font-size: 12px; color: #b6bcc6; font-variant-numeric: tabular-nums; }
.sheet-grid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px;
}
.cell {
  position: relative;
  height: 44px; border-radius: 9px; cursor: pointer;
  font-size: 14px; font-weight: 500;
  border: 2px solid #e3e6ea; background: #fff; color: var(--muted);
  font-variant-numeric: tabular-nums;
  transition: transform .08s ease;
}
.cell:hover { transform: translateY(-1px); }
.cell.ans { border-color: #2f6feb; color: #2f6feb; }
.cell.ok { border-color: #1a9e5c; background: #e8f7ef; color: #1a9e5c; }
.cell.bad { border-color: #d94040; background: #fdecec; color: #d94040; }
.cell.cur {
  background: #2f6feb; border-color: #2f6feb; color: #fff;
  box-shadow: 0 0 0 3px rgba(47, 111, 235, .18);
}
.cell.cur.ok, .cell.cur.bad, .cell.cur.ans { color: #fff; }

/* ---------- 标记（疑惑题） ---------- */
/* 答题卡格子右上角圆点：空心紫=标记·未做，实心橙=标记·已做 */
.cell.flag-undone::after,
.cell.flag-done::after {
  content: ''; position: absolute; top: 3px; right: 3px;
  width: 9px; height: 9px; border-radius: 50%; box-sizing: border-box;
}
.cell.flag-undone::after { background: #fff; border: 2px solid #7c5cf0; }
.cell.flag-done::after { background: #f59e0b; border: 2px solid #f59e0b; }
.cell.cur.flag-undone::after { background: #fff; border-color: #c9b8ff; }
.cell.cur.flag-done::after { background: #ffd27a; border-color: #ffd27a; }

/* 题目区「标记」按钮 */
.btn.flagged {
  background: #fff7ed; border-color: #f0c894; color: #b96f08; font-weight: 500;
}
.btn.flagged:hover { background: #ffefdc; border-color: #e8b877; }

/* 答题卡图例：标记两态 */
.sheet-legend.flags { border-bottom: none; padding-top: 0; }
.sheet-legend i.flag-undone { border: 2px solid #7c5cf0; background: #fff; border-radius: 50%; }
.sheet-legend i.flag-done { border: 2px solid #f59e0b; background: #f59e0b; border-radius: 50%; }

/* ---------- 解析卡片 ---------- */
.analysis {
  margin-top: 16px;
  background: #fafbfc;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.analysis-hd {
  background: #f1f3f6;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  border-bottom: 1px solid var(--line);
}
.analysis-body { padding: 12px 14px; }
.ans-line {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 13px;
  margin-bottom: 6px;
  align-items: center;
}
.ans-line.muted { color: var(--muted); font-size: 12px; margin-bottom: 10px; }
.ans-line b { font-weight: 600; }
.ans-line b.ok { color: var(--ok); }
.ans-line b.bad { color: var(--bad); }
.verdict-tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 5px;
}
.verdict-tag.ok { background: var(--ok-soft); color: var(--ok); }
.verdict-tag.bad { background: var(--bad-soft); color: var(--bad); }
.verdict-tag.warn { background: #fff3e0; color: #b8791a; }
.analysis-sep {
  height: 1px;
  background: var(--line);
  margin: 10px 0;
}
.analysis-section { margin-bottom: 10px; }
.analysis-section:last-child { margin-bottom: 0; }
.analysis-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.analysis-content {
  font-size: 13px;
  color: #3a3f47;
  line-height: 1.7;
}
/* 解析区展示的题干原文（含批注序号） */
.analysis-content.annotated {
  background: #f7f8fa;
  border: 1px dashed var(--line);
  border-radius: 6px;
  padding: 8px 12px;
}
.analysis-content.annotated .blank-line {
  min-width: 110px;
  border-bottom-color: #9aa1ab;
}
.analysis-content.note {
  background: #f7f8fa;
  border-left: 3px solid var(--accent);
  padding: 8px 12px;
  border-radius: 0 6px 6px 0;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 36px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(30, 40, 55, 0.92);
  color: #fff;
  padding: 10px 22px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: all .25s ease;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
