
:root {
  --bg: #ffffff;
  --bg-alt: #fafbfc;
  --bg-elev: #ffffff;
  --text: #0c111d;
  --text-mute: #475467;
  --text-soft: #667085;
  --border: #eaecf0;
  --border-soft: #f2f4f7;
  --accent: #0060A8;
  --accent-soft: rgba(0,96,168,.10);
  --accent-text: #0060A8;
  --code-bg: #f6f7f9;
  --code-text: #0c111d;
  --kbd-bg: #f2f4f7;
  --warning-bg: #fffaeb;
  --warning-border: #fec84b;
  --warning-text: #93370d;
  --note-bg: #eff8ff;
  --note-border: #2e90fa;
  --note-text: #175cd3;
  --shadow-sm: 0 1px 2px rgba(16,24,40,.04);
  --shadow-md: 0 4px 12px rgba(16,24,40,.06);
  --radius: 8px;
  --content-max: 760px;
}
[data-theme="dark"] {
  --bg: #0b0d12;
  --bg-alt: #0f1117;
  --bg-elev: #14171e;
  --text: #e6e8ec;
  --text-mute: #98a2b3;
  --text-soft: #667085;
  --border: #1f232b;
  --border-soft: #181b21;
  --accent: #4D9FFF;
  --accent-soft: rgba(77,159,255,.14);
  --accent-text: #86BDFF;
  --code-bg: #14171e;
  --code-text: #e6e8ec;
  --kbd-bg: #1f232b;
  --warning-bg: rgba(254,200,75,.07);
  --warning-border: #b9881f;
  --warning-text: #f9d77b;
  --note-bg: rgba(46,144,250,.08);
  --note-border: #2e90fa;
  --note-text: #8ec1ff;
}

* { box-sizing: border-box; }
html, body { padding: 0; margin: 0; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,.85);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
[data-theme="dark"] .site-header { background: rgba(11,13,18,.85); }
.header-inner {
  max-width: 1400px; margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; gap: 24px; height: 60px;
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); font-weight: 600; font-size: 15px; }
.brand-lockup { height: 26px; width: auto; display: block; }
[data-theme="dark"] .brand-lockup { filter: brightness(1.4) saturate(0.85); }
.brand-divider { color: var(--text-soft); font-weight: 400; font-size: 18px; opacity: .6; }
.brand-tag { color: var(--text-mute); font-weight: 500; font-size: 14px; letter-spacing: .01em; }
.brand:hover { text-decoration: none; }
.brand:hover .brand-tag { color: var(--text); }
.search {
  flex: 1; max-width: 480px; position: relative;
  display: flex; align-items: center; gap: 6px;
  background: var(--bg-alt); border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 10px; color: var(--text-mute);
  transition: border-color .12s, background .12s;
}
.search:focus-within {
  border-color: var(--accent); background: var(--bg);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.search input {
  flex: 1; border: none; outline: none; background: transparent;
  font: inherit; color: var(--text); padding: 1px 2px;
}
.search input::placeholder { color: var(--text-mute); }
.search-kbd {
  font: 500 11px 'JetBrains Mono', monospace;
  color: var(--text-mute); background: var(--kbd-bg);
  padding: 2px 6px; border-radius: 4px; border: 1px solid var(--border-soft);
}
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow-md);
  max-height: 60vh; overflow-y: auto;
  z-index: 100;
}
.search-results[hidden] { display: none; }
.search-result {
  display: block; padding: 10px 14px; color: var(--text);
  border-bottom: 1px solid var(--border-soft);
}
.search-result:last-child { border-bottom: none; }
.search-result:hover, .search-result.active { background: var(--bg-alt); text-decoration: none; }
.search-result strong { font-weight: 600; font-size: 14px; display: block; margin-bottom: 2px; }
.search-result span { color: var(--text-mute); font-size: 12.5px; line-height: 1.5; }
.search-result mark { background: var(--accent-soft); color: var(--accent-text); padding: 0 2px; border-radius: 2px; }
.search-empty { padding: 18px; color: var(--text-mute); font-size: 13px; }

