/* ==========================================================================
   人工智能训练师 理论刷题 —— 样式表
   手机优先，桌面端自动放宽
   ========================================================================== */

:root {
  --bg: #f4f6fa;
  --bg-soft: #ffffff;
  --bg-sunken: #eaeef5;
  --text: #17202e;
  --text-soft: #5b6675;
  --text-dim: #6b7789;
  --line: #dde3ec;
  --brand: #2f6bff;
  --brand-soft: #e8efff;
  --ok: #12a05c;
  --ok-soft: #e3f6ec;
  --bad: #e5484d;
  --bad-soft: #fdeaea;
  --warn: #c07a00;
  --warn-soft: #fdf3e0;
  --shadow: 0 1px 2px rgba(23, 32, 46, .06), 0 8px 24px rgba(23, 32, 46, .07);
  --radius: 14px;
  --radius-sm: 10px;
  --tap: 46px;
}

[data-theme="dark"] {
  --bg: #10151d;
  --bg-soft: #182029;
  --bg-sunken: #202a36;
  --text: #e9eef6;
  --text-soft: #aab6c6;
  --text-dim: #8b97a8;
  --line: #2a3542;
  --brand: #6c94ff;
  --brand-soft: #1d2a44;
  --ok: #37c07f;
  --ok-soft: #16301f;
  --bad: #ff6b70;
  --bad-soft: #341b1d;
  --warn: #e0a63c;
  --warn-soft: #33280f;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }

.wrap { width: 100%; max-width: 860px; margin: 0 auto; padding: 0 16px 96px; }

/* ---------------------------------------------------------------- 顶栏 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(10px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 860px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
}

.topbar h1 {
  font-size: 17px;
  margin: 0;
  font-weight: 650;
  letter-spacing: .2px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar .spacer { flex: 1 1 0; min-width: 0; }
.topbar .icon-btn { flex: 0 0 auto; }

.icon-btn {
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  border-radius: var(--radius-sm);
  min-width: var(--tap);
  height: 40px;
  padding: 0 12px;
  font-size: 15px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background .15s, border-color .15s, transform .08s;
}

.icon-btn:hover { border-color: var(--brand); }
.icon-btn:active { transform: scale(.97); }
.icon-btn.ghost { background: transparent; }

/* ---------------------------------------------------------------- 卡片 */
.card {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin: 16px 0;
}

.card h2 { font-size: 16px; margin: 0 0 4px; font-weight: 650; }
.card .hint { color: var(--text-dim); font-size: 13px; margin: 0 0 12px; }

.hero { text-align: center; padding: 28px 18px 22px; }
.hero h1 { font-size: 25px; margin: 0 0 6px; letter-spacing: .3px; }
.hero p { margin: 0; color: var(--text-dim); font-size: 14px; }
.hero .big { font-size: 34px; font-weight: 700; color: var(--brand); line-height: 1.1; }

.stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 18px;
}

.stat-row .stat {
  background: var(--bg-sunken);
  border-radius: var(--radius-sm);
  padding: 10px 6px;
}

.stat b { display: block; font-size: 19px; font-weight: 680; }
.stat span { font-size: 12px; color: var(--text-dim); }

