/* =========================================================================
   dm-champ-docs-generator — base theme
   Light mode only in v0.1. Tunable via CSS variables set at build time.
   ========================================================================= */

:root {
  /* Brand — overridden per-tenant via <style> in <head> */
  --brand-primary: #25D366;
  --brand-accent: #128C7E;
  --brand-font: "Inter", system-ui, -apple-system, sans-serif;
  --brand-font-display: "Space Grotesk", var(--brand-font);
  --brand-font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Surfaces */
  --surface-0: #ffffff;
  --surface-1: #fafbfc;
  --surface-2: #f4f6f8;
  --surface-3: #eef1f4;

  /* Text */
  --text-strong: #0b1020;
  --text-body: #1f2937;
  --text-muted: #5c6373;
  --text-subtle: #8a93a6;

  /* Borders */
  --border-subtle: rgba(15, 23, 42, 0.06);
  --border-default: rgba(15, 23, 42, 0.1);
  --border-strong: rgba(15, 23, 42, 0.16);

  /* Radii */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-pill: 999px;

  /* Elevation */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06), 0 2px 8px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.06), 0 12px 36px rgba(15, 23, 42, 0.04);

  /* Layout */
  --topbar-h: 72px;
  --sidebar-w: 272px;
  --toc-w: 220px;
  --content-max: 780px;

  /* Motion */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

* , *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--brand-font);
  font-size: 16px;
  line-height: 1.7;
  color: var(--text-body);
  background: var(--surface-0);
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Grid backdrop — soft radial mask keeps content legible while giving the
   page texture. Fixed so it stays put on scroll. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(15, 23, 42, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 23, 42, 0.055) 1px, transparent 1px);
  background-size: 52px 52px;
  -webkit-mask-image: radial-gradient(ellipse 90% 80% at 50% 20%, black 10%, transparent 85%);
  mask-image: radial-gradient(ellipse 90% 80% at 50% 20%, black 10%, transparent 85%);
  pointer-events: none;
  z-index: 0;
}

/* Soft tint that picks up the brand color behind the hero area. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 40% at 50% -5%, color-mix(in srgb, var(--brand-primary) 9%, transparent) 0%, transparent 60%),
    radial-gradient(ellipse 40% 30% at 85% 10%, color-mix(in srgb, var(--brand-accent) 7%, transparent) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(15, 23, 42, 0.15);
  border-radius: 999px;
  border: 2px solid var(--surface-0);
}
::-webkit-scrollbar-thumb:hover { background: rgba(15, 23, 42, 0.28); }

::selection { background: color-mix(in srgb, var(--brand-primary) 22%, transparent); }

a { color: var(--brand-primary); text-decoration: none; transition: color 0.15s var(--ease); }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* =========================================================================
   Layout
   ========================================================================= */

.layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  height: var(--topbar-h);
  padding: 0 28px;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border-subtle);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-strong);
  font-family: var(--brand-font-display);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.02em;
}

.brand:hover { text-decoration: none; }

/* CSS-painted logo (was an <img>). The image is fetched as a CSS background
   instead of via a replaced element, which avoids the per-navigation flicker
   you get when an <img> is created with src="" and only swapped to the real
   URL once JS runs. --brand-logo-url is set synchronously in the head script
   and combined with a <link rel="preload"> so the image is in cache before
   the body paints. Fixed width (140px) reserves layout so neighboring
   elements never reflow when the image arrives. */
.brand-logo {
  display: inline-block;
  height: 26px;
  width: 140px;
  background-image: var(--brand-logo-url, none);
  background-repeat: no-repeat;
  background-position: left center;
  background-size: contain;
}
html[data-no-logo] .brand-logo { display: none; }

/* Brand-name visibility is gated by an html attribute set synchronously in
   the head script BEFORE the brand-name element is parsed. A reactive sibling
   selector (.brand-logo:not([hidden]) ~ .brand-name) would only update after
   the MutationObserver removes `hidden`, one microtask too late, producing a
   visible "AppName Docs" flicker between paint and swap on cached nav. */
.brand-name { white-space: nowrap; display: none; }
html[data-no-logo] .brand-name { display: inline; }

.topnav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  margin-left: 24px;
}

