/* 医学免疫学 · 自测练习 —— 与门户一致的素净编辑风（白纸 + 深青 accent） */
:root {
  --bg: #f7f7f6;
  --paper: #ffffff;
  --ink: #1f2421;
  --muted: #6b7168;
  --line: #e6e4de;
  --accent: #1b6e66;
  --accent-soft: #e8f1ef;
  --ok: #2e7d4f;
  --ok-soft: #e9f5ee;
  --bad: #b3453d;
  --bad-soft: #fbeeec;
  --radius: 16px;
}

* { box-sizing: border-box; }

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

.wrap {
  max-width: 780px;
  margin: 0 auto;
  padding: 0 20px 56px;
}

/* 顶栏 */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 0 10px;
}
.back {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
}
.back:hover { color: var(--accent); }
.brand {
  font-size: 13px;
  letter-spacing: .12em;
  color: var(--muted);
}

/* 标题 */
h1 {
  font-family: "Georgia", "Times New Roman", "Songti SC", "SimSun", serif;
  font-size: 42px;
  font-weight: 600;
  line-height: 1.15;
  margin: 18px 0 10px;
  letter-spacing: .01em;
}
.sub {
  color: var(--muted);
  margin: 0 0 22px;
  font-size: 15px;
  max-width: 620px;
}
.sec-title {
  font-family: "Georgia", "Songti SC", "SimSun", serif;
  font-size: 21px;
  font-weight: 600;
  margin: 36px 0 14px;
}

/* 统计磁贴 */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 0 0 22px;
}
.stat {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat b {
  font-family: "Georgia", "Songti SC", serif;
  font-size: 26px;
  font-weight: 600;
  color: var(--accent);
}
.stat span { font-size: 12.5px; color: var(--muted); }

/* 模式卡片 */
.mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
}
.mode {
  text-align: left;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  cursor: pointer;
  font: inherit;
  color: var(--ink);
  transition: border-color .15s, background .15s;
}
.mode:hover { border-color: var(--accent); background: var(--accent-soft); }
.mode span { display: block; font-weight: 600; font-size: 16px; }
.mode small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.mode:disabled { opacity: .45; cursor: not-allowed; }
.mode:disabled:hover { border-color: var(--line); background: var(--paper); }

/* 题型筛选 */
.type-filter {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 12px;
}
.tf {
  font: inherit;
  font-size: 13px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--muted);
  padding: 5px 14px;
  cursor: pointer;
  transition: all .12s;
}
.tf:hover { border-color: var(--accent); color: var(--accent); }
.tf.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* 主观题模式切换 */
.mode-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 14px;
}
.ms-label { font-size: 13px; color: var(--muted); }

/* 主观题直达入口卡 */
.subj-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 10px;
}
.subj-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 18px;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: border-color .15s, background .15s;
}
.subj-card:hover { border-color: var(--accent); background: var(--active); }
.subj-card b { display: block; font-size: 15.5px; font-weight: 600; color: var(--accent); }
.subj-card span { display: block; font-size: 12.5px; color: var(--muted); margin-top: 5px; line-height: 1.5; }
.subj-card em { display: block; font-style: normal; font-size: 12px; color: var(--muted); margin-top: 10px; }
.subj-card em i { font-style: normal; font-weight: 600; color: var(--text); }

/* 章节网格 */
.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 8px;
}
.chapter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 14px;
  cursor: pointer;
  font: inherit;
  font-size: 14.5px;
  color: var(--ink);
  text-align: left;
  transition: border-color .15s, background .15s;
}
.chapter:hover { border-color: var(--accent); background: var(--accent-soft); }
.chapter em { font-style: normal; color: var(--muted); font-size: 12.5px; white-space: nowrap; }

/* 卡片 */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px 28px;
}

/* 答题头部 */
.quiz-head { margin: 6px 0 16px; }
.progress {
  height: 6px;
  background: var(--line);
  border-radius: 99px;
  overflow: hidden;
}
#progressBar {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 99px;
  transition: width .25s ease;
}
.quiz-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
}
.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: 1px;
}
.dot.ok { background: var(--ok); }
.dot.bad { background: var(--bad); }

/* 题目 */
.q-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.tag {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.tag.ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); font-weight: 400; }
.stem {
  font-size: 20px;
  line-height: 1.55;
  font-weight: 600;
  margin: 2px 0 18px;
}

