/* ============================================================
   ML 图谱 · 样式表
   设计系统：深邃科技风 + 渐变高亮 + 玻璃拟态卡片
   ============================================================ */

:root {
  /* 主题色 */
  --accent-1: #6c5ce7; /* 靛紫 */
  --accent-2: #00d4ff; /* 青蓝 */
  --accent-3: #ff7ac6; /* 粉 */
  --accent-4: #00e6a0; /* 绿 */
  --accent-5: #ffb85c; /* 橙 */
  --accent-6: #5c9bff; /* 蓝 */

  /* 分类配色 */
  --c-super: #00d4ff;   /* 监督学习 */
  --c-unsuper: #00e6a0; /* 无监督 */
  --c-ensemble: #ffb85c;/* 集成学习 */
  --c-dl: #ff7ac6;      /* 深度学习 */
  --c-stat: #5c9bff;    /* 统计 */

  /* 深浅主题（默认深色） */
  --bg: #0a0e1a;
  --bg-soft: #0e1424;
  --surface: #121a2e;
  --surface-2: #162036;
  --border: #243050;
  --border-strong: #31406b;
  --text: #e9eefb;
  --text-soft: #c2cbe4;
  --muted: #8b95b8;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --glow: 0 0 24px rgba(0, 212, 255, 0.25);
  --code-bg: #0c1224;
  --code-fg: #cfe3ff;      /* 代码块文字（浅色） */
  --code-inline-fg: #7ee8c4;
  --header-bg: rgba(10, 14, 26, 0.72);

  --grad-main: linear-gradient(135deg, #6c5ce7 0%, #00d4ff 100%);
  --grad-soft: linear-gradient(135deg, rgba(108,92,231,.18), rgba(0,212,255,.18));

  --radius: 16px;
  --radius-sm: 10px;
  --sidebar-w: 280px;
  --font-sans: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Noto Sans SC", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", "Fira Code", ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
}

/* 浅色主题 */
html[data-theme="light"] {
  --bg: #f4f6fc;
  --bg-soft: #eceff8;
  --surface: #ffffff;
  --surface-2: #f6f8fd;
  --border: #dde3f0;
  --border-strong: #c6cfe4;
  --text: #1a2338;
  --text-soft: #3a4663;
  --muted: #6b7795;
  --shadow: 0 12px 32px rgba(30, 42, 80, 0.10);
  --glow: 0 0 20px rgba(0, 150, 220, 0.18);
  --code-bg: #eef1f7;      /* 浅色主题：浅底深字——避免被「智能夜间模式」反转成黑底黑字 */
  --code-fg: #1f2937;
  --code-inline-fg: #0b7a5c;
  --header-bg: rgba(244, 246, 252, 0.82);
  --grad-soft: linear-gradient(135deg, rgba(108,92,231,.10), rgba(0,180,230,.12));
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; scroll-padding-top: 24px; color-scheme: dark; }
html[data-theme="light"] { color-scheme: light; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background .35s ease, color .35s ease;
}

::selection { background: rgba(0, 212, 255, .3); }

/* 自定义滚动条 */
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--accent-2); }

a { color: var(--accent-2); text-decoration: none; }

/* ============ 阅读进度条 ============ */
.read-progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 0%;
  background: var(--grad-main); z-index: 200;
  box-shadow: 0 0 12px rgba(0,212,255,.6);
  transition: width .1s linear;
}

/* ============ 侧边栏 ============ */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w);
  background: var(--header-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 100;
  transition: transform .35s cubic-bezier(.4,0,.2,1);
}

.sidebar__brand {
  display: flex; align-items: center; gap: 12px;
  padding: 22px 20px 14px;
}
.sidebar__collapse {
  margin-left: auto; flex: none;
  width: 26px; height: 26px; border-radius: 8px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--muted); cursor: pointer; font-size: 14px; line-height: 1;
  transition: all .18s ease;
}
.sidebar__collapse:hover { color: var(--text); border-color: var(--accent-2); transform: translateX(-2px); }
.brand__mark {
  display: grid; place-items: center;
  width: 42px; height: 42px; border-radius: 12px;
  background: var(--grad-soft); border: 1px solid var(--border);
  animation: float 5s ease-in-out infinite;
}
.brand__text { display: flex; flex-direction: column; line-height: 1.25; }
.brand__text strong { font-size: 17px; letter-spacing: .5px; }
.brand__text span { font-size: 11.5px; color: var(--muted); }

.sidebar__search { position: relative; margin: 6px 16px 14px; }
.sidebar__search input {
  width: 100%; padding: 10px 14px 10px 36px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  font-size: 13.5px; outline: none;
  transition: border .2s, box-shadow .2s;
}
.sidebar__search input:focus { border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(0,212,255,.15); }
.sidebar__search input::placeholder { color: var(--muted); }
.search__icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 18px; }

