/* ============================================================
   AILab · 设计系统
   ------------------------------------------------------------
   配色取自 Anthropic 品牌色：Ivory / Cloud 两种纸张、Slate 墨色、
   Book Cloth 黏土作为唯一强调色。语义色（绿/黄/红）一律去饱和后
   使用，且只做"墨色和小标记"，不做填充色块——避免彩色徽章满屏。

   字体三种角色，全部走系统字库（CJK 系统衬线在目标设备上很好，
   也省掉几 MB 的中文 webfont）：
     --font-display  宋体，只在 ≥22px 的标题上用
     --font-ui       无衬线，正文与界面
     --code-font     等宽，只用于真实的标识符与数字（M07 / W3 / 8-14）
   ============================================================ */
:root {
  color-scheme: light;
  /* 画布 —— 两种纸张：Ivory 用于课程，Cloud 用于备赛作战室 */
  --bg: #f0eee6;
  --bg-paper2: #e6e3d7;
  --bg-elev: #f8f7f2;
  --bg-soft: #e8e6dc;
  --bg-inset: #dedbcf;
  /* 文本 —— Slate 墨色 */
  --text: #191919;
  --text-soft: #5c5b56;
  --text-mute: #8b8a83;
  /* 边框 —— 细线优先于色块 */
  --border: #d9d7cb;
  --border-soft: #e4e2d7;
  /* 强调色 —— Book Cloth 黏土（全站唯一强调色） */
  --accent: #cc785c;
  --accent-hover: #b3634a;
  --accent-soft: #eaddd3;
  --accent-border: #d9a48c;
  --kraft: #d4a27f;
  --manilla: #ebdbbc;
  /* 主操作（运行 / 完成）—— 去饱和苔绿，融进暖调而不跳出来 */
  --primary: #4e6b52;
  --primary-hover: #405843;
  /* 代码（亮色模式 = 暖浅色） */
  --code-bg: #f4f2ea;
  --code-bar: #e8e6dc;
  --code-border: #dedbcf;
  --code-text: #191919;
  --code-mute: #5c5b56;
  --code-out: #191919;
  --code-err: #a4453a;
  --code-font: "JetBrains Mono", "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --code-font-size: 13px;
  --syntax-keyword: #000080;
  --syntax-title: #795e26;
  --syntax-string: #008000;
  --syntax-number: #1750eb;
  --syntax-comment: #6a737d;
  --syntax-attr: #871094;
  --syntax-built-in: #0000c0;
  /* 语义色 —— 全部去饱和，只做墨色与小标记 */
  --ok: #4e6b52;
  --warn: #8a6a2f;
  --danger: #a4453a;
  --info: #5a7186;
  /* 侧栏导航 —— 比正文纸张略深一档，像装订好的书脊 */
  --nav-bg: #eae8df;
  --nav-text: #191919;
  --nav-text-soft: #5c5b56;
  --nav-text-mute: #8b8a83;
  --nav-border: #dedbd0;
  --nav-hover: #e2dfd4;
  --nav-accent-bar: #cc785c;
  --nav-active-bg: #e0dccf;
  --nav-accent-soft: rgba(204, 120, 92, .16);
  /* 阴影 —— 几乎不用，分层靠细线与留白 */
  --shadow-sm: none;
  --shadow-md: 0 1px 2px rgba(25, 25, 25, .06);
  --shadow-lg: 0 8px 30px rgba(25, 25, 25, .14);
  --radius: 8px;
  --radius-sm: 6px;
  /* 字体三角色 */
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  --font-display: "Songti SC", "Source Han Serif SC", "Source Han Serif CN", "Noto Serif CJK SC", "Noto Serif SC", STSong, SimSun, Georgia, "Times New Roman", serif;
  --topbar-h: 58px;
  --sidebar-w: 286px;
  --maxw: 860px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1a1917;
  --bg-paper2: #16150f;
  --bg-elev: #211f1c;
  --bg-soft: #262421;
  --bg-inset: #131211;
  --text: #f0eee6;
  --text-soft: #aca79d;
  --text-mute: #827e75;
  --border: #35322c;
  --border-soft: #2a2723;
  --accent: #d9926f;
  --accent-hover: #e5a283;
  --accent-soft: rgba(217, 146, 111, 0.15);
  --accent-border: #8a5d47;
  --kraft: #c99a78;
  --manilla: #6b5c41;
  --primary: #6f8f72;
  --primary-hover: #83a186;
  --code-bg: #1a1917;
  --code-bar: #262421;
  --code-border: #35322c;
  --code-text: #f0eee6;
  --code-mute: #a39a8c;
  --code-out: #d6cfc2;
  --code-err: #e88a7d;
  --syntax-keyword: #cf8e6d;
  --syntax-title: #56a8f5;
  --syntax-string: #6aab73;
  --syntax-number: #2aacb8;
  --syntax-comment: #7a7e85;
  --syntax-attr: #c77dbb;
  --syntax-built-in: #dcdcaa;
  --ok: #7fa384;
  --warn: #c2a05c;
  --danger: #e08476;
  --info: #8fa8bd;
  --nav-bg: #131210;
  --nav-text: #f0eee6;
  --nav-text-soft: #aca79d;
  --nav-text-mute: #827e75;
  --nav-border: #2a2723;
  --nav-hover: rgba(255,255,255,.045);
  --nav-accent-bar: #d98e6f;
  --nav-active-bg: rgba(217,119,87,.15);
  --nav-accent-soft: rgba(217,119,87,.22);
  --shadow-sm: none;
  --shadow-md: 0 1px 2px rgba(0,0,0,.4);
  --shadow-lg: 0 8px 30px rgba(0,0,0,.55);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  transition: background-color .3s ease;
}
a { color: inherit; text-decoration: none; }
::selection { background: var(--accent-soft); }

/* 展示级标题统一走宋体：只在 ≥22px 使用，小字仍是无衬线，
   保证中文界面的可读性不受影响。 */
.display { font-family: var(--font-display); font-weight: 600; letter-spacing: 0; }
/* 小标签：等宽 + 字距，只用来标注真实的编号与分类 */
.eyebrow {
  font-family: var(--code-font); font-size: 11px; font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase; color: var(--text-mute);
}

