:root {
  --ground: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --line: #e2e6ec;
  --line-strong: #cfd5de;
  --ink: #11151b;
  --ink-2: #4d5867;
  --ink-3: #707b89;
  --accent: #c2541a;
  --accent-dark: #9f4212;
  --accent-soft: #c2541a12;
  --accent-line: #c2541a38;
  --code: #0b0d12;
  --code-2: #121620;
  --code-line: #242a35;
  --code-ink: #e6e9ef;
  --code-muted: #8390a2;
  --ok: #12754f;
  --ok-soft: #12754f12;
  --warn: #8a5a00;
  --warn-soft: #8a5a0014;
  --shadow: 0 1px 2px rgba(15, 19, 25, .04), 0 8px 28px rgba(15, 19, 25, .07);
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", "Cascadia Code", "Roboto Mono", Consolas, monospace;
  --topbar: 64px;
  --sidebar: 268px;
}

:root[data-theme="dark"] {
  --ground: #0b0d12;
  --surface: #12151c;
  --surface-2: #1a1f28;
  --line: #252b36;
  --line-strong: #353d4a;
  --ink: #eef0f4;
  --ink-2: #a8b0bd;
  --ink-3: #7f8998;
  --accent: #ef9150;
  --accent-dark: #ffad73;
  --accent-soft: #ef91501a;
  --accent-line: #ef915045;
  --code: #080a0e;
  --code-2: #10131a;
  --code-line: #252b36;
  --ok: #47bd87;
  --ok-soft: #47bd8718;
  --warn: #e3a741;
  --warn-soft: #e3a74118;
  --shadow: 0 12px 32px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--topbar) + 24px); }
body { margin: 0; background: var(--ground); color: var(--ink); font-family: var(--sans); font-size: 15px; line-height: 1.68; }
a { color: inherit; }
button, input, select { font: inherit; }
code, kbd, pre { font-family: var(--mono); }
code { font-size: .88em; }
[hidden] { display: none !important; }
.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; left: 16px; top: -60px; padding: 10px 14px; color: #fff; background: var(--accent); border-radius: 8px; text-decoration: none; transition: top .2s; }
.skip-link:focus { top: 10px; }