.sidebar__nav { flex: 1; overflow-y: auto; padding: 4px 10px 16px; }
.nav-section {
  margin: 8px 6px 4px; padding: 6px 8px;
  font-size: 11px; font-weight: 600; letter-spacing: 1.5px;
  color: var(--muted); text-transform: uppercase;
}
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; margin: 2px 0; border-radius: 9px;
  color: var(--text-soft); font-size: 13.5px; cursor: pointer;
  border: 1px solid transparent;
  transition: background .18s, color .18s, transform .18s;
}
.nav-link:hover { background: var(--surface); color: var(--text); transform: translateX(3px); }
.nav-link.active {
  background: var(--grad-soft); color: var(--text);
  border-color: var(--border);
}
.nav-link .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; box-shadow: 0 0 8px currentColor; }
.nav-link .num { font-size: 11px; color: var(--muted); margin-left: auto; font-family: var(--font-mono); }

/* ============ 主内容 ============ */
.main { margin-left: var(--sidebar-w); min-height: 100vh; }

/* 顶部栏（移动端） */
.topbar {
  position: sticky; top: 0; z-index: 90;
  display: none; align-items: center; gap: 12px;
  padding: 12px 16px; background: var(--header-bg);
  backdrop-filter: blur(14px); border-bottom: 1px solid var(--border);
}
.topbar__menu {
  display: grid; gap: 4px; padding: 6px;
  background: transparent; border: none; cursor: pointer;
}
.topbar__menu span { width: 20px; height: 2px; background: var(--text); border-radius: 2px; }
.topbar__title { font-weight: 700; letter-spacing: .5px; }
.topbar__theme { margin-left: auto; background: var(--surface); border: 1px solid var(--border); color: var(--text); width: 36px; height: 36px; border-radius: 10px; cursor: pointer; font-size: 16px; }

.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  opacity: 0; pointer-events: none; z-index: 95; transition: opacity .3s;
}
body.menu-open .overlay { opacity: 1; pointer-events: auto; }

/* ============ Hero ============ */
.hero {
  position: relative; min-height: 92vh;
  display: flex; align-items: center; justify-content: center;
  padding: 80px 40px 60px; overflow: hidden;
  text-align: center;
}
.hero__canvas { position: absolute; inset: 0; z-index: 0; opacity: .9; }
.hero__canvas canvas { width: 100%; height: 100%; display: block; }
.hero__inner { position: relative; z-index: 1; max-width: 880px; }
.hero__eyebrow {
  display: inline-block; padding: 6px 16px; border-radius: 100px;
  background: var(--grad-soft); border: 1px solid var(--border);
  color: var(--accent-2); font-size: 13px; font-weight: 600; letter-spacing: 1px;
  margin-bottom: 22px; animation: fadeUp .7s ease both;
}
.hero__title {
  font-size: clamp(40px, 7vw, 76px); font-weight: 800; line-height: 1.08;
  letter-spacing: -1px; margin-bottom: 20px; animation: fadeUp .7s .08s ease both;
}
.hero__title .grad {
  background: var(--grad-main); -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: gradShift 6s ease infinite;
}
.hero__sub {
  font-size: clamp(15px, 2vw, 18px); color: var(--text-soft);
  max-width: 720px; margin: 0 auto 30px; animation: fadeUp .7s .16s ease both;
}
.hero__sub strong { color: var(--text); font-weight: 600; }
.hero__cta { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; animation: fadeUp .7s .24s ease both; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 13px 26px; border-radius: 100px; font-size: 15px; font-weight: 600;
  cursor: pointer; transition: transform .2s, box-shadow .2s, background .2s;
  border: 1px solid transparent;
}
.btn--primary { background: var(--grad-main); color: #fff; box-shadow: 0 8px 24px rgba(0,140,220,.35); }
.btn--primary:hover { transform: translateY(-3px); box-shadow: 0 14px 34px rgba(0,160,240,.45); }
.btn--primary span { transition: transform .2s; }
.btn--primary:hover span { transform: translateX(4px); }
.btn--ghost { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn--ghost:hover { transform: translateY(-3px); border-color: var(--accent-2); color: var(--accent-2); }

.hero__stats {
  display: flex; gap: 40px; justify-content: center; margin-top: 46px;
  animation: fadeUp .7s .32s ease both;
}
.stat { display: flex; flex-direction: column; }
.stat strong { font-size: 30px; font-family: var(--font-mono); color: var(--text); }
.stat span { font-size: 13px; color: var(--muted); }

.hero__scroll {
  position: absolute; bottom: 28px; left: 50%; transform: translateX(-50%);
  color: var(--muted); font-size: 12px; letter-spacing: 1px;
  display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 1;
}
.hero__scroll span {
  width: 22px; height: 34px; border: 2px solid var(--border-strong); border-radius: 12px; position: relative;
}
.hero__scroll span::after {
  content: ""; position: absolute; top: 6px; left: 50%; width: 4px; height: 7px;
  margin-left: -2px; background: var(--accent-2); border-radius: 2px;
  animation: scrollDot 1.6s ease infinite;
}

/* ============ 知识图谱大图 ============ */
.graph-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 18px; }
.graph-toolbar .chip.active { color: #0c1224; }
.graph-reset {
  background: var(--surface); border: 1px solid var(--border); color: var(--muted);
  padding: 5px 13px; border-radius: 999px; font-size: 12px; cursor: pointer;
  font-family: inherit; transition: all .18s ease;
}
.graph-reset:hover { color: var(--accent-2); border-color: var(--accent-2); }
.graph-wrap {
  position: relative; border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; background: var(--bg-soft);
}
.graph-wrap canvas { display: block; width: 100%; touch-action: none; cursor: grab; }
.graph-wrap canvas:active { cursor: grabbing; }

/* ============ 通用 Section ============ */
.section { padding: 70px 40px; max-width: 1200px; margin: 0 auto; }
.section__head { margin-bottom: 42px; max-width: 780px; }
.eyebrow {
  display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: 2px;
  color: var(--accent-2); margin-bottom: 10px;
}
.section__head h2 { font-size: clamp(26px, 4vw, 40px); font-weight: 800; letter-spacing: -.5px; margin-bottom: 12px; }
.section__desc { color: var(--text-soft); font-size: 16px; }

/* 滚动进入动画 */
.reveal { opacity: 0; transform: translateY(28px); transition: opacity .7s ease, transform .7s cubic-bezier(.2,.7,.2,1); }
.reveal.in-view { opacity: 1; transform: none; }

/* ============ 路线图 ============ */
.roadmap { display: flex; flex-wrap: wrap; gap: 14px; align-items: stretch; }
.roadmap-stage {
  flex: 1 1 170px; min-width: 160px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 16px; position: relative; overflow: hidden;
  transition: transform .25s, border-color .25s, box-shadow .25s;
}
.roadmap-stage:hover { transform: translateY(-6px); border-color: var(--border-strong); box-shadow: var(--shadow); }
.roadmap-stage::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--stage-color, var(--accent-2));
}
.roadmap-stage .stage__no {
  font-size: 11px; font-family: var(--font-mono); color: var(--muted);
  letter-spacing: 1px;
}
.roadmap-stage h4 { font-size: 16px; margin: 6px 0 8px; }
.roadmap-stage ul { list-style: none; }
.roadmap-stage li {
  font-size: 12.5px; color: var(--text-soft); padding: 3px 0 3px 16px; position: relative;
}
.roadmap-stage li::before {
  content: ""; position: absolute; left: 2px; top: 11px; width: 6px; height: 6px;
  border-radius: 50%; background: var(--stage-color, var(--accent-2)); opacity: .7;
}

