/* ==========================================================================
   Kizen Plugin Docs — design system

   Palette is drawn from the slate + sky/indigo scale the docs' own CSS examples
   use, so the site reads as part of the same product as its content.

   Theming: `:root` holds light tokens. Dark tokens are applied both by the OS
   preference (unless explicitly overridden to light) and by an explicit
   `data-theme="dark"`, so the in-page toggle can win in either direction.
   ========================================================================== */

:root {
  color-scheme: light;

  --bg: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-sunken: #f1f5f9;
  --bg-raised: #ffffff;
  --bg-overlay: rgb(15 23 42 / 0.45);

  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --text: #0f172a;
  --text-muted: #475569;
  --text-faint: #64748b;

  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --accent-border: #c7d2fe;
  --accent-contrast: #ffffff;

  --shadow-sm: 0 1px 2px rgb(15 23 42 / 0.06), 0 1px 3px rgb(15 23 42 / 0.08);
  --shadow-lg: 0 10px 15px -3px rgb(15 23 42 / 0.1), 0 4px 6px -4px rgb(15 23 42 / 0.1);
  --shadow-xl: 0 24px 48px -12px rgb(15 23 42 / 0.25);

  /* Syntax tokens — see lib/highlight.mjs for the class letters. */
  --t-c: #64748b;
  --t-s: #0f766e;
  --t-n: #b45309;
  --t-k: #7c3aed;
  --t-b: #be185d;
  --t-f: #2563eb;
  --t-t: #0891b2;
  --t-p: #0369a1;
  --t-d: #c2410c;
  --t-v: #db2777;
  --t-g: #be123c;
  --t-a: #0891b2;
  --t-u: #64748b;

  --topbar-h: 3.5rem;
  --sidebar-w: 17.5rem;
  --toc-w: 15rem;
  --content-max: 48rem;

  --radius-sm: 0.375rem;
  --radius: 0.5rem;
  --radius-lg: 0.75rem;

  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  /* CLI flags (`--yes`) and arrows (`=>`) must read as distinct characters, so ligatures stay off
     wherever monospace is used — some system mono fonts would otherwise fuse them. */
  --mono-ligatures: none;
}

/* Dark tokens, duplicated across the two selectors that can request them. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b1120;
    --bg-subtle: #0f172a;
    --bg-sunken: #0a0f1d;
    --bg-raised: #131c31;
    --bg-overlay: rgb(2 6 16 / 0.7);
    --border: #1e293b;
    --border-strong: #334155;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --text-faint: #64748b;
    --accent: #38bdf8;
    --accent-hover: #7dd3fc;
    --accent-soft: #0c2033;
    --accent-border: #1e3a5f;
    --accent-contrast: #04121f;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.5);
    --shadow-xl: 0 24px 48px -12px rgb(0 0 0 / 0.7);
    --t-c: #64748b;
    --t-s: #5eead4;
    --t-n: #fcd34d;
    --t-k: #c4b5fd;
    --t-b: #fda4af;
    --t-f: #93c5fd;
    --t-t: #67e8f9;
    --t-p: #7dd3fc;
    --t-d: #fdba74;
    --t-v: #f9a8d4;
    --t-g: #fda4af;
    --t-a: #67e8f9;
    --t-u: #94a3b8;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1120;
  --bg-subtle: #0f172a;
  --bg-sunken: #0a0f1d;
  --bg-raised: #131c31;
  --bg-overlay: rgb(2 6 16 / 0.7);
  --border: #1e293b;
  --border-strong: #334155;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-faint: #64748b;
  --accent: #38bdf8;
  --accent-hover: #7dd3fc;
  --accent-soft: #0c2033;
  --accent-border: #1e3a5f;
  --accent-contrast: #04121f;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.5);
  --shadow-xl: 0 24px 48px -12px rgb(0 0 0 / 0.7);
  --t-c: #64748b;
  --t-s: #5eead4;
  --t-n: #fcd34d;
  --t-k: #c4b5fd;
  --t-b: #fda4af;
  --t-f: #93c5fd;
  --t-t: #67e8f9;
  --t-p: #7dd3fc;
  --t-d: #fdba74;
  --t-v: #f9a8d4;
  --t-g: #fda4af;
  --t-a: #67e8f9;
  --t-u: #94a3b8;
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 0.15em; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.icon {
  width: 1.125rem;
  height: 1.125rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: 0.75rem 1rem;
  background: var(--accent);
  color: var(--accent-contrast);
  border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { left: 0; }

kbd {
  font-family: var(--font-mono);
  font-variant-ligatures: var(--mono-ligatures);
  font-size: 0.75em;
  padding: 0.15em 0.4em;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  color: var(--text-muted);
  white-space: nowrap;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}
.icon-btn:hover { background: var(--bg-sunken); color: var(--text); border-color: var(--border); }

/* --------------------------------------------------------------------------
   Top bar
   -------------------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  height: var(--topbar-h);
  padding: 0 1rem;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px) saturate(180%);
  border-bottom: 1px solid var(--border);
}

.nav-toggle { display: none; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  color: var(--text);
  font-weight: 650;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand:hover { color: var(--text); text-decoration: none; }

.brand-mark {
  display: block;
  width: 1.75rem;
  height: 1.75rem;
  /* Artwork is a circle on a transparent field, so it needs no radius or backplate of its own. */
  object-fit: contain;
  flex-shrink: 0;
}

