/* ==========================================================================
   工程力学（理论力学）第 1–2 章 · 学习网页
   样式表：桌面 / 平板 / 手机 自适应
   ========================================================================== */

/* ---------- 1. 设计变量 ---------- */
:root {
  /* 主色（第 1 章 · 蓝） */
  --c1: #2563eb;
  --c1-dark: #1d4ed8;
  --c1-soft: #dbeafe;

  /* 副色（第 2 章 · 紫） */
  --c2: #7c3aed;
  --c2-dark: #6d28d9;
  --c2-soft: #ede9fe;

  /* 语义色 */
  --ok: #059669;
  --ok-soft: #d1fae5;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --accent: #0891b2;
  --accent-soft: #cffafe;

  /* 中性色 */
  --bg: #f6f8fc;
  --bg-alt: #eef2f9;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-soft: #475569;
  --text-mute: #94a3b8;

  --line: #cbd5e1;          /* 思维导图连线 */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .04);
  --shadow: 0 4px 12px rgba(15, 23, 42, .07), 0 1px 3px rgba(15, 23, 42, .05);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, .10);

  --radius: 14px;
  --radius-sm: 9px;
  --radius-lg: 20px;

  --header-h: 62px;
  --wrap: 1180px;

  --font: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", "Noto Sans SC",
          -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: "SFMono-Regular", "JetBrains Mono", Consolas, "Liberation Mono", monospace;
}

/* 深色模式 */
html[data-theme="dark"] {
  --c1: #60a5fa;
  --c1-dark: #3b82f6;
  --c1-soft: #1e3a5f;
  --c2: #a78bfa;
  --c2-dark: #8b5cf6;
  --c2-soft: #35296b;
  --ok: #34d399;
  --ok-soft: #14392e;
  --warn: #fbbf24;
  --warn-soft: #3d2f0c;
  --danger: #f87171;
  --danger-soft: #45191b;
  --accent: #22d3ee;
  --accent-soft: #123a45;
  --bg: #0b1120;
  --bg-alt: #0f172a;
  --surface: #151f33;
  --surface-2: #1b2740;
  --border: #263148;
  --border-strong: #38445e;
  --text: #e8eef8;
  --text-soft: #a8b6cc;
  --text-mute: #77859c;
  --line: #3b4a66;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow: 0 4px 14px rgba(0, 0, 0, .4);
  --shadow-lg: 0 14px 34px rgba(0, 0, 0, .5);
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 14px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.75;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
  transition: background .25s ease, color .25s ease;
}

h1, h2, h3, h4, h5 { line-height: 1.35; margin: 0 0 .5em; font-weight: 700; letter-spacing: -.01em; }
p { margin: 0 0 1em; }
a { color: var(--c1); text-decoration: none; }
a:hover { text-decoration: underline; }
ul, ol { margin: 0 0 1em; padding-left: 1.35em; }
li { margin: .3em 0; }
img, svg { max-width: 100%; height: auto; }
code, .mono { font-family: var(--mono); font-size: .92em; }
strong, b { font-weight: 700; color: var(--text); }
hr { border: 0; border-top: 1px solid var(--border); margin: 2rem 0; }
::selection { background: var(--c1-soft); color: var(--text); }

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 18px; }

/* 跳过导航（无障碍） */
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 999;
  background: var(--c1); color: #fff; padding: 10px 16px; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

