/* Tokens. One set, light by default, dark by system preference or by the toggle. */
:root {
  --bg: #ffffff;
  --fg: #0a0a0a;
  --muted: #6b7280;
  --border: #e5e5e5;
  --surface: #fafafa;
  --accent: #0a0a0a;
  --accent-fg: #ffffff;
  --hatch: #efefef;
  --warn: #d97706;
  --info: #2563eb;
  --ok: #16a34a;
  --code-comment: #8b8b8b;
  --code-string: #0a6b3d;
  --code-number: #8a4b00;
  --code-keyword: #7c1fa0;
  --code-function: #1a4fa0;
  --code-property: #0b5d8f;
  --code-punctuation: #6b7280;
  --code-variable: #a33a00;
  --sans: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0b0b0c; --fg: #f4f4f5; --muted: #9b9ba3; --border: #26262b; --surface: #131316;
    --accent: #f4f4f5; --accent-fg: #0b0b0c; --hatch: #18181b;
    --code-comment: #6f6f78; --code-string: #7fd1a3; --code-number: #e8b17a; --code-keyword: #d4a8f0;
    --code-function: #8ab6f0; --code-property: #7ec8e8; --code-punctuation: #9b9ba3; --code-variable: #f0a878;
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #0b0b0c; --fg: #f4f4f5; --muted: #9b9ba3; --border: #26262b; --surface: #131316;
  --accent: #f4f4f5; --accent-fg: #0b0b0c; --hatch: #18181b;
  --code-comment: #6f6f78; --code-string: #7fd1a3; --code-number: #e8b17a; --code-keyword: #d4a8f0;
  --code-function: #8ab6f0; --code-property: #7ec8e8; --code-punctuation: #9b9ba3; --code-variable: #f0a878;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 128px; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/24px var(--sans); -webkit-font-smoothing: antialiased; }
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
a { color: inherit; text-decoration: none; }
svg.i { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
code, pre, kbd { font-family: var(--mono); }

/* ---------------------------------------------------------------- header */
.top { position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.top-row { display: flex; align-items: center; gap: 16px; height: 64px; padding: 0 40px; }
.brand { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; white-space: nowrap; }
.brand-mark { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 6px; background: var(--fg); color: var(--bg); font: 600 12px/1 var(--mono); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.search { display: flex; align-items: center; gap: 8px; width: 256px; height: 34px; padding: 6px 12px; border: 1px solid var(--border); border-radius: 12px; background: transparent; color: var(--muted); font: 14px/20px var(--sans); cursor: pointer; }
.search span { flex: 1; text-align: left; }
.search kbd { font: 10px/1 var(--sans); padding: 3px 5px; border: 1px solid var(--border); border-radius: 4px; }
.theme { display: flex; gap: 2px; padding: 2px; border: 1px solid var(--border); border-radius: 12px; }
.theme button { width: 28px; height: 28px; display: grid; place-items: center; border: 0; border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer; }
.theme button:hover { color: var(--fg); }
.theme button[aria-pressed='true'] { background: var(--surface); color: var(--fg); box-shadow: inset 0 0 0 1px var(--border); }
.ghost { display: inline-flex; align-items: center; height: 34px; padding: 6px 12px; border: 1px solid var(--border); border-radius: 12px; color: var(--muted); font-size: 14px; line-height: 20px; }
.ghost:hover { color: var(--fg); }
.menu { display: none; width: 34px; height: 34px; place-items: center; border: 1px solid var(--border); border-radius: 12px; background: transparent; color: var(--fg); cursor: pointer; }
.tabs { display: flex; padding: 0 28px; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 12px; font-size: 14px; line-height: 20px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; transition: color 0.15s; }
.tabs a:hover { color: var(--fg); }
.tabs a.active { color: var(--fg); font-weight: 500; border-bottom-color: var(--fg); }

/* ---------------------------------------------------------------- layout */
.shell { display: flex; }
.side { position: sticky; top: 113px; flex: none; width: 288px; height: calc(100vh - 113px); overflow-y: auto; padding: 32px 16px 32px 24px; }
.hatch { position: sticky; top: 113px; flex: none; width: 40px; height: calc(100vh - 113px); border-left: 1px solid var(--border); border-right: 1px solid var(--border); background-image: repeating-linear-gradient(315deg, var(--hatch) 0, var(--hatch) 1px, transparent 1px, transparent 10px); }
.main { flex: 1; min-width: 0; display: flex; gap: 40px; padding: 0 40px; }
.article { flex: 1; min-width: 0; max-width: 616px; padding: 40px 0 80px; }
.toc { position: sticky; top: 113px; flex: none; width: 224px; height: calc(100vh - 113px); overflow-y: auto; padding: 36px 0 32px; }

/* sidebar */
.side-group + .side-group { margin-top: 24px; }
.side-head { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 14px; line-height: 20px; font-weight: 500; }
.side ul { list-style: none; margin: 8px 0 0 8px; padding: 0; box-shadow: inset 1px 0 0 0 var(--border); }
.side li a { display: block; padding: 6px 0 6px 16px; font-size: 14px; line-height: 20px; color: var(--muted); transition: color 0.15s; }
.side li a:hover { color: var(--fg); }
.side li a[aria-current='page'] { color: var(--fg); font-weight: 500; box-shadow: inset 1px 0 0 0 var(--fg); }

/* on this page */
.toc-title { margin: 0 0 12px; font-size: 11px; line-height: 16px; font-weight: 500; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.toc ul { list-style: none; margin: 0; padding: 0; box-shadow: inset 1px 0 0 0 var(--border); }
.toc li { margin-bottom: 6px; }
.toc a { display: block; padding: 2px 0 2px 12px; font-size: 14px; line-height: 20px; color: var(--muted); border-left: 1px solid transparent; transition: color 0.15s; }
.toc a:hover { color: var(--fg); }
.toc a.active { color: var(--fg); border-left-color: var(--fg); }

/* ---------------------------------------------------------------- prose */
.article .eyebrow { margin: 0; font: 12px/16px var(--mono); letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.crumbs { margin: 0; font-size: 12px; line-height: 16px; color: var(--muted); }
.crumbs a:hover { color: var(--fg); }
.article h1 { margin: 12px 0 0; font-size: 36px; line-height: 40px; font-weight: 600; letter-spacing: -0.025em; }
.article .lead { margin: 16px 0 0; max-width: 62ch; font-size: 18px; line-height: 32px; color: var(--muted); }
.article h2 { margin: 48px 0 0; font-size: 20px; line-height: 28px; font-weight: 600; letter-spacing: -0.025em; }
.article h3 { margin: 32px 0 0; font-size: 16px; line-height: 24px; font-weight: 600; letter-spacing: -0.01em; }
.article p, .article li { font-size: 15px; line-height: 28px; color: var(--muted); }
.article p { margin: 12px 0 0; }
.article ul, .article ol { margin: 12px 0 0; padding-left: 20px; }
.article li + li { margin-top: 4px; }
.article strong { color: var(--fg); font-weight: 500; }
.article em { color: var(--fg); font-style: normal; }
.article p a, .article li a, .article td a { color: var(--fg); text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 3px; }
.article p a:hover, .article li a:hover { text-decoration-color: var(--fg); }
:not(pre) > code { font-size: 13px; color: var(--fg); background: var(--surface); border-radius: 4px; padding: 2px 4px; }

.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }
.btn { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 8px 16px; border: 1px solid var(--border); border-radius: 12px; font-size: 14px; line-height: 20px; color: var(--fg); background: transparent; white-space: nowrap; cursor: pointer; transition: background 0.15s; }
.btn:hover { background: var(--surface); }
.btn-primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); font-weight: 500; }
.btn-primary:hover { background: var(--accent); opacity: 0.88; }

/* code blocks */
.code { margin: 16px 0 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.hero-code { margin-top: 32px; }
.code-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 12px; background: var(--surface); border-bottom: 1px solid var(--border); }
.code-bar span { font: 12px/16px var(--mono); color: var(--muted); }
.copy { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font: 12px/16px var(--sans); cursor: pointer; }
.copy:hover { background: var(--border); color: var(--fg); }
.code pre { margin: 0; padding: 16px 20px; overflow-x: auto; background: var(--surface); color: var(--fg); font-size: 14px; line-height: 22.75px; }
.t-c { color: var(--code-comment); } .t-s { color: var(--code-string); } .t-n { color: var(--code-number); }
.t-k { color: var(--code-keyword); } .t-f { color: var(--code-function); } .t-p { color: var(--code-property); }
.t-u { color: var(--code-punctuation); } .t-v { color: var(--code-variable); }

/* tables: same frame as the code blocks */
.table { margin: 16px 0 0; border: 1px solid var(--border); border-radius: 12px; overflow-x: auto; }
.table table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 22px; }
.table th { padding: 8px 12px; text-align: left; font-size: 12px; line-height: 16px; font-weight: 500; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); background: var(--surface); border-bottom: 1px solid var(--border); }
.table td { padding: 10px 12px; color: var(--muted); border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table td:first-child { white-space: nowrap; color: var(--fg); }

/* callouts */
.callout { display: flex; gap: 12px; margin: 20px 0 0; padding: 16px; border: 1px solid var(--border); border-left: 2px solid var(--info); border-radius: 12px; background: var(--surface); }
.callout-warn { border-left-color: var(--warn); }
.callout svg.i { margin-top: 2px; color: var(--muted); }
.callout-title { margin: 0 !important; font-size: 14px !important; line-height: 20px !important; font-weight: 500; color: var(--fg) !important; }
.callout-body { margin: 4px 0 0 !important; font-size: 14px !important; line-height: 24px !important; }

/* cards */
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
.cards-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.card { display: flex; flex-direction: column; padding: 20px; border: 1px solid var(--border); border-radius: 12px; transition: border-color 0.15s, background 0.15s; }
.card:hover { border-color: var(--muted); }
.card svg.i { width: 18px; height: 18px; color: var(--fg); }
.card-title { margin: 12px 0 0 !important; font-size: 15px !important; line-height: 22px !important; font-weight: 500; color: var(--fg) !important; }
.card-text { margin: 6px 0 0 !important; font-size: 14px !important; line-height: 24px !important; }
.card-more { margin-top: auto; padding-top: 12px; display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--fg); }
.cards-3 .card { padding: 16px; }

/* download / panel */
.panel { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; margin: 24px 0 0; padding: 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.panel-text { flex: 1; min-width: 240px; }
.panel-text p { margin: 4px 0 0 !important; font-size: 14px !important; line-height: 24px !important; }

/* ---------------------------------------------------------------- reference */
.ops { margin-top: 16px; }
.op { margin: 0 0 16px; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; scroll-margin-top: 128px; }
.op-head { padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
.op-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.method { padding: 2px 6px; border: 1px solid var(--border); border-radius: 4px; font: 500 11px/18px var(--mono); letter-spacing: 0.025em; text-transform: uppercase; color: var(--fg); background: var(--bg); }
.op-line > code { font-size: 13px; background: transparent !important; padding: 0 !important; }
.op-scope { display: inline-flex; align-items: center; gap: 6px; }
.op-scope span { font: 12px/16px var(--mono); color: var(--muted); }
.op-title { margin: 6px 0 0 !important; font-size: 14px !important; line-height: 22px !important; }
.op-body { padding: 16px; }
.op-body > * + * { margin-top: 20px; }
.label { margin: 0; font-size: 12px; line-height: 16px; font-weight: 500; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.fields { margin: 8px 0 0; border: 1px solid var(--border); border-radius: 12px; }
.field { padding: 8px 12px; }
.field + .field { border-top: 1px solid var(--border); }
.field dt { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px; }
.field dt span { font: 12px/16px var(--mono); color: var(--muted); }
.field dt .req { color: var(--warn); }
.field dd { margin: 2px 0 0; font-size: 14px; line-height: 22px; color: var(--muted); }
.field dd:empty { display: none; }
.field details { margin-top: 6px; }
.field summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.field summary:hover { color: var(--fg); }
.field .fields { margin-top: 8px; }
.resp { margin: 8px 0 0 !important; font-size: 14px !important; line-height: 22px !important; }
.op .code { margin-top: 8px; }

/* ---------------------------------------------------------------- footer & search */
.foot { margin-top: 64px; padding-top: 20px; border-top: 1px solid var(--border); font-size: 12px; line-height: 20px; color: var(--muted); }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 56px; }
.pager a { padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; transition: border-color 0.15s; }
.pager a:hover { border-color: var(--muted); }
.pager span { display: block; font-size: 12px; line-height: 16px; color: var(--muted); }
.pager strong { display: block; margin-top: 4px; font-size: 14px; line-height: 20px; font-weight: 500; }
.pager .next { grid-column: 2; text-align: right; }

.palette { position: fixed; inset: 0; z-index: 50; display: grid; place-items: start center; padding-top: 12vh; background: rgb(0 0 0 / 0.4); }
.palette[hidden] { display: none; }
.palette-box { width: min(560px, calc(100vw - 32px)); overflow: hidden; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); box-shadow: 0 24px 64px rgb(0 0 0 / 0.25); }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 0 14px; border-bottom: 1px solid var(--border); color: var(--muted); }
.palette input { flex: 1; height: 48px; border: 0; background: transparent; color: var(--fg); font: 15px var(--sans); outline: none; }
.palette ul { list-style: none; margin: 0; padding: 6px; max-height: 50vh; overflow-y: auto; }
.palette li a { display: flex; justify-content: space-between; gap: 12px; padding: 8px 10px; border-radius: 8px; font-size: 14px; }
.palette li a span { font: 12px/20px var(--mono); color: var(--muted); }
.palette li a.sel { background: var(--surface); }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1240px) { .toc { display: none; } }
@media (max-width: 1024px) { .hatch { display: none; } .side { width: 248px; } }
@media (max-width: 860px) {
  html { scroll-padding-top: 120px; }
  .top-row { padding: 0 16px; gap: 10px; }
  .tabs { padding: 0 4px; }
  .search { flex: 1; width: auto; }
  .search kbd, .ghost { display: none; }
  .theme { display: none; }
  .menu { display: grid; }
  .shell { display: block; }
  .side { display: none; position: static; width: auto; height: auto; padding: 20px 16px; border-bottom: 1px solid var(--border); }
  body.side-open .side { display: block; }
  .main { padding: 0 16px; }
  .article { padding-top: 28px; }
  .article h1 { font-size: 30px; line-height: 36px; }
  .cards, .cards-3, .pager { grid-template-columns: 1fr; }
  .pager .next { grid-column: auto; }
  .table td:first-child { white-space: normal; }
}

