/* ============================================================
   Study Hub · 设计系统
   ------------------------------------------------------------
   所有视觉规则集中在这里，内容页只写 Markdown，不写样式。
   改版 = 只改这个文件（这就是"不会难看"的根本原因）。
   ============================================================ */

/* ---------- 1. 令牌 ---------- */
:root {
  --bg:        #f6f5f1;
  --surface:   #ffffff;
  --surface-2: #fbfaf7;
  --ink:       #171715;
  --ink-2:     #43423d;
  --muted:     #8b8880;
  --line:      #e4e1d9;
  --line-soft: #eeebe4;
  --shadow-sm: 0 1px 2px rgba(23, 23, 21, .05);
  --shadow-md: 0 1px 3px rgba(23, 23, 21, .05), 0 8px 24px -8px rgba(23, 23, 21, .10);
  --shadow-lg: 0 2px 6px rgba(23, 23, 21, .06), 0 24px 48px -16px rgba(23, 23, 21, .16);

  --c: #3f7d5c;              /* 当前科目主色，由 JS 注入 */
  --c-soft: rgba(63, 125, 92, .10);

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-xl: 26px;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC",
               "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Songti SC",
                "Noto Serif SC", Georgia, serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", "JetBrains Mono",
               Consolas, "Liberation Mono", monospace;

  --side-w: 258px;
  --pad: 40px;
  --ease: cubic-bezier(.22, .61, .36, 1);
}

html[data-theme="dark"] {
  --bg:        #121211;
  --surface:   #1a1a18;
  --surface-2: #201f1d;
  --ink:       #ece9e1;
  --ink-2:     #c3c0b7;
  --muted:     #8a877e;
  --line:      #2c2b28;
  --line-soft: #242320;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 1px 3px rgba(0, 0, 0, .4), 0 8px 24px -8px rgba(0, 0, 0, .5);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, .5), 0 24px 48px -16px rgba(0, 0, 0, .6);
  --c-soft: rgba(255, 255, 255, .07);
}

/* ---------- 2. 基础 ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
img { max-width: 100%; display: block; }
::selection { background: var(--c); color: #fff; }

:focus-visible {
  outline: 2px solid var(--c);
  outline-offset: 2px;
  border-radius: 4px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* 细滚动条 */
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--line); border-radius: 10px; border: 3px solid var(--bg); }

/* ---------- 3. 骨架布局 ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--side-w);
  display: flex;
  flex-direction: column;
  gap: 26px;
  padding: 26px 18px 18px;
  border-right: 1px solid var(--line);
  background: var(--bg);
  z-index: 40;
}

.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px; }
.brand-mark {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--ink);
  color: var(--bg);
  font-family: var(--font-serif);
  font-size: 17px;
  letter-spacing: -.5px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-name { font-family: var(--font-serif); font-size: 16.5px; letter-spacing: -.2px; }
.brand-sub { font-size: 11px; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }

.side-scroll { flex: 1; overflow-y: auto; margin: 0 -8px; padding: 0 8px; }

.nav-label {
  font-size: 10.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 10px;
  margin: 0 0 8px;
}

.nav { display: flex; flex-direction: column; gap: 1px; margin-bottom: 24px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  font-size: 13.5px;
  transition: background .16s var(--ease), color .16s var(--ease);
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); font-weight: 550; }
.nav-item .ico { font-size: 14px; width: 18px; text-align: center; opacity: .85; }
.nav-item .count { margin-left: auto; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

.subj-list { display: flex; flex-direction: column; gap: 1px; }
.subj-link {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  color: var(--ink-2);
  transition: background .16s var(--ease);
}
.subj-link:hover { background: var(--surface-2); color: var(--ink); }
.subj-link.is-active { background: var(--surface); box-shadow: var(--shadow-sm); color: var(--ink); font-weight: 550; }
.subj-dot {
  width: 7px; height: 7px; border-radius: 50%; flex: none;
  background: var(--sc, var(--muted));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--sc, #999) 14%, transparent);
}
.subj-link .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.subj-link .n { margin-left: auto; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

.side-foot { display: flex; align-items: center; gap: 8px; padding: 0 6px; }
.icon-btn {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: var(--r-sm);
  color: var(--muted);
  font-size: 14px;
  transition: background .16s var(--ease), color .16s var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.side-foot .spacer { flex: 1; }
.side-foot .ver { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* 主区域 */
.main {
  flex: 1;
  min-width: 0;
  margin-left: var(--side-w);
  padding: 0 var(--pad) 96px;
}
.wrap { max-width: 1080px; margin: 0 auto; }
.wrap-narrow { max-width: 720px; margin: 0 auto; }

