:root {
  color-scheme: light;
  --paper: #fbfaf8;
  --surface: #ffffff;
  --surface-soft: #f5f3ef;
  --ink: #18202c;
  --muted: #657080;
  --faint: #8b93a0;
  --line: #e6e2dc;
  --line-strong: #d7d1c8;
  --accent: #e94f3d;
  --accent-soft: #fff0ec;
  --code: #111827;
  --code-ink: #eef2f7;
  --green: #138a62;
  --shadow: 0 18px 50px rgb(24 32 44 / 12%);
  --topbar: 68px;
  --sidebar: 274px;
  --toc: 220px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --paper: #111419;
  --surface: #171b21;
  --surface-soft: #1d222a;
  --ink: #edf0f4;
  --muted: #a4adba;
  --faint: #7d8795;
  --line: #292f38;
  --line-strong: #39414d;
  --accent: #ff715e;
  --accent-soft: #311e1c;
  --code: #090b0e;
  --code-ink: #e8ecf1;
  --green: #51c49c;
  --shadow: 0 22px 60px rgb(0 0 0 / 36%);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--topbar) + 24px); }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.72;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration-color: color-mix(in srgb, var(--accent) 50%, transparent); text-underline-offset: 3px; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 3px; border-radius: 5px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; z-index: 100; top: 8px; left: 12px; padding: 8px 12px; background: var(--ink); color: var(--paper); transform: translateY(-150%); }
.skip-link:focus { transform: none; }

.topbar {
  position: fixed;
  z-index: 40;
  inset: 0 0 auto 0;
  height: var(--topbar);
  display: grid;
  grid-template-columns: var(--sidebar) minmax(260px, 620px) 1fr;
  align-items: center;
  gap: 24px;
  padding: 0 28px;
  background: color-mix(in srgb, var(--paper) 90%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px) saturate(150%);
}

.brand { display: inline-flex; align-items: center; gap: 10px; width: fit-content; text-decoration: none; font-weight: 760; letter-spacing: -.02em; font-size: 17px; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; color: white; background: var(--ink); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 16px; box-shadow: inset 0 0 0 1px rgb(255 255 255 / 12%); }
.brand-mark::first-letter { color: var(--accent); }
.brand-suffix { padding-left: 10px; color: var(--muted); border-left: 1px solid var(--line-strong); font-weight: 520; }

.search-trigger { height: 38px; display: flex; align-items: center; gap: 10px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 9px; color: var(--muted); background: var(--surface); cursor: pointer; box-shadow: 0 1px 2px rgb(24 32 44 / 4%); text-align: left; }
.search-trigger:hover { border-color: var(--faint); color: var(--ink); }
.search-trigger svg, .search-box svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.search-trigger span { flex: 1; }
kbd { min-width: 22px; padding: 1px 6px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; background: var(--surface-soft); color: var(--faint); font: 11px/18px ui-monospace, SFMono-Regular, Menlo, monospace; text-align: center; }
.top-actions { justify-self: end; display: flex; align-items: center; gap: 18px; }
.top-actions a { color: var(--muted); font-size: 13px; text-decoration: none; font-weight: 600; }
.top-actions a:hover { color: var(--ink); }
.icon-button, .menu-button { border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.icon-button { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; }
.icon-button:hover { background: var(--surface-soft); color: var(--ink); }
.icon-button svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.menu-button { display: none; font-size: 13px; font-weight: 700; }

.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 820px) var(--toc); justify-content: center; gap: 44px; min-height: 100vh; padding: var(--topbar) 28px 80px; }
.sidebar { position: sticky; top: var(--topbar); height: calc(100vh - var(--topbar)); padding: 28px 20px 28px 0; overflow-y: auto; border-right: 1px solid var(--line); scrollbar-width: thin; }
.version-select { display: flex; align-items: center; gap: 8px; margin: 0 0 26px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 12px; font-weight: 650; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 14%, transparent); }
.latest { margin-left: auto; color: var(--faint); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.nav-group { margin: 0 0 26px; }
.nav-group > p { margin: 0 0 8px 10px; color: var(--faint); font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.nav-group a { display: flex; align-items: center; min-height: 34px; padding: 5px 10px; border-radius: 7px; color: var(--muted); font-size: 13px; line-height: 1.25; text-decoration: none; }
.nav-group a:hover { color: var(--ink); background: var(--surface-soft); }
.nav-group a.active { color: var(--accent); background: var(--accent-soft); font-weight: 680; }
.sidebar-note { margin-top: 40px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: linear-gradient(145deg, var(--surface), var(--surface-soft)); font-size: 12px; }
.sidebar-note span { display: block; color: var(--muted); }
.sidebar-note a { display: inline-flex; gap: 6px; margin-top: 2px; color: var(--ink); font-weight: 680; text-decoration: none; }

.content { width: 100%; min-width: 0; padding: 62px 0 100px; }
.breadcrumbs { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; color: var(--faint); font-size: 12px; font-weight: 600; }
.breadcrumbs span:last-child { color: var(--accent); }
.eyebrow { color: var(--accent); font-size: 11px; font-weight: 850; letter-spacing: .11em; text-transform: uppercase; }
h1, h2, h3 { margin: 0; letter-spacing: -.035em; line-height: 1.2; scroll-margin-top: calc(var(--topbar) + 24px); }
h1 { max-width: 760px; font-size: clamp(36px, 5vw, 55px); font-weight: 790; }
h2 { margin-top: 54px; padding-top: 6px; font-size: 26px; font-weight: 750; }
h3 { margin-top: 34px; font-size: 18px; font-weight: 720; }
.lede { max-width: 720px; margin: 20px 0 34px; color: var(--muted); font-size: 18px; line-height: 1.68; }
.content p, .content ul, .content ol, .content table { max-width: 740px; }
.content p { margin: 15px 0; }
.content ul, .content ol { padding-left: 24px; }
.content li { padding-left: 3px; margin: 7px 0; }
.content strong { font-weight: 720; }
.content code:not(pre code) { padding: 2px 6px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface-soft); color: color-mix(in srgb, var(--ink) 85%, var(--accent)); font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }
.content hr { margin: 48px 0; border: 0; border-top: 1px solid var(--line); }

.quick-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 32px 0 10px; }
.quick-card { position: relative; min-height: 142px; padding: 20px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); text-decoration: none; transition: border-color .16s ease, transform .16s ease, box-shadow .16s ease; }
.quick-card:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); box-shadow: 0 12px 28px rgb(24 32 44 / 8%); }
.quick-card .card-icon { display: grid; place-items: center; width: 31px; height: 31px; margin-bottom: 16px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font: 700 14px ui-monospace, SFMono-Regular, Menlo, monospace; }
.quick-card strong { display: block; margin-bottom: 3px; font-size: 14px; }
.quick-card span { color: var(--muted); font-size: 12px; line-height: 1.5; }
.quick-card::after { content: "→"; position: absolute; top: 18px; right: 18px; color: var(--faint); }