.resp-details { margin-top: 8px; }
.resp-details > summary { cursor: pointer; font-size: 13px; line-height: 20px; color: var(--muted); }
.resp-details > summary:hover { color: var(--fg); }

/* reference navigation: every route by name */
.side-sub { margin: 0; font-size: 12px; line-height: 16px; font-weight: 500; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.side-sub a:hover { color: var(--fg); }
.side li a .mini { display: inline-block; width: 34px; font: 500 10px/20px var(--mono); color: var(--muted); }
.side li a:has(.mini) { display: flex; align-items: baseline; }
.toc-sub a { padding-left: 24px; font-size: 13px; }
.op-name { margin: 32px 0 10px !important; font-size: 16px !important; line-height: 24px !important; scroll-margin-top: 128px; }
.ops > .op-name:first-child { margin-top: 20px !important; }
.table td:last-child code { white-space: nowrap; }
.table .method { background: transparent; }

/* Centred frame: on wide screens the whole layout sits in the middle instead of hugging
   the left edge. Header, tabs and body share the same width so their edges line up. */
:root { --frame: 1440px; }
.top-row, .tabs { max-width: var(--frame); margin: 0 auto; }
.shell { max-width: var(--frame); margin: 0 auto; }
.main { justify-content: center; }
.article { max-width: 720px; }