/* ---------- 3. 顶栏 ---------- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  height: var(--header-h);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
@supports not (backdrop-filter: blur(1px)) {
  .site-header { background: var(--surface); }
}

.header-inner {
  max-width: var(--wrap); margin: 0 auto; padding: 0 18px;
  height: 100%; display: flex; align-items: center; gap: 12px;
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); flex-shrink: 0; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--c1), var(--c2));
  color: #fff; display: grid; place-items: center;
  font-size: 15px; font-weight: 800; letter-spacing: -.5px;
  box-shadow: 0 3px 10px rgba(37, 99, 235, .3);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text b { font-size: 15px; }
.brand-text small { font-size: 11px; color: var(--text-mute); font-weight: 500; letter-spacing: .02em; }

.nav { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.nav a {
  padding: 7px 13px; border-radius: 8px; font-size: 14.5px;
  color: var(--text-soft); font-weight: 500; white-space: nowrap;
  transition: background .18s, color .18s;
}
.nav a:hover { background: var(--bg-alt); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--c1-soft); color: var(--c1-dark); font-weight: 700; }

.icon-btn {
  width: 38px; height: 38px; flex-shrink: 0; cursor: pointer;
  display: grid; place-items: center; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-soft); font-size: 17px; line-height: 1;
  transition: background .18s, color .18s, border-color .18s;
}
.icon-btn:hover { background: var(--bg-alt); color: var(--text); border-color: var(--border-strong); }
.icon-btn .i-moon { display: none; }
html[data-theme="dark"] .icon-btn .i-sun { display: none; }
html[data-theme="dark"] .icon-btn .i-moon { display: block; }

.nav-toggle { display: none; }

/* 移动端抽屉 */
@media (max-width: 860px) {
  .nav-toggle { display: grid; order: 3; }
  .nav {
    position: fixed; inset: var(--header-h) 0 auto 0;
    flex-direction: column; align-items: stretch; gap: 4px;
    background: var(--surface); border-bottom: 1px solid var(--border);
    padding: 12px 18px 18px; margin: 0;
    box-shadow: var(--shadow-lg);
    transform: translateY(-12px); opacity: 0; visibility: hidden;
    transition: transform .22s ease, opacity .22s ease, visibility .22s;
  }
  .nav.open { transform: none; opacity: 1; visibility: visible; }
  .nav a { padding: 12px 14px; font-size: 16px; border-radius: 10px; }
  .nav a.active { background: var(--c1-soft); }
  .brand-text small { display: none; }
}

/* ---------- 4. Hero ---------- */
.hero {
  position: relative; overflow: hidden;
  padding: 54px 0 46px;
  background:
    radial-gradient(1000px 380px at 12% -10%, var(--c1-soft) 0%, transparent 62%),
    radial-gradient(900px 360px at 92% 4%, var(--c2-soft) 0%, transparent 60%),
    var(--bg);
  border-bottom: 1px solid var(--border);
}
.hero::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(to right, color-mix(in srgb, var(--text) 5%, transparent) 1px, transparent 1px),
    linear-gradient(to bottom, color-mix(in srgb, var(--text) 5%, transparent) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(720px 320px at 25% 0%, #000 0%, transparent 78%);
  -webkit-mask-image: radial-gradient(720px 320px at 25% 0%, #000 0%, transparent 78%);
}
.hero > .wrap { position: relative; z-index: 1; }

.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-soft); font-size: 12.5px; font-weight: 600;
  padding: 5px 13px; border-radius: 999px; margin-bottom: 16px;
  letter-spacing: .03em; box-shadow: var(--shadow-sm);
}
.eyebrow .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }

