:root {
  color-scheme: dark;
  --bg: #0b0f14;
  --bg-raised: #10161d;
  --bg-soft: #131a22;
  --bg-code: #080c11;
  --line: #202a35;
  --line-soft: #18212b;
  --text: #e5eaf0;
  --text-strong: #f5f7fa;
  --muted: #98a4b3;
  --quiet: #687586;
  --accent: #5dd6e8;
  --accent-soft: rgba(93, 214, 232, .1);
  --accent-line: rgba(93, 214, 232, .32);
  --warning: #e5b567;
  --success: #79d29b;
  --sidebar: 276px;
  --toc: 224px;
  --header: 58px;
  --content: 820px;
  font-family: "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; scroll-padding-top: calc(var(--header) + 24px); }
body { min-height: 100vh; margin: 0; color: var(--text); background: var(--bg); font-size: 15px; line-height: 1.65; }
body.nav-open { overflow: hidden; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
svg { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }

::selection { color: var(--text-strong); background: rgba(93, 214, 232, .24); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { border: 3px solid transparent; border-radius: 999px; background: #364352; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

.skip-link {
  position: fixed;
  z-index: 100;
  top: 10px;
  left: 10px;
  transform: translateY(-150%);
  padding: 9px 13px;
  border: 1px solid var(--accent);
  border-radius: 7px;
  color: #071014;
  background: var(--accent);
  text-decoration: none;
}
.skip-link:focus { transform: none; }

.sidebar {
  position: fixed;
  z-index: 40;
  inset: 0 auto 0 0;
  width: var(--sidebar);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: #0d1218;
}
.sidebar-head {
  height: var(--header);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  padding: 0 18px;
  border-bottom: 1px solid var(--line-soft);
}
.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-strong);
  font-weight: 650;
  letter-spacing: -.01em;
  text-decoration: none;
}
.brand img { width: 27px; height: 27px; border-radius: 6px; }
.brand small {
  margin-left: 2px;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--quiet);
  font: 500 10px/1.35 "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
}
.sidebar-close { display: none; margin-left: auto; }

.doc-nav {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  padding: 18px 12px 24px;
}
.nav-group + .nav-group { margin-top: 22px; }
.nav-group > p,
.sidebar-resources > p {
  margin: 0 10px 7px;
  color: var(--quiet);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .045em;
  text-transform: uppercase;
}
.nav-group a,
.sidebar-resources a {
  min-height: 35px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.35;
  text-decoration: none;
}
.nav-group a:hover,
.sidebar-resources a:hover { color: var(--text-strong); background: rgba(255,255,255,.035); }
.nav-group a.active { color: var(--accent); background: var(--accent-soft); }
.nav-group a.active::before {
  content: "";
  width: 3px;
  height: 15px;
  margin-left: -10px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}
.sidebar-resources {
  flex: 0 0 auto;
  padding: 15px 12px 18px;
  border-top: 1px solid var(--line-soft);
}
.sidebar-resources svg { width: 16px; height: 16px; color: var(--quiet); }

.topbar {
  position: fixed;
  z-index: 30;
  top: 0;
  right: 0;
  left: var(--sidebar);
  height: var(--header);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 15, 20, .92);
  backdrop-filter: blur(12px);
}
.icon-button {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}
.icon-button:hover { color: var(--text-strong); background: var(--bg-soft); }
.icon-button svg { width: 19px; height: 19px; }
.menu-button,
.sidebar-close { display: none; }
.crumbs {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--quiet);
  font-size: 13px;
}
.crumbs svg { width: 14px; height: 14px; }
.crumbs strong {
  max-width: 260px;
  overflow: hidden;
  color: var(--muted);
  font-weight: 550;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-trigger {
  width: min(360px, 35vw);
  height: 34px;
  display: flex;
  align-items: center;
  gap: 9px;
  margin-left: auto;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--quiet);
  background: var(--bg-raised);
  cursor: pointer;
}
.search-trigger:hover { border-color: #344251; color: var(--muted); }
.search-trigger svg { width: 16px; height: 16px; }
.search-trigger span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 23px;
  min-height: 20px;
  padding: 1px 5px;
  border: 1px solid #2c3744;
  border-bottom-color: #3b4959;
  border-radius: 4px;
  color: var(--quiet);
  background: #111820;
  font: 500 10px/1 "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  white-space: nowrap;
}
.search-trigger kbd { margin-left: auto; }
.header-link {
  color: var(--muted);
  font-size: 13px;
  font-weight: 550;
  text-decoration: none;
  white-space: nowrap;
}
.header-link:hover { color: var(--accent); }