/* ============ 方法论卡片 ============ */
.method-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.method-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; position: relative; overflow: hidden;
  transition: transform .25s, border-color .25s;
}
.method-card:hover { transform: translateY(-5px); border-color: var(--border-strong); }
.method-card .m-no {
  font-size: 34px; font-weight: 800; font-family: var(--font-mono);
  background: var(--grad-main); -webkit-background-clip: text; background-clip: text; color: transparent;
  opacity: .55; line-height: 1;
}
.method-card h4 { font-size: 16.5px; margin: 8px 0 8px; }
.method-card p { font-size: 13.5px; color: var(--text-soft); }

/* ============ 主题卡片 ============ */
.topic-list { display: flex; flex-direction: column; gap: 26px; }

.topic {
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  overflow: hidden; position: relative;
  transition: box-shadow .3s, border-color .3s;
  /* 96 张卡片的长页：跳过视口外卡片的渲染（布局/绘制），显著降低滚动与首帧成本 */
  content-visibility: auto;
  contain-intrinsic-size: auto 860px;
}
/* 窄屏卡片更高（标签换行/面板堆叠），占位估计同步放大，减少滚动跳动 */
@media (max-width: 720px) {
  .topic { contain-intrinsic-size: auto 1250px; }
}
.topic:hover { border-color: var(--border-strong); }
.topic::before {
  content: ""; position: absolute; top: 0; left: 0; width: 100%; height: 3px;
  background: linear-gradient(90deg, var(--topic-accent, var(--accent-2)), transparent);
  opacity: .8;
}

.topic__header { padding: 26px 28px 18px; }
.topic__top { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.topic__icon {
  width: 54px; height: 54px; border-radius: 14px; flex: none;
  display: grid; place-items: center; font-size: 27px;
  background: var(--grad-soft); border: 1px solid var(--border);
}
.topic__title-group { flex: 1; min-width: 200px; }
.topic__title-group h3 { font-size: 24px; font-weight: 800; letter-spacing: -.3px; display: flex; align-items: center; gap: 10px; }
.topic__name mark { background: rgba(255,224,102,.45); color: inherit; border-radius: 3px; padding: 0 2px; }
.topic__title-group .en { font-size: 13px; color: var(--muted); font-family: var(--font-mono); }
.topic__num { font-family: var(--font-mono); font-size: 13px; color: var(--muted); }

.topic__tags { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.tag {
  font-size: 11.5px; font-weight: 600; padding: 4px 11px; border-radius: 100px;
  border: 1px solid var(--border-strong); color: var(--text-soft); letter-spacing: .3px;
}
.tag--cat { color: var(--tag-color, var(--accent-2)); border-color: var(--tag-color, var(--accent-2)); background: color-mix(in srgb, var(--tag-color, var(--accent-2)) 10%, transparent); }
.tag--diff { color: var(--accent-5); border-color: var(--accent-5); background: rgba(255,184,92,.1); }

.topic__tagline {
  margin-top: 14px; font-size: 15.5px; color: var(--text-soft);
  padding-left: 14px; border-left: 3px solid var(--topic-accent, var(--accent-2));
}

/* ============ 标签页 ============ */
.topic__tabs {
  display: flex; gap: 4px; padding: 0 28px;
  border-bottom: 1px solid var(--border); overflow-x: auto;
  scrollbar-width: none;
}
.topic__tabs::-webkit-scrollbar { display: none; }
.tab-btn {
  padding: 12px 15px; font-size: 14px; font-weight: 600; color: var(--muted);
  background: none; border: none; cursor: pointer; white-space: nowrap;
  border-bottom: 2px solid transparent; transition: color .2s, border-color .2s;
  font-family: inherit;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--topic-accent, var(--accent-2)); border-bottom-color: var(--topic-accent, var(--accent-2)); }

.topic__body { padding: 24px 28px 30px; }
.tab-panel { display: none; animation: tabIn .35s ease; }
.tab-panel.active { display: block; }

/* ============ 内容排版 ============ */
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 12px; padding: 12px 0; border-bottom: 1px dashed var(--border); }
.kv:last-child { border-bottom: none; }
.kv dt { font-weight: 700; color: var(--topic-accent, var(--accent-2)); font-size: 14px; }
.kv dd { color: var(--text-soft); font-size: 14.5px; }