.hero h1 {
  font-size: clamp(1.6rem, 4.4vw, 2.6rem);
  margin: 0 0 14px; letter-spacing: -.02em;
}
.hero h1 .grad {
  background: linear-gradient(100deg, var(--c1) 10%, var(--c2) 90%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-lead { font-size: clamp(.98rem, 2.2vw, 1.1rem); color: var(--text-soft); max-width: 66ch; margin-bottom: 24px; }

.hero-actions { display: flex; flex-wrap: wrap; gap: 11px; margin-bottom: 30px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 20px; border-radius: 11px; font-weight: 650; font-size: 15px;
  border: 1px solid transparent; cursor: pointer; transition: all .18s ease;
  font-family: inherit;
}
.btn-primary { background: linear-gradient(135deg, var(--c1), var(--c2)); color: #fff; box-shadow: 0 5px 16px rgba(37, 99, 235, .28); }
.btn-primary:hover { text-decoration: none; transform: translateY(-2px); box-shadow: 0 9px 22px rgba(37, 99, 235, .34); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { text-decoration: none; background: var(--bg-alt); transform: translateY(-2px); }
.btn-sm { padding: 8px 14px; font-size: 13.5px; border-radius: 9px; }

/* Hero 统计 */
.hero-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 15px 16px; box-shadow: var(--shadow-sm);
}
.stat .num { display: block; font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; }
.stat .lbl { font-size: 12.5px; color: var(--text-mute); font-weight: 600; }
.stat:nth-child(1) .num { color: var(--c1); }
.stat:nth-child(2) .num { color: var(--c2); }
.stat:nth-child(3) .num { color: var(--accent); }
.stat:nth-child(4) .num { color: var(--ok); }

@media (max-width: 620px) {
  .hero { padding: 36px 0 32px; }
  .hero-stats { grid-template-columns: repeat(2, 1fr); }
  .hero-actions .btn { flex: 1 1 100%; justify-content: center; }
}

/* ---------- 5. 主体与章节 ---------- */
main { display: block; padding: 40px 0 60px; }
.section { margin-bottom: 46px; scroll-margin-top: calc(var(--header-h) + 16px); }
.section:last-child { margin-bottom: 0; }

.section-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.section-head h2 {
  font-size: clamp(1.22rem, 3vw, 1.6rem); margin: 0;
  display: flex; align-items: center; gap: 11px;
}
.sec-num {
  display: inline-grid; place-items: center; flex-shrink: 0;
  min-width: 36px; height: 36px; padding: 0 9px;
  border-radius: 11px; font-size: 15px; font-weight: 800;
  background: var(--c1-soft); color: var(--c1-dark);
}
.sec-sub { color: var(--text-mute); font-size: 13.5px; font-weight: 600; }
.section-desc { color: var(--text-soft); margin: 0 0 22px; max-width: 78ch; }

/* 章节页锚点配色 */
body[data-chapter="2"] .sec-num { background: var(--c2-soft); color: var(--c2-dark); }
body[data-chapter="2"] a { color: var(--c2); }

/* ---------- 6. 卡片与网格 ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px 22px;
  box-shadow: var(--shadow-sm); margin-bottom: 16px;
}
.card > :last-child { margin-bottom: 0; }
.card h3 { font-size: 1.06rem; margin-bottom: .55em; }
.card h4 { font-size: .97rem; margin: 1.1em 0 .45em; color: var(--text); }
.card h4:first-child { margin-top: 0; }

.grid { display: grid; gap: 16px; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 980px) { .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 680px) { .g-2, .g-3, .g-4 { grid-template-columns: 1fr; } }

/* 卡片顶部色条 */
.card-accent { border-top: 3px solid var(--c1); }
.card-accent.c2 { border-top-color: var(--c2); }
.card-accent.c-accent { border-top-color: var(--accent); }
.card-accent.c-ok { border-top-color: var(--ok); }
.card-accent.c-warn { border-top-color: var(--warn); }
.card-accent.c-danger { border-top-color: var(--danger); }

/* 卡片标题带序号徽标 */
.card-badge { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-badge .bg {
  width: 28px; height: 28px; flex-shrink: 0; border-radius: 9px;
  display: grid; place-items: center; font-size: 13.5px; font-weight: 800;
  background: var(--c1-soft); color: var(--c1-dark);
}
.card-badge .bg.c2 { background: var(--c2-soft); color: var(--c2-dark); }
.card-badge .bg.c-ok { background: var(--ok-soft); color: var(--ok); }
.card-badge .bg.c-warn { background: var(--warn-soft); color: var(--warn); }
.card-badge .bg.c-danger { background: var(--danger-soft); color: var(--danger); }
.card-badge .bg.c-accent { background: var(--accent-soft); color: var(--accent); }
.card-badge h3 { margin: 0; font-size: 1.02rem; }

/* ---------- 7. 提示框 ---------- */
.note {
  border-radius: var(--radius-sm); padding: 13px 16px 13px 15px;
  border-left: 4px solid var(--c1); background: var(--c1-soft);
  margin: 14px 0; font-size: 15px;
}
.note > :last-child { margin-bottom: 0; }
.note-title { font-weight: 750; display: block; margin-bottom: 3px; font-size: 14px; letter-spacing: .01em; }
.note.tip { border-left-color: var(--ok); background: var(--ok-soft); }
.note.warn { border-left-color: var(--warn); background: var(--warn-soft); }
.note.danger { border-left-color: var(--danger); background: var(--danger-soft); }
.note.info { border-left-color: var(--accent); background: var(--accent-soft); }
html[data-theme="dark"] .note { background: color-mix(in srgb, var(--c1-soft) 62%, var(--surface)); }
html[data-theme="dark"] .note.tip { background: color-mix(in srgb, var(--ok-soft) 62%, var(--surface)); }
html[data-theme="dark"] .note.warn { background: color-mix(in srgb, var(--warn-soft) 62%, var(--surface)); }
html[data-theme="dark"] .note.danger { background: color-mix(in srgb, var(--danger-soft) 62%, var(--surface)); }
html[data-theme="dark"] .note.info { background: color-mix(in srgb, var(--accent-soft) 62%, var(--surface)); }

/* ---------- 8. 公式 ---------- */
.fml {
  font-family: "Cambria Math", "Latin Modern Math", Georgia, "Times New Roman", var(--font);
  font-style: italic; white-space: nowrap;
  color: var(--text);
}
.fml b, .fml strong { font-style: normal; }
.fml-block {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 13px 18px; margin: 13px 0;
  font-family: "Cambria Math", Georgia, "Times New Roman", var(--font);
  font-size: 1.03rem; text-align: center;
  overflow-x: auto; overflow-y: hidden;
}
.fml-block .fml { font-size: 1.06rem; }
.fml-block .cap { display: block; font-family: var(--font); font-size: 12.5px; color: var(--text-mute); font-style: normal; margin-top: 6px; }

/* 公式速查行 */
.fml-row {
  display: flex; align-items: baseline; gap: 12px;
  padding: 9px 0; border-bottom: 1px dashed var(--border);
}
.fml-row:last-child { border-bottom: 0; }
.fml-row .k { flex: 0 0 34%; font-size: 14.5px; color: var(--text-soft); font-weight: 600; }
.fml-row .v { flex: 1 1 auto; font-family: "Cambria Math", Georgia, serif; font-style: italic; font-size: 1rem; }
@media (max-width: 560px) {
  .fml-row { flex-direction: column; gap: 2px; }
  .fml-row .k { flex: none; font-size: 13.5px; }
}

/* 变量说明 */
.vars { font-size: 14px; color: var(--text-soft); margin: 8px 0 0; padding-left: 0; list-style: none; }
.vars li { padding-left: 15px; position: relative; }
.vars li::before { content: "›"; position: absolute; left: 3px; color: var(--c1); font-weight: 800; }
body[data-chapter="2"] .vars li::before { color: var(--c2); }

/* 希腊字母 / 符号微调 */
.sym { font-family: "Cambria Math", Georgia, serif; font-style: italic; }

/* ---------- 9. 表格 ---------- */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 14px 0; border-radius: var(--radius-sm); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 14.5px; background: var(--surface); min-width: 480px; }
th, td { padding: 10px 13px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--surface-2); font-weight: 700; font-size: 13.5px; color: var(--text-soft); white-space: nowrap; letter-spacing: .01em; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td .fml { font-size: .97rem; }
.tbl-narrow table { min-width: 0; }

/* 提示：手机上可横滑 */
.tbl-hint { display: none; font-size: 12.5px; color: var(--text-mute); margin: -6px 0 12px; }
@media (max-width: 640px) { .tbl-hint { display: block; } }

/* ---------- 10. 列表样式 ---------- */
.list-check { list-style: none; padding-left: 0; }
.list-check li { position: relative; padding-left: 28px; margin: .45em 0; }
.list-check li::before {
  content: "✓"; position: absolute; left: 0; top: .05em;
  width: 19px; height: 19px; border-radius: 50%;
  background: var(--ok-soft); color: var(--ok);
  font-size: 11px; font-weight: 800; display: grid; place-items: center;
}
.list-num { list-style: none; padding-left: 0; counter-reset: n; }
.list-num > li { position: relative; padding-left: 34px; margin: .5em 0; counter-increment: n; }
.list-num > li::before {
  content: counter(n); position: absolute; left: 0; top: .18em;
  width: 22px; height: 22px; border-radius: 7px;
  background: var(--c1-soft); color: var(--c1-dark);
  font-size: 12px; font-weight: 800; display: grid; place-items: center;
}
body[data-chapter="2"] .list-num > li::before { background: var(--c2-soft); color: var(--c2-dark); }

/* 标签 */
.tags { display: flex; flex-wrap: wrap; gap: 7px; margin: 10px 0; }
.tag {
  font-size: 12.5px; font-weight: 650; padding: 5px 13px; border-radius: 999px;
  background: var(--bg-alt); color: var(--text-soft); border: 1px solid var(--border);
  font-family: inherit; cursor: pointer; line-height: 1.4;
  transition: background .16s, color .16s, border-color .16s, box-shadow .16s;
}
.tag:hover { border-color: var(--border-strong); color: var(--text); }
.tag.c1 { background: var(--c1-soft); color: var(--c1-dark); border-color: transparent; }
.tag.c2 { background: var(--c2-soft); color: var(--c2-dark); border-color: transparent; }
.tag.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.tag.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.tag.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.tag.active {
  background: var(--c1); color: #fff; border-color: transparent;
  box-shadow: 0 3px 10px color-mix(in srgb, var(--c1) 40%, transparent);
}
.tag.c2.active { background: var(--c2); box-shadow: 0 3px 10px color-mix(in srgb, var(--c2) 40%, transparent); }
.tag.c1.active { background: var(--c1); }
html[data-theme="dark"] .tag.active { color: #0b1120; }

/* 被筛选隐藏的分支 */
[hidden] { display: none !important; }

/* ---------- 11. 学习路线图（index） ---------- */
.route { position: relative; padding-left: 0; }
.route-step {
  position: relative; padding-left: 64px; padding-bottom: 26px;
}
.route-step::before {   /* 竖线 */
  content: ""; position: absolute; left: 21px; top: 40px; bottom: 0;
  width: 2px; background: linear-gradient(var(--border-strong), var(--border));
}
.route-step:last-child::before { display: none; }
.route-step:last-child { padding-bottom: 0; }
.route-num {
  position: absolute; left: 0; top: 0;
  width: 44px; height: 44px; border-radius: 13px;
  display: grid; place-items: center; font-size: 17px; font-weight: 800;
  background: var(--surface); border: 2px solid var(--c1); color: var(--c1);
  box-shadow: var(--shadow-sm); z-index: 1;
}
.route-step:nth-child(2) .route-num { border-color: var(--c2); color: var(--c2); }
.route-step:nth-child(3) .route-num { border-color: var(--accent); color: var(--accent); }
.route-step:nth-child(4) .route-num { border-color: var(--ok); color: var(--ok); }
.route-step:nth-child(5) .route-num { border-color: var(--warn); color: var(--warn); }
.route-body h3 { font-size: 1.04rem; margin: 8px 0 6px; }
.route-meta { font-size: 12.5px; color: var(--text-mute); font-weight: 650; margin-bottom: 6px; }
.route-body p { color: var(--text-soft); margin-bottom: .6em; }

@media (max-width: 560px) {
  .route-step { padding-left: 52px; }
  .route-num { width: 36px; height: 36px; font-size: 15px; border-radius: 11px; }
  .route-step::before { left: 17px; top: 34px; }
}

/* ---------- 12. 思维导图 ---------- */
.mm-intro {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-bottom: 16px;
}
.mm-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-left: auto; }

.mm {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 26px 24px 30px;
  box-shadow: var(--shadow-sm); overflow-x: auto;
}

.mm-root {
  display: inline-flex; flex-direction: column; gap: 1px;
  padding: 13px 24px; border-radius: 14px;
  background: linear-gradient(135deg, var(--c1), var(--c2));
  color: #fff; box-shadow: 0 8px 22px rgba(37, 99, 235, .28);
  margin-bottom: 20px;
}
.mm-root span { font-size: 11.5px; font-weight: 700; opacity: .85; letter-spacing: .06em; }
.mm-root strong { font-size: 1.06rem; font-weight: 800; letter-spacing: -.01em; }

.mm-tree, .mm-tree ul { list-style: none; margin: 0; padding: 0; }
.mm-tree { padding-left: 0 !important; }
.mm-tree > li { margin: 0; }

/* 一级分支：带色块标题 */
.mm-branch { --mm-line: var(--border-strong); margin: 14px 0 18px; }
.mm-branch > .mm-node {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 8px 16px; border-radius: 11px; font-weight: 750; font-size: 15px;
  background: var(--c1-soft); color: var(--c1-dark);
  border: 1px solid color-mix(in srgb, var(--c1) 32%, transparent);
}
.mm-branch.a2 { --mm-line: color-mix(in srgb, var(--c2) 42%, var(--border)); }
.mm-branch.a2 > .mm-node { background: var(--c2-soft); color: var(--c2-dark); border-color: color-mix(in srgb, var(--c2) 32%, transparent); }
.mm-branch.a3 { --mm-line: color-mix(in srgb, var(--accent) 42%, var(--border)); }
.mm-branch.a3 > .mm-node { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 32%, transparent); }
.mm-branch.a4 { --mm-line: color-mix(in srgb, var(--ok) 42%, var(--border)); }
.mm-branch.a4 > .mm-node { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 32%, transparent); }
.mm-branch.a5 { --mm-line: color-mix(in srgb, var(--warn) 42%, var(--border)); }
.mm-branch.a5 > .mm-node { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 32%, transparent); }
.mm-branch.a6 { --mm-line: color-mix(in srgb, var(--danger) 42%, var(--border)); }
.mm-branch.a6 > .mm-node { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 32%, transparent); }

