:root {
  --bg: #f1f5f4;
  --card: #fdfffe;
  --ink: #17292a;
  --muted: #647a78;
  --faint: #9fb2af;
  --line: #dbe5e3;
  --line-strong: #b9cdc9;
  --accent: #0c7166;        /* 试剂青 */
  --accent-weak: #e2f1ee;
  --green: #2e7d54;
  --green-weak: #e6f2ea;
  --red: #c0563a;
  --red-weak: #f9ebe5;
  --radius: 5px;
  --serif: "Noto Serif SC", "Source Han Serif SC", "STZhongsong", "SimSun", Georgia, serif;
  --sans: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  font-size: 15px;
}
/* 实验记录纸横线质感 */
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image: repeating-linear-gradient(0deg, transparent, transparent 31px, rgba(90,130,125,.05) 31px, rgba(90,130,125,.05) 32px);
}
#app { max-width: 700px; margin: 0 auto; padding-bottom: 70px; position: relative; z-index: 1; }
.hidden { display: none !important; }

/* ---------- 顶栏 ---------- */
#topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 11px 16px;
  background: rgba(246,244,238,.94); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line-strong);
}
.icon-btn {
  width: 34px; height: 34px; border: 1px solid var(--line-strong); border-radius: 4px;
  background: transparent; font-size: 17px; cursor: pointer; color: var(--ink); flex: none;
  font-family: var(--serif); line-height: 1;
}
.icon-btn:active { background: var(--line); }
.topbar-title {
  font-family: var(--serif); font-weight: 700; font-size: 16.5px; letter-spacing: .06em;
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar-right { flex: none; display: flex; gap: 8px; }

/* ---------- 视图 ---------- */
.view { padding: 20px 18px; animation: fadein .16s ease; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.view-title {
  font-family: var(--serif); font-size: 14px; color: var(--muted); font-weight: 600;
  letter-spacing: .12em; margin: 22px 0 10px;
  display: flex; align-items: center; gap: 10px;
}
.view-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.view-title:first-child { margin-top: 6px; }

/* ---------- 首页 ---------- */
.hero { padding: 34px 0 8px; border-bottom: 1px solid var(--line-strong); }
.hero-kicker {
  font-size: 12px; letter-spacing: .22em; color: var(--muted); margin-bottom: 10px;
}
.hero-row { display: flex; align-items: center; gap: 16px; }
.hero-seal {
  flex: none; width: 52px; height: 52px;
  border: 2px solid var(--accent); border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--serif); font-weight: 700; font-size: 20px; color: var(--accent);
  letter-spacing: .05em; line-height: 1.1; padding: 4px;
  box-shadow: inset 0 0 0 1px rgba(12,113,102,.25);
}
.hero h1 {
  font-family: var(--serif); font-size: 30px; font-weight: 700; letter-spacing: .1em; line-height: 1.2;
}
.hero-sub { color: var(--muted); font-size: 13px; margin-top: 6px; line-height: 1.7; }
.bank-summary {
  margin-top: 16px; padding-bottom: 16px;
  font-size: 12.5px; color: var(--muted); letter-spacing: .02em;
}
.bank-summary b { color: var(--ink); font-weight: 600; }
.bank-summary .dot { margin: 0 7px; color: var(--faint); }

.menu-list { margin-top: 6px; }
.menu-card {
  display: flex; align-items: center; gap: 16px; width: 100%;
  padding: 17px 8px; text-align: left; cursor: pointer;
  background: transparent; border: none; border-bottom: 1px solid var(--line);
  font-family: inherit; color: var(--ink);
}
.menu-card:active { background: rgba(12,113,102,.05); }
.menu-glyph {
  flex: none; width: 42px; height: 42px;
  border: 1.5px solid var(--accent); border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--serif); font-weight: 700; font-size: 19px; color: var(--accent);
}
.menu-body { flex: 1; min-width: 0; }
.menu-name { font-size: 16px; font-weight: 600; letter-spacing: .04em; }
.menu-desc { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.menu-arrow { flex: none; color: var(--faint); font-size: 18px; font-family: var(--serif); }

/* ---------- 通用控件 ---------- */
.btn-primary {
  display: block; width: 100%; margin: 24px 0 10px; padding: 13px;
  background: var(--ink); color: var(--bg); border: none; border-radius: 4px;
  font-size: 15.5px; font-weight: 600; cursor: pointer; font-family: inherit;
  letter-spacing: .2em; text-indent: .2em;
}
.btn-primary:active { opacity: .85; }
.btn-primary:disabled { background: var(--faint); cursor: not-allowed; }
.btn-ghost, .btn-danger {
  padding: 8px 13px; border-radius: 4px; font-size: 13px; cursor: pointer; font-family: inherit;
  background: transparent; border: 1px solid var(--line-strong); color: var(--ink);
}
.btn-danger { color: var(--red); border-color: #d8bfb4; }
.seg { display: flex; gap: 0; border: 1px solid var(--line-strong); border-radius: 4px; overflow: hidden; }
.seg-btn {
  flex: 1; padding: 10px 8px; border: none; background: transparent;
  font-size: 14px; cursor: pointer; color: var(--muted); font-family: inherit;
  border-right: 1px solid var(--line);
}
.seg-btn:last-child { border-right: none; }
.seg-btn.active { background: var(--ink); color: var(--bg); font-weight: 600; }

/* ---------- 专项题型列表 ---------- */
.type-list { display: flex; flex-direction: column; }
.type-item {
  display: flex; align-items: baseline; gap: 12px; padding: 15px 8px;
  background: transparent; border: none; border-bottom: 1px solid var(--line);
  cursor: pointer; font-family: inherit; font-size: 15px; text-align: left; color: var(--ink);
}
.type-item:active { background: rgba(12,113,102,.05); }
.type-item .t-idx {
  font-family: var(--serif); color: var(--accent); font-size: 14px; width: 20px; flex: none;
}
.type-item .t-name { font-weight: 600; letter-spacing: .04em; }
.type-item .t-meta { color: var(--muted); font-size: 12.5px; margin-left: auto; }
.type-item.active .t-name { color: var(--accent); }
.type-item.active::before { content: "▸"; color: var(--accent); margin-right: -8px; }

/* ---------- 组卷配置表 ---------- */
.exam-cfg-table { display: flex; flex-direction: column; border-top: 1px solid var(--line-strong); }
.exam-cfg-row {
  display: flex; align-items: center; gap: 10px; padding: 13px 4px;
  border-bottom: 1px solid var(--line);
}
.exam-cfg-row .r-name { width: 76px; font-weight: 600; font-size: 14.5px; letter-spacing: .03em; }
.exam-cfg-row input[type=number] {
  width: 60px; padding: 7px 4px; border: 1px solid var(--line-strong); border-radius: 4px;
  font-size: 15px; text-align: center; font-family: inherit; background: var(--card); color: var(--ink);
}
.exam-cfg-row .r-label { font-size: 12px; color: var(--muted); }
.exam-cfg-row .r-avail { font-size: 12px; color: var(--faint); margin-left: auto; }
.exam-total {
  text-align: center; margin-top: 20px; color: var(--muted); font-size: 13.5px; letter-spacing: .05em;
}
.exam-total b { color: var(--accent); font-size: 20px; font-family: var(--serif); margin: 0 2px; }

/* ---------- 刷题界面 ---------- */
#quiz-progress-wrap { margin-bottom: 14px; }
.progress-text {
  font-size: 12.5px; color: var(--muted); margin-bottom: 7px;
  display: flex; justify-content: space-between; letter-spacing: .08em;
}
.progress-bar { height: 3px; background: var(--line); border-radius: 0; overflow: hidden; }
#quiz-progress-fill { height: 100%; background: var(--accent); width: 0; transition: width .25s ease; }

.quiz-card-box {
  background: var(--card); border: 1px solid var(--line-strong); border-radius: 6px;
  padding: 20px 18px;
}
.q-type-tag {  display: inline-block; font-size: 11.5px; padding: 2px 8px; border-radius: 3px;
  border: 1px solid var(--line-strong); color: var(--muted); letter-spacing: .1em; margin-bottom: 12px;
}
.q-type-tag.q-cat-tag { color: var(--accent); border-color: var(--accent-weak); background: var(--accent-weak); margin-left: 6px; }

/* 搜索页 */
.search-wrap input[type="search"] {
  width: 100%; padding: 12px 14px; font-size: 15px; font-family: inherit;
  border: 1px solid var(--line-strong); border-radius: 4px; background: var(--card); color: var(--ink);
}
.search-wrap input[type="search"]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-weak); }
.search-count { font-size: 13px; color: var(--muted); margin: 14px 2px 8px; }
.search-item {
  display: flex; align-items: baseline; gap: 8px; padding: 11px 4px;
  border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.search-item .si-tag {
  flex: none; font-size: 11px; padding: 1px 6px; border-radius: 3px;
  border: 1px solid var(--line-strong); color: var(--muted); letter-spacing: .05em;
}
.search-item .si-cat { color: var(--accent); border-color: var(--accent-weak); background: var(--accent-weak); }
.search-item .si-stem { flex: 1 1 100%; font-size: 13.5px; color: var(--ink); line-height: 1.7; }
.q-stem { font-size: 16px; line-height: 1.9; white-space: pre-wrap; margin-bottom: 18px; }

.q-options { display: flex; flex-direction: column; gap: 9px; }
.opt-btn {
  display: flex; gap: 11px; align-items: flex-start; text-align: left; width: 100%;
  padding: 11px 13px; border-radius: 4px; border: 1px solid var(--line);
  background: transparent; cursor: pointer; font-size: 15px; line-height: 1.65; font-family: inherit;
  color: var(--ink); transition: border-color .1s, background .1s;
}
.opt-btn .opt-key {
  flex: none; min-width: 22px; height: 22px; padding: 0 4px; border-radius: 3px;
  border: 1px solid var(--line-strong);
  display: flex; align-items: center; justify-content: center;
  font-size: 12.5px; font-weight: 600; color: var(--muted); margin-top: 2px;
}
.opt-btn.selected { border-color: var(--ink); background: rgba(39,35,27,.04); }
.opt-btn.selected .opt-key { border-color: var(--ink); color: var(--ink); background: var(--ink); color: var(--bg); }
.opt-btn.correct { border-color: var(--green); background: var(--green-weak); }
.opt-btn.correct .opt-key { border-color: var(--green); background: var(--green); color: #fff; }
.opt-btn.wrong { border-color: var(--red); background: var(--red-weak); }
.opt-btn.wrong .opt-key { border-color: var(--red); background: var(--red); color: #fff; }
.opt-btn:disabled { cursor: default; }

.q-feedback {
  margin-top: 15px; padding: 12px 14px; border-radius: 4px; font-size: 14px; line-height: 1.8;
  border-left: 3px solid;
}
.q-feedback.ok { background: var(--green-weak); border-color: var(--green); color: var(--green); }
.q-feedback.no { background: var(--red-weak); border-color: var(--red); color: var(--red); }
.q-feedback .fb-title { font-weight: 700; margin-bottom: 3px; letter-spacing: .04em; }
.q-feedback .fb-answer { color: var(--ink); }

.subjective-answer {
  margin-top: 15px; background: var(--card); border: 1px dashed var(--line-strong);
  border-radius: 4px; padding: 14px 16px; font-size: 14.5px; line-height: 1.9; white-space: pre-wrap;
}
.subjective-answer .sa-title {
  font-family: var(--serif); font-weight: 700; color: var(--accent); margin-bottom: 8px; letter-spacing: .1em;
}

.self-grade-row { display: flex; gap: 10px; margin-top: 15px; }
.self-grade-row button {
  flex: 1; padding: 11px; border-radius: 4px; font-size: 14.5px; font-weight: 600; cursor: pointer;
  font-family: inherit; letter-spacing: .1em; background: transparent;
}
.self-grade-row .sg-ok { border: 1px solid var(--green); color: var(--green); }
.self-grade-row .sg-no { border: 1px solid var(--red); color: var(--red); }
.self-grade-row button:active { opacity: .8; }

/* 主观题临时草稿输入框 */
.draft-box { margin-top: 15px; }
.draft-box textarea {
  width: 100%; min-height: 120px; resize: vertical;
  background: var(--card); border: 1px solid var(--line-strong); border-radius: 4px;
  padding: 12px 14px; font-family: var(--sans); font-size: 14.5px; line-height: 1.8;
  color: var(--ink);
}
.draft-box textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-weak); }
.draft-box textarea::placeholder { color: var(--faint); }
.draft-actions { display: flex; gap: 10px; margin-top: 12px; }
.draft-actions .btn-primary { flex: 1.4; }
.draft-actions .btn-ghost { flex: 1; }
.draft-note { margin-top: 8px; font-size: 12px; color: var(--faint); text-align: center; letter-spacing: .05em; }
.my-draft {
  margin-top: 15px; background: var(--accent-weak); border-left: 3px solid var(--accent);
  border-radius: 4px; padding: 12px 14px; font-size: 14.5px; line-height: 1.9; white-space: pre-wrap;
}
.my-draft .sa-title { color: var(--accent); font-family: var(--serif); font-weight: 700; margin-bottom: 8px; letter-spacing: .1em; font-size: 13px; }
.cmp-result { margin-top: 14px; }
.cmp-meter {
  height: 8px; background: var(--line); border-radius: 4px; overflow: hidden;
}
.cmp-fill { height: 100%; border-radius: 4px; transition: width .4s ease; }
.cmp-fill.hi { background: var(--green); }
.cmp-fill.mid { background: var(--accent); }
.cmp-fill.low { background: var(--red); }
.cmp-note { margin-top: 8px; font-size: 13px; color: var(--muted); line-height: 1.7; }
.cmp-note b { color: var(--ink); }
.cmp-note span { font-size: 12px; color: var(--faint); }

#quiz-nav { display: flex; gap: 10px; margin-top: 15px; }
#quiz-nav button {
  flex: 1; padding: 12px; border-radius: 4px; font-size: 15px; font-weight: 600;
  cursor: pointer; font-family: inherit; letter-spacing: .1em;
  border: 1px solid var(--line-strong); background: var(--card); color: var(--ink);
}
#quiz-nav .nav-main { background: var(--ink); border-color: var(--ink); color: var(--bg); }
#quiz-nav button:disabled { opacity: .35; cursor: default; }

