:root {
  --bg: #ffffff;
  --side: #eef3f0;
  --raised: #ffffff;
  --ink: #12261e;
  --muted: #4b6158;
  --green: #0b6e4f;
  --signal: #f2b705;
  --line: #cfdad4;
  --soft: #f4f8f6;
  --inline-code: #e7efea;
  --hover: rgba(11, 110, 79, 0.07);
  --note: #fffaeb;
  --req: #9a4d00;
  --code-bg: #12261e;
  --code-ink: #e6efe9;
  --shadow: rgba(18, 38, 30, 0.35);
  --sans: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --side-w: 290px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0e1a15;
  --side: #0a1410;
  --raised: #13231c;
  --ink: #e3ece7;
  --muted: #9bb2a7;
  --green: #5ccf9f;
  --line: #24392f;
  --soft: #13231c;
  --inline-code: #1b3027;
  --hover: rgba(92, 207, 159, 0.08);
  --note: #221d0c;
  --req: #f2b705;
  --code-bg: #08110d;
  --shadow: rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 20px; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 1.03rem/1.65 var(--sans); }
a { color: var(--green); text-underline-offset: 3px; }
a:hover { color: var(--ink); }
:focus-visible { outline: 3px solid var(--signal); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: var(--bg); padding: 8px 12px; border-radius: 6px; z-index: 30; }
.skip:focus { left: 8px; }
.brand { font-weight: 800; font-size: 1.08rem; color: var(--ink); text-decoration: none; letter-spacing: -0.01em; }
.brand span { color: var(--green); }
.brand:hover { color: var(--ink); }
.tool svg, .expand-all svg, .chev { display: block; }

/* Small square icon buttons */
.tool { display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--raised); color: var(--muted); cursor: pointer; }
.tool svg { width: 18px; height: 18px; }
.tool:hover { color: var(--ink); border-color: var(--muted); }
.tool[aria-pressed="true"] { color: var(--green); border-color: var(--green); background: var(--hover); }
.theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: inline; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }

/* Three columns. The sidebar runs the full height, so nothing sits above it. */
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr) 230px; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--side); border-right: 1px solid var(--line); }
.content { min-width: 0; max-width: 840px; width: 100%; margin: 0 auto; padding: 22px 44px 0; display: flex; flex-direction: column; }
.toc { position: sticky; top: 0; align-self: start; max-height: 100vh; overflow-y: auto; padding: 72px 20px 32px 8px; font-size: 0.88rem; }

/* Sidebar */
.side-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 22px 20px 14px; }
.version { font: 500 0.75rem var(--mono); color: var(--muted); }
.search { position: relative; padding: 0 16px; }
.search input { width: 100%; font: 400 0.95rem var(--sans); padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--raised); color: var(--ink); }
.search input::placeholder { color: var(--muted); }
.search-results { position: absolute; z-index: 5; left: 16px; right: 16px; list-style: none; margin: 6px 0 0; padding: 6px; background: var(--raised); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 30px -12px var(--shadow); max-height: 60vh; overflow-y: auto; }
.search-results li a { display: block; padding: 8px 10px; border-radius: 6px; text-decoration: none; color: var(--ink); }
.search-results li a:hover, .search-results li a[aria-selected="true"] { background: var(--hover); }
.search-results small { display: block; color: var(--muted); font-size: 0.78rem; }
.search-results .empty { padding: 8px 10px; color: var(--muted); font-size: 0.9rem; }
.nav-tools { display: flex; justify-content: flex-end; padding: 10px 16px 4px; }
.expand-all { display: inline-flex; align-items: center; gap: 6px; font: 600 0.8rem var(--sans); color: var(--muted); background: none; border: 0; padding: 4px 6px; border-radius: 6px; cursor: pointer; }
.expand-all:hover { color: var(--ink); background: var(--hover); }
.expand-all svg { width: 15px; height: 15px; }
.side-nav { flex: 1; overflow-y: auto; padding: 0 12px 24px; overscroll-behavior: contain; }
.side-nav ul { list-style: none; margin: 0; padding: 0; }
.side-nav summary { list-style: none; display: flex; align-items: center; gap: 6px; cursor: pointer; border-radius: 6px; user-select: none; }
.side-nav summary::-webkit-details-marker { display: none; }
.side-nav summary:hover { background: var(--hover); }
.chev { width: 14px; height: 14px; flex: none; color: var(--muted); transition: transform 0.15s ease; }
details[open] > summary .chev { transform: rotate(90deg); }
.nav-section { margin-top: 6px; }
.nav-section > summary { padding: 6px 8px; font-weight: 800; font-size: 0.95rem; color: var(--ink); }
.nav-section > ul { padding: 2px 0 8px 10px; }
.nav-group > summary { padding: 5px 8px; font-size: 0.9rem; font-weight: 600; color: var(--ink); }
.nav-group > ul { padding-left: 14px; }
.side-nav li a { display: block; padding: 5px 8px 5px 12px; border-left: 2px solid var(--line); color: var(--muted); text-decoration: none; font-size: 0.93rem; line-height: 1.4; }
.side-nav li a:hover { color: var(--ink); background: var(--hover); }
.side-nav li a[aria-current="page"] { color: var(--green); font-weight: 600; border-left-color: var(--green); background: var(--raised); }
.side-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line); }
.side-foot > a { font-size: 0.88rem; font-weight: 600; color: var(--muted); text-decoration: none; }
.side-foot > a:hover { color: var(--ink); }
.tools { display: flex; align-items: center; gap: 6px; }
.layout-toggle { display: none; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: 9px; }
.layout-toggle .tool { border: 0; width: 28px; height: 28px; }
.show-sidebar { display: none; position: fixed; left: 14px; bottom: 14px; z-index: 8; box-shadow: 0 8px 20px -10px var(--shadow); }

