/* ---------- Tokens ---------- */
:root {
  color-scheme: light;
  --bg: #ffffff;
  --bg-subtle: #faf9fb;
  --bg-muted: #f3f1f6;
  --border: #e7e4ec;
  --border-strong: #d6d1de;
  --text: #1c1a23;
  --text-2: #4a4655;
  --muted: #6b6677;
  --accent: #702da0;
  --accent-hover: #5d2386;
  --accent-tint: #f4ecfa;
  --on-accent: #ffffff;
  --info: #1d4ed8;
  --info-bg: #eff6ff;
  --info-border: #bfdbfe;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --warn-border: #fcd34d;
  --shadow: 0 1px 2px rgba(28, 26, 35, .06), 0 8px 24px rgba(28, 26, 35, .08);
  --header-h: 64px;
  --sidebar-w: 280px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "JetBrains Mono", "Cascadia Code", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #100e15;
  --bg-subtle: #15121b;
  --bg-muted: #1d1925;
  --border: #2a2533;
  --border-strong: #3a3347;
  --text: #ece9f2;
  --text-2: #cfc9db;
  --muted: #9d97ab;
  --accent: #c79bf0;
  --accent-hover: #d9b6f6;
  --accent-tint: #26192f;
  --on-accent: #1a0f24;
  --info: #93b4ff;
  --info-bg: #111a2e;
  --info-border: #223a6b;
  --warn: #f0b44c;
  --warn-bg: #2a2010;
  --warn-border: #6b4a12;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--header-h) + 24px); scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text-2);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent-tint); color: var(--text); }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: fixed; top: -56px; left: 16px; z-index: 100;
  padding: 8px 14px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
}
.skip:focus { top: 12px; }

/* ---------- Icons (Lucide + Octicons, inlined as a sprite) ---------- */
.ico {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.ico-fill { fill: currentColor; stroke: none; }

/* ---------- Header ---------- */
.header {
  position: fixed; inset: 0 0 auto 0; z-index: 30;
  height: var(--header-h);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
@supports (backdrop-filter: blur(8px)) {
  .header { background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: saturate(1.4) blur(10px); }
}
.header-inner { display: flex; align-items: center; gap: 16px; height: 100%; padding: 0 24px; }
.brand {
  display: flex; align-items: center; gap: 10px;
  color: var(--text); font-size: 17px; font-weight: 650; letter-spacing: -.01em; text-decoration: none;
}
.brand svg { display: block; }
.version {
  padding: 1px 8px; background: var(--bg-muted); border-radius: 999px;
  color: var(--muted); font-size: 12px; font-weight: 500;
}
.header-center { flex: 1; display: flex; justify-content: center; }
.search-btn {
  display: flex; align-items: center; gap: 10px;
  width: min(440px, 100%); height: 40px; padding: 0 10px 0 12px;
  background: var(--bg-subtle); border: 1px solid var(--border); border-radius: 10px;
  color: var(--muted); font-size: 14px;
  transition: border-color .15s, color .15s;
}
.search-btn:hover { border-color: var(--border-strong); color: var(--text); }
.search-text { flex: 1; text-align: left; }
.header-actions { display: flex; align-items: center; gap: 4px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; padding: 0;
  background: transparent; border: 0; border-radius: 8px; color: var(--muted);
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--bg-muted); color: var(--text); }
.icon-btn .ico { width: 20px; height: 20px; }
.menu-btn { display: none; }
.theme-btn .icon-sun { display: none; }
:root[data-theme="dark"] .theme-btn .icon-sun { display: block; }
:root[data-theme="dark"] .theme-btn .icon-moon { display: none; }
kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; padding: 0 6px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  color: var(--muted); font-family: var(--font); font-size: 12px; line-height: 20px;
}
kbd .ico { width: 12px; height: 12px; }

