/* @font-face declarations are inlined into <head> via index.hbs so they can
   reference cache-busted font URLs through mdBook's `resource` helper. */

/* Type scale. */

main h1 {
  font-family: var(--font-serif);
  font-size: 40px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 0 0 var(--space-5);
  color: var(--text-heading);
}

main h2 {
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.005em;
  margin: var(--space-6) 0 var(--space-3);
  color: var(--text-heading);
}
/* H2 immediately after H1: collapse the upper margin so the lede paragraph
   doesn't get pushed away awkwardly. */
main h1 + h2 { margin-top: var(--space-5); }

main h3 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  line-height: 1.4;
  margin: var(--space-6) 0 var(--space-2);
  color: var(--text-heading);
}

main h4 {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  line-height: 1.4;
  margin: var(--space-5) 0 var(--space-2);
  color: var(--text-heading);
}

main h5, main h6 {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  margin: var(--space-4) 0 var(--space-2);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

main p, main li {
  font-family: var(--font-sans);
  font-size: 17px;
  font-weight: 400;
  line-height: 1.65;
  color: var(--text-body);
}

main p { margin: 0 0 var(--space-4); }

main ul, main ol { margin: 0 0 var(--space-4); padding-left: var(--space-6); }
main li { margin-bottom: var(--space-2); }
main li > p:last-child { margin-bottom: 0; }

main strong { font-weight: 600; }
main em { font-style: italic; }

@media (max-width: 768px) {
  main h1 { font-size: 32px; }
  main h2 { font-size: 24px; }
  main h3 { font-size: 18px; }
  main h4 { font-size: 16px; }
  main p, main li { font-size: 16px; }
}
/* Resets and global defaults. */

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

html {
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.65;
  color: var(--text-body);
  background: var(--bg-page);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "kern", "liga";
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-page);
  color: var(--text-body);
}

::selection { background: var(--selection-bg); color: var(--selection-fg); }

a {
  color: var(--text-link);
  text-decoration-color: transparent;
  text-decoration-line: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  transition: text-decoration-color var(--transition);
}
a:hover {
  text-decoration-color: var(--text-link-decoration);
}

/* On dark theme, links are already yellow — underline yellow on hover stays consistent.
   On light theme, link color is near-black with a yellow underline appearing on hover. */

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: var(--space-7) 0;
}

img, svg, video {
  max-width: 100%;
  height: auto;
}

button {
  font: inherit;
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
}

input, textarea, select {
  font: inherit;
  color: inherit;
}

/* Focus rings — yellow with a darker inner outline so visible against any background. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 1px var(--focus-ring-inner);
  border-radius: var(--radius-sm);
}

/* Skip-to-content for screen readers. */
.skip-link {
  position: absolute;
  top: -200px;
  left: var(--space-4);
  padding: var(--space-2) var(--space-4);
  background: var(--accent);
  color: var(--accent-text-on);
  font-weight: 600;
  z-index: 1000;
  border-radius: var(--radius-sm);
  text-decoration: none;
}
.skip-link:focus { top: var(--space-4); }

/* Visually hidden helper. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Anchor links on headings. */
main h1, main h2, main h3, main h4, main h5, main h6 {
  scroll-margin-top: calc(var(--header-height) + 16px);
  position: relative;
}
main h1 a.header, main h2 a.header, main h3 a.header,
main h4 a.header, main h5 a.header, main h6 a.header {
  color: inherit !important;
  text-decoration: none;
  background: transparent !important;
}
main h2 a.header::before,
main h3 a.header::before,
main h4 a.header::before {
  content: "#";
  position: absolute;
  left: -0.7em;
  font-size: 0.7em;
  font-weight: 500;
  line-height: inherit;
  top: 0.2em;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity var(--transition);
}
main h2:hover a.header::before,
main h3:hover a.header::before,
main h4:hover a.header::before {
  opacity: 1;
}

/* Inline code. */
main p code, main li code, main td code, main th code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  padding: 0.1em 0.35em;
  background: var(--bg-surface-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-body);
}

