@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;700&family=Instrument+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

/* ───────────────────────────────────────────────────────────────────────────
   PersivX Docs — design tokens.

   The brand is two colors, sampled from the wordmark: navy #242E3D ("PERSIV")
   and sage #ACC3A6 (the "X"). Sage at its brand value is only 1.9:1 on white,
   so light mode uses a deepened sage (#4C7547, 5.3:1) as the accent and saves
   the literal brand color for dark mode, where it lands at 9.6:1 on #171614.
   Navy carries headings and body ink in light mode.
   ─────────────────────────────────────────────────────────────────────────── */

:root {
  /* Brand */
  --brand-navy: #242E3D;
  --brand-sage: #ACC3A6;

  /* Accent */
  --primary: #4C7547;
  --primary-hover: #3A5C36;
  --primary-light: #EDF2EB;

  /* Surfaces */
  --bg: #FFFFFF;
  --bg-alt: #F8F8F5;
  --bg-sidebar: #F8F8F5;
  --bg-card: #FFFFFF;
  --table-head-bg: #F6F7F4;
  --hover-surface: #EDEEE9;

  /* Borders */
  --border: #E5E7E1;
  --border-light: #E9EAE5;
  --border-table-row: #F0F1EC;
  --border-nav-guide: #E1E3DC;

  /* Text — navy-tinted ramp */
  --text: #1C232E;
  --text-heading-alt: #242E3D;
  --text-body: #3A414C;
  --text-lead: #575E69;
  --text-muted: #6A717C;
  --text-muted-link: #676E79;
  --text-label: #878E98;
  --text-label-alt: #969DA6;
  --text-faint: #A5ABB4;

  /* Callout families — info is blue so it stays distinct from the sage
     accent, which .callout-tip uses. */
  --info: #2D6CA8;
  --callout-info-bg: #F5F9FD;
  --callout-info-border: #DEE9F5;
  --callout-warning-bg: #FBF4EA;
  --callout-warning-border: #F0E2CC;
  --callout-tip-bg: #F0F5EE;
  --callout-tip-border: #DCE7D9;

  --success: #3A6B3F;
  --warning: #9A5100;
  --danger: #C4262B;
  --purple: #7B4C9E;
  --badge-admin-bg: rgba(196,38,43,0.08);
  --badge-all-bg: rgba(58,107,63,0.10);

  /* Code */
  --code-bg: #1B2029;
  --code-bar-bg: #222833;
  --code-bar-border: #2E3540;
  --code-text: #E4E7EA;
  --inline-code-bg: #F0F1EC;
  --inline-code-text: #1C232E;

  --wordmark-sub: var(--brand-sage);

  --header-h: 48px;
  --sidebar-width: 248px;
  --toc-width: 200px;

  --radius: 8px;
  --radius-sm: 5px;
  --radius-lg: 8px;
  --shadow-sm: 0 1px 3px rgba(36,46,61,0.07);
  --shadow-md: 0 4px 12px rgba(36,46,61,0.10);
  --focus-ring: 0 0 0 4px rgba(76,117,71,0.20);

  --font-head: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-body: 'Instrument Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', monospace;

  color-scheme: light;
}