.search-trigger {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
  min-width: 0;
  max-width: 20rem;
  flex: 1 1 12rem;
  padding: 0.4375rem 0.625rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-subtle);
  color: var(--text-faint);
  font: inherit;
  font-size: 0.875rem;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}
.search-trigger:hover { border-color: var(--border-strong); background: var(--bg); }
.search-trigger-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-kbd { margin-left: auto; }

.theme-toggle .theme-icon-dark { display: none; }
:root[data-theme="dark"] .theme-toggle .theme-icon-light { display: none; }
:root[data-theme="dark"] .theme-toggle .theme-icon-dark { display: inline-flex; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .theme-icon-light { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .theme-icon-dark { display: inline-flex; }
}

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  align-items: start;
  max-width: 100rem;
  margin: 0 auto;
}

.sidebar {
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  overscroll-behavior: contain;
  border-right: 1px solid var(--border);
  scrollbar-width: thin;
}
.sidebar-inner { padding: 1.5rem 0.75rem 3rem 1.25rem; }

.nav-group + .nav-group { margin-top: 1.5rem; }

.nav-group-title {
  margin: 0 0 0.5rem 0.5rem;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

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

.nav-link {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.3125rem 0.5rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1.5;
  transition: background-color 0.12s, color 0.12s;
}
.nav-link:hover { background: var(--bg-sunken); color: var(--text); text-decoration: none; }

.nav-link.is-current {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  box-shadow: inset 2px 0 0 var(--accent);
}

.nav-num {
  flex: none;
  min-width: 1.25rem;
  font-family: var(--font-mono);
  font-variant-ligatures: var(--mono-ligatures);
  font-size: 0.6875rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-faint);
}
.nav-link.is-current .nav-num { color: var(--accent); }

.main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--toc-w);
  gap: 2.5rem;
  align-items: start;
  padding: 0 2rem;
}

