:root {
  --bg: #faf8f4;
  --surface: #ffffff;
  --band: #f2f0f8;
  --fg: #1a1430;
  --muted: #5e587a;
  --faint: #807a93;
  --line: #e7e1d6;
  --brand: #5036b0;
  --brand-deep: #3a2783;
  --brand-tint: #ede9f8;
  --on-brand: #ffffff;
  --code-bg: #f4f1fa;
  --quote-bg: #fdf6ea;
  --quote-line: #e6c48d;
  --mark: #fde68a;
  --tok-key: #7c3aed;
  --tok-str: #0f7a4d;
  --tok-attr: #a3480b;
  --tok-tag: #3a2783;
  --tok-com: #807a93;
  --tok-num: #b4235a;
  --font: "DM Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Plus Jakarta Sans", var(--font);
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15111f; --surface: #1d1829; --band: #1a1526; --fg: #ebe8f3; --muted: #aaa3c2; --faint: #8a83a3;
    --line: #322c44; --brand: #b4a0f4; --brand-deep: #cbbcf8; --brand-tint: #2a2243; --on-brand: #15111f;
    --code-bg: #221c33; --quote-bg: #2b2318; --quote-line: #7a5f2d; --mark: #5b4a12;
    --tok-key: #c4a8ff; --tok-str: #7fd6a8; --tok-attr: #f0b07a; --tok-tag: #a9b8ff; --tok-com: #8a83a3; --tok-num: #f59bbf;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15111f; --surface: #1d1829; --band: #1a1526; --fg: #ebe8f3; --muted: #aaa3c2; --faint: #8a83a3;
  --line: #322c44; --brand: #b4a0f4; --brand-deep: #cbbcf8; --brand-tint: #2a2243; --on-brand: #15111f;
  --code-bg: #221c33; --quote-bg: #2b2318; --quote-line: #7a5f2d; --mark: #5b4a12;
  --tok-key: #c4a8ff; --tok-str: #7fd6a8; --tok-attr: #f0b07a; --tok-tag: #a9b8ff; --tok-com: #8a83a3; --tok-num: #f59bbf;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-padding-top: 72px; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.65 var(--font); -webkit-text-size-adjust: 100%; }
a { color: var(--brand); }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* Header */
.top {
  position: sticky; top: 0; z-index: 20; height: 60px; display: flex; align-items: center; gap: 14px;
  padding: 0 20px; background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--fg); font: 700 17px var(--display); letter-spacing: -.01em; flex-shrink: 0; }
.brand b { color: var(--brand); font-weight: 700; }
.top > button { background: none; border: 1px solid var(--line); border-radius: 8px; width: 36px; height: 36px; flex-shrink: 0; }
.top > button:hover { border-color: var(--brand); color: var(--brand); }
.top .menu { display: none; }
.top-links { display: flex; gap: 18px; margin-left: auto; font-size: 14.5px; }
.top-links a { color: var(--muted); text-decoration: none; }
.top-links a:hover { color: var(--brand); }

.search { position: relative; flex: 0 1 340px; margin-left: 28px; }
.search input {
  width: 100%; height: 38px; padding: 0 34px 0 12px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--surface); color: var(--fg); font: 14.5px var(--font);
}
.search input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
.search kbd { position: absolute; right: 9px; top: 9px; font: 12px var(--mono); color: var(--faint); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; pointer-events: none; }
.search input:focus + kbd { display: none; }
.search-results {
  position: absolute; top: 44px; left: 0; width: min(520px, calc(100vw - 32px)); max-height: 70vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 16px 40px rgb(20 12 50 / .16); padding: 6px;
}
.search-results a { display: flex; flex-direction: column; gap: 1px; padding: 9px 11px; border-radius: 8px; text-decoration: none; color: var(--fg); }
.search-results a[aria-selected="true"], .search-results a:hover { background: var(--brand-tint); }
.sr-page { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 600; }
.sr-head { font-weight: 600; font-size: 14.5px; }
.sr-text { font-size: 13px; color: var(--muted); line-height: 1.45; }
.sr-text mark, .sr-head mark { background: var(--mark); color: inherit; border-radius: 2px; }
.sr-empty { padding: 12px; font-size: 14px; color: var(--muted); }

/* Layout */
.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr) 220px; max-width: 1320px; margin: 0 auto; }
.sidebar { position: sticky; top: 60px; align-self: start; height: calc(100vh - 60px); overflow-y: auto; padding: 24px 12px 24px 16px; border-right: 1px solid var(--line); font-size: 14.5px; }
.sidebar a { display: block; padding: 6px 10px; border-radius: 6px; color: var(--fg); text-decoration: none; }
.sidebar a:hover { background: var(--brand-tint); }
.sidebar a.active { background: var(--brand-tint); color: var(--brand); font-weight: 600; }
.nav-group { margin: 18px 10px 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 600; }
.nav-external { display: none !important; }