.topnav-link {
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  border-radius: var(--r-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  transition: background 0.12s var(--ease), color 0.12s var(--ease);
}

.topnav-link:hover {
  background: var(--surface-2);
  color: var(--text-strong);
  text-decoration: none;
}

.topnav-link-active {
  color: var(--brand-primary);
  background: color-mix(in srgb, var(--brand-primary) 10%, transparent);
}

.topbar-right { display: flex; align-items: center; gap: 12px; }

/* ===== Search trigger — reads like a filled input even though it's a button ===== */
.search-trigger {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: 280px;
  height: 36px;
  padding: 0 10px 0 12px;
  background: var(--surface-1);
  border: 1px solid var(--border-default);
  border-radius: var(--r-md);
  color: var(--text-subtle);
  font-family: inherit;
  font-size: 14px;
  font-weight: 400;
  text-align: left;
  cursor: pointer;
  transition:
    background 0.12s var(--ease),
    border-color 0.12s var(--ease),
    color 0.12s var(--ease),
    box-shadow 0.12s var(--ease);
}

.search-trigger:hover {
  background: var(--surface-0);
  border-color: var(--border-strong);
  color: var(--text-body);
  box-shadow: var(--shadow-xs);
}

.search-trigger:focus-visible {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-primary) 18%, transparent);
}

.search-trigger-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--text-subtle);
}

.search-trigger-label {
  flex: 1;
  font-weight: 400;
}

.search-trigger-kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 22px;
  padding: 0 6px;
  font-family: var(--brand-font);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-subtle);
  background: var(--surface-0);
  border: 1px solid var(--border-default);
  border-radius: 5px;
  box-shadow: inset 0 -1px 0 rgba(15, 23, 42, 0.06);
}

@media (max-width: 1100px) {
  .search-trigger { width: 220px; }
}

@media (max-width: 820px) {
  .search-trigger {
    width: 36px;
    padding: 0;
    justify-content: center;
  }
  .search-trigger-label,
  .search-trigger-kbd { display: none; }
}

/* ===== Search modal ===== */
.search-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: min(12vh, 96px) 20px 20px;
}

.search-modal[hidden] { display: none; }

.search-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(11, 16, 32, 0.45);
  backdrop-filter: blur(6px) saturate(160%);
  -webkit-backdrop-filter: blur(6px) saturate(160%);
  animation: searchBackdropIn 0.18s var(--ease);
}

.search-modal-panel {
  position: relative;
  width: 100%;
  max-width: 640px;
  background: var(--surface-0);
  border: 1px solid var(--border-default);
  border-radius: var(--r-lg);
  box-shadow:
    0 20px 50px rgba(15, 23, 42, 0.25),
    0 6px 16px rgba(15, 23, 42, 0.08);
  overflow: hidden;
  animation: searchPanelIn 0.22s var(--ease);
}

