/* ========== 颜色：浅色（默认）/ 深色 / 克莱因蓝 / 樱花粉 ==========
 * 页面右上角「配色」可以切换；「跟随系统」时按手机的深浅色模式显示。
 */
:root {
  --bg: #f5f7f4;
  --surface: #ffffff;
  --surface-2: #eef3ef;
  --text: #1b2a21;
  --text-2: #5a6b60;
  --text-3: #8a988f;
  --line: #dde5df;
  --brand: #2f8f5b;
  --brand-ink: #ffffff;
  --brand-soft: #e3f3ea;
  --ok: #2f8f5b;
  --ok-soft: #e3f3ea;
  --bad: #d14848;
  --bad-soft: #fbe9e7;
  --warn: #c98a12;
  --warn-soft: #fbf1dc;
  --blue: #3a78c9;
  --blue-soft: #e5eefa;
  --ex: #e0553a;          /* 兴奋 / 负电位 */
  --auxin: #e89b1c;       /* 生长素 */
  --agar: #f3d98b;
  --foil: #a9b1b8;
  --plant: #6cb24a;
  --plant-dark: #4d8a33;
  --root: #b0753a;        /* 生长素曲线：根 */
  --bud: #4d8a33;         /* 生长素曲线：芽 */
  --on-ok: #ffffff;       /* 绿色 / 红色圆点上的文字 */
  --on-ch: #ffffff;       /* 章节色圆点上的文字 */
  --knob: #ffffff;        /* 开关的圆钮 */
  /* 五章的章节色 */
  --c1: #2a9d8f;
  --c2: #7b61ff;
  --c3: #e76f51;
  --c4: #3b82c4;
  --c5: #5a9e3a;
  --shadow: 0 1px 2px rgba(20, 40, 30, .06), 0 6px 20px rgba(20, 40, 30, .05);
  --radius: 16px;
  --radius-sm: 10px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="klein"]):not([data-theme="pink"]) {
    --bg: #121714;
    --surface: #1b221e;
    --surface-2: #232c27;
    --text: #e6ede8;
    --text-2: #a3b1a8;
    --text-3: #75847b;
    --line: #2e3933;
    --brand: #4cb67c;
    --brand-ink: #0d1a12;
    --brand-soft: #1e3328;
    --ok: #5cc28a;
    --ok-soft: #1c3427;
    --bad: #ef6b6b;
    --bad-soft: #3a2222;
    --warn: #e2b04a;
    --warn-soft: #3a3020;
    --blue: #6fa3e8;
    --blue-soft: #1f2c3d;
    --ex: #ff7a5c;
    --agar: #b89a45;
    --foil: #7d868e;
    --plant: #6fbf4c;
    --plant-dark: #4f9234;
    --root: #d19556;
    --bud: #6fbf4c;
    --on-ok: #0d1a12;
    --c2: #9483ff;
    --c4: #5b9ad6;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121714; --surface: #1b221e; --surface-2: #232c27; --text: #e6ede8; --text-2: #a3b1a8;
  --text-3: #75847b; --line: #2e3933; --brand: #4cb67c; --brand-ink: #0d1a12; --brand-soft: #1e3328;
  --ok: #5cc28a; --ok-soft: #1c3427; --bad: #ef6b6b; --bad-soft: #3a2222; --warn: #e2b04a;
  --warn-soft: #3a3020; --blue: #6fa3e8; --blue-soft: #1f2c3d; --ex: #ff7a5c; --agar: #b89a45;
  --foil: #7d868e; --plant: #6fbf4c; --plant-dark: #4f9234; --root: #d19556; --bud: #6fbf4c;
  --on-ok: #0d1a12; --c2: #9483ff; --c4: #5b9ad6;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

/* 樱花粉：浅粉底色、白色卡片、玫瑰粉按钮（按钮上的白字保证对比度够） */
:root[data-theme="pink"] {
  --bg: #fff4f6;
  --surface: #ffffff;
  --surface-2: #fde8ee;
  --text: #3a1d2a;
  --text-2: #7d5566;
  --text-3: #b08696;
  --line: #f5d4de;
  --brand: #cc3d6b;
  --brand-ink: #ffffff;
  --brand-soft: #fde2ea;
  --ok: #2e9468;
  --ok-soft: #e1f4ea;
  --bad: #d23c3c;
  --bad-soft: #fde6e4;
  --c2: #8b5cf6;
  --c3: #e8743b;
  --shadow: 0 1px 2px rgba(120, 40, 70, .06), 0 6px 20px rgba(120, 40, 70, .07);
  color-scheme: light;
}

/* 克莱因蓝：页面是国际克莱因蓝 #002FA7，读字的卡片用更深的蓝，按钮用白色 */
:root[data-theme="klein"] {
  --bg: #002fa7;
  --surface: #06237f;
  --surface-2: rgba(255, 255, 255, .10);
  --text: #ffffff;
  --text-2: #c9d5ff;
  --text-3: #92a6e8;
  --line: rgba(255, 255, 255, .17);
  --brand: #ffffff;
  --brand-ink: #002fa7;
  --brand-soft: rgba(255, 255, 255, .13);
  --ok: #5ce1a0;
  --ok-soft: rgba(92, 225, 160, .17);
  --bad: #ff9090;
  --bad-soft: rgba(255, 144, 144, .17);
  --warn: #ffd166;
  --warn-soft: rgba(255, 209, 102, .16);
  --blue: #a3ccff;
  --blue-soft: rgba(163, 204, 255, .17);
  --ex: #ff7a5c;
  --auxin: #ffb020;
  --agar: #e3c66b;
  --foil: #b9c3d9;
  --plant: #72d26a;
  --plant-dark: #3e9e3a;
  --root: #ffb27a;
  --bud: #8fe27e;
  --on-ok: #002fa7;
  --on-ch: #06237f;
  --knob: #c9d5ff;
  --c1: #5eead4;
  --c2: #c4b5fd;
  --c3: #fdba8c;
  --c4: #9fd0ff;
  --c5: #bef264;
  --shadow: 0 1px 2px rgba(0, 10, 60, .35), 0 8px 24px rgba(0, 10, 60, .3);
  color-scheme: dark;
}

/* ========== 基础 ========== */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    "Noto Sans CJK SC", "Source Han Sans SC", "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.65;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--brand); text-decoration: none; }
button { font: inherit; color: inherit; }
h1, h2, h3 { line-height: 1.35; margin: 0; }
h1 { font-size: 22px; }
svg [tabindex]:focus:not(:focus-visible) { outline: none; }
svg { display: block; }
.muted { color: var(--text-2); }
.small { font-size: 14px; }
.tiny { font-size: 12px; color: var(--text-3); }

/* ========== 顶栏 / 底栏 ========== */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  height: calc(52px + env(safe-area-inset-top)); padding: 0 16px;
  padding-top: env(safe-area-inset-top);
  padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right));
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; color: var(--text); font-size: 17px; letter-spacing: .5px; }
.brand::before { content: "🌿"; margin-right: 6px; }
.topbar { justify-content: space-between; }

