:root {
  --primary: #2563eb;
  --primary-soft: #eff4ff;
  --text: #24292f;
  --text-2: #57606a;
  --border: #e4e8ee;
  --bg: #ffffff;
  --bg-2: #f6f8fa;
  --sidebar-w: 280px;
  --topbar-h: 56px;
  --code-bg: #0d1117;
  --radius: 10px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 15.5px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== 顶栏 ===== */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h); z-index: 50;
  display: flex; align-items: center; gap: 12px; padding: 0 16px;
  background: rgba(255,255,255,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.menu-btn {
  display: none; border: 1px solid var(--border); background: var(--bg); color: var(--text);
  width: 34px; height: 34px; border-radius: 8px; cursor: pointer;
  align-items: center; justify-content: center;
}
.brand { display: flex; align-items: center; gap: 9px; color: var(--text); min-width: 0; }
.brand:hover { text-decoration: none; }
.brand-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  background: linear-gradient(135deg, #2563eb, #0ea5e9); color: #fff;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-text strong { font-size: 14.5px; white-space: nowrap; }
.brand-text em { font-style: normal; font-size: 12px; color: var(--text-2); }

/* 搜索框 */
.search { position: relative; margin-left: auto; width: min(320px, 42vw); }
.search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-2); pointer-events: none; }
.search input {
  width: 100%; height: 34px; padding: 0 12px 0 32px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg-2);
  font-size: 13.5px; color: var(--text); outline: none; transition: border .15s, background .15s;
}
.search input:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px var(--primary-soft); }
.search-results {
  position: absolute; top: 42px; right: 0; width: min(420px, 88vw); max-height: 65vh; overflow: auto;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(15,23,42,.14); padding: 6px;
}
.sr-item { display: block; padding: 9px 11px; border-radius: 8px; color: var(--text); }
.sr-item:hover, .sr-item.hl { background: var(--primary-soft); text-decoration: none; }
.sr-title { font-size: 13.5px; font-weight: 600; display: flex; gap: 8px; align-items: center; }
.sr-group { font-size: 11px; color: var(--text-2); background: var(--bg-2); border: 1px solid var(--border); padding: 0 6px; border-radius: 99px; white-space: nowrap; }
.sr-snippet { font-size: 12.5px; color: var(--text-2); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-empty { padding: 14px; text-align: center; color: var(--text-2); font-size: 13px; }
.sr-item mark, .search-results mark { background: #fff3bf; color: inherit; padding: 0 1px; border-radius: 2px; }

/* ===== 布局 ===== */
.layout {
  display: flex;
  padding-top: var(--topbar-h);
  min-height: 100vh;
  align-items: flex-start;
}
.sidebar {
  width: var(--sidebar-w); flex: none;
  position: sticky; top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h)); overflow-y: auto;
  padding: 18px 14px 32px; border-right: 1px solid var(--border); background: #fbfcfe;
  overscroll-behavior: contain;
}
.sidebar-backdrop { display: none; }
.nav-home {
  display: block; padding: 8px 12px; border-radius: 8px; font-weight: 600; font-size: 14px;
  color: var(--text); margin-bottom: 10px;
}
.nav-home:hover { background: var(--bg-2); text-decoration: none; }
.nav-home.active { background: var(--primary-soft); color: var(--primary); }
.nav-group-title {
  font-size: 12.5px; font-weight: 700; color: var(--text-2); letter-spacing: .02em;
  padding: 12px 12px 6px; 
}
.nav-group ul { list-style: none; margin: 0; padding: 0; }
.nav-group a {
  display: block; padding: 6px 12px; border-radius: 8px; font-size: 13.8px; color: var(--text);
  line-height: 1.5;
}
.nav-group a:hover { background: var(--bg-2); text-decoration: none; color: var(--primary); }
.nav-group a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }

.content {
  flex: 1; min-width: 0; max-width: 880px;
  margin: 0 auto; padding: 34px 40px 60px;
}