.mm-branch > .mm-node .n {
  width: 21px; height: 21px; border-radius: 6px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 11.5px; font-weight: 800;
  background: color-mix(in srgb, currentColor 18%, transparent);
}

/* 子级通用：树形肘连接 */
.mm-tree ul { margin-left: 15px; }
.mm-tree ul > li {
  position: relative; padding: 6px 0 6px 30px; margin: 0;
}
.mm-tree ul > li::before {      /* 竖脊 */
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px;
  background: var(--mm-line, var(--line));
}
.mm-tree ul > li:last-child::before { bottom: auto; height: 18px; }
.mm-tree ul > li::after {       /* 肘（横线） */
  content: ""; position: absolute; left: 0; top: 16px; width: 23px; height: 2px;
  background: var(--mm-line, var(--line));
}
.mm-tree ul > li:last-child::after { border-radius: 0 0 0 6px; }

/* 二级节点：显式行高，保证肘线对准文字中线 */
.mm-node2 {
  font-weight: 700; font-size: 14.5px; line-height: 1.45; color: var(--text);
  display: inline-block;
}
.mm-node2 .k { color: var(--c1-dark); font-weight: 800; margin-right: 4px; }
body[data-chapter="2"] .mm-node2 .k { color: var(--c2-dark); }

/* 三级叶子 */
.mm-tree ul ul > li { padding-top: 4px; padding-bottom: 4px; }
.mm-tree ul ul > li::after { top: 14px; }
.mm-tree ul ul > li:last-child::before { height: 16px; }
.mm-leaf { font-size: 14px; line-height: 1.5; color: var(--text-soft); }
.mm-leaf .fml { color: var(--text); }
.mm-leaf strong { color: var(--text); }