/* 配色切换 */
.theme-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 12px 0 6px;
  border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text-2);
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.swatch {
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, var(--bg) 50%, var(--brand) 50%);
}
.theme-menu {
  position: absolute; top: calc(100% + 6px); right: max(12px, env(safe-area-inset-right));
  width: 210px; padding: 6px; z-index: 30;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
}
.theme-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 0 10px;
  border: 0; border-radius: 10px; background: transparent; color: var(--text);
  font-size: 15px; text-align: left; cursor: pointer;
}
.theme-menu button:hover, .theme-menu button:focus-visible { background: var(--surface-2); }
.theme-menu .swatch { width: 24px; height: 24px; }
.theme-menu .check { margin-left: auto; color: var(--brand); font-weight: 700; visibility: hidden; }
.theme-menu button[aria-checked="true"] .check { visibility: visible; }
.theme-menu .sw-system { background: linear-gradient(135deg, #f5f7f4 50%, #121714 50%); }
.theme-menu .sw-light { background: linear-gradient(135deg, #f5f7f4 50%, #2f8f5b 50%); }
.theme-menu .sw-dark { background: linear-gradient(135deg, #121714 50%, #4cb67c 50%); }
.theme-menu .sw-klein { background: linear-gradient(135deg, #002fa7 50%, #ffffff 50%); }
.theme-menu .sw-pink { background: linear-gradient(135deg, #fff4f6 50%, #cc3d6b 50%); }
[hidden] { display: none !important; }

.page {
  max-width: 760px; margin: 0 auto;
  padding: 16px max(16px, env(safe-area-inset-right)) calc(96px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px; height: 58px; font-size: 12px; color: var(--text-2);
}
.tabbar .tab-ico { font-size: 20px; line-height: 1.1; filter: grayscale(1); opacity: .7; }
.tabbar a.active { color: var(--brand); font-weight: 600; }
.tabbar a.active .tab-ico { filter: none; opacity: 1; }

/* ========== 通用组件 ========== */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}
.card h2 { font-size: 18px; margin-bottom: 8px; }
.card h3 { font-size: 16px; margin-bottom: 6px; }
.section-title { font-size: 15px; color: var(--text-2); font-weight: 600; margin: 22px 4px 10px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 18px;
  border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text);
  font-weight: 600; cursor: pointer; user-select: none;
  transition: transform .08s ease, background .15s ease;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-block { display: flex; width: 100%; }
.btn-lg { min-height: 52px; font-size: 17px; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 36px; padding: 4px 14px;
  border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text);
  font-size: 14px; cursor: pointer; line-height: 1.4;
}
.chip.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
.chip.ok { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.chip.bad { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }

.note {
  border-radius: var(--radius-sm); padding: 10px 12px; font-size: 14px;
  background: var(--surface-2); color: var(--text-2);
}
.note.ok { background: var(--ok-soft); color: var(--text); }
.note.bad { background: var(--bad-soft); color: var(--text); }
.note.warn { background: var(--warn-soft); color: var(--text); }
.note strong { color: var(--text); }

.progress { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--brand); border-radius: 99px; transition: width .3s ease; }

.back { display: inline-flex; align-items: center; gap: 4px; color: var(--text-2); font-size: 14px; margin-bottom: 10px; }
.back::before { content: "‹"; font-size: 22px; line-height: 1; margin-top: -2px; }

.empty { text-align: center; padding: 36px 12px; color: var(--text-2); }
.empty .big { font-size: 40px; }

/* ========== 首页 ========== */
.hello { margin: 4px 4px 14px; }
.hello h1 { font-size: 22px; }
.greeting {
  background: var(--brand-soft); border: none; box-shadow: none;
  font-size: 15px; display: flex; gap: 10px; align-items: flex-start;
}
.greeting .from { font-size: 22px; line-height: 1.2; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 8px; text-align: center; }
.stat b { display: block; font-size: 24px; line-height: 1.2; }
.stat span { font-size: 12px; color: var(--text-2); }

.chapter-card { display: block; color: var(--text); border-left: 5px solid var(--ch, var(--brand)); }
.chapter-card .ch-no { font-size: 12px; color: var(--ch, var(--brand)); font-weight: 700; letter-spacing: 1px; }
.chapter-card h3 { font-size: 17px; margin: 2px 0 4px; }
.chapter-card .ch-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-2); margin-bottom: 6px; }
.chapter-card .progress > i { background: var(--ch, var(--brand)); }

.now-card { border-left: 5px solid var(--ch); }
.now-card .ch-no { font-size: 12px; color: var(--ch); font-weight: 700; letter-spacing: 1px; }
.now-card h3 { font-size: 19px; margin: 2px 0 12px; }
.now-links { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.now-links .btn { padding: 0 6px; font-size: 14px; min-height: 42px; }
.upto { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); }
.upto .chip { min-height: 32px; padding: 2px 12px; }
.chapter-grid { display: grid; gap: 14px; margin-bottom: 14px; }
.chapter-grid .card { margin: 0; }
.chapter-card.later { opacity: .6; }
.later-tag { margin-left: 8px; font-size: 11px; font-weight: 600; letter-spacing: 0; color: var(--text-2); background: var(--surface-2); border-radius: 6px; padding: 1px 6px; }

/* ========== 章节页 ========== */
.ch-head { margin: 0 4px 12px; }
.ch-head .ch-no { font-size: 13px; font-weight: 700; color: var(--ch); letter-spacing: 1px; }
.ch-head h1 { font-size: 22px; }
.tabs {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px;
  padding: 4px; margin-bottom: 14px;
  background: var(--surface-2); border-radius: 999px;
  position: sticky; top: calc(60px + env(safe-area-inset-top)); z-index: 5;
}
.tabs a { text-align: center; padding: 8px 0; border-radius: 999px; color: var(--text-2); font-weight: 600; font-size: 15px; }
.tabs a.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.cloze-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; font-weight: 600; user-select: none; }
.switch input { display: none; }
.switch i { width: 44px; height: 26px; border-radius: 99px; background: var(--line); position: relative; transition: background .2s; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--knob); transition: left .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + i { background: var(--brand); }
.switch input:checked + i::after { left: 21px; }
.switch input:checked + i::after { background: var(--brand-ink); }

.kp-list { list-style: none; margin: 0; padding: 0; }
.kp-list li { position: relative; padding: 9px 0 9px 18px; border-top: 1px dashed var(--line); }
.kp-list li:first-child { border-top: none; }
.kp-list li::before { content: ""; position: absolute; left: 2px; top: 19px; width: 6px; height: 6px; border-radius: 50%; background: var(--ch, var(--brand)); }
.kp-list li.pit::before { background: var(--bad); }
.pit-tag { display: inline-block; font-size: 11px; font-weight: 700; color: var(--bad); background: var(--bad-soft); border-radius: 6px; padding: 0 6px; margin-right: 6px; vertical-align: 1px; }
.kw { font-weight: 700; color: var(--text); border-bottom: 2px solid var(--ch, var(--brand)); }
@supports (background: color-mix(in srgb, red 50%, transparent)) {
  .kw { border-bottom: none; background: linear-gradient(transparent 62%, color-mix(in srgb, var(--ch, var(--brand)) 28%, transparent) 0); }
}
.cloze-on .kw {
  color: transparent; background: var(--surface-2); border-radius: 6px;
  border-bottom: 2px solid var(--ch, var(--brand)); cursor: pointer; padding: 0 2px;
}
.cloze-on .kw.shown { color: var(--ch, var(--brand)); background: var(--surface-2); }
.kp-table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 6px 0 2px; }
.kp-table th, .kp-table td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
.kp-table th { background: var(--surface-2); font-weight: 600; }

/* ========== 答题 ========== */
.quiz-top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.quiz-top .progress { flex: 1; }
.quiz-top .count { font-size: 14px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.q-tag { display: inline-block; font-size: 12px; font-weight: 700; color: var(--ch, var(--brand)); margin-bottom: 6px; }
.q-stem { font-size: 17px; font-weight: 600; margin-bottom: 14px; white-space: pre-line; }
.options { display: grid; gap: 10px; }
.option {
  display: flex; gap: 10px; align-items: flex-start; text-align: left;
  width: 100%; padding: 12px 14px; min-height: 50px;
  border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface);
  cursor: pointer; line-height: 1.5;
}
.option .key {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-2); font-size: 13px; font-weight: 700; color: var(--text-2);
}
.option.correct { border-color: var(--ok); background: var(--ok-soft); }
.option.correct .key { background: var(--ok); color: var(--on-ok); }
.option.wrong { border-color: var(--bad); background: var(--bad-soft); }
.option.wrong .key { background: var(--bad); color: var(--on-ok); }
.options.locked .option { cursor: default; }
.explain { margin-top: 14px; }
.explain b { display: block; margin-bottom: 2px; }
.result-big { font-size: 44px; font-weight: 800; text-align: center; margin: 6px 0; font-variant-numeric: tabular-nums; }
.wrong-item { padding: 12px 0; border-top: 1px solid var(--line); }
.wrong-item:first-child { border-top: none; padding-top: 0; }
.wrong-item .q { font-weight: 600; margin-bottom: 4px; }
.wrong-item .a { font-size: 14px; color: var(--text-2); }
.wrong-item .a b { color: var(--ok); }

/* ========== 小结 ========== */
.share-box {
  width: 100%; min-height: 180px; resize: vertical;
  font: inherit; font-size: 15px; line-height: 1.7;
  padding: 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text);
}
.toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px;
  font-size: 14px; z-index: 50; opacity: 0; transition: opacity .2s; pointer-events: none;
}
.toast.show { opacity: .94; }

/* ========== 互动实验通用 ========== */
.sim { border-top: 4px solid var(--ch, var(--brand)); }
.sim-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.sim-head .tag { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.sim-desc { font-size: 14px; color: var(--text-2); margin: 2px 0 12px; }
.sim-stage { background: var(--surface-2); border-radius: 12px; padding: 8px; margin-bottom: 12px; overflow: hidden; }
.sim-stage svg { width: 100%; height: auto; max-width: 560px; max-height: 48vh; margin: 0 auto; }
.sim-row { margin: 10px 0; }
.sim-label { font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.slider-row { display: grid; grid-template-columns: 64px 1fr 36px; align-items: center; gap: 10px; margin: 6px 0; font-size: 14px; }
.slider-row output { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); }
input[type="range"] { width: 100%; accent-color: var(--brand); height: 28px; }
.svg-text { fill: var(--text); font-size: 13px; font-family: inherit; }
.svg-sub { fill: var(--text-2); font-size: 11px; font-family: inherit; }
.svg-line { stroke: var(--line); }
.shake { animation: shake .35s ease; }
@keyframes shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }

/* 排序小游戏 */
.order-done { counter-reset: step; list-style: none; padding: 0; margin: 0 0 10px; }
.order-done li { counter-increment: step; display: flex; gap: 8px; padding: 8px 10px; margin-bottom: 6px; border-radius: 10px; background: var(--ok-soft); font-size: 14px; }
.order-done li::before { content: counter(step); flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--ok); color: var(--on-ok); font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; margin-top: 1px; }
.order-pool { display: grid; gap: 8px; }
.order-pool button { text-align: left; padding: 10px 12px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface); font-size: 14px; cursor: pointer; line-height: 1.5; }
.order-pool button.err { border-color: var(--bad); background: var(--bad-soft); }