/* Dark palette is declared twice on purpose: once for viewers on the system
   default (no data-theme attribute), once for an explicit toggle to dark. The
   media block is guarded so an explicit "light" choice always wins over the
   OS preference. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --primary: #ACC3A6;
    --primary-hover: #C6D8C1;
    --primary-light: rgba(172,195,166,0.14);
    --bg: #16191E;
    --bg-alt: #1E222A;
    --bg-sidebar: #16191E;
    --bg-card: #1E222A;
    --table-head-bg: #1E222A;
    --hover-surface: #272C35;
    --border: #313742;
    --border-light: #292E37;
    --border-table-row: #242931;
    --border-nav-guide: #313742;
    --text: #EDEFF1;
    --text-heading-alt: #E7EAEC;
    --text-body: #D0D4D9;
    --text-lead: #AEB4BC;
    --text-muted: #99A0A9;
    --text-muted-link: #99A0A9;
    --text-label: #838A94;
    --text-label-alt: #838A94;
    --text-faint: #6F7680;
    --info: #6FAEE8;
    --callout-info-bg: rgba(111,174,232,0.08);
    --callout-info-border: rgba(111,174,232,0.26);
    --callout-warning-bg: rgba(240,164,60,0.08);
    --callout-warning-border: rgba(240,164,60,0.26);
    --callout-tip-bg: rgba(172,195,166,0.08);
    --callout-tip-border: rgba(172,195,166,0.26);
    --success: #8FCB96;
    --warning: #F0A43C;
    --danger: #F0797D;
    --purple: #C39BE0;
    --badge-admin-bg: rgba(240,121,125,0.14);
    --badge-all-bg: rgba(143,203,150,0.14);
    --code-bg: #0F1216;
    --code-bar-bg: #16191E;
    --code-bar-border: #292E37;
    --code-text: #E4E7EA;
    --inline-code-bg: #272C35;
    --inline-code-text: #EDEFF1;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.35);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.45);
    --focus-ring: 0 0 0 4px rgba(172,195,166,0.22);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --primary: #ACC3A6;
  --primary-hover: #C6D8C1;
  --primary-light: rgba(172,195,166,0.14);
  --bg: #16191E;
  --bg-alt: #1E222A;
  --bg-sidebar: #16191E;
  --bg-card: #1E222A;
  --table-head-bg: #1E222A;
  --hover-surface: #272C35;
  --border: #313742;
  --border-light: #292E37;
  --border-table-row: #242931;
  --border-nav-guide: #313742;
  --text: #EDEFF1;
  --text-heading-alt: #E7EAEC;
  --text-body: #D0D4D9;
  --text-lead: #AEB4BC;
  --text-muted: #99A0A9;
  --text-muted-link: #99A0A9;
  --text-label: #838A94;
  --text-label-alt: #838A94;
  --text-faint: #6F7680;
  --info: #6FAEE8;
  --callout-info-bg: rgba(111,174,232,0.08);
  --callout-info-border: rgba(111,174,232,0.26);
  --callout-warning-bg: rgba(240,164,60,0.08);
  --callout-warning-border: rgba(240,164,60,0.26);
  --callout-tip-bg: rgba(172,195,166,0.08);
  --callout-tip-border: rgba(172,195,166,0.26);
  --success: #8FCB96;
  --warning: #F0A43C;
  --danger: #F0797D;
  --purple: #C39BE0;
  --badge-admin-bg: rgba(240,121,125,0.14);
  --badge-all-bg: rgba(143,203,150,0.14);
  --code-bg: #0F1216;
  --code-bar-bg: #16191E;
  --code-bar-border: #292E37;
  --code-text: #E4E7EA;
  --inline-code-bg: #272C35;
  --inline-code-text: #EDEFF1;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.35);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.45);
  --focus-ring: 0 0 0 4px rgba(172,195,166,0.22);
  color-scheme: dark;
}

/* The wordmark is navy + sage artwork on a transparent ground. On dark,
   brightness(0) flattens every opaque pixel to black regardless of its hue,
   then invert(1) lifts it to white — so it reads cleanly without boxing the
   logo in a white chip or swapping in a second image file. */
:root:not([data-theme="light"]) .header-brand img,
:root[data-theme="dark"] .header-brand img {
  filter: brightness(0) invert(1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  color: var(--text);
  line-height: 1.6;
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.15s ease, color 0.15s ease;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); text-decoration: underline; }

::selection { background: var(--primary-light); }

a:focus-visible, button:focus-visible, input:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: 4px;
}

/* The search input shows focus on its pill-shaped container instead (see
   .header-search:focus-within) — letting the input also take the generic ring
   double-stacks two overlapping shadows of different shapes. */
.header-search input:focus-visible { box-shadow: none; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--primary);
  color: #fff;
  padding: 10px 16px;
  border-radius: 0 0 6px 0;
  z-index: 500;
  font-size: 13px;
  font-weight: 600;
}

.skip-link:focus { left: 0; }

