
:root {
  --bg: #ffffff;
  --bg-soft: #f7f8fa;
  --bg-hover: #eef0f4;
  --bg-code: #f3f4f7;
  --bg-pre: #f6f8fa;
  --border: #e3e6eb;
  --text: #1b1f24;
  --text-soft: #4b5563;
  --text-muted: #6b7280;
  --accent: #6d4aff;
  --accent-soft: rgba(109, 74, 255, 0.1);
  --link: #5b3ae6;
  --hl-k: #c2185b;
  --hl-s: #0a7e3e;
  --hl-n: #b45309;
  --hl-c: #8a94a3;
  --hl-f: #4b3fd1;
  --t-prim: #0e7490;
  --realm-server: #2563eb;
  --realm-client: #d97706;
  --realm-menu: #059669;
  --realm-shared: #7c3aed;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-lg: 0 16px 40px rgba(16, 24, 40, 0.16);
  --topbar-h: 56px;
  --sidebar-w: 288px;
  --toc-w: 232px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0f1115;
  --bg-soft: #151820;
  --bg-hover: #1d212b;
  --bg-code: #1b1f28;
  --bg-pre: #161a22;
  --border: #262b36;
  --text: #e6e8ec;
  --text-soft: #b9bfca;
  --text-muted: #8b93a1;
  --accent: #9d86ff;
  --accent-soft: rgba(157, 134, 255, 0.14);
  --link: #a995ff;
  --hl-k: #ff7ab2;
  --hl-s: #7ee2a8;
  --hl-n: #fbbf6b;
  --hl-c: #6b7385;
  --hl-f: #a5b4fc;
  --t-prim: #67d4e8;
  --realm-server: #60a5fa;
  --realm-client: #fbbf24;
  --realm-menu: #34d399;
  --realm-shared: #c4b5fd;
  --shadow: none;
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--topbar-h) + 16px); }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
code, kbd, pre { font-family: var(--font-mono); }
kbd {
  font-size: 0.75em;
  padding: 0.1em 0.4em;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--bg-soft);
}