.page-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, var(--content)) var(--toc);
  justify-content: center;
  gap: 70px;
  margin-left: var(--sidebar);
  padding: calc(var(--header) + 48px) 42px 96px;
}
.content { min-width: 0; }
.doc-meta {
  min-height: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
  color: var(--quiet);
  font-size: 12px;
}
.doc-meta span { font-weight: 650; letter-spacing: .055em; text-transform: uppercase; }
.doc-meta a { color: var(--quiet); text-decoration: none; }
.doc-meta a:hover { color: var(--accent); }

.toc {
  position: sticky;
  top: calc(var(--header) + 36px);
  align-self: start;
  max-height: calc(100vh - var(--header) - 62px);
  overflow-y: auto;
  padding-left: 20px;
  border-left: 1px solid var(--line);
}
.toc > p {
  margin: 0 0 11px;
  color: var(--text);
  font-size: 12px;
  font-weight: 650;
}
.toc nav { display: grid; gap: 2px; }
.toc a {
  display: block;
  padding: 4px 0;
  color: var(--quiet);
  font-size: 12px;
  line-height: 1.45;
  text-decoration: none;
}
.toc a[data-level="3"] { padding-left: 12px; }
.toc a:hover,
.toc a.active { color: var(--accent); }

.markdown-body { color: var(--muted); overflow-wrap: anywhere; }
.markdown-body > :first-child { margin-top: 0 !important; }
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  position: relative;
  color: var(--text-strong);
  font-weight: 650;
  line-height: 1.3;
  letter-spacing: -.018em;
  scroll-margin-top: calc(var(--header) + 24px);
}
.markdown-body h1 { margin: 0 0 18px; font-size: clamp(30px, 4vw, 38px); letter-spacing: -.035em; }
.markdown-body h1 + p { margin-top: 0; color: #b5bfcb; font-size: 17px; line-height: 1.7; }
.markdown-body h2 { margin: 56px 0 17px; padding-top: 4px; font-size: 25px; }
.markdown-body h2::before {
  content: "";
  position: absolute;
  top: -24px;
  right: 0;
  left: 0;
  height: 1px;
  background: var(--line-soft);
}
.markdown-body h3 { margin: 35px 0 12px; font-size: 19px; }
.markdown-body h4 { margin: 27px 0 9px; font-size: 16px; }
.heading-anchor {
  position: absolute;
  right: 100%;
  margin-right: 8px;
  color: var(--quiet);
  font-weight: 400;
  opacity: 0;
  text-decoration: none;
}
.markdown-body :is(h2,h3,h4):hover .heading-anchor { opacity: 1; }
.markdown-body p { margin: 0 0 18px; }
.markdown-body a { color: var(--accent); text-decoration: none; }
.markdown-body a:hover { text-decoration: underline; text-underline-offset: 3px; }
.markdown-body strong { color: var(--text); font-weight: 650; }
.markdown-body hr { height: 1px; margin: 40px 0; border: 0; background: var(--line); }
.markdown-body ul,
.markdown-body ol { margin: 0 0 20px; padding-left: 24px; }
.markdown-body li { margin: 6px 0; padding-left: 3px; }
.markdown-body li::marker { color: var(--quiet); }
.markdown-body blockquote {
  margin: 24px 0;
  padding: 14px 17px;
  border-left: 3px solid var(--accent);
  border-radius: 0 7px 7px 0;
  color: #b1bbc7;
  background: var(--accent-soft);
}
.markdown-body blockquote p:last-child { margin-bottom: 0; }
.markdown-body code {
  padding: .12em .34em;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: #b8e9ef;
  background: var(--bg-soft);
  font: 500 .88em/1.45 "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
}
.code-block {
  position: relative;
  margin: 22px 0 26px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-code);
}
.code-label {
  min-height: 34px;
  display: flex;
  align-items: center;
  padding: 0 13px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--quiet);
  font: 500 10px "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  text-transform: uppercase;
}
.code-copy {
  position: absolute;
  top: 5px;
  right: 7px;
  height: 24px;
  padding: 0 8px;
  border: 0;
  border-radius: 4px;
  color: var(--quiet);
  background: transparent;
  font-size: 11px;
  cursor: pointer;
}
.code-copy:hover { color: var(--text); background: var(--bg-soft); }
.code-block pre { margin: 0; padding: 17px 18px; overflow: auto; }
.code-block pre code {
  padding: 0;
  border: 0;
  color: #cbd5df;
  background: transparent;
  font-size: 12.5px;
  line-height: 1.7;
}
.markdown-body table {
  width: 100%;
  margin: 22px 0 28px;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
}
.markdown-body th,
.markdown-body td { padding: 10px 13px; border-bottom: 1px solid var(--line-soft); text-align: left; vertical-align: top; }
.markdown-body th { color: var(--text); background: var(--bg-raised); font-size: 12px; font-weight: 650; }
.markdown-body td + td,
.markdown-body th + th { border-left: 1px solid var(--line-soft); }
.markdown-body tr:last-child td { border-bottom: 0; }
.markdown-body tbody tr:hover { background: rgba(255,255,255,.016); }

