/* ==========================================================================
   okfsmith Docs Site — docs.css
   Implements docs/DESIGN_TOKENS.md (Worker #2, UX Designer) EXACTLY.
   Plain CSS, zero dependencies, no external fonts/imports.
   All asset references are relative.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens — full :root set from DESIGN_TOKENS.md §1, §2, §6
   -------------------------------------------------------------------------- */
:root {
  --bg: #16150F;
  --bg-2: #1C1A15;
  --surface: #201E17;
  --surface-2: #262219;
  --border: #333027;
  --border-strong: #46412F;
  --text: #F4F1E8;
  --text-2: #C9C3B2;
  --text-3: #8E8773;
  --accent: #D97757;
  --accent-strong: #E8896B;
  --accent-dim: #3A2620;
  --accent-text: #F0A37E;
  --code-bg: #0E0D0B;
  --code-header-bg: #181611;
  --inline-code-bg: #2A2519;
  --inline-code-fg: #EFCFA4;
  --link: #E9B48C;
  --link-hover: #F5CDA6;
  --success: #7FB069;
  --success-bg: #1E2B1C;
  --warning: #E0A458;
  --warning-bg: #2E2415;
  --danger: #DE6B5A;
  --danger-bg: #2E1B17;
  --note: #D97757;
  --note-bg: #2E2019;
  --focus-ring: #D9775780;
  --overlay: #0B0A08CC;

  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia,
                "Charter", "Bitstream Charter", "Sitka Text", "Noto Serif", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto,
               "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas,
               "Liberation Mono", "DejaVu Sans Mono", monospace;

  --topbar-h: 64px;
  --tabbar-h: 48px;
  --sidebar-w: 260px;
  --toc-w: 230px;
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
}

::selection {
  background: #D97757;
  color: #16150F;
}

/* --------------------------------------------------------------------------
   2. Reset / 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;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: var(--link);
  text-decoration: none;
  transition: color 120ms ease;
}

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

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

button {
  font: inherit;
  cursor: pointer;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth; /* TOC anchor jumps only per §5 */
  }
}

/* --------------------------------------------------------------------------
   3. Top bar — header.topbar, 64px sticky (§4.1)
   -------------------------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-h);
  background: #16150FE6; /* 90% opaque --bg */
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-inline: 2rem;
}

.wordmark {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.docs-label {
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--text-2);
  white-space: nowrap;
}

.lang-chip {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.1875rem 0.625rem;
  white-space: nowrap;
  background: transparent;
}

/* Search trigger button styled as an input */
#search-open {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-3);
  font-size: 0.875rem;
  padding: 0.4375rem 0.75rem;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}

#search-open:hover {
  border-color: var(--border-strong);
  color: var(--text-2);
}

#search-open .search-placeholder {
  flex: 1;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

kbd {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  line-height: 1;
  color: var(--text-2); /* 10.4:1 on --surface-2 (AA) */
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.25rem 0.375rem;
  white-space: nowrap;
}

#search-open kbd + kbd {
  margin-left: 0.125rem;
}

/* CTA */
a.cta,
.cta {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--accent);
  color: #16150F;
  font-weight: 600;
  font-size: 0.875rem;
  border-radius: 8px;
  padding: 0.5rem 1rem;
  border: 1px solid transparent;
  white-space: nowrap;
  transition: background-color 120ms ease, color 120ms ease;
}

a.cta:hover,
.cta:hover {
  background: var(--accent-strong);
  color: #16150F;
  text-decoration: none;
}

/* Hamburger — visible only <800px */
.hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-2);
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}

.hamburger:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-strong);
}

.hamburger svg {
  width: 20px;
  height: 20px;
}

/* --------------------------------------------------------------------------
   4. Tab bar — nav.tabs, 48px sticky (§4.2)
   -------------------------------------------------------------------------- */
.tabs {
  position: sticky;
  top: var(--topbar-h);
  z-index: 40;
  height: var(--tabbar-h);
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
}

.tabs-inner {
  height: 100%;
  max-width: 1440px;
  margin-inline: auto;
  padding-inline: 2rem;
  display: flex;
  align-items: stretch;
  overflow-x: auto;
  scrollbar-width: none; /* hidden scrollbar */
}