/* 答题卡 */
#answer-sheet {
  margin-top: 16px; background: var(--card); border: 1px solid var(--line-strong);
  border-radius: 6px; padding: 16px;
}
#answer-sheet .sheet-title { font-family: var(--serif); font-weight: 700; font-size: 14.5px; letter-spacing: .12em; }
.sheet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 7px; margin-top: 12px; }
.sheet-cell {
  aspect-ratio: 1; border-radius: 3px; border: 1px solid var(--line); background: transparent;
  font-size: 12.5px; cursor: pointer; font-family: inherit; color: var(--muted);
}
.sheet-cell.answered { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.sheet-cell.current { outline: 2px solid var(--ink); outline-offset: 1px; }
.sheet-legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin-top: 12px; }
.sheet-legend i { display: inline-block; width: 11px; height: 11px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; border: 1px solid var(--line-strong); }
.sheet-legend i.on { border-color: var(--accent); background: var(--accent-weak); }

/* ---------- 结果页 ---------- */
.result-hero { text-align: center; padding: 34px 0 14px; }
.result-label { font-size: 12px; letter-spacing: .3em; color: var(--muted); margin-bottom: 12px; }
.result-score { font-family: var(--serif); font-size: 58px; font-weight: 700; color: var(--accent); line-height: 1; }
.result-score .u { font-size: 16px; font-weight: 500; color: var(--muted); letter-spacing: .05em; }
.result-sub { color: var(--muted); font-size: 13.5px; margin-top: 14px; line-height: 2; }
.result-table {
  width: 100%; border-collapse: collapse; margin-top: 18px;
  border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line-strong);
}
.result-table th, .result-table td {
  padding: 12px 14px; font-size: 13.5px; text-align: left; border-bottom: 1px solid var(--line);
}
.result-table tr:last-child td { border-bottom: none; }
.result-table th { color: var(--muted); font-weight: 600; font-size: 12px; letter-spacing: .12em; }