/* 移动端顶栏 */
.topbar {
  display: none;
  position: sticky; top: 0; z-index: 30;
  align-items: center; gap: 10px;
  height: 56px;
  margin: 0 calc(var(--pad) * -1);
  padding: 0 var(--pad);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px) saturate(1.6);
  border-bottom: 1px solid var(--line);
}
.topbar .brand-name { font-size: 15px; }

.scrim {
  position: fixed; inset: 0; z-index: 35;
  background: rgba(20, 20, 18, .38);
  backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none;
  transition: opacity .2s var(--ease);
}

/* ---------- 4. 首页 ---------- */
.hero { padding: 64px 0 34px; }
.hero-kicker {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 18px;
}
.hero-kicker::before {
  content: ""; width: 18px; height: 1px; background: var(--line);
}
.hero h1 {
  margin: 0 0 14px;
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: clamp(30px, 4.4vw, 46px);
  line-height: 1.14;
  letter-spacing: -.02em;
}
.hero h1 em { font-style: italic; color: var(--ink-2); }
.hero p { margin: 0; max-width: 54ch; color: var(--ink-2); font-size: 15px; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  margin: 34px 0 52px;
  background: var(--line-soft);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  overflow: hidden;
}
.stat { background: var(--bg); padding: 16px 18px; }
.stat-v {
  font-family: var(--font-serif);
  font-size: 26px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.stat-k { font-size: 11.5px; color: var(--muted); letter-spacing: .04em; margin-top: 4px; }

.sec-head {
  display: flex; align-items: baseline; gap: 12px;
  margin: 0 0 18px;
}
.sec-head h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 21px;
  letter-spacing: -.01em;
}
.sec-head .line { flex: 1; height: 1px; background: var(--line); }
.sec-head .more { font-size: 12.5px; color: var(--muted); }
.sec-head .more:hover { color: var(--ink); }

.grid-subj {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(228px, 1fr));
  gap: 14px;
  margin-bottom: 56px;
}
.subj-card {
  position: relative;
  display: flex; flex-direction: column; gap: 14px;
  padding: 20px;
  min-height: 168px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s var(--ease);
}
.subj-card::after {
  content: "";
  position: absolute; inset: 0 0 auto 0; height: 3px;
  background: var(--sc);
  opacity: 0;
  transition: opacity .2s var(--ease);
}
.subj-card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--sc) 34%, var(--line));
  box-shadow: var(--shadow-md);
}
.subj-card:hover::after { opacity: 1; }
.subj-card .chip {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 11px;
  font-family: var(--font-serif);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: .06em;
  color: color-mix(in srgb, var(--sc) 82%, var(--ink));
  background: color-mix(in srgb, var(--sc) 11%, transparent);
  border: 1px solid color-mix(in srgb, var(--sc) 20%, transparent);
}
.subj-card .nm {
  font-family: var(--font-serif);
  font-size: 17px;
  line-height: 1.25;
  letter-spacing: -.01em;
}
.subj-card .nm small { display: block; font-family: var(--font-sans); font-size: 12px; color: var(--muted); margin-top: 3px; letter-spacing: 0; }
.subj-card .foot {
  margin-top: auto;
  display: flex; align-items: center; gap: 10px;
  font-size: 11.5px; color: var(--muted);
}
.bar { flex: 1; height: 3px; border-radius: 3px; background: var(--line-soft); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--sc); border-radius: 3px; transition: width .5s var(--ease); }