@keyframes searchBackdropIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes searchPanelIn {
  from { opacity: 0; transform: translateY(-8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Pagefind UI — theme to match our CSS vars. */
.search-modal-panel .pagefind-ui {
  --pagefind-ui-primary: var(--brand-primary);
  --pagefind-ui-text: var(--text-body);
  --pagefind-ui-background: var(--surface-0);
  --pagefind-ui-border: var(--border-subtle);
  --pagefind-ui-tag: var(--surface-2);
  --pagefind-ui-border-width: 1px;
  --pagefind-ui-border-radius: 10px;
  --pagefind-ui-font: var(--brand-font);
  padding: 10px 14px 14px;
}

.search-modal-panel .pagefind-ui__form::before {
  background-color: var(--text-subtle) !important;
  opacity: 0.85;
}

.search-modal-panel .pagefind-ui__search-input {
  font-size: 16px;
  font-family: var(--brand-font);
  background: transparent;
  border: none;
  padding: 14px 14px 14px 40px;
  border-bottom: 1px solid var(--border-subtle);
  border-radius: 0;
  color: var(--text-strong);
}

.search-modal-panel .pagefind-ui__search-input:focus {
  outline: none;
  box-shadow: none;
}

.search-modal-panel .pagefind-ui__search-clear {
  color: var(--text-subtle);
}

.search-modal-panel .pagefind-ui__results-area {
  max-height: min(60vh, 520px);
  overflow-y: auto;
  padding: 8px 2px;
}

.search-modal-panel .pagefind-ui__message {
  font-size: 13px;
  color: var(--text-subtle);
  padding: 14px 16px;
}

.search-modal-panel .pagefind-ui__result {
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 12px 14px;
  margin: 4px 0;
  transition: background 0.12s var(--ease), border-color 0.12s var(--ease);
}

.search-modal-panel .pagefind-ui__result:hover {
  background: var(--surface-1);
  border-color: var(--border-subtle);
}

.search-modal-panel .pagefind-ui__result-title {
  font-family: var(--brand-font-display);
  font-weight: 600;
  font-size: 15px;
  color: var(--text-strong);
}

.search-modal-panel .pagefind-ui__result-excerpt {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.55;
}

.search-modal-panel .pagefind-ui__result-excerpt mark {
  background: color-mix(in srgb, var(--brand-primary) 22%, transparent);
  color: var(--text-strong);
  border-radius: 3px;
  padding: 0 2px;
}

body.page-openapi .search-trigger { display: none; }


.topbar-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 18px;
  border-radius: var(--r-pill);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: #ffffff;
  background: linear-gradient(180deg, color-mix(in srgb, var(--brand-primary) 92%, white) 0%, var(--brand-primary) 100%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    inset 0 -1px 0 rgba(0, 0, 0, 0.1),
    0 1px 2px rgba(0, 0, 0, 0.12),
    0 4px 12px color-mix(in srgb, var(--brand-primary) 28%, transparent);
  transition:
    transform 0.15s var(--ease),
    box-shadow 0.15s var(--ease),
    filter 0.15s var(--ease);
}

.topbar-link:hover {
  text-decoration: none;
  filter: brightness(1.08);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.26),
    inset 0 -1px 0 rgba(0, 0, 0, 0.1),
    0 2px 4px rgba(0, 0, 0, 0.12),
    0 8px 24px color-mix(in srgb, var(--brand-primary) 34%, transparent);
}

.topbar-link:active {
  transform: scale(0.98);
  filter: brightness(0.95);
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.2),
    0 1px 2px rgba(0, 0, 0, 0.15);
}

.shell {
  flex: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  max-width: 1480px;
  width: 100%;
  margin: 0 auto;
}

/* =========================================================================
   Sidebar
   ========================================================================= */

.sidebar {
  padding: 28px 12px 48px 24px;
  position: sticky;
  top: var(--topbar-h);
  align-self: start;
  max-height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  scrollbar-gutter: stable;
  font-size: 14px;
}

.nav-section + .nav-section { margin-top: 22px; }

.nav-section-title {
  font-family: var(--brand-font-display);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-subtle);
  font-weight: 600;
  padding: 0 10px 10px;
}

.nav-list { list-style: none; margin: 0; padding: 0; }

.nav-list .nav-list {
  margin: 2px 0 4px 10px;
  padding-left: 8px;
  border-left: 1px solid var(--border-subtle);
}

.nav-item > a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  color: var(--text-muted);
  line-height: 1.45;
  transition: background 0.12s var(--ease), color 0.12s var(--ease);
}

.nav-item > a:hover {
  background: var(--surface-2);
  color: var(--text-strong);
  text-decoration: none;
}

.nav-item-active > a {
  background: color-mix(in srgb, var(--brand-primary) 10%, transparent);
  color: var(--brand-primary);
  font-weight: 500;
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  color: var(--text-subtle);
  transition: color 0.12s var(--ease);
}
.nav-item > a:hover .nav-icon { color: var(--text-strong); }
.nav-item-active > a .nav-icon { color: var(--brand-primary); }
.nav-item-label { min-width: 0; }
/* Nested items (children of a top-level nav-item) skip the icon column so
   they align with their parent's label, matching GitBook's two-tier feel. */
.nav-list .nav-list .nav-item > a { gap: 0; }

/* =========================================================================
   Content
   ========================================================================= */

.content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--toc-w);
  gap: 56px;
  padding: 48px 56px 96px;
}

.page {
  min-width: 0;
  max-width: var(--content-max);
}

.page h1,
.page h2,
.page h3,
.page h4 {
  font-family: var(--brand-font-display);
  color: var(--text-strong);
  text-wrap: balance;
  letter-spacing: -0.025em;
  /* Anchor link for each heading is placed before the heading text in
     markup; pulling it out of flow via `position: absolute` keeps the
     heading itself flush-left with body copy instead of visibly indented. */
  position: relative;
}

