/* AI-FDE 文档站公共样式
 * 使用方：/docs/** 、/zh/docs/**（由 tools/build-docs.mjs 生成）
 * 视觉与首页（工具页）区分：文档偏「杂志/报告」，深蓝色系、可长文阅读。
 */
:root {
  --ink: #1a1a1a;
  --ink-soft: #4b5563;
  --line: #d8dde3;
  --line-soft: #ebeff3;
  --navy: #1c3a5e;
  --navy-deep: #0f2540;
  --panel: #f6f8fa;
  --accent: #2dd4bf;
  --warn: #fff6e5;
  --warn-line: #d79a2b;
  --maxw: 1500px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: #fff;
  color: var(--ink);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.8;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--navy); }
a:hover { text-decoration: none; }

/* 站点头 */
header.site {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 12px 28px; background: var(--navy-deep); color: #fff;
  position: sticky; top: 0; z-index: 60;
}
header.site .brand { color: #fff; font-weight: 700; text-decoration: none; letter-spacing: .3px; font-size: 15px; }
header.site .brand span { color: var(--accent); }
header.site nav { display: flex; gap: 6px; align-items: center; }
header.site nav a {
  color: #cfdce8; text-decoration: none; font-size: 13.5px;
  padding: 6px 11px; border-radius: 6px;
}
header.site nav a:hover { background: rgba(255,255,255,.09); color: #fff; }
header.site nav a.on { background: rgba(45,212,191,.18); color: #fff; }
header.site nav a.lang { border: 1px solid rgba(255,255,255,.35); }

/* 布局 */
.wrap { display: flex; align-items: flex-start; max-width: var(--maxw); margin: 0 auto; padding-left: 280px; transition: padding-left .22s ease; }
body.nav-closed .wrap { padding-left: 0; }
nav.toc {
  position: fixed; left: 0; top: 62px; bottom: 0; z-index: 65;
  width: 280px; overflow-y: auto;
  padding: 22px 16px 48px 24px; border-right: 1px solid var(--line-soft); background: #fbfcfd;
  transition: transform .22s ease, visibility .22s;
}
body.nav-closed nav.toc { transform: translateX(-100%); visibility: hidden; }

/* 左侧抽屉拉手：展开时贴在导航右边缘，收起时回到视口左边缘 */
#series-btn {
  position: fixed; left: 280px; top: 50%; transform: translateY(-50%); z-index: 71;
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 12px 8px; border: 1px solid var(--line); border-left: 0; border-radius: 0 8px 8px 0;
  background: #fff; color: var(--navy); font-family: inherit; font-size: 12px; line-height: 1;
  cursor: pointer; box-shadow: 3px 2px 12px rgba(15,37,64,.10);
  transition: left .22s ease, background .15s, color .15s;
}
#series-btn .lb { writing-mode: vertical-rl; letter-spacing: 2px; }
#series-btn svg { transition: transform .22s ease; }
#series-btn:hover { background: #f2f6fa; }
#series-btn[aria-expanded="true"] { background: var(--navy); color: #fff; border-color: var(--navy); }
body.nav-closed #series-btn { left: 0; }
body.nav-closed #series-btn svg { transform: rotate(180deg); }
nav.toc .toc-h {
  font-size: 12px; letter-spacing: 1.5px; color: var(--ink-soft);
  text-transform: uppercase; margin: 18px 0 8px; font-weight: 700;
}
nav.toc .toc-h:first-child { margin-top: 0; }
nav.toc a {
  display: block; text-decoration: none; color: var(--ink-soft);
  padding: 5px 8px; border-left: 3px solid transparent; font-size: 13.5px; line-height: 1.5;
}
nav.toc a:hover { background: var(--panel); color: var(--navy); }
nav.toc a.on { background: #eaf0f6; border-left-color: var(--navy); color: var(--navy); font-weight: 600; }
nav.toc a.art { padding-left: 8px; }
nav.toc a.art.cur { color: var(--navy); font-weight: 700; background: #eef3f8; }
nav.toc a.art .no { display: inline-block; min-width: 20px; color: #9aa4b2; font-variant-numeric: tabular-nums; }
nav.toc .toc-grp {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  width: 100%; margin: 14px 0 4px; padding: 10px 8px 4px;
  border: 0; border-top: 1px dashed var(--line); background: none; font-family: inherit; text-align: left;
  font-size: 11.5px; font-weight: 700; color: #7a8697; letter-spacing: .3px; cursor: pointer;
}
nav.toc .toc-grp:hover { color: var(--navy); }
nav.toc .toc-grp.cur { color: var(--navy); }
nav.toc .toc-grp .caret { font-size: 10px; opacity: .65; transition: transform .18s; }
nav.toc .toc-grp.collapsed .caret { transform: rotate(-90deg); }
nav.toc .toc-grp-body.collapsed { display: none; }
nav.toc .toc-grp:first-child { margin-top: 4px; border-top: none; }
nav.toc a.h3 { padding-left: 22px; font-size: 12.5px; }

/* 本页目录：右侧滑出面板，默认完全隐藏（横向），点贴边标签才出现 */
nav.page-toc {
  position: fixed; top: 62px; right: 0; bottom: 0; z-index: 72;
  width: 288px; max-width: 86vw; overflow-y: auto;
  padding: 18px 18px 48px; background: #fff; border-left: 1px solid var(--line);
  box-shadow: -10px 0 30px rgba(15,37,64,.10);
  transform: translateX(102%); visibility: hidden;
  transition: transform .22s ease, visibility .22s;
}
nav.page-toc.open { transform: translateX(0); visibility: visible; }
nav.page-toc .pt-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 0 0 10px; margin: 0 0 10px; border-bottom: 1px solid var(--line-soft);
  font-size: 11.5px; font-weight: 700; letter-spacing: 1.2px; color: #9aa4b2;
}
nav.page-toc .pt-close {
  border: 0; background: none; font-family: inherit; font-size: 13px; line-height: 1;
  color: #9aa4b2; cursor: pointer; padding: 4px 5px; border-radius: 4px;
}
nav.page-toc .pt-close:hover { background: var(--panel); color: var(--navy); }
nav.page-toc .pt-body { border-left: 2px solid var(--line-soft); }
nav.page-toc a {
  display: block; text-decoration: none; color: var(--ink-soft); font-size: 13px;
  padding: 5px 4px 5px 11px; margin-left: -2px; border-left: 2px solid transparent;
  line-height: 1.55;
}
nav.page-toc a:hover { color: var(--navy); }
nav.page-toc a.on { color: var(--navy); border-left-color: var(--navy); font-weight: 600; }
nav.page-toc a.h3 { padding-left: 22px; font-size: 12.5px; color: #8a94a2; }

/* 触发标签：宽屏竖排贴右边缘，窄屏右下角胶囊 */
#pagetoc-btn {
  position: fixed; right: 0; top: 50%; transform: translateY(-50%); z-index: 73;
  writing-mode: vertical-rl; padding: 14px 8px;
  border: 1px solid var(--line); border-right: 0; border-radius: 8px 0 0 8px;
  background: #fff; color: var(--navy); font-family: inherit; font-size: 12px; letter-spacing: 2px;
  cursor: pointer; box-shadow: -3px 2px 12px rgba(15,37,64,.10);
}
#pagetoc-btn:hover { background: #f2f6fa; }
#pagetoc-btn[aria-expanded="true"] { background: var(--navy); color: #fff; border-color: var(--navy); }
/* 宽屏：展开时标签跟到面板外沿，像抽屉拉手 */
@media (min-width: 961px) {
  #pagetoc-btn { transition: right .22s ease, background .15s, color .15s; }
  #pagetoc-btn[aria-expanded="true"] { right: 288px; }
}

main { flex: 1 1 auto; min-width: 0; max-width: 980px; margin: 0 auto; padding: 30px 40px 90px; transition: max-width .22s ease; }
/* 左侧抽屉收起时正文加宽，填满空出来的横向空间 */
body.nav-closed main { max-width: 1060px; }

/* 面包屑 */
.crumb { font-size: 13px; color: var(--ink-soft); margin-bottom: 14px; }
.crumb a { color: var(--ink-soft); text-decoration: none; }
.crumb a:hover { color: var(--navy); }

/* 正文排版 */
article h1.doc-title {
  font-size: 26px; line-height: 1.4; margin: 0 0 8px; padding-bottom: 14px;
  border-bottom: 2px solid var(--navy);
}
article .doc-sub { color: var(--ink-soft); font-size: 14px; margin: 0 0 4px; }
article .doc-meta { color: #8a94a2; font-size: 13px; margin: 0 0 26px; }
article h2 {
  font-size: 20px; margin: 42px 0 14px; padding: 9px 0 9px 13px;
  border-left: 5px solid var(--navy); background: #f4f7fa; color: var(--navy);
  scroll-margin-top: 66px;
}
article h3 { font-size: 16.5px; margin: 28px 0 10px; color: var(--ink); border-bottom: 1px solid var(--line); padding-bottom: 6px; scroll-margin-top: 66px; }
article h4 { font-size: 15px; margin: 20px 0 8px; }
article p { margin: 11px 0; }
article ul, article ol { margin: 11px 0; padding-left: 26px; }
article li { margin: 5px 0; }
article strong { font-weight: 700; }
article code { background: var(--panel); padding: 1px 5px; border-radius: 3px; font-size: 13px; font-family: Consolas, Monaco, monospace; overflow-wrap: break-word; }
article pre { background: #0f172a; color: #e2e8f0; padding: 16px 18px; border-radius: 8px; overflow-x: auto; font-size: 13px; line-height: 1.6; }
article pre code { background: none; color: inherit; padding: 0; font-size: 13px; }
article img { max-width: 100%; height: auto; border: 1px solid var(--line-soft); border-radius: 6px; margin: 16px 0; display: block; }
article blockquote {
  margin: 16px 0; padding: 12px 16px; background: var(--panel);
  border-left: 4px solid var(--navy); color: var(--ink); font-size: 14px;
}
article blockquote p { margin: 6px 0; }
article hr { border: none; border-top: 1px dashed var(--line); margin: 30px 0; }

/* 表格 */
.tw { overflow-x: auto; margin: 16px 0; border: 1px solid var(--line); }
article table { border-collapse: collapse; width: 100%; font-size: 13.5px; min-width: 520px; }
article th, article td { border: 1px solid var(--line); padding: 9px 11px; text-align: left; vertical-align: top; line-height: 1.65; }
article thead th { background: #eef2f6; font-weight: 700; white-space: nowrap; }
article tbody tr:nth-child(even) { background: #fafbfc; }
article tbody tr:hover { background: #f2f6fa; }

/* 上下篇 */
.pager { display: flex; gap: 14px; margin: 44px 0 0; border-top: 1px solid var(--line); padding-top: 20px; }
.pager a {
  flex: 1; text-decoration: none; border: 1px solid var(--line); border-radius: 8px;
  padding: 12px 15px; color: var(--ink); background: #fff;
}
.pager a:hover { border-color: var(--navy); background: #f7fafc; }
.pager .dir { display: block; font-size: 12px; color: var(--ink-soft); margin-bottom: 4px; }
.pager .ttl { font-weight: 600; color: var(--navy); }
.pager .next { text-align: right; }
.pager .spacer { flex: 1; }

/* 文末 */
.doc-foot { margin-top: 30px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 13px; color: var(--ink-soft); }
.doc-foot a { color: var(--navy); }

/* 列表页 */
.hero { padding: 44px 0 26px; border-bottom: 1px solid var(--line); }
.hero h1 { font-size: 30px; margin: 0 0 12px; }
.hero p { color: var(--ink-soft); max-width: 720px; margin: 0; }
.series { margin: 34px 0; }
.series h2 { font-size: 20px; color: var(--navy); border-left: 5px solid var(--navy); padding-left: 12px; }
.series h2:first-child { margin-top: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; margin: 18px 0; }
.card {
  display: block; text-decoration: none; color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; padding: 18px 18px 16px; background: #fff;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.card:hover { border-color: var(--navy); box-shadow: 0 6px 20px rgba(28,58,94,.09); transform: translateY(-1px); }
.card .no { font-size: 12px; color: #9aa4b2; letter-spacing: 1px; }
.card h3 { margin: 6px 0 8px; font-size: 16.5px; color: var(--ink); border: none; padding: 0; }
.card p { margin: 0; font-size: 13.5px; color: var(--ink-soft); line-height: 1.7; }
.card .tags { margin-top: 12px; font-size: 12px; color: #8a94a2; }

/* 移动端 */
@media (max-width: 960px) {
  header.site { padding: 10px 16px; }
  .wrap { flex-direction: column; align-items: stretch; padding-left: 0; }
  nav.toc {
    position: static; left: auto; top: auto; bottom: auto; z-index: auto;
    width: 100%; flex: none; max-height: none; overflow: visible; transform: none;
    border-right: none;
    border-bottom: 1px solid var(--line); padding: 12px 16px; background: #fbfcfd;
  }
  body.nav-closed nav.toc { transform: none; visibility: visible; }
  body.nav-closed main { max-width: none; }
  #series-btn { display: none; }
  nav.toc .toc-body { display: none; }
  nav.toc.open .toc-body { display: block; }
  nav.toc .toc-h { margin-top: 0; }
  nav.toc .toc-h:first-child { cursor: pointer; display: flex; justify-content: space-between; }
  nav.toc .toc-h:first-child::after { content: "☰ 目录"; font-size: 12px; letter-spacing: 0; color: var(--navy); }
  nav.toc.open .toc-h:first-child::after { content: "✕ 收起"; }
  nav.toc .toc-h:not(:first-child) { display: none; }
  nav.toc.open .toc-h:not(:first-child) { display: block; }
  main { padding: 18px 16px 70px; margin: 0; max-width: none; }
  article h1.doc-title { font-size: 21px; }
  article h2 { font-size: 17px; margin: 32px 0 12px; }
  article table { min-width: 460px; }
  .pager { flex-direction: column; }
  .pager .next { text-align: left; }
  #pagetoc-btn {
    writing-mode: horizontal-tb; letter-spacing: 0; transform: none;
    top: auto; bottom: 74px; right: 16px; padding: 8px 13px;
    border-radius: 999px; border-right: 1px solid var(--line);
    font-size: 12.5px; font-weight: 600; box-shadow: 0 2px 10px rgba(15,37,64,.14);
  }
  nav.page-toc { top: 58px; width: 300px; }
}
@media print {
  header.site, nav.toc, nav.page-toc, .pager, #pagetoc-btn, #series-btn, #top { display: none; }
  main { padding: 0; }
  article h2 { background: none; }
  .tw { overflow: visible; }
  article table { min-width: 0; font-size: 11px; }
}