.main-inner {
  min-width: 0;
  max-width: var(--content-max);
  padding: 2.25rem 0 4rem;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  font-size: 0.8125rem;
  color: var(--text-faint);
}
.breadcrumb a { color: var(--text-faint); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb-sep { color: var(--border-strong); }

/* --------------------------------------------------------------------------
   On-this-page table of contents
   -------------------------------------------------------------------------- */

.toc {
  position: sticky;
  top: calc(var(--topbar-h) + 2.25rem);
  max-height: calc(100vh - var(--topbar-h) - 4rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: 2rem;
  font-size: 0.8125rem;
  scrollbar-width: thin;
}

.toc-title {
  margin: 0 0 0.625rem;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.toc-list { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border); }

.toc-item a {
  display: block;
  padding: 0.25rem 0 0.25rem 0.75rem;
  margin-left: -1px;
  border-left: 2px solid transparent;
  color: var(--text-muted);
  line-height: 1.45;
  /* Method-signature headings ("this.openCreateRecordModal(objectId, …)") are longer than the TOC is
     wide and contain no spaces to break at, so they must be allowed to break anywhere. */
  overflow-wrap: anywhere;
}
.toc-item a:hover { color: var(--text); text-decoration: none; border-left-color: var(--border-strong); }
.toc-h3 a { padding-left: 1.5rem; font-size: 0.78125rem; color: var(--text-faint); }

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

/* --------------------------------------------------------------------------
   Document typography
   -------------------------------------------------------------------------- */

.doc { min-width: 0; }

.doc > :first-child { margin-top: 0; }

.doc-heading {
  scroll-margin-top: calc(var(--topbar-h) + 1rem);
  line-height: 1.25;
  letter-spacing: -0.018em;
  color: var(--text);
}

.doc h1.doc-heading {
  margin: 0 0 1.25rem;
  font-size: clamp(1.875rem, 1.4rem + 1.6vw, 2.4rem);
  font-weight: 750;
}
.doc h2.doc-heading {
  margin: 3rem 0 1rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
  font-size: 1.5rem;
  font-weight: 700;
}
.doc h3.doc-heading { margin: 2.25rem 0 0.75rem; font-size: 1.1875rem; font-weight: 650; }
.doc h4.doc-heading { margin: 1.75rem 0 0.625rem; font-size: 1rem; font-weight: 650; }

/* Anchor affordance: reserved space, revealed on hover/focus so layout never shifts. */
.doc-heading-anchor {
  margin-left: 0.4em;
  color: var(--border-strong);
  font-weight: 400;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}
.doc-heading:hover .doc-heading-anchor,
.doc-heading-anchor:focus-visible { opacity: 1; }
.doc-heading-anchor:hover { color: var(--accent); text-decoration: none; }

.doc p { margin: 0 0 1.125rem; }
.doc strong { font-weight: 650; color: var(--text); }

.doc ul,
.doc ol { margin: 0 0 1.125rem; padding-left: 1.375rem; }
.doc li { margin: 0.3125rem 0; }
.doc li > ul,
.doc li > ol { margin: 0.375rem 0; }
.doc li::marker { color: var(--text-faint); }

.doc hr { height: 1px; margin: 2.5rem 0; border: 0; background: var(--border); }

.doc blockquote {
  margin: 0 0 1.125rem;
  padding: 0.875rem 1.125rem;
  border-left: 3px solid var(--accent-border);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--accent-soft);
  color: var(--text-muted);
}
.doc blockquote > :last-child { margin-bottom: 0; }

.doc img { max-width: 100%; height: auto; border-radius: var(--radius); }

/* Inline code */
.doc :not(pre) > code {
  padding: 0.15em 0.36em;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  font-family: var(--font-mono);
  font-variant-ligatures: var(--mono-ligatures);
  font-size: 0.8375em;
  word-break: break-word;
  color: var(--text);
}
.doc a > code { color: inherit; border-color: var(--accent-border); }

/* Target isn't a page in this site. The build names these; the dotted underline makes them visible
   in context too, rather than looking like a working link. */
.link-unresolved { text-decoration: underline dotted; text-underline-offset: 0.2em; }

.link-external::after {
  content: "↗";
  margin-left: 0.15em;
  font-size: 0.8em;
  vertical-align: 0.1em;
  opacity: 0.6;
}

/* --------------------------------------------------------------------------
   Code blocks
   -------------------------------------------------------------------------- */

.code-block {
  margin: 0 0 1.375rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-subtle);
  overflow: hidden;
}

.code-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.4375rem 0.5rem 0.4375rem 0.875rem;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-sunken) 60%, transparent);
}

.code-lang {
  font-size: 0.6875rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.code-copy {
  margin-left: auto;
  padding: 0.1875rem 0.5rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-faint);
  font: inherit;
  font-size: 0.75rem;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}
.code-copy:hover { background: var(--bg); color: var(--text); border-color: var(--border); }
.code-copy.is-copied { color: var(--accent); border-color: var(--accent-border); background: var(--accent-soft); }

.code-pre {
  margin: 0;
  padding: 1rem 1.125rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-variant-ligatures: var(--mono-ligatures);
  font-size: 0.8125rem;
  line-height: 1.65;
  tab-size: 2;
  scrollbar-width: thin;
}
.code-pre code { font: inherit; }

.t-c { color: var(--t-c); font-style: italic; }
.t-s { color: var(--t-s); }
.t-n { color: var(--t-n); }
.t-k { color: var(--t-k); font-weight: 600; }
.t-b { color: var(--t-b); }
.t-f { color: var(--t-f); }
.t-t { color: var(--t-t); }
.t-p { color: var(--t-p); }
.t-d { color: var(--t-d); }
.t-v { color: var(--t-v); }
.t-g { color: var(--t-g); }
.t-a { color: var(--t-a); }
.t-u { color: var(--t-u); }

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */

.table-wrap {
  margin: 0 0 1.375rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-raised);
  overflow: hidden;
}

/* The horizontal scroll lives on an inner element so the filter row stays put. */
.table-scroll { overflow-x: auto; scrollbar-width: thin; }

.doc table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.doc thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 0.625rem 0.875rem;
  border-bottom: 1px solid var(--border-strong);
  background: var(--bg-subtle);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: left;
  white-space: nowrap;
}

.doc tbody td {
  padding: 0.5625rem 0.875rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.doc tbody tr:last-child td { border-bottom: 0; }
.doc tbody tr:hover { background: var(--bg-subtle); }

.doc td:first-child { white-space: nowrap; }
.doc td:first-child > code { white-space: nowrap; }

.table-filter-row {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
}

.table-filter {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.3125rem 0.625rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.8125rem;
}
.table-filter::placeholder { color: var(--text-faint); }

.table-filter-count {
  flex: none;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-faint);
}