.page h1 {
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1.1;
  margin: 0 0 0.6em;
  background: linear-gradient(180deg, var(--text-strong) 0%, color-mix(in srgb, var(--text-strong) 70%, var(--brand-primary)) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.page h2 {
  font-size: 1.55rem;
  font-weight: 650;
  line-height: 1.25;
  margin: 2.25em 0 0.5em;
  scroll-margin-top: calc(var(--topbar-h) + 16px);
}

.page h3 {
  font-size: 1.18rem;
  font-weight: 600;
  line-height: 1.35;
  margin: 1.75em 0 0.5em;
  scroll-margin-top: calc(var(--topbar-h) + 16px);
}

.page h4 {
  font-size: 1rem;
  font-weight: 600;
  margin: 1.5em 0 0.4em;
}

.page p, .page ul, .page ol { margin: 0 0 1.1em; }

.page ul, .page ol { padding-left: 1.4em; }
.page li { margin-bottom: 0.35em; }
.page li::marker { color: var(--text-subtle); }

.page strong { color: var(--text-strong); font-weight: 600; }

.page hr {
  border: none;
  border-top: 1px solid var(--border-default);
  margin: 2.5em 0;
}

/* Inline code */
.page :not(pre) > code {
  font-family: var(--brand-font-mono);
  font-size: 0.88em;
  background: var(--surface-2);
  color: var(--text-strong);
  padding: 0.15em 0.4em;
  border-radius: 5px;
  border: 1px solid var(--border-subtle);
}

/* Fenced code blocks (shiki) */
.page pre {
  position: relative;
  margin: 1.25em 0;
  padding: 18px 20px;
  border-radius: var(--r-md);
  overflow-x: auto;
  background: #f6f8fa !important;
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-xs);
  font-size: 0.88rem;
  line-height: 1.65;
}

.page pre code {
  background: transparent;
  border: none;
  padding: 0;
  font-family: var(--brand-font-mono);
  color: inherit;
}

.page pre .shiki { background: transparent !important; }

/* Shiki dual-theme renders each span with `--shiki-light` / `--shiki-dark`
   custom props but no `color` declaration — it expects the consumer to map
   one variant to `color`. Map the light-theme foreground; without this,
   tokens with no inline style (and the wrapper `<pre>` itself) inherit
   the page text color. */
.page pre.shiki,
.page pre.shiki span { color: var(--shiki-light); }

/* Headings anchor icon (markdown-it-anchor ariaHidden) — positioned in the
   left margin without taking flow space, so the heading text stays flush
   with body copy. */
.heading-anchor {
  position: absolute;
  right: 100%;
  padding-right: 8px;
  color: var(--text-subtle);
  opacity: 0;
  transition: opacity 0.15s var(--ease);
  font-weight: 400;
  text-decoration: none;
}
.page h1:hover .heading-anchor,
.page h2:hover .heading-anchor,
.page h3:hover .heading-anchor,
.page h4:hover .heading-anchor { opacity: 1; }
.page h1:hover .heading-anchor { -webkit-text-fill-color: var(--text-subtle); }

/* Tables */
.page table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 1.25em 0;
  font-size: 0.95em;
  border: 1px solid var(--border-default);
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}

.page th, .page td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  text-align: left;
  vertical-align: top;
}
.page tr:last-child td { border-bottom: none; }

.page th {
  background: var(--surface-1);
  font-weight: 600;
  font-size: 0.85em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.page tbody tr:hover td { background: var(--surface-1); }

/* Blockquotes (fallback — most are upgraded to callouts) */
.page blockquote {
  margin: 1.25em 0;
  padding: 12px 18px;
  background: var(--surface-1);
  border-left: 3px solid var(--brand-primary);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  color: var(--text-muted);
}
.page blockquote p:last-child { margin-bottom: 0; }

/* Images */
.page img {
  max-width: 100%;
  border-radius: var(--r-md);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-sm);
}

/* =========================================================================
   Callouts (from markdown-it-container)
   ========================================================================= */

.callout {
  --cal-color: var(--brand-primary);
  position: relative;
  margin: 1.5em 0;
  padding: 16px 18px 16px 48px;
  border-radius: var(--r-md);
  background: var(--surface-1);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-xs);
}

.callout::before {
  content: "";
  position: absolute;
  left: 16px;
  top: 18px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--cal-color);
  opacity: 0.15;
}

.callout::after {
  content: "";
  position: absolute;
  left: 22px;
  top: 24px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cal-color);
}

.callout p:last-child { margin-bottom: 0; }
.callout strong { color: var(--text-strong); }