.tabs-inner::-webkit-scrollbar {
  display: none;
}

a.tab,
.tab {
  display: inline-flex;
  align-items: center;
  padding: 0.75rem 1rem;
  color: var(--text-2);
  font-size: 0.875rem;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}

a.tab:hover,
.tab:hover {
  color: var(--text);
  border-bottom-color: var(--border-strong);
  text-decoration: none;
}

a.tab.active,
.tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   5. 3-column grid — .layout (§3)
   -------------------------------------------------------------------------- */
.layout,
.docs-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  gap: 3rem;
  max-width: 1440px;
  margin-inline: auto;
  padding-inline: 2rem;
  padding-block: 2.5rem 4rem;
}

/* --------------------------------------------------------------------------
   6. Sidebar nav — aside.sidebar (§4.3)
   -------------------------------------------------------------------------- */
.sidebar {
  position: sticky;
  top: calc(var(--topbar-h) + var(--tabbar-h) + 1.5rem);
  max-height: calc(100vh - var(--topbar-h) - var(--tabbar-h) - 1.5rem);
  overflow-y: auto;
  align-self: start;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.nav-group {
  margin-bottom: 0.25rem;
}

.nav-group-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  margin: 1.5rem 0 0.5rem;
  padding-inline: 0.75rem;
}

.nav-group:first-child .nav-group-title {
  margin-top: 0;
}

a.nav-link,
.nav-link {
  display: block;
  padding: 0.375rem 0.75rem;
  border-radius: 6px;
  border-left: 2px solid transparent;
  color: var(--text-2);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.4;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}

a.nav-link:hover,
.nav-link:hover {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}

a.nav-link.active,
.nav-link.active {
  background: var(--accent-dim);
  color: var(--accent-text);
  font-weight: 600;
  border-left-color: var(--accent);
}

a.nav-link.active:hover,
.nav-link.active:hover {
  color: var(--accent-text);
}

/* Nested children with a guide line */
.nav-group .nav-group .nav-link,
.nav-children {
  margin-left: 1rem;
  border-left: 1px solid var(--border);
  border-radius: 0 6px 6px 0;
}

.nav-children .nav-link {
  border-left: 2px solid transparent;
  margin-left: -1px;
}

.nav-children .nav-link.active {
  border-left-color: var(--accent);
}

/* --------------------------------------------------------------------------
   7. Main content — main.content (§4.4, typography §2)
   -------------------------------------------------------------------------- */
.content {
  min-width: 0;
}

.content-inner,
.prose {
  max-width: 46rem;
}

.prose {
  color: var(--text);
  font-size: 1rem;
  line-height: 1.7;
}

.prose p {
  margin: 0 0 1.25rem;
  max-width: 68ch;
}

.prose ul,
.prose ol {
  margin: 0 0 1.25rem;
  padding-left: 1.5rem;
  max-width: 68ch;
}

.prose li {
  margin-bottom: 0.375rem;
}

.prose li::marker {
  color: var(--accent-text);
}

.prose a {
  color: var(--link);
}

.prose a:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

.prose strong {
  font-weight: 650;
  color: var(--text);
}

.prose hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

/* Headings */
.prose h2,
.prose h3,
.prose h4,
.prose h1 {
  scroll-margin-top: calc(64px + 48px + 1rem);
}

h2[id],
h3[id],
h4[id] {
  scroll-margin-top: calc(64px + 48px + 1rem);
}

.prose h2 {
  font-family: var(--font-sans);
  font-size: 1.5rem;
  line-height: 1.3;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 2.5rem 0 1rem;
}

.prose h3 {
  font-family: var(--font-sans);
  font-size: 1.25rem;
  line-height: 1.35;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 2rem 0 0.875rem;
}

.prose h4 {
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.4;
  font-weight: 650;
  color: var(--text);
  margin: 1.5rem 0 0.75rem;
}

/* Eyebrow + h1 + copy-page row */
.title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.title-block {
  min-width: 0;
}

.eyebrow {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.4;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-text);
  margin: 0 0 0.75rem;
}

.title-row h1,
.prose h1,
h1.page-title {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 1.4rem + 3vw, 2.75rem);
  line-height: 1.15;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 0;
}