/* ---------------- 顶栏 ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  height: calc(var(--topbar-h) + var(--safe-top));
  padding-top: var(--safe-top);
  display: flex; align-items: center; gap: 10px;
  padding-left: 16px; padding-right: 16px;
  /* Anthropic 风格:顶栏与页面同一层奶油底,靠细分隔线分层,不用纯白 */
  background: var(--bg);
  border-bottom: 1px solid var(--border-soft);
}
.brand { display: flex; align-items: center; gap: 9px; font-size: 16px; }
.brand-mark { font-size: 15px; color: var(--accent); }
.brand-text { font-weight: 500; color: var(--text); letter-spacing: .01em; }
.brand-text b { font-weight: 700; }
.topbar-spacer { flex: 1; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: transparent; color: var(--text-soft);
  cursor: pointer; transition: background .12s, border-color .12s, color .12s;
}
.icon-btn:hover { background: var(--bg-soft); color: var(--text); border-color: var(--border); }
.icon-btn:active { background: var(--bg-inset); }
.menu-btn { display: inline-flex; }

.progress-pill {
  display: flex; align-items: center; gap: 9px;
  font-family: var(--code-font); font-size: 11.5px; font-weight: 600;
  color: var(--text-mute); font-variant-numeric: tabular-nums;
  background: transparent; padding: 5px 4px; border: 0;
}
.progress-pill__bar { width: 54px; height: 2px; background: var(--border); overflow: hidden; }
.progress-pill__bar i { display: block; height: 100%; width: 0%; background: var(--accent); transition: width .5s cubic-bezier(.2,.8,.2,1); }

