:root {
  --bg: #ffffff;
  --bg-soft: #f6f8fb;
  --panel: #ffffff;
  --border: #e4e8ef;
  --text: #111827;
  --muted: #5b6577;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --accent-text: #ffffff;
  --logo-bar: #111827;
  --code-bg: #ffffff;
  --code-head: #f3f5f9;
  --code-text: #080808;
  --code-border: #dfe3ea;
  --tk-k: #0033b3;
  --tk-s: #067d17;
  --tk-n: #1750eb;
  --tk-c: #8c8c8c;
  --tk-a: #9e880d;
  --tk-d: #00627a;
  --tk-u: #871094;
  --tk-t: #080808;
  --inline-code-bg: #eef2f8;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
  --topbar-h: 64px;
  --banner-h: 0px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

[data-theme="dark"] {
  --bg: #0b0e14;
  --bg-soft: #10141c;
  --panel: #12161f;
  --border: #1e2430;
  --text: #e7eaf1;
  --muted: #98a2b6;
  --accent: #4d8dff;
  --accent-soft: rgba(77, 141, 255, 0.14);
  --accent-text: #06101f;
  --logo-bar: #ffffff;
  --code-bg: #1e1f22;
  --code-head: #27282c;
  --code-text: #bcbec4;
  --code-border: #2e3036;
  --tk-k: #cf8e6d;
  --tk-s: #6aab73;
  --tk-n: #2aacb8;
  --tk-c: #7a7e85;
  --tk-a: #b3ae60;
  --tk-d: #56a8f5;
  --tk-u: #c77dbb;
  --tk-t: #bcbec4;
  --inline-code-bg: #1a2030;
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; scrollbar-color: var(--border) transparent; }
.code-block pre code, .code-block pre { font-variant-ligatures: none; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--topbar-h) + var(--banner-h) + 18px); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; cursor: pointer; }
kbd {
  font-family: var(--mono);
  font-size: 11px;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--muted);
  background: var(--bg-soft);
}

.banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 42px;
  padding: 8px 44px 8px 16px;
  background: var(--accent-soft);
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  position: relative;
  text-align: center;
}
.banner-dot { width: 8px; height: 8px; border-radius: 50%; background: #34d399; flex: none; }
.banner a { font-weight: 600; }
.banner-close {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: 0; padding: 6px; border-radius: 8px; color: var(--muted);
}
.banner-close:hover { background: var(--accent-soft); color: var(--text); }
.banner.hidden { display: none; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 24px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }
.brand:hover { text-decoration: none; }
.logo-bar { fill: var(--logo-bar); }
.icon-btn { display: none; background: none; border: 0; padding: 8px; border-radius: 10px; color: var(--text); }
.icon-btn:hover { background: var(--bg-soft); }
.search-btn {
  margin-left: 16px;
  display: flex; align-items: center; gap: 10px;
  width: min(360px, 34vw);
  height: 40px; padding: 0 12px;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 12px;
  color: var(--muted); text-align: left;
  transition: border-color .15s, box-shadow .15s;
}
.search-btn:hover { border-color: var(--accent); }
.search-label { flex: 1; font-size: 14px; }
.top-links { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.btn {
  display: inline-flex; align-items: center; height: 38px; padding: 0 16px;
  border: 1px solid var(--border); border-radius: 11px;
  color: var(--text); font-size: 14px; font-weight: 600; background: var(--panel);
  transition: transform .12s, border-color .15s, background .15s;
}
.btn:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }

.shell {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  max-width: 1560px;
  margin: 0 auto;
}
.sidebar {
  position: sticky; top: calc(var(--topbar-h));
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 22px 14px 40px 24px;
  border-right: 1px solid var(--border);
  scrollbar-width: thin;
}
.nav-list { list-style: none; margin: 0; padding: 0; }
.nav-list .nav-list { margin-left: 12px; padding-left: 10px; border-left: 1px solid var(--border); }
.nav-item {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  padding: 7px 12px; margin: 1px 0;
  border-radius: 10px; color: var(--muted); font-size: 14.5px; line-height: 1.35;
}
.nav-item a { color: inherit; flex: 1; }
a.nav-item:hover, summary.nav-item:hover { background: var(--bg-soft); color: var(--text); text-decoration: none; }
.nav-item.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.nav-group summary { list-style: none; cursor: pointer; }
.nav-group summary::-webkit-details-marker { display: none; }
.nav-group summary a:hover { text-decoration: none; }
.chev { transition: transform .15s; color: var(--muted); flex: none; }
details[open] > summary .chev { transform: rotate(90deg); }

.content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 230px;
  gap: 40px;
  padding: 36px 40px 80px 56px;
  min-width: 0;
}
.doc { min-width: 0; max-width: 820px; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.crumbs a { color: var(--accent); }
.crumbs .sep { margin: 0 8px; color: var(--border); }
.doc-title { font-size: 2.35rem; line-height: 1.15; letter-spacing: -0.025em; margin: 0 0 22px; font-weight: 800; }

.prose { font-size: 16px; }
.prose > :first-child { margin-top: 0; }
.prose p { margin: 0 0 1.05em; color: color-mix(in srgb, var(--text) 92%, var(--muted)); }
.prose h2, .prose h3, .prose h4 { position: relative; line-height: 1.25; letter-spacing: -0.015em; font-weight: 700; }
.prose h2 { font-size: 1.65rem; margin: 2.2em 0 0.7em; padding-bottom: .35em; border-bottom: 1px solid var(--border); }
.prose h3 { font-size: 1.25rem; margin: 1.8em 0 0.55em; }
.prose h4 { font-size: 1.05rem; margin: 1.5em 0 0.5em; }
.prose .anchor {
  position: absolute; left: -1.05em; color: var(--accent); opacity: 0; text-decoration: none; font-weight: 400;
}
.prose h2:hover .anchor, .prose h3:hover .anchor, .prose h4:hover .anchor { opacity: .7; }
.prose ul, .prose ol { padding-left: 1.5em; margin: 0 0 1.1em; }
.prose li { margin: .35em 0; }
.prose li::marker { color: var(--accent); }
.prose li > ul, .prose li > ol { margin: .3em 0 .3em; }
.prose strong { font-weight: 700; color: var(--text); }
.prose a.ext::after { content: "\2197"; font-size: .8em; margin-left: 2px; }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 2em 0; }
.prose img { max-width: 100%; border-radius: 12px; border: 1px solid var(--border); }
.prose code {
  font-family: var(--mono); font-size: .86em;
  padding: .16em .42em; border-radius: 6px;
  background: var(--inline-code-bg); border: 1px solid var(--border);
}
.prose blockquote.callout {
  margin: 1.4em 0; padding: 14px 18px; border-radius: 12px;
  background: var(--accent-soft); border: 1px solid var(--border); border-left: 4px solid var(--accent);
}
.prose blockquote.callout > :last-child { margin-bottom: 0; }
.callout-title { text-transform: uppercase; font-size: 12px; font-weight: 800; letter-spacing: .08em; color: var(--accent); margin-bottom: 4px; }
.callout-warning, .callout-danger { border-left-color: #f59e0b; background: rgba(245, 158, 11, .1); }
.callout-warning .callout-title, .callout-danger .callout-title { color: #f59e0b; }

.table-wrap { overflow-x: auto; margin: 1.3em 0; border: 1px solid var(--border); border-radius: 12px; }
.prose table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
.prose th, .prose td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.prose thead th { background: var(--bg-soft); font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.prose tbody tr:last-child td { border-bottom: 0; }
.al-center { text-align: center !important; }
.al-right { text-align: right !important; }

.code-block {
  margin: 1.3em 0; border: 1px solid var(--code-border); border-radius: 12px; overflow: hidden;
  background: var(--code-bg); box-shadow: 0 1px 0 rgba(0,0,0,.03);
}
.code-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 8px 7px 16px; background: var(--code-head); border-bottom: 1px solid var(--code-border);
  font-family: var(--mono); font-size: 12px; color: var(--muted);
}
.code-lang { letter-spacing: .04em; text-transform: uppercase; font-size: 11.5px; }
.code-block[data-lang$="-draft"] { border-color: rgba(245, 158, 11, .55); }
.code-block[data-lang$="-draft"] .code-lang { color: #f59e0b; }
.code-copy {
  display: inline-flex; align-items: center; gap: 6px; background: transparent; border: 1px solid transparent;
  border-radius: 8px; padding: 4px 9px; color: var(--muted); font-size: 12px; transition: all .15s;
}
.code-copy:hover { background: var(--accent-soft); color: var(--text); }
.code-copy.copied { color: #34d399; }
.code-block pre { margin: 0; padding: 16px 18px; overflow-x: auto; scrollbar-width: thin; }
.code-block pre code {
  font-family: var(--mono); font-size: 13.5px; line-height: 1.6; color: var(--code-text);
  background: none; border: 0; padding: 0; white-space: pre; tab-size: 4; display: block;
}
.tk-k { color: var(--tk-k); }
.tk-s { color: var(--tk-s); }
.tk-n { color: var(--tk-n); }
.tk-c { color: var(--tk-c); font-style: italic; }
.tk-a { color: var(--tk-a); }
.tk-d { color: var(--tk-d); }
.tk-u { color: var(--tk-u); font-style: italic; }
.tk-t { color: var(--tk-t); }

.updated { color: var(--muted); font-size: 13px; margin: 2.2em 0 1em; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 2.4em 0 2em; }
.pager a {
  display: flex; align-items: center; gap: 14px; padding: 16px 18px; border: 1px solid var(--border); border-radius: 14px;
  color: var(--text); font-weight: 600; transition: border-color .15s, transform .12s, background .15s;
}
.pager a:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-1px); background: var(--accent-soft); }
.pager small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; }
.pager-next { justify-content: flex-end; text-align: right; }
.pager svg { color: var(--accent); flex: none; }

.toc { position: sticky; top: calc(var(--topbar-h) + 28px); align-self: start; max-height: calc(100vh - var(--topbar-h) - 56px); overflow-y: auto; font-size: 13.5px; }
.toc-title { display: flex; align-items: center; gap: 8px; text-transform: uppercase; letter-spacing: .08em; font-size: 11.5px; font-weight: 800; color: var(--muted); margin-bottom: 10px; }
.toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border); }
.toc li a { display: block; padding: 5px 12px; margin-left: -1px; border-left: 2px solid transparent; color: var(--muted); line-height: 1.4; }
.toc li.lvl-3 a { padding-left: 26px; font-size: 13px; }
.toc li a:hover { color: var(--text); text-decoration: none; }
.toc li a.active { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }

.site-footer { margin-top: 2em; padding-top: 1.4em; border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; }
.site-footer .privacy { margin: 6px 0 0; max-width: 62ch; font-size: 12.5px; opacity: .85; }

.theme-switch {
  position: fixed; right: 20px; bottom: 20px; z-index: 30; display: flex; gap: 2px; padding: 4px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 999px; box-shadow: var(--shadow);
}
.theme-switch button { display: grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: 50%; background: none; color: var(--muted); }
.theme-switch button:hover { color: var(--text); }
[data-theme-mode="light"] .theme-switch [data-theme="light"],
[data-theme-mode="system"] .theme-switch [data-theme="system"],
[data-theme-mode="dark"] .theme-switch [data-theme="dark"] { background: var(--accent-soft); color: var(--accent); }

.search-modal { position: fixed; inset: 0; z-index: 100; display: flex; justify-content: center; align-items: flex-start; padding-top: 12vh; background: rgba(5, 8, 14, .62); backdrop-filter: blur(4px); }
.search-modal[hidden] { display: none; }
.search-panel { width: min(640px, 92vw); background: var(--panel); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.search-input-row { display: flex; align-items: center; gap: 12px; padding: 0 18px; border-bottom: 1px solid var(--border); color: var(--muted); }
.search-input-row input { flex: 1; height: 58px; border: 0; outline: 0; background: none; color: var(--text); font: inherit; font-size: 16px; }
.search-results { list-style: none; margin: 0; padding: 8px; max-height: 52vh; overflow-y: auto; }
.search-results li a { display: block; padding: 10px 12px; border-radius: 10px; color: var(--text); }
.search-results li a:hover, .search-results li a.sel { background: var(--accent-soft); text-decoration: none; }
.search-results .r-title { font-weight: 600; }
.search-results .r-snippet { color: var(--muted); font-size: 13px; line-height: 1.45; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.search-results mark { background: rgba(250, 204, 21, .3); color: inherit; border-radius: 3px; }
.search-empty { padding: 26px; text-align: center; color: var(--muted); }

.lang-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--bg-soft); }
.lang-switch a { padding: 7px 10px; font-size: 12.5px; font-weight: 700; color: var(--muted); letter-spacing: .04em; }
.lang-switch a:hover { color: var(--text); text-decoration: none; background: var(--accent-soft); }
.lang-switch a.on { background: var(--accent); color: var(--accent-text); }
.lang-note { margin: -8px 0 18px; padding: 9px 14px; border-radius: 10px; background: rgba(245, 158, 11, .1); border: 1px solid rgba(245, 158, 11, .35); font-size: 13.5px; }

.scrim { display: none; }

@media (max-width: 1180px) {
  .content { grid-template-columns: minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 900px) {
  .icon-btn { display: inline-flex; }
  .topbar { padding: 0 14px; gap: 8px; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; height: auto; width: min(320px, 86vw); z-index: 60;
    background: var(--bg); transform: translateX(-102%); transition: transform .22s ease; padding-top: 80px;
  }
  body.menu-open .sidebar { transform: none; }
  body.menu-open .scrim { display: block; position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .5); }
  .content { padding: 24px 18px 70px; }
  .search-btn { width: auto; margin-left: auto; padding: 0 10px; }
  .search-label, .search-btn kbd, .top-links .btn:not(.btn-primary) { display: none; }
  .top-links { margin-left: 0; }
  .brand-text { font-size: 15px; }
  .doc-title { font-size: 1.9rem; }
  .pager { grid-template-columns: 1fr; }
  .prose .anchor { display: none; }
}
@media (max-width: 520px) {
  .top-links .btn { display: none; }
  .theme-switch { right: 12px; bottom: 12px; }
}
@media print {
  .topbar, .sidebar, .toc, .theme-switch, .banner, .pager, .code-copy { display: none !important; }
  .shell, .content { display: block; padding: 0; }
}