.title-row h1 + p.lead,
.lead {
  font-size: 1.125rem;
  color: var(--text-2);
  line-height: 1.6;
  margin: 1rem 0 0;
  max-width: 60ch;
}

/* Copy-page button */
#copy-page,
.copy-page {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-2);
  border-radius: 8px;
  padding: 0.5rem 0.875rem; /* ~40px tall touch target */
  font-size: 0.8125rem;
  font-weight: 500;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}

#copy-page:hover,
.copy-page:hover {
  border-color: var(--border-strong);
  color: var(--text);
  background: var(--surface-2);
}

#copy-page svg,
.copy-page svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

#copy-page.copied,
.copy-page.copied {
  color: var(--success);
  border-color: #7FB06966;
}

/* --------------------------------------------------------------------------
   8. Code blocks — figure.codeblock / pre.codeblock (§4.5)
   -------------------------------------------------------------------------- */
.codeblock {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin: 1.5rem 0;
  background: var(--code-bg);
}

.codeblock-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--code-header-bg);
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 0.75rem 0.5rem 1.25rem;
}

.codeblock-lang {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.codeblock pre,
pre.codeblock {
  margin: 0;
  padding: 1rem 1.25rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.65;
  color: var(--text);
  tab-size: 2;
  background: var(--code-bg);
}

/* Bare pre.codeblock keeps the bordered card look from §4.5 */
pre.codeblock {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.codeblock pre code,
pre.codeblock code {
  font: inherit;
  color: inherit;
  background: transparent;
  border: 0;
  padding: 0;
  white-space: pre;
}

/* Copy button — .copy-btn is the class build.py emits in codeblock header
   strips; .code-copy is injected by assets/js/docs.js into bare
   pre.codeblock. Both share base + floating styles so the injected button
   never shifts code text (CLS). */
.copy-btn,
.code-copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  width: 28px;
  height: 28px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-3);
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease, opacity 150ms ease;
}

.copy-btn:hover,
.code-copy:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-strong);
}

.copy-btn svg,
.code-copy svg {
  width: 14px;
  height: 14px;
}

.copy-btn .copy-label,
.code-copy .code-copy-label {
  font-size: 0.75rem;
  font-weight: 500;
}

.copy-btn.copied,
.code-copy.copied {
  color: var(--success);
}

.codeblock-header .copy-btn {
  width: auto;
  height: auto;
  padding: 0.375rem 0.625rem;
  border-color: var(--border);
}

/* Floating copy button when there is no header strip */
.codeblock-wrap {
  position: relative;
}

.codeblock-wrap > .copy-btn,
pre.codeblock > button.copy-btn,
pre.codeblock > .copy-btn,
pre.codeblock > .code-copy {
  position: absolute;
  top: 0.625rem;
  right: 0.625rem;
  opacity: 0;
  background: var(--surface);
  border-color: var(--border);
}

.codeblock-wrap:hover > .copy-btn,
.codeblock-wrap:focus-within > .copy-btn,
pre.codeblock:hover > button.copy-btn,
pre.codeblock:focus-within > button.copy-btn,
pre.codeblock:hover > .copy-btn,
pre.codeblock:focus-within > .copy-btn,
pre.codeblock:hover > .code-copy,
pre.codeblock:focus-within > .code-copy {
  opacity: 1;
}