/* Hidden sidebar: the page takes the room. */
:root[data-sidebar="hidden"] .shell { grid-template-columns: 0 minmax(0, 1fr) 230px; }
:root[data-sidebar="hidden"] .sidebar { visibility: hidden; overflow: hidden; border: 0; }
:root[data-sidebar="hidden"] .show-sidebar { display: inline-grid; }

/* Page */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 32px; margin-bottom: 6px; }
.crumbs { margin: 0; color: var(--muted); font-size: 0.88rem; }
.page-links { display: flex; gap: 18px; font-size: 0.9rem; font-weight: 600; }
.page-links a { color: var(--muted); text-decoration: none; }
.page-links a:hover { color: var(--green); }
.content h1 { font-size: clamp(2rem, 3.6vw, 2.6rem); line-height: 1.1; letter-spacing: -0.03em; font-weight: 800; margin: 8px 0 20px; }
.content h2 { font-size: 1.55rem; letter-spacing: -0.015em; line-height: 1.2; margin: 44px 0 12px; padding-top: 4px; font-weight: 800; }
.content h3 { font-size: 1.2rem; margin: 30px 0 10px; font-weight: 600; }
.content h4 { font-size: 1.02rem; margin: 24px 0 8px; }
.content h2, .content h3, .content h4 { position: relative; }
.anchor { position: absolute; left: -1.1em; width: 1em; color: var(--line); text-decoration: none; opacity: 0; font-weight: 400; }
h2:hover .anchor, h3:hover .anchor, h4:hover .anchor, .anchor:focus { opacity: 1; }
.content p, .content li { max-width: 72ch; }
.content ul, .content ol { padding-left: 1.3em; }
.content li + li { margin-top: 4px; }
.content blockquote { margin: 20px 0; padding: 12px 18px; border-left: 4px solid var(--signal); background: var(--note); border-radius: 0 10px 10px 0; }
.content blockquote p { margin: 6px 0; }
.content hr { border: 0; border-top: 1px solid var(--line); margin: 36px 0; }
.content img { max-width: 100%; }