main { min-width: 0; padding: 28px 44px 80px; }
.toc { position: sticky; top: 60px; align-self: start; max-height: calc(100vh - 60px); overflow-y: auto; padding: 28px 16px; font-size: 13.5px; }
.toc-title { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 600; margin-bottom: 8px; }
.toc a { display: block; padding: 3px 0; color: var(--muted); text-decoration: none; line-height: 1.4; }
.toc a:hover { color: var(--brand); }
.toc a.d3 { padding-left: 12px; }
.toc code { font-size: 12px; }

.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; font-size: 13px; color: var(--muted); padding-bottom: 14px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.meta > span { min-width: 0; overflow-wrap: anywhere; }
.meta code { font-size: 12.5px; word-break: break-all; }
.meta-actions { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.meta-actions button, .meta-actions a { font-size: 13px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); text-decoration: none; color: var(--fg); }
.meta-actions button:hover, .meta-actions a:hover { border-color: var(--brand); color: var(--brand); }
.pill { font-size: 11.5px; padding: 1px 7px; border-radius: 999px; background: var(--brand-tint); color: var(--brand); font-weight: 600; cursor: help; }

/* Prose */
.prose { max-width: 760px; }
.prose h1, .prose h2, .prose h3, .home h1, .home h2 { font-family: var(--display); letter-spacing: -.015em; text-wrap: balance; }
.prose h1 { font-size: 36px; line-height: 1.15; margin: 26px 0 12px; font-weight: 800; }
.prose h2 { font-size: 24px; line-height: 1.3; margin: 48px 0 10px; padding-top: 14px; border-top: 1px solid var(--line); font-weight: 700; }
.prose h3 { font-size: 18px; margin: 30px 0 8px; font-weight: 700; }
.prose hr + h2 { border-top: 0; padding-top: 0; }
.prose h1, .prose h2, .prose h3, .prose h4 { position: relative; }
.anchor { position: absolute; left: -1.1em; opacity: 0; text-decoration: none; color: var(--faint); font-weight: 400; }
:is(h1, h2, h3, h4):hover > .anchor, .anchor:focus { opacity: 1; }
.prose p, .prose li { overflow-wrap: anywhere; }
.prose li { margin: 4px 0; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 36px 0; }
.prose code, .home code, .fill code { font-family: var(--mono); font-size: .86em; background: var(--code-bg); border: 1px solid var(--line); border-radius: 4px; padding: .08em .35em; }
.prose blockquote { margin: 18px 0; padding: 10px 18px; background: var(--quote-bg); border-left: 3px solid var(--quote-line); border-radius: 0 8px 8px 0; }
.prose blockquote > :first-child { margin-top: 4px; }
.table-wrap { overflow-x: auto; margin: 14px 0; }
table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
th, td { text-align: left; vertical-align: top; padding: 8px 12px; border-bottom: 1px solid var(--line); }
th { font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

/* Code */
.code { position: relative; margin: 14px 0; }
.code pre { margin: 0; background: var(--code-bg); border: 1px solid var(--line); border-radius: 10px; padding: 16px 16px 14px; overflow-x: auto; font: 13.5px/1.6 var(--mono); }
.code pre code { background: none; border: 0; padding: 0; font-size: inherit; }
.code-lang { position: absolute; top: 0; left: 14px; transform: translateY(-50%); font: 600 10.5px var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--faint); background: var(--bg); padding: 0 6px; border-radius: 4px; }
.copy-code { position: absolute; top: 8px; right: 8px; font-size: 12px; padding: 3px 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); opacity: .8; }
.copy-code:hover, .copy-code:focus { opacity: 1; border-color: var(--brand); }
.hljs-keyword, .hljs-built_in, .hljs-selector-tag, .hljs-section { color: var(--tok-key); }
.hljs-string, .hljs-template-variable, .hljs-addition { color: var(--tok-str); }
.hljs-attr, .hljs-attribute, .hljs-property, .hljs-variable { color: var(--tok-attr); }
.hljs-tag, .hljs-name, .hljs-title, .hljs-selector-class, .hljs-selector-pseudo, .hljs-type { color: var(--tok-tag); }
.hljs-comment, .hljs-meta, .hljs-deletion { color: var(--tok-com); font-style: italic; }
.hljs-number, .hljs-literal, .hljs-symbol { color: var(--tok-num); }

/* Buttons */
.btn-primary, .btn-ghost { display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; border-radius: 999px; font: 600 14.5px var(--font); text-decoration: none; border: 1px solid transparent; }
.btn-primary { background: var(--brand); color: var(--on-brand); }
.btn-primary:hover { background: var(--brand-deep); }
.btn-ghost { border-color: var(--line); background: var(--surface); color: var(--fg); }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); }