/* Hand-rolled token colors (§4.5). Comment is --text-3 for 5.11:1 on code-bg. */
.tok-keyword { color: #E8896B; }
.tok-string  { color: #A8C686; }
.tok-comment { color: #8E8773; font-style: italic; }
.tok-number  { color: #E0A458; }
.tok-function{ color: #EFCFA4; }
.tok-operator,
.tok-punct   { color: var(--text-2); }

/* --------------------------------------------------------------------------
   9. Inline code (§4.6)
   -------------------------------------------------------------------------- */
.prose code,
p code,
li code,
td code,
.inline-code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  line-height: 1;
  background: var(--inline-code-bg);
  color: var(--inline-code-fg);
  padding: 0.15em 0.375em;
  border-radius: 5px;
  border: 1px solid #3a3222;
  white-space: nowrap;
}

.codeblock code,
.codeblock pre code,
pre.codeblock code {
  font-size: inherit;
  background: transparent;
  border: 0;
  padding: 0;
  color: inherit;
  white-space: pre;
}

/* --------------------------------------------------------------------------
   10. Tables (§4.7)
   -------------------------------------------------------------------------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  margin: 1.5rem 0;
}

.table-wrap table {
  width: 100%;
  border-collapse: collapse;
  margin: 0;
  font-size: 0.9375rem;
}

.table-wrap th {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-3);
  text-align: left;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}

.table-wrap td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9375rem;
  vertical-align: top;
  color: var(--text-2);
}

.table-wrap td:first-child {
  color: var(--text);
}

.table-wrap tbody tr:last-child td {
  border-bottom: 0;
}

.table-wrap tbody tr:hover td {
  background: var(--surface-2);
  transition: background-color 120ms ease;
}

/* --------------------------------------------------------------------------
   11. Admonitions (§4.8)
   -------------------------------------------------------------------------- */
.admonition {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 0.75rem;
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  border: 1px solid;
  font-size: 0.9375rem;
  line-height: 1.65;
}

.admonition-icon {
  margin-top: 0.15rem;
  color: currentColor;
}

.admonition-icon svg {
  width: 20px;
  height: 20px;
  display: block;
}

.admon-title {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 700;
  margin: 0 0 0.375rem;
}

.admonition p {
  margin: 0 0 0.625rem;
  color: var(--text-2);
}

.admonition p:last-child {
  margin-bottom: 0;
}

.admonition a {
  color: var(--link);
}

.admonition.note {
  border-color: #D9775766;
  background: var(--note-bg);
  color: var(--text-2);
}

.admonition.note .admon-title,
.admonition.note .admonition-icon {
  color: var(--accent-text);
}

.admonition.tip {
  border-color: #7FB06966;
  background: var(--success-bg);
  color: var(--text-2);
}

.admonition.tip .admon-title,
.admonition.tip .admonition-icon {
  color: var(--success);
}

.admonition.warning {
  border-color: #E0A45866;
  background: var(--warning-bg);
  color: var(--text-2);
}

.admonition.warning .admon-title,
.admonition.warning .admonition-icon {
  color: var(--warning);
}

.admonition.danger {
  border-color: #DE6B5A66;
  background: var(--danger-bg);
  color: var(--text-2);
}

.admonition.danger .admon-title,
.admonition.danger .admonition-icon {
  color: var(--danger);
}

/* --------------------------------------------------------------------------
   12. Right TOC — aside.toc (§3)
   -------------------------------------------------------------------------- */
.toc {
  position: sticky;
  top: calc(var(--topbar-h) + var(--tabbar-h) + 1.5rem);
  max-height: calc(100vh - var(--topbar-h) - var(--tabbar-h) - 1.5rem);
  overflow-y: auto;
  align-self: start;
}

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

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

#toc-list li,
.toc-list li {
  margin: 0;
}

#toc-list a,
.toc-list a {
  display: block;
  padding: 0.25rem 0;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--text-3);
  transition: color 120ms ease;
}

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

#toc-list a.active,
.toc-list a.active {
  color: var(--accent-text);
  font-weight: 600;
}

#toc-list ul,
.toc-list ul {
  list-style: none;
  margin: 0;
  padding-left: 0.875rem;
}

/* Mobile "On this page" details — hidden on desktop, shown <800px */
.toc-mobile {
  display: none;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  margin: 0 0 1.5rem;
  padding: 0.75rem 1rem;
}

.toc-mobile summary {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.toc-mobile summary::-webkit-details-marker {
  display: none;
}

.toc-mobile summary::after {
  content: "+";
  color: var(--text-3);
  font-size: 1.125rem;
  line-height: 1;
}

.toc-mobile[open] summary::after {
  content: "–";
}

.toc-mobile ul {
  list-style: none;
  margin: 0.75rem 0 0.25rem;
  padding: 0;
}

.toc-mobile a {
  display: block;
  padding: 0.375rem 0;
  font-size: 0.875rem;
  color: var(--text-2);
}

/* --------------------------------------------------------------------------
   13. Advanced details — details.advanced
   -------------------------------------------------------------------------- */
details.advanced {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  margin: 1.5rem 0;
  padding: 0.875rem 1.25rem;
}

details.advanced summary {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: color 120ms ease;
}

details.advanced summary::-webkit-details-marker {
  display: none;
}

details.advanced summary::before {
  content: "▸";
  color: var(--accent-text);
  font-size: 0.875rem;
  transition: transform 120ms ease;
}

details.advanced[open] summary::before {
  transform: rotate(90deg);
}

details.advanced summary:hover {
  color: var(--accent-text);
}

details.advanced .advanced-body {
  margin-top: 0.75rem;
  color: var(--text-2);
  font-size: 0.9375rem;
}

/* --------------------------------------------------------------------------
   14. Search modal — .search-modal (§4.9)
   -------------------------------------------------------------------------- */
.search-scrim {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: var(--overlay);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms var(--ease-drawer);
}

.search-scrim.open {
  opacity: 1;
  pointer-events: auto;
}

.search-modal {
  position: fixed;
  z-index: 100;
  top: 15vh;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  width: min(640px, calc(100vw - 2rem));
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  box-shadow: 0 24px 64px #000000A6;
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms var(--ease-drawer), transform 220ms var(--ease-drawer);
  overflow: hidden;
}

.search-modal.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.search-input-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.search-input-row svg {
  width: 18px;
  height: 18px;
  color: var(--text-3);
  flex-shrink: 0;
}

#search-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.5;
}

#search-input::placeholder {
  color: var(--text-3);
}

#search-results {
  max-height: 50vh;
  overflow-y: auto;
  padding: 0.5rem;
}

.search-result {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  transition: background-color 120ms ease;
}

.search-result:hover,
.search-result.selected {
  background: var(--surface-2);
}

.search-result-title {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.125rem;
}

.search-result-snippet {
  display: block;
  font-size: 0.8125rem;
  color: var(--text-3);
  line-height: 1.5;
}

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

/* --------------------------------------------------------------------------
   15. Footer
   -------------------------------------------------------------------------- */
.footer,
footer.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.footer-inner {
  max-width: 1440px;
  margin-inline: auto;
  padding: 2.5rem 2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  justify-content: space-between;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  color: var(--text);
  font-weight: 600;
  font-size: 0.9375rem;
}

.footer-brand img {
  width: 24px;
  height: 24px;
}

.footer-tagline {
  font-size: 0.8125rem;
  color: var(--text-3);
  margin: 0.5rem 0 0;
  max-width: 32ch;
}

.footer-links {
  display: flex;
  gap: 3rem;
  flex-wrap: wrap;
}

.footer-col-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  margin: 0 0 0.75rem;
}