/* 折叠 */
.mm-collapsed > ul { display: none; }
.mm-collapsed > .mm-node { opacity: .92; }
.mm-branch.is-collapsed > .mm-node::after {
  content: "＋"; margin-left: 4px; font-size: 12px; opacity: .6;
}
.mm-branch { cursor: default; }
.mm-branch > .mm-node { cursor: pointer; user-select: none; transition: transform .15s, box-shadow .15s; }
.mm-branch > .mm-node:hover { transform: translateX(2px); box-shadow: var(--shadow-sm); }

@media (max-width: 560px) {
  .mm { padding: 18px 14px 22px; }
  .mm-root { padding: 11px 17px; }
  .mm-root strong { font-size: .97rem; }
  .mm-branch > .mm-node { font-size: 14px; padding: 7px 13px; }
  .mm-tree ul { margin-left: 8px; }
  .mm-tree ul > li { padding-left: 22px; }
  .mm-tree ul > li::after { width: 16px; }
  .mm-node2 { font-size: 14px; }
  .mm-leaf { font-size: 13.5px; }
}

/* 图例 */
.mm-legend {
  display: flex; flex-wrap: wrap; gap: 14px; margin-top: 18px;
  padding-top: 16px; border-top: 1px dashed var(--border);
  font-size: 12.5px; color: var(--text-mute);
}
.mm-legend span { display: inline-flex; align-items: center; gap: 6px; }
.mm-legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.mm-legend i.l1 { background: var(--c1); }
.mm-legend i.l2 { background: var(--c2); }
.mm-legend i.l3 { background: var(--accent); }
.mm-legend i.l4 { background: var(--ok); }
.mm-legend i.l5 { background: var(--warn); }
.mm-legend i.l6 { background: var(--danger); }