/* ── Header — sticky, spans the full width above the grid ── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  height: var(--header-h);
  padding: 0 20px;
  background: rgba(255,255,255,0.9);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}

:root:not([data-theme="light"]) .site-header,
:root[data-theme="dark"] .site-header {
  background: rgba(22,25,30,0.85);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex-shrink: 0;
}

.header-brand img { height: 16px; width: auto; }

.wordmark {
  font-family: var(--font-head);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  white-space: nowrap;
}

.wordmark-sub { color: var(--wordmark-sub); }

.docs-badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--primary);
  color: #fff;
  flex-shrink: 0;
  white-space: nowrap;
}

:root:not([data-theme="light"]) .docs-badge,
:root[data-theme="dark"] .docs-badge { color: var(--brand-navy); }

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  justify-content: flex-end;
  min-width: 0;
}

.header-search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 1 320px;
  min-width: 0;
  height: 28px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.header-search:focus-within {
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
}

.header-search-icon {
  font-size: 12px;
  color: var(--text-label);
  flex-shrink: 0;
  line-height: 1;
}

.header-search input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  outline: none;
  font-family: inherit;
  font-size: 12px;
  color: var(--text);
}

.header-search input::placeholder { color: var(--text-label); }

/* Global search results dropdown, anchored to .header-search */
.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  min-width: 360px;
  max-height: 70vh;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 6px;
  z-index: 250;
}

.search-result {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text);
}

.search-result:hover, .search-result.active {
  background: var(--hover-surface);
  text-decoration: none;
}

.search-result-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
}

.search-result-sep { color: var(--text-faint); font-weight: 400; }

.search-result-snippet {
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--text-muted);
}

.search-results mark {
  background: var(--primary-light);
  color: var(--primary-hover);
  border-radius: 2px;
  padding: 0 1px;
}

:root:not([data-theme="light"]) .search-results mark,
:root[data-theme="dark"] .search-results mark { color: var(--primary); }

.search-empty {
  padding: 10px 12px;
  font-size: 12.5px;
  color: var(--text-muted);
  font-style: italic;
}

@media (max-width: 800px) {
  .search-results { min-width: 0; }
}

.kbd-chip {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 5px;
  border: 1px solid var(--border-light);
  border-radius: 4px;
  color: var(--text-label);
  flex-shrink: 0;
  white-space: nowrap;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.12s ease;
  flex-shrink: 0;
}

.theme-toggle:hover {
  background: var(--hover-surface);
  color: var(--text);
  border-color: var(--text-muted);
}

.menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text);
  padding: 4px 6px;
  flex-shrink: 0;
}

/* ── Doc grid — sidebar + content below the header ── */
.doc-grid {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0,1fr);
  gap: 0;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: var(--header-h);
  align-self: start;
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 20px 16px 48px 24px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  z-index: 50;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12.5px;
}

.sidebar nav a {
  display: block;
  padding: 4px 8px;
  color: var(--text-muted-link);
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 400;
  border-radius: var(--radius-sm);
  transition: color 0.12s ease, background-color 0.12s ease;
  -webkit-tap-highlight-color: transparent;
  line-height: 1.4;
}

.sidebar nav a:hover { color: var(--text); text-decoration: none; }

.sidebar nav a.active {
  color: var(--primary);
  font-weight: 600;
  background: transparent;
}

.sidebar nav a.nav-hidden,
.sidebar nav .nav-section.nav-hidden,
.sidebar nav .nav-subgroup.nav-hidden {
  display: none !important;
}

.sidebar nav .no-results {
  padding: 8px;
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

.sidebar nav .nav-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-heading-alt);
  cursor: pointer;
  user-select: none;
}

.sidebar nav .nav-section:hover { background: var(--hover-surface); }

.sidebar nav .nav-section.collapsible::after {
  content: "▾";
  font-size: 13px;
  line-height: 1;
  color: var(--text-faint);
  transition: transform 0.15s ease;
}

.sidebar nav .nav-section.collapsible.collapsed::after {
  transform: rotate(-90deg);
}

.nav-section-links {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: 2px 0 8px 9px;
  padding-left: 8px;
  border-left: 1px solid var(--border-nav-guide);
  max-height: 600px;
  overflow: hidden;
  transition: max-height 0.22s ease, opacity 0.18s ease;
}

.nav-section-links.collapsed {
  max-height: 0;
  opacity: 0;
  margin-top: 0;
  margin-bottom: 0;
}

.sidebar nav.search-active .nav-section-links.collapsed {
  max-height: 600px;
  opacity: 1;
  margin: 2px 0 8px 9px;
}