.header-actions { display: flex; align-items: center; gap: 16px; color: var(--text-mute); }
.header-actions a { color: var(--text-mute); font-size: 14px; }
.header-actions a:hover { color: var(--text); text-decoration: none; }
#theme-toggle, #mobile-nav-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  background: transparent; border: 1px solid var(--border); border-radius: 6px;
  color: var(--text-mute); cursor: pointer; padding: 0;
}
#theme-toggle:hover, #mobile-nav-toggle:hover { color: var(--text); border-color: var(--text-mute); }
[data-theme="light"] #theme-toggle .icon-moon { display: none; }
[data-theme="dark"]  #theme-toggle .icon-sun { display: none; }
#mobile-nav-toggle { display: none; }

/* ---------- Layout ---------- */
.layout {
  max-width: 1400px; margin: 0 auto;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 240px;
  gap: 48px;
  padding: 0 24px;
}
.sidebar {
  padding: 32px 0 64px;
  position: sticky; top: 60px; align-self: start;
  height: calc(100vh - 60px);
  overflow-y: auto;
  border-right: 1px solid var(--border-soft);
  padding-right: 16px;
}
.content { padding: 32px 0 64px; min-width: 0; max-width: var(--content-max); }
.toc-rail {
  padding: 32px 0;
  position: sticky; top: 60px; align-self: start;
  height: calc(100vh - 60px);
}
.toc-sticky { padding-left: 16px; border-left: 1px solid var(--border-soft); }

/* ---------- Nav ---------- */
.nav-tree { font-size: 14px; }
.nav-section { margin-bottom: 22px; }
.nav-section-title {
  text-transform: uppercase; letter-spacing: .04em;
  font-size: 11px; font-weight: 600; color: var(--text-soft);
  padding: 0 10px; margin-bottom: 6px;
}
.nav-list { list-style: none; padding: 0; margin: 0; }
.nav-item {
  display: block; padding: 5px 10px; border-radius: 6px;
  color: var(--text-mute); line-height: 1.45;
}
.nav-item:hover { color: var(--text); background: var(--bg-alt); text-decoration: none; }
.nav-item.active {
  color: var(--accent-text); background: var(--accent-soft); font-weight: 500;
}

/* ---------- TOC ---------- */
.toc-rail h4 {
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-soft); margin: 0 0 10px; font-weight: 600;
}
.toc-list { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.toc-list li { line-height: 1.5; padding: 4px 0; }
.toc-list a { color: var(--text-mute); }
.toc-list a:hover { color: var(--text); text-decoration: none; }
.toc-list a.active { color: var(--accent-text); }
.toc-h3 { padding-left: 12px; }
.toc-empty { color: var(--text-soft); font-size: 12px; }

/* ---------- Content typography ---------- */
.content article > .page-eyebrow {
  display: inline-block; font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--accent-text); background: var(--accent-soft);
  padding: 3px 10px; border-radius: 999px; margin-bottom: 14px;
}
.content h1 {
  font-size: 36px; line-height: 1.18; font-weight: 700;
  letter-spacing: -.02em; margin: 0 0 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.content h2 {
  font-size: 22px; line-height: 1.3; font-weight: 600;
  letter-spacing: -.015em; margin: 48px 0 12px;
  padding-top: 12px;
}
.content h3 { font-size: 17px; font-weight: 600; margin: 28px 0 10px; }
.content h4 { font-size: 15px; font-weight: 600; margin: 22px 0 8px; }
.content p { margin: 0 0 14px; }
.content ul, .content ol { margin: 0 0 16px; padding-left: 24px; }
.content li { margin: 6px 0; line-height: 1.65; }
.content li > p { margin: 0 0 8px; }
.content li > p:last-child { margin-bottom: 0; }
.content ul { list-style: none; }
.content ul > li { position: relative; padding-left: 4px; }
.content ul > li::before {
  content: ''; position: absolute; left: -18px; top: 0.7em;
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--text-soft);
}
.content ul ul > li::before {
  width: 5px; height: 1px; border-radius: 0; top: 0.85em;
  background: var(--border);
}
.content ol { list-style: none; counter-reset: ol-counter; }
.content ol > li { position: relative; padding-left: 6px; counter-increment: ol-counter; }
.content ol > li::before {
  content: counter(ol-counter) ".";
  position: absolute; left: -22px; top: 0;
  color: var(--text-soft); font-variant-numeric: tabular-nums;
  font-weight: 500;
  min-width: 18px; text-align: right;
}
.content strong { color: var(--text); font-weight: 600; }
.content em { font-style: italic; }
.content blockquote {
  margin: 16px 0; padding: 10px 16px;
  border-left: 3px solid var(--border); color: var(--text-mute);
  background: var(--bg-alt); border-radius: 0 6px 6px 0;
}
.content hr { border: none; border-top: 1px solid var(--border); margin: 32px 0; }