/* ---------- 统计 ---------- */
.stat-cards { display: flex; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--card); }
.stat-card { flex: 1; padding: 16px 6px; text-align: center; border-right: 1px solid var(--line); }
.stat-card:last-child { border-right: none; }
.stat-card .v { font-family: var(--serif); font-size: 24px; font-weight: 700; color: var(--ink); }
.stat-card .v small { font-size: 12px; color: var(--faint); font-weight: 500; }
.stat-card .l { font-size: 11.5px; color: var(--muted); margin-top: 4px; letter-spacing: .1em; }
.stat-section { margin-top: 24px; }
.stat-section h3 {
  font-family: var(--serif); font-size: 14px; letter-spacing: .1em; margin-bottom: 12px;
  display: flex; align-items: center; gap: 10px;
}
.stat-section h3::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.bar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 11px; }
.bar-row .b-label { width: 40px; font-size: 13px; flex: none; color: var(--muted); }
.bar-row .b-track { flex: 1; height: 14px; background: var(--line); border-radius: 2px; overflow: hidden; }
.bar-row .b-fill { height: 100%; border-radius: 2px; background: var(--accent); transition: width .3s ease; }
.bar-row .b-fill.mid { background: #b28a3d; }
.bar-row .b-fill.low { background: var(--red); }
.bar-row .b-val { width: 56px; font-size: 12.5px; color: var(--muted); text-align: right; flex: none; }
.exam-hist { border-top: 1px solid var(--line-strong); }
.exam-hist-item {
  display: flex; align-items: center; padding: 13px 4px; border-bottom: 1px solid var(--line); gap: 14px;
}
.exam-hist-item .eh-score { font-family: var(--serif); font-size: 21px; font-weight: 700; color: var(--accent); width: 76px; flex: none; }
.exam-hist-item .eh-score small { font-size: 11px; color: var(--faint); font-weight: 500; }
.exam-hist-item .eh-info { flex: 1; font-size: 12.5px; color: var(--muted); line-height: 1.7; }
.empty-tip { text-align: center; color: var(--muted); font-size: 13.5px; padding: 30px 0; line-height: 2; }
.danger-zone {
  display: flex; gap: 8px; flex-wrap: wrap; margin-top: 30px; padding-top: 18px;
  border-top: 1px dashed var(--line-strong);
}

/* ---------- 错题本 ---------- */
.sub-list { display: flex; flex-direction: column; }
.sub-item {
  display: flex; align-items: center; gap: 12px; padding: 16px 8px;
  background: transparent; border: none; border-bottom: 1px solid var(--line);
  cursor: pointer; font-family: inherit; text-align: left; font-size: 14.5px; color: var(--ink);
}
.sub-item:active { background: rgba(12,113,102,.05); }
.sub-item .s-count { margin-left: auto; color: var(--muted); font-size: 12.5px; }
.sub-item .s-arrow { color: var(--faint); font-family: var(--serif); font-size: 17px; }

/* ---------- 底部导航 ---------- */
#bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  max-width: 700px; margin: 0 auto; display: flex;
  background: rgba(246,244,238,.96); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line-strong); padding-bottom: env(safe-area-inset-bottom);
}
#bottom-nav button {
  flex: 1; padding: 11px 0 12px; background: none; border: none; cursor: pointer;
  font-size: 12px; color: var(--muted); font-family: var(--serif); letter-spacing: .2em;
}
#bottom-nav button:active { color: var(--accent); }

/* ---------- Toast ---------- */
#toast {
  position: fixed; bottom: 88px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 20px;
  border-radius: 4px; font-size: 13.5px; z-index: 99; white-space: nowrap; letter-spacing: .04em;
}

@media (max-width: 480px) {
  .view { padding: 16px 14px; }
  .hero h1 { font-size: 26px; }
}

/* 首页搜索区 */
.home-search { margin-top: 16px; }

/* 多选 chips（知识点 / 题型组合筛选） */
.chip-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line-strong); background: var(--card); color: var(--ink);
  padding: 7px 11px; font-size: 13px; border-radius: 4px; font-family: var(--sans);
  letter-spacing: .02em; text-align: left;
}
.chip i { font-style: normal; color: var(--muted); font-size: 11px; margin-left: 4px; }
.chip.active { border-color: var(--accent); color: var(--accent); background: var(--accent-weak); }
.chip.active i { color: var(--accent); opacity: .75; }
.chip:disabled { opacity: .38; }
.chip:active { opacity: .8; }

/* 视图小标题旁提示 */
.title-hint { font-size: 11.5px; color: var(--faint); font-weight: 400; letter-spacing: .05em; margin-left: 4px; }