.recent { display: flex; flex-direction: column; border-top: 1px solid var(--line-soft); }
.recent-row {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 2px;
  border-bottom: 1px solid var(--line-soft);
  transition: padding-left .18s var(--ease);
}
.recent-row:hover { padding-left: 6px; }
.recent-row .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--sc, var(--muted)); flex: none; }
.recent-row .t { font-size: 14px; }
.recent-row .t small { display: block; color: var(--muted); font-size: 11.5px; }
.recent-row .d { margin-left: auto; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- 5. 科目页 ---------- */
.page-head { padding: 56px 0 26px; border-bottom: 1px solid var(--line); margin-bottom: 30px; }
.crumb { font-size: 12px; color: var(--muted); margin-bottom: 16px; display: flex; gap: 7px; align-items: center; }
.crumb a:hover { color: var(--ink); }
.page-title { display: flex; align-items: center; gap: 16px; margin: 0 0 12px; }
.page-title .chip {
  width: 52px; height: 52px; flex: none;
  display: grid; place-items: center;
  border-radius: 14px;
  font-family: var(--font-serif);
  font-size: 17px; font-weight: 500; letter-spacing: .06em;
  color: color-mix(in srgb, var(--c) 82%, var(--ink));
  background: color-mix(in srgb, var(--c) 11%, transparent);
  border: 1px solid color-mix(in srgb, var(--c) 22%, transparent);
}
.page-title h1 {
  margin: 0;
  font-family: var(--font-serif); font-weight: 400;
  font-size: clamp(25px, 3vw, 33px); line-height: 1.15; letter-spacing: -.02em;
}
.page-title h1 small { display: block; font-family: var(--font-sans); font-size: 13px; color: var(--muted); margin-top: 4px; letter-spacing: 0; }
.page-desc { color: var(--ink-2); max-width: 62ch; margin: 0 0 18px; }
.page-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 7px; margin: 0 0 24px; }
.chip-btn {
  padding: 5px 12px;
  border-radius: 100px;
  border: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--ink-2);
  background: var(--surface);
  transition: all .16s var(--ease);
}
.chip-btn:hover { border-color: var(--muted); }
.chip-btn.is-on { background: var(--ink); border-color: var(--ink); color: var(--bg); }

.grid-units { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.unit-card {
  display: flex; flex-direction: column; gap: 10px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease), transform .18s var(--ease);
}
.unit-card:hover { transform: translateY(-1px); border-color: color-mix(in srgb, var(--c) 32%, var(--line)); box-shadow: var(--shadow-md); }
.unit-card .top { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); letter-spacing: .04em; }
.unit-card .badge {
  padding: 2px 7px; border-radius: 5px;
  background: color-mix(in srgb, var(--c) 11%, transparent);
  color: color-mix(in srgb, var(--c) 78%, var(--ink));
  font-weight: 550; letter-spacing: .02em;
}
.unit-card h3 {
  margin: 0;
  font-family: var(--font-serif); font-weight: 400;
  font-size: 17px; line-height: 1.35; letter-spacing: -.01em;
}
.unit-card h3 small { display: block; font-family: var(--font-sans); font-size: 12px; color: var(--muted); margin-top: 3px; }
.unit-card p { margin: 0; font-size: 13px; color: var(--ink-2); line-height: 1.6; }
.unit-card .foot { margin-top: auto; padding-top: 8px; display: flex; align-items: center; gap: 10px; font-size: 11.5px; color: var(--muted); }
.unit-card .read { color: var(--c); font-weight: 550; }

/* 空状态 */
.empty {
  padding: 56px 24px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: var(--r-lg);
  color: var(--muted);
}
.empty .big { font-size: 26px; margin-bottom: 10px; opacity: .5; }
.empty p { margin: 0 0 4px; font-size: 13.5px; }
.empty code { font-family: var(--font-mono); font-size: 12px; color: var(--ink-2); }