.loading-state { display: flex; align-items: center; gap: 12px; padding: 30px 0; color: var(--quiet); }
.loading-state span {
  width: 16px;
  height: 16px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.loading-state p { margin: 0; }
.error-state { padding: 22px; border: 1px solid #5d3438; border-radius: 8px; color: #e7b8bb; background: rgba(135,52,60,.1); }

.page-nav {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 64px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}
.page-nav a {
  min-height: 82px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--quiet);
  font-size: 11px;
  text-decoration: none;
}
.page-nav a:last-child { text-align: right; }
.page-nav a:hover { border-color: var(--accent-line); background: var(--accent-soft); }
.page-nav strong { margin-top: 3px; color: var(--text); font-size: 14px; font-weight: 600; }

.search-dialog {
  width: min(690px, calc(100% - 30px));
  max-height: min(720px, calc(100vh - 48px));
  padding: 0;
  overflow: hidden;
  border: 1px solid #33404e;
  border-radius: 11px;
  color: var(--text);
  background: var(--bg-raised);
  box-shadow: 0 26px 80px rgba(0,0,0,.62);
}
.search-dialog::backdrop { background: rgba(3,6,9,.72); backdrop-filter: blur(3px); }
.search-box { display: flex; flex-direction: column; max-height: inherit; }
.search-input-row {
  height: 58px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 15px;
  border-bottom: 1px solid var(--line);
}
.search-input-row svg { width: 19px; height: 19px; color: var(--quiet); }
.search-input-row input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  color: var(--text-strong);
  background: transparent;
  font-size: 15px;
}
.search-input-row input::placeholder { color: var(--quiet); }
.search-results { min-height: 240px; flex: 1; overflow-y: auto; padding: 8px; }
.search-empty { padding: 44px 28px; text-align: center; color: var(--quiet); }
.search-empty strong { display: block; margin-bottom: 7px; color: var(--muted); font-size: 14px; }
.search-empty p { margin: 0; font-size: 13px; }
.search-empty code { color: var(--accent); }
.search-result {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 18px;
  padding: 11px 12px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.search-result:hover,
.search-result.active { color: var(--text); background: var(--accent-soft); }
.search-result strong { color: var(--text); font-size: 13.5px; font-weight: 600; }
.search-result span { color: var(--quiet); font-size: 11px; }
.search-result p {
  grid-column: 1 / -1;
  margin: 0;
  overflow: hidden;
  color: var(--quiet);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-box footer {
  min-height: 39px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 13px;
  border-top: 1px solid var(--line);
  color: var(--quiet);
  font-size: 10px;
}
.search-box footer span { display: flex; align-items: center; gap: 4px; }
.search-box footer kbd { min-width: 18px; min-height: 17px; padding: 0 4px; font-size: 9px; }

.noscript {
  position: fixed;
  z-index: 200;
  inset: 20px;
  padding: 20px;
  border: 1px solid #5d3438;
  color: #e7b8bb;
  background: #1d1114;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1180px) {
  .page-shell { grid-template-columns: minmax(0, var(--content)); }
  .toc { display: none; }
}

@media (max-width: 860px) {
  :root { --sidebar: 282px; }
  .sidebar { transform: translateX(-102%); box-shadow: 24px 0 60px rgba(0,0,0,.5); transition: transform .2s ease; }
  body.nav-open .sidebar { transform: none; }
  .sidebar-close,
  .menu-button { display: inline-grid; }
  .sidebar-scrim {
    position: fixed;
    z-index: 35;
    inset: 0;
    background: rgba(0,0,0,.58);
  }
  .topbar { left: 0; padding: 0 14px; }
  .page-shell { margin-left: 0; padding-right: 28px; padding-left: 28px; }
  .crumbs span,
  .crumbs svg { display: none; }
  .search-trigger { width: 42px; margin-left: auto; justify-content: center; }
  .search-trigger span,
  .search-trigger kbd { display: none; }
}

@media (max-width: 620px) {
  .topbar { gap: 10px; }
  .header-link { display: none; }
  .page-shell { padding: calc(var(--header) + 30px) 18px 70px; }
  .markdown-body h1 { font-size: 30px; }
  .markdown-body h2 { margin-top: 46px; font-size: 23px; }
  .markdown-body table { display: block; overflow-x: auto; white-space: nowrap; }
  .page-nav { grid-template-columns: 1fr; }
  .page-nav a:last-child { text-align: left; }
  .doc-meta a { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