/* ---------- 13. 章节页双栏（TOC + 内容） ---------- */
.layout { display: grid; grid-template-columns: 236px minmax(0, 1fr); gap: 34px; align-items: start; }
/* 单列时也必须用 minmax(0,1fr)，否则 min-content 下限会被表格的 min-width 撑破视口 */
@media (max-width: 1000px) { .layout { grid-template-columns: minmax(0, 1fr); gap: 0; } }
.layout > * { min-width: 0; }

.toc {
  position: sticky; top: calc(var(--header-h) + 20px);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 14px;
  box-shadow: var(--shadow-sm); max-height: calc(100vh - var(--header-h) - 44px);
  overflow-y: auto;
}
.toc h3 {
  font-size: 12px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--text-mute); margin: 0 0 9px 8px; font-weight: 700;
}
.toc ol { list-style: none; margin: 0; padding: 0; counter-reset: t; }
.toc li { margin: 0; counter-increment: t; }
.toc a {
  display: block; padding: 6.5px 10px; border-radius: 8px;
  font-size: 13.5px; color: var(--text-soft); border-left: 3px solid transparent;
  transition: all .16s;
}
.toc a::before { content: counter(t) ". "; color: var(--text-mute); font-weight: 700; font-variant-numeric: tabular-nums; }
.toc a:hover { background: var(--bg-alt); color: var(--text); text-decoration: none; }
.toc a.active {
  background: var(--c1-soft); color: var(--c1-dark); font-weight: 700;
  border-left-color: var(--c1);
}
body[data-chapter="2"] .toc a.active { background: var(--c2-soft); color: var(--c2-dark); border-left-color: var(--c2); }