.topbar { position: fixed; z-index: 30; inset: 0 0 auto 0; height: var(--topbar); display: flex; align-items: center; justify-content: space-between; padding: 0 22px; background: color-mix(in srgb, var(--surface) 94%, transparent); border-bottom: 1px solid var(--line); backdrop-filter: blur(16px); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 220px; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; color: #fff; background: linear-gradient(145deg, #da6b2d, #a33d0c); box-shadow: inset 0 1px 0 rgba(255,255,255,.3), 0 4px 12px rgba(194,84,26,.24); font-weight: 800; }
.brand-name { font-size: 18px; font-weight: 750; letter-spacing: -.02em; }
.brand-product { color: var(--ink-3); padding-left: 10px; border-left: 1px solid var(--line-strong); font-size: 14px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.version-picker select, .theme-button, .menu-button { height: 36px; color: var(--ink-2); background: var(--surface-2); border: 0; border-radius: 8px; }
.version-picker select { padding: 0 30px 0 11px; cursor: pointer; }
.theme-button { width: 36px; cursor: pointer; font-size: 18px; }
.top-link { padding: 7px 11px; color: var(--ink-2); text-decoration: none; border-radius: 8px; }
.top-link:hover, .theme-button:hover, .version-picker select:hover { color: var(--ink); background: var(--line); }
.menu-button { display: none; padding: 0 11px; gap: 7px; align-items: center; cursor: pointer; }

.sidebar { position: fixed; z-index: 20; left: 0; top: var(--topbar); bottom: 0; width: var(--sidebar); display: flex; flex-direction: column; padding: 24px 18px 18px; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--line); }
.search-wrap label { display: block; margin: 0 0 7px 2px; color: var(--ink-3); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.search-field { height: 39px; display: flex; align-items: center; gap: 7px; padding: 0 9px; background: var(--surface-2); border: 1px solid transparent; border-radius: 9px; }
.search-field:focus-within { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-field input { min-width: 0; flex: 1; color: var(--ink); background: transparent; border: 0; outline: 0; font-size: 13px; }
.search-field input::placeholder { color: var(--ink-3); }
.search-field kbd { padding: 1px 5px; color: var(--ink-3); background: var(--surface); border: 1px solid var(--line); border-radius: 4px; font-size: 10px; }
.search-status { min-height: 18px; margin: 4px 2px 0; color: var(--ink-3); font-size: 11px; }
.sidebar nav { padding-bottom: 24px; }
.sidebar nav a { position: relative; display: block; margin: 1px 0; padding: 6px 10px; color: var(--ink-2); border-radius: 7px; text-decoration: none; font-size: 13px; }
.sidebar nav a:hover { color: var(--ink); background: var(--surface-2); }
.sidebar nav a.active { color: var(--accent-dark); background: var(--accent-soft); font-weight: 650; }
.sidebar nav a.active::before { content: ""; position: absolute; left: -18px; top: 8px; bottom: 8px; width: 3px; background: var(--accent); border-radius: 0 3px 3px 0; }
.nav-label { margin: 20px 10px 5px; color: var(--ink-3); font-size: 10px; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; }
.sidebar-footer { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid var(--line); display: flex; justify-content: space-between; color: var(--ink-3); font: 10px var(--mono); }

.content { margin: var(--topbar) 0 0 var(--sidebar); min-width: 0; }
.doc-section { display: grid; grid-template-columns: minmax(360px, 46%) minmax(420px, 54%); min-height: 390px; border-bottom: 1px solid var(--line); }
.copy { padding: 64px clamp(38px, 5vw, 76px); }
.copy.wide-copy { grid-column: 1 / -1; max-width: 1180px; width: 100%; margin: 0 auto; }
.example { min-width: 0; padding: 64px clamp(28px, 4vw, 58px); color: var(--code-ink); background: var(--code); border-left: 1px solid var(--code-line); }
.hero { min-height: 650px; background: radial-gradient(circle at 24% 15%, var(--accent-soft), transparent 36%), var(--surface); }
.hero .copy { display: flex; flex-direction: column; justify-content: center; }
.hero-code { display: flex; flex-direction: column; justify-content: center; background: radial-gradient(circle at 80% 20%, rgba(194,84,26,.13), transparent 36%), var(--code); }
.eyebrow, .section-kicker { margin: 0 0 14px; color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
h1 { max-width: 740px; margin: 0; font-size: clamp(42px, 5vw, 68px); line-height: 1.04; letter-spacing: -.055em; }
h2 { margin: 0 0 18px; font-size: clamp(29px, 3vw, 42px); line-height: 1.12; letter-spacing: -.035em; }
h3 { margin: 29px 0 9px; font-size: 17px; letter-spacing: -.015em; }
p { margin: 0 0 18px; color: var(--ink-2); }
.lede { max-width: 690px; margin-top: 24px; font-size: 19px; line-height: 1.6; }
.hero-actions { display: flex; gap: 10px; margin: 10px 0 38px; }
.primary-action, .secondary-action { padding: 10px 15px; border-radius: 8px; font-weight: 700; text-decoration: none; }
.primary-action { color: #fff; background: var(--accent); box-shadow: inset 0 1px 0 rgba(255,255,255,.24), 0 6px 16px rgba(194,84,26,.18); }
.primary-action:hover { background: var(--accent-dark); }
.secondary-action { color: var(--ink); background: var(--surface-2); }
.principles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; max-width: 720px; }
.principles div { display: flex; flex-direction: column; gap: 3px; }
.principles strong { font-size: 13px; }
.principles span { color: var(--ink-3); font-size: 12px; line-height: 1.45; }

.copy code { padding: .12em .34em; color: var(--accent-dark); background: var(--accent-soft); border-radius: 4px; }
.code-head { display: flex; align-items: center; justify-content: space-between; min-height: 32px; padding-bottom: 11px; color: var(--code-muted); border-bottom: 1px solid var(--code-line); font: 11px var(--mono); text-transform: uppercase; letter-spacing: .07em; }
.code-head span + span { text-transform: none; letter-spacing: 0; }
.copy-button { padding: 4px 7px; color: var(--code-muted); background: transparent; border: 1px solid var(--code-line); border-radius: 5px; cursor: pointer; font-size: 10px; }
.copy-button:hover, .copy-button.copied { color: #fff; border-color: #4b5667; }
pre { margin: 0; padding: 23px 0; overflow-x: auto; color: var(--code-ink); font-size: 13px; line-height: 1.72; tab-size: 4; }
pre code { font-size: inherit; }
.kw { color: #e99774; }.type { color: #7dcfff; }.str { color: #a8d58b; }.num { color: #e9bc73; }.comment { color: #778397; font-style: italic; }.fn { color: #d9b1ff; }.tag { color: #e99774; }
.code-note { padding-top: 15px; color: var(--code-muted); border-top: 1px solid var(--code-line); font-size: 11px; }

.callout { margin: 28px 0 0; padding: 16px 18px; border-left: 3px solid; border-radius: 0 8px 8px 0; }
.callout strong { display: block; margin-bottom: 4px; font-size: 13px; }
.callout p { margin: 0; font-size: 13px; }
.callout.note { background: var(--accent-soft); border-color: var(--accent); }
.callout.warning { background: var(--warn-soft); border-color: var(--warn); }
.callout.success { background: var(--ok-soft); border-color: var(--ok); }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin: 12px 0 0; overflow: hidden; background: var(--line); border: 1px solid var(--line); border-radius: 9px; }
.facts div { padding: 13px 15px; background: var(--surface); }
.facts dt { color: var(--ink-3); font-size: 11px; }
.facts dd { margin: 4px 0 0; }
.method-list { margin: 24px 0; padding: 0; list-style: none; }
.method-list li { display: grid; grid-template-columns: minmax(150px, auto) 1fr; gap: 14px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.method-list li span { color: var(--ink-2); font-size: 13px; }
details { margin: 8px 0; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
summary { cursor: pointer; font-weight: 700; font-size: 13px; }
details p { margin: 9px 0 0; font-size: 13px; }
.policy-grid { display: grid; gap: 8px; margin: 25px 0; }
.policy-grid div { display: grid; grid-template-columns: 180px 1fr; gap: 15px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.policy-grid span { color: var(--ink-2); font-size: 13px; }
.error-codes { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 22px; }
.error-codes code { font-size: 10px; letter-spacing: .03em; }

.comparison-table { margin-top: 30px; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.table-row { display: grid; grid-template-columns: 110px 180px 1.2fr 1.3fr; gap: 16px; padding: 14px 16px; border-top: 1px solid var(--line); align-items: start; }
.table-row:first-child { border-top: 0; }
.table-row span { color: var(--ink-2); font-size: 13px; }
.table-head { background: var(--surface-2); color: var(--ink-3); font-size: 10px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.platform-grid, .type-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 30px; }
.platform-grid article, .type-list article { padding: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: 11px; box-shadow: var(--shadow); }
.platform-grid h3, .type-list h3 { margin-top: 12px; }
.platform-grid p, .type-list p { margin: 0; font-size: 13px; }
.platform-badge { padding: 4px 7px; color: var(--accent-dark); background: var(--accent-soft); border-radius: 5px; font: 9px var(--mono); font-weight: 800; text-transform: uppercase; }
.type-list { grid-template-columns: repeat(2, 1fr); }
.type-list article { box-shadow: none; }
.type-list h3 { margin: 0 0 8px; }
.api-index { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-top: 26px; }
.api-index article { padding: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: 11px; }
.api-index h3 { margin-top: 0; }
.api-index ul { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 14px; margin: 0; padding: 0; list-style: none; }
.api-index article:nth-child(2) ul { grid-template-columns: 1fr; }
.api-index li { min-width: 0; }
.api-index code { word-break: break-word; }
.reference-note { margin-top: 18px; }

.page-footer { display: flex; justify-content: space-between; align-items: center; min-height: 140px; padding: 32px clamp(38px, 5vw, 76px); background: var(--surface); }
.page-footer div { display: flex; flex-direction: column; }
.page-footer span { color: var(--ink-3); font-size: 12px; }
.page-footer a { color: var(--accent-dark); text-decoration: none; font-weight: 650; }
.no-results { position: fixed; z-index: 10; left: calc(var(--sidebar) + 50%); top: 50%; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--ink-2); }
.no-results strong { color: var(--ink); font-size: 20px; }

@media (max-width: 1080px) {
  .doc-section { grid-template-columns: 1fr; }
  .copy { padding: 52px clamp(30px, 7vw, 70px); }
  .example { padding: 40px clamp(30px, 7vw, 70px); border-left: 0; }
  .hero { min-height: auto; }
  .hero-code { min-height: 340px; }
  .platform-grid { grid-template-columns: 1fr; }
  .table-row { grid-template-columns: 95px 160px 1fr; }
  .table-row > :last-child { display: none; }
}

@media (max-width: 760px) {
  :root { --topbar: 58px; }
  .topbar { padding: 0 13px; }
  .brand { min-width: 0; }
  .brand-product, .version-picker, .top-link { display: none; }
  .menu-button { display: flex; }
  .sidebar { top: var(--topbar); width: min(86vw, 310px); transform: translateX(-102%); transition: transform .24s ease; box-shadow: 16px 0 48px rgba(0,0,0,.22); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-scrim { position: fixed; z-index: 15; inset: var(--topbar) 0 0 0; display: block; background: rgba(5,7,10,.52); }
  .content { margin-left: 0; }
  .copy, .example { padding: 42px 22px; }
  .hero .copy { padding-top: 58px; }
  h1 { font-size: clamp(39px, 12vw, 55px); }
  h2 { font-size: 30px; }
  .lede { font-size: 17px; }
  .principles { grid-template-columns: 1fr; gap: 12px; }
  .hero-code { min-height: 300px; }
  pre { font-size: 12px; }
  .facts, .type-list, .api-index { grid-template-columns: 1fr; }
  .method-list li, .policy-grid div { grid-template-columns: 1fr; gap: 5px; }
  .comparison-table { overflow-x: auto; }
  .table-row { min-width: 630px; grid-template-columns: 95px 170px 1fr; }
  .platform-grid, .type-list { gap: 10px; }
  .page-footer { padding: 30px 22px; }
  .no-results { left: 50%; width: calc(100% - 44px); text-align: center; }
}

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