.table-empty {
  padding: 1.25rem 0.875rem;
  color: var(--text-faint);
  font-size: 0.875rem;
  text-align: center;
}

/* --------------------------------------------------------------------------
   Pager + footer
   -------------------------------------------------------------------------- */

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 3.5rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--border);
}

.pager-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text);
  transition: border-color 0.15s, background-color 0.15s, transform 0.15s;
}
.pager-link:hover {
  border-color: var(--accent-border);
  background: var(--accent-soft);
  text-decoration: none;
  transform: translateY(-1px);
}
.pager-next { grid-column: 2; flex-direction: row-reverse; text-align: right; }
.pager-meta { display: flex; flex-direction: column; min-width: 0; }
.pager-label { font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-faint); }
.pager-title { font-size: 0.9375rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pager-link .icon { color: var(--text-faint); }
.pager-slot { display: none; }

.doc-footer {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  color: var(--text-faint);
  font-size: 0.8125rem;
}
.doc-footer p { margin: 0; }
.doc-footer code {
  padding: 0.1em 0.3em;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  font-family: var(--font-mono);
  font-variant-ligatures: var(--mono-ligatures);
  font-size: 0.9em;
}

/* --------------------------------------------------------------------------
   Search
   -------------------------------------------------------------------------- */

.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  justify-content: center;
  padding: 1rem;
  background: var(--bg-overlay);
  backdrop-filter: blur(3px);
}
.search-overlay[hidden] { display: none; }

.search-panel {
  display: flex;
  flex-direction: column;
  width: min(42rem, 100%);
  max-height: min(34rem, calc(100vh - 2rem));
  margin-top: max(3rem, 8vh);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-raised);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.75rem 0.75rem 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-faint);
}

.search-input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 1rem;
}
.search-input:focus { outline: none; }
.search-input::placeholder { color: var(--text-faint); }
.search-input::-webkit-search-cancel-button { display: none; }

.search-results { flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; padding: 0.5rem; }

.search-empty { padding: 2rem 1rem; text-align: center; color: var(--text-faint); font-size: 0.875rem; }

.search-hit {
  display: block;
  padding: 0.5625rem 0.75rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text);
}
.search-hit:hover { text-decoration: none; }
.search-hit.is-active { background: var(--accent-soft); border-color: var(--accent-border); }

.search-hit-top {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.125rem;
}
.search-hit-heading {
  font-size: 0.9375rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-hit-crumb {
  flex: none;
  margin-left: auto;
  font-size: 0.6875rem;
  color: var(--text-faint);
  white-space: nowrap;
}
.search-hit-snippet {
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.search-hit mark {
  padding: 0 0.1em;
  border-radius: 2px;
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  color: inherit;
  font-weight: 600;
}

.search-hint {
  display: flex;
  gap: 1rem;
  padding: 0.5rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
  font-size: 0.75rem;
  color: var(--text-faint);
}
.search-hint kbd { margin-right: 0.15rem; }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

/* Drop the TOC only once it would genuinely squeeze the prose column. Sidebar (17.5) + content (48)
   + TOC (15) + gap and padding fit comfortably at 1440px, the most common laptop width, so this
   threshold must stay below it. */
@media (max-width: 78rem) {
  .main { grid-template-columns: minmax(0, 1fr); }
  .toc { display: none; }
}

@media (max-width: 64rem) {
  .nav-toggle { display: inline-flex; }
  .layout { grid-template-columns: minmax(0, 1fr); }

  .sidebar {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    z-index: 50;
    width: min(20rem, 85vw);
    background: var(--bg);
    box-shadow: var(--shadow-lg);
    transform: translateX(-100%);
    transition: transform 0.22s ease;
  }
  .sidebar.is-open { transform: translateX(0); }

  .sidebar-scrim {
    position: fixed;
    inset: var(--topbar-h) 0 0;
    z-index: 45;
    background: var(--bg-overlay);
  }
  .sidebar-scrim[hidden] { display: none; }

  .main { padding: 0 1.25rem; }
  .brand-text { display: none; }
}

@media (max-width: 40rem) {
  .main { padding: 0 1rem; }
  .main-inner { padding: 1.5rem 0 3rem; }
  .search-trigger-text { display: none; }
  .search-trigger { flex: 0 0 auto; max-width: none; }
  .search-kbd { display: none; }
  .pager { grid-template-columns: 1fr; }
  .pager-next { grid-column: 1; }
  .doc h2.doc-heading { margin-top: 2.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

@media print {
  .topbar, .sidebar, .toc, .pager, .search-overlay, .sidebar-scrim, .code-copy { display: none !important; }
  .layout, .main { display: block; }
  .main-inner { max-width: none; padding: 0; }
  .code-block, .table-wrap { break-inside: avoid; }
}
