:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eaf1ff;
  --text: #1f2329;
  --text-2: #4e5969;
  --muted: #86909c;
  --line: #e5e6eb;
  --bg: #ffffff;
  --bg-soft: #f7f8fa;
  --code-bg: #f2f3f5;
  --topbar-h: 56px;
  --sidebar-w: 268px;
  --toc-w: 232px;
}
* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--topbar-h) + 16px); scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.75;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- top bar ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 28px;
  padding: 0 24px;
  background: rgba(255,255,255,.96);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.menu-btn {
  display: none; border: 0; background: transparent; padding: 6px; margin: 0 -6px 0 -8px;
  cursor: pointer; color: var(--text-2); border-radius: 6px;
}
.menu-btn:hover { background: var(--bg-soft); }
.logo { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 16px; white-space: nowrap; }
.logo:hover { color: var(--text); text-decoration: none; }
.logo svg { flex: none; }
.logo .sub { font-weight: 500; color: var(--text-2); padding-left: 10px; border-left: 1px solid var(--line); font-size: 14px; }
.topnav { display: flex; align-items: stretch; height: 100%; gap: 4px; }
.topnav a {
  display: flex; align-items: center; padding: 0 14px; color: var(--text-2); font-size: 14px;
  border-bottom: 2px solid transparent; margin-top: 2px;
}
.topnav a:hover { color: var(--primary); text-decoration: none; }
.topnav a.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.search-btn {
  display: flex; align-items: center; gap: 8px; width: 260px; height: 34px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg-soft);
  color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; text-align: left;
}
.search-btn:hover { border-color: #c9cdd4; background: #fff; }
.search-btn span.grow { flex: 1; }
.search-btn kbd {
  font: 11px/1 inherit; font-family: inherit; padding: 3px 6px; border: 1px solid var(--line); border-radius: 4px; background: #fff; color: var(--muted);
}
.pill {
  display: inline-flex; align-items: center; height: 34px; padding: 0 14px; border-radius: 8px;
  font-size: 13px; white-space: nowrap; border: 1px solid var(--line); color: var(--text-2); background: #fff;
}
.pill:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.pill.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.pill.primary:hover { background: var(--primary-hover); color: #fff; }

/* ---------- layout ---------- */
.layout { display: flex; padding-top: var(--topbar-h); min-height: 100vh; }
.sidebar {
  position: fixed; top: var(--topbar-h); bottom: 0; left: 0; width: var(--sidebar-w);
  overflow-y: auto; padding: 20px 12px 40px 20px; border-right: 1px solid var(--line); background: #fff;
}
.sidebar::-webkit-scrollbar, .toc-inner::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb, .toc-inner::-webkit-scrollbar-thumb { background: #dcdfe4; border-radius: 3px; }
.nav-group { margin-bottom: 18px; }
.nav-group-title { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .06em; padding: 0 10px; margin-bottom: 6px; }
.nav-item {
  display: block; padding: 7px 10px; margin: 1px 0; border-radius: 6px; color: var(--text-2); font-size: 14px; line-height: 1.5;
}
.nav-item:hover { background: var(--bg-soft); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-sub { margin: 2px 0 4px 12px; padding-left: 10px; border-left: 1px solid var(--line); }
.nav-sub a { display: block; padding: 4px 8px; font-size: 13px; color: var(--muted); border-radius: 4px; line-height: 1.5; }
.nav-sub a:hover { color: var(--primary); text-decoration: none; }
.sidebar-foot { margin-top: 24px; padding: 12px; border-radius: 8px; background: var(--bg-soft); font-size: 12px; color: var(--text-2); line-height: 1.7; }
.sidebar-foot b { color: var(--text); }

.content { flex: 1; min-width: 0; margin-left: var(--sidebar-w); margin-right: var(--toc-w); }
.content-inner { max-width: 820px; margin: 0 auto; padding: 32px 40px 24px; }
.toc { position: fixed; top: var(--topbar-h); bottom: 0; right: 0; width: var(--toc-w); padding: 28px 16px 24px 8px; }
.toc-inner { max-height: 100%; overflow-y: auto; border-left: 1px solid var(--line); padding-left: 16px; }
.toc-title { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .06em; margin-bottom: 10px; }
.toc a { display: block; padding: 3px 0; font-size: 13px; line-height: 1.55; color: var(--text-2); }
.toc a.l3 { padding-left: 14px; font-size: 12.5px; color: var(--muted); }
.toc a:hover { color: var(--primary); text-decoration: none; }
.toc a.on { color: var(--primary); font-weight: 600; }
.toc.empty { display: none; }

/* ---------- article ---------- */
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--primary); }
.crumbs .sep { margin: 0 6px; }
.doc h1 { font-size: 32px; line-height: 1.35; margin: 0 0 12px; font-weight: 700; letter-spacing: -.01em; }
.doc .lead { font-size: 16px; color: var(--text-2); margin: 0 0 24px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.doc h2 { font-size: 23px; line-height: 1.4; margin: 40px 0 14px; padding-bottom: 8px; border-bottom: 1px solid var(--line); font-weight: 700; }
.doc h3 { font-size: 18px; line-height: 1.45; margin: 28px 0 10px; font-weight: 600; }
.doc h2 .anchor, .doc h3 .anchor { margin-left: 8px; color: var(--primary); opacity: 0; font-weight: 400; text-decoration: none; }
.doc h2:hover .anchor, .doc h3:hover .anchor { opacity: .7; }
.doc p { margin: 0 0 14px; }
.doc ul, .doc ol { padding-left: 24px; margin: 0 0 16px; }
.doc li { margin: 0 0 6px; }
.doc a { text-decoration: none; }
.doc a:hover { text-decoration: underline; text-underline-offset: 3px; }
.doc strong { font-weight: 600; }
.doc code { font-family: "JetBrains Mono", Consolas, "SF Mono", Menlo, monospace; font-size: .88em; background: var(--code-bg); color: #c2410c; padding: 2px 6px; border-radius: 4px; }
.doc pre { position: relative; margin: 0 0 18px; padding: 16px 18px; background: #0f172a; color: #e2e8f0; border-radius: 8px; overflow-x: auto; font-size: 13px; line-height: 1.65; }
.doc pre code { background: transparent; color: inherit; padding: 0; font-size: inherit; }
.copy-btn {
  position: absolute; top: 8px; right: 8px; padding: 3px 10px; border: 1px solid rgba(255,255,255,.2); border-radius: 5px;
  background: rgba(255,255,255,.08); color: #cbd5e1; font: 12px/1.6 inherit; cursor: pointer; opacity: 0; transition: opacity .15s;
}
.doc pre:hover .copy-btn, .copy-btn:focus { opacity: 1; }
.copy-btn:hover { background: rgba(255,255,255,.18); }
.table-wrap { overflow-x: auto; margin: 0 0 18px; border: 1px solid var(--line); border-radius: 8px; }
.doc table { width: 100%; border-collapse: collapse; font-size: 14px; }
.doc th, .doc td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.doc tr:last-child td { border-bottom: 0; }
.doc th { background: var(--bg-soft); font-weight: 600; color: var(--text-2); white-space: nowrap; }
.doc details { margin: 0 0 16px; border: 1px solid var(--line); border-radius: 8px; padding: 0 16px; }
.doc details[open] { padding-bottom: 4px; }
.doc summary { padding: 10px 0; cursor: pointer; font-weight: 600; color: var(--primary); }

.callout { margin: 0 0 18px; padding: 12px 16px 12px 16px; border-radius: 8px; border: 1px solid #bfd4ff; border-left: 4px solid var(--primary); background: #f3f7ff; }
.callout > :last-child { margin-bottom: 0; }
.callout-title { font-weight: 700; margin-bottom: 4px; color: var(--primary); }
.callout.warn { background: #fff9eb; border-color: #fde1a1; border-left-color: #f59e0b; }
.callout.warn .callout-title { color: #b45309; }
.callout.danger { background: #fff1f0; border-color: #ffccc7; border-left-color: #f5222d; }
.callout.danger .callout-title { color: #cf1322; }
.callout.ok { background: #f0fbf4; border-color: #b7ebc6; border-left-color: #16a34a; }
.callout.ok .callout-title { color: #15803d; }

/* legacy FAQ markup */
.doc h3.step-title { margin: 32px 0 14px; padding: 10px 16px; border-left: 4px solid var(--primary); border-radius: 0 8px 8px 0; background: var(--primary-soft); color: var(--primary); font-size: 18px; }
.doc p.restart-warning { margin: 20px 0; padding: 14px 18px; border: 1px solid #ffccc7; border-left: 4px solid #f5222d; border-radius: 8px; background: #fff1f0; color: #cf1322; font-weight: 600; line-height: 1.85; }
.doc p.restart-warning strong { font-weight: 800; text-decoration: underline; text-underline-offset: 3px; }

figure.shot { margin: 8px 0 22px; }
figure.shot img { display: block; max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: 8px; cursor: zoom-in; box-shadow: 0 2px 10px rgba(15,23,42,.06); }
figure.shot figcaption { margin-top: 8px; font-size: 13px; color: var(--muted); text-align: center; }

.steps-flow { list-style: none; padding: 0; margin: 0 0 20px; counter-reset: s; display: grid; gap: 10px; }
.steps-flow li { counter-increment: s; position: relative; margin: 0; padding: 12px 16px 12px 54px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.steps-flow li::before {
  content: counter(s); position: absolute; left: 14px; top: 12px; width: 26px; height: 26px; line-height: 26px; text-align: center;
  border-radius: 50%; background: var(--primary); color: #fff; font-size: 13px; font-weight: 700;
}
.steps-flow li b { display: block; }
.steps-flow li span { color: var(--text-2); font-size: 14px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin: 0 0 20px; }
.card {
  display: block; padding: 16px 18px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--text);
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.card:hover { border-color: var(--primary); box-shadow: 0 6px 20px rgba(37,99,235,.10); transform: translateY(-1px); text-decoration: none !important; color: var(--text); }
.card .ic { width: 36px; height: 36px; border-radius: 8px; background: var(--primary-soft); color: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 700; margin-bottom: 10px; font-size: 15px; }
.card .t { font-weight: 600; font-size: 15px; margin-bottom: 2px; }
.card .d { font-size: 13px; color: var(--text-2); line-height: 1.6; }

.hero { margin: 0 0 30px; padding: 36px 36px 32px; border-radius: 14px; background: linear-gradient(135deg, #eff5ff 0%, #f8faff 55%, #fff7ed 100%); border: 1px solid #dbe6ff; }
.hero h1 { font-size: 34px; margin: 0 0 10px; }
.hero p { margin: 0 0 20px; color: var(--text-2); font-size: 16px; max-width: 560px; }
.hero .btns { display: flex; gap: 12px; flex-wrap: wrap; }
.hero .btns a { display: inline-flex; align-items: center; height: 38px; padding: 0 20px; border-radius: 8px; font-size: 14px; font-weight: 600; text-decoration: none !important; }
.hero .btns .p { background: var(--primary); color: #fff; }
.hero .btns .p:hover { background: var(--primary-hover); }
.hero .btns .s { background: #fff; color: var(--text); border: 1px solid var(--line); }
.hero .btns .s:hover { border-color: var(--primary); color: var(--primary); }

.pager { display: flex; gap: 14px; margin: 44px 0 0; }
.pager a { flex: 1; display: block; padding: 12px 16px; border: 1px solid var(--line); border-radius: 8px; color: var(--text); }
.pager a:hover { border-color: var(--primary); text-decoration: none; }
.pager .lbl { display: block; font-size: 12px; color: var(--muted); }
.pager .ttl { font-weight: 600; color: var(--primary); }
.pager .next { text-align: right; }
.pager .spacer { flex: 1; }

.footer { margin-top: 48px; padding: 20px 0 28px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); line-height: 1.9; }
.footer a { color: var(--muted); }
.footer a:hover { color: var(--primary); }

/* ---------- search modal ---------- */
.search-mask { position: fixed; inset: 0; z-index: 100; background: rgba(15,23,42,.45); display: none; align-items: flex-start; justify-content: center; padding: 12vh 16px 16px; }
.search-mask.open { display: flex; }
.search-box { width: 100%; max-width: 640px; max-height: 70vh; display: flex; flex-direction: column; background: #fff; border-radius: 12px; box-shadow: 0 20px 60px rgba(15,23,42,.3); overflow: hidden; }
.search-box input { border: 0; outline: 0; padding: 16px 20px; font: inherit; font-size: 16px; border-bottom: 1px solid var(--line); }
.search-results { overflow-y: auto; padding: 8px; }
.search-results a { display: block; padding: 10px 12px; border-radius: 8px; color: var(--text); }
.search-results a:hover, .search-results a.sel { background: var(--primary-soft); text-decoration: none; }
.search-results .rt { font-weight: 600; font-size: 14px; }
.search-results .rt small { font-weight: 400; color: var(--muted); margin-left: 8px; }
.search-results .rs { font-size: 12.5px; color: var(--text-2); margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.search-results mark { background: #fde68a; color: inherit; border-radius: 2px; }
.search-empty { padding: 28px; text-align: center; color: var(--muted); font-size: 14px; }

.lightbox { position: fixed; inset: 0; z-index: 120; background: rgba(15,23,42,.82); display: none; align-items: center; justify-content: center; padding: 20px; cursor: zoom-out; }
.lightbox.open { display: flex; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; background: #fff; }

.mask { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .toc { display: none; }
  .content { margin-right: 0; }
}
@media (max-width: 900px) {
  .topbar { padding: 0 14px; gap: 14px; }
  .menu-btn { display: block; }
  .topnav, .logo .sub, .pill.qq { display: none; }
  .search-btn { width: auto; }
  .search-btn .grow, .search-btn kbd { display: none; }
  .sidebar { transform: translateX(-100%); transition: transform .2s; z-index: 60; }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(15,23,42,.2); }
  body.nav-open .mask { display: block; position: fixed; inset: 0; top: var(--topbar-h); z-index: 55; background: rgba(15,23,42,.4); }
  .content { margin-left: 0; }
  .content-inner { padding: 22px 18px 16px; }
  .doc h1 { font-size: 26px; }
  .doc h2 { font-size: 20px; }
  .hero { padding: 24px 20px; }
  .hero h1 { font-size: 26px; }
  .pager { flex-direction: column; }
}
@media print {
  .topbar, .sidebar, .toc, .pager, .copy-btn { display: none !important; }
  .content { margin: 0; }
}

/* ---------- sections: posts / news ---------- */
.post-list { display: grid; gap: 14px; margin: 0 0 20px; }
.post-card { display: block; padding: 16px 20px; border: 1px solid var(--line); border-radius: 10px; color: var(--text); background: #fff; transition: border-color .15s, box-shadow .15s; }
.post-card:hover { border-color: var(--primary); box-shadow: 0 6px 20px rgba(37,99,235,.08); text-decoration: none !important; color: var(--text); }
.post-card .pt { font-size: 17px; font-weight: 600; margin: 4px 0 2px; }
.post-card .pd { font-size: 13.5px; color: var(--text-2); }
.post-meta { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; color: var(--muted); font-size: 13px; margin: 0 0 14px; }
.post-card .post-meta { margin: 0; }
.tag { display: inline-block; padding: 0 8px; border-radius: 4px; background: var(--primary-soft); color: var(--primary); font-size: 12px; line-height: 20px; font-weight: 500; }
.tag.act { background: #fff4e6; color: #d46b08; }
.tag.news { background: #e8f7ef; color: #15803d; }
ul.mini { margin: 6px 0 0; padding-left: 18px; font-size: 13.5px; color: var(--text-2); }
ul.mini li { margin: 0 0 2px; }
.doc .news-item { display: flex; gap: 16px; padding: 20px 0; border-bottom: 1px solid var(--line); }
.doc .news-item:last-of-type { border-bottom: 0; }
.news-item .no { flex: none; width: 28px; padding-top: 5px; font-size: 14px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.news-item .nb { min-width: 0; }
.doc .news-item h2 { margin: 0 0 8px; padding: 0; border: 0; font-size: 19px; line-height: 1.5; }
.doc .news-item p { margin: 0 0 8px; color: var(--text-2); }
.news-item .src { font-size: 12.5px; color: var(--muted); }
.doc blockquote { margin: 0 0 16px; padding: 4px 16px; border-left: 4px solid var(--line); color: var(--text-2); background: var(--bg-soft); border-radius: 0 6px 6px 0; }
.doc hr { border: 0; border-top: 1px solid var(--line); margin: 28px 0; }
.card .d ul.mini { margin-top: 2px; }
