:root {
  --bg: #fdfdfa; --fg: #1f2328; --muted: #6b7280;
  --sidebar-bg: #f7f7f4; --border: #e5e2d8;
  --link: #2563eb; --hl: #dbeafe;
  --formula-bg: #f5f5f0;
}
[data-theme="dark"] {
  --bg: #1a1b1e; --fg: #d6d3c8; --muted: #8b8f98;
  --sidebar-bg: #222327; --border: #33353b;
  --link: #7aa2f7; --hl: #2b3a55;
  --formula-bg: #24252a;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg);
  font-family: "Noto Sans CJK SC","PingFang SC","Microsoft YaHei",sans-serif;
  font-size: 16.5px; line-height: 1.85; letter-spacing: 0.01em; }
.content { font-weight: 400; }
.content h1, .content h2, .content h3 { font-weight: 700; letter-spacing: 0.02em; }
a { color: var(--link); text-decoration: none; }

/* 顶栏 */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center;
  gap: 14px; padding: 8px 18px; border-bottom: 1px solid var(--border);
  background: var(--bg); font-size: 14px; }
.topbar .brand { font-weight: 700; }
.topbar .crumb { color: var(--muted); }
.topbar .spacer { flex: 1; }
.search-box { padding: 4px 10px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--sidebar-bg); color: var(--fg); width: 180px; }
.theme-btn { border: 1px solid var(--border); background: none; color: var(--fg);
  border-radius: 6px; padding: 3px 10px; cursor: pointer; }

/* 布局 */
.layout { display: flex; align-items: flex-start; }
.sidebar { width: 250px; flex-shrink: 0; position: sticky; top: 45px;
  max-height: calc(100vh - 45px); overflow: auto; padding: 14px 12px;
  border-right: 1px solid var(--border); background: var(--sidebar-bg);
  font-size: 13.5px; line-height: 1.6; }
.sidebar .book-title { font-weight: 700; margin: 10px 0 4px; }
.sidebar details { margin-left: 4px; }
.sidebar summary { cursor: pointer; font-weight: 600; }
.sidebar a { display: block; padding: 1px 6px; border-radius: 4px; color: var(--fg); }
.sidebar a.active { background: var(--hl); color: var(--link); font-weight: 600; }
.content { flex: 1; max-width: 860px; padding: 24px 40px 80px; font-size: 16px; }

/* 正文元素 */
.content h1 { font-size: 24px; border-bottom: 2px solid var(--border); padding-bottom: 8px; }
.content h2.sec, .content h2 { font-size: 19px; margin-top: 36px; }
.content img { max-width: 100%; }
/* TikZ 渲染的 SVG（黑线透明底）：暗色下反白，避免黑线看不清 */
[data-theme="dark"] .content img[src$=".svg"] { filter: invert(0.85); }
.content table { border-collapse: collapse; margin: 12px auto; }
.content td, .content th { border: 1px solid var(--border); padding: 4px 10px; }

/* 注解框（pandoc 把 zhujie-* 环境映射为 div.zhujie-*） */
.zhujie-intuition, .zhujie-pitfall, .zhujie-derivation, .zhujie-xref {
  border-left: 4px solid; padding: 8px 14px; margin: 14px 0;
  font-size: 14.5px; border-radius: 0 6px 6px 0; }
.zhujie-intuition::before, .zhujie-pitfall::before,
.zhujie-derivation::before, .zhujie-xref::before {
  display: inline-block; font-weight: 700; margin-right: 6px; }
.zhujie-intuition { border-color: #3b82f6; background: #3b82f60f; }
.zhujie-intuition::before { content: "注解·直觉"; color: #2563eb; }
.zhujie-pitfall { border-color: #f59e0b; background: #f59e0b14; }
.zhujie-pitfall::before { content: "注解·易错"; color: #b45309; }
.zhujie-derivation { border-color: #16a34a; background: #16a34a0f; }
.zhujie-derivation::before { content: "注解·补推导"; color: #15803d; }
.zhujie-xref { border-color: #8b5cf6; background: #8b5cf612; }
.zhujie-xref::before { content: "注解·跨书"; color: #7c3aed; }

/* 暗色下注解标签色（保证 ≥4.5:1 对比度） */
[data-theme="dark"] .zhujie-intuition::before { color: #60a5fa; }
[data-theme="dark"] .zhujie-pitfall::before { color: #fbbf24; }
[data-theme="dark"] .zhujie-derivation::before { color: #4ade80; }
[data-theme="dark"] .zhujie-xref::before { color: #a78bfa; }

/* 页脚跨书链接 */
.xfooter { border-top: 1px solid var(--border); margin-top: 48px;
  padding-top: 14px; font-size: 14px; color: var(--muted); }

@media (max-width: 900px) {
  .sidebar { display: none; }
  .content { padding: 16px 18px 60px; }
}

/* Pagefind UI 暗色兼容 */
[data-theme="dark"] {
  --pagefind-ui-primary: #7aa2f7;
  --pagefind-ui-text: #d6d3c8;
  --pagefind-ui-background: #222327;
  --pagefind-ui-border: #33353b;
  --pagefind-ui-tag: #2b3a55;
}

/* —— 学习区分度增强 —— */
/* 展示公式：淡底卡片，与正文拉开 */
.content .math.display {
  display: block; background: var(--formula-bg); border-radius: 6px;
  padding: 10px 14px; margin: 14px 0; overflow-x: auto; text-align: center;
}
/* 关键词强调：加粗 + 主题色 */
.content strong { color: #c2410c; font-weight: 700; }
[data-theme="dark"] .content strong { color: #fb923c; }
/* 章节标题层级加重 */
.content h1 { font-size: 26px; margin-top: 8px; }
.content h2 { border-left: 4px solid var(--link); padding-left: 10px; }
/* 定义/结论句式引导词醒目（配合源文件 \textbf） */
