
:root {
  --font-sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
  --bg: #ffffff;
  --bg-side: #f8f9fb;
  --surface: #ffffff;
  --surface-2: #f3f5f8;
  --border: #e1e5eb;
  --border-strong: #c5ccd6;
  --text: #18202d;
  --text-muted: #556070;
  --accent: #2c4fb8;
  --accent-hover: #233f95;
  --accent-soft: #e9eefb;
  --accent-text: #ffffff;
  --code-bg: #0f1623;
  --code-head: #172031;
  --code-text: #e6ebf3;
  --code-muted: #9aa6b8;
  --t-key: #8fb4ff;
  --t-str: #a5e3a1;
  --t-num: #f6c177;
  --t-com: #7f8b9e;
  --t-attr: #f0a6ca;
  --note-bg: #e9eefb; --note-border: #c3d0f2;
  --tip-bg: #e6f4ec; --tip-border: #b5dcc4;
  --warn-bg: #fdf3da; --warn-border: #efd393;
  --legal-bg: #f3f0fb; --legal-border: #d6cdf0;
  --focus: #2c4fb8;
  --radius: 10px;
  --header-h: 60px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1117; --bg-side: #10151d; --surface: #131a24; --surface-2: #18202c;
    --border: #252f3d; --border-strong: #3a4657; --text: #e6ebf3; --text-muted: #a3aebd;
    --accent: #8fb0ff; --accent-hover: #b3c9ff; --accent-soft: #1b2740; --accent-text: #0d1117;
    --code-bg: #0a0e14; --code-head: #111823;
    --note-bg: #142038; --note-border: #2b3f6b; --tip-bg: #112a1d; --tip-border: #23553a;
    --warn-bg: #2d2410; --warn-border: #5e4a17; --legal-bg: #1f1a33; --legal-border: #3d3366;
    --focus: #8fb0ff; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1117; --bg-side: #10151d; --surface: #131a24; --surface-2: #18202c;
  --border: #252f3d; --border-strong: #3a4657; --text: #e6ebf3; --text-muted: #a3aebd;
  --accent: #8fb0ff; --accent-hover: #b3c9ff; --accent-soft: #1b2740; --accent-text: #0d1117;
  --code-bg: #0a0e14; --code-head: #111823;
  --note-bg: #142038; --note-border: #2b3f6b; --tip-bg: #112a1d; --tip-border: #23553a;
  --warn-bg: #2d2410; --warn-border: #5e4a17; --legal-bg: #1f1a33; --legal-border: #3d3366;
  --focus: #8fb0ff; color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 16px); }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.65 var(--font-sans); }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.skip { position: absolute; left: -9999px; top: 8px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: 6px; }
.skip:focus { left: 8px; }

/* Header */
.top { position: sticky; top: 0; z-index: 20; height: var(--header-h); display: flex; align-items: center; gap: 16px;
  padding: 0 20px; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.brand { display: inline-flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; font-weight: 700; white-space: nowrap; }
.brand svg rect { fill: var(--accent); }
.brand svg path { stroke: var(--accent-text); }
.brand .docs-word { color: var(--text-muted); font-weight: 500; }
.search { position: relative; flex: 1; max-width: 420px; }
.search input { width: 100%; height: 38px; padding: 0 12px 0 34px; border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit; font-size: 15px; }
.search svg { position: absolute; left: 10px; top: 11px; color: var(--text-muted); pointer-events: none; }
.search kbd { position: absolute; right: 8px; top: 8px; font: 12px var(--font-mono); color: var(--text-muted); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; }
.results { position: absolute; top: 44px; left: 0; right: 0; max-height: 70vh; overflow: auto; background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: 0 12px 32px rgba(0,0,0,.18); padding: 6px; margin: 0; list-style: none; }
.results[hidden] { display: none; }
.results a { display: block; padding: 8px 10px; border-radius: 6px; text-decoration: none; color: var(--text); }
.results a[aria-selected="true"], .results a:hover { background: var(--accent-soft); }
.results .r-page { font-size: 12px; color: var(--text-muted); }
.results .r-title { font-weight: 600; }
.results .r-snip { font-size: 13px; color: var(--text-muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.results .r-empty { padding: 10px; color: var(--text-muted); }
.top-links { display: flex; align-items: center; gap: 14px; margin-left: auto; white-space: nowrap; }
.top-links a { color: var(--text-muted); text-decoration: none; font-size: 15px; }
.top-links a:hover { color: var(--text); }
.top-links a.cta { background: var(--accent); color: var(--accent-text); padding: 7px 14px; border-radius: 8px; font-weight: 600; }
.top-links a.cta:hover { background: var(--accent-hover); color: var(--accent-text); }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; min-width: 36px; height: 36px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--surface); color: var(--text); cursor: pointer; font: inherit; font-size: 14px; padding: 0 8px; }
.icon-btn:hover { border-color: var(--border-strong); }
.menu-btn { display: none; }

/* Three columns */
.layout { display: grid; grid-template-columns: 260px minmax(0, 1fr) 220px; max-width: 1480px; margin: 0 auto; }
.layout.wide { grid-template-columns: 260px minmax(0, 1fr); }
.side { position: sticky; top: var(--header-h); height: calc(100vh - var(--header-h)); overflow-y: auto; padding: 20px 14px 40px 20px;
  border-right: 1px solid var(--border); background: var(--bg-side); }
.side h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin: 18px 0 6px 8px; }
.side h2:first-child { margin-top: 0; }
.side ul { list-style: none; margin: 0; padding: 0; }
.side a { display: block; padding: 5px 8px; border-radius: 6px; color: var(--text); text-decoration: none; font-size: 14.5px; line-height: 1.4; }
.side a:hover { background: var(--surface-2); }
.side a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.main { min-width: 0; padding: 32px 48px 80px; }
.main > .content { max-width: 780px; }
.layout.wide .main > .content { max-width: 1180px; }
.toc { position: sticky; top: var(--header-h); height: calc(100vh - var(--header-h)); overflow-y: auto; padding: 32px 20px 40px 8px; font-size: 13.5px; }
.toc h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin: 0 0 8px; }
.toc ul { list-style: none; padding: 0; margin: 0; }
.toc li.d3 { padding-left: 12px; }
.toc a { display: block; padding: 3px 0; color: var(--text-muted); text-decoration: none; line-height: 1.4; }
.toc a:hover, .toc a.active { color: var(--accent); }