/* 手机上 TOC 折叠为顶部块 */
@media (max-width: 1000px) {
  .toc {
    position: static; max-height: none; margin-bottom: 26px;
  }
  .toc h3 { cursor: pointer; display: flex; align-items: center; justify-content: space-between; margin: 0; padding: 2px 4px; }
  .toc h3::after { content: "▾"; font-size: 12px; transition: transform .2s; }
  .toc.closed h3::after { transform: rotate(-90deg); }
  .toc.closed ol { display: none; }
  .toc ol { margin-top: 10px; }
}

/* ---------- 14. 例题块 ---------- */
.ex {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; margin: 16px 0;
  box-shadow: var(--shadow-sm);
}
.ex-head {
  display: flex; align-items: center; gap: 11px; flex-wrap: wrap;
  padding: 13px 18px; background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.ex-tag {
  font-size: 11.5px; font-weight: 800; letter-spacing: .05em;
  padding: 3px 10px; border-radius: 6px;
  background: var(--c1); color: #fff; flex-shrink: 0;
}
body[data-chapter="2"] .ex-tag { background: var(--c2); }
.ex-head h4 { margin: 0; font-size: .98rem; font-weight: 700; }
.ex-body { padding: 16px 18px; }
.ex-body > :last-child { margin-bottom: 0; }
.ex-q { color: var(--text); font-size: 15px; }
.ex-sol { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); }
.ex-sol h5 {
  font-size: 12.5px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-mute); margin: 0 0 8px; font-weight: 750;
}
.ex-ans {
  display: inline-flex; flex-wrap: wrap; gap: 10px 18px;
  background: var(--ok-soft); border-radius: var(--radius-sm);
  padding: 10px 15px; margin-top: 10px; font-size: 14.5px;
}
html[data-theme="dark"] .ex-ans { background: color-mix(in srgb, var(--ok-soft) 62%, var(--surface)); }
.ex-ans b { color: var(--ok); font-weight: 750; }

/* ---------- 15. 自测题 ---------- */
.quiz { margin: 16px 0; }
.quiz details {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); margin-bottom: 10px;
  box-shadow: var(--shadow-sm); overflow: hidden;
}
.quiz summary {
  cursor: pointer; padding: 13px 17px; font-weight: 600; font-size: 15px;
  display: flex; align-items: flex-start; gap: 11px; list-style: none;
  transition: background .15s;
}
.quiz summary::-webkit-details-marker { display: none; }
.quiz summary:hover { background: var(--surface-2); }
.quiz summary::before {
  content: "Q"; flex-shrink: 0; width: 22px; height: 22px; border-radius: 7px;
  display: grid; place-items: center; font-size: 11.5px; font-weight: 800;
  background: var(--c1-soft); color: var(--c1-dark); margin-top: 2px;
}
body[data-chapter="2"] .quiz summary::before { background: var(--c2-soft); color: var(--c2-dark); }
.quiz details[open] summary { border-bottom: 1px solid var(--border); background: var(--surface-2); }
.quiz .ans {
  padding: 14px 17px 16px 50px; font-size: 15px; color: var(--text-soft);
}
.quiz .ans > :last-child { margin-bottom: 0; }
.quiz .ans b { color: var(--ok); }
@media (max-width: 560px) { .quiz .ans { padding-left: 17px; } }