/* ---------- Sidebar ---------- */
#sidebar {
  position: fixed; top: var(--header-h); bottom: 0; left: 0; z-index: 10;
  width: var(--sidebar-w); padding: 24px 16px 40px; overflow-y: auto;
  background: var(--bg); border-right: 1px solid var(--border);
  scrollbar-width: thin;
}
.nav-title { margin: 20px 10px 6px; color: var(--text); font-size: 13px; font-weight: 650; line-height: 1.4; }
.nav-title:first-child { margin-top: 0; }
#sidebar a {
  display: flex; align-items: center; gap: 10px;
  min-height: 36px; padding: 7px 10px; margin: 1px 0; border-radius: 8px;
  line-height: 1.4;
  color: var(--text-2); font-size: 14px; font-weight: 500; text-decoration: none;
  transition: background .15s, color .15s;
}
#sidebar a .ico { flex-shrink: 0; width: 16px; height: 16px; color: var(--muted); stroke-width: 1.85; }
#sidebar a:hover { background: var(--bg-muted); color: var(--text); }
#sidebar a.active { background: var(--accent-tint); color: var(--accent); }
#sidebar a.active .ico { color: var(--accent); }
.scrim { position: fixed; inset: var(--header-h) 0 0 0; z-index: 9; background: rgba(0, 0, 0, .45); }

/* ---------- Content ---------- */
main { margin-left: var(--sidebar-w); padding: calc(var(--header-h) + 48px) 56px 80px; }
article { max-width: 780px; margin: 0 auto; }
h1, h2, h3 { color: var(--text); line-height: 1.25; }
h1 { margin: 0 0 14px; font-size: 40px; font-weight: 700; letter-spacing: -.025em; }
h2 { margin: 64px 0 16px; font-size: 28px; font-weight: 650; letter-spacing: -.02em; }
h3 { margin: 36px 0 12px; font-size: 20px; font-weight: 600; letter-spacing: -.01em; }
p { margin: 0 0 16px; }
.lead { max-width: 640px; margin: 0 0 20px; color: var(--text-2); font-size: 19px; line-height: 1.6; }
ul, ol { margin: 0 0 16px; padding-left: 1.5em; }
li { margin: 6px 0; padding-left: 4px; }
li::marker { color: var(--muted); }
strong { color: var(--text); font-weight: 600; }
.anchor { margin-left: .4em; color: var(--muted); font-weight: 400; text-decoration: none; opacity: 0; }
.anchor::before { content: "#"; }
h2:hover .anchor, h3:hover .anchor, .anchor:focus-visible { opacity: 1; }
.caption { margin: -4px 0 20px; color: var(--muted); font-size: 14px; }

/* Page intro */
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 0 0 40px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 42px; padding: 0 18px; border-radius: 10px;
  font-size: 14px; font-weight: 600; text-decoration: none;
  transition: background .15s, border-color .15s;
}
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg); border: 1px solid var(--border-strong); color: var(--text); }
.btn-secondary:hover { background: var(--bg-subtle); }

.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.card {
  display: flex; flex-direction: column; gap: 12px; padding: 18px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 12px;
  color: inherit; text-decoration: none;
  transition: border-color .15s, box-shadow .15s;
}
.card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.card-title { display: block; color: var(--text); font-size: 15px; font-weight: 600; line-height: 1.4; }
.card-text { display: block; margin-top: 2px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.icon-tile {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 36px; height: 36px; background: var(--accent-tint); border-radius: 8px; color: var(--accent);
}
.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; margin: 0 0 16px; }
.feature { display: flex; flex-direction: column; gap: 12px; }
.feature h3 { margin: 0 0 4px; font-size: 16px; font-weight: 600; letter-spacing: 0; }
.feature p { margin: 0; font-size: 15px; line-height: 1.6; }

/* Code */
code { font-family: var(--mono); font-size: .875em; }
:not(pre) > code {
  padding: .12em .4em; background: var(--bg-muted); border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); overflow-wrap: anywhere;
}
.code-block { margin: 0 0 16px; overflow: hidden; background: var(--bg-subtle); border: 1px solid var(--border); border-radius: 12px; }
.code-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 6px 8px 6px 14px; background: var(--bg-muted); border-bottom: 1px solid var(--border);
}
.code-lang { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; font-weight: 500; }
.code-lang .ico { width: 14px; height: 14px; }
.copy-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px;
  background: transparent; border: 1px solid transparent; border-radius: 6px;
  color: var(--muted); font-size: 12px; font-weight: 500;
  transition: background .15s, color .15s, border-color .15s;
}
.copy-btn .ico { width: 14px; height: 14px; }
.copy-btn:hover { background: var(--bg); border-color: var(--border); color: var(--text); }
.copy-btn.copied { color: var(--accent); }
pre { margin: 0; padding: 16px 18px; overflow-x: auto; color: var(--text); font-size: 13.5px; line-height: 1.65; tab-size: 4; }
pre code { padding: 0; background: none; border: 0; font-size: inherit; }