/* 同步按钮：4 种状态用颜色区分 */
.sync-btn { transition: color .15s; }
.sync-btn--idle    { color: var(--text-soft); }
.sync-btn--syncing { color: var(--primary); animation: sync-spin 1.2s linear infinite; }
.sync-btn--ok      { color: #2ea043; }
.sync-btn--error   { color: #d1242f; }
.sync-btn--offline { color: #bf8700; }
@keyframes sync-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .sync-btn--syncing { animation: none; }
}

/* ---------------- 布局 ---------------- */
.layout { display: flex; align-items: flex-start; transition: margin-right .24s cubic-bezier(.2,.8,.2,1); }
/* 数据面板停靠时，整块布局右移让出空间，笔记内容自适应回流（类 iPadOS 分屏） */
/* 拖拽改宽时关闭过渡，保证跟手 */
.sidebar {
  position: sticky; top: calc(var(--topbar-h) + var(--safe-top));
  height: calc(100vh - var(--topbar-h) - var(--safe-top));
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  border-right: 1px solid var(--nav-border);
  display: flex; flex-direction: column;
  background: var(--nav-bg);
  overflow: hidden;
  transition: flex-basis .24s cubic-bezier(.2,.8,.2,1), width .24s cubic-bezier(.2,.8,.2,1);
}
/* 桌面端折叠左侧目录 */
body.sidebar-collapsed .sidebar { flex-basis: 0; width: 0; border-right-color: transparent; }
/* ---------------- 侧栏搜索 ---------------- */
.sidebar-search {
  position: relative; display: flex; align-items: center; gap: 8px;
  margin: 10px 10px 4px; padding: 0 10px; height: 38px;
  background: var(--nav-hover); border: 1px solid var(--nav-border); border-radius: 10px;
  transition: border-color .15s, box-shadow .15s;
}
.sidebar-search:focus-within { border-color: var(--nav-accent-bar); box-shadow: 0 0 0 3px var(--nav-accent-soft); }
.sidebar-search__icon { color: var(--text-mute); flex: 0 0 auto; }
.sidebar-search__input {
  flex: 1; min-width: 0; border: 0; background: transparent; outline: none;
  font: inherit; font-size: 13.5px; color: var(--text); padding: 0;
}
.sidebar-search__input::placeholder { color: var(--text-mute); }
.sidebar-search__input::-webkit-search-cancel-button { display: none; }
.sidebar-search__kbd {
  flex: 0 0 auto; font-size: 11px; font-weight: 600; color: var(--text-mute);
  background: var(--bg-inset); border: 1px solid var(--border-soft); border-radius: 5px;
  padding: 0 6px; line-height: 17px; font-family: inherit;
}
.sidebar-search:focus-within .sidebar-search__kbd { display: none; }
.sidebar-search__clear {
  flex: 0 0 auto; border: 0; background: transparent; color: var(--text-mute);
  font-size: 18px; line-height: 1; cursor: pointer; padding: 0 2px; border-radius: 5px;
}
.sidebar-search__clear:hover { color: var(--text); background: var(--bg-inset); }

.search-results { display: none; flex: 1; overflow-y: auto; padding: 4px 10px 28px; }
.sidebar.is-searching .search-results { display: block; }
.sidebar.is-searching .nav { display: none; }   /* 搜索时用结果列表替换目录 */
.search-count { font-size: 11px; color: var(--text-mute); padding: 8px 6px 6px; }
.search-count b { color: var(--text-soft); }
.search-empty { font-size: 13px; color: var(--text-mute); padding: 16px 8px; line-height: 1.6; }

.search-hit {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 9px 10px; border-radius: 9px; margin: 2px 0; cursor: pointer;
  text-decoration: none; transition: background .12s;
}
.search-hit:hover, .search-hit.is-sel { background: var(--bg-inset); }
.search-hit.is-sel { box-shadow: inset 0 0 0 1px var(--accent-border); }
.search-hit__icon {
  width: 24px; height: 24px; flex: 0 0 24px; border-radius: 6px;
  display: grid; place-items: center; font-size: 13px;
  background: var(--bg-soft); border: 1px solid var(--border-soft); margin-top: 1px;
}
.search-hit__main { min-width: 0; display: grid; gap: 2px; }
.search-hit__title {
  font-size: 13.5px; font-weight: 600; color: var(--text);
  display: flex; align-items: center; gap: 6px;
}
.search-hit__soon {
  font-size: 9px; font-weight: 700; color: var(--text-mute);
  border: 1px dashed var(--border); border-radius: 999px; padding: 0 6px; flex: 0 0 auto;
}
.search-hit__snip {
  font-size: 11.5px; line-height: 1.5; color: var(--text-mute);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.search-hit mark, .search-hit__title mark {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  color: inherit; border-radius: 3px; padding: 0 1px; font-weight: 700;
}

/* 搜索命中跳转：内容块短暂高亮，并避开吸顶栏 */
[data-block-index] { scroll-margin-top: calc(var(--topbar-h) + 16px); }
.block-flash { animation: block-flash 1.5s ease-out; border-radius: 12px; }
@keyframes block-flash {
  0%, 22% { box-shadow: 0 0 0 3px var(--accent-soft); background: var(--accent-soft); }
  100% { box-shadow: 0 0 0 3px transparent; background: transparent; }
}
@media (prefers-reduced-motion: reduce) { .block-flash { animation: none; } }

.nav { flex: 1; overflow-y: auto; padding: 8px 10px 28px; }
.nav::-webkit-scrollbar { width: 10px; }
.nav::-webkit-scrollbar-thumb { background: var(--nav-border); border-radius: 9px; border: 3px solid var(--nav-bg); }
/* 首页那一项和下面的目录拉开距离 */
.nav-home { margin-bottom: 10px; }

/* ===== 顶层分类 (section): 暖调标题 + 暖灰分隔线, 靠字重与间距分层 ===== */
.nav-section {
  margin: 4px 0 2px; padding: 0;
  border: 0;
  border-top: 1px solid var(--nav-border);
}
.nav-section:first-of-type { border-top: 0; margin-top: 6px; }

.nav-section__head,
.nav-subgroup__head {
  width: 100%; border: 0; background: transparent; color: var(--nav-text-soft);
  cursor: pointer; font: inherit; text-align: left; -webkit-tap-highlight-color: transparent;
}
/* 顶层分类:清晰的粗体标题,右侧箭头,占据视觉中心 */
.nav-section__head {
  display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 8px;
  padding: 13px 8px 7px; border-radius: 8px;
  color: var(--nav-text);
}
/* 分区编号：与首页「课程板块」同一套编号，两处读起来是同一张地图 */
.nav-section__n {
  font-family: var(--code-font); font-size: 10px; font-weight: 600;
  color: var(--nav-text-mute); font-variant-numeric: tabular-nums;
}
.nav-section--active .nav-section__n { color: var(--nav-accent-bar, var(--accent)); }
.nav-section__head:hover { background: var(--nav-hover); }
/* 规划中的分区:一枚安静的暖灰标签 */
.nav-section__plan {
  font-size: 10px; font-weight: 600; letter-spacing: .04em; color: var(--nav-text-mute);
  background: transparent; border: 0; padding: 0;
}
/* 整段规划中的分区整体压暗，与可学分区拉开层次 */
.nav-section--soon .nav-section__title { color: var(--nav-text-mute); }
.nav-section__chev,
.nav-subgroup__chev {
  display: inline-grid; place-items: center; color: var(--nav-text-mute);
  font-size: 10px; transition: transform .18s cubic-bezier(.2,.8,.2,1);
}
.nav-section.collapsed .nav-section__chev,
.nav-subgroup.collapsed .nav-subgroup__chev { transform: rotate(-90deg); }
.nav-section__text { display: grid; gap: 1px; min-width: 0; }
.nav-section__meter {
  margin-right: 6px; font-family: var(--code-font); font-size: 10px;
  color: var(--nav-text-mute); font-variant-numeric: tabular-nums;
}
.nav-section__title {
  font-size: 13.5px; font-weight: 700; color: var(--nav-text);
  letter-spacing: .01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; align-items: center; gap: 8px;
}
.nav-section__title .nav-section__emoji {
  font-size: 14px; font-weight: 400; filter: none; flex: 0 0 auto;
}
.nav-section__text small { display: none; }
.nav-section__body { padding: 2px 0 4px; }
.nav-section.collapsed .nav-section__body,
.nav-subgroup.collapsed .nav-subgroup__body { display: none; }

/* ===== 子分组 (subgroup): 缩进的安静标签, 箭头默认隐藏, hover/折叠时显现 ===== */
.nav-subgroup {
  margin: 2px 0;
}
.nav-subgroup__head {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  padding: 5px 8px 5px 18px; border-radius: 6px;
  font-size: 11px; font-weight: 600; color: var(--nav-text-mute);
  letter-spacing: .03em; text-transform: none;
}
.nav-subgroup__head:hover { background: var(--nav-hover); color: var(--nav-text-soft); }
.nav-subgroup__title {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.nav-subgroup__chev {
  font-size: 9px; opacity: 0; transition: opacity .12s, transform .18s cubic-bezier(.2,.8,.2,1);
}
.nav-subgroup__head:hover .nav-subgroup__chev,
.nav-subgroup.collapsed .nav-subgroup__chev { opacity: .55; }
.nav-subgroup__body { padding: 0; }

/* ===== 章节项 (item): 缩进到子组内部, 选中为暖色胶囊 + 左侧色条 ===== */
.nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px 6px 30px; border-radius: 7px; margin: 1px 0;
  color: var(--nav-text-soft); font-size: 13px; font-weight: 400;
  cursor: pointer; transition: background .12s, color .12s; position: relative;
  -webkit-tap-highlight-color: transparent;
}
.nav-item:hover { background: var(--nav-hover); color: var(--nav-text); }
.nav-item.active {
  background: var(--nav-active-bg); color: var(--nav-text); font-weight: 600;
}
.nav-item.active::before {
  content: ""; position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 17px; border-radius: 2px; background: var(--nav-accent-bar);
}
.nav-item__icon { display: none; }
.nav-item__text {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  display: flex; align-items: center; gap: 6px;
}
.nav-item__emoji {
  flex: 0 0 auto; font-size: 13px; filter: grayscale(.2); opacity: .8;
}
.nav-item.active .nav-item__emoji { opacity: 1; filter: none; }
.nav-item__check { color: var(--ok); display: none; flex: 0 0 auto; font-size: 11px; }
.nav-item.done .nav-item__check { display: inline-flex; }
.nav-item.done { color: var(--nav-text-mute); }
.nav-item.done .nav-item__emoji { opacity: .55; }
.nav-item.soon { opacity: .5; }
.nav-item__badge {
  font-size: 10px; font-weight: 400; padding: 0; border-radius: 0;
  background: transparent; color: var(--nav-text-mute); flex: 0 0 auto;
  letter-spacing: .02em;
}
/* 备赛侧：顶层入口不缩进，模块行用等宽编号领读 */
.nav-item--top { padding-left: 10px; font-weight: 500; }
.nav-item--top.active::before { left: 2px; }
.nav-item__code {
  flex: 0 0 auto; font-family: var(--code-font); font-size: 10.5px; font-weight: 600;
  color: var(--nav-text-mute); font-variant-numeric: tabular-nums; min-width: 22px;
}
.nav-item.active .nav-item__code { color: var(--nav-accent-bar); }
.nav-item.done .nav-item__code { color: var(--ok); }
.nav-item__meta {
  flex: 0 0 auto; font-family: var(--code-font); font-size: 10px;
  color: var(--nav-text-mute); font-variant-numeric: tabular-nums;
}
.nav-item__mark { flex: 0 0 auto; font-size: 9px; color: var(--nav-text-mute); }
.nav-item__mark.is-risk { color: var(--danger); }
.nav-item__mark.is-star { color: var(--nav-accent-bar); }
.nav-subgroup__count {
  font-family: var(--code-font); font-size: 9.5px; color: var(--nav-text-mute);
  font-variant-numeric: tabular-nums; margin-left: auto; margin-right: 6px;
}

/* ===== 章节内二级导航 (subnav): 当前章节下方内联展开本章 h2/h3 小标题 ===== */
.nav-subnav {
  margin: 2px 0 6px; padding: 2px 0;
  position: relative;
}
/* 用一条竖线把这一层串起来，暗示“从属于上面的章节” */
.nav-subnav::before {
  content: ""; position: absolute; left: 34px; top: 4px; bottom: 4px;
  width: 1px; background: var(--nav-border);
}
.nav-subitem {
  display: block; position: relative;
  padding: 3px 10px 3px 46px; border-radius: 6px;
  color: var(--nav-text-mute); font-size: 12px; line-height: 1.45;
  cursor: pointer; transition: color .12s, background .12s;
  -webkit-tap-highlight-color: transparent;
}
.nav-subitem__text {
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.nav-subitem--l3 { padding-left: 60px; font-size: 11.5px; }
.nav-subitem:hover { color: var(--nav-text); background: var(--nav-hover); }
/* 高亮当前小节：竖线上点亮一段 + 文字加重 */
.nav-subitem.active { color: var(--nav-text); font-weight: 600; }
.nav-subitem.active::before {
  content: ""; position: absolute; left: 31px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 14px; border-radius: 2px; background: var(--nav-accent-bar);
}
.nav-subitem--l3.active::before { left: 31px; }

/* 小标题锚点：滚动定位时让出顶栏高度，避免标题被固定顶栏遮住 */
.sec-anchor { scroll-margin-top: calc(var(--topbar-h) + 16px); }

/* 占位章节"规划知识点"清单 */
.plan-list { list-style: none; margin: 12px 0 4px; padding: 0; display: grid; gap: 8px; }
.plan-list li {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px; border-radius: 10px;
  background: var(--bg-soft); border: 1px solid var(--border-soft);
}
.plan-pt { font-size: 14px; line-height: 1.5; color: var(--text-soft); }
.plan-pt strong { color: var(--text); }
.plan-lv {
  flex: 0 0 auto; margin-top: 1px;
  font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px;
  color: #fff; white-space: nowrap;
}
.plan-lv.lv1 { background: #6e7781; }
.plan-lv.lv2 { background: var(--accent); }
.plan-lv.lv3 { background: #8250df; }

.sidebar-foot { padding: 12px 16px calc(14px + var(--safe-bottom)); border-top: 1px solid var(--border); }

.scrim { display: none; }

/* ---------------- 内容区 ---------------- */
.content {
  flex: 1; min-width: 0;
  padding: 32px clamp(18px, 5vw, 56px) 120px;
  max-width: calc(var(--maxw) + 112px);
  margin: 0 auto;
}
.page-head { margin-bottom: 34px; padding-bottom: 22px; border-bottom: 1px solid var(--border); }
.crumb {
  font-family: var(--code-font); font-size: 11px; letter-spacing: .08em;
  color: var(--text-mute); font-weight: 500;
}
.page-title {
  font-family: var(--font-display); font-weight: 600;
  font-size: clamp(26px, 5vw, 36px); line-height: 1.3; margin: 12px 0 10px;
  letter-spacing: 0; text-wrap: balance;
}
.page-sub { font-size: 16px; color: var(--text-soft); max-width: 38em; line-height: 1.75; }
.page-meta { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 18px; }
/* 标签不再做成彩色胶囊，只是一行安静的小字，靠间隔分隔 */
.chip {
  display: inline-flex; align-items: center;
  font-size: 12px; font-weight: 500; color: var(--text-mute);
  background: transparent; border: 0; padding: 0;
}
.chip + .chip::before {
  content: ""; width: 3px; height: 3px; border-radius: 50%;
  background: var(--border); margin-right: 14px;
}

/* prose */
.prose { font-size: 16px; color: var(--text); line-height: 1.8; }
.prose h2 {
  font-family: var(--font-display); font-weight: 600;
  font-size: 24px; margin: 46px 0 16px; line-height: 1.4;
  padding-bottom: .35em; border-bottom: 1px solid var(--border);
  letter-spacing: 0; scroll-margin-top: 80px;
}
.prose h3 { font-size: 17px; font-weight: 600; margin: 30px 0 8px; letter-spacing: .01em; }
.prose h4 { font-size: 15px; font-weight: 600; margin: 22px 0 6px; opacity: .92; }
.prose p { margin: 14px 0; color: var(--text); }
.prose ul, .prose ol { margin: 12px 0; padding-left: 22px; }
.prose li { margin: 5px 0; }
.prose code, .callout__body code {
  font-family: var(--code-font);
  font-size: .87em; background: var(--bg-inset); color: var(--text);
  padding: .2em .4em; border-radius: 6px; font-weight: 400;
  overflow-wrap: anywhere;   /* 长标识符在窄屏要能断行，否则顶破容器 */
}
[data-theme="dark"] .prose code { background: rgba(110,118,129,0.2); }

/* 讲义里偶尔会有整段引用（提示词模板、数据契约）——用 <pre> 直接展示原样文本。 */
.prose pre, .callout__body pre {
  font-family: var(--code-font); font-size: 12.5px; line-height: 1.7;
  background: var(--code-bg); color: var(--text);
  border: 1px solid var(--code-border); border-radius: var(--radius);
  padding: 14px 16px; margin: 16px 0;
  overflow-x: auto; white-space: pre-wrap; word-break: break-word;
}
.prose pre code, .callout__body pre code { background: none; padding: 0; font-size: inherit; }
.prose strong { font-weight: 600; }
.prose a.link { color: var(--accent); }
.prose a.link:hover { text-decoration: underline; }

/* ---- 站内章节跳转胶囊(xref)+ 悬停预览气泡 ---- */
.prose a.xref, .callout__body a.xref {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 0 9px 1px; margin: 0 1px;
  border-radius: 999px; border: 1px solid transparent;
  background: var(--accent-soft); color: var(--accent);
  font-size: 0.92em; line-height: 1.6; white-space: nowrap;
  vertical-align: baseline; text-decoration: none;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .15s;
}
.prose a.xref:hover, .callout__body a.xref:hover {
  background: var(--bg-elev); border-color: var(--accent-border);
  color: var(--accent-hover); transform: translateY(-1px);
  box-shadow: var(--shadow-md); text-decoration: none;
}
.xref__icon { font-size: 0.95em; line-height: 1; }
/* 预览气泡:body 下的全局悬浮层,由 JS 定位(fixed),不受表格 overflow 裁剪。
   0.08s 的出现延迟做防抖:光标快速扫过一排链接时不闪一串气泡。 */
.xref-tip {
  position: fixed; z-index: 90; pointer-events: none;
  max-width: 340px; padding: 6px 11px;
  background: var(--bg-elev); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: 12.5px; font-weight: 500; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
  opacity: 0; transform: translateY(3px);
  transition: opacity .16s ease .08s, transform .16s ease .08s;
}
.xref-tip.show { opacity: 1; transform: translateY(0); }

/* ---- 分步动画播放器(anim 块) ---- */
.anim {
  margin: 20px 0; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-soft); overflow: hidden;
}
.anim__title {
  padding: 10px 16px 0; font-size: 14px; font-weight: 600; color: var(--text);
}
.anim__stage { padding: 12px 14px 2px; color: var(--text-soft); }
.anim__stage svg { fill: currentColor; }   /* 与 figure.diagram 同一套约定:文字/线条跟主题走 */
.anim__stage .d-accent { fill: var(--accent); }
.anim__stage .d-stroke-accent { stroke: var(--accent); }
.anim__stage .d-primary { fill: var(--primary); }
.anim__stage .d-stroke-primary { stroke: var(--primary); }
.anim__stage svg { display: block; width: 100%; max-width: 680px; margin: 0 auto; }
/* data-on 元素:默认隐藏,进入所属步骤后淡入;位移过渡由各动画自带的 <style> 定义 */
.anim__stage [data-on] { opacity: 0; transition: opacity .45s ease, transform .6s cubic-bezier(.4, 0, .2, 1); }
.anim__stage [data-on].on { opacity: 1; }
.anim__desc {
  min-height: 44px; padding: 9px 16px; font-size: 13.5px; line-height: 1.65;
  color: var(--text); border-top: 1px dashed var(--border-soft);
}
.anim__desc b {
  display: inline-block; margin-right: 7px; padding: 0 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-size: 12px;
}
.anim__bar { display: flex; align-items: center; gap: 8px; padding: 6px 14px 14px; flex-wrap: wrap; }
.anim__btn {
  border: 1px solid var(--border); background: var(--bg-elev); color: var(--text);
  border-radius: 999px; padding: 4px 14px; font-size: 12.5px; cursor: pointer;
  transition: border-color .15s, background .15s, transform .15s;
}
.anim__btn:hover:not(:disabled) { border-color: var(--accent-border); transform: translateY(-1px); }
.anim__btn:disabled { opacity: .35; cursor: default; }
.anim__btn--primary { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.anim__dots { display: flex; gap: 6px; margin: 0 auto; }
.anim__dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--border);
  cursor: pointer; transition: background .2s, transform .2s;
}
.anim__dot.active { background: var(--accent); transform: scale(1.3); }
.prose table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 14px; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--border); padding: 7px 13px; text-align: left; }
.prose th { background: var(--bg-soft); font-weight: 600; }
.prose tr:nth-child(2n) td { background: var(--bg-soft); }
.prose .katex-display,
.callout .katex-display {
  overflow-x: auto; overflow-y: hidden; padding: 4px 0;
}
.prose .katex,
.callout .katex {
  font-size: 1.04em;
}

/* 概念示意图(内联 SVG,自适应深浅主题:线条/文字用 currentColor,强调色用 --accent) */
.prose figure.diagram {
  margin: 20px 0;
  padding: 16px 12px 10px;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  background: var(--bg-soft);
  text-align: center;
}
/* 只匹配直接子元素:KaTeX 画根号用的 <svg> 嵌在 figcaption 里,
   若被下面的 width:100% / height:auto 命中,根号会被撑出裁剪框而隐形。 */
.prose figure.diagram > svg {
  display: block;
  width: 100%;
  height: auto;
  max-width: 640px;
  margin: 0 auto;
  color: var(--text-soft);          /* currentColor 基准 → 线条/文字 */
  overflow: visible;
}
.prose figure.diagram > svg text { fill: currentColor; }
.prose figure.diagram figcaption {
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-mute);
  line-height: 1.5;
}
.prose figure.diagram .d-accent { fill: var(--accent); }
.prose figure.diagram .d-stroke-accent { stroke: var(--accent); }
.prose figure.diagram .d-primary { fill: var(--primary); }
.prose figure.diagram .d-stroke-primary { stroke: var(--primary); }
/* 真实图片(本地化保存,见 assets/figures) */
.prose figure.diagram img {
  display: block; max-width: 100%; height: auto; margin: 0 auto;
  border-radius: 8px; border: 1px solid var(--border-soft);
  background: #fff; padding: 6px; box-sizing: border-box;
  cursor: zoom-in; transition: filter .15s ease;
}
.prose figure.diagram img:hover { filter: brightness(1.04); }
/* 自制配图是「画在透明底上的插画」,要跟着主题走:不垫白底,让图卡的 --bg-soft 透上来。
   注意不能对所有 img 一刀切——vendored 的 Wikimedia 线稿图是黑线+透明,
   在暗色模式下必须保留上面那条 background:#fff,否则黑线画在暗底上直接看不见。 */
.prose figure.diagram img.themed {
  background: transparent; padding: 0; border-color: transparent;
}
/* 生成式配图若含主题相关的文字/线条，使用一浅一深两张资源，跟随站点实际 data-theme 切换。 */
.prose figure.diagram img.theme-asset-dark { display: none; }
[data-theme="dark"] .prose figure.diagram img.theme-asset-light { display: none; }
[data-theme="dark"] .prose figure.diagram img.theme-asset-dark { display: block; }

/* 图片灯箱：点击配图放大浏览 */
.lightbox {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 4vmin; background: rgba(0, 0, 0, .82);
  cursor: zoom-out; backdrop-filter: blur(2px);
}
.lightbox[hidden] { display: none; }
.lightbox img {
  max-width: 96vw; max-height: 92vh; width: auto; height: auto;
  border-radius: 8px; box-shadow: 0 12px 48px rgba(0, 0, 0, .5);
  background: #fff;
}
/* 主题化配图在灯箱里也跟主题:白底会把暗色模式下的插画衬得很突兀 */
.lightbox img.themed { background: var(--bg-soft); padding: 10px; }
.lightbox-close {
  position: absolute; top: 16px; right: 20px;
  width: 40px; height: 40px; border-radius: 50%;
  border: none; background: rgba(255, 255, 255, .15); color: #fff;
  font-size: 24px; line-height: 1; cursor: pointer;
}
.lightbox-close:hover { background: rgba(255, 255, 255, .28); }
.prose figure.diagram .imgrow {
  display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; align-items: flex-start;
}
.prose figure.diagram .imgrow figure { margin: 0; }
.prose figure.diagram .imgrow figcaption { margin-top: 6px; }
.prose figure.diagram .attr { font-size: 11px; color: var(--text-mute); opacity: .85; margin-top: 6px; }
.prose figure.diagram .attr a { color: inherit; text-decoration: underline; }

/* ---- 配套学习资料卡片(章节引用的外部原始材料:视频/长文/代码仓库) ----
   讲义里"该看哪份材料、看哪一段"要一眼可辨,所以做成卡片而不是一串裸链接。
   时间戳做成胶囊,直接带 ?t= 秒数跳进视频对应位置。 */
.prose .reslist { list-style: none; margin: 18px 0; padding: 0; display: grid; gap: 10px; }
.prose .res {
  margin: 0; padding: 12px 15px;
  border: 1px solid var(--border-soft); border-left: 2px solid var(--accent);
  border-radius: 10px; background: var(--bg-soft);
}
.prose .res__kind {
  font-family: var(--code-font); font-size: 11px; letter-spacing: .08em;
  color: var(--text-mute); margin-right: 9px; text-transform: uppercase;
}
.prose .res__title { font-weight: 600; }
.prose .res__title a { color: var(--accent); text-decoration: none; }
.prose .res__title a:hover { text-decoration: underline; }
.prose .res__note { margin: 6px 0 0; font-size: 13.5px; color: var(--text-mute); line-height: 1.7; }
.prose .res__note a { color: var(--accent); text-decoration: none; }
.prose .res__note a:hover { text-decoration: underline; }
.prose .res__segs {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin: 10px 0 0; padding: 0; list-style: none;
}
.prose .res__segs li { margin: 0; }
.prose .res__segs a, .prose .res__segs span {
  display: inline-flex; align-items: baseline; gap: 6px;
  padding: 2px 10px; border: 1px solid var(--border); border-radius: 999px;
  font-size: 12.5px; line-height: 1.7; color: var(--text);
  text-decoration: none; background: var(--bg-elev);
}
.prose .res__segs a:hover { border-color: var(--accent-border); color: var(--accent); }
.prose .res__segs b { font-family: var(--code-font); font-weight: 600; font-size: 11.5px; color: var(--accent); }
.prose .res__segs .skip { opacity: .55; }
.prose .res__segs .skip b { color: var(--text-mute); }

/* 关键术语 */
.kbd { font-family: ui-monospace, monospace; font-size: .85em; background: var(--bg-soft); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 6px; padding: 1px 6px; }

/* callout */
.callout {
  display: flex; gap: 12px; margin: 18px 0; padding: 14px 16px;
  border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--bg-elev);
  border-left: 3px solid var(--info);
}
.callout__icon { font-size: 17px; line-height: 1.5; }
.callout__body { flex: 1; font-size: 14px; color: var(--text-soft); }
.callout__title { font-weight: 600; margin-bottom: 2px; font-size: 14px; }
.callout__body p { margin: 4px 0; font-size: 14px; color: var(--text-soft); }
.callout__body > *:first-child { margin-top: 0; }
.callout__body > *:last-child { margin-bottom: 0; }
.callout table { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 13px; display: block; overflow-x: auto; }
.callout th, .callout td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.callout th { background: var(--bg-soft); font-weight: 600; color: var(--text); }
.callout tr:nth-child(2n) td { background: var(--bg-soft); }
.callout--tip { border-left-color: var(--ok); }
.callout--warn { border-left-color: var(--warn); }
.callout--danger { border-left-color: var(--danger); }
.callout--key { border-left-color: var(--accent); }