/* Content */
.breadcrumb { font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; }
.page-head h1 { font-size: clamp(1.8rem, 3vw, 2.3rem); line-height: 1.2; letter-spacing: -0.02em; margin: 0 0 8px; }
.lead { font-size: 1.12rem; color: var(--text-muted); margin: 0 0 24px; }
.page-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.page-actions a, .page-actions button { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border: 1px solid var(--border);
  border-radius: 7px; background: var(--surface); color: var(--text); font: inherit; font-size: 13px; text-decoration: none; cursor: pointer; }
.page-actions a:hover, .page-actions button:hover { border-color: var(--border-strong); }
.content h2 { font-size: 1.45rem; letter-spacing: -0.01em; margin: 44px 0 12px; padding-top: 4px; line-height: 1.3; }
.content h3 { font-size: 1.15rem; margin: 30px 0 8px; line-height: 1.35; }
.content h4 { font-size: 1rem; margin: 22px 0 6px; }
.content h2 .anchor, .content h3 .anchor, .content h4 .anchor { float: left; margin-left: -1.1em; width: 1em; color: var(--text-muted); text-decoration: none; opacity: 0; }
.content h2:hover .anchor, .content h3:hover .anchor, .content h4:hover .anchor { opacity: 1; }
.content p, .content ul, .content ol { margin: 0 0 14px; }
.content li { margin: 4px 0; }
.content li > ul, .content li > ol { margin: 4px 0 0; }
.content code { font: 0.88em var(--font-mono); background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; overflow-wrap: anywhere; }
.content blockquote { margin: 0 0 16px; padding: 4px 16px; border-left: 3px solid var(--border-strong); color: var(--text-muted); }
.content hr { border: 0; border-top: 1px solid var(--border); margin: 32px 0; }
.content img { max-width: 100%; }
.content details { margin: 0 0 16px; border: 1px solid var(--border); border-radius: 8px; padding: 8px 14px; }
.content summary { cursor: pointer; font-weight: 600; }
.table-wrap { overflow-x: auto; margin: 0 0 18px; border: 1px solid var(--border); border-radius: 8px; }
.content table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
.content th, .content td { text-align: left; vertical-align: top; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.content th { background: var(--surface-2); font-weight: 600; white-space: nowrap; }
.content tr:last-child td { border-bottom: 0; }
.content td code { white-space: nowrap; }
.callout { margin: 0 0 18px; padding: 12px 16px; border-radius: 8px; border: 1px solid var(--note-border); background: var(--note-bg); }
.callout > :last-child { margin-bottom: 0; }
.callout-title { font-weight: 700; margin: 0 0 4px; }
.callout-tip { background: var(--tip-bg); border-color: var(--tip-border); }
.callout-warning { background: var(--warn-bg); border-color: var(--warn-border); }
.callout-legal { background: var(--legal-bg); border-color: var(--legal-border); }
.callout-agent { background: var(--accent-soft); border-color: var(--note-border); }

/* Code */
.code, .tabs { margin: 0 0 18px; border-radius: 10px; overflow: hidden; background: var(--code-bg); border: 1px solid var(--code-bg); }
.tabs .code { margin: 0; border: 0; border-radius: 0; }
.code-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 38px; padding: 0 8px 0 14px;
  background: var(--code-head); color: var(--code-muted); font-size: 13px; }