.pros-cons { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .pros-cons { grid-template-columns: 1fr; } }
.pc-box { border-radius: var(--radius-sm); padding: 18px; }
.pc-box--pros { background: rgba(0,230,160,.07); border: 1px solid rgba(0,230,160,.25); }
.pc-box--cons { background: rgba(255,120,120,.06); border: 1px solid rgba(255,120,120,.25); }
.pc-box h5 { font-size: 14px; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.pc-box--pros h5 { color: var(--accent-4); }
.pc-box--cons h5 { color: #ff7b7b; }
.pc-box li { list-style: none; font-size: 13.5px; color: var(--text-soft); padding: 4px 0 4px 18px; position: relative; }
.pc-box--pros li::before { content: "✓"; position: absolute; left: 0; color: var(--accent-4); }
.pc-box--cons li::before { content: "✕"; position: absolute; left: 0; color: #ff7b7b; }

/* 时间线 */
.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 4px; bottom: 4px; width: 2px; background: var(--border-strong); }
.tl-item { position: relative; padding: 0 0 16px 12px; }
.tl-item::before {
  content: ""; position: absolute; left: -21px; top: 6px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--topic-accent, var(--accent-2));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--topic-accent, var(--accent-2)) 25%, transparent);
}
.tl-item .year { font-family: var(--font-mono); font-size: 12px; font-weight: 700; color: var(--topic-accent, var(--accent-2)); }
.tl-item p { font-size: 13.5px; color: var(--text-soft); }

/* 列表 */
.plain-list { list-style: none; }
.plain-list li { padding: 5px 0 5px 20px; position: relative; font-size: 14.5px; color: var(--text-soft); }
.plain-list li::before { content: "▸"; position: absolute; left: 2px; color: var(--topic-accent, var(--accent-2)); }

/* 笔记步骤 */
.learn-steps { display: flex; flex-direction: column; gap: 10px; }
.learn-step { display: flex; gap: 14px; align-items: flex-start; background: var(--surface-2); border-radius: var(--radius-sm); padding: 13px 16px; }
.learn-step .ls-no {
  flex: none; width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center;
  background: var(--topic-accent, var(--accent-2)); color: #0a0e1a; font-weight: 800; font-size: 13px;
}
.learn-step p { font-size: 14px; color: var(--text-soft); }
.learn-step p strong { color: var(--text); }