/* ---------------- 代码块 ---------------- */
.dots { display: none; }
.code-tool-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 28px; padding: 4px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--code-border); background: transparent;
  color: var(--code-mute); font-size: 12px; font-weight: 600;
  cursor: pointer; transition: color .12s, border-color .12s, background .12s, opacity .12s;
  -webkit-tap-highlight-color: transparent;
}
.code-tool-btn:hover { color: var(--code-text); border-color: var(--code-mute); background: rgba(255,255,255,.04); }
.code-tool-btn:disabled { opacity: .45; cursor: default; }
.run-btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; color: #fff;
  background: var(--primary); border: 1px solid rgba(27,31,36,.15); cursor: pointer;
  padding: 5px 14px; border-radius: var(--radius-sm); transition: background .12s;
  -webkit-tap-highlight-color: transparent;
}
.run-btn:hover { background: var(--primary-hover); }
.run-btn:active { transform: translateY(.5px); }
.run-btn:disabled { opacity: .6; cursor: progress; }


/* 代码补全候选框（Tab 触发） */
.cmp-pop {
  position: fixed; z-index: 1000; min-width: 210px; max-width: min(420px, calc(100vw - 16px));
  max-height: min(280px, calc(100vh - 24px)); overflow-y: auto;
  background: var(--code-bg); border: 1px solid var(--code-border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding: 4px;
  font-family: var(--code-font); font-size: var(--code-font-size); line-height: 1.45;
  color: var(--code-text);
}
.cmp-pop::-webkit-scrollbar { width: 10px; }
.cmp-pop::-webkit-scrollbar-thumb { background: var(--code-border); border-radius: 9px; border: 3px solid var(--code-bg); }
.cmp-pop::-webkit-scrollbar-track { background: transparent; }
[data-theme="dark"] .cmp-pop {
  box-shadow: 0 12px 28px rgba(1, 4, 9, .72), 0 0 0 1px rgba(255,255,255,.02);
}
.cmp-item {
  display: grid; grid-template-columns: 36px minmax(0, 1fr); align-items: center; gap: 8px;
  min-height: 28px; padding: 3px 8px;
  border-radius: 4px; cursor: pointer; white-space: nowrap;
  color: var(--code-text);
}
.cmp-item.is-sel { background: var(--accent-soft); color: var(--code-text); }
.cmp-item:hover { background: var(--code-bar); }
.cmp-type {
  width: 36px; text-align: center; font-size: 10px; line-height: 16px; font-weight: 700;
  color: var(--accent); background: var(--accent-soft);
  border: 1px solid rgba(84, 174, 255, .35); border-radius: 3px;
}
.cmp-name { overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
[data-theme="dark"] .cmp-item.is-sel { background: rgba(68, 147, 248, .22); }
[data-theme="dark"] .cmp-type { border-color: rgba(68, 147, 248, .32); }

/* ---------------- 测验 ---------------- */
.quiz { margin: 22px 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elev); padding: 18px; }
.quiz__q { font-weight: 600; font-size: 15px; margin-bottom: 12px; }
.quiz__opt {
  display: flex; align-items: center; gap: 11px; padding: 10px 13px; margin: 7px 0;
  border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer;
  font-size: 14px; transition: border-color .12s, background .12s; -webkit-tap-highlight-color: transparent;
}
.quiz__opt:hover { border-color: var(--accent); background: var(--bg-soft); }
.quiz__opt .mark { width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--border); flex:0 0 20px; display:grid; place-items:center; font-size: 12px; }
.quiz__opt.correct { border-color: var(--ok); background: rgba(31,136,61,.08); }
.quiz__opt.correct .mark { border-color: var(--ok); background: var(--ok); color:#fff; }
.quiz__opt.wrong { border-color: var(--danger); background: rgba(207,34,46,.08); }
.quiz__opt.wrong .mark { border-color: var(--danger); background: var(--danger); color:#fff; }
.quiz__explain { display:none; margin-top: 12px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--bg-soft); border: 1px solid var(--border); font-size: 14px; color: var(--text-soft); }
.quiz__explain.show { display: block; }

/* 章节底部 */
.chapter-foot { margin-top: 52px; padding-top: 24px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 18px; }
.complete-btn {
  align-self: flex-start; display: inline-flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 600; color: #fff; background: var(--primary);
  border: 1px solid rgba(27,31,36,.15); border-radius: var(--radius-sm); padding: 9px 18px; cursor: pointer;
  transition: background .12s;
}
.complete-btn:hover { background: var(--primary-hover); }
.complete-btn:active { transform: translateY(.5px); }
.complete-btn.done { background: var(--bg-soft); color: var(--ok); border-color: var(--border); }
.pager { display: flex; gap: 12px; justify-content: space-between; }
.pager a {
  flex: 1; border: 1px solid var(--border); border-radius: var(--radius); padding: 13px 16px;
  background: var(--bg-elev); transition: border-color .12s, background .12s;
}
.pager a:hover { border-color: var(--accent); background: var(--bg-soft); }
.pager a.next { text-align: right; }
.pager__dir { font-size: 12px; color: var(--text-mute); font-weight: 500; }
.pager__title { font-size: 14px; font-weight: 600; margin-top: 2px; color: var(--accent); }
.pager a.disabled { opacity: .4; pointer-events: none; }

/* ============================================================
   首页
   ------------------------------------------------------------
   一个人的书桌：报头 → 接着读 → 一条进度线 → 折叠的板块索引。
   没有卡片墙，分层全靠细线与留白。
   ============================================================ */
.masthead { padding: 26px 0 36px; }
.masthead__eyebrow {
  font-family: var(--code-font); font-size: 11px; font-weight: 600;
  letter-spacing: .18em; color: var(--text-mute);
}
.masthead__title {
  font-family: var(--font-display); font-weight: 600;
  font-size: clamp(30px, 6vw, 46px); line-height: 1.25; margin: 18px 0 0;
  letter-spacing: .01em; text-wrap: balance;
}
.masthead__lead {
  font-size: 16px; line-height: 1.85; color: var(--text-soft);
  max-width: 36em; margin: 20px 0 0;
}

.meter { height: 2px; background: var(--border); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--accent); transition: width .5s cubic-bezier(.2,.8,.2,1); }