main pre {
  font-family: var(--font-mono);
  background: var(--bg-code);
  color: var(--text-body);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin: 0 0 var(--space-5);
  overflow-x: auto;
  font-size: 14px;
  line-height: 1.6;
}
main pre code {
  background: transparent;
  border: 0;
  padding: 0;
  font-size: inherit;
  color: inherit;
}

/* Blockquote. */
main blockquote {
  margin: 0 0 var(--space-5);
  padding: var(--space-3) var(--space-5);
  border-left: 4px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
}
main blockquote > p:last-child { margin-bottom: 0; }

/* Images in markdown — frame and center. */
main p > img,
main img.framed {
  display: block;
  margin: var(--space-5) auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  background: var(--bg-surface);
}

/* Print enhancements. */
@media print {
  .skip-link, header, nav#sidebar, aside.right-rail, button { display: none !important; }
  body { background: white; color: black; }

  /* Wrap any horizontally-scrollable content so nothing is cut off in PDF
     output. Drops the scroll containers and the right-edge gradient hint. */
  main .table-scroll,
  main .table-scroll-inner,
  main .code-block,
  main .code-block > pre {
    overflow: visible !important;
  }
  main .table-scroll::after { display: none !important; }

  /* Allow long lines inside <pre> to wrap. Preserve whitespace so indentation
     is kept; break at any character so very long unbreakable strings (URLs,
     hashes, tokens) don't run off the page. */
  main pre,
  main pre code {
    white-space: pre-wrap !important;
    word-break: break-word !important;
    overflow-wrap: anywhere !important;
  }

  /* Tables: allow cell content to wrap and let columns size to content. */
  main table { table-layout: auto !important; width: 100% !important; }
  main thead th,
  main tbody td {
    white-space: normal !important;
    word-break: break-word !important;
    overflow-wrap: anywhere !important;
  }

  /* Hide the floating code toolbar (lang pill + copy icon) in print. */
  main .code-toolbar,
  main .code-lang { display: none !important; }
  main .code-block > pre { padding-top: var(--space-4) !important; padding-right: var(--space-4) !important; }

  /* Avoid orphaning a heading from its content across page breaks. */
  main h1, main h2, main h3, main h4 {
    break-after: avoid;
    page-break-after: avoid;
  }
  main pre, main figure, main img, main table {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}
/* Three-column shell. */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: var(--header-height) 1fr;
  grid-template-areas:
    "header header"
    "sidebar main";
  min-height: 100vh;
}

.app-header { grid-area: header; }
.app-sidebar { grid-area: sidebar; }
.app-main { grid-area: main; }

/* Content + right-rail layout inside main. Right rail is ALWAYS visible
   on wide viewports — see DOCS_STRUCTURE.md / UI-UX.md.
   padding-left equals the inner grid `gap` so the content column appears
   visually centered between the sidebar and the right rail. */
.app-main {
  display: grid;
  grid-template-columns: 1fr var(--right-rail-width);
  gap: var(--space-7);
  align-items: start;
  padding: var(--space-7) var(--space-5) var(--space-7) var(--space-7);
  min-width: 0;
}
.app-main > .content-column {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  justify-self: center;
  min-width: 0;
}

/* Pages that wrap content in <div class="landscape"> opt out of the
   readable-measure constraint — used for wide tables and diagrams.
   Both the left sidebar and the right rail stay visible. The
   .landscape block owns its horizontal overflow so a wide table
   scrolls inside it instead of expanding the outer grid. */
.app:has(.landscape) {
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}
.app-main:has(.landscape) {
  grid-template-columns: minmax(0, 1fr) var(--right-rail-width);
}
.app-main:has(.landscape) > .content-column { max-width: none; min-width: 0; }
.landscape {
  max-width: 100%;
  overflow-x: auto;
}
.landscape > *,
.landscape main > p,
.landscape main > ul,
.landscape main > ol,
.landscape main > blockquote { max-width: none; }