/* ===== 右侧本页目录 ===== */
.page-toc {
  width: 230px; flex: none; position: sticky; top: calc(var(--topbar-h) + 20px);
  max-height: calc(100vh - var(--topbar-h) - 60px); overflow-y: auto;
  padding: 6px 18px 30px 0; font-size: 12.8px;
}
.toc-title { font-weight: 700; color: var(--text-2); font-size: 12px; margin-bottom: 8px; letter-spacing: .04em; }
.toc-list { list-style: none; margin: 0; padding: 0; border-left: 1.5px solid var(--border); }
.toc-list a { display: block; padding: 3.5px 0 3.5px 12px; color: var(--text-2); border-left: 1.5px solid transparent; margin-left: -1.5px; line-height: 1.45; }
.toc-list a:hover { color: var(--primary); text-decoration: none; }
.toc-list a.current { color: var(--primary); border-left-color: var(--primary); font-weight: 600; }
.toc-list .lv3 a { padding-left: 26px; }

/* ===== 正文 ===== */
article { min-width: 0; word-wrap: break-word; }
article h1 {
  font-size: 27px; line-height: 1.35; margin: 0 0 22px; padding-bottom: 14px;
  border-bottom: 1px solid var(--border); font-weight: 700;
}
article h2 {
  font-size: 21px; margin: 40px 0 14px; padding-bottom: 8px;
  border-bottom: 1px solid var(--border); font-weight: 650;
}
article h3 { font-size: 17.5px; margin: 30px 0 10px; font-weight: 650; }
article h4 { font-size: 15.5px; margin: 22px 0 8px; }
article p { margin: 12px 0; }
article img {
  max-width: 100%; height: auto; display: block; margin: 16px auto;
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(15,23,42,.07);
}
article ul, article ol { padding-left: 26px; margin: 10px 0; }
article li { margin: 4px 0; }
article li > ul, article li > ol { margin: 4px 0; }
article hr { border: 0; border-top: 1px solid var(--border); margin: 30px 0; }
article strong { font-weight: 650; }

/* 引用块(含 ⚠️ 注意) */
article blockquote {
  margin: 16px 0; padding: 12px 16px; border-radius: 0 var(--radius) var(--radius) 0;
  border-left: 3.5px solid var(--primary); background: var(--primary-soft); color: #2b3a55;
}
article blockquote p { margin: 6px 0; }