.footer-links ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.footer-links li {
  margin-bottom: 0.5rem;
}

.footer-links a {
  font-size: 0.875rem;
  color: var(--text-2);
  transition: color 120ms ease;
}

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

.footer-bottom {
  max-width: 1440px;
  margin-inline: auto;
  padding: 0 2rem 2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  font-size: 0.8125rem;
  color: var(--text-3);
}

/* --------------------------------------------------------------------------
   16. Breakpoints (§3)
   -------------------------------------------------------------------------- */

/* 800–1099px: hide right TOC, 2-column grid */
@media (max-width: 1099px) {
  .layout,
  .docs-shell {
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    gap: 2.5rem;
  }

  aside.toc,
  .toc {
    display: none;
  }
}

/* <800px: off-canvas drawer, single column, hamburger */
@media (max-width: 799px) {
  .hamburger {
    display: inline-flex;
  }

  .topbar {
    padding-inline: 1rem;
    gap: 0.75rem;
  }

  .layout,
  .docs-shell {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    padding-inline: 1.5rem;
  }

  /* Sidebar becomes an off-canvas drawer. visibility:hidden (not just
     off-canvas transform) keeps its links out of the keyboard tab order
     and hidden from assistive tech while the drawer is closed. */
  aside.sidebar,
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    top: 0;
    width: min(320px, 85vw);
    max-height: none;
    height: 100dvh;
    background: var(--surface);
    border-right: 1px solid var(--border-strong);
    z-index: 60;
    transform: translateX(-100%);
    visibility: hidden;
    /* NOTE: visibility is intentionally NOT transitioned. A visibility
       transition flips discretely mid-duration, which would leave the
       drawer non-focusable when docs.js moves focus into it on open. */
    transition: transform 220ms var(--ease-drawer);
    padding: 1.5rem 1.25rem 2rem;
    overflow-y: auto;
  }

  body.drawer-open aside.sidebar,
  body.drawer-open .sidebar {
    transform: translateX(0);
    visibility: visible;
  }

  .drawer-scrim {
    position: fixed;
    inset: 0;
    z-index: 55;
    background: var(--overlay);
    opacity: 0;
    pointer-events: none;
    transition: opacity 220ms var(--ease-drawer);
  }

  body.drawer-open .drawer-scrim {
    opacity: 1;
    pointer-events: auto;
  }

  /* TOC becomes the mobile details block */
  .toc-mobile {
    display: block;
  }

  .title-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  #search-open {
    min-width: 0;
  }

  #search-open .search-placeholder,
  #search-open kbd {
    display: none;
  }
}