code { font: 0.86em var(--mono); }
:not(pre) > code { background: var(--inline-code); padding: 2px 6px; border-radius: 5px; word-break: break-word; }
pre.code { margin: 16px 0 20px; padding: 16px 18px; background: var(--code-bg); color: var(--code-ink); border-radius: 12px; overflow-x: auto; font: 400 0.86rem/1.6 var(--mono); }
:root[data-theme="dark"] pre.code { border: 1px solid var(--line); }
pre.code code { font: inherit; background: none; padding: 0; }
.hljs-comment, .hljs-quote { color: #7f9a8e; font-style: italic; }
.hljs-string, .hljs-template-string { color: #ffd76a; }
.hljs-keyword, .hljs-built_in, .hljs-literal, .hljs-type { color: #8fd3ff; }
.hljs-number { color: #ffb38a; }
.hljs-attr, .hljs-property, .hljs-variable, .hljs-params { color: #a8e6c4; }
.hljs-title, .hljs-title.function_, .hljs-section { color: #ffffff; font-weight: 500; }
.hljs-meta, .hljs-symbol { color: #c6a8ff; }

.table-scroll { overflow-x: auto; margin: 16px 0 22px; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; background: var(--soft); }
tr:last-child td { border-bottom: 0; }
table.fields td:first-child { white-space: nowrap; }
table.fields td:nth-child(2) { color: var(--muted); white-space: nowrap; }
.req { display: block; margin-top: 2px; color: var(--req); font-size: 0.8rem; font-weight: 600; }

/* Tabs inside guides */
.tabset { margin: 16px 0 22px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.tabset [role="tablist"] { display: flex; gap: 2px; padding: 6px 6px 0; background: var(--soft); border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabset [role="tab"] { font: 600 0.88rem var(--sans); background: transparent; border: 0; padding: 8px 14px; border-radius: 8px 8px 0 0; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tabset [role="tab"][aria-selected="true"] { background: var(--bg); color: var(--green); box-shadow: inset 0 -2px 0 var(--green); }
.tabset [role="tabpanel"] { padding: 4px 16px; }
.tabset [role="tabpanel"] > pre.code:first-child { margin-top: 12px; }

/* Reference pages */
.endpoint { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; background: var(--soft); border: 1px solid var(--line); border-radius: 12px; margin: 0 0 12px; }
.endpoint .method { font: 600 0.8rem var(--mono); background: var(--green); color: var(--bg); padding: 4px 8px; border-radius: 6px; }
.endpoint code { font-size: 0.95rem; background: none; padding: 0; word-break: break-all; }
.verified { font-size: 0.9rem; margin: 0 0 20px; }
.verified.yes { color: var(--green); }
.verified.yes::before { content: ""; display: inline-block; width: 9px; height: 9px; background: var(--signal); border-radius: 2px; margin-right: 8px; vertical-align: 1px; }
.verified.no { color: var(--muted); }
.sent-to { color: var(--muted); font-size: 0.92rem; }
.code-label { margin: 18px 0 -8px; font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.op-grid > div { min-width: 0; }

/* Two columns on wide screens: examples sit beside the text and follow you down. */
@media (min-width: 1200px) {
  .is-reference .layout-toggle { display: inline-flex; }
  :root[data-layout="split"] .is-reference .shell { grid-template-columns: var(--side-w) minmax(0, 1fr); }
  :root[data-layout="split"][data-sidebar="hidden"] .is-reference .shell { grid-template-columns: 0 minmax(0, 1fr); }
  :root[data-layout="split"] .is-reference .toc { display: none; }
  :root[data-layout="split"] .is-reference .content { max-width: 1480px; }
  :root[data-layout="split"] .is-reference .content > p,
  :root[data-layout="split"] .is-reference .content > .endpoint { max-width: 760px; }
  :root[data-layout="split"] .op-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 36px; align-items: start; }
  :root[data-layout="split"] .op-code { position: sticky; top: 16px; }
  :root[data-layout="split"] .op-code > .code-label:first-child { margin-top: 6px; }
}

/* Previous and next */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 56px 0 0; padding-top: 24px; border-top: 1px solid var(--line); }
.pager a { display: block; padding: 14px 18px; border: 1px solid var(--line); border-radius: 12px; text-decoration: none; color: var(--ink); font-weight: 600; line-height: 1.35; }
.pager a:hover { border-color: var(--green); color: var(--green); }
.pager span { display: block; color: var(--muted); font-size: 0.82rem; font-weight: 400; margin-bottom: 2px; }
.pager .next { text-align: right; grid-column: 2; }
.edit { margin: 20px 0 0; font-size: 0.88rem; }
.edit a { color: var(--muted); }
.footer { margin-top: auto; padding: 32px 0 28px; color: var(--muted); font-size: 0.82rem; }
.footer p { margin: 0; max-width: 90ch; }

/* On this page */
.toc p { margin: 0 0 8px; font-weight: 800; color: var(--ink); }
.toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.toc li a { display: block; padding: 3px 0 3px 12px; margin-left: -1px; border-left: 2px solid transparent; color: var(--muted); text-decoration: none; line-height: 1.4; }
.toc li.d3 a { padding-left: 24px; font-size: 0.84rem; }
.toc li a:hover { color: var(--ink); }
.toc li a.active { color: var(--green); border-left-color: var(--green); }

/* Medium screens: no room for "On this page". */
.mobile-bar { display: none; }
@media (max-width: 1199px) {
  .shell { grid-template-columns: var(--side-w) minmax(0, 1fr); }
  :root[data-sidebar="hidden"] .shell { grid-template-columns: 0 minmax(0, 1fr); }
  .toc { display: none; }
}
/* Narrow screens: a slim bar with the menu; the sidebar slides over the page. */
@media (max-width: 900px) {
  .mobile-bar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 14px; height: 56px; padding: 0 16px; background: var(--bg); border-bottom: 1px solid var(--line); }
  .mobile-bar .theme-toggle { margin-left: auto; }
  .menu { font: 600 0.9rem var(--sans); color: var(--ink); background: var(--raised); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; cursor: pointer; }
  html { scroll-padding-top: 72px; }
  .shell, :root[data-sidebar="hidden"] .shell { display: block; }
  .sidebar, :root[data-sidebar="hidden"] .sidebar { position: fixed; z-index: 20; top: 0; left: 0; width: min(320px, 88vw); height: 100vh; visibility: hidden; overflow: hidden; border-right: 1px solid var(--line); transform: translateX(-100%); transition: transform 0.2s ease, visibility 0.2s; }
  body.nav-open .sidebar { transform: none; visibility: visible; box-shadow: 12px 0 30px -18px var(--shadow); }
  .side-foot .theme-toggle, .hide-sidebar, .show-sidebar, :root[data-sidebar="hidden"] .show-sidebar { display: none; }
  .content { padding: 18px 20px 0; }
  .page-links { display: none; }
  .anchor { display: none; }
}
@media (max-width: 520px) {
  .pager { grid-template-columns: 1fr; }
  .pager .next { grid-column: 1; }
  th, td { padding: 8px 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .sidebar, .chev { transition: none; }
}