.right-rail {
  display: block;
  position: sticky;
  top: calc(var(--header-height) + var(--space-5));
  max-height: calc(100vh - var(--header-height) - var(--space-6));
  overflow-y: auto;
  font-family: var(--font-display);
  font-size: 13px;
  color: var(--text-muted);
  padding-bottom: var(--space-5);
}

/* The content column ensures readable measure for prose, but allows
   tables/code/diagrams to span its full width. */
.content-column main {
  min-width: 0;
}
.content-column main > p,
.content-column main > ul,
.content-column main > ol,
.content-column main > blockquote {
  max-width: var(--measure);
}

/* Responsive breakpoints. */
@media (max-width: 1279px) {
  .app-main {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .right-rail { display: none; }
  .app-main > .content-column { margin: 0 auto; justify-self: center; }
}

@media (max-width: 1023px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-areas:
      "header"
      "main";
  }
  .app-sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    width: 280px;
    transform: translateX(-100%);
    transition: transform var(--transition-slow);
    z-index: 50;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow-md);
  }
  body.sidebar-open .app-sidebar { transform: translateX(0); }
  body.sidebar-open::before {
    content: "";
    position: fixed;
    inset: var(--header-height) 0 0 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 40;
  }
}

@media (max-width: 768px) {
  :root { --header-height: 56px; }
  .app-main { padding: var(--space-5) var(--space-4); }
}

/* Page-end nav (Previous / Next). */
.nav-wrapper {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
  margin-top: var(--space-7);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border);
}
.nav-wrapper a {
  display: block;
  padding: var(--space-4);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text-body);
  transition: border-color var(--transition);
}
.nav-wrapper a:hover {
  border-color: var(--border-strong);
}
.nav-wrapper a .nav-label {
  display: block;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: var(--space-1);
}
.nav-wrapper a .nav-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
}
.nav-wrapper a.next { text-align: right; grid-column: 2; }
.nav-wrapper a.previous { grid-column: 1; }

@media (max-width: 768px) {
  .nav-wrapper { grid-template-columns: 1fr; }
  .nav-wrapper a.next, .nav-wrapper a.previous { grid-column: 1; text-align: left; }
}
/* Header. */

/* Header is always navy + yellow on both themes — Exaba's signature combo.
   Surfaces inside (search button, hover backgrounds) use a slightly lighter
   navy so they read against the header background. */
.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--header-height);
  background: #10253E;
  color: #E8ECF1;
  border-bottom: 1px solid #2A4972;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: 0 var(--space-5);
  transition: box-shadow var(--transition);
}
.app-header.is-scrolled { box-shadow: var(--shadow-sm); }

.header-logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: #FFFFFF;
  text-decoration: none;
  flex-shrink: 0;
}
.header-logo svg {
  height: 32px;
  width: auto;
  display: block;
}
.header-logo:hover { text-decoration: none; }

.header-search {
  flex: 1;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}
.header-search button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: #17304F;
  border: 1px solid #2A4972;
  border-radius: var(--radius-md);
  font-family: var(--font-display);
  font-size: 14px;
  color: #A8B5C7;
  text-align: left;
  transition: border-color var(--transition);
}
.header-search button:hover { border-color: #3A5A85; color: #E8ECF1; }
.header-search .search-icon { width: 16px; height: 16px; flex-shrink: 0; }
.header-search .search-label { flex: 1; }
.header-search .search-shortcut {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 500;
  border-radius: 4px;
  background: var(--accent);
  color: #10253E;
  border: 1px solid var(--accent);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}
.header-actions a, .header-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  color: #A8B5C7;
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
}
.header-actions a:hover, .header-actions button:hover {
  background: #17304F;
  color: #FFFFFF;
  text-decoration: none;
}
.header-actions svg { width: 18px; height: 18px; }

.sidebar-toggle {
  display: none;
}
@media (max-width: 1023px) {
  .sidebar-toggle { display: inline-flex; }
}

@media (max-width: 768px) {
  .app-header { padding: 0 var(--space-3); gap: var(--space-2); }
  .header-search { max-width: none; }
  .header-search .search-label { font-size: 13px; }
  /* Hide the action icons on mobile; they live in the sidebar drawer footer. */
  .header-actions { display: none; }
}