/* Tables */
.table-wrap { margin: 0 0 20px; overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; text-align: left; }
th { padding: 11px 16px; background: var(--bg-subtle); color: var(--text); font-weight: 600; white-space: nowrap; }
td { padding: 11px 16px; border-top: 1px solid var(--border); vertical-align: top; }
tbody tr:hover { background: var(--bg-subtle); }

/* Callouts */
.callout {
  display: flex; gap: 12px; margin: 0 0 20px; padding: 14px 16px;
  border: 1px solid var(--info-border); border-radius: 12px; background: var(--info-bg);
}
.callout > .ico { margin-top: 3px; color: var(--info); }
.callout p { margin: 0; font-size: 15px; line-height: 1.6; }
.callout-title { margin-bottom: 2px !important; color: var(--info); font-weight: 600; }
.callout-warning { border-color: var(--warn-border); background: var(--warn-bg); }
.callout-warning > .ico, .callout-warning .callout-title { color: var(--warn); }

/* Footer */
.page-footer {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 24px;
  max-width: 780px; margin: 72px auto 0; padding-top: 24px;
  border-top: 1px solid var(--border); color: var(--muted); font-size: 14px;
}
.page-footer p { margin: 0; }
.page-footer a { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); text-decoration: none; }
.page-footer a:hover { color: var(--text); }