/* 链条逐步揭晓 */
.chain { list-style: none; margin: 0; padding: 0; }
.chain li { position: relative; padding: 0 0 14px 30px; font-size: 15px; }
.chain li::before { content: ""; position: absolute; left: 10px; top: 22px; bottom: 0; width: 2px; background: var(--line); }
.chain li:last-child::before { display: none; }
.chain li .dot { position: absolute; left: 0; top: 2px; width: 22px; height: 22px; border-radius: 50%; background: var(--ch, var(--brand)); color: var(--on-ch); font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.chain li.hidden-step { color: transparent; }
.chain li.hidden-step .body { background: var(--surface-2); border-radius: 8px; user-select: none; }
.chain li.hidden-step .dot { background: var(--line); }

/* 激素沙盘 */
.axis-grid { display: grid; gap: 8px; }
.gland { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.gland .name { font-weight: 700; }
.gland .hormone { font-size: 13px; color: var(--text-2); }
.gland .lvl { display: flex; align-items: center; gap: 6px; }
.lvl-btn { min-width: 64px; min-height: 36px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface-2); font-weight: 700; cursor: pointer; }
.lvl-btn.up { color: var(--bad); border-color: var(--bad); background: var(--bad-soft); }
.lvl-btn.down { color: var(--blue); border-color: var(--blue); background: var(--blue-soft); }
.lvl-btn.same { color: var(--text-2); }
.mark { font-size: 18px; width: 22px; text-align: center; }
.axis-arrow { text-align: center; font-size: 13px; color: var(--text-2); line-height: 1.3; }

/* 小屏适配 */
@media (max-width: 380px) {
  .page { padding-left: 12px; padding-right: 12px; }
  .q-stem { font-size: 16px; }
  .stat b { font-size: 21px; }
}
@media (min-width: 700px) {
  .page { max-width: 820px; }
  .tabbar { max-width: 820px; margin: 0 auto; border: 1px solid var(--line); border-bottom: none; border-radius: 18px 18px 0 0; }
  .chapter-grid { grid-template-columns: 1fr 1fr; }
  .q-stem { font-size: 19px; }
  .option { font-size: 17px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
.chapter-grid .card:last-child:nth-child(odd) { grid-column: 1 / -1; }
/* 自动滚动时给顶栏和底栏留出位置 */
.sim-stage, .sim-row, .after .btn-row, .sync-card { scroll-margin: calc(72px + env(safe-area-inset-top)) 0 calc(90px + env(safe-area-inset-bottom)); }

/* ========== 笔记：聊天气泡 ========== */
.notes-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 4px 4px 4px; }
.notes-tip { margin: 0 4px 10px; }
.notes-filter { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; margin-bottom: 6px; scrollbar-width: none; }
.notes-filter::-webkit-scrollbar { display: none; }
.notes-filter .chip { flex: none; }
.chat { display: flex; flex-direction: column; gap: 6px; padding: 4px 0; }
.chat-day { align-self: center; font-size: 12px; color: var(--text-3); background: var(--surface-2); border-radius: 99px; padding: 2px 12px; margin: 12px 0 4px; }
.msg { display: flex; flex-direction: column; max-width: 84%; }
.msg.me { align-self: flex-end; align-items: flex-end; }
.msg.book { align-self: flex-start; align-items: flex-start; }
.msg + .msg.book { margin-top: 8px; }
.bubble {
  padding: 9px 14px; border-radius: 20px;
  font-size: 15px; line-height: 1.6; white-space: pre-wrap; word-break: break-word;
}
.msg.me .bubble { background: var(--brand); color: var(--brand-ink); border-bottom-right-radius: 6px; cursor: pointer; }
.msg.book .bubble { background: var(--surface); color: var(--text); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.bubble .from { display: block; font-size: 11px; font-weight: 700; letter-spacing: .3px; color: var(--ch, var(--text-2)); margin-bottom: 2px; }
.msg-meta { font-size: 11px; color: var(--text-3); margin: 3px 8px 0; }
.msg-actions { display: flex; gap: 6px; margin-top: 6px; }
.msg-actions button, .mini-btn {
  min-height: 32px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text-2); font-size: 13px; cursor: pointer;
}
.msg-actions button.danger { color: var(--bad); border-color: var(--bad); }
.msg .answer-it { margin-top: 6px; }
.note-input {
  width: 100%; min-height: 46px; max-height: 40vh; resize: none;
  font: inherit; font-size: 16px; line-height: 1.55; /* 16px：iPhone 上点输入框不会自动放大 */
  padding: 10px 14px; border-radius: 18px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text);
}
.note-input:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.note-select {
  font: inherit; font-size: 16px; min-height: 36px; padding: 2px 10px;
  border-radius: 99px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
}
.composer {
  margin-top: 12px; padding: 10px; display: grid; gap: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow);
}
.composer-row { display: flex; gap: 8px; align-items: flex-end; }
.send-btn {
  flex: none; width: 46px; height: 46px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--brand); color: var(--brand-ink); font-size: 18px; font-weight: 700;
}
.composer-quote {
  display: flex; align-items: flex-start; gap: 8px; padding: 6px 10px; border-radius: 12px;
  background: var(--surface-2); color: var(--text-2); font-size: 13px; line-height: 1.5;
}
.composer-quote span { flex: 1; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.composer-quote button { flex: none; border: 0; background: transparent; color: var(--text-3); font-size: 18px; line-height: 1; cursor: pointer; }
.composer-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* 写笔记弹窗（放在屏幕上方，手机键盘弹出时也不会被挡住） */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 60; display: flex; justify-content: center; align-items: flex-start;
  padding: calc(20px + env(safe-area-inset-top)) 12px 12px; background: rgba(0, 0, 0, .38);
}
.sheet {
  width: 100%; max-width: 560px; max-height: calc(100% - 8px); overflow: auto;
  display: grid; gap: 10px; padding: 14px;
  background: var(--bg); color: var(--text); border-radius: 22px; box-shadow: 0 12px 40px rgba(0, 0, 0, .25);
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { font-size: 18px; }
.sheet-x { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--surface-2); color: var(--text-2); font-size: 20px; cursor: pointer; }
body.sheet-open { overflow: hidden; }