/* top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.25rem;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand {
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
  color: var(--text);
  white-space: nowrap;
  min-width: calc(var(--sidebar-w) - 2.25rem);
}
.brand:hover { text-decoration: none; }
.brand span { color: var(--accent); }
.brand small {
  margin-left: 0.5rem;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  vertical-align: middle;
}
.search-wrap { position: relative; flex: 1; max-width: 560px; }
.search-wrap input {
  width: 100%;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 4.5rem 0 0.85rem;
  font: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg-soft);
}
.search-wrap input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); background: var(--bg); }
.search-kbd { position: absolute; right: 0.6rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.search-results {
  display: none;
  position: absolute;
  left: 0; right: 0;
  top: calc(100% + 6px);
  max-height: min(70vh, 560px);
  overflow: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  padding: 0.35rem;
}
.search-results.open { display: block; }
.search-hit { display: block; padding: 0.5rem 0.65rem; border-radius: 7px; color: inherit; }
.search-hit:hover, .search-hit.sel { background: var(--accent-soft); text-decoration: none; }
.search-hit .hit-top { display: flex; align-items: baseline; gap: 0.5rem; }
.search-hit .hit-kind { font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); min-width: 4.2rem; }
.search-hit .hit-name { font-family: var(--font-mono); font-size: 0.85rem; font-weight: 600; }
.search-hit .hit-name mark { background: none; color: var(--accent); }
.search-hit .hit-sum { font-size: 0.8rem; color: var(--text-muted); margin-left: 4.7rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-empty { padding: 0.75rem; color: var(--text-muted); font-size: 0.85rem; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 0.5rem; }
.top-link { font-size: 0.88rem; color: var(--text-soft); font-weight: 500; }
.theme-toggle, .menu-toggle {
  width: 34px; height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text-soft);
  cursor: pointer;
  font-size: 1rem;
}
.theme-toggle::before { content: "☾"; }
[data-theme="dark"] .theme-toggle::before { content: "☀"; }
.menu-toggle { display: none; }

/* layout */
.layout { display: flex; align-items: flex-start; max-width: 1480px; margin: 0 auto; }
.sidebar {
  position: sticky;
  top: var(--topbar-h);
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 1rem 0.75rem 3rem;
  border-right: 1px solid var(--border);
  scrollbar-width: thin;
}
.content { flex: 1; min-width: 0; padding: 2rem 3rem 4rem; }
.page { max-width: 820px; }
.toc {
  position: sticky;
  top: var(--topbar-h);
  width: var(--toc-w);
  flex: 0 0 var(--toc-w);
  max-height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 2rem 1rem 2rem 0.5rem;
  font-size: 0.82rem;
  scrollbar-width: thin;
}
.toc-title { font-weight: 600; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 0.5rem; }
.toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border); }
.toc li a { display: block; padding: 0.18rem 0 0.18rem 0.75rem; margin-left: -1px; border-left: 2px solid transparent; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toc li.toc-l3 a { padding-left: 1.5rem; font-family: var(--font-mono); font-size: 0.78rem; }
.toc li a:hover { color: var(--text); text-decoration: none; }
.toc li a.current { color: var(--accent); border-left-color: var(--accent); }

/* navigation */
.nav-group { margin-bottom: 1rem; }
.nav-title { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-muted); padding: 0.35rem 0.5rem; }
.nav-tree { list-style: none; margin: 0; padding: 0; }
.nav-tree .nav-tree { margin-left: 0.75rem; padding-left: 0.3rem; border-left: 1px solid var(--border); }
.nav-item:not(.open) > .nav-tree { display: none; }
.nav-row { display: flex; align-items: center; border-radius: 6px; }
.nav-row > a, .nav-row > .nav-label {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.22rem 0.4rem;
  border-radius: 6px;
  color: var(--text-soft);
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
}
.nav-row > a span:last-child, .nav-row > .nav-label span:last-child { overflow: hidden; text-overflow: ellipsis; }
.nav-row > a:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.nav-row > a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-twist, .nav-twist-pad { flex: 0 0 18px; width: 18px; height: 22px; }
.nav-twist { border: 0; background: none; padding: 0; color: var(--text-muted); cursor: pointer; border-radius: 4px; }
.nav-twist::before { content: ""; display: inline-block; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform 0.15s; }
.nav-item.open > .nav-row > .nav-twist::before { transform: rotate(45deg); }
.nav-twist:hover { color: var(--text); background: var(--bg-hover); }
.nav-icon { flex: 0 0 auto; font-size: 0.6rem; font-weight: 700; width: 15px; height: 15px; line-height: 15px; text-align: center; border-radius: 4px; font-family: var(--font-mono); }
.nav-class { background: rgba(37, 99, 235, 0.14); color: var(--realm-server); }
.nav-type { background: rgba(5, 150, 105, 0.14); color: var(--realm-menu); }