/* ---- 接着读：首页唯一的主动作，通栏一行，不是卡片 ---- */
.resume {
  display: grid; grid-template-columns: auto 1fr auto; gap: 4px 16px;
  align-items: baseline; padding: 22px 4px 24px;
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
  position: relative; transition: background-color .18s;
}
.resume:hover { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.resume::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  background: var(--accent); transform: scaleX(0); transform-origin: left;
  transition: transform .32s cubic-bezier(.2,.8,.2,1);
}
.resume:hover::after { transform: scaleX(1); }
.resume__k {
  grid-row: 1 / span 2; align-self: center;
  font-family: var(--code-font); font-size: 11px; font-weight: 600;
  letter-spacing: .1em; color: var(--text-mute); white-space: nowrap;
}
.resume__t {
  font-family: var(--font-display); font-weight: 600;
  font-size: clamp(22px, 3.2vw, 26px); line-height: 1.4; color: var(--text);
}
.resume__s { grid-column: 2; font-size: 12.5px; color: var(--text-mute); }
.resume__go {
  grid-row: 1 / span 2; align-self: center;
  color: var(--accent); font-weight: 600; font-size: 14px; white-space: nowrap;
}
.resume:hover .resume__t { color: var(--accent); }

/* ---- 进度：一条线 + 三个数字 ---- */
.hstat { padding: 20px 4px 0; }
.hstat__bar { height: 2px; background: var(--border); overflow: hidden; }
.hstat__bar i { display: block; height: 100%; background: var(--accent); transition: width .5s cubic-bezier(.2,.8,.2,1); }
.hstat__row { display: flex; gap: 34px; margin-top: 14px; }
.hstat__cell { display: grid; gap: 2px; }
.hstat__cell b {
  font-family: var(--code-font); font-size: 19px; font-weight: 700;
  color: var(--text); font-variant-numeric: tabular-nums; line-height: 1.1;
}
.hstat__cell b i {
  font-style: normal; font-size: 12px; font-weight: 500; color: var(--text-mute);
}
.hstat__cell span {
  font-size: 11px; letter-spacing: .08em; color: var(--text-mute);
}