/* Sidebar drawer footer (theme/print/github). Hidden on desktop where the
   header carries those actions. */
.sidebar-actions {
  display: none;
}
@media (max-width: 768px) {
  .sidebar-actions {
    display: flex;
    flex-direction: column;
    margin-top: auto;
    padding: var(--space-2) var(--space-2) 2px;
    border-top: 1px solid var(--border);
    gap: 0;
  }
  .sidebar-actions a, .sidebar-actions button {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    width: 100%;
    padding: 6px var(--space-2);
    background: transparent;
    border: 0;
    border-radius: var(--radius-sm);
    color: var(--text-body);
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
  }
  .sidebar-actions a:hover, .sidebar-actions button:hover {
    background: var(--bg-surface-hover);
    text-decoration: none;
  }
  .sidebar-actions svg { width: 14px; height: 14px; flex-shrink: 0; }
  /* Allow the sidebar to align its footer to the bottom on mobile. */
  .app-sidebar { display: flex; flex-direction: column; padding-bottom: 0; }
  .app-sidebar mdbook-sidebar-scrollbox { flex: 1; min-height: 0; overflow-y: auto; }
  /* Right-align the search icon-button when the action icons are out of the way. */
  .header-search { margin: 0 0 0 auto; max-width: 40px; }
}
/* Linear-style sidebar. */

.app-sidebar {
  position: sticky;
  top: var(--header-height);
  align-self: start;
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
  background: var(--bg-page);
  border-right: 1px solid var(--border);
  padding: var(--space-5) 0;
  font-family: var(--font-display);
  font-size: 14px;
}

.app-sidebar nav { padding: 0; }

.app-sidebar ol, .app-sidebar ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Top-level "part_title" rendered by mdBook for SUMMARY.md headers. */
.app-sidebar li.part-title {
  display: block;
  padding: var(--space-4) var(--space-5) var(--space-2);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Collapsible top-level sections (single-open accordion). sidebar.js promotes
   each part-title li to a clickable section header by adding the .part-section
   class, marks the section containing the active page with .part-active, and
   tags every chapter-item belonging to a collapsed section with .part-hidden.
   (mdBook's toc.js wraps part-titles in an extra <li>, but that's invalid
   HTML — browsers strip the wrapper, so the part-title <li> is the live node.) */
.app-sidebar li.part-title.part-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}
.app-sidebar li.part-title.part-section:hover {
  color: var(--text-body);
}
.app-sidebar li.part-title.part-section.part-active {
  color: var(--text-body);
}
.app-sidebar li.part-title.part-section::after {
  content: "";
  display: inline-block;
  width: 0;
  height: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 5px solid currentColor;
  margin-left: var(--space-2);
  opacity: 0.7;
  transition: transform var(--transition);
}
.app-sidebar li.part-title.part-section.part-open::after {
  transform: rotate(90deg);
}
.app-sidebar li.chapter-item.part-hidden { display: none; }

/* Chapter / page items. */
.app-sidebar li.chapter-item,
.app-sidebar li {
  position: relative;
  margin: 0;
}

/* mdBook 0.5.x emits items as:
     <li class="chapter-item [has-children] [expanded]">
       <span class="chapter-link-wrapper">
         <a href="..." [class="active"]>...</a>
         [<a class="chapter-fold-toggle"><div>❱</div></a>]
       </span>
       [<ol class="chapter">…nested…</ol>]
     </li>
   The wrapper layout puts the link and the fold-toggle anchor on one row. */

.app-sidebar .chapter-link-wrapper {
  display: flex;
  align-items: stretch;
  position: relative;
  border-left: 3px solid transparent;
  transition: background var(--transition), border-color var(--transition);
}
.app-sidebar .chapter-link-wrapper:hover {
  background: var(--bg-surface-hover);
  border-left-color: var(--accent);
}
.app-sidebar .chapter-link-wrapper:has(a.active) {
  background: var(--bg-surface-hover);
  border-left-color: var(--accent);
}