/* page */
.crumbs { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 0.75rem; display: flex; flex-wrap: wrap; gap: 0.3rem; align-items: center; }
.crumbs a { color: var(--text-muted); }
.crumb-kind { font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; color: var(--accent); margin-right: 0.4rem; }
h1 { font-size: 2.1rem; line-height: 1.2; letter-spacing: -0.025em; margin: 0 0 0.6rem; font-weight: 700; word-break: break-word; }
h2 { font-size: 1.4rem; letter-spacing: -0.015em; margin: 2.6rem 0 0.9rem; padding-bottom: 0.4rem; border-bottom: 1px solid var(--border); font-weight: 650; }
h3 { font-size: 1.05rem; margin: 0; font-family: var(--font-mono); font-weight: 600; word-break: break-word; }
.page-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; margin-bottom: 1rem; }
.badge { display: inline-block; font-size: 0.7rem; font-weight: 600; padding: 0.1rem 0.5rem; border-radius: 999px; background: var(--bg-code); color: var(--text-muted); border: 1px solid var(--border); line-height: 1.5; }
.b-lib { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.b-class { color: var(--realm-server); background: rgba(37, 99, 235, 0.1); border-color: transparent; }
.b-type { color: var(--realm-menu); background: rgba(5, 150, 105, 0.1); border-color: transparent; }
.b-event { color: var(--realm-client); }
.b-async { color: var(--realm-shared); }
.b-warn { color: #b91c1c; background: rgba(220, 38, 38, 0.1); border-color: transparent; }
.realms { display: inline-flex; border-radius: 6px; overflow: hidden; border: 1px solid var(--border); vertical-align: middle; }
.realm { font-size: 0.66rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; padding: 0.08rem 0.42rem; line-height: 1.55; }
.realm + .realm { border-left: 1px solid var(--border); }
.realm-server { color: var(--realm-server); }
.realm-client { color: var(--realm-client); }
.realm-menu { color: var(--realm-menu); }
.realm-shared { color: var(--realm-shared); }
td .realms { margin-left: 0.4rem; }
.src-link { font-size: 0.75rem; color: var(--text-muted); margin-left: 0.25rem; }
.ancestry { font-family: var(--font-mono); font-size: 0.85rem; color: var(--text-muted); margin: 0 0 1rem; }
.ancestry strong { color: var(--text); }
.mixins { font-size: 0.82rem; }
.lead { font-size: 1.1rem; color: var(--text-soft); }
.hero { margin-bottom: 1.5rem; }
.stats { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 1.25rem 0 0.5rem; }
.stats div { flex: 1 1 120px; border: 1px solid var(--border); border-radius: 10px; padding: 0.75rem 1rem; background: var(--bg-soft); }
.stats strong { display: block; font-size: 1.5rem; letter-spacing: -0.02em; }
.stats span { color: var(--text-muted); font-size: 0.82rem; }
.empty { color: var(--text-muted); }

/* prose */
.prose { color: var(--text); }
.prose p { margin: 0.6rem 0; }
.prose h3, .prose h4, .prose h5, .prose h6 { font-family: var(--font); margin: 1.3rem 0 0.5rem; font-size: 1rem; }
.prose ul, .prose ol, ul.see { margin: 0.5rem 0 0.8rem; padding-left: 1.4rem; }
.prose li { margin: 0.2rem 0; }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 1.2rem 0; }
.prose a { text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--link) 40%, transparent); text-underline-offset: 2px; }
.prose a.code-link { text-decoration: none; }
:not(pre) > code, .code-link code {
  font-size: 0.86em;
  background: var(--bg-code);
  border: 1px solid var(--border);
  padding: 0.05em 0.35em;
  border-radius: 5px;
  overflow-wrap: break-word;
}
.code-link code { color: var(--link); }
.code-link:hover { text-decoration: none; }
.code-link:hover code { border-color: var(--accent); }
.hint { margin: 1rem 0; padding: 0.6rem 1rem; border-radius: 8px; border: 1px solid var(--border); border-left: 4px solid var(--accent); background: var(--bg-soft); }
.hint p { margin: 0.3rem 0; }
.hint-warning, .hint-caution { border-left-color: #d97706; }
.hint-important { border-left-color: #dc2626; }
.hint-tip { border-left-color: #059669; }

.code-block { margin: 0.9rem 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--bg-pre); }
.code-head { display: flex; justify-content: space-between; align-items: center; padding: 0.3rem 0.5rem 0.3rem 0.9rem; border-bottom: 1px solid var(--border); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
.copy-btn { font: inherit; font-size: 0.7rem; text-transform: none; letter-spacing: 0; border: 1px solid var(--border); background: var(--bg); color: var(--text-soft); border-radius: 5px; padding: 0.1rem 0.5rem; cursor: pointer; }
.code-block pre { margin: 0; padding: 0.85rem 1rem; overflow-x: auto; font-size: 0.84rem; line-height: 1.55; }
.hl-k { color: var(--hl-k); }
.hl-s, .t-str { color: var(--hl-s); }
.hl-n { color: var(--hl-n); }
.hl-c { color: var(--hl-c); font-style: italic; }
.hl-f { color: var(--hl-f); }
.t-prim { color: var(--t-prim); }
.t-link { color: var(--link); }

/* api blocks */
.sig { margin: 0.6rem 0; padding: 0.7rem 0.95rem; background: var(--bg-pre); border: 1px solid var(--border); border-radius: 8px; overflow-x: auto; font-size: 0.85rem; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.sig .s-name { font-weight: 600; }
.sig .s-param { color: var(--text-soft); }
.member { padding: 1.4rem 0 1.1rem; border-bottom: 1px solid var(--border); }
.member:last-child { border-bottom: 0; }
.member-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem; }
.member-tags { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
.member h3 { position: relative; }
.anchor { position: absolute; right: 100%; padding-right: 0.35em; color: var(--text-muted); opacity: 0; font-weight: 400; }
.member h3:hover .anchor, .anchor:focus { opacity: 1; text-decoration: none; }
.member:target { animation: flash 1.6s ease-out; }
@keyframes flash { from { background: var(--accent-soft); } to { background: transparent; } }
.sub-title { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin: 1rem 0 0.35rem; }
.alias-note { color: var(--text-muted); font-size: 0.9rem; }
.value { color: var(--text-muted); font-size: 0.85rem; white-space: nowrap; }
.opt { margin-left: 0.4rem; font-size: 0.68rem; color: var(--text-muted); font-style: italic; }

.table-wrap { overflow-x: auto; margin: 0.4rem 0 1rem; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.prose table th, .prose table td, table.api th, table.api td { text-align: left; padding: 0.5rem 0.7rem; border-bottom: 1px solid var(--border); vertical-align: top; }
table.api thead th, .prose table th { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); font-weight: 600; background: var(--bg-soft); }
table.api td:first-child { white-space: nowrap; }
table.api td:nth-child(2) { min-width: 6.5rem; }
table.api tr:target { background: var(--accent-soft); }
table.summary td:first-child { width: 1%; }
table.summary td { padding: 0.4rem 0.7rem; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0.75rem; margin: 0.75rem 0 1.5rem; }
.card { display: block; border: 1px solid var(--border); border-radius: 10px; padding: 0.8rem 1rem; color: inherit; background: var(--bg); box-shadow: var(--shadow); transition: border-color 0.12s, transform 0.12s; }
.card:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-1px); }
.card-kind { font-size: 0.64rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.k-library, .k-globals { color: var(--accent); }
.k-class { color: var(--realm-server); }
.k-type { color: var(--realm-menu); }
.card-title { font-family: var(--font-mono); font-weight: 600; margin: 0.15rem 0 0.25rem; word-break: break-word; }
.card-sum { font-size: 0.82rem; color: var(--text-muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

details.inherited { border: 1px solid var(--border); border-radius: 8px; margin: 0.5rem 0; background: var(--bg-soft); }
details.inherited summary { cursor: pointer; padding: 0.5rem 0.85rem; font-size: 0.9rem; }
details.inherited .count { font-size: 0.72rem; color: var(--text-muted); margin-left: 0.3rem; }
.inherited-list { padding: 0 0.85rem 0.7rem; display: flex; flex-wrap: wrap; gap: 0.35rem; }
.subclasses { font-family: var(--font-mono); font-size: 0.88rem; line-height: 1.9; }

.pager { display: flex; justify-content: space-between; gap: 1rem; max-width: 820px; margin-top: 3rem; }
.pager a { flex: 1; max-width: 50%; border: 1px solid var(--border); border-radius: 10px; padding: 0.75rem 1rem; color: var(--text); font-weight: 600; font-family: var(--font-mono); font-size: 0.9rem; word-break: break-word; }
.pager a span { display: block; font-family: var(--font); font-weight: 400; font-size: 0.75rem; color: var(--text-muted); }
.pager a:hover { border-color: var(--accent); text-decoration: none; }
.pager-next { text-align: right; margin-left: auto; }
.page-foot { max-width: 820px; margin-top: 2.5rem; padding-top: 1rem; border-top: 1px solid var(--border); font-size: 0.8rem; color: var(--text-muted); }

@media (max-width: 1240px) { .toc { display: none; } }
@media (max-width: 900px) {
  .menu-toggle { display: inline-block; }
  .brand { min-width: 0; }
  .search-kbd, .top-link { display: none; }
  .sidebar { position: fixed; left: 0; top: var(--topbar-h); z-index: 30; background: var(--bg); transform: translateX(-105%); transition: transform 0.2s ease; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .content { padding: 1.25rem 1.1rem 3rem; }
  h1 { font-size: 1.7rem; }
}