/* ---------- 6. 阅读页 ---------- */
.reader-bar {
  position: fixed; inset: 0 0 auto 0; height: 2px; z-index: 60;
  background: transparent;
}
.reader-bar > i { display: block; height: 100%; width: 0; background: var(--c); transition: width .1s linear; }

.reader {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 210px;
  gap: 56px;
  align-items: start;
}
.reader-head { padding: 52px 0 24px; border-bottom: 1px solid var(--line); margin-bottom: 34px; }
.reader-head .tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 0; }
.tag {
  padding: 3px 9px; border-radius: 5px;
  background: var(--surface-2); border: 1px solid var(--line-soft);
  font-size: 11.5px; color: var(--muted);
}
.reader-head h1 {
  margin: 0;
  font-family: var(--font-serif); font-weight: 400;
  font-size: clamp(27px, 3.4vw, 38px);
  line-height: 1.2; letter-spacing: -.02em;
}
.reader-head h1 small { display: block; font-family: var(--font-sans); font-size: 14px; color: var(--muted); margin-top: 8px; letter-spacing: 0; }
.reader-meta {
  display: flex; flex-wrap: wrap; gap: 16px;
  margin-top: 18px; font-size: 12px; color: var(--muted);
}
.reader-meta span { display: inline-flex; align-items: center; gap: 6px; }

.toc { position: sticky; top: 32px; font-size: 12.5px; max-height: calc(100vh - 64px); overflow-y: auto; }
.toc-title { font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: 12px; }
.toc a {
  display: block; padding: 4px 0 4px 11px;
  color: var(--muted);
  border-left: 1px solid var(--line);
  line-height: 1.5;
  transition: color .16s var(--ease), border-color .16s var(--ease);
}
.toc a:hover { color: var(--ink); }
.toc a.lvl-3 { padding-left: 22px; font-size: 12px; }
.toc a.is-active { color: var(--c); border-color: var(--c); font-weight: 550; }

.reader-foot { margin-top: 56px; padding-top: 28px; border-top: 1px solid var(--line); }
.read-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 28px; }
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 15px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 13px;
  transition: all .16s var(--ease);
}
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn-primary:hover { opacity: .88; border-color: var(--ink); }
.btn.is-done { background: color-mix(in srgb, var(--c) 12%, transparent); border-color: color-mix(in srgb, var(--c) 40%, var(--line)); color: color-mix(in srgb, var(--c) 85%, var(--ink)); }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pager a {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
}
.pager a:hover { border-color: var(--muted); box-shadow: var(--shadow-sm); }
.pager .k { font-size: 11px; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
.pager .v { font-family: var(--font-serif); font-size: 15px; margin-top: 4px; line-height: 1.35; }
.pager .next { text-align: right; }

/* ---------- 7. 正文排版（Markdown 渲染结果） ---------- */
.article { font-size: 16px; line-height: 1.78; color: var(--ink-2); }
.article > *:first-child { margin-top: 0; }

.article h2 {
  margin: 2.2em 0 .7em;
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 25px;
  line-height: 1.3;
  letter-spacing: -.015em;
  color: var(--ink);
  scroll-margin-top: 24px;
}
.article h3 {
  margin: 1.9em 0 .5em;
  font-size: 16.5px;
  font-weight: 650;
  color: var(--ink);
  letter-spacing: -.005em;
  scroll-margin-top: 24px;
}
.article h4 {
  margin: 1.6em 0 .4em;
  font-size: 14px;
  font-weight: 650;
  color: var(--muted);
  letter-spacing: .04em;
  text-transform: uppercase;
}
.article p { margin: 0 0 1.05em; }
.article strong { color: var(--ink); font-weight: 650; }
.article em { font-style: italic; }
.article a {
  color: color-mix(in srgb, var(--c) 88%, var(--ink));
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: color-mix(in srgb, var(--c) 40%, transparent);
}
.article a:hover { text-decoration-color: var(--c); }
.article mark { background: color-mix(in srgb, var(--c) 20%, transparent); color: inherit; padding: 1px 3px; border-radius: 3px; }
.article hr { border: 0; height: 1px; background: var(--line); margin: 2.4em 0; }

.article ul, .article ol { margin: 0 0 1.1em; padding-left: 1.35em; }
.article li { margin: .32em 0; }
.article li::marker { color: var(--muted); }
.article ul ul, .article ol ol, .article ul ol, .article ol ul { margin: .3em 0 .2em; }

.article blockquote {
  margin: 1.4em 0;
  padding: 2px 0 2px 18px;
  border-left: 2px solid var(--line);
  color: var(--muted);
  font-family: var(--font-serif);
  font-size: 16.5px;
}
.article blockquote p:last-child { margin-bottom: 0; }

.article code {
  font-family: var(--font-mono);
  font-size: .87em;
  padding: 1.5px 5px;
  border-radius: 5px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  color: color-mix(in srgb, var(--c) 70%, var(--ink));
}
.article pre {
  margin: 1.4em 0;
  padding: 15px 17px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.6;
}
.article pre code { padding: 0; border: 0; background: none; color: var(--ink-2); font-size: 13px; }

.article .table-wrap { margin: 1.5em 0; overflow-x: auto; }
.article table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.article th {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: .03em;
  color: var(--muted);
  text-transform: uppercase;
  white-space: nowrap;
}
.article td { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.article tr:last-child td { border-bottom: 0; }
.article tbody tr:hover { background: var(--surface-2); }

/* 图片 */
.article figure { margin: 1.8em 0; }
.article figure img {
  width: 100%;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface-2);
  cursor: zoom-in;
}
.article figcaption {
  margin-top: 9px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  font-style: italic;
}
.article .img-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 1.6em 0; }
.article .img-row figure { margin: 0; }