/* ---------------------------------------------------------------- 选项组 */
.field { margin-bottom: 18px; }
.field > label.title {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
  transition: all .15s;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chip[aria-pressed="true"] {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  font-weight: 600;
}

.chip small { opacity: .75; font-size: 12px; }

.btn-primary {
  width: 100%;
  min-height: 52px;
  border: none;
  border-radius: var(--radius);
  background: var(--brand);
  color: #fff;
  font-size: 17px;
  font-weight: 650;
  cursor: pointer;
  transition: filter .15s, transform .08s;
}

.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:active { transform: scale(.99); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row > * { flex: 1 1 140px; }

.quick {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.quick button {
  min-height: 62px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  transition: border-color .15s, transform .08s;
}

.quick button:hover { border-color: var(--brand); }
.quick button:active { transform: scale(.98); }
.quick button b { font-weight: 620; }
.quick button span { font-size: 12px; color: var(--text-dim); }

/* ---------------------------------------------------------------- 答题页 */
.quiz-head {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-dim);
  padding: 12px 0 4px;
}

.progress {
  height: 6px;
  background: var(--bg-sunken);
  border-radius: 999px;
  overflow: hidden;
  margin: 6px 0 16px;
}

.progress i {
  display: block;
  height: 100%;
  background: var(--brand);
  width: 0;
  transition: width .25s;
}

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

.tag {
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--bg-sunken);
  color: var(--text-soft);
  white-space: nowrap;
}

.tag.lv3 { background: #e8f1ff; color: #1d5bd8; }
.tag.lv4 { background: #f0e9ff; color: #6a3fd0; }
[data-theme="dark"] .tag.lv3 { background: #1b2a45; color: #8fb4ff; }
[data-theme="dark"] .tag.lv4 { background: #2a2244; color: #c0a6ff; }

.src-official { background: var(--ok-soft); color: var(--ok); }
.src-consensus { background: var(--brand-soft); color: var(--brand); }
.src-referenced { background: var(--bg-sunken); color: var(--text-soft); }
.src-reviewed { background: #f0e9ff; color: #6a3fd0; }
.src-ai { background: var(--warn-soft); color: var(--warn); }
[data-theme="dark"] .src-reviewed { background: #2a2244; color: #c0a6ff; }

.stem {
  font-size: 17px;
  line-height: 1.7;
  font-weight: 550;
  margin: 4px 0 18px;
  word-break: break-word;
}

.options { display: flex; flex-direction: column; gap: 10px; }

.opt {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 14px 15px;
  min-height: var(--tap);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 16px;
  line-height: 1.55;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .06s;
  font-family: inherit;
}

.opt:hover:not(.locked) { border-color: var(--brand); }
.opt:active:not(.locked) { transform: scale(.995); }

.opt .key {
  flex: 0 0 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--bg-sunken);
  color: var(--text-soft);
  font-size: 14px;
  font-weight: 650;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}

.opt .txt { flex: 1; word-break: break-word; }

.opt.chosen { border-color: var(--brand); background: var(--brand-soft); }
.opt.chosen .key { background: var(--brand); color: #fff; }

.opt.correct { border-color: var(--ok); background: var(--ok-soft); }
.opt.correct .key { background: var(--ok); color: #fff; }

.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.wrong .key { background: var(--bad); color: #fff; }

.opt.locked { cursor: default; }

.feedback { margin-top: 16px; border-radius: var(--radius-sm); padding: 14px 15px; border: 1px solid var(--line); }
.feedback.ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.feedback.bad { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.feedback .verdict { font-weight: 680; font-size: 15px; margin-bottom: 6px; }
.feedback .verdict.ok { color: var(--ok); }
.feedback .verdict.bad { color: var(--bad); }
.feedback .ansline { font-size: 14px; margin-bottom: 8px; }
.feedback .exp { font-size: 14.5px; color: var(--text-soft); white-space: pre-wrap; }
.feedback .srcnote { font-size: 12.5px; color: var(--text-dim); margin-top: 10px; }

.qfoot {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 25;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
}

.qfoot-inner {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  gap: 10px;
  align-items: center;
}

.qfoot button {
  flex: 1;
  min-height: var(--tap);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
}

.qfoot button.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 620; }
.qfoot button:disabled { opacity: .4; }

/* ---------------------------------------------------------------- 答题卡 */
.sheet-btn { position: relative; }

.sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(10, 14, 20, .45);
  display: none;
  align-items: flex-end;
}

.sheet.open { display: flex; }

.sheet-body {
  background: var(--bg-soft);
  width: 100%;
  max-height: 72vh;
  border-radius: 18px 18px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  overflow: auto;
}

.sheet-body h3 { margin: 0 0 12px; font-size: 15px; }

.grid-nums { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 8px; }

.grid-nums button {
  min-height: 40px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}

.grid-nums button.ok { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.grid-nums button.bad { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.grid-nums button.done { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }
.grid-nums button.cur { outline: 2px solid var(--brand); outline-offset: 1px; }

/* ---------------------------------------------------------------- 列表页 */
.tabs { display: flex; gap: 8px; margin: 16px 0 8px; }

.tabs button {
  flex: 1;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--text-soft);
  font-size: 15px;
  cursor: pointer;
  font-family: inherit;
}

.tabs button[aria-selected="true"] { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 620; }

/* ---------------------------------------------------------------- 章节 */
details#secDetails > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  list-style: none;
  padding: 2px 0;
}

details#secDetails > summary::-webkit-details-marker { display: none; }

details#secDetails > summary::after {
  content: '展开';
  margin-left: auto;
  color: var(--brand);
  font-size: 13px;
  font-weight: 500;
}

details#secDetails[open] > summary::after { content: '收起'; }

details#secDetails .sum-title { font-size: 16px; font-weight: 650; }

details#secDetails .sum-state {
  font-size: 13px;
  color: var(--text-dim);
  background: var(--bg-sunken);
  border-radius: 999px;
  padding: 3px 10px;
}

.sec-group .chip { padding: 8px 12px; font-size: 13.5px; min-height: 36px; }

.sec-group { margin-bottom: 14px; }
.sec-group:last-child { margin-bottom: 0; }

.sec-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-dim);
}

.sec-head button {
  border: none;
  background: none;
  color: var(--brand);
  font-size: 12.5px;
  cursor: pointer;
  padding: 2px 4px;
  font-family: inherit;
}

.sec-head .sec-count { margin-left: auto; font-weight: 400; color: var(--text-dim); font-size: 12.5px; }

.chip.dim { opacity: .45; }

.list { display: flex; flex-direction: column; gap: 10px; }

.list-item {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
}

.list-item .lt { font-size: 15px; line-height: 1.6; word-break: break-word; }
.list-item .lm { font-size: 12.5px; color: var(--text-dim); margin-top: 8px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.list-item .lm b { font-weight: 600; }

.empty { text-align: center; color: var(--text-dim); padding: 40px 16px; font-size: 14.5px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%) translateY(10px);
  background: rgba(20, 26, 34, .93);
  color: #fff;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 60;
  max-width: 88vw;
  text-align: center;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.result { text-align: center; }
.result .score { font-size: 46px; font-weight: 720; line-height: 1.1; }
.result .score.ok { color: var(--ok); }
.result .score.bad { color: var(--bad); }

.kv { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 18px 0; }
.kv div { background: var(--bg-sunken); border-radius: var(--radius-sm); padding: 10px; }
.kv b { display: block; font-size: 20px; }
.kv span { font-size: 12px; color: var(--text-dim); }

.foot-note { color: var(--text-dim); font-size: 12.5px; text-align: center; padding: 24px 8px 8px; line-height: 1.8; }

table.src-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.src-table td { padding: 6px 4px; border-bottom: 1px solid var(--line); }
table.src-table td:last-child { text-align: right; color: var(--text-dim); }

@media (min-width: 720px) {
  .hero h1 { font-size: 30px; }
  .quick { grid-template-columns: repeat(4, 1fr); }
  .stat-row { gap: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