/* Page-link anchor (NOT the chapter-fold-toggle). Take all available width. */
.app-sidebar .chapter-link-wrapper > a:not(.chapter-fold-toggle) {
  flex: 1 1 auto;
  display: block;
  padding: 6px var(--space-5);
  color: var(--text-body);
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  line-height: 1.4;
  min-width: 0;
}
.app-sidebar a:hover { text-decoration: none; }
.app-sidebar a.active {
  color: var(--text-heading);
  font-weight: 600;
}

/* Nested levels: indentation. mdBook 0.5.x uses ol.section for nested children. */
.app-sidebar ol.section .chapter-link-wrapper > a:not(.chapter-fold-toggle) {
  padding-left: calc(var(--space-5) + var(--space-4));
}
.app-sidebar ol.section ol.section .chapter-link-wrapper > a:not(.chapter-fold-toggle) {
  padding-left: calc(var(--space-5) + var(--space-7));
}

/* Numbered chapter prefix from SUMMARY.md. */
.app-sidebar a strong {
  font-weight: 500;
  color: var(--text-muted);
  margin-right: 0.4em;
  font-variant-numeric: tabular-nums;
}
.app-sidebar a.active strong { color: var(--text-heading); }

/* Folding chevrons (mdBook 0.5.x emits <a class="chapter-fold-toggle"><div>❱</div></a>). */
.app-sidebar .chapter-fold-toggle {
  flex: 0 0 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  width: 28px;
  height: auto;
  align-self: stretch;
  color: var(--text-muted);
  text-decoration: none;
}
.app-sidebar .chapter-fold-toggle:hover { color: var(--text-body); }
.app-sidebar .chapter-fold-toggle > div {
  /* Replace mdBook's Unicode chevron with a CSS triangle so we don't depend
     on font glyph availability. */
  font-size: 0;
  width: 0;
  height: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 5px solid currentColor;
  transition: transform var(--transition);
}
.app-sidebar li.expanded > .chapter-link-wrapper .chapter-fold-toggle > div,
.app-sidebar li.expanded > .chapter-fold-toggle > div { transform: rotate(90deg); }

.app-sidebar li.affix > .chapter-link-wrapper a { font-weight: 600; }

/* Collapse nested sections when parent is not expanded. */
/* mdBook 0.5.x uses ol.section for nested chapters. The presence of a
   nested ol.section is the implicit "has children" signal — there's no
   .has-children class. Collapse by default; expanded class reveals. */
.app-sidebar li.chapter-item > ol.section { display: none; }
.app-sidebar li.chapter-item.expanded > ol.section { display: block; }

/* Spacers and dividers. */
.app-sidebar li.spacer,
.app-sidebar hr {
  display: block;
  height: 1px;
  background: var(--border);
  border: 0;
  margin: var(--space-3) var(--space-5);
  padding: 0;
}

@media (max-width: 1023px) {
  .app-sidebar { height: calc(100vh - var(--header-height)); }
}
/* Right-rail "On this page" TOC. */

.right-rail__heading {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 var(--space-2);
  padding-left: 0;
}

.right-rail ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.right-rail li { margin: 0; }

.right-rail ul li a {
  display: block;
  padding: 6px 0 6px var(--space-3);
  font-family: var(--font-display);
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  border-left: 2px solid transparent;
  line-height: 1.4;
  margin-left: -2px;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}
.right-rail ul li a:hover { color: var(--text-body); }
.right-rail ul li a.active {
  color: var(--text-heading);
  border-left-color: var(--accent);
  background: var(--bg-surface-hover);
  font-weight: 600;
}

.right-rail li.level-1 > a { font-weight: 600; color: var(--text-body); }
.right-rail li.level-3 a { padding-left: calc(var(--space-3) + var(--space-3)); }
.right-rail li.level-4 a { padding-left: calc(var(--space-3) + var(--space-5)); }

