/* ============================================================
 * style.css —— 答题页样式
 * 主题变量集中在 :root，换科目换配色只改这里。
 * ========================================================== */

:root {
  --bg: #f6f2ea;
  --paper: #fffdf8;
  --paper-soft: #fbf7ef;
  --ink: #2a2520;
  --ink-soft: #6b6157;
  --ink-faint: #9a8f80;
  --line: #e5ddcf;
  --line-strong: #d5c9b4;
  --brand: #8c2f2f;
  --brand-soft: #f5e6e1;
  --jade: #2f6b5f;
  --jade-soft: #e3efe9;
  --gold: #b98a2f;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(60, 45, 30, .05), 0 10px 28px rgba(60, 45, 30, .06);
  --serif: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 600; }

/* ---------------- 顶栏 ---------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 12px 28px 11px;
  background: rgba(246, 242, 234, .9);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand { min-width: 0; }

.brand-sub {
  font-size: 12px;
  letter-spacing: .18em;
  color: var(--ink-faint);
  text-transform: uppercase;
}

.brand-title {
  margin: 2px 0 0;
  font-size: 20px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meter {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex: none;
  font-variant-numeric: tabular-nums;
}

.meter-time {
  font-size: 15px;
  letter-spacing: .06em;
  color: var(--ink-soft);
}

.meter-count {
  font-size: 15px;
  color: var(--ink-soft);
}

.meter-count .sep { margin: 0 5px; color: var(--line-strong); }

.progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: transparent;
}

.progress-bar {
  height: 100%;
  width: 0;
  background: var(--jade);
  transition: width .25s ease;
}

/* ---------------- 主体布局 ---------------- */

.main { padding: 26px 28px 40px; }

.layout {
  display: grid;
  grid-template-columns: 208px minmax(0, 1fr);
  gap: 34px;
  max-width: 1080px;
  margin: 0 auto;
  align-items: start;
}

.loading {
  max-width: 720px;
  margin: 80px auto;
  text-align: center;
  color: var(--ink-faint);
}

.loading.error { color: var(--brand); }

/* ---------------- 侧栏导航 ---------------- */

.side {
  position: sticky;
  top: 96px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.side-title {
  font-size: 12px;
  letter-spacing: .16em;
  color: var(--ink-faint);
}

.navgrid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 7px;
}

.navcell {
  position: relative;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--paper);
  color: var(--ink-soft);
  font: inherit;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
}

.navcell:hover { border-color: var(--line-strong); }

.navcell.answered {
  background: var(--jade);
  border-color: var(--jade);
  color: #fff;
}

.navcell.current { box-shadow: 0 0 0 2px var(--jade-soft); }

.navcell.flagged::after {
  content: "";
  position: absolute;
  top: 4px;
  right: 4px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  color: var(--ink-faint);
}

.legend span { display: inline-flex; align-items: center; gap: 5px; }

