/* 刷题系统样式：浅色、单一强调色，绿 / 红只用于对错标记 */

:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1f2329;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff6ff;
  --accent-border: #bfdbfe;
  --ok: #15803d;
  --ok-soft: #f0fdf4;
  --ok-border: #86efac;
  --bad: #dc2626;
  --bad-soft: #fef2f2;
  --bad-border: #fca5a5;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --warn-border: #fcd34d;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 10px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { margin: 0 0 12px; font-weight: 600; line-height: 1.35; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.text-ok { color: var(--ok); }
.text-bad { color: var(--bad); }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 50px;
}
.brand { font-weight: 700; color: var(--text); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.topnav { display: flex; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.topnav::-webkit-scrollbar { display: none; }
.topnav a { color: var(--muted); padding: 6px 10px; border-radius: 6px; white-space: nowrap; font-size: 15px; }
.topnav a:hover { color: var(--text); background: var(--bg); text-decoration: none; }
.topnav a.is-active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.nav-count {
  display: inline-block;
  min-width: 18px;
  margin-left: 4px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--bad-soft);
  color: var(--bad);
  font-size: 12px;
  line-height: 18px;
  text-align: center;
}

/* ---------- 版心 ---------- */
.page { max-width: 760px; margin: 0 auto; padding: 16px 16px 48px; }

/* ---------- 按钮、卡片、提示、标签 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; background: var(--accent); border-color: var(--accent); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-danger { color: var(--bad); border-color: var(--bad-border); }
.btn-danger:hover { background: var(--bad-soft); }
.btn-sm { min-height: 32px; padding: 4px 10px; font-size: 14px; }
.btn-block { width: 100%; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}
.card.empty { text-align: center; color: var(--muted); padding: 32px 16px; }

.alert {
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  margin: 0 0 12px;
  font-size: 15px;
}
.alert-error { background: var(--bad-soft); color: var(--bad); border-color: var(--bad-border); }
.alert-ok { background: var(--ok-soft); color: var(--ok); border-color: var(--ok-border); }
.alert-warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-border); }

.tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  line-height: 18px;
  white-space: nowrap;
}
.tag-muted { background: var(--warn-soft); border-color: var(--warn-border); color: var(--warn); }
.tag-warn { background: var(--bad-soft); border-color: var(--bad-border); color: var(--bad); }
.tag-plain { background: var(--accent-soft); border-color: var(--accent-border); color: var(--accent); }

/* ---------- 表单 ---------- */
.form .field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field-label { font-size: 14px; color: var(--muted); }
input:not([type="checkbox"]):not([type="radio"]), select, textarea {
  font: inherit;
  font-size: 16px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  width: 100%;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible, .option:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.choices { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.choice { display: inline-flex; align-items: center; gap: 6px; font-size: 15px; cursor: pointer; }
.choice input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; flex: none; }
.range { display: flex; align-items: center; gap: 8px; }
.range input { width: 110px; }

/* ---------- 首页概览 ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
.stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--text);
}
a.stat:hover { text-decoration: none; border-color: var(--accent); }
.stat-label { font-size: 13px; color: var(--muted); }
.stat strong { font-size: 24px; font-weight: 650; line-height: 1.2; }
.stat small { font-size: 14px; color: var(--muted); font-weight: 400; }
.bar { display: block; height: 4px; border-radius: 2px; background: var(--border); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); }

.resume { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.resume-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.resume-title { font-weight: 600; }

.grid-2 { display: grid; gap: 16px; }

/* ---------- 列表 ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); }
.list-item:first-child { border-top: 0; }
.list-main { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; color: var(--text); }
a.list-main:hover { text-decoration: none; }
a.list-main:hover .list-title { color: var(--accent); }
.list-title { font-size: 15px; line-height: 1.5; }
.list-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 13px; }
.q-no { font-weight: 600; color: var(--accent); margin-right: 4px; }

/* ---------- 答题卡 ---------- */
.sheet {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 14px;
  margin-bottom: 12px;
}
.sheet summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.sheet summary::-webkit-details-marker { display: none; }
.sheet[open] summary { border-bottom: 1px solid var(--border); }
.sheet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(34px, 1fr));
  gap: 6px;
  padding: 10px 0;
}
.cell {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  font-size: 13px;
}
.cell:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }
.cell-done { background: var(--accent-soft); border-color: var(--accent-border); color: var(--accent); font-weight: 600; }
.cell-ok { background: var(--ok-soft); border-color: var(--ok-border); color: var(--ok); font-weight: 600; }
.cell-bad { background: var(--bad-soft); border-color: var(--bad-border); color: var(--bad); font-weight: 600; }
.cell.is-current { outline: 2px solid var(--accent); outline-offset: 1px; }
.sheet-legend { display: flex; align-items: center; gap: 6px; font-size: 13px; padding-bottom: 10px; }
.sheet-legend .cell { display: inline-flex; width: 26px; height: 22px; }