.right-rail__meta {
  margin-top: var(--space-5);
  padding: var(--space-3) 0 0 0;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.right-rail__meta a {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0;
  color: var(--text-muted);
  font-weight: 500;
  text-decoration: none;
}
.right-rail__meta a:hover { color: var(--text-body); text-decoration: none; }
.right-rail__meta svg { width: 12px; height: 12px; }
.right-rail__meta .last-updated { padding: 0; }
.right-rail__meta .copy-md {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0;
  background: none;
  border: 0;
  color: var(--text-muted);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
}
.right-rail__meta .copy-md:hover { color: var(--text-body); }
/* ⌘K search palette. */

.search-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
}
.search-overlay.is-open { opacity: 1; pointer-events: auto; }

.search-palette {
  width: 640px;
  max-width: calc(100vw - var(--space-5));
  max-height: 70vh;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.96);
  transition: transform var(--transition-fast);
}
.search-overlay.is-open .search-palette { transform: scale(1); }

.search-input-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  border-bottom: 1px solid var(--border);
}
.search-input-wrap svg { width: 16px; height: 16px; color: var(--text-muted); flex-shrink: 0; }
.search-input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 500;
  color: var(--text-body);
}
.search-input::placeholder { color: var(--text-muted); }
.search-close {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 500;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  background: var(--bg-surface);
}

.search-results {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-2);
}

.search-section-heading {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: var(--space-3) var(--space-3) var(--space-1);
}

.search-result {
  display: block;
  padding: var(--space-3);
  margin-bottom: 2px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-body);
  transition: background var(--transition-fast);
}
.search-result:hover, .search-result.is-active {
  background: var(--bg-surface-hover);
  text-decoration: none;
}
.search-result.is-active { outline: 2px solid var(--accent); outline-offset: -2px; }

.search-result__breadcrumb {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}

.search-result__title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-heading);
  margin-bottom: 2px;
}

.search-result__snippet {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.search-result mark {
  background: var(--accent);
  color: var(--accent-text-on);
  padding: 0 2px;
  border-radius: 2px;
}

.search-empty {
  padding: var(--space-5);
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

.search-footer {
  padding: var(--space-2) var(--space-4);
  border-top: 1px solid var(--border);
  font-family: var(--font-display);
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
}
.search-footer kbd {
  font-family: var(--font-display);
  font-size: 11px;
  padding: 1px 5px;
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-body);
}
/* Code blocks. */

/* Code block container — built by code-enhance.js, hosts the toolbar. */
main .code-block {
  position: relative;
  margin: 0 0 var(--space-5);
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
main .code-block > pre {
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  /* Top padding reserved for the language pill that sits above the code. */
  padding-top: 36px;
}
main .code-block:not([data-lang]) > pre { padding-top: var(--space-4); }

@media (max-width: 768px) {
  /* On small screens, hide the language pill and shrink the toolbar so the
     copy icon doesn't crowd or visually overlap the code. */
  main .code-lang { display: none; }
  main .code-block > pre { padding-top: var(--space-4); padding-right: 44px; }
  main .code-toolbar { top: 4px; right: 4px; }
}

/* Language pill anchored to the top-left of the code block, sitting ABOVE
   the code so it never overlaps content. */
main .code-lang {
  position: absolute;
  top: 8px;
  left: 12px;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--bg-surface-hover);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
  user-select: none;
  z-index: 2;
  pointer-events: none;
}

/* Toolbar at the top-right hosts the copy button, sitting inline above
   the code (the pre's padding-top reserves space). */
main .code-toolbar {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  z-index: 2;
}

main .code-copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  color: var(--text-muted);
  background: var(--bg-surface-hover);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
  box-shadow: 0 0 0 4px var(--bg-code);
}
main .code-copy svg { display: block; }
main .code-copy:hover {
  color: var(--text-body);
  border-color: var(--border-strong);
}
main .code-copy.is-copied {
  color: var(--accent-text-on);
  background: var(--accent);
  border-color: var(--accent);
}

main pre > code {
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.6;
  display: block;
  background: transparent;
}

/* Highlight.js token base styles. Light theme below; dark via the highlight-dark css. */