.callout-info,
.callout-note { --cal-color: #3b82f6; }
.callout-tip { --cal-color: #10b981; }
.callout-warning { --cal-color: #f59e0b; }
.callout-danger { --cal-color: #ef4444; }

/* =========================================================================
   TOC (right rail)
   ========================================================================= */

.toc {
  position: sticky;
  top: calc(var(--topbar-h) + 16px);
  align-self: start;
  max-height: calc(100vh - var(--topbar-h) - 32px);
  overflow-y: auto;
  font-size: 13px;
  padding-left: 12px;
  border-left: 1px solid var(--border-subtle);
}

.toc-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--brand-font-display);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-subtle);
  font-weight: 600;
  margin-bottom: 12px;
  padding-left: 2px;
}
.toc-title svg { width: 14px; height: 14px; flex: 0 0 14px; }

.toc-list { list-style: none; padding: 0; margin: 0; }

.toc-item a {
  display: block;
  padding: 4px 10px;
  border-radius: var(--r-sm);
  color: var(--text-muted);
  line-height: 1.45;
  transition: background 0.12s var(--ease), color 0.12s var(--ease);
}

.toc-item a:hover {
  background: var(--surface-2);
  color: var(--text-strong);
  text-decoration: none;
}

.toc-item.is-active > a {
  background: color-mix(in srgb, var(--brand-primary) 10%, transparent);
  color: var(--brand-primary);
  font-weight: 500;
}

.toc-level-3 a { padding-left: 22px; font-size: 12px; }

/* =========================================================================
   OpenAPI / Scalar
   ========================================================================= */

/* OpenAPI pages go edge-to-edge — Scalar owns the full width and brings
   its own left sidebar. */
.shell-openapi {
  grid-template-columns: 1fr;
  max-width: none;
}

.content-openapi {
  display: block;
  gap: 0;
  padding: 0;
}

body.page-openapi::before,
body.page-openapi::after { display: none; }

.api-reference-wrapper .dark-mode-toggle,
.api-reference-wrapper [data-testid="theme-picker"],
.api-reference-wrapper .scalar-app-layout .darklight,
.api-reference-wrapper .darklight-reference,
.api-reference-wrapper .t-doc__sidebar-theme-toggle { display: none !important; }

.api-reference-wrapper {
  --scalar-color-accent: var(--brand-primary);
  --scalar-color-1: var(--text-strong);
  --scalar-color-2: var(--text-body);
  --scalar-color-3: var(--text-muted);
  --scalar-background-1: var(--surface-0);
  --scalar-background-2: var(--surface-1);
  --scalar-background-3: var(--surface-2);
  --scalar-border-color: var(--border-default);
  --scalar-radius: var(--r-md);
  --scalar-radius-lg: var(--r-lg);
  --scalar-font: var(--brand-font);
  --scalar-font-code: var(--brand-font-mono);
  --scalar-button-1: var(--brand-primary);
  --scalar-button-1-color: #ffffff;
  --scalar-button-1-hover: color-mix(in srgb, var(--brand-primary) 88%, black);
  min-height: calc(100vh - var(--topbar-h));
}

/* =========================================================================
   Embed mode
   ========================================================================= */

.embed .toc { display: none; }

/* Keep the topbar visible in embed mode but slim it down to just the
   space-switcher tabs (Docs / API Reference / Changelog). The agency app
   already supplies its own brand chrome around the iframe, so the tabs are
   the only piece that genuinely belongs inside the embed. Shrinking
   --topbar-h keeps sidebar sticky offsets and scroll-margin-top in sync. */
.embed { --topbar-h: 48px; }
.embed .topbar {
  padding: 0 16px;
  background: var(--surface-1);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.embed .topbar .brand { display: none; }
/* Keep the search trigger visible inside the embed — agencies asked for it
   even though the iframe sits inside their app chrome. The "Open <app>"
   link is still hidden because it would punt users out of the embed. */
.embed .topbar .topbar-right { display: flex; }
.embed .topbar .topbar-link { display: none; }
.embed .topbar .search-trigger {
  height: 32px;
  font-size: 13px;
}
.embed .topbar .search-trigger-label { display: none; }
.embed .topbar .search-trigger-kbd { display: none; }
.embed .topnav { margin-left: 0; }

.embed body::before { display: none; }

.embed .shell { grid-template-columns: 240px 1fr; }
/* OpenAPI pages don't render a sidebar — restore the single-column track
   the base `.shell-openapi` rule sets, otherwise the lone `<main>` lands
   in the 240px-wide sidebar slot and the spec wraps to ~10px wide. */
.embed .shell-openapi { grid-template-columns: 1fr; }

.embed .content {
  grid-template-columns: minmax(0, 1fr);
  padding: 28px 36px 56px;
}
.embed .content-openapi { padding: 0; }

/* =========================================================================
   Page-actions toolbar (top-right of every content page)
   ========================================================================= */

/* The toolbar is rendered as the first child inside <article class="page">
   so the article keeps its grid cell. -8px margin-bottom lets the H1 sit
   close beneath the toolbar instead of dragging an empty band along. */
.page-toolbar {
  display: flex;
  justify-content: flex-end;
  margin: -8px 0 -8px;
}

.page-actions {
  position: relative;
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--border-default);
  border-radius: var(--r-sm);
  background: var(--surface-0);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-body);
  box-shadow: var(--shadow-xs);
}