/* Nested subgroup — one more indent level for a topic too large for a single
   page (e.g. Query Mode, Visualization Features). Same collapse mechanics. */
.nav-subgroup { display: flex; flex-direction: column; }

.nav-subgroup-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  width: 100%;
  padding: 4px 8px;
  border: 0;
  background: transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted-link);
  text-align: left;
  cursor: pointer;
}

.nav-subgroup-toggle:hover { color: var(--text); background: var(--hover-surface); }

.nav-subgroup.has-active .nav-subgroup-toggle { color: var(--text); font-weight: 600; }

.nav-subgroup-chevron {
  font-size: 11px;
  line-height: 1;
  color: var(--text-faint);
  transition: transform 0.15s ease;
  flex-shrink: 0;
}

.nav-subgroup.collapsed .nav-subgroup-chevron { transform: rotate(-90deg); }

.nav-subgroup-links {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: 1px 0 4px 9px;
  padding-left: 8px;
  border-left: 1px solid var(--border-nav-guide);
  max-height: 400px;
  overflow: hidden;
  transition: max-height 0.2s ease, opacity 0.16s ease;
}

.nav-subgroup-links a { font-size: 12px; }

.nav-subgroup.collapsed .nav-subgroup-links {
  max-height: 0;
  opacity: 0;
  margin-top: 0;
  margin-bottom: 0;
}

.sidebar nav.search-active .nav-subgroup.collapsed .nav-subgroup-links {
  max-height: 400px;
  opacity: 1;
  margin: 1px 0 4px 9px;
}

/* ── Content grid: article + TOC ── */
.main {
  display: grid;
  grid-template-columns: minmax(0,1fr) var(--toc-width);
  gap: 40px;
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 40px;
  align-items: start;
}

.main-content {
  min-width: 0;
  padding: 36px 0 90px;
}

.breadcrumb {
  font-family: var(--font-body);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 10px;
  min-height: 13px;
}

.breadcrumb:empty { margin-bottom: 0; min-height: 0; }

.main h1 {
  font-family: var(--font-head);
  font-size: 29px;
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: -0.028em;
  margin: 0 0 10px;
  color: var(--text);
  scroll-margin-top: 80px;
}

.subtitle {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-lead);
  max-width: 64ch;
  margin-bottom: 0;
  font-weight: 400;
}

/* Lead rule — divides the H1/lead pair from the first content block */
.main-content > .subtitle {
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 24px;
}

.main h2 {
  font-family: var(--font-head);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.018em;
  margin: 28px 0 9px;
  color: var(--text);
  scroll-margin-top: 80px;
}

.main h2:first-of-type { margin-top: 0; }

.main h3 {
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-heading-alt);
  margin: 20px 0 6px;
  scroll-margin-top: 80px;
}

.main h4 {
  font-family: var(--font-head);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-label);
  margin: 16px 0 5px;
  scroll-margin-top: 80px;
}

.main p {
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-body);
  max-width: 76ch;
  margin-bottom: 10px;
}

/* Tables */
.doc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.doc-table th, .doc-table td {
  padding: 7px 12px;
  text-align: left;
  vertical-align: top;
}

.doc-table th {
  background: var(--table-head-bg);
  font-weight: 700;
  font-size: 9.5px;
  color: var(--text-label);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--border-light);
}

.doc-table td {
  color: var(--text-body);
  line-height: 1.45;
  border-bottom: 1px solid var(--border-table-row);
}

.doc-table tr:last-child td { border-bottom: none; }