/* GitHub Light palette. */
html.exaba-light .hljs,
html:not(.exaba-dark):not(.exaba-light) .hljs { color: #24292e; background: var(--bg-code); }
html.exaba-light .hljs-doctag,
html.exaba-light .hljs-keyword,
html.exaba-light .hljs-meta .hljs-keyword,
html.exaba-light .hljs-template-tag,
html.exaba-light .hljs-template-variable,
html.exaba-light .hljs-type,
html.exaba-light .hljs-variable.language_ { color: #d73a49; }
html.exaba-light .hljs-title,
html.exaba-light .hljs-title.class_,
html.exaba-light .hljs-title.class_.inherited__,
html.exaba-light .hljs-title.function_ { color: #6f42c1; }
html.exaba-light .hljs-attr,
html.exaba-light .hljs-attribute,
html.exaba-light .hljs-literal,
html.exaba-light .hljs-meta,
html.exaba-light .hljs-number,
html.exaba-light .hljs-operator,
html.exaba-light .hljs-variable,
html.exaba-light .hljs-selector-attr,
html.exaba-light .hljs-selector-class,
html.exaba-light .hljs-selector-id { color: #005cc5; }
html.exaba-light .hljs-regexp,
html.exaba-light .hljs-string,
html.exaba-light .hljs-meta .hljs-string { color: #032f62; }
html.exaba-light .hljs-built_in,
html.exaba-light .hljs-symbol { color: #e36209; }
html.exaba-light .hljs-comment,
html.exaba-light .hljs-code,
html.exaba-light .hljs-formula { color: #6a737d; }
html.exaba-light .hljs-name,
html.exaba-light .hljs-quote,
html.exaba-light .hljs-selector-tag,
html.exaba-light .hljs-selector-pseudo { color: #22863a; }
html.exaba-light .hljs-section { color: #005cc5; font-weight: bold; }
html.exaba-light .hljs-emphasis { font-style: italic; }
html.exaba-light .hljs-strong { font-weight: bold; }

/* Brand-tinted GitHub Dark variant. */
html.exaba-dark .hljs { color: #c9d1d9; background: var(--bg-code); }
html.exaba-dark .hljs-doctag,
html.exaba-dark .hljs-keyword,
html.exaba-dark .hljs-meta .hljs-keyword,
html.exaba-dark .hljs-template-tag,
html.exaba-dark .hljs-template-variable,
html.exaba-dark .hljs-type,
html.exaba-dark .hljs-variable.language_ { color: #ff7b72; }
html.exaba-dark .hljs-title,
html.exaba-dark .hljs-title.class_,
html.exaba-dark .hljs-title.class_.inherited__,
html.exaba-dark .hljs-title.function_ { color: #d2a8ff; }
html.exaba-dark .hljs-attr,
html.exaba-dark .hljs-attribute,
html.exaba-dark .hljs-literal,
html.exaba-dark .hljs-meta,
html.exaba-dark .hljs-number,
html.exaba-dark .hljs-operator,
html.exaba-dark .hljs-variable,
html.exaba-dark .hljs-selector-attr,
html.exaba-dark .hljs-selector-class,
html.exaba-dark .hljs-selector-id { color: #79c0ff; }
html.exaba-dark .hljs-regexp,
html.exaba-dark .hljs-string,
html.exaba-dark .hljs-meta .hljs-string { color: #a5d6ff; }
html.exaba-dark .hljs-built_in,
html.exaba-dark .hljs-symbol { color: #ffa657; }
html.exaba-dark .hljs-comment,
html.exaba-dark .hljs-code,
html.exaba-dark .hljs-formula { color: #8b949e; }
html.exaba-dark .hljs-name,
html.exaba-dark .hljs-quote,
html.exaba-dark .hljs-selector-tag,
html.exaba-dark .hljs-selector-pseudo { color: #7ee787; }
html.exaba-dark .hljs-section { color: #79c0ff; font-weight: bold; }
html.exaba-dark .hljs-emphasis { font-style: italic; }
html.exaba-dark .hljs-strong { font-weight: bold; }

/* prefers-color-scheme: dark fallback when no explicit theme class. */
@media (prefers-color-scheme: dark) {
  html:not(.exaba-light) .hljs { color: #c9d1d9; background: var(--bg-code); }
  html:not(.exaba-light) .hljs-doctag,
  html:not(.exaba-light) .hljs-keyword,
  html:not(.exaba-light) .hljs-template-tag,
  html:not(.exaba-light) .hljs-type { color: #ff7b72; }
  html:not(.exaba-light) .hljs-string { color: #a5d6ff; }
  html:not(.exaba-light) .hljs-comment { color: #8b949e; }
  html:not(.exaba-light) .hljs-number,
  html:not(.exaba-light) .hljs-attr,
  html:not(.exaba-light) .hljs-literal { color: #79c0ff; }
  html:not(.exaba-light) .hljs-built_in { color: #ffa657; }
  html:not(.exaba-light) .hljs-name { color: #7ee787; }
}
/* Tables. */

/* Tables sit inside a stable wrapper that handles horizontal overflow.
   The wrapper itself shows the right-edge gradient hint (pinned to the
   wrapper's visible right edge, not the table's right edge). */
main .table-scroll {
  margin: 0 0 var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  position: relative;
  overflow: hidden; /* Clip the rounded corners; child handles horizontal scroll. */
}

/* Inner element actually scrolls; this lets the wrapper's overflow:hidden
   keep the rounded corners while the gradient sits OUTSIDE the scroll. */
main .table-scroll-inner {
  overflow-x: auto;
}

/* Right-edge gradient hint pinned to the wrapper (not the scrolled inner). */
main .table-scroll::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 24px;
  background: linear-gradient(to left, var(--bg-surface), transparent);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition);
  z-index: 1;
}
main .table-scroll.has-overflow::after { opacity: 1; }

main table {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  font-feature-settings: "tnum";
  margin: 0;
}

main thead {
  background: var(--bg-surface-hover);
}

main thead th {
  background: var(--bg-surface-hover);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: left;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

main tbody td {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid rgba(128, 128, 128, 0.15);
  vertical-align: top;
  color: var(--text-body);
}

main tbody tr:first-child td { border-top: 0; }

main table.zebra tbody tr:nth-child(even) {
  background: var(--bg-surface-hover);
}

/* sticky-thead disabled: the table-scroll-inner only scrolls horizontally,
   and a vertical-sticky thead inside a horizontal-scroll context creates a
   visible gap above the header row equal to its `top` offset. Re-enable
   only if we move tables into a page-level vertical-scroll container. */
/* Motion utilities + reduced-motion. */

@view-transition { navigation: auto; }

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 120ms;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0ms !important;
    animation-duration: 0ms !important;
    animation-iteration-count: 1 !important;
  }
  ::view-transition-old(root),
  ::view-transition-new(root) { animation: none !important; }
}

/* ============================================================================
   Responsive overrides (placed last so they win against the per-component
   default rules above).
   ============================================================================ */

@media (max-width: 1023px) {
  .app {
    grid-template-columns: 1fr !important;
    grid-template-areas: "header" "main" !important;
  }
  .app-sidebar {
    position: fixed !important;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    width: 280px;
    height: calc(100vh - var(--header-height));
    transform: translateX(-100%);
    transition: transform var(--transition-slow);
    z-index: 50;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow-md);
  }
  body.has-toc .app-main {
    grid-template-columns: 1fr !important;
  }
  body.has-toc .right-rail { display: none !important; }
}

@media (max-width: 768px) {
  :root { --header-height: 56px; }
  .app-header { padding: 0 var(--space-3); gap: var(--space-2); }
  .header-logo svg { height: 28px; }
  .header-search .search-label {
    /* Hide the placeholder text on small screens; keep the icon + chip. */
    display: none;
  }
  .header-search button {
    width: 40px;
    padding: var(--space-2);
    justify-content: center;
  }
  .header-search .search-shortcut { display: none; }
  .app-main { padding: var(--space-5) var(--space-4); }
}