/* 选项 */
.options { display: flex; flex-direction: column; gap: 9px; }
.opt {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 15px;
  cursor: pointer;
  font: inherit;
  font-size: 15.5px;
  line-height: 1.55;
  color: var(--ink);
  transition: border-color .12s, background .12s;
}
.opt:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); }
.opt.selected { border-color: var(--accent); background: var(--accent-soft); }
.opt.selected .letter { background: var(--accent); border-color: var(--accent); color: #fff; }
.opt .letter {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: var(--bg);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.opt.correct { border-color: var(--ok); background: var(--ok-soft); }
.opt.correct .letter { background: var(--ok); border-color: var(--ok); color: #fff; }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.wrong .letter { background: var(--bad); border-color: var(--bad); color: #fff; }
.opt.dim { opacity: .55; }
.opt:disabled { cursor: default; }

/* 反馈 */
.feedback {
  margin-top: 18px;
  border-radius: 12px;
  padding: 14px 16px;
  background: var(--accent-soft);
  border: 1px solid #cfe3df;
}
.feedback.bad { background: var(--bad-soft); border-color: #eed3cf; }
.fb-title { font-weight: 700; margin-bottom: 4px; }
.feedback.bad .fb-title { color: var(--bad); }
.feedback:not(.bad) .fb-title { color: var(--ok); }
.fb-explain { font-size: 14.5px; color: #3d443f; }

/* 操作 */
.q-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 22px;
  gap: 10px;
}
.btn {
  font: inherit;
  font-size: 15px;
  border-radius: 10px;
  padding: 10px 20px;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  text-decoration: none;
  display: inline-block;
  transition: background .12s, border-color .12s;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #175d57; }
.btn.primary:disabled { opacity: .4; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--muted); border-color: transparent; }
.btn.ghost:hover { color: var(--accent); border-color: var(--line); }

.hint { font-size: 12.5px; color: var(--muted); text-align: center; margin: 14px 0 0; }

/* 自评题（名词解释/简答/论述） */
.self-area { margin-top: 20px; }
.btn.wide { width: 100%; padding: 12px; }
.self-answer {
  margin-top: 14px;
  background: var(--accent-soft);
  border: 1px solid #cfe3df;
  border-radius: 12px;
  padding: 16px 18px;
}
.sa-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: .1em;
  margin-bottom: 8px;
}
.sa-body {
  font-size: 15px;
  line-height: 1.8;
  color: #2a302c;
  white-space: pre-wrap;
  word-break: break-word;
}
.sa-hint {
  font-size: 13.5px;
  color: #4a5350;
  line-height: 1.7;
}
.self-buttons {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.self-label { font-size: 13.5px; color: var(--muted); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ok:hover { background: #256a42; }
.btn.bad { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.bad:hover { background: #96362f; }
.btn[hidden] { display: none; }
.self-buttons[hidden] { display: none; }

/* 结果页 */
.result-card { text-align: center; padding: 32px 28px; }
.ring {
  --p: 0;
  width: 132px;
  height: 132px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--line) 0);
  display: flex;
  align-items: center;
  justify-content: center;
}
.ring-in {
  width: 104px;
  height: 104px;
  border-radius: 50%;
  background: var(--paper);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
}
.ring-in b {
  font-family: "Georgia", "Songti SC", serif;
  font-size: 28px;
  color: var(--accent);
  line-height: 1.1;
}
.ring-in span { font-size: 12px; color: var(--muted); }
#resultTitle {
  font-family: "Georgia", "Songti SC", serif;
  font-size: 26px;
  margin: 4px 0 6px;
}
.result-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 20px;
}

/* 错题回顾 */
.wrong-list { display: flex; flex-direction: column; gap: 12px; }
.wrong-item {
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 3px solid var(--bad);
  border-radius: 12px;
  padding: 16px 18px;
}
.wrong-item .wq { font-weight: 600; margin-bottom: 8px; }
.wrong-item .wa { font-size: 14px; color: var(--muted); }
.wrong-item .wa b { color: var(--ok); font-weight: 600; }
.wrong-item .we { font-size: 13.5px; color: var(--muted); margin-top: 6px; }
.wa-answer {
  font-size: 13.5px;
  line-height: 1.7;
  color: #3d443f;
  background: var(--bg);
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 8px;
  max-height: 180px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.empty {
  color: var(--muted);
  font-size: 14.5px;
  background: var(--paper);
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 22px;
  text-align: center;
}

.source {
  font-size: 12.5px;
  color: #8b9088;
  margin-top: 30px;
  line-height: 1.6;
}
.foot {
  text-align: center;
  font-size: 12px;
  color: #a0a49c;
  margin-top: 40px;
}

@media (max-width: 560px) {
  .wrap { padding: 0 14px 44px; }
  h1 { font-size: 32px; }
  .card { padding: 20px 18px; }
  .stem { font-size: 18px; }
  .stats { grid-template-columns: repeat(3, 1fr); }
  .stat { padding: 10px 12px; }
  .stat b { font-size: 22px; }
  .quiz-meta { font-size: 12px; }
}