.doc-table td code, .main p code, .main li code, .callout code {
  background: var(--inline-code-bg);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11.5px;
  font-family: var(--font-mono);
  color: var(--inline-code-text);
  font-weight: 500;
  white-space: nowrap;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.doc-table tr:hover td { background: var(--hover-surface); }

/* Callouts */
.callout {
  padding: 11px 13px;
  border-radius: var(--radius);
  margin: 14px 0;
  border: 1px solid var(--callout-info-border);
  border-left: 3px solid var(--info);
  background: var(--callout-info-bg);
  font-size: 13px;
  line-height: 1.55;
}

.callout-warning { border-color: var(--callout-warning-border); border-left-color: var(--warning); background: var(--callout-warning-bg); }
.callout-tip { border-color: var(--callout-tip-border); border-left-color: var(--primary); background: var(--callout-tip-bg); }

/* Only the callout's leading <strong> becomes the label. Scoping this to the
   first child (rather than every strong in the callout) lets body text inside
   a callout use <strong> for ordinary emphasis without turning into a second
   heading. */
.callout > strong:first-child {
  display: block;
  margin-bottom: 2px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.callout-info > strong:first-child { color: var(--info); }
.callout-warning > strong:first-child { color: var(--warning); }
.callout-tip > strong:first-child { color: var(--primary-hover); }

:root:not([data-theme="light"]) .callout-tip > strong:first-child,
:root[data-theme="dark"] .callout-tip > strong:first-child { color: var(--primary); }

.callout a { font-weight: 500; }

.callout > *:last-child { margin-bottom: 0; }

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  vertical-align: middle;
}

.badge-admin { background: var(--badge-admin-bg); color: var(--danger); }
.badge-all { background: var(--badge-all-bg); color: var(--success); }

/* Images */
.main img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  margin: 14px 0 16px;
}

.main img.no-shadow { border: none; }

/* Lists */
.main ul, .main ol {
  margin: 2px 0 12px;
  padding-left: 17px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.main li {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-body);
  max-width: 74ch;
}

.main li strong { color: var(--text); }

.main li > ul, .main li > ol { margin: 4px 0 0; }

/* Code blocks */
.code-block {
  margin: 14px 0 16px;
  border: 1px solid var(--code-bar-border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--code-bg);
}

.code-block-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 12px;
  background: var(--code-bar-bg);
  border-bottom: 1px solid var(--code-bar-border);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-label);
}

.code-block pre {
  margin: 0;
  padding: 11px 13px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--code-text);
}

/* Divider */
.doc-divider {
  height: 1px;
  background: var(--border-light);
  margin: 26px 0;
  border: none;
}

/* Hero image */
.hero-img {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  margin-bottom: 32px;
}

/* Embedded PDF viewer — used by the Automations pages until their content is
   written out as real HTML. */
.pdf-embed {
  width: 100%;
  height: 780px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  margin: 14px 0 16px;
  background: var(--bg-alt);
}

@media (max-width: 768px) {
  .pdf-embed { height: 460px; }
}

/* On-this-page TOC */
.toc {
  position: sticky;
  top: var(--header-h);
  align-self: start;
  max-height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 36px 0 48px;
}

.toc-title {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-label-alt);
  margin-bottom: 8px;
}

.toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border-light);
}

.toc li { margin: 0; }

.toc a {
  display: block;
  padding: 4px 0 4px 11px;
  margin-left: -1px;
  border-left: 2px solid transparent;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 11.5px;
  line-height: 1.4;
  transition: color 0.12s ease, border-color 0.12s ease;
}

.toc a:hover { color: var(--text); text-decoration: none; }

.toc a.active {
  color: var(--primary);
  border-left-color: var(--primary);
  font-weight: 600;
}

/* Prev / next page navigation */
.page-nav {
  display: flex;
  gap: 10px;
  margin-top: 40px;
}

.page-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 13px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  background: var(--bg-card);
  transition: border-color 0.15s ease;
}

.page-nav a:hover { border-color: var(--text-faint); text-decoration: none; }

.page-nav .page-nav-label {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-label-alt);
}

.page-nav .page-nav-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.page-nav-next { text-align: right; align-items: flex-end; margin-left: auto; }

/* Topics grid (landing page) */
.topics-category {
  margin: 28px 0 6px;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-label-alt);
  font-weight: 700;
}

.topics-category:first-child { margin-top: 0; }

.topics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 2px 28px;
  margin-bottom: 8px;
  --topic-color: var(--primary);
  --topic-color-bg: var(--primary-light);
}

.topics-grid a {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
  text-decoration: none;
}

.topic-icon {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  line-height: 1;
  background: var(--topic-color-bg);
  color: var(--topic-color);
  transition: transform 0.12s ease;
}

.topic-body { min-width: 0; }

.topics-grid a .topic-title {
  display: block;
  color: var(--primary);
  font-weight: 600;
  font-size: 14px;
  font-family: var(--font-head);
}

.topics-grid a .topic-desc {
  display: block;
  color: var(--text-muted);
  font-size: 12.5px;
  margin-top: 2px;
  line-height: 1.4;
}