/* ---------- Search dialog ---------- */
dialog {
  width: min(640px, calc(100vw - 32px)); max-height: min(560px, 78vh);
  margin: 11vh auto auto; padding: 0; overflow: hidden;
  background: var(--bg); color: var(--text-2);
  border: 1px solid var(--border-strong); border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, .3);
}
dialog[open] { display: flex; flex-direction: column; }
dialog::backdrop { background: rgba(10, 8, 14, .55); backdrop-filter: blur(2px); }
.search-head { display: flex; align-items: center; gap: 12px; padding: 0 18px; border-bottom: 1px solid var(--border); color: var(--muted); }
.search-head .ico { width: 20px; height: 20px; }
#search-input {
  flex: 1; min-width: 0; height: 58px; padding: 0;
  background: transparent; border: 0; outline: 0; color: var(--text); font-size: 17px;
}
#search-input::placeholder { color: var(--muted); }
#search-input::-webkit-search-cancel-button { display: none; }
#search-results { margin: 0; padding: 8px; overflow-y: auto; list-style: none; }
#search-results:empty { display: none; }
#search-results li { margin: 0; padding: 0; }
#search-results a {
  display: flex; align-items: flex-start; gap: 12px; padding: 10px 12px; border-radius: 10px;
  color: var(--text); text-decoration: none;
}
#search-results li[aria-selected="true"] a { background: var(--accent-tint); }
.result-icon {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 32px; height: 32px; background: var(--bg-muted); border-radius: 8px; color: var(--muted);
}
.result-icon .ico { width: 16px; height: 16px; }
li[aria-selected="true"] .result-icon { background: var(--bg); color: var(--accent); }
.result-text { min-width: 0; }
.result-title { font-size: 15px; font-weight: 600; }
.result-section { margin-left: 8px; color: var(--muted); font-size: 12px; font-weight: 400; }
.result-snippet { display: block; margin-top: 2px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.result-snippet mark { background: none; color: var(--accent); font-weight: 600; }
.search-hint { margin: 0; padding: 20px 18px; color: var(--muted); font-size: 14px; }
.search-foot {
  display: flex; gap: 20px; padding: 10px 18px; background: var(--bg-subtle); border-top: 1px solid var(--border);
  color: var(--muted); font-size: 12px;
}
.search-foot span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .header-inner { padding: 0 12px; gap: 8px; }
  .menu-btn { display: inline-flex; }
  .header-center { justify-content: flex-end; }
  .search-btn { width: 38px; height: 38px; padding: 0; justify-content: center; background: transparent; border-color: transparent; }
  .search-text, .search-btn kbd { display: none; }
  #sidebar { display: none; width: 300px; max-width: 86vw; box-shadow: 8px 0 32px rgba(0, 0, 0, .2); }
  #sidebar.open { display: block; z-index: 15; }
  main { margin-left: 0; padding: calc(var(--header-h) + 28px) 20px 56px; }
  h1 { font-size: 34px; }
  h2 { margin-top: 52px; font-size: 24px; }
  .features { grid-template-columns: 1fr; gap: 20px; }
  .search-foot { display: none; }
}
@media (max-width: 540px) {
  .cards { grid-template-columns: 1fr; }
  .version { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
@media print {
  .header, #sidebar, .scrim, .copy-btn, .anchor, .actions { display: none !important; }
  main { margin: 0; padding: 0; }
  pre { white-space: pre-wrap; }
}


/* Project artwork and finishing touches */
.doc-banner { margin: 0 0 32px; border-radius: 18px; overflow: hidden; background: #1b0c31; box-shadow: 0 12px 32px #32104c12; }
.doc-banner img { display: block; width: 100%; height: auto; }
.header .brand > svg { box-shadow: 0 3px 10px #702da025; border-radius: 8px; }
.cards { margin-top: 8px; }
.card { background: linear-gradient(145deg, var(--bg), var(--bg-subtle)); }
.card:hover { transform: translateY(-2px); }
.card .icon-tile { border: 1px solid color-mix(in srgb, var(--accent) 12%, transparent); }
.card { transition: border-color .18s, box-shadow .18s, transform .18s; }
h2 { padding-top: 30px; border-top: 1px solid var(--border); }
.features { padding: 6px 0; }
.btn-primary { box-shadow: 0 4px 12px #702da01a; }
.header-actions { padding-left: 12px; border-left: 1px solid var(--border); }
.attribution { flex-basis: 100%; margin: 8px 0 0!important; color: var(--muted); font-size: 12px; }
.attribution a { display: inline; color: inherit; text-decoration: underline; }
.footer-dot { margin: 0 8px; color: var(--border-strong); }
@media(min-width:1400px) { main { padding-left: 72px; padding-right: 72px; } article,.page-footer { max-width: 860px; } }
@media(max-width:540px) { .doc-banner { margin-bottom: 26px; border-radius: 14px; } .header-actions { padding-left: 4px; border: 0; } .actions { gap: 8px; } .btn { padding: 0 13px; font-size: 13px; } .lead { font-size: 17px; } }
@media(prefers-reduced-motion:reduce) { .card:hover { transform: none; } }

/* Shared grouped reference tables. */
.code-section + .code-section { margin-top: 32px; }
.code-heading { margin-bottom: 12px; }
.code-heading h3 { margin: 0; font-size: 17px; }
.code-section .table-wrap { margin: 0; }
#command-groups th:first-child { width: 30%; }

/* Action headings within documentation topics. */
h4 { margin: 28px 0 8px; color: var(--text); font-size: 16px; font-weight: 650; line-height: 1.4; }

/* ---------- Syntax highlighting ---------- */
:root {
  --syntax-command: #702da0;
  --syntax-option: #1859a8;
  --syntax-string: #147347;
  --syntax-number: #9a4700;
  --syntax-comment: #6b6677;
}
:root[data-theme="dark"] {
  --syntax-command: #d5a6ff;
  --syntax-option: #8abaff;
  --syntax-string: #86d6a5;
  --syntax-number: #ffc080;
  --syntax-comment: #aaa3b8;
}
.syntax-command, .syntax-keyword { color: var(--syntax-command); }
.syntax-option, .syntax-key { color: var(--syntax-option); }
.syntax-string { color: var(--syntax-string); }
.syntax-number { color: var(--syntax-number); }
.syntax-comment { color: var(--syntax-comment); font-style: italic; }
.syntax-parameter { color: var(--syntax-option); }

/* ---------- Response codes ---------- */
#codes-view > h2:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
#code-rows th:first-child { width: 130px; }
#code-rows td:first-child { white-space: nowrap; }
#code-rows tr[data-prefix] { scroll-margin-top: calc(var(--header-h) + 24px); }
#code-rows tr:target td { background: var(--accent-tint); }