/* 知识点旁边的「写理解」按钮 */
.kp-list li.has-note { padding-right: 36px; }
.kp-note {
  position: absolute; right: -4px; top: 5px; width: 34px; height: 34px; border: 0; border-radius: 50%;
  background: transparent; font-size: 15px; opacity: .45; cursor: pointer;
}
.kp-note:hover, .kp-note:focus-visible { opacity: 1; background: var(--surface-2); }

/* 打字时隐藏底栏，免得挡住输入框 */
body.typing .tabbar { display: none; }
.quiz-next { flex-wrap: nowrap; }
.quiz-next .next { flex: 1; }

/* ========== 云同步 ========== */
.sync-code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 24px; font-weight: 700; letter-spacing: 2px; color: var(--brand);
  font-variant-numeric: tabular-nums; user-select: all;
}
.code-input {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  text-transform: uppercase; letter-spacing: 1px;
}
.sync-prompt { display: flex; gap: 12px; align-items: flex-start; }
.sync-prompt .big { font-size: 26px; line-height: 1.2; }
.sync-prompt p { margin: 2px 0 8px; }

/* ========== 简答题 ========== */
.short-input { min-height: 120px; border-radius: 14px; }
.points { margin-top: 12px; }
.point {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 2px;
  border-top: 1px dashed var(--line); cursor: pointer; font-size: 15px; line-height: 1.55;
}
.point:first-of-type { border-top: none; }
.point input { flex: none; width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--brand); }
.switch.small { margin-top: 12px; font-size: 14px; font-weight: 500; }