/* ---------- 16. 章节入口卡片 ---------- */
.ch-card {
  display: block; position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 22px 24px;
  box-shadow: var(--shadow-sm); transition: all .22s ease; height: 100%;
  color: inherit;
}
.ch-card:hover {
  text-decoration: none; transform: translateY(-4px);
  box-shadow: var(--shadow-lg); border-color: var(--c1);
}
.ch-card.c2:hover { border-color: var(--c2); }
.ch-card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: linear-gradient(90deg, var(--c1), var(--c1-dark));
}
.ch-card.c2::before { background: linear-gradient(90deg, var(--c2), var(--c2-dark)); }
.ch-card.cmk::before { background: linear-gradient(90deg, var(--accent), var(--ok)); }
.ch-card .ch-no {
  font-size: 11.5px; font-weight: 800; letter-spacing: .1em;
  color: var(--c1); text-transform: uppercase;
}
.ch-card.c2 .ch-no { color: var(--c2); }
.ch-card.cmk .ch-no { color: var(--accent); }
.ch-card h3 { font-size: 1.14rem; margin: 5px 0 8px; }
.ch-card p { color: var(--text-soft); font-size: 14.5px; margin-bottom: 13px; }
.ch-card .go {
  font-size: 13.5px; font-weight: 700; color: var(--c1);
  display: inline-flex; align-items: center; gap: 5px;
}
.ch-card.c2 .go { color: var(--c2); }
.ch-card.cmk .go { color: var(--accent); }
.ch-card:hover .go { gap: 9px; }
.ch-card ul { font-size: 13.5px; color: var(--text-mute); margin-bottom: 14px; }

/* ---------- 17. 页脚 ---------- */
.site-footer {
  border-top: 1px solid var(--border); background: var(--surface);
  padding: 30px 0 34px; color: var(--text-mute); font-size: 13.5px;
}
.footer-grid { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; justify-content: space-between; }
.footer-grid > div { min-width: 200px; }
.footer-grid h4 { font-size: 13.5px; color: var(--text); margin-bottom: .5em; }
.site-footer a { color: var(--text-soft); }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin: .3em 0; }
.footer-bottom {
  margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border);
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between;
}

/* ---------- 18. 回到顶部 ---------- */
.to-top {
  position: fixed; right: 20px; bottom: 22px; z-index: 90;
  width: 44px; height: 44px; border-radius: 13px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-soft); font-size: 18px;
  display: grid; place-items: center; box-shadow: var(--shadow);
  opacity: 0; visibility: hidden; transform: translateY(10px);
  transition: all .24s ease;
}
.to-top.show { opacity: 1; visibility: visible; transform: none; }
.to-top:hover { background: var(--c1); color: #fff; border-color: var(--c1); }
@media (max-width: 560px) { .to-top { right: 14px; bottom: 14px; width: 40px; height: 40px; } }

/* ---------- 19. 阅读进度条 ---------- */
.progress {
  position: fixed; top: 0; left: 0; height: 3px; z-index: 200;
  background: linear-gradient(90deg, var(--c1), var(--c2));
  width: 0; transition: width .1s linear;
}

/* ---------- 20. 打印 ---------- */
@media print {
  .site-header, .to-top, .progress, .toc, .hero-actions, .mm-toolbar, .site-footer { display: none !important; }
  body { background: #fff; font-size: 11pt; }
  .card, .ex, .mm { box-shadow: none; break-inside: avoid; }
  .layout { grid-template-columns: 1fr; }
  .quiz details { break-inside: avoid; }
  .quiz details[open] .ans { display: block; }
}

/* ---------- 21. 降低动效偏好 ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}