/* <520px: tighter paddings, icon-only search */
@media (max-width: 519px) {
  .topbar-inner,
  .tabs-inner {
    padding-inline: 1rem;
  }

  .layout,
  .docs-shell {
    padding-inline: 1rem;
    padding-block: 1.5rem 3rem;
  }

  .docs-label {
    display: none;
  }

  #search-open {
    padding: 0.4375rem 0.625rem;
  }

  .wordmark {
    font-size: 0.9375rem;
  }

  a.cta,
  .cta {
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
  }

  .footer-inner,
  .footer-bottom {
    padding-inline: 1rem;
  }
}

/* --------------------------------------------------------------------------
   16b. Integration layer — aliases for the real build.py markup classes
   (kept separate so the §1–§16 system stays untouched)
   -------------------------------------------------------------------------- */

/* Skip link: visually hidden until keyboard-focused.
   Dark text on the accent keeps 5.86:1 contrast (WCAG AA for text). */
.skip-link {
  position: absolute;
  top: -100px;
  left: 1rem;
  z-index: 200;
  background: var(--accent);
  color: #16150F;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.875rem;
  transition: top 120ms ease;
}
.skip-link:focus {
  top: 0.75rem;
  color: #16150F;
  text-decoration: none;
}

/* Topbar brand */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  color: var(--text);
  text-decoration: none;
  flex-shrink: 0;
}
.brand:hover {
  color: var(--text);
  text-decoration: none;
}
.brand img {
  display: block;
}
.brand-divider {
  width: 1px;
  height: 1.25rem;
  background: var(--border);
  margin-inline: 0.25rem;
  flex-shrink: 0;
}

/* Tab bar — real markup: ul.tab-list > li.tab-item > a.tab-link */
.tab-list {
  display: flex;
  align-items: stretch;
  gap: 0.25rem;
  list-style: none;
  margin: 0;
  padding: 0;
  height: 100%;
}
.tab-item {
  display: flex;
  list-style: none;
}
.tab-link {
  display: inline-flex;
  align-items: center;
  padding: 0 1rem;
  color: var(--text-2);
  font-size: 0.875rem;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}
.tab-link:hover {
  color: var(--text);
  border-bottom-color: var(--border-strong);
  text-decoration: none;
}
.tab-link[data-active="true"] {
  color: var(--text);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* Sidebar nav — real markup: p.nav-group-label, ul.nav-list, a.nav-item */
.nav-group-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  margin: 1.5rem 0 0.5rem;
  padding-inline: 0.75rem;
}
.nav-group:first-child .nav-group-label {
  margin-top: 0;
}
.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav-item {
  display: block;
  padding: 0.375rem 0.75rem;
  border-radius: 6px;
  border-left: 2px solid transparent;
  color: var(--text-2);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.4;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}
.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}
.nav-item[data-active="true"] {
  background: var(--accent-dim);
  color: var(--accent-text);
  font-weight: 600;
  border-left-color: var(--accent);
}

/* Drawer close button: only visible when the sidebar is a mobile drawer */
.drawer-close {
  display: none;
}
@media (max-width: 799px) {
  .drawer-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    margin-left: auto;
    margin-bottom: 0.5rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-2);
    cursor: pointer;
  }
  .drawer-close:hover {
    color: var(--text);
    border-color: var(--border-strong);
  }
}