.topics-grid a:hover .topic-title { text-decoration: underline; }
.topics-grid a:hover .topic-icon { transform: scale(1.05); }

/* Capability pill row */
.platform-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 20px;
}

.platform-badges span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 20px;
  background: var(--bg-alt);
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 550;
}

/* Docs footer */
.docs-footer {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border-light);
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.docs-footer a { color: var(--text-muted); }
.docs-footer a:hover { color: var(--primary); }

/* Scrollbars */
.sidebar::-webkit-scrollbar, .toc::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb, .toc::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }

/* Overlay (mobile nav drawer) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 199;
}

.sidebar-overlay.active { display: block; }

/* Table wrapper for horizontal scroll */
.table-wrap {
  margin: 12px 0 16px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  overflow-x: auto;
  overflow-y: hidden;
  background: var(--bg-card);
  -webkit-overflow-scrolling: touch;
}

.table-wrap .doc-table {
  margin: 0;
  min-width: 480px;
}

/* Mobile */
@media (max-width: 800px) {
  .doc-grid { grid-template-columns: minmax(0,1fr); }

  .menu-btn { display: inline-flex; align-items: center; justify-content: center; }

  .header-search { flex: 1; max-width: none; }
  .header-brand .wordmark { font-size: 13px; }

  .sidebar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    height: calc(100vh - var(--header-h));
    width: 280px;
    max-width: 84vw;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 250;
    box-shadow: var(--shadow-md);
  }

  .sidebar.open { transform: translateX(0); }
}

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

@media (max-width: 768px) {
  .main { padding: 0 18px; }
  .main-content { padding: 24px 0 60px; }

  .main h1 { font-size: 24px; }
  .main h2 { font-size: 17px; }

  .doc-table { font-size: 12px; }
  .doc-table th, .doc-table td { padding: 7px 9px; }

  .callout { padding: 10px 12px; font-size: 12.5px; }

  .page-nav { flex-direction: column; }
}

@media (min-width: 801px) and (max-width: 1120px) {
  .main { padding: 0 32px; }
}

/* Print */
@media print {
  .sidebar, .site-header, .sidebar-overlay, .toc, .page-nav, .theme-toggle, .skip-link { display: none !important; }
  .doc-grid { display: block; }
  .main { max-width: none; padding: 0; }
  .main-content { padding: 0; }
  a { color: inherit; text-decoration: underline; }
}

/* Two-up text/screenshot row — collapses to a single column on narrow
   viewports. Replaces the per-page inline flex styles and <style> blocks the
   markdown source used to carry. */
.split {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  flex-wrap: wrap;
  margin: 14px 0 16px;
}

.split > * { flex: 1 1 300px; min-width: 0; }

.split img { margin-top: 0; }

/* An aside note under a list item — the grey "Country goes in For every…"
   annotations in the visualization walkthroughs. */
.note-inline {
  display: block;
  color: var(--text-muted);
  font-size: 12.5px;
  margin-top: 2px;
}

/* ── Changelog ──
   A version list reads better as a two-column ledger than as 40 headings:
   the version tags form a scannable rail on the left, and nothing floods the
   on-this-page TOC (which only collects h2s). */
.changelog {
  display: flex;
  flex-direction: column;
  margin: 8px 0 0;
  border-top: 1px solid var(--border-light);
}

.changelog-entry {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
}

.changelog-version {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--primary);
  padding-top: 1px;
  white-space: nowrap;
}

.changelog-body > *:first-child { margin-top: 0; }
.changelog-body > *:last-child { margin-bottom: 0; }

.changelog-body ul,
.changelog-body ol { margin: 0; }

.changelog-body li { font-size: 13px; }

@media (max-width: 600px) {
  .changelog-entry { grid-template-columns: minmax(0, 1fr); gap: 4px; }
}

/* Landing list of release pages */
.version-index {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
  margin: 12px 0 16px;
}

.version-index a {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 10px 13px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  background: var(--bg-card);
  text-decoration: none;
  transition: border-color 0.15s ease;
}

.version-index a:hover { border-color: var(--text-faint); text-decoration: none; }

.version-index .version-number {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--primary);
}

.version-index .version-meta {
  font-size: 11px;
  color: var(--text-muted);
}
