:root {
  --brand: #2f54eb;
  --brand-soft: #eef2ff;
  --bg: #f7f8fa;
  --panel: #ffffff;
  --text: #1f2329;
  --muted: #6b7280;
  --border: #e5e7eb;
  --sidebar-w: 280px;
  --topbar-h: 56px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--topbar-h) + 16px); overflow-x: hidden; }

body {
  margin: 0;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
  overflow-x: hidden;
}

/* ============ 首页 ============ */
.home-header {
  text-align: center;
  padding: 52px 16px 28px;
  background: linear-gradient(180deg, #eef2ff 0%, #f7f8fa 100%);
  border-bottom: 1px solid var(--border);
}
.logo-badge {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  font-weight: 700;
  margin: 0 auto 14px;
  box-shadow: 0 6px 18px rgba(47, 84, 235, .25);
}
.logo-badge.sm { width: 30px; height: 30px; border-radius: 8px; font-size: 15px; margin: 0; box-shadow: none; }
.site-title { font-size: 28px; margin: 0; letter-spacing: .5px; }
.site-sub { color: var(--muted); margin: 8px 0 0; font-size: 14px; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 20px;
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 20px 48px;
}
.card {
  display: block;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  transition: transform .15s ease, box-shadow .15s ease;
}
.card:hover { transform: translateY(-4px); box-shadow: 0 10px 28px rgba(0, 0, 0, .1); }
.card-thumb {
  height: 138px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 46px;
  color: #fff;
}
/* 占位配图：将 .card-thumb 内容换成 <img src="./assets/xxx.png" style="width:100%;height:100%;object-fit:cover"> 即可 */
.thumb-1 { background: linear-gradient(135deg, #2f54eb, #5b7cfa); }
.thumb-2 { background: linear-gradient(135deg, #0ea5a4, #22c1b6); }
.thumb-3 { background: linear-gradient(135deg, #f59e0b, #fbbf24); }
.thumb-4 { background: linear-gradient(135deg, #ef4444, #f97316); }
.card-body { padding: 16px 18px 20px; }
.card-body h3 { margin: 0 0 6px; font-size: 17px; }
.card-body p { margin: 0; color: var(--muted); font-size: 14px; }
.card-go { display: inline-block; margin-top: 12px; color: var(--brand); font-size: 14px; font-weight: 600; }

.home-footer {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 24px;
  border-top: 1px solid var(--border);
}

/* ============ 手册页顶栏 ============ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 14px; font-weight: 600; text-decoration: none; color: var(--text); }
.brand-logo { font-size: 20px; }
.brand-name { white-space: nowrap; }
.search-box { margin-left: auto; }
.search-box input {
  width: 220px;
  max-width: 40vw;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
}
.search-box input:focus { border-color: var(--brand); }
.menu-toggle {
  display: none;
  border: none;
  background: transparent;
  font-size: 20px;
  cursor: pointer;
  color: var(--text);
}

/* 布局 */
.layout { display: flex; align-items: flex-start; min-width: 0; overflow-x: hidden; }

/* 左侧目录 */
.sidebar {
  position: sticky;
  top: var(--topbar-h);
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 16px 12px;
  background: var(--panel);
  border-right: 1px solid var(--border);
}
.toc a {
  display: block;
  padding: 6px 10px;
  color: var(--muted);
  text-decoration: none;
  border-radius: 6px;
  font-size: 14px;
  border-left: 3px solid transparent;
}
.toc a.sub { padding-left: 24px; font-size: 13px; }
.toc a:hover { background: var(--brand-soft); color: var(--brand); }
.toc a.active {
  background: var(--brand-soft);
  color: var(--brand);
  border-left-color: var(--brand);
  font-weight: 600;
}
.toc .toc-hide { display: none; }

/* 内容区 */
.content {
  flex: 1;
  min-width: 0;
  padding: 28px 36px 80px;
  overflow-x: hidden;
}
.doc { max-width: 820px; margin: 0 auto; }
.chapter { scroll-margin-top: calc(var(--topbar-h) + 16px); }
.doc h2 {
  margin-top: 36px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--brand);
  font-size: 22px;
}
.doc h3 { margin-top: 26px; font-size: 17px; color: #374151; }
.doc p, .doc li { font-size: 15px; }
.doc ol, .doc ul { padding-left: 22px; }
.doc li { margin: 4px 0; }
.doc strong { color: var(--brand); }

/* 图片自适应：杜绝溢出 + 灯箱点击 */
.doc img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  cursor: zoom-in;
}

.back-link { display: inline-block; margin-bottom: 12px; color: var(--brand); text-decoration: none; font-size: 14px; font-weight: 600; }
.doc-lead { color: var(--muted); background: var(--brand-soft); padding: 12px 16px; border-radius: 10px; font-size: 14px; margin: 0 0 8px; }

/* 截图占位框 */
.shot {
  margin: 16px 0;
  border: 1px dashed var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--panel);
}
.shot-placeholder {
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  background: repeating-linear-gradient(45deg, #fafafa, #fafafa 12px, #f1f3f5 12px, #f1f3f5 24px);
  font-size: 14px;
}
.shot figcaption {
  padding: 8px 12px;
  font-size: 13px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  background: #fcfcfd;
}

.doc-footer {
  margin-top: 48px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

/* 移动端遮罩 */
.sidebar-mask {
  display: none;
  position: fixed;
  inset: var(--topbar-h) 0 0 0;
  background: rgba(0, 0, 0, .35);
  z-index: 20;
}

/* 响应式 */
@media (max-width: 900px) {
  .menu-toggle { display: block; }
  .sidebar {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 25;
    box-shadow: 2px 0 12px rgba(0, 0, 0, .12);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-mask.show { display: block; }
  .content { padding: 20px 16px 60px; }
}

/* 新增：滚动锚点修正（生成内容无 .chapter 包裹时） */
.doc h2, .doc h3, .doc h4 { scroll-margin-top: calc(var(--topbar-h) + 16px); }
.toc a.sub2 { padding-left: 38px; font-size: 12px; color: #9ca3af; }

/* 新增：Excel 表格 */
.table-wrap { overflow-x: auto; margin: 16px 0; }
.xl { border-collapse: collapse; width: 100%; font-size: 14px; }
.xl th, .xl td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; vertical-align: top; }
.xl th { background: var(--brand-soft); font-weight: 600; }

/* 新增：图片灯箱 */
.lightbox {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .8);
  display: none; align-items: center; justify-content: center; z-index: 100; cursor: zoom-out;
}
.lightbox.show { display: flex; }
.lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 8px; box-shadow: 0 8px 40px rgba(0, 0, 0, .5); }