/* 公式 */
.formula-box {
  background: var(--code-bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 20px; margin: 8px 0 12px;
  overflow-x: auto;
}
.formula { font-family: var(--font-mono); font-size: 19px; color: #cfe3ff; white-space: nowrap; text-align: center; }
.formula .frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; margin: 0 3px; }
.formula .frac .num { border-bottom: 1px solid currentColor; padding: 0 6px 2px; }
.formula .frac .den { padding: 2px 6px 0; }
.formula .op { color: var(--accent-3); }
.formula .sym { color: var(--accent-2); }
.formula .fn { color: var(--accent-5); }
.formula-text { font-size: 13px; color: var(--muted); margin-top: 6px; }

/* 代码块 */
.code-block {
  background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 16px 18px; font-family: var(--font-mono); font-size: 13px; line-height: 1.6;
  overflow-x: auto; color: #cfe3ff; margin: 10px 0;
}
.code-block .c { color: #6b7795; }
.code-block .k { color: #ff7ac6; }
.code-block .f { color: #00d4ff; }

/* ============ 演示区 ============ */
.demo {
  margin-top: 6px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); overflow: hidden;
}
.demo__head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.demo__head h5 { font-size: 14.5px; font-weight: 700; }
.demo__head .demo__badge {
  font-size: 10.5px; padding: 3px 9px; border-radius: 100px; letter-spacing: 1px;
  background: var(--grad-soft); border: 1px solid var(--border); color: var(--accent-2); font-weight: 700;
}
.demo__controls { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; align-items: center; }
.demo__canvas-wrap { position: relative; }
.demo__canvas-wrap canvas { width: 100%; height: auto; display: block; }
.demo__foot { padding: 10px 18px; font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--border); }

/* 控件 */
.ctrl-btn {
  padding: 7px 14px; font-size: 12.5px; font-weight: 600; border-radius: 8px; cursor: pointer;
  background: var(--surface); color: var(--text-soft); border: 1px solid var(--border-strong);
  transition: all .18s; font-family: inherit;
}
.ctrl-btn:hover { border-color: var(--accent-2); color: var(--accent-2); }
.ctrl-btn.primary { background: var(--grad-main); color: #fff; border-color: transparent; }
.ctrl-btn.primary:hover { color: #fff; opacity: .9; }
.ctrl-select, .ctrl-input {
  padding: 7px 10px; font-size: 12.5px; border-radius: 8px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); outline: none; font-family: inherit;
}
.ctrl-range { accent-color: var(--accent-2); cursor: pointer; }
.ctrl-label { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }

/* ============ 资源网格 ============ */
.resource-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.resource-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; transition: transform .25s, border-color .25s;
}
.resource-card:hover { transform: translateY(-5px); border-color: var(--border-strong); }
.resource-card .rc-tag { font-size: 11px; font-weight: 700; letter-spacing: 1px; color: var(--accent-3); }
.resource-card h4 { font-size: 16px; margin: 6px 0 8px; }
.resource-card p { font-size: 13px; color: var(--text-soft); margin-bottom: 10px; }
.resource-card a { font-size: 13px; font-weight: 600; }


/* ============ 侧栏整体收起（桌面） ============ */
.sidebar-show {
  position: fixed; top: 14px; left: 14px; z-index: 210;
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); cursor: pointer; font-size: 17px;
  box-shadow: var(--shadow);
  display: none; align-items: center; justify-content: center;
  transition: all .18s ease;
}
.sidebar-show:hover { background: var(--grad-main); color: #fff; border-color: transparent; }
@media (min-width: 901px) {
  body.sidebar-hidden .sidebar { transform: translateX(-100%); box-shadow: none; }
  body.sidebar-hidden .main { margin-left: 0; }
  body.sidebar-hidden .sidebar-show { display: flex; }
  body.sidebar-hidden .sidebar__collapse { display: none; }
}

/* ============ 页脚 / 回顶 ============ */
.footer { padding: 40px; text-align: center; color: var(--muted); font-size: 13px; border-top: 1px solid var(--border); }
.footer p + p { margin-top: 6px; }

.backtop {
  position: fixed; right: 26px; bottom: 26px; z-index: 80;
  width: 46px; height: 46px; border-radius: 50%; font-size: 20px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); cursor: pointer;
  opacity: 0; pointer-events: none; transform: translateY(12px);
  transition: all .3s; box-shadow: var(--shadow);
}
.backtop.show { opacity: 1; pointer-events: auto; transform: none; }
.backtop:hover { background: var(--grad-main); color: #fff; border-color: transparent; }

/* 固定主题切换（桌面端） */
.theme-fixed {
  position: fixed; top: 18px; right: 24px; z-index: 85;
  width: 42px; height: 42px; border-radius: 12px; font-size: 18px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong);
  cursor: pointer; box-shadow: var(--shadow); transition: all .25s;
}
.theme-fixed:hover { background: var(--grad-main); color: #fff; border-color: transparent; }
@media (max-width: 900px) { .theme-fixed { display: none; } }

/* 固定 GitHub 仓库入口（桌面端，主题切换钮左侧） */
.gh-fixed {
  position: fixed; top: 18px; right: 78px; z-index: 85;
  width: 42px; height: 42px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong);
  box-shadow: var(--shadow); transition: all .25s;
}
.gh-fixed svg { width: 22px; height: 22px; fill: currentColor; }
.gh-fixed:hover { background: var(--grad-main); color: #fff; border-color: transparent; transform: translateY(-2px); }
@media (max-width: 900px) { .gh-fixed { display: none; } }

/* 移动端 topbar 内的 GitHub 入口（主题钮右侧） */
.topbar__gh {
  display: flex; align-items: center; margin-left: 10px;
  color: var(--text); text-decoration: none;
}
.topbar__gh svg { width: 21px; height: 21px; fill: currentColor; }

/* ============ 动画 ============ */
@keyframes fadeUp { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
@keyframes tabIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes gradShift { 0%,100% { filter: hue-rotate(0deg); } 50% { filter: hue-rotate(18deg); } }
@keyframes scrollDot { 0% { transform: translateY(0); opacity: 1; } 70% { transform: translateY(14px); opacity: 0; } 100% { opacity: 0; } }
@keyframes pulse { 0%,100% { opacity: .6; } 50% { opacity: 1; } }

/* ============ 响应式 ============ */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  body.menu-open .sidebar { transform: none; }
  .main { margin-left: 0; }
  .topbar { display: flex; }
  .section { padding: 50px 20px; }
  .hero { padding: 70px 20px 60px; }
  .kv { grid-template-columns: 1fr; gap: 4px; }
  .kv dt { margin-top: 6px; }
}

/* 无障碍：减少动态 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; transition-duration: .001s !important; }
  html { scroll-behavior: auto; }
}

/* ============================================================
   深度阅读（markdown 长文）
   ============================================================ */
.deep-mount { max-width: 820px; }
.deep-loading { color: var(--muted); font-size: 14px; padding: 24px 0; }

/* --- 加载失败提示 --- */
.deep-error {
  border: 1px solid var(--border); border-left: 3px solid var(--accent-5);
  background: var(--surface-2); border-radius: 12px; padding: 18px 20px;
  font-size: 14px; line-height: 1.85; color: var(--text-soft);
}
.deep-error__title { font-weight: 700; color: var(--accent-5); margin-bottom: 8px; font-size: 15px; }
.deep-error p { margin: 6px 0; }
.deep-error ul { margin: 8px 0 8px 20px; }
.deep-error li { margin: 4px 0; }
.deep-error code {
  background: var(--code-bg); border: 1px solid var(--border);
  border-radius: 5px; padding: 1px 6px; font-size: 12.5px; color: var(--accent-2);
  font-family: "SF Mono", Menlo, Consolas, monospace;
}
.deep-error__note { color: var(--muted); font-size: 13px; }

/* --- 目录 --- */
.md-toc {
  border: 1px solid var(--border); border-radius: 12px;
  background: linear-gradient(135deg, rgba(108,92,231,.08), rgba(0,212,255,.06));
  padding: 14px 18px 16px; margin: 0 0 26px;
}
.md-toc__title {
  font-size: 12px; font-weight: 700; letter-spacing: .12em;
  color: var(--accent-2); text-transform: uppercase; margin-bottom: 8px;
}
.md-toc ul { list-style: none; margin: 0; padding: 0; }
.md-toc li { margin: 3px 0; }
.md-toc__l3 { padding-left: 18px; }
.md-toc a { color: var(--text-soft); text-decoration: none; font-size: 14px; }
.md-toc a:hover { color: var(--accent-2); text-decoration: underline; }

/* --- 正文排版 --- */
.deep-mount h1, .deep-mount h2, .deep-mount h3,
.deep-mount h4, .deep-mount h5, .deep-mount h6 { scroll-margin-top: 84px; line-height: 1.4; }
.md-h1 { font-size: 26px; margin: 8px 0 20px; padding-bottom: 12px; border-bottom: 2px solid var(--border); color: var(--text); }
.md-h2 { font-size: 21px; margin: 38px 0 14px; padding-left: 12px; border-left: 4px solid var(--accent-2); color: var(--text); }
.md-h3 { font-size: 17px; margin: 26px 0 10px; color: var(--accent-2); }
.md-h4 { font-size: 15px; margin: 20px 0 8px; color: var(--text-soft); }
.md-h5, .md-h6 { font-size: 14px; margin: 16px 0 6px; color: var(--muted); }

.md-p { margin: 13px 0; font-size: 15px; line-height: 1.95; color: var(--text-soft); }
.deep-mount strong { color: var(--text); font-weight: 700; }
.deep-mount em { color: var(--accent-5); font-style: normal; }
.deep-mount del { color: var(--muted); }
.deep-mount a { color: var(--accent-2); text-decoration: none; border-bottom: 1px solid rgba(0,212,255,.35); }
.deep-mount a:hover { border-bottom-color: var(--accent-2); }

.md-hr { border: none; border-top: 1px dashed var(--border-strong); margin: 34px 0; }
.md-img { max-width: 100%; border-radius: 10px; margin: 14px 0; border: 1px solid var(--border); }

/* --- 行内代码与公式 --- */
.md-code-inline {
  background: var(--code-bg); border: 1px solid var(--border); border-radius: 5px;
  padding: 1px 6px; font-size: 13px; color: var(--code-inline-fg);
  font-family: "SF Mono", Menlo, Consolas, monospace;
}
/* --- 公式（LaTeX 子集渲染）--- */
.md-math, .md-formula {
  font-family: "Cambria Math", "Latin Modern Math", "STIX Two Math", "Times New Roman", Georgia, "Songti SC", serif;
  font-style: italic; color: var(--text); line-height: 1.35;
}
.md-math { padding: 0 2px; font-size: 1.04em; }
.md-math .m-op, .md-formula .m-op,
.md-math .m-text, .md-formula .m-text,
.md-math .m-raw, .md-formula .m-raw { font-style: normal; }
.md-math .m-text, .md-formula .m-text { font-family: inherit; }
.m-op { margin-right: .12em; }
.m-raw { color: var(--accent-5); }
.m-sp { display: inline-block; }

/* 上下标 */
.m-scr > sub, .m-scr > sup { font-size: .68em; font-style: inherit; }
.m-scr > sub { vertical-align: -.3em; }
.m-scr > sup { vertical-align: .58em; }

/* 分数 */
.m-frac { display: inline-block; vertical-align: -.56em; text-align: center; margin: 0 .14em; font-size: .97em; }
.m-frac > .m-num { display: block; padding: 0 .3em .1em; border-bottom: 1.3px solid currentColor; }
.m-frac > .m-den { display: block; padding: .1em .3em 0; }

/* 根号 */
.m-sqrt { display: inline-flex; align-items: flex-start; }
.m-sqrt > .m-radic { font-style: normal; }
.m-sqrt > .m-rad { border-top: 1.3px solid currentColor; padding: .17em .2em 0 .12em; margin-top: .04em; }

/* 重音（上加符号） */
.m-acc { position: relative; display: inline-block; }
.m-acc::after { position: absolute; left: 0; right: 0; text-align: center; font-style: normal; line-height: 1; }
.m-acc--bar::after { content: ''; top: -.05em; border-top: 1.4px solid currentColor; }
.m-acc--hat::after { content: '^'; top: -.66em; font-size: .92em; }
.m-acc--tilde::after { content: '~'; top: -.54em; font-size: 1.05em; }
.m-acc--dot::after { content: '\00B7'; top: -.68em; }
.m-acc--vec::after { content: '\2192'; top: -.66em; font-size: .85em; }

/* 二项式系数 */
.m-bin-coef { display: inline-flex; flex-direction: column; vertical-align: -.62em; text-align: center; margin: 0 .12em; }
.m-bin-in { display: block; padding: 0 .3em; font-size: .92em; }

/* 自动间距（模拟 LaTeX 的二元关系符/运算符间距） */
.m-rel { margin: 0 .24em; }
.m-bin { margin: 0 .18em; }

/* 定界符（\left( \right) 等自动放大） */
.m-delim--auto { font-size: 1.32em; vertical-align: -.16em; font-style: normal; }
.m-delim--md { font-size: 1.45em; vertical-align: -.18em; font-style: normal; }
.m-delim--lg { font-size: 1.8em; vertical-align: -.22em; font-style: normal; }

/* 大运算符的上下限（独立公式里叠放） */
.m-limits { display: inline-flex; flex-direction: column; align-items: center; vertical-align: -.42em; margin: 0 .16em; }
.m-lim-sup, .m-lim-sub { font-size: .62em; line-height: 1.15; }
.m-lim-base { font-size: 1.22em; line-height: 1; }
.md-formula {
  margin: 20px 0; padding: 18px 20px; text-align: center;
  background: var(--code-bg); border: 1px solid var(--border); border-left: 3px solid var(--accent-5);
  border-radius: 10px; font-size: 17px; overflow-x: auto;
}

/* --- 长文交叉引用自动链接 --- */
.topic-xref {
  color: var(--accent-2); border-bottom: 1px dashed rgba(0, 212, 255, .45);
  cursor: pointer; transition: all .15s ease;
}
.topic-xref:hover { color: var(--accent-3); border-bottom-color: var(--accent-3); background: rgba(255, 122, 198, .08); }

/* --- 代码块 --- */
.md-code {
  position: relative; margin: 18px 0; border-radius: 12px;
  border: 1px solid var(--border); background: var(--code-bg); overflow: hidden;
}
.md-code__lang {
  position: absolute; top: 0; right: 0; padding: 3px 10px;
  background: var(--surface-2); border-left: 1px solid var(--border); border-bottom: 1px solid var(--border);
  border-radius: 0 12px 0 8px; font-size: 11px; color: var(--muted); letter-spacing: .06em;
}
.md-code pre { margin: 0; padding: 16px 18px; overflow-x: auto; }
.md-code code {
  font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 13px;
  line-height: 1.75; color: var(--code-fg); white-space: pre;
}

/* --- 列表 --- */
.md-list { margin: 12px 0 12px 4px; padding-left: 22px; }
.md-list li { margin: 6px 0; font-size: 15px; line-height: 1.85; color: var(--text-soft); }
.md-list li::marker { color: var(--accent-2); }
.md-list .md-list { margin: 6px 0 6px 2px; }
.md-task { list-style: none; margin-left: -20px; display: flex; gap: 8px; align-items: flex-start; }
.md-check {
  flex: 0 0 16px; width: 16px; height: 16px; margin-top: 5px;
  border: 1.5px solid var(--border-strong); border-radius: 4px;
  font-size: 11px; line-height: 14px; text-align: center; color: transparent;
}
.md-task.is-done { color: var(--muted); text-decoration: line-through; }
.md-task.is-done .md-check { background: var(--accent-4); border-color: var(--accent-4); color: #06231a; text-decoration: none; }

/* --- 引用 / 提示块 --- */
.md-quote {
  margin: 18px 0; padding: 14px 18px; border-radius: 10px;
  border: 1px solid var(--border); border-left: 3px solid var(--border-strong);
  background: var(--surface-2);
}
.md-quote .md-p:first-child { margin-top: 0; }
.md-quote .md-p:last-child { margin-bottom: 0; }
.md-quote__label { font-weight: 700; font-size: 13px; margin-bottom: 6px; letter-spacing: .04em; }
.md-quote--note { border-left-color: var(--accent-6); background: rgba(92,155,255,.08); }
.md-quote--note .md-quote__label { color: var(--accent-6); }
.md-quote--tip { border-left-color: var(--accent-4); background: rgba(0,230,160,.07); }
.md-quote--tip .md-quote__label { color: var(--accent-4); }
.md-quote--warn { border-left-color: #ff6b6b; background: rgba(255,107,107,.08); }
.md-quote--warn .md-quote__label { color: #ff6b6b; }
.md-quote--key { border-left-color: var(--accent-5); background: rgba(255,184,92,.08); }
.md-quote--key .md-quote__label { color: var(--accent-5); }

/* --- 表格 --- */
.md-table-wrap { margin: 18px 0; overflow-x: auto; border-radius: 10px; border: 1px solid var(--border); }
.md-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.md-table th {
  background: var(--surface-2); color: var(--text); font-weight: 700;
  padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border-strong); white-space: nowrap;
}
.md-table td { padding: 9px 14px; color: var(--text-soft); border-bottom: 1px solid var(--border); line-height: 1.7; }
.md-table tr:last-child td { border-bottom: none; }
.md-table tbody tr:hover td { background: rgba(0,212,255,.04); }

@media (max-width: 720px) {
  .md-h1 { font-size: 22px; }
  .md-h2 { font-size: 18px; }
  .md-p, .md-list li { font-size: 14.5px; }
  .md-code code { font-size: 12px; }
  .md-table th, .md-table td { padding: 8px 10px; font-size: 13px; }
}

/* 首屏占位提示（JS 渲染前显示，减少「白屏以为挂了」的错觉） */
.loading-hint {
  padding: 26px 8px; text-align: center; color: var(--muted);
  font-size: 13.5px; letter-spacing: .04em;
  animation: loadingPulse 1.6s ease-in-out infinite;
}
@keyframes loadingPulse { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .loading-hint { animation: none; opacity: .8; } }

/* ============ 主题筛选工具条 ============ */
.topic-toolbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin: 4px 0 24px;
}
.topic-filter { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1; }
.chip {
  border: 1px solid var(--border); background: var(--surface); color: var(--text-soft);
  padding: 5px 13px; border-radius: 999px; font-size: 12.5px; cursor: pointer;
  font-family: inherit; transition: all .18s ease; line-height: 1.5;
}
.chip:hover { border-color: var(--chip-color, var(--accent-2)); color: var(--text); transform: translateY(-1px); }
.chip.active {
  background: var(--chip-color, var(--accent-2)); border-color: var(--chip-color, var(--accent-2));
  color: #0c1224; font-weight: 600;
}
.diff-select {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 6px 10px; font-family: inherit; font-size: 12.5px; cursor: pointer;
}
.topic-count { font-size: 12px; color: var(--muted); font-family: var(--font-mono); white-space: nowrap; }
.topic-empty {
  display: none; text-align: center; padding: 56px 20px; color: var(--muted);
  border: 1px dashed var(--border-strong); border-radius: var(--radius); font-size: 14px;
}
.topic-empty strong { display: block; font-size: 17px; margin-bottom: 10px; color: var(--text-soft); }

/* ============ 侧栏分类分组 ============ */
.nav-section--groups { display: flex; align-items: center; gap: 6px; }
.nav-section--groups .nav-act {
  margin-left: auto; background: none; border: 1px solid var(--border);
  color: var(--muted); font-size: 10px; padding: 1px 7px; border-radius: 6px;
  cursor: pointer; font-family: inherit; transition: all .15s ease;
}
.nav-section--groups .nav-act:hover { color: var(--accent-2); border-color: var(--accent-2); }
.nav-group { margin-bottom: 2px; }
.nav-group__head {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 10px;
  background: none; border: none; color: var(--text-soft); font-size: 12.5px; font-weight: 600;
  cursor: pointer; font-family: inherit; border-radius: 8px; letter-spacing: .02em;
}
.nav-group__head:hover { background: var(--surface); color: var(--text); }
.nav-group__head .num { margin-left: auto; font-size: 11px; color: var(--muted); font-family: var(--font-mono); }
.nav-group__head::after { content: '▾'; font-size: 10px; color: var(--muted); transition: transform .2s ease; }
.nav-group:not(.open) .nav-group__head::after { transform: rotate(-90deg); }
.nav-group:not(.open) .nav-group__body { display: none; }
.nav-group__body { padding-left: 6px; }

/* 键盘可达性：标签页与筛选的焦点样式 */
.tab-btn:focus-visible, .chip:focus-visible, .nav-group__head:focus-visible {
  outline: 2px solid var(--accent-2); outline-offset: -2px; border-radius: 6px;
}

/* ============ 打印样式：把主题卡片完整铺平到纸上 ============ */
@media print {
  :root, html[data-theme="light"] {
    --bg: #fff; --bg-soft: #fff; --surface: #fff; --surface-2: #f5f6f8;
    --border: #ccc; --border-strong: #aaa; --text: #111; --text-soft: #222;
    --muted: #555; --code-bg: #f3f4f6; --code-fg: #111; --code-inline-fg: #065f46;
    --header-bg: #fff; --shadow: none; --glow: none;
  }
  .sidebar, .topbar, .backtop, .theme-fixed, .gh-fixed, .topbar__gh, .read-progress, .hero__canvas, .hero__scroll,
  .overlay, .topic-toolbar, .topic__tabs, .demo-mount, .deep-loading, .deep-error,
  .btn, .roadmap, .method-cards, .resource-grid, .footer { display: none !important; }
  .main { margin-left: 0 !important; }
  .hero { min-height: auto; padding: 24px 0 8px; background: none; }
  .hero__cta, .hero__stats { display: none; }
  .topic {
    break-inside: avoid; box-shadow: none; border: 1px solid #ddd;
    background: #fff !important; margin-bottom: 18px;
  }
  /* 所有标签页平铺展示，用 data-label 标注小标题 */
  .tab-panel { display: block !important; animation: none; border-top: 1px dashed #ddd; margin-top: 12px; padding-top: 4px; }
  .tab-panel::before {
    content: attr(data-label); display: block; font-size: 11px; font-weight: 700;
    color: #666; letter-spacing: .1em; margin: 8px 0 6px;
  }
  .reveal { opacity: 1 !important; transform: none !important; animation: none !important; }
  a { color: #0645ad; }
}