.dot { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.dot.done { background: var(--jade); }
.dot.flag { background: var(--brand); border-radius: 50%; }

.side-tip {
  font-size: 12px;
  line-height: 1.7;
  color: var(--ink-faint);
  padding-top: 4px;
  border-top: 1px dashed var(--line);
}

/* ---------------- 题目列表 ---------------- */

.qlist { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.instructions {
  padding: 14px 18px;
  background: var(--paper-soft);
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
  border-radius: 10px;
  font-size: 14px;
  color: var(--ink-soft);
}

.group {
  margin: 18px 0 2px;
  font-size: 17px;
  letter-spacing: .02em;
}

.qcard {
  padding: 20px 22px 18px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  scroll-margin-top: 92px;
}

.qhead {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.qno {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 27px;
  height: 27px;
  padding: 0 6px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.qtag {
  font-size: 12px;
  letter-spacing: .04em;
  color: var(--brand);
  background: var(--brand-soft);
  padding: 2px 9px;
  border-radius: 999px;
}

.flag {
  margin-left: auto;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-faint);
  font: inherit;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: .15s;
}

.flag:hover { border-color: var(--brand); color: var(--brand); }
.flag.on { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }

.stem {
  font-size: 16.5px;
  line-height: 1.9;
  letter-spacing: .01em;
}

.stem strong { font-weight: 700; }

.stem code {
  font-family: var(--serif);
  background: var(--paper-soft);
  padding: 0 4px;
  border-radius: 4px;
}

/* ---------------- 选项 ---------------- */

.opts {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}

.opt {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  cursor: pointer;
  transition: border-color .15s, background .15s, box-shadow .15s;
}

.opt:hover { border-color: var(--line-strong); background: #fffefb; }

.opt input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.opt .key {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin-top: 2px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  font-size: 13px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  transition: .15s;
}

.opt-text { flex: 1 1 auto; font-size: 15.5px; line-height: 1.7; }

.opt.on {
  border-color: var(--jade);
  background: var(--jade-soft);
  box-shadow: inset 0 0 0 1px var(--jade);
}

.opt.on .key {
  background: var(--jade);
  border-color: var(--jade);
  color: #fff;
}

.opt:focus-within { outline: 2px solid var(--jade-soft); outline-offset: 2px; }

/* ---------------- 简答 ---------------- */

.essay {
  display: block;
  width: 100%;
  margin-top: 14px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fffefa;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15.5px;
  line-height: 1.8;
  resize: vertical;
  min-height: 120px;
}

.essay:focus {
  outline: none;
  border-color: var(--jade);
  box-shadow: 0 0 0 3px var(--jade-soft);
}

.essay-meta {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
  font-size: 12px;
  color: var(--ink-faint);
}

/* ---------------- 底部操作条 ---------------- */

.bottombar {
  position: sticky;
  bottom: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 28px;
  background: rgba(246, 242, 234, .93);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}

.bottombar-hint {
  font-size: 14px;
  color: var(--ink-soft);
}

.bottombar-actions { display: flex; gap: 10px; }

.btn {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  padding: 9px 20px;
  border-radius: 10px;
  cursor: pointer;
  transition: .15s;
}

.btn:hover { border-color: var(--ink-faint); }
.btn.ghost { background: transparent; color: var(--ink-soft); border-color: transparent; }
.btn.ghost:hover { background: rgba(0, 0, 0, .03); color: var(--ink); }

.btn.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  font-weight: 500;
}

.btn.primary:hover { background: #7a2828; }

.btn.primary.ready { box-shadow: 0 0 0 3px var(--brand-soft); }

/* ---------------- 结果页 ---------------- */

.result {
  max-width: 820px;
  margin: 20px auto 60px;
}

.result-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

.result-head h2 {
  margin: 0;
  font-size: 26px;
  letter-spacing: .02em;
}

.result-sub { margin: 0; font-size: 14px; color: var(--ink-faint); }

.result-tip {
  margin: 14px 0;
  padding: 12px 16px;
  font-size: 14px;
  color: var(--ink-soft);
  background: var(--paper-soft);
  border: 1px solid var(--line);
  border-left: 3px solid var(--jade);
  border-radius: 10px;
}

.report {
  width: 100%;
  height: 46vh;
  min-height: 280px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, var(--serif);
  font-size: 13px;
  line-height: 1.75;
  resize: vertical;
}

.result-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

/* ---------------- 响应式 ---------------- */

@media (max-width: 900px) {
  .topbar { padding: 10px 16px; }
  .brand-title { font-size: 17px; }
  .main { padding: 18px 16px 32px; }
  .layout { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .side { position: static; }
  .navgrid { grid-template-columns: repeat(10, 1fr); }
  .navcell { height: 30px; font-size: 12px; }
  .side-tip { display: none; }
  .qcard { padding: 16px 16px 14px; }
  .stem { font-size: 16px; }
  .bottombar { padding: 10px 16px; }
  .report { height: 58vh; }
}

@media (max-width: 560px) {
  .navgrid { grid-template-columns: repeat(8, 1fr); }
  .meter-time { display: none; }
  .opt { padding: 9px 11px; }
  .opt-text { font-size: 15px; }
  .btn { padding: 9px 14px; }
}

/* ---------------- 试卷切换 ---------------- */

.paper-pick {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  margin-left: 18px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
}

.pick-label {
  font-size: 11px;
  letter-spacing: .14em;
  color: var(--ink-faint);
}

.paper-pick select {
  max-width: 42vw;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  outline: none;
  cursor: pointer;
}

/* ---------------- 解析视图 ---------------- */

.verdict {
  margin-left: auto;
  font-size: 12.5px;
  padding: 2px 10px;
  border-radius: 999px;
  letter-spacing: .02em;
}

.verdict.ok { color: var(--jade); background: var(--jade-soft); }
.verdict.bad { color: var(--brand); background: var(--brand-soft); }

.qcard.exp .opt { cursor: default; }
.qcard.exp .opt:hover { border-color: var(--line); background: var(--paper); }

.opt.is-key,
.opt.is-key:hover {
  border-color: var(--jade);
  background: var(--jade-soft);
  box-shadow: inset 0 0 0 1px var(--jade);
}

.opt.is-wrong,
.opt.is-wrong:hover {
  border-color: var(--brand);
  background: #fbeeea;
  box-shadow: inset 0 0 0 1px var(--brand);
}

.opt .mark {
  margin-left: auto;
  padding-left: 8px;
  font-weight: 700;
}

.opt.is-key .mark { color: var(--jade); }
.opt.is-wrong .mark { color: var(--brand); }

.opt-more {
  margin: -3px 0 2px;
  padding: 0 4px 0 46px;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--ink-soft);
}

.answer-line {
  margin-top: 12px;
  font-size: 13.5px;
  color: var(--ink-soft);
}

.answer-line b { color: var(--ink); font-weight: 600; }

.explain-box {
  margin-top: 10px;
  padding: 12px 16px;
  background: var(--paper-soft);
  border-left: 3px solid var(--gold);
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.9;
}

.explist {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 16px;
}

@media (max-width: 900px) {
  .pick-label { display: none; }
  .paper-pick { margin-left: 8px; padding: 5px 8px; }
  .paper-pick select { max-width: 46vw; font-size: 12px; }
  .opt-more { padding-left: 40px; }
}

.bottombar[hidden] { display: none !important; }

/* ---------------- 模拟考试：成绩卡与报告 ---------------- */

.score-card {
  margin: 18px 0 4px;
  padding: 26px 30px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
}

.score-num {
  font-family: var(--serif);
  font-size: 62px;
  line-height: 1.1;
  color: var(--brand);
  font-variant-numeric: tabular-nums;
}

.score-num span {
  font-size: 20px;
  color: var(--ink-faint);
  margin-left: 4px;
}

.score-line {
  margin-top: 8px;
  font-size: 14px;
  color: var(--ink-soft);
}

.report-area { margin-top: 18px; }

.report-tip {
  padding: 12px 16px;
  font-size: 13.5px;
  line-height: 1.8;
  color: var(--ink-soft);
  background: var(--paper-soft);
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
  border-radius: 10px;
}

.report-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.report-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--paper-soft);
}

.report-bar h3 {
  margin: 0;
  font-size: 16px;
}

.report-md {
  margin: 0;
  padding: 18px 22px 26px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.95;
  color: var(--ink);
}

/* 难题标识 */
.hard-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 6px;
  background: #f7e7c8;
  border: 1px solid #e6c791;
  color: #8a5a12;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .05em;
}

/* ---------------- 解析页答题卡状态色 ---------------- */

.navcell.st-right,
.navcell.st-right:hover {
  background: var(--jade);
  border-color: var(--jade);
  color: #fff;
}

.navcell.st-right-flag,
.navcell.st-right-flag:hover {
  background: #f7e7b0;
  border-color: #e3cd85;
  color: #6b5316;
}

.navcell.st-partial,
.navcell.st-partial:hover {
  background: #f0a04b;
  border-color: #d98328;
  color: #5a3a12;
}

.navcell.st-wrong,
.navcell.st-wrong:hover {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.dot.st-right { background: var(--jade); }
.dot.st-right-flag { background: #f7e7b0; border: 1px solid #e3cd85; }
.dot.st-partial { background: #f0a04b; }
.dot.st-wrong { background: var(--brand); }

.legend-4 { gap: 10px; }
.legend-4 span { font-size: 11.5px; }

/* ---------------- 作答分析图 ---------------- */

.stats {
  margin-top: 14px;
  padding: 18px 20px 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stats-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.stats-head h3 {
  margin: 0;
  font-size: 16px;
}

.stats-sub {
  font-size: 11.5px;
  letter-spacing: .1em;
  color: var(--ink-faint);
}

.stats-kind {
  margin: 16px 0 8px;
  font-size: 11.5px;
  letter-spacing: .14em;
  color: var(--ink-faint);
}

.stat-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 7px 0;
  font-size: 13px;
}

.stat-label {
  flex: none;
  width: 118px;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-track {
  flex: 1 1 auto;
  height: 10px;
  background: #efe9dd;
  border-radius: 999px;
  overflow: hidden;
}

.stat-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  transition: width .3s ease;
}

.stat-row.good .stat-fill { background: var(--jade); }
.stat-row.mid .stat-fill { background: #e0a63c; }
.stat-row.bad .stat-fill { background: var(--brand); }

.stat-val {
  flex: none;
  width: 54px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
}

.explain-tip {
  margin: 12px 2px 4px;
  font-size: 12.5px;
  color: var(--ink-faint);
  line-height: 1.8;
}

@media (max-width: 900px) {
  .stat-label { width: 88px; }
}

/* ---------------- 选卷首页 ---------------- */

.home {
  max-width: 1000px;
  margin: 8px auto 70px;
}

.home-lead {
  margin: 6px 0 0;
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.9;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.home-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px 20px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}

.home-card:hover {
  border-color: var(--jade);
  transform: translateY(-2px);
  box-shadow: 0 10px 26px rgba(60, 45, 30, .1);
}

.home-seal {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand);
  font-family: var(--serif);
  font-size: 17px;
}

.home-body { flex: 1 1 auto; min-width: 0; }

.home-title {
  display: block;
  font-family: var(--serif);
  font-size: 16.5px;
  font-weight: 600;
  line-height: 1.5;
}

.home-desc {
  display: block;
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.75;
  color: var(--ink-soft);
}

.home-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.home-tag {
  font-size: 11.5px;
  color: var(--ink-faint);
  background: var(--paper-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 9px;
}

.home-arrow {
  flex: none;
  align-self: center;
  color: var(--ink-faint);
  font-size: 16px;
}

.home-foot {
  margin-top: 22px;
  font-size: 12.5px;
  color: var(--ink-faint);
  line-height: 1.9;
}

.home-foot code {
  font-family: ui-monospace, Menlo, monospace;
  background: var(--paper-soft);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0 5px;
}

@media (max-width: 900px) {
  .home-grid { grid-template-columns: minmax(0, 1fr); }
}

/* [hidden] 与 display 冲突时以 hidden 为准 */
.paper-pick[hidden] { display: none !important; }