.code-label { font-weight: 600; }
.code-head [role="tablist"] { display: flex; gap: 2px; overflow-x: auto; }
.code-head [role="tab"] { background: none; border: 0; color: var(--code-muted); font: inherit; font-size: 13px; padding: 9px 10px; cursor: pointer; border-bottom: 2px solid transparent; }
.code-head [role="tab"][aria-selected="true"] { color: var(--code-text); border-bottom-color: #8fb0ff; }
.copy { background: transparent; color: var(--code-muted); border: 1px solid #2c3647; border-radius: 6px; font: inherit; font-size: 12px; padding: 3px 9px; cursor: pointer; }
.copy:hover { color: var(--code-text); border-color: #4a5870; }
.code pre { margin: 0; padding: 14px 16px; overflow-x: auto; color: var(--code-text); font: 13.5px/1.6 var(--font-mono); tab-size: 2; }
.code pre code { background: none; border: 0; padding: 0; font: inherit; color: inherit; white-space: pre; }
.code[data-lang="text"] pre code, .code[data-lang="markdown"] pre code { white-space: pre-wrap; overflow-wrap: anywhere; }
.t-key { color: var(--t-key); } .t-str { color: var(--t-str); } .t-num { color: var(--t-num); } .t-com { color: var(--t-com); font-style: italic; }
.t-attr { color: var(--t-attr); } .t-add { color: #a5e3a1; } .t-del { color: #f59a93; }

/* API reference rows: text left, code right */
.op { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 32px; align-items: start; padding-bottom: 12px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.op-code { position: sticky; top: calc(var(--header-h) + 16px); }
.op-code .code pre { max-height: 460px; }
.op-text > p:first-child code { font-size: 0.95em; font-weight: 600; }
.op .table-wrap { font-size: 13.5px; }
.op td:last-child, .op th:last-child { width: 55%; }

/* Footer of a page */
.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 48px; padding-top: 20px; border-top: 1px solid var(--border); }
.pager a { display: block; flex: 1; padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px; text-decoration: none; }
.pager a:hover { border-color: var(--accent); }
.pager .next { text-align: right; }
.pager small { display: block; color: var(--text-muted); }
.page-foot { margin-top: 28px; font-size: 13px; color: var(--text-muted); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: 8px; font-size: 14px; z-index: 50; }
.toast[hidden] { display: none; }

@media (max-width: 1200px) {
  .layout { grid-template-columns: 240px minmax(0, 1fr); }
  .toc { display: none; }
  .op { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .op-code { position: static; }
}
@media (max-width: 860px) {
  .top { padding: 0 16px; gap: 10px; }
  .menu-btn { display: inline-flex; }
  .top-links .hide-sm, .search kbd { display: none; }
  .brand .docs-word { display: none; }
  .layout, .layout.wide { grid-template-columns: minmax(0, 1fr); }
  .side { display: none; position: fixed; top: var(--header-h); left: 0; right: 0; bottom: 0; height: auto; z-index: 15; border-right: 0; }
  .side.open { display: block; }
  .main { padding: 24px 16px 64px; }
  .content h2 .anchor, .content h3 .anchor, .content h4 .anchor { display: none; }
}
@media (max-width: 520px) {
  .top-links .cta { display: none; }
  .search { max-width: none; }
}
@media print {
  .top, .side, .toc, .page-actions, .pager, .copy { display: none !important; }
  .layout { display: block; }
}