.callout { max-width: 740px; margin: 26px 0; padding: 16px 18px 16px 19px; border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 8px; background: color-mix(in srgb, var(--accent-soft) 60%, var(--surface)); }
.callout strong { display: block; margin-bottom: 2px; font-size: 13px; }
.callout p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.callout.tip { border-left-color: var(--green); background: color-mix(in srgb, var(--green) 7%, var(--surface)); }
.callout.warning { border-left-color: #e6a036; background: color-mix(in srgb, #e6a036 8%, var(--surface)); }

.code-block { position: relative; max-width: 760px; margin: 24px 0; overflow: hidden; border: 1px solid color-mix(in srgb, var(--code) 70%, white); border-radius: 11px; background: var(--code); box-shadow: 0 10px 28px rgb(0 0 0 / 8%); }
.code-label { display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 13px; border-bottom: 1px solid rgb(255 255 255 / 8%); color: #8f9baa; font: 10px ui-monospace, SFMono-Regular, Menlo, monospace; text-transform: uppercase; letter-spacing: .08em; }
.code-label::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 10px 0 #e6a036, 20px 0 #4caf7d; margin-right: 20px; }
.code-block pre { margin: 0; padding: 17px 18px 20px; color: var(--code-ink); overflow-x: auto; font: 12px/1.7 ui-monospace, SFMono-Regular, Menlo, monospace; tab-size: 2; }
.copy-code { position: absolute; top: 6px; right: 7px; padding: 3px 8px; border: 1px solid rgb(255 255 255 / 12%); border-radius: 5px; background: rgb(255 255 255 / 6%); color: #aeb7c4; font-size: 10px; cursor: pointer; }
.copy-code:hover { color: white; background: rgb(255 255 255 / 11%); }

.steps { max-width: 740px; margin: 28px 0; counter-reset: step; }
.step { position: relative; min-height: 80px; padding: 0 0 28px 50px; counter-increment: step; }
.step:not(:last-child)::before { content: ""; position: absolute; left: 17px; top: 35px; bottom: 0; width: 1px; background: var(--line-strong); }
.step::after { content: counter(step); position: absolute; left: 0; top: -2px; display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--line-strong); border-radius: 50%; background: var(--surface); color: var(--accent); font: 700 12px ui-monospace, SFMono-Regular, Menlo, monospace; }
.step h3 { margin: 0 0 5px; font-size: 15px; letter-spacing: -.01em; }
.step p { margin: 0; color: var(--muted); font-size: 13px; }

.table-wrap { max-width: 760px; margin: 24px 0; overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.content table { width: 100%; border-collapse: collapse; font-size: 13px; }
.content th, .content td { padding: 11px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.content th { background: var(--surface-soft); color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .06em; }
.content tr:last-child td { border-bottom: 0; }
.key-row { display: flex; flex-wrap: wrap; gap: 8px; }

.page-links { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 64px; padding-top: 24px; border-top: 1px solid var(--line); }
.page-link { padding: 14px 16px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); text-decoration: none; }
.page-link.next { text-align: right; }
.page-link small { display: block; color: var(--faint); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.page-link span { color: var(--ink); font-size: 13px; font-weight: 680; }
.page-footer { margin-top: 30px; color: var(--faint); font-size: 11px; }

.toc { position: sticky; top: var(--topbar); height: fit-content; max-height: calc(100vh - var(--topbar)); padding: 63px 0 28px; overflow-y: auto; }
.toc > p { margin: 0 0 10px; color: var(--ink); font-size: 11px; font-weight: 750; }
.toc a { display: block; padding: 5px 0 5px 12px; border-left: 1px solid var(--line); color: var(--faint); font-size: 11px; line-height: 1.45; text-decoration: none; }
.toc a:hover, .toc a.active { color: var(--accent); border-left-color: var(--accent); }
.toc a.depth-3 { padding-left: 24px; }

.search-dialog { width: min(650px, calc(100vw - 32px)); max-height: min(620px, calc(100vh - 60px)); margin-top: 12vh; padding: 0; border: 1px solid var(--line-strong); border-radius: 14px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.search-dialog::backdrop { background: rgb(12 16 22 / 46%); backdrop-filter: blur(3px); }
.search-box { display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 10px; padding: 13px 15px; border-bottom: 1px solid var(--line); color: var(--muted); }
.search-box input { min-width: 0; padding: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 16px; }
.search-results { max-height: 430px; overflow-y: auto; padding: 8px; }
.search-result { display: block; width: 100%; padding: 11px 12px; border: 0; border-radius: 8px; background: transparent; color: var(--ink); text-align: left; cursor: pointer; }
.search-result:hover, .search-result.selected { background: var(--surface-soft); }
.search-result strong { display: block; font-size: 13px; }
.search-result span { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; line-height: 1.45; }
.search-result mark { background: var(--accent-soft); color: var(--accent); }
.empty-results { padding: 40px 20px; color: var(--muted); text-align: center; font-size: 13px; }
.search-hint { display: flex; gap: 18px; margin: 0; padding: 10px 14px; border-top: 1px solid var(--line); color: var(--faint); font-size: 10px; }
.search-hint span { display: flex; align-items: center; gap: 4px; }
.scrim { display: none; }

@media (max-width: 1120px) {
  :root { --sidebar: 246px; }
  .shell { grid-template-columns: var(--sidebar) minmax(0, 780px); gap: 36px; }
  .toc { display: none; }
  .topbar { grid-template-columns: var(--sidebar) minmax(240px, 560px) 1fr; }
}

@media (max-width: 760px) {
  :root { --topbar: 60px; }
  .topbar { grid-template-columns: 1fr auto; gap: 12px; padding: 0 16px; }
  .brand-suffix, .top-actions > a, .top-actions .icon-button { display: none; }
  .search-trigger { grid-column: 1 / -1; position: fixed; z-index: 30; top: 70px; left: 16px; right: 16px; }
  .menu-button { display: block; }
  .shell { display: block; padding: calc(var(--topbar) + 56px) 20px 50px; }
  .sidebar { position: fixed; z-index: 35; top: var(--topbar); left: 0; bottom: 0; width: min(310px, 86vw); height: auto; padding: 24px 18px; background: var(--paper); transform: translateX(-102%); transition: transform .2s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .scrim { position: fixed; z-index: 34; inset: var(--topbar) 0 0; background: rgb(12 16 22 / 42%); }
  .scrim.open { display: block; }
  .content { padding: 34px 0 70px; }
  h1 { font-size: 38px; }
  h2 { margin-top: 44px; font-size: 23px; }
  .lede { font-size: 16px; }
  .quick-grid { grid-template-columns: 1fr; }
  .quick-card { min-height: 125px; }
  .page-links { grid-template-columns: 1fr; }
}

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

@media print {
  .topbar, .sidebar, .toc, .page-links { display: none; }
  .shell { display: block; padding: 0; }
  .content { max-width: 780px; margin: auto; padding: 30px 0; }
  .code-block { break-inside: avoid; }
}
