/* ============================================================
   注安技术通关台 · 样章UI（MVP-1.3）
   方向：内容优先、简约明快（参考Apple/OpenAI克制风格，非复制品牌）
   ============================================================ */

:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --text: #1d1d1f;
  --text-2: #55575f;
  --text-3: #86868b;
  --border: #e3e3e8;
  --border-2: #d2d2d8;
  --accent: #245c8a;
  --accent-soft: #e8f0f7;
  --accent-text: #1d4f79;
  --ok: #2e6b4f;
  --ok-soft: #e6f2ec;
  --bad: #9c3d3d;
  --bad-soft: #f7e9e9;
  --warn-soft: #f4efdf;
  --radius: 12px;
  --radius-s: 8px;
  --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.03);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.hidden { display: none !important; }
.muted { color: var(--text-3); }
.no-scroll { overflow: hidden; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.ic { width: 20px; height: 20px; flex: 0 0 auto; }

/* ---------- 布局 ---------- */
.app {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  min-height: 100vh;
}
.side-nav {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.brand { font-size: 20px; font-weight: 700; letter-spacing: 0.2px; padding: 2px 10px 0; }
.brand span { color: var(--accent-text); }
.side-subject { font-size: 12.5px; color: var(--text-3); padding: 0 10px 12px; border-bottom: 1px solid var(--border); margin: 2px 0 10px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  border: 0; background: transparent; border-radius: var(--radius-s);
  padding: 9px 12px; text-align: left; font-size: 15px; color: var(--text-2);
}
.nav-item:hover { background: #f0f0f2; color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.side-progress { margin-top: auto; padding: 12px 10px 4px; }
.side-progress-title { font-size: 12.5px; color: var(--text-3); margin-bottom: 6px; }
.progress-track { height: 6px; border-radius: 3px; background: #ececf0; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); width: 0; transition: width 0.25s ease; }
.side-progress-num { font-size: 12.5px; color: var(--text-3); margin-top: 6px; }
.side-foot { font-size: 11.5px; color: var(--text-3); padding: 0 10px; margin: 8px 0 0; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 18px 28px 6px;
}
.topbar h1 { font-size: 22px; margin: 0; font-weight: 650; }
.content { padding: 14px 28px 48px; max-width: 1180px; width: 100%; }
.chip { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 4px 12px; font-size: 13px; }
.chip-verified { background: var(--ok-soft); color: var(--ok); }

/* ---------- 卡片与按钮 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-soft);
}
.card-title { font-size: 17px; font-weight: 650; margin: 0 0 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } }
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stat { text-align: center; padding: 10px 4px; }
.stat-num { font-size: 26px; font-weight: 700; letter-spacing: -0.3px; }
.stat-den { font-size: 15px; color: var(--text-3); font-weight: 400; }
.stat-lb { font-size: 13px; color: var(--text-3); margin-top: 2px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.hint { color: var(--text-3); font-size: 13.5px; margin: 10px 0 0; }

.btn {
  border: 1px solid transparent; border-radius: var(--radius-s);
  padding: 10px 18px; font-size: 15px; font-weight: 550;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #1d4f79; }
.btn-outline { background: var(--surface); border-color: var(--border-2); color: var(--text); }
.btn-outline:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-text); }
.btn-small { padding: 6px 12px; font-size: 14px; }
.row-right { display: flex; justify-content: flex-end; }

/* ---------- 标签 ---------- */
.tag {
  display: inline-block; border-radius: 6px; padding: 1px 8px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.3px; vertical-align: 1px;
}
.tag-fact { background: var(--accent-soft); color: var(--accent-text); }
.tag-device { background: #eef0f4; color: #4a5568; }
.tag-understand { background: #f1f1f3; color: var(--text-2); }
.tag-asked { background: #e7f0ee; color: #2f5f56; }
.tag-ext { background: #f2f0ea; color: #8a7a4a; }
.tag-fig { background: #efebf4; color: #6a5680; }
.tag-ok { background: var(--ok-soft); color: var(--ok); }
.tag-bad { background: var(--bad-soft); color: var(--bad); }
.ev-chip {
  display: inline-block; font-size: 12px; font-weight: 600;
  color: var(--accent-text); background: var(--accent-soft);
  border: 1px solid #cfe0ee; border-radius: 6px; padding: 1px 8px;
  cursor: pointer; margin: 2px 6px 2px 0;
}
.ev-chip:hover { border-color: var(--accent); }
.ev-line { margin-top: 6px; display: block; }

/* ---------- 知识点 ---------- */
.kp-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; align-items: start; }
.kp-layout > * { min-width: 0; }
@media (max-width: 1080px) { .kp-layout { grid-template-columns: minmax(0, 1fr); } }
.kp-aside { position: sticky; top: 14px; }
@media (max-width: 1080px) { .kp-aside { position: static; } }
.kp-toc { padding: 12px 14px; }
.toc-label { font-size: 12.5px; color: var(--text-3); font-weight: 600; }
#kp-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.kp-toc-btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--border); background: var(--surface);
  border-radius: 999px; padding: 6px 12px 6px 8px; font-size: 13.5px; color: var(--text-2);
  min-width: 0; max-width: 100%;
}
.kp-toc-btn:hover { border-color: var(--border-2); color: var(--text); }
.kp-toc-btn.active { background: var(--accent-soft); border-color: #bcd3e6; color: var(--accent-text); font-weight: 600; }
.kp-toc-btn > span:nth-child(2) { min-width: 0; }
.kp-no {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%; background: #eef0f4;
  font-size: 12px; font-weight: 700; color: var(--text-2);
}
.kp-toc-btn.active .kp-no { background: var(--accent); color: #fff; }
.kp-qn { font-size: 11.5px; color: var(--ok); flex: 0 0 auto; white-space: nowrap; }

.kp-head-row { display: flex; gap: 14px; }
.kp-head-row > div { min-width: 0; }
.kp-big-no {
  font-size: 34px; font-weight: 800; color: var(--border-2); line-height: 1;
  flex: 0 0 auto; letter-spacing: -1px;
}
.kp-head h2 { margin: 0 0 8px; font-size: 21px; font-weight: 700; }
.kp-what { margin: 0; color: var(--text-2); }
.kp-why { margin: 14px 0 0; padding: 12px 14px; background: #f7f7f9; border-radius: var(--radius-s); font-size: 14.5px; color: var(--text-2); }
.kp-sec h3 { font-size: 16.5px; margin: 0 0 12px; font-weight: 650; }
.sec-sub { font-size: 12.5px; color: var(--text-3); font-weight: 400; }

.dev-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.dev-card { min-width: 0; border: 1px solid var(--border); border-radius: var(--radius-s); padding: 14px; background: #fcfcfd; }
.dev-head { font-size: 15.5px; font-weight: 650; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dev-dl { margin: 0; display: grid; grid-template-columns: 66px 1fr; row-gap: 6px; font-size: 14px; }
.dev-dl dt { color: var(--text-3); }
.dev-dl dd { margin: 0; min-width: 0; color: var(--text); }

.fact-list, .conf-list, .asked-list, .ext-list { list-style: none; margin: 0; padding: 0; }
.fact-li { padding: 10px 0; border-top: 1px solid var(--border); }
.fact-li:first-child { border-top: 0; }
.fact-li p { margin: 4px 0 0; }
.conf-li, .asked-li { padding: 8px 0 8px 18px; position: relative; border-bottom: 1px dashed var(--border); }
.conf-li::before, .asked-li::before { content: ""; position: absolute; left: 2px; top: 16px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); opacity: 0.7; }
.conf-li b { font-weight: 650; }
.conf-li p, .asked-li { margin: 2px 0 0; color: var(--text-2); }
.ext-li { font-size: 14px; color: var(--text-3); padding-left: 18px; }
.qlink-row { display: flex; flex-wrap: wrap; gap: 10px; }

.aside-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.aside-card h4 { margin: 0 0 10px; font-size: 14.5px; font-weight: 650; }
.num-list { margin: 0; padding: 0; list-style: none; }
.num-list li { font-size: 13.5px; padding: 5px 0 5px 16px; position: relative; border-bottom: 1px dashed var(--border); }
.num-list li:last-child { border-bottom: 0; }
.num-list li::before { content: ""; position: absolute; left: 0; top: 13px; width: 6px; height: 6px; border-radius: 2px; background: var(--accent); opacity: 0.55; }
.ev-index { list-style: none; margin: 0; padding: 0; }
.ev-item { font-size: 13px; padding: 7px 0; border-bottom: 1px dashed var(--border); }
.ev-item:last-child { border-bottom: 0; }
.ev-id { font-weight: 700; color: var(--accent-text); display: block; }
.ev-topic { color: var(--text-2); display: block; }
.ev-page { color: var(--text-3); font-size: 12px; }
.aside-note { font-size: 12px; color: var(--text-3); margin: 10px 0 0; }

/* ---------- 图示 ---------- */
.diagram-figure { margin: 6px 0 0; border: 1px solid var(--border); border-radius: var(--radius-s); padding: 14px; background: #fcfcfd; }
.diagram-figure figcaption { font-size: 13.5px; color: var(--text-2); margin-bottom: 10px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.btn-zoom {
  margin-top: 10px; border: 1px solid var(--border-2); background: var(--surface);
  border-radius: 6px; font-size: 13px; padding: 5px 12px; color: var(--text-2);
}
.btn-zoom:hover { border-color: var(--accent); color: var(--accent-text); }
.cmp-table { display: block; width: 100%; overflow-x: auto; font-size: 13.5px; }
.cmp-row { display: grid; grid-template-columns: 96px repeat(3, minmax(170px, 1fr)); }
.cmp-row > span { padding: 8px 10px; border-top: 1px solid var(--border); border-right: 1px solid var(--border); background: #fff; }
.cmp-row > span:first-child { border-left: 1px solid var(--border); }
.cmp-head > span { background: #f4f6f8; font-weight: 650; color: var(--text-2); }
.chain { margin: 4px 0 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.chain li { display: grid; grid-template-columns: 84px 1fr 2.2fr; gap: 12px; align-items: baseline; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-s); background: #fff; font-size: 14px; }
.chain b { color: var(--accent-text); font-weight: 700; }
.chain li span { color: var(--text-2); }
@media (max-width: 640px) {
  .cmp-row { grid-template-columns: 78px repeat(3, minmax(150px, 1fr)); }
  .chain li { grid-template-columns: 1fr; gap: 2px; }
}

/* ---------- 答题 ---------- */
.quiz-top { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; flex-wrap: wrap; }
.q-progress { font-size: 15px; color: var(--text-3); }
.q-progress span { font-size: 22px; font-weight: 700; color: var(--text); }
.q-meta { font-size: 13.5px; color: var(--text-2); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.q-card h2 { font-size: 18px; font-weight: 600; line-height: 1.55; margin: 4px 0 16px; }
.opt-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.opt {
  display: flex; gap: 12px; align-items: flex-start;
  border: 1px solid var(--border-2); border-radius: var(--radius-s);
  padding: 12px 14px; background: #fff; font-size: 15.5px; line-height: 1.5;
}
.opt-lb {
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%;
  border: 1px solid var(--border-2); display: inline-flex; align-items: center; justify-content: center;
  font-size: 13.5px; font-weight: 650; color: var(--text-2); margin-top: 1px;
}
.opt:hover { border-color: var(--accent); }
.opt-selected { border-color: var(--accent); background: var(--accent-soft); }
.opt-selected .opt-lb { background: var(--accent); border-color: var(--accent); color: #fff; }
.opt-correct { border-color: var(--ok); background: var(--ok-soft); }
.opt-correct .opt-lb { background: var(--ok); border-color: var(--ok); color: #fff; }
.opt-wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt-wrong .opt-lb { background: var(--bad); border-color: var(--bad); color: #fff; }
.opt-done { cursor: default; }

.exp-box { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 14px; }
.exp-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.exp-title { font-weight: 650; font-size: 15px; }
.exp-text { margin: 0 0 8px; font-size: 15px; color: var(--text); }
.w-list { display: grid; gap: 6px; margin: 8px 0; }
.w-item { font-size: 14px; background: #f7f7f9; border-radius: 6px; padding: 8px 12px; }
.w-item b { color: var(--text-2); }
.q-source { font-size: 12.5px; color: var(--text-3); margin: 10px 0 0; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.quiz-actions {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 14px; padding: 12px 0;
}
.q-score { margin-left: auto; color: var(--text-3); font-size: 14px; }
.empty-card { text-align: center; padding: 40px 20px; }
.empty-card p { font-size: 17px; }

/* ---------- 错题与复习 ---------- */
.wrong-list { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 10px; }
.wrong-item {
  width: 100%; text-align: left; border: 1px solid var(--border);
  border-radius: var(--radius-s); background: #fff; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 4px;
}
.wrong-item:hover { border-color: var(--accent); }
.wrong-meta { font-size: 12.5px; color: var(--ok); font-weight: 600; }
.wrong-q { font-size: 15px; }
.review-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 640px) { .review-grid { grid-template-columns: repeat(2, 1fr); } }
.review-day {
  border: 1px solid var(--border); border-radius: var(--radius-s); background: #fff;
  padding: 16px 12px; text-align: left; display: flex; flex-direction: column; gap: 4px;
}
.review-day:hover { border-color: var(--accent); }
.review-day.done { background: var(--ok-soft); border-color: #bfddcc; }
.rd-label { font-weight: 650; }
.rd-status { font-size: 12.5px; color: var(--text-3); }
.review-day.done .rd-status { color: var(--ok); }
.rd-desc { font-size: 12.5px; color: var(--text-3); }

/* ---------- 放大层 ---------- */
.zoom-overlay {
  position: fixed; inset: 0; background: rgba(20, 22, 26, 0.55);
  display: flex; align-items: center; justify-content: center; z-index: 60; padding: 20px;
}
.zoom-body {
  background: var(--surface); border-radius: 14px; max-width: 960px; width: 100%;
  max-height: 88vh; overflow: auto; padding: 20px;
}
.zoom-copy .btn-zoom { display: none; }
.zoom-close {
  position: fixed; top: 16px; right: 16px; width: 40px; height: 40px;
  border-radius: 50%; border: 0; background: rgba(255, 255, 255, 0.92);
  display: inline-flex; align-items: center; justify-content: center;
}
.ev-detail h3 { margin-top: 0; }
.ev-detail blockquote { border-left: 3px solid var(--border-2); margin: 10px 0 0; padding: 4px 12px; color: var(--text-2); }

/* ---------- 底部导航（手机） ---------- */
.bottom-nav {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: rgba(255, 255, 255, 0.96); border-top: 1px solid var(--border);
  backdrop-filter: saturate(1.4) blur(8px);
  padding-bottom: env(safe-area-inset-bottom);
}
.bn-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: transparent; border: 0; padding: 8px 4px 10px; font-size: 11.5px; color: var(--text-3);
}
.bn-item .ic { width: 22px; height: 22px; }
.bn-item.active { color: var(--accent-text); font-weight: 600; }

@media (max-width: 899px) {
  .app { display: block; }
  .side-nav { display: none; }
  .content { padding: 10px 16px 84px; }
  .topbar { padding: 14px 16px 4px; }
  .bottom-nav { display: flex; }
  #kp-list { flex-direction: column; align-items: stretch; }
  .kp-toc-btn { width: 100%; justify-content: flex-start; min-height: 44px; }
  .quiz-actions { position: sticky; bottom: 64px; background: var(--bg); border-radius: 10px; padding: 8px 2px; z-index: 5; }
  .quiz-actions .btn { min-height: 44px; }
  .quiz-actions.qa-static { position: static; }
  .q-card h2 { font-size: 16.5px; }
}

@supports (padding-bottom: env(safe-area-inset-bottom)) {
  @media (max-width: 899px) {
    .content { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
    .quiz-actions { bottom: calc(64px + env(safe-area-inset-bottom)); }
  }
}

/* 200% 文字缩放等大字号场景的兜底 */
@media (min-width: 1200px) {
  .content { max-width: 1240px; }
}