/* ========== 章节题库 ========== */
.bank-cats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.bank-cat {
  display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 10px 4px;
  border-radius: 14px; background: var(--surface-2); color: var(--text); text-align: center;
}
.bank-cat b { font-size: 14px; }
.bank-cat .n { font-size: 26px; font-weight: 800; line-height: 1.2; font-variant-numeric: tabular-nums; color: var(--ch); }
.bank-cat small { font-size: 12px; color: var(--text-2); }
.bank-cat em { font-style: normal; font-size: 12px; font-weight: 600; color: var(--brand); margin-top: 2px; }
.bank-filter { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; margin-bottom: 4px; scrollbar-width: none; }
.bank-filter::-webkit-scrollbar { display: none; }
.bank-filter .chip { flex: none; }
.bank-legend { margin: 2px 4px 10px; display: flex; align-items: center; flex-wrap: wrap; gap: 2px; }
.bank-list { padding: 4px 14px; }
.bank-item { border-top: 1px solid var(--line); }
.bank-item:first-child { border-top: none; }
.bank-item summary {
  display: grid; grid-template-columns: 12px 1fr; column-gap: 10px; row-gap: 2px;
  padding: 12px 0; cursor: pointer; list-style: none;
}
.bank-item summary::-webkit-details-marker { display: none; }
.st { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-top: 7px; background: var(--line); flex: none; }
.bank-legend .st { margin: 0 4px 0 0; }
.st-good { background: var(--ok); }
.st-wrong { background: var(--bad); }
.bank-q {
  font-size: 15px; line-height: 1.55; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.bank-no { color: var(--text-3); font-variant-numeric: tabular-nums; }
.bank-meta { grid-column: 2; font-size: 12px; color: var(--text-3); }
.bank-item[open] .bank-q { display: none; }
.bank-body { padding: 0 0 14px 22px; }
.bank-stem { font-size: 15px; font-weight: 600; white-space: pre-line; margin-bottom: 6px; }
.bank-opts { margin: 0 0 6px; padding-left: 22px; list-style: upper-alpha; font-size: 15px; }
.bank-opts.plain { list-style: disc; }
.bank-opts li { padding: 2px 0; }
.bank-ans { margin-top: 10px; font-size: 14px; }
