:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --ink: #1f2733;
  --muted: #6b7785;
  --line: #e4e9f0;
  --brand: #2563eb;
  --brand-d: #1d4ed8;
  --ok: #16a34a;
  --ok-bg: #ecfdf3;
  --bad: #dc2626;
  --bad-bg: #fef2f2;
  --warn: #d97706;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(20,40,80,.06);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  padding-bottom: 64px;
}

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; font-size: 18px; letter-spacing: .5px; }
.brand span { color: var(--muted); font-weight: 600; font-size: 13px; margin-left: 4px; }
.nav { display: flex; gap: 6px; }
.nav-btn {
  border: 1px solid var(--line); background: #fff; color: var(--muted);
  padding: 7px 12px; border-radius: 999px; font-size: 14px; cursor: pointer;
  transition: .15s;
}
.nav-btn.active { background: var(--brand); border-color: var(--brand); color: #fff; }

main { max-width: 720px; margin: 0 auto; padding: 18px 16px; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card h2 { margin: 0 0 4px; font-size: 19px; }
.card .sub { color: var(--muted); font-size: 13px; margin: 0 0 14px; }

.row { display: flex; gap: 10px; flex-wrap: wrap; }
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }

select, input[type="number"] {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; font-size: 15px; background: #fff; color: var(--ink);
}

.btn {
  display: inline-block; border: none; cursor: pointer;
  background: var(--brand); color: #fff; font-size: 15px; font-weight: 600;
  padding: 12px 18px; border-radius: 10px; transition: .15s;
}
.btn:active { transform: translateY(1px); }
.btn:hover { background: var(--brand-d); }
.btn.block { width: 100%; }
.btn.ghost { background: #fff; color: var(--brand); border: 1px solid var(--brand); }
.btn.danger { background: #fff; color: var(--bad); border: 1px solid var(--bad); }

/* 选项 */
.opt {
  display: flex; align-items: flex-start; gap: 10px;
  border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; margin-bottom: 10px; cursor: pointer; background: #fff;
  transition: .12s;
}
.opt:hover { border-color: #c7d2fe; }
.opt .lab {
  flex: 0 0 24px; height: 24px; border-radius: 50%;
  background: #eef2ff; color: var(--brand); font-weight: 700;
  display: flex; align-items: center; justify-content: center; font-size: 14px;
}
.opt.selected { border-color: var(--brand); background: #f5f8ff; }
.opt.correct { border-color: var(--ok); background: var(--ok-bg); }
.opt.wrong { border-color: var(--bad); background: var(--bad-bg); }
.opt.dim { opacity: .55; }

/* 题目 */
.q-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.chip { font-size: 12px; padding: 3px 9px; border-radius: 999px; background: #eef2ff; color: var(--brand); }
.chip.diff-压轴 { background: #fef2f2; color: var(--bad); }
.chip.diff-冲高 { background: #fff7ed; color: var(--warn); }
.chip.diff-基础 { background: #ecfdf3; color: var(--ok); }
.q-st { font-size: 18px; font-weight: 600; margin: 4px 0 16px; line-height: 1.5; }
.opt-text { font-size: 16px; }

.feedback { margin-top: 14px; padding: 14px; border-radius: 10px; font-size: 15px; }
.feedback.ok { background: var(--ok-bg); color: #14532d; }
.feedback.bad { background: var(--bad-bg); color: #7f1d1d; }
.feedback b { color: inherit; }
.feedback .why { margin-top: 6px; color: #475569; font-size: 14px; }

.progress { height: 8px; background: #e8edf4; border-radius: 999px; overflow: hidden; margin-bottom: 14px; }
.progress > i { display: block; height: 100%; background: var(--brand); transition: width .2s; }

/* 统计 */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 6px; }
.stat { background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 12px; text-align: center; }
.stat .n { font-size: 22px; font-weight: 800; }
.stat .t { font-size: 12px; color: var(--muted); }

.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.empty .big { font-size: 40px; margin-bottom: 8px; }

.wrong-item { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; }
.wrong-item .q { font-weight: 600; margin-bottom: 6px; }
.tag-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.history-item { border-bottom: 1px dashed var(--line); padding: 10px 0; display: flex; justify-content: space-between; gap: 10px; }
.history-item:last-child { border-bottom: none; }
.right { text-align: right; }

.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 20px 16px 30px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #1f2733; color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 50;
}
.toast.show { opacity: 1; }

@media (max-width: 480px) {
  body { font-size: 15px; }
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
  .stat .n { font-size: 19px; }
}

/* ---------------- 试卷模式 ---------------- */
.paper-struct { background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 16px; font-size: 14px; line-height: 2; }
.paper-meta { font-size: 13px; color: var(--muted); }
.sec-title { font-weight: 700; font-size: 15px; color: var(--brand); margin: 18px 2px 10px; }
.q-block { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 12px; }
.q-head { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.q-no { font-weight: 800; font-size: 16px; color: var(--ink); }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.fig { text-align: center; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px; margin: 10px 0; }
.fill-input { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 15px; margin-top: 6px; }
.solve-box { width: 100%; min-height: 84px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 15px; resize: vertical; margin-top: 6px; font-family: inherit; }
.fill-ans { margin-top: 8px; padding: 10px 12px; background: #f8fafc; border-radius: 8px; font-size: 14px; }
.solve-ans { margin-top: 8px; padding: 10px 12px; background: var(--ok-bg); border-radius: 8px; font-size: 15px; }
.solve-steps { margin-top: 8px; padding: 10px 12px; background: #f8fafc; border-radius: 8px; font-size: 14px; }
.solve-steps ol { margin: 6px 0 0; padding-left: 20px; }
.solve-steps li { margin-bottom: 4px; }

/* ---------------- A4 横版可打印试卷 ---------------- */
.paper-toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.badge { font-size: 12px; padding: 4px 10px; border-radius: 999px; font-weight: 600; }
.badge-blue { background: #eff6ff; color: var(--brand); border: 1px solid #bfdbfe; }
.hidden { display: none !important; }

.paper-sheet {
  background: #fff; border: 1px solid var(--line); border-radius: 4px;
  padding: 28px 26px; box-shadow: 0 4px 20px rgba(0,0,0,.08);
  font-size: 15px; line-height: 1.7; color: #111; max-width: 980px; margin: 0 auto;
}
.paper-head { border-bottom: 3px double #333; padding-bottom: 12px; margin-bottom: 18px; text-align: center; }
.paper-head h1 { font-size: 22px; letter-spacing: 2px; margin: 0 0 6px; }
.score-line { display: flex; justify-content: center; gap: 30px; font-size: 15px; margin-top: 6px; flex-wrap: wrap; }
.score-line b { border-bottom: 1px solid #333; display: inline-block; min-width: 64px; text-align: center; }
.paper-head .meta { font-size: 14px; color: #444; margin-top: 8px; }
.paper-sec-title { font-size: 17px; font-weight: 700; border-left: 5px solid #111; padding-left: 10px; margin: 22px 0 12px; display: flex; justify-content: space-between; align-items: center; }
.paper-sec-title span { font-size: 13px; font-weight: 500; color: #666; }
.pq { margin-bottom: 14px; page-break-inside: avoid; }
.pq-st { line-height: 1.8; }
.pq-no { font-weight: 700; }
.pq-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 24px; margin-top: 6px; }
.pq-opt { font-size: 14.5px; }
.pq-fill { color: #888; font-size: 13px; }
.pq-answer-line { border-bottom: 1px solid #999; height: 26px; margin: 4px 0 2px; }
.pq-solve-space { min-height: 18mm; border: 1px dashed #bbb; border-radius: 6px; margin-top: 8px; background: repeating-linear-gradient(transparent, transparent 26px, #eee 26px, #eee 27px); }
.answer-page { margin-top: 24px; border-top: 3px solid #333; padding-top: 18px; }
.answer-page h3 { font-size: 17px; margin: 0 0 10px; }
.ans-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.ans-table th, .ans-table td { padding: 6px 10px; border: 1px solid #333; }
.ans-table th { background: #f3f4f6; }
.ans-table td:first-child { text-align: center; width: 48px; }
.print-note { font-size: 13px; color: #888; text-align: center; margin-top: 10px; }
.pq-fig { margin: 8px 0 6px; }
.pq-fig svg { max-width: 230px; }

@media print {
  .topbar, .foot, .paper-toolbar, .toast { display: none !important; }
  body { background: #fff; padding: 0; }
  .paper-sheet { box-shadow: none; border: none; margin: 0; width: auto; max-width: none; padding: 0; }
  .pq { page-break-inside: avoid; }
  .pq-solve-space { min-height: 40mm !important; }
  .answer-page { page-break-before: always; }
  .pq-fig, .pq-fig svg { max-width: 200px !important; }
  .card, .q-block { box-shadow: none; border: none; background: #fff; }
  .sec-title { color: #111; }
  @page { size: A4 landscape; margin: 10mm 12mm; }
}