/* Prompt filler */
.fill { max-width: 760px; margin: 22px 0 8px; padding: 20px 22px; border: 1px solid var(--line); border-radius: 14px; background: var(--band); }
.fill-head h2 { margin: 0; font: 700 18px var(--display); }
.fill-head p { margin: 4px 0 14px; font-size: 14.5px; color: var(--muted); }
.fill-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 16px; }
.fill-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fill-key { font: 600 12px var(--mono); color: var(--brand); }
.fill-field input { height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--fg); font: 14.5px var(--font); }
.fill-field input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
.fill-hint { font-size: 12.5px; color: var(--faint); line-height: 1.4; overflow-wrap: anywhere; }
.fill-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.fill-actions button { cursor: pointer; }
.fill-preview { margin: 14px 0 0; max-height: 420px; overflow: auto; white-space: pre-wrap; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; font: 13px/1.55 var(--mono); }

/* Pager */
.pager { max-width: 760px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 56px; }
.pager a { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; text-decoration: none; color: var(--fg); font-weight: 600; background: var(--surface); }
.pager a:hover { border-color: var(--brand); color: var(--brand); }
.pager a span { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 600; }
.pager .next { text-align: right; grid-column: 2; }

/* Home */
.home { max-width: 900px; }
.hero { padding: 36px 0 12px; }
.eyebrow { font-size: 12.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--brand); font-weight: 700; }
.home h1 { font-size: 46px; line-height: 1.08; font-weight: 800; margin: 10px 0 14px; }
.home .lede { font-size: 18.5px; color: var(--muted); max-width: 60ch; margin: 0; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 24px; }
.home section { margin-top: 48px; }
.home h2 { font-size: 22px; font-weight: 700; margin: 0 0 14px; }
.home h2 a { color: inherit; }
.inside-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; counter-reset: none; }
.inside-list a { display: block; height: 100%; padding: 12px 14px; border-radius: 10px; background: var(--band); border: 1px solid var(--line); text-decoration: none; color: var(--fg); font-weight: 500; font-size: 15px; }
.inside-list a:hover { border-color: var(--brand); color: var(--brand); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.card { display: flex; flex-direction: column; gap: 6px; padding: 18px 18px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); text-decoration: none; color: var(--fg); transition: border-color .15s, transform .15s; }
.card:hover { border-color: var(--brand); transform: translateY(-1px); }
.card-group { font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--brand); font-weight: 700; }
.card-title { font: 700 17px var(--display); letter-spacing: -.01em; }
.card-desc { font-size: 14px; color: var(--muted); }
.card-url { font: 12px var(--mono); color: var(--faint); margin-top: auto; padding-top: 6px; }
.agents { display: grid; grid-template-columns: 1.1fr 1fr; gap: 24px; align-items: center; padding: 24px; border-radius: 16px; background: var(--band); border: 1px solid var(--line); }
.agents p { margin: 0; color: var(--muted); }
.agents .code { margin: 0; }
.agents .code pre { background: var(--surface); }
.fine { font-size: 14px; color: var(--muted); margin-top: 40px; }

@media (max-width: 1100px) {
  .shell { grid-template-columns: 220px minmax(0, 1fr); }
  .toc { display: none; }
  .top-links { display: none; }
  .search { margin-left: auto; }
  .nav-external { display: block !important; }
}
@media (max-width: 760px) {
  .top { gap: 10px; padding: 0 16px; }
  .shell { display: block; }
  .top .menu { display: inline-block; }
  .brand span { display: none; }
  .search { flex: 1 1 auto; margin-left: 0; }
  .search kbd { display: none; }
  .sidebar { display: none; position: fixed; inset: 60px 0 0 0; height: auto; z-index: 15; background: var(--bg); border-right: 0; padding: 12px 16px 40px; font-size: 16px; }
  .sidebar.open { display: block; }
  main { padding: 20px 16px 64px; }
  .prose h1 { font-size: 29px; }
  .prose h2 { font-size: 21px; }
  .anchor { display: none; }
  .meta-actions { margin-left: 0; }
  .home h1 { font-size: 34px; }
  .agents { grid-template-columns: 1fr; padding: 18px; }
  .pager { grid-template-columns: 1fr; }
  .pager .next { grid-column: 1; }
  .card-url span { display: none; }
  .fill { padding: 16px; }
}
.prose :is(h1, h2, h3) code { font-size: .78em; padding: 0 .3em; }
.code pre { padding-right: 72px; }
.agents { grid-template-columns: 1fr 1fr; }
@media (max-width: 760px) { .agents { grid-template-columns: 1fr; } }
.report { max-width: 760px; margin-top: 48px; padding: 14px 16px; border: 1px dashed var(--line); border-radius: 12px; font-size: 14.5px; color: var(--muted); }
.pager { margin-top: 20px; }