/* 课程索引：默认只列分区，点开才展开章节，首页因此保持在一屏半 */
.cindex { margin-top: 44px; }
.cindex__label {
  font-family: var(--code-font); font-size: 11px; font-weight: 700; letter-spacing: .12em;
  color: var(--text-mute); margin: 0 0 4px; padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.cindex__sec { border-bottom: 1px solid var(--border-soft); }
.cindex__head {
  width: 100%; display: grid; grid-template-columns: 34px 1fr auto 90px 14px;
  gap: 16px; align-items: center; padding: 16px 2px;
  border: 0; background: transparent; cursor: pointer; text-align: left; font: inherit; color: inherit;
}
.cindex__head:hover .cindex__t { color: var(--accent); }
.cindex__n {
  font-family: var(--code-font); font-size: 11px; font-weight: 600;
  color: var(--text-mute); font-variant-numeric: tabular-nums;
}
.cindex__main { min-width: 0; }
.cindex__t { display: block; font-size: 16px; font-weight: 600; }
.cindex__d {
  display: block; font-size: 12.5px; color: var(--text-mute); margin-top: 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cindex__c {
  font-family: var(--code-font); font-size: 11.5px; color: var(--text-mute);
  font-variant-numeric: tabular-nums;
}
.cindex__chev { color: var(--text-mute); font-size: 10px; transition: transform .2s; }
.cindex__sec.is-collapsed .cindex__chev { transform: rotate(-90deg); }
.cindex__sec.is-collapsed .cindex__body { display: none; }
.cindex__body {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0 24px; padding: 0 0 16px 50px;
}
.cindex__ch {
  display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: baseline;
  padding: 7px 0; font-size: 13.5px; border-bottom: 1px solid var(--border-soft);
}
.cindex__ch:hover .cindex__cht { color: var(--accent); }
.cindex__chn {
  font-family: var(--code-font); font-size: 10.5px; color: var(--text-mute);
  font-variant-numeric: tabular-nums;
}
.cindex__cht { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cindex__chs { font-size: 10.5px; color: var(--text-mute); }
.cindex__ch.is-done .cindex__chn { color: var(--accent); }
.cindex__ch.is-soon { opacity: .5; }

/* ---------------- 底部 Tabbar (移动端) ---------------- */
.tabbar { display: none; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 980px) {
  :root { --sidebar-w: 260px; }
}
@media (max-width: 820px) {
  .menu-btn { display: inline-flex; }
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100dvh; width: 84vw; max-width: 320px;
    z-index: 100; transform: translateX(-100%); transition: transform .26s cubic-bezier(.2,.8,.2,1);
    background: var(--nav-bg); box-shadow: var(--shadow-lg); padding-top: calc(var(--safe-top) + 10px);
  }
  .sidebar.open { transform: translateX(0); }
  /* 移动端用抽屉，桌面折叠态不应压缩抽屉宽度 */
  body.sidebar-collapsed .sidebar { flex-basis: auto; width: 84vw; border-right-color: var(--nav-border); }
  .scrim { display: block; position: fixed; inset: 0; z-index: 90; background: rgba(1,4,9,.5);
    opacity: 0; pointer-events: none; transition: opacity .22s; }
  .scrim.show { opacity: 1; pointer-events: auto; }
  .content { padding: 22px 18px calc(120px + var(--safe-bottom)); }
  .progress-pill__bar { display: none; }
  .masthead { padding: 12px 0 32px; }
  .resume { grid-template-columns: 1fr; gap: 6px; padding: 20px 2px 22px; }
  .resume__k, .resume__go { grid-row: auto; align-self: start; }
  .resume__s { grid-column: 1; }
  .hstat__row { gap: 24px; }
  .cindex__head { grid-template-columns: 30px 1fr auto 14px; gap: 10px; }
  .cindex__head .meter { display: none; }
  .cindex__d { display: none; }
  .cindex__body { padding-left: 0; grid-template-columns: 1fr; }

  .tabbar {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
    background: var(--bg-elev);
    border-top: 1px solid var(--border);
    padding: 6px 8px calc(6px + var(--safe-bottom));
  }
  .tab {
    flex: 1; display: flex; align-items: center; justify-content: center;
    padding: 10px 4px; font-size: 12.5px; font-weight: 600; color: var(--text-mute);
    -webkit-tap-highlight-color: transparent; min-width: 0; position: relative;
  }
  .tab.active { color: var(--text); }
  .tab.active::after {
    content: ""; position: absolute; left: 26%; right: 26%; top: 0; height: 2px; background: var(--accent);
  }
  .tab span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
}
@media (max-width: 420px) {
  .cards { grid-template-columns: 1fr; }
}

/* iPad 竖屏优化：保留侧栏但稍窄 */
@media (min-width: 821px) and (max-width: 1100px) {
  :root { --maxw: 720px; }
}

/* ============================================================
   大模型配置（当前标签页）
   ============================================================ */
.llm-config-btn { position: relative; }
.llm-config-btn::after {
  content: ""; position: absolute; right: 5px; bottom: 5px;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-mute); border: 2px solid var(--bg);
}
.llm-config-btn--ready { color: var(--primary); }
.llm-config-btn--ready::after { background: var(--primary); }
body.modal-open { overflow: hidden; }
.llm-modal { display: none; position: fixed; inset: 0; z-index: 140; align-items: center; justify-content: center; padding: 18px; }
.llm-modal.open { display: flex; }
.llm-modal__scrim { position: absolute; inset: 0; background: rgba(1, 4, 9, .58); backdrop-filter: blur(2px); }
.llm-modal__card {
  position: relative; width: min(560px, 100%); max-height: min(760px, calc(100dvh - 36px)); overflow: auto;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}
.llm-modal__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 20px 22px 14px; border-bottom: 1px solid var(--border-soft); }
.llm-modal__head h2 { margin: 2px 0 0; font-size: 20px; line-height: 1.35; }
.llm-modal__close { border: none; background: transparent; color: var(--text-mute); font-size: 24px; cursor: pointer; line-height: 1; padding: 2px 4px; }
.llm-modal__close:hover { color: var(--text); }
.llm-modal__body { display: grid; gap: 14px; padding: 18px 22px; }
.llm-field { display: grid; gap: 6px; font-size: 13px; color: var(--text-soft); }
.llm-field > span { font-weight: 600; color: var(--text); }
.llm-field input, .llm-field select {
  width: 100%; min-width: 0; padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--text); font: inherit; outline: none;
}
.llm-field input:focus, .llm-field select:focus { border-color: var(--accent-border); box-shadow: 0 0 0 3px var(--accent-soft); }
.llm-field small { color: var(--text-mute); line-height: 1.5; }
.llm-field code { font-family: var(--code-font); font-size: 11px; }
.llm-key-row { display: flex; gap: 8px; }
.llm-key-row button { flex: 0 0 auto; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-soft); color: var(--text-soft); cursor: pointer; }
.llm-modal__notice { padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-soft); color: var(--text-soft); font-size: 12px; line-height: 1.55; }
.llm-modal__notice code { font-family: var(--code-font); font-size: 11px; }
.llm-modal__status { min-height: 20px; font-size: 12.5px; color: var(--text-soft); white-space: pre-wrap; }
.llm-modal__status.is-ok { color: var(--primary); }
.llm-modal__status.is-error { color: var(--danger); }
.llm-modal__foot { display: flex; align-items: center; gap: 8px; padding: 14px 22px 20px; border-top: 1px solid var(--border-soft); }
.llm-modal__spacer { flex: 1; }
.llm-btn { padding: 8px 13px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-soft); color: var(--text); cursor: pointer; font-weight: 600; }
.llm-btn:hover:not(:disabled) { background: var(--bg-inset); }
.llm-btn:disabled { opacity: .6; cursor: wait; }
.llm-btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.llm-btn--primary:hover:not(:disabled) { background: var(--accent-hover); }
.llm-btn--danger { color: var(--danger); }

/* ============================================================
   ch29 大小模型协同实验
   ============================================================ */

@media (max-width: 700px) {
  .llm-modal { padding: 0; align-items: flex-end; }
  .llm-modal__card { width: 100%; max-height: 92dvh; border-radius: 16px 16px 0 0; }
  .llm-modal__foot { flex-wrap: wrap; }
  .llm-modal__spacer { display: none; }
  .llm-modal__foot .llm-btn { flex: 1; }
}