/* 行内代码 */
article code {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Courier New", monospace;
  font-size: .88em; background: var(--bg-2); border: 1px solid var(--border);
  padding: .12em .38em; border-radius: 5px;
}
/* 代码块 */
article pre {
  background: var(--code-bg); border-radius: var(--radius); padding: 14px 16px;
  overflow-x: auto; margin: 16px 0; line-height: 1.6;
}
article pre code { background: none; border: 0; padding: 0; color: #e6edf3; font-size: 13.2px; }

/* 表格 */
.table-wrap { overflow-x: auto; margin: 16px 0; border: 1px solid var(--border); border-radius: var(--radius); }
article table { border-collapse: collapse; width: 100%; font-size: 14px; line-height: 1.6; }
article th, article td { padding: 9px 13px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
article thead th { background: var(--bg-2); font-weight: 650; white-space: nowrap; }
article tbody tr:last-child td { border-bottom: 0; }
article tbody tr:nth-child(even) { background: #fafbfd; }

/* ===== 上一篇/下一篇 ===== */
.pager { display: flex; gap: 14px; margin-top: 46px; padding-top: 22px; border-top: 1px solid var(--border); }
.pager-item {
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px;
  padding: 13px 16px; border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); transition: border .15s, box-shadow .15s;
}
.pager-item:hover { text-decoration: none; border-color: var(--primary); box-shadow: 0 4px 14px rgba(37,99,235,.12); }
.pager-item span { font-size: 12px; color: var(--text-2); }
.pager-item strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pager-item.next { text-align: right; margin-left: auto; }
.pager-item.empty { visibility: hidden; }

/* ===== 移动端 ===== */
@media (max-width: 1200px) { .page-toc { display: none; } }
@media (max-width: 900px) {
  .menu-btn { display: inline-flex; }
  .sidebar {
    position: fixed; left: 0; top: var(--topbar-h); z-index: 40;
    transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: none; width: min(300px, 84vw);
  }
  body.sidebar-open .sidebar { transform: translateX(0); box-shadow: 12px 0 32px rgba(15,23,42,.12); }
  .sidebar-backdrop {
    display: block; position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 30;
    background: rgba(15,23,42,.4); opacity: 0; pointer-events: none; transition: opacity .2s;
  }
  body.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
  .content { padding: 24px 18px 48px; }
  article h1 { font-size: 23px; }
  article h2 { font-size: 19px; }
}

@media print {
  .topbar, .sidebar, .sidebar-backdrop, .page-toc, .pager, .search { display: none !important; }
  .layout { padding-top: 0; display: block; }
  .content { max-width: none; padding: 0; }
}

/* === hljs === */
pre code.hljs {
  display: block;
  overflow-x: auto;
  padding: 1em
}
code.hljs {
  padding: 3px 5px
}
/*!
  Theme: GitHub Dark
  Description: Dark theme as seen on github.com
  Author: github.com
  Maintainer: @Hirse
  Updated: 2021-05-15

  Outdated base version: https://github.com/primer/github-syntax-dark
  Current colors taken from GitHub's CSS
*/
.hljs {
  color: #c9d1d9;
  background: #0d1117
}
.hljs-doctag,
.hljs-keyword,
.hljs-meta .hljs-keyword,
.hljs-template-tag,
.hljs-template-variable,
.hljs-type,
.hljs-variable.language_ {
  /* prettylights-syntax-keyword */
  color: #ff7b72
}
.hljs-title,
.hljs-title.class_,
.hljs-title.class_.inherited__,
.hljs-title.function_ {
  /* prettylights-syntax-entity */
  color: #d2a8ff
}
.hljs-attr,
.hljs-attribute,
.hljs-literal,
.hljs-meta,
.hljs-number,
.hljs-operator,
.hljs-variable,
.hljs-selector-attr,
.hljs-selector-class,
.hljs-selector-id {
  /* prettylights-syntax-constant */
  color: #79c0ff
}
.hljs-regexp,
.hljs-string,
.hljs-meta .hljs-string {
  /* prettylights-syntax-string */
  color: #a5d6ff
}
.hljs-built_in,
.hljs-symbol {
  /* prettylights-syntax-variable */
  color: #ffa657
}
.hljs-comment,
.hljs-code,
.hljs-formula {
  /* prettylights-syntax-comment */
  color: #8b949e
}
.hljs-name,
.hljs-quote,
.hljs-selector-tag,
.hljs-selector-pseudo {
  /* prettylights-syntax-entity-tag */
  color: #7ee787
}
.hljs-subst {
  /* prettylights-syntax-storage-modifier-import */
  color: #c9d1d9
}
.hljs-section {
  /* prettylights-syntax-markup-heading */
  color: #1f6feb;
  font-weight: bold
}
.hljs-bullet {
  /* prettylights-syntax-markup-list */
  color: #f2cc60
}
.hljs-emphasis {
  /* prettylights-syntax-markup-italic */
  color: #c9d1d9;
  font-style: italic
}
.hljs-strong {
  /* prettylights-syntax-markup-bold */
  color: #c9d1d9;
  font-weight: bold
}
.hljs-addition {
  /* prettylights-syntax-markup-inserted */
  color: #aff5b4;
  background-color: #033a16
}
.hljs-deletion {
  /* prettylights-syntax-markup-deleted */
  color: #ffdcd7;
  background-color: #67060c
}
.hljs-char.escape_,
.hljs-link,
.hljs-params,
.hljs-property,
.hljs-punctuation,
.hljs-tag {
  /* purposely ignored */
  
}