.page-actions-copy,
.page-actions-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: transparent;
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.page-actions-copy { padding-right: 8px; }
.page-actions-toggle {
  padding: 6px 8px;
  border-left: 1px solid var(--border-default);
}
.page-actions-toggle svg { transform: rotate(180deg); transition: transform 0.15s var(--ease); }
.page-actions-toggle[aria-expanded="true"] svg { transform: rotate(0); }
.page-actions-copy svg,
.page-actions-toggle svg { width: 14px; height: 14px; flex: 0 0 14px; color: var(--text-muted); }

.page-actions-copy:hover,
.page-actions-toggle:hover { background: var(--surface-1); }

.page-actions-copy.is-flash {
  color: var(--brand-primary);
}

.page-actions-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 280px;
  padding: 6px;
  background: var(--surface-0);
  border: 1px solid var(--border-default);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  z-index: 20;
}

.page-actions-menu > * {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 8px 10px;
  background: transparent;
  border: 0;
  border-radius: var(--r-sm);
  color: var(--text-body);
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.page-actions-menu > *:hover { background: var(--surface-1); color: var(--text-strong); }
.page-actions-menu svg { width: 18px; height: 18px; flex: 0 0 18px; margin-top: 2px; color: var(--text-muted); }
.page-actions-menu strong {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
  color: var(--text-strong);
}
.page-actions-menu strong svg { width: 11px; height: 11px; flex: 0 0 11px; margin: 0; color: currentColor; }
.page-actions-menu em {
  display: block;
  font-style: normal;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.page-actions-sep {
  height: 1px;
  background: var(--border-subtle);
  margin: 4px 4px;
}

/* =========================================================================
   Code block copy buttons
   ========================================================================= */

.code-block {
  position: relative;
}
.code-block pre { margin: 0; }
.page .code-block { margin: 1.25em 0; }

.code-copy {
  position: absolute;
  top: 8px;
  right: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  background: var(--surface-0);
  border: 1px solid var(--border-default);
  border-radius: var(--r-sm);
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s var(--ease), color 0.12s var(--ease), background 0.12s var(--ease);
}
.code-block:hover .code-copy,
.code-copy:focus-visible { opacity: 1; }
.code-copy:hover { color: var(--text-strong); background: var(--surface-1); }
.code-copy svg { width: 14px; height: 14px; }
.code-copy.is-copied { color: var(--brand-primary); border-color: color-mix(in srgb, var(--brand-primary) 50%, var(--border-default)); }
.code-copy.is-copied::after {
  content: "Copied";
  position: absolute;
  right: calc(100% + 6px);
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--brand-primary);
  white-space: nowrap;
}

/* =========================================================================
   Responsive
   ========================================================================= */

@media (max-width: 1100px) {
  .content { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .toc { display: none; }
}

@media (max-width: 820px) {
  :root { --topbar-h: 56px; }
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--border-default);
    max-height: none;
    padding: 20px 20px 24px;
  }
  .content { padding: 28px 20px 64px; }
  .page h1 { font-size: 2rem; }
  .topbar { padding: 0 16px; gap: 12px; }
  .topnav { margin-left: 8px; overflow-x: auto; scrollbar-width: none; }
  .topnav::-webkit-scrollbar { display: none; }
  .topnav-link { padding: 6px 10px; font-size: 13px; }
  .topbar-link { height: 32px; padding: 0 14px; font-size: 13px; }
}