/* Anchor links on headings */
.content :is(h2,h3,h4) { scroll-margin-top: 80px; }

/* ---------- Images ---------- */
.content img {
  max-width: 100%; height: auto; border-radius: 6px;
  border: 1px solid var(--border-soft); margin: 14px 0;
  background: var(--bg-alt);
}

/* ---------- Tables ---------- */
.content table {
  width: 100%; border-collapse: collapse; margin: 20px 0;
  font-size: 14px; display: block; overflow-x: auto;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg);
}
.content thead { background: var(--bg-alt); }
.content thead th {
  text-transform: uppercase; letter-spacing: .04em;
  font-size: 11.5px; font-weight: 600;
  color: var(--text-soft);
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
.content tbody tr { border-bottom: 1px solid var(--border-soft); }
.content tbody tr:last-child { border-bottom: none; }
.content tbody tr:hover { background: var(--bg-alt); }
.content th, .content td {
  text-align: left; padding: 11px 16px;
  vertical-align: top;
}
.content td { color: var(--text); }
.content td code {
  font-size: 12px; white-space: nowrap;
}

/* ---------- Code ---------- */
.content code {
  font: 500 13px/1.6 'JetBrains Mono', ui-monospace, SF Mono, Menlo, Monaco, monospace;
  background: var(--code-bg); padding: 1px 5px; border-radius: 4px;
  border: 1px solid var(--border-soft); color: var(--code-text);
  font-size: 12.5px;
  word-break: break-word;
}
.content pre {
  margin: 16px 0; padding: 16px 18px;
  background: var(--code-bg); border: 1px solid var(--border);
  border-radius: 8px; overflow-x: auto;
}
.content pre code {
  background: transparent; border: none; padding: 0; font-size: 13px;
  display: block; line-height: 1.6;
}
/* CodeHilite tokens (subset) - light */
.codehilite .k, .codehilite .kd, .codehilite .kn, .codehilite .kr { color: #b91c63; }
.codehilite .s, .codehilite .s1, .codehilite .s2, .codehilite .sb { color: #1d6ae5; }
.codehilite .c, .codehilite .c1, .codehilite .cm { color: #98a2b3; font-style: italic; }
.codehilite .nf, .codehilite .nb, .codehilite .nc { color: #b54708; }
.codehilite .mi, .codehilite .mf, .codehilite .il { color: #027a48; }
.codehilite .o, .codehilite .ow { color: #344054; }
[data-theme="dark"] .codehilite .k, [data-theme="dark"] .codehilite .kd, [data-theme="dark"] .codehilite .kn, [data-theme="dark"] .codehilite .kr { color: #ff7eb6; }
[data-theme="dark"] .codehilite .s, [data-theme="dark"] .codehilite .s1, [data-theme="dark"] .codehilite .s2 { color: #82cfff; }
[data-theme="dark"] .codehilite .c, [data-theme="dark"] .codehilite .c1, [data-theme="dark"] .codehilite .cm { color: #667085; }
[data-theme="dark"] .codehilite .nf, [data-theme="dark"] .codehilite .nb, [data-theme="dark"] .codehilite .nc { color: #f4a677; }
[data-theme="dark"] .codehilite .mi, [data-theme="dark"] .codehilite .mf, [data-theme="dark"] .codehilite .il { color: #7ee0a0; }
[data-theme="dark"] .codehilite .o, [data-theme="dark"] .codehilite .ow { color: #c2c8d0; }

/* ---------- Callouts ---------- */
.callout {
  position: relative;
  margin: 18px 0; padding: 14px 16px 14px 48px;
  border-radius: 8px; border: 1px solid;
  font-size: 14.5px;
}
.callout::before {
  content: ''; position: absolute; left: 14px; top: 14px;
  width: 22px; height: 22px;
  background-repeat: no-repeat; background-position: center;
  background-size: 22px 22px;
  opacity: 0.92;
}
.callout p:last-child { margin-bottom: 0; }
.callout-warning {
  background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning-text);
}
.callout-warning::before {
  /* triangle-exclamation icon, currentColor-ish via stroke=%23-warning-text */
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2393370d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M12 9v4'/><path d='M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z'/><circle cx='12' cy='17' r='.5' fill='%2393370d'/></svg>");
}
[data-theme="dark"] .callout-warning::before {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23f9d77b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M12 9v4'/><path d='M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z'/><circle cx='12' cy='17' r='.5' fill='%23f9d77b'/></svg>");
}
.callout-warning a { color: var(--warning-text); text-decoration: underline; }
.callout-highlight, .callout-note, .callout-info {
  background: var(--note-bg); border-color: var(--note-border); color: var(--note-text);
}
.callout-highlight::before, .callout-note::before, .callout-info::before {
  /* info circle icon */
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23175cd3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='12' cy='12' r='10'/><path d='M12 16v-4'/><circle cx='12' cy='8' r='.5' fill='%23175cd3'/></svg>");
}
[data-theme="dark"] .callout-highlight::before, [data-theme="dark"] .callout-note::before, [data-theme="dark"] .callout-info::before {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238ec1ff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='12' cy='12' r='10'/><path d='M12 16v-4'/><circle cx='12' cy='8' r='.5' fill='%238ec1ff'/></svg>");
}
.callout-highlight a, .callout-note a, .callout-info a { color: var(--note-text); text-decoration: underline; }

/* ---------- Footer ---------- */
.page-footer {
  margin-top: 80px; padding-top: 32px; border-top: 1px solid var(--border);
  color: var(--text-soft); font-size: 13px;
}
.footer-support {
  margin-bottom: 22px; padding: 16px 18px;
  background: var(--bg-alt); border: 1px solid var(--border-soft); border-radius: 8px;
}
.footer-support h4 {
  margin: 0 0 4px; font-size: 13px; font-weight: 600; color: var(--text);
  text-transform: uppercase; letter-spacing: .04em;
}
.footer-support p { margin: 0; font-size: 14px; color: var(--text-mute); line-height: 1.6; }
.footer-support a { color: var(--accent-text); }
.footer-meta { margin: 0; }
.footer-meta a { color: var(--text-mute); }
.footer-meta a:hover { color: var(--text); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .layout { grid-template-columns: 240px minmax(0, 1fr); gap: 36px; }
  .toc-rail { display: none; }
}
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; gap: 0; padding: 0 18px; }
  .sidebar {
    position: fixed; left: 0; top: 60px;
    width: 280px; height: calc(100vh - 60px);
    background: var(--bg); border-right: 1px solid var(--border);
    transform: translateX(-100%); transition: transform .2s ease;
    z-index: 40; padding: 24px 16px;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop {
    position: fixed; inset: 60px 0 0 0; background: rgba(0,0,0,.4);
    z-index: 35; opacity: 0; pointer-events: none; transition: opacity .2s;
  }
  .sidebar-backdrop.show { opacity: 1; pointer-events: auto; }
  #mobile-nav-toggle { display: inline-flex; }
  .header-actions a { display: none; }
  .content { padding: 20px 0 48px; }
  .content h1 { font-size: 28px; }
  .content h2 { font-size: 20px; margin-top: 36px; }
}
@media (max-width: 480px) {
  .brand span { display: none; }
  .search-kbd { display: none; }
}