/* 提示块 */
.callout {
  margin: 1.6em 0;
  padding: 15px 18px 15px 17px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  border-left: 3px solid var(--cc, var(--c));
  background: var(--surface);
  font-size: 15px;
  line-height: 1.7;
}
.callout > .ct {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 650;
  letter-spacing: .03em;
  color: var(--cc, var(--c));
  margin-bottom: 6px;
  text-transform: uppercase;
}
.callout p:last-child, .callout ul:last-child, .callout ol:last-child, .callout table:last-child { margin-bottom: 0; }
.callout p { color: var(--ink-2); }
.callout code { background: var(--bg); }

.callout.key   { --cc: #3f7d5c; background: color-mix(in srgb, #3f7d5c 5%, var(--surface)); }
.callout.def   { --cc: #3b6ea5; background: color-mix(in srgb, #3b6ea5 5%, var(--surface)); }
.callout.exam  { --cc: #a85548; background: color-mix(in srgb, #a85548 5%, var(--surface)); }
.callout.tip   { --cc: #2f7d84; background: color-mix(in srgb, #2f7d84 5%, var(--surface)); }
.callout.warn  { --cc: #a8781f; background: color-mix(in srgb, #a8781f 6%, var(--surface)); }
.callout.note  { --cc: var(--muted); background: var(--surface-2); }

html[data-theme="dark"] .callout.key  { background: color-mix(in srgb, #3f7d5c 13%, var(--surface)); }
html[data-theme="dark"] .callout.def  { background: color-mix(in srgb, #3b6ea5 14%, var(--surface)); }
html[data-theme="dark"] .callout.exam { background: color-mix(in srgb, #a85548 14%, var(--surface)); }
html[data-theme="dark"] .callout.tip  { background: color-mix(in srgb, #2f7d84 14%, var(--surface)); }
html[data-theme="dark"] .callout.warn { background: color-mix(in srgb, #a8781f 14%, var(--surface)); }

/* 术语卡 */
.terms { margin: 1.6em 0; display: flex; flex-direction: column; gap: 1px; background: var(--line-soft); border: 1px solid var(--line-soft); border-radius: var(--r-md); overflow: hidden; }
.terms .term { display: grid; grid-template-columns: minmax(120px, 34%) 1fr; gap: 16px; padding: 12px 16px; background: var(--surface); }
.terms .term .k { font-weight: 600; color: var(--ink); font-size: 14px; }
.terms .term .v { color: var(--ink-2); font-size: 14px; }

/* 测验 */
.quiz {
  margin: 1.8em 0;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
}
.quiz > .q {
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 12px;
  font-size: 15px;
  display: flex; gap: 9px;
}
.quiz > .q::before {
  content: "Q";
  flex: none;
  width: 19px; height: 19px;
  display: grid; place-items: center;
  border-radius: 5px;
  background: color-mix(in srgb, var(--c) 14%, transparent);
  color: color-mix(in srgb, var(--c) 90%, var(--ink));
  font-size: 11px; font-weight: 700;
  margin-top: 2px;
}
.quiz .opts { display: flex; flex-direction: column; gap: 7px; }
.quiz .opt {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: 14px;
  color: var(--ink-2);
  text-align: left;
  transition: all .15s var(--ease);
  width: 100%;
}
.quiz .opt:hover:not(.locked) { border-color: var(--muted); background: var(--surface-2); }
.quiz .opt .mk {
  flex: none; width: 17px; height: 17px;
  border: 1.5px solid var(--line);
  border-radius: 50%;
  margin-top: 3px;
  display: grid; place-items: center;
  font-size: 10px; color: transparent;
}
.quiz .opt.ok { border-color: #3f7d5c; background: color-mix(in srgb, #3f7d5c 9%, var(--surface)); color: var(--ink); }
.quiz .opt.ok .mk { border-color: #3f7d5c; background: #3f7d5c; color: #fff; }
.quiz .opt.no { border-color: #a85548; background: color-mix(in srgb, #a85548 8%, var(--surface)); }
.quiz .opt.no .mk { border-color: #a85548; background: #a85548; color: #fff; }
.quiz .fb { margin-top: 11px; font-size: 13px; color: var(--muted); min-height: 18px; }
.quiz .fb.good { color: #3f7d5c; }
.quiz .fb.bad { color: #a85548; }

/* 原子计算器 */
.atomcalc {
  margin: 1.8em 0;
  padding: 18px 20px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
}
.atomcalc > .ct {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 650; letter-spacing: .03em;
  text-transform: uppercase; color: var(--c);
  margin-bottom: 14px;
}
.ac-inputs { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.ac-inputs label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 12px; font-weight: 600; color: var(--ink-2);
}
.ac-inputs label small { font-weight: 400; font-size: 10.5px; color: var(--muted); letter-spacing: .02em; }
.ac-inputs input {
  width: 104px;
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}
.ac-inputs input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--c) 55%, var(--line));
  background: var(--surface);
}
.ac-out {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--line-soft);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
  overflow: hidden;
}
.ac-out > div { background: var(--surface); padding: 10px 13px; display: flex; flex-direction: column; gap: 2px; }
.ac-out > div.wide { grid-column: 1 / -1; flex-direction: row; align-items: baseline; gap: 12px; }
.ac-out .k { font-size: 10.5px; color: var(--muted); letter-spacing: .03em; }
.ac-out b {
  font-family: var(--font-mono);
  font-size: 17px;
  font-weight: 500;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.ac-out > div.wide b { font-size: 15px; letter-spacing: .02em; }
.ac-hint { margin: 10px 0 0; font-size: 11.5px; color: var(--muted); }
.ac-hint.bad { color: #a85548; }

/* ---------- 8. 搜索 ---------- */
.search-modal {
  position: fixed; inset: 0; z-index: 80;
  display: none;
  padding: 12vh 20px 20px;
  background: rgba(20, 20, 18, .34);
  backdrop-filter: blur(3px);
}
.search-modal.is-open { display: block; }
.search-box {
  max-width: 620px; margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.search-input {
  width: 100%;
  padding: 17px 20px;
  border: 0; border-bottom: 1px solid var(--line-soft);
  background: none;
  font-size: 15.5px;
  color: var(--ink);
}
.search-input::placeholder { color: var(--muted); }
.search-input:focus { outline: none; }
.search-input::-webkit-search-cancel-button,
.search-input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }
.search-list { max-height: 56vh; overflow-y: auto; padding: 7px; }
.search-hit {
  display: block; padding: 10px 13px; border-radius: var(--r-sm);
  font-size: 13.5px;
}
.search-hit:hover, .search-hit.sel { background: var(--surface-2); }
.search-hit .s { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.search-hit .h { color: var(--ink); }
.search-hit .d {
  margin-top: 2px; font-size: 11.5px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.search-hit mark { background: color-mix(in srgb, var(--c) 22%, transparent); color: inherit; }
.search-empty { padding: 26px; text-align: center; color: var(--muted); font-size: 13px; }
.search-hint { padding: 9px 16px; border-top: 1px solid var(--line-soft); font-size: 11px; color: var(--muted); display: flex; gap: 14px; }
kbd {
  font-family: var(--font-mono); font-size: 10.5px;
  padding: 1px 5px; border: 1px solid var(--line); border-radius: 4px;
  background: var(--surface-2); color: var(--muted);
}

/* 图片灯箱 */
.lightbox {
  position: fixed; inset: 0; z-index: 90;
  display: none; place-items: center;
  padding: 30px;
  background: rgba(12, 12, 11, .93);
}
.lightbox.is-open { display: grid; }
.lightbox img { max-width: 100%; max-height: 92vh; border-radius: 4px; }
.lightbox .close { position: absolute; top: 18px; right: 22px; color: #fff; font-size: 26px; opacity: .7; }
.lightbox .close:hover { opacity: 1; }

/* ---------- 9. 页脚 / 杂项 ---------- */
.foot-note {
  margin-top: 72px;
  padding-top: 22px;
  border-top: 1px solid var(--line-soft);
  display: flex; flex-wrap: wrap; gap: 10px 20px;
  font-size: 11.5px; color: var(--muted);
}
.foot-note a:hover { color: var(--ink); }

.fade-in { animation: fadeIn .3s var(--ease) both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

.loading { padding: 100px 0; text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- 10. 响应式 ---------- */
@media (max-width: 1100px) {
  .reader { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .toc { display: none; }
}

@media (max-width: 860px) {
  :root { --pad: 22px; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform .26s var(--ease);
    box-shadow: none;
    background: var(--bg);
  }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  body.nav-open .scrim { opacity: 1; pointer-events: auto; }
  .main { margin-left: 0; }
  .topbar { display: flex; }
  .hero { padding: 34px 0 24px; }
  .stats { grid-template-columns: repeat(2, 1fr); margin-bottom: 38px; }
  .grid-subj { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
  .subj-card { padding: 16px; min-height: 148px; }
  .grid-units { grid-template-columns: 1fr; }
  .page-head { padding: 26px 0 20px; }
  .reader-head { padding: 28px 0 20px; }
  .article { font-size: 15.5px; }
  .article h2 { font-size: 22px; }
  .pager { grid-template-columns: 1fr; }
  .pager .next { text-align: left; }
  .terms .term { grid-template-columns: 1fr; gap: 3px; }
  .article .img-row { grid-template-columns: 1fr; }
}

/* ---------- 11. 打印 ---------- */
@media print {
  .sidebar, .topbar, .toc, .reader-bar, .read-actions, .pager, .foot-note, .scrim { display: none !important; }
  .main { margin: 0; padding: 0; }
  .reader { display: block; }
  body { background: #fff; color: #000; }
  .article { font-size: 11.5pt; }
  .article h2 { page-break-after: avoid; }
  .callout, .quiz, figure, table { page-break-inside: avoid; }
}
