:root {
  --bg: #ffffff; --bg-soft: #f6f7f9; --bg-code: #f3f4f6; --text: #1f2328;
  --muted: #5d6673; --border: #dde1e6; --accent: #2f6fdd; --accent-soft: #e8f0fd;
  --kw: #a6265d; --type: #0b7a75; --str: #2e7d32; --num: #b35900; --cmt: #7a8290;
  --obj: #6f42c1;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15181d; --bg-soft: #1b1f25; --bg-code: #20252c; --text: #e3e6ea;
    --muted: #9aa3ae; --border: #2e343c; --accent: #6ea2ff; --accent-soft: #1f2b40;
    --kw: #ff7aa8; --type: #5fd4cc; --str: #8fd18f; --num: #ffb366; --cmt: #7f8894;
    --obj: #c3a2ff;
  }
}
:root[data-theme="dark"] {
  --bg: #15181d; --bg-soft: #1b1f25; --bg-code: #20252c; --text: #e3e6ea;
  --muted: #9aa3ae; --border: #2e343c; --accent: #6ea2ff; --accent-soft: #1f2b40;
  --kw: #ff7aa8; --type: #5fd4cc; --str: #8fd18f; --num: #ffb366; --cmt: #7f8894;
  --obj: #c3a2ff;
}
* { box-sizing: border-box; }
html { scroll-padding-top: 64px; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font-family: ui-monospace, "JetBrains Mono", Consolas, monospace; font-size: 13px; }
:not(pre) > code { background: var(--bg-code); padding: 1px 5px; border-radius: 4px; overflow-wrap: anywhere; }

.topbar {
  position: sticky; top: 0; z-index: 10; height: 52px; display: flex; align-items: center;
  gap: 12px; padding: 0 16px; background: var(--bg); border-bottom: 1px solid var(--border);
}
.topbar .brand { font-weight: 700; color: var(--text); font-size: 16px; }
.brand span { font-weight: 400; color: var(--muted); }
.topbar .version {
  font-size: 12px; color: var(--muted); border: 1px solid var(--border);
  border-radius: 10px; padding: 0 8px;
}
.topbar button {
  background: none; border: 1px solid var(--border); color: var(--text); border-radius: 6px;
  width: 34px; height: 30px; cursor: pointer; font-size: 16px;
}
#theme { margin-left: auto; }
#menu { display: none; }

.layout { display: grid; grid-template-columns: 270px minmax(0, 1fr) 220px; }
.sidebar {
  position: sticky; top: 52px; height: calc(100vh - 52px); overflow-y: auto;
  padding: 16px 12px 40px; border-right: 1px solid var(--border); background: var(--bg-soft);
}
.sidebar .brand { display: none; }
#filter {
  width: 100%; padding: 7px 10px; margin-bottom: 12px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit;
}
.groups, .groups ul { list-style: none; margin: 0; padding: 0; }
.group-link {
  display: block; padding: 5px 8px; font-weight: 600; color: var(--text); border-radius: 5px;
}
.group > ul { display: none; padding-left: 8px; margin-bottom: 6px; }
.group.active > ul, .group.open > ul { display: block; }
.group.active > .group-link { background: var(--accent-soft); color: var(--accent); }
.item a {
  display: block; padding: 2px 8px; font-size: 13px; color: var(--muted);
  font-family: ui-monospace, Consolas, monospace;
}
.item a:hover { color: var(--accent); text-decoration: none; }
.no-match { color: var(--muted); font-size: 13px; padding: 0 8px; }

.content { padding: 28px 40px 80px; max-width: 900px; min-width: 0; }
h1 { font-size: 30px; margin: 0 0 8px; }
h2 { font-size: 21px; margin: 0 0 4px; }
h3 { font-size: 15px; margin: 20px 0 8px; }
.summary { color: var(--muted); margin: 0 0 12px; }
.intro { padding-bottom: 12px; }
.entry { border-top: 1px solid var(--border); padding: 28px 0 8px; }
.entry h2 .anchor { color: var(--text); font-family: ui-monospace, Consolas, monospace; }
.label {
  font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
  margin: 18px 0 6px; font-weight: 600;
}
.legacy-note { margin-top: 0; color: var(--muted); }
.muted { color: var(--muted); }
.return-type { font-size: 13px; font-weight: 400; }
.since {
  display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 999px;
  font-size: 11px; font-weight: 600; line-height: 16px; vertical-align: middle; white-space: nowrap;
  font-family: ui-monospace, Consolas, monospace;
  color: var(--accent); background: var(--accent-soft); border: 1px solid var(--accent);
}

pre { margin: 0; padding: 12px 14px; overflow-x: auto; }
pre.signature {
  background: var(--accent-soft); border-left: 3px solid var(--accent); border-radius: 6px;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.code { position: relative; background: var(--bg-code); border-radius: 6px; margin: 8px 0 14px; }
.copy {
  position: absolute; top: 6px; right: 6px; font-size: 12px; padding: 2px 8px; cursor: pointer;
  border: 1px solid var(--border); border-radius: 4px; background: var(--bg); color: var(--muted);
  opacity: 0; transition: opacity .15s;
}
.code:hover .copy, .copy:focus { opacity: 1; }
.t-kw { color: var(--kw); } .t-type { color: var(--type); } .t-string { color: var(--str); }
.t-number { color: var(--num); } .t-comment { color: var(--cmt); font-style: italic; }
.t-obj { color: var(--obj); } .t-key { color: var(--type); }

table { border-collapse: collapse; width: 100%; margin: 8px 0 14px; font-size: 14px; display: block; overflow-x: auto; }
th, td { text-align: left; vertical-align: top; padding: 6px 10px; border-bottom: 1px solid var(--border); }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
table.fields td:first-child, table.fields td:nth-child(2) { white-space: nowrap; }
td.depth-1 { padding-left: 24px; } td.depth-2 { padding-left: 38px; } td.depth-3 { padding-left: 52px; }
.group-card { margin: 18px 0 26px; }
.group-card h3 { font-size: 18px; margin-bottom: 2px; }
.group-card p { margin: 0 0 6px; color: var(--muted); }
table.index td:first-child { width: 42%; white-space: nowrap; }

.toc {
  position: sticky; top: 52px; height: calc(100vh - 52px); overflow-y: auto;
  padding: 28px 16px; font-size: 13px;
}
.toc p { font-weight: 600; margin: 0 0 6px; color: var(--muted); }
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc a { color: var(--muted); display: block; padding: 2px 0; font-family: ui-monospace, Consolas, monospace; }

@media (max-width: 1200px) {
  .layout { grid-template-columns: 250px minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 800px) {
  .layout { display: block; }
  #menu { display: inline-block; }
  .sidebar {
    display: none; position: fixed; inset: 52px 0 0 0; z-index: 9; height: auto; border: 0;
  }
  body.nav-open .sidebar { display: block; }
  .content { padding: 20px 16px 60px; }
  table.fields td:first-child, table.fields td:nth-child(2), table.index td:first-child { white-space: normal; }
}