/* Search trigger (topbar) */
.search-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-3);
  font-size: 0.875rem;
  padding: 0.4375rem 0.75rem;
  cursor: pointer;
  transition: border-color 120ms ease, color 120ms ease;
}
.search-trigger:hover {
  border-color: var(--border-strong);
  color: var(--text-2);
}
.search-kbd {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0.0625rem 0.375rem;
  color: var(--text-2); /* 10.4:1 on --surface-2 (AA) */
}

/* Search modal internals — real markup uses .search-box */
.search-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.search-icon {
  color: var(--text-3);
  flex-shrink: 0;
}
.search-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--text-3);
  cursor: pointer;
  flex-shrink: 0;
}
.search-close:hover {
  background: var(--surface-2);
  color: var(--text);
}
.search-results {
  max-height: 50vh;
  overflow-y: auto;
  padding: 0.5rem;
  list-style: none;
  margin: 0;
}
/* Search result items (rendered by search.js) */
.search-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.search-list li {
  margin: 0;
}
.search-list a {
  display: block;
  padding: 0.625rem 0.875rem;
  border-radius: 8px;
  text-decoration: none;
}
.search-list li.is-active a,
.search-list a:hover {
  background: var(--surface-2);
  text-decoration: none;
}
.search-eyebrow {
  display: block;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-text);
  margin-bottom: 0.125rem;
}
.search-title {
  display: block;
  font-weight: 600;
  color: var(--text);
  font-size: 0.9375rem;
}
.search-snippet {
  display: block;
  font-size: 0.8125rem;
  color: var(--text-3);
  margin-top: 0.125rem;
  line-height: 1.5;
}
.search-snippet mark {
  background: var(--accent-dim);
  color: var(--accent-text);
  border-radius: 3px;
  padding: 0 1px;
}
.search-status {
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--text-3);
  font-size: 0.875rem;
  margin: 0;
}

/* TOC nested list */
.toc-sub {
  list-style: none;
  margin: 0.25rem 0 0.25rem 0.5rem;
  padding: 0 0 0 0.75rem;
  border-left: 1px solid var(--border);
}
.toc-sub a {
  font-size: 0.8125rem;
}

/* Prev / next page nav */
.prev-next {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.page-next {
  margin-left: auto;
  text-align: right;
  display: block;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  max-width: 22rem;
  transition: border-color 120ms ease, background-color 120ms ease;
}
.page-next:hover {
  border-color: var(--border-strong);
  background: var(--surface);
  text-decoration: none;
}
.page-prev {
  margin-right: auto;
  text-align: left;
  display: block;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  max-width: 22rem;
  transition: border-color 120ms ease, background-color 120ms ease;
}
.page-prev:hover {
  border-color: var(--border-strong);
  background: var(--surface);
  text-decoration: none;
}
.prev-next-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  margin-bottom: 0.25rem;
}
.prev-next-title {
  display: block;
  font-weight: 600;
  color: var(--text);
}

/* Admonition internals — real markup: span.admon-icon, div.admon-body */
.admon-icon {
  margin-top: 0.15rem;
  color: currentColor;
}
.admon-icon svg {
  width: 20px;
  height: 20px;
  display: block;
}
.admon-body {
  min-width: 0;
}

/* 404 page: standalone centered content (no sidebar grid) */
.not-found {
  max-width: 44rem;
  margin: 0 auto;
  padding: 4rem 2rem 6rem;
}

/* Mobile fixes (visual QA 2026-09-26) */
@media (max-width: 799px) {
  /* Let long inline code wrap instead of overflowing the viewport.
     (Includes .prose code to beat the base rule's specificity.) */
  .prose code,
  p code,
  li code,
  td code,
  .inline-code {
    white-space: normal;
    overflow-wrap: anywhere;
  }
  /* The kbd hint pill gets squished in the narrow topbar — hide it */
  .search-kbd {
    display: none;
  }
}

/* --------------------------------------------------------------------------
   17. Motion (§5) — reduced motion last so it wins
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}

/* --------------------------------------------------------------------------
   18. Guide screenshots — dashboard.md and future image-bearing pages
   -------------------------------------------------------------------------- */
.content img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.5rem auto;
  border: 1px solid var(--border, #2a2a2a);
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}