/* ---------- 题目页 ---------- */
.q-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 10px;
}
.q-session { color: var(--text); font-weight: 600; }
.q-pos { margin-left: auto; font-variant-numeric: tabular-nums; }
.q-timer { font-family: var(--mono); font-size: 18px; font-weight: 600; color: var(--text); padding: 0 4px; }
.q-timer.is-urgent { color: var(--bad); }

.q-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 12px; }
.q-title { font-size: 18px; margin: 4px 0 10px; }
.q-stem { font-size: 16px; line-height: 1.75; margin-bottom: 16px; }

/* 渲染出来的内容：纯文本段落和代码块 */
.rich p { margin: 0; }
.rich ul, .rich ol { margin: 8px 0; padding-left: 1.4em; }
.rich li { margin: 4px 0; }
.rich code { font-family: var(--mono); font-size: 0.9em; background: var(--bg); padding: 1px 5px; border-radius: 4px; }
.rich pre {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin: 10px 0;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.55;
}
.rich pre code { background: none; padding: 0; font-size: inherit; }

.options { display: flex; flex-direction: column; gap: 10px; }
.option {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--card);
}
.option-line { display: flex; gap: 12px; align-items: flex-start; }
.option-key {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
  line-height: 1;
  margin-top: 1px;
}
.option-text { flex: 1; min-width: 0; font-size: 15.5px; line-height: 1.65; }
.option-mark { flex: none; font-weight: 700; margin-left: 4px; }
.option-expl {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  font-size: 14px;
  line-height: 1.65;
  color: #374151;
}

/* 可作答时 */
.q-page[data-interactive="1"] .option { cursor: pointer; }
.q-page[data-interactive="1"] .option:hover { border-color: var(--accent); background: var(--accent-soft); }
.option.is-chosen { border-color: var(--accent); background: var(--accent-soft); }
.option.is-chosen .option-key { background: var(--accent); border-color: var(--accent); color: #fff; }

/* 出了结果后：✔ 正确项，✘ 错项，选中的错项标红 */
.option.is-correct { border-color: var(--ok-border); background: var(--ok-soft); }
.option.is-correct .option-key { border-color: var(--ok); color: var(--ok); }
.option.is-correct.is-chosen .option-key { background: var(--ok); border-color: var(--ok); color: #fff; }
.option.is-correct .option-mark { color: var(--ok); }
.option.is-wrong.is-chosen { border-color: var(--bad-border); background: var(--bad-soft); }
.option.is-wrong.is-chosen .option-key { background: var(--bad); border-color: var(--bad); color: #fff; }
.option.is-wrong.is-chosen .option-mark { color: var(--bad); }
.option.is-dim { border-style: dashed; }
.option.is-dim .option-mark { color: #9ca3af; }

.answer-panel { margin-top: 16px; }
.panel { border-top: 2px solid var(--border); padding-top: 14px; scroll-margin-top: 62px; }
.panel-ok { border-top-color: var(--ok); }
.panel-bad { border-top-color: var(--bad); }
.panel-result { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 12px; }
.result-badge { display: inline-block; padding: 2px 12px; border-radius: 999px; font-weight: 600; font-size: 14px; }
.panel-ok .result-badge { background: var(--ok-soft); color: var(--ok); border: 1px solid var(--ok-border); }
.panel-bad .result-badge { background: var(--bad-soft); color: var(--bad); border: 1px solid var(--bad-border); }
.result-answers { font-size: 15px; color: var(--muted); }
.result-answers strong { color: var(--text); font-size: 16px; }
.result-answers strong.text-ok { color: var(--ok); }
.sep { margin: 0 6px; }

.kp h2, .votes h2 { font-size: 14px; color: var(--muted); margin: 14px 0 6px; }
.kp-point { margin: 0 0 8px; font-size: 15.5px; }
.kp .rich { font-size: 15px; line-height: 1.75; color: #374151; }
.no-expl { margin: 12px 0; font-size: 15px; }

.vote-row { display: flex; flex-wrap: wrap; gap: 6px; }
.vote {
  padding: 1px 10px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.vote.is-top { color: var(--text); font-weight: 600; border-color: #d1d5db; }
.votes .alert { margin: 10px 0 0; }

.tools { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.note-box { margin-top: 10px; }
.note-input { resize: vertical; min-height: 78px; }
.note-actions { display: flex; align-items: center; gap: 10px; margin-top: 8px; }

/* 底部操作栏：手机上贴底，桌面是一张卡片 */
.q-nav {
  position: sticky;
  bottom: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 16px -16px 0;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--border);
}
.q-nav-spacer { flex: 1; }
.q-nav-form { display: contents; }
.q-hint { flex: 1; min-width: 0; font-size: 13px; }

/* ---------- 小结 / 成绩 ---------- */
.crumbs { font-size: 14px; color: var(--muted); margin: 0 0 12px; }
.result-grid { display: flex; flex-wrap: wrap; gap: 12px 32px; margin: 8px 0 12px; }
.big { display: flex; flex-direction: column; gap: 2px; }
.big strong { font-size: 34px; font-weight: 650; line-height: 1.2; }
.big strong.small { font-size: 20px; padding-top: 8px; }
.big-value { display: flex; align-items: baseline; gap: 6px; }

/* ---------- 统计 ---------- */
.chart { display: flex; align-items: flex-end; gap: 2px; height: 96px; margin-top: 8px; }
.chart-col { flex: 1; height: 100%; display: flex; align-items: flex-end; }
.chart-col i { display: block; width: 100%; background: var(--accent); border-radius: 2px 2px 0 0; }
.chart-col i.is-zero { height: 2px; background: var(--border); }
.chart-axis { display: flex; justify-content: space-between; font-size: 12px; margin-top: 4px; }

.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th, .table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th:first-child, .table td:first-child { white-space: normal; }
.table th { color: var(--muted); font-weight: 500; font-size: 13px; }

/* ---------- 其他 ---------- */
.page-head h1 { margin-bottom: 4px; }
.actions { margin-bottom: 12px; }
.pager { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 16px; font-size: 14px; }
.search-form { display: flex; gap: 8px; margin-bottom: 16px; }
.error-page h1 { margin-bottom: 8px; }
.login-box { max-width: 380px; margin: 48px auto 0; text-align: center; }
.login-box h1 { margin-bottom: 4px; }
.login-box .form { margin-top: 16px; text-align: left; }

@media (min-width: 720px) {
  .page { padding: 24px 24px 56px; }
  .topbar-inner { padding: 0 24px; }
  .card { padding: 20px 24px; }
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .login-box { margin-top: 96px; }
  .q-nav {
    margin: 16px 0 0;
    padding: 10px 16px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
  }
}
