:root {
  color-scheme: light;
  --surface: #FFFFFF;
  --surface-rgb: 255, 255, 255;
  --ink: #181818;
  --ink-rgb: 24, 24, 24;
  --muted: #5B6472;
  --accent: #0078D4;
  --grid-line: rgba(0, 120, 212, 0.16);
  --font-body: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --step: clamp(1.6rem, 1.5vw + 1.2rem, 2.2rem);
  --highlight-bg: rgba(255, 214, 126, 0.45);
  --highlight-border: rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-body);
  min-height: 100%;
}

body {
  /* App shell: header / content / footer. The `1fr` content row auto-fits to
     whatever space the header+footer leave — no viewport math — and the canvas
     scrolls within it. `dvh` (with `vh` fallback) tracks the dynamic viewport,
     so the shell re-fits on orientation change and when browser UI bars show or
     hide; that, plus the grid 1fr, is what keeps it from clipping. */
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
  min-height: 100dvh;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover,
a:focus {
  text-decoration: underline;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.skip-link:focus {
  position: fixed;
  left: 1rem;
  top: 1rem;
  width: auto;
  height: auto;
  padding: 0.5rem 0.75rem;
  background: var(--ink);
  color: var(--surface);
  letter-spacing: 0.08em;
}

.shell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem clamp(1.5rem, 4vw, 4rem);
  border-bottom: 1px solid var(--grid-line);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(6px);
  background: rgba(var(--surface-rgb), 0.92);
}

.top-actions {
  display: inline-flex;
  gap: 0.75rem;
}

.ghost-button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--grid-line);
  background: transparent;
  padding: 0.4rem 0.75rem;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 999px;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}

.ghost-button:hover,
.ghost-button:focus-visible {
  background: rgba(var(--ink-rgb), 0.08);
  border-color: rgba(var(--ink-rgb), 0.3);
}

.ghost-label {
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}

.share-menu-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: start end;
  padding: 5.25rem clamp(1rem, 4vw, 4rem) 1rem;
  background: rgba(var(--ink-rgb), 0.18);
}

.share-menu-modal {
  width: min(22rem, calc(100vw - 2rem));
  max-height: min(70vh, 34rem);
  overflow: auto;
  border: 1px solid var(--grid-line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 60px rgba(var(--ink-rgb), 0.18);
}

.share-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--grid-line);
}

.share-menu-title {
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.share-menu-close {
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--grid-line);
  border-radius: 4px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
}

.share-menu-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 0.45rem;
  padding: 0.85rem;
}

.share-menu-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 2.4rem;
  border: 1px solid var(--grid-line);
  border-radius: 6px;
  padding: 0.55rem 0.65rem;
  background: rgba(var(--ink-rgb), 0.02);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 0.86rem;
  text-align: left;
}

.share-menu-icon {
  width: 1.125rem;
  height: 1.125rem;
  flex: 0 0 auto;
  object-fit: contain;
}

.share-menu-label {
  min-width: 0;
  overflow-wrap: anywhere;
}

.share-menu-item:hover,
.share-menu-item:focus-visible,
.share-menu-close:hover,
.share-menu-close:focus-visible {
  border-color: rgba(var(--ink-rgb), 0.35);
  background: rgba(var(--ink-rgb), 0.07);
  outline: none;
  text-decoration: none;
}

.share-menu-url {
  margin: 0;
  padding: 0.75rem 1rem 1rem;
  border-top: 1px solid var(--grid-line);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.static-share {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid #eee;
}

.static-share h2 {
  font-size: 0.95rem;
}

.static-share ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Docs Map (#33) — framework-free relationship view. */
.docs-map {
  margin-top: 1.5rem;
  position: relative;
}

.docs-map-svg {
  width: 100%;
  height: auto;
  max-height: 75vh;
  border: 1px solid var(--grid-line);
  border-radius: 8px;
  background: rgba(var(--surface-rgb), 0.4);
  touch-action: none;
  cursor: grab;
}

.docs-map-svg:active {
  cursor: grabbing;
}

.docs-map-controls {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(3, minmax(2rem, auto));
  gap: 0.25rem;
  pointer-events: auto;
}

.docs-map-search {
  grid-column: 1 / -1;
}

.docs-map-search input {
  width: 100%;
  min-height: 1.95rem;
  border: 1px solid var(--grid-line);
  border-radius: 4px;
  padding: 0.35rem 0.5rem;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.78rem;
  opacity: 0.94;
}

.docs-map-search input:focus-visible {
  border-color: var(--muted);
  outline: none;
  opacity: 1;
}

.docs-map-control {
  min-width: 2rem;
  height: 1.85rem;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--grid-line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1;
  opacity: 0.92;
  padding: 0 0.45rem;
  white-space: nowrap;
}

.docs-map-control:hover,
.docs-map-control:focus-visible {
  border-color: var(--muted);
  opacity: 1;
  outline: none;
}

.docs-map-node {
  cursor: pointer;
}

.docs-map-node circle {
  transition: r 120ms ease, opacity 120ms ease, stroke-width 120ms ease;
}

.docs-map-node:hover circle,
.docs-map-node:focus-visible circle,
.docs-map-node.is-active circle {
  r: 11;
  stroke: var(--surface);
  stroke-width: 3px;
}

.docs-map-node.is-neighbor circle {
  r: 10;
  stroke: var(--ink);
  stroke-width: 2px;
}

.docs-map-node.is-dimmed {
  opacity: 0.28;
}

.docs-map-node:focus-visible {
  outline: none;
}

.docs-map-label {
  font-size: 13px;
  fill: var(--ink);
  paint-order: stroke;
  stroke: var(--surface);
  stroke-width: 3px;
  pointer-events: none;
  transition: opacity 140ms ease;
}

.docs-map-label.is-decluttered {
  opacity: 0;
}

.docs-map-community {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.docs-map-edge {
  stroke: var(--grid-line);
  transition: opacity 120ms ease, stroke 120ms ease, stroke-width 120ms ease;
}

.docs-map-edge:hover,
.docs-map-edge.is-active {
  opacity: 0.9;
  stroke: var(--muted);
}

.docs-map-edge.is-dimmed {
  opacity: 0.12;
}

.docs-map-popup {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 5;
  width: min(20rem, calc(100% - 1.5rem));
  max-height: min(65vh, 28rem);
  overflow: auto;
  border: 1px solid var(--grid-line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 1rem 2.5rem rgba(var(--ink-rgb), 0.12);
  padding: 0.85rem;
}

.docs-map-popup[hidden] {
  display: none;
}

.docs-map-popup h2 {
  margin: 0 1.6rem 0.35rem 0;
  color: var(--ink);
  font-size: 0.92rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.docs-map-popup-source {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

.docs-map-popup-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.65rem;
}

.docs-map-popup-chips span {
  border: 1px solid var(--grid-line);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  line-height: 1;
  padding: 0.3rem 0.45rem;
}

.docs-map-popup-open {
  margin-top: 0.85rem;
  border: 1px solid var(--grid-line);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  padding: 0.45rem 0.6rem;
  text-transform: uppercase;
}

.docs-map-popup-open:hover,
.docs-map-popup-open:focus-visible {
  border-color: var(--muted);
  outline: none;
}

.docs-map-popup-close {
  position: absolute;
  top: 0.45rem;
  right: 0.45rem;
  width: 1.3rem;
  height: 1.3rem;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1;
}

.docs-map-popup-close:hover,
.docs-map-popup-close:focus-visible {
  border-color: var(--grid-line);
  color: var(--ink);
  outline: none;
}

.docs-map-empty {
  color: var(--muted);
  font-style: italic;
}

/* Runtime theme picker (#35) — injected into .top-actions when enabled. */
.theme-picker {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.theme-picker-select {
  border: 1px solid var(--grid-line);
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  padding: 0.4rem 0.6rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease;
}

.theme-picker-select:hover,
.theme-picker-select:focus-visible {
  border-color: rgba(var(--ink-rgb), 0.3);
  background: rgba(var(--ink-rgb), 0.04);
}

.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 0.3rem;
  font-size: clamp(1.2rem, 2vw, 1.6rem);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  /* The brand is the home link — it should read as clickable (pointer, not a
     text caret) and never as underlined link text. */
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  width: fit-content;
  border-radius: 4px;
  transition: opacity 0.15s ease;
}
.brand:hover,
.brand:focus-visible {
  text-decoration: none;
  opacity: 0.72;
}
.brand:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.brand-mark {
  font-weight: 600;
}

.brand-sub {
  font-weight: 300;
  color: var(--muted);
}


.layout {
  display: grid;
  grid-template-columns: minmax(15rem, 20rem) minmax(0, 1fr);
  min-height: 0;
  height: 100%;
  overflow: hidden;
  position: relative; /* anchor for the absolute nav drawer (overlay/push modes) */
}

.sidebar {
  border-right: 1px solid var(--grid-line);
  background: rgba(var(--surface-rgb), 0.7);
  position: relative;
  overflow: hidden;
}

.sidebar-inner {
  height: 100%;
  padding: clamp(1.5rem, 3vw, 2.25rem) clamp(1.25rem, 3vw, 2rem);
  display: grid;
  gap: 1.25rem;
  overflow-y: auto;
  scrollbar-width: thin;
}

.nav {
  display: grid;
  gap: 0.15rem;
  /* Pack the list at the top by default; the sidebar grid stretches .nav to
     full height, so without this the auto rows distribute across the column
     (the awkward "spread out" look). Override per tenant via `navAlign`. */
  align-content: start;
}

.nav-title {
  font-size: 0.82rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.nav-summary {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.5;
}

.nav-leaf,
.nav-item,
.nav-parent {
  all: unset;
  display: grid;
  gap: 0.1rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease;
  text-align: left;
}

.nav-leaf {
  padding: 0.42rem 0.9rem 0.42rem 1.1rem;
  border-left: 2px solid transparent;
}

.nav-item {
  padding: 0.38rem 0.75rem 0.38rem 1.4rem;
  border-left: 2px solid transparent;
}

.nav-parent {
  padding: 0.48rem 0.75rem 0.48rem 1.1rem;
  border-left: 2px solid transparent;
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  align-items: center;
}

.nav-parent > .nav-summary {
  grid-column: 1 / -1;
  grid-row: 2;
}

.nav-parent .nav-title {
  grid-column: 1;
  grid-row: 1;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.2em;
}

.nav-parent::after {
  content: '\25BE';
  /* Explicit placement: keep the disclosure arrow in row 1 / column 2 beside
     the title. Auto-placement here diverges in Firefox (the arrow lands on its
     own centered row). */
  grid-column: 2;
  grid-row: 1;
  justify-self: end;
  align-self: center;
  font-size: 0.75rem;
  color: var(--muted);
  transform: rotate(-90deg);
  transition: transform 160ms ease;
}

/* Parent with content - title navigates, arrow expands */
.nav-parent-with-content {
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
}

.nav-parent-with-content .nav-summary {
  grid-column: 1 / -1;
  grid-row: 2;
}

.nav-parent-with-content::after {
  display: none; /* Hide default arrow, use custom toggle */
}

.nav-parent-with-content .nav-title-link {
  grid-column: 1;
  grid-row: 1;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  cursor: pointer;
  text-decoration: none;
}

.nav-parent-with-content .nav-title-link:hover {
  text-decoration: underline;
}

.nav-parent-with-content .nav-expand-toggle {
  grid-column: 2;
  grid-row: 1;
  justify-self: end;
  align-self: center;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  cursor: pointer;
  border-radius: 3px;
}

.nav-parent-with-content .nav-expand-toggle::after {
  content: '\25BE';
  font-size: 0.75rem;
  color: var(--muted);
  transform: rotate(-90deg);
  transition: transform 160ms ease;
}

.nav-parent-with-content .nav-expand-toggle:hover {
  background: rgba(var(--ink-rgb), 0.1);
}

.nav-group.expanded .nav-parent-with-content .nav-expand-toggle::after {
  transform: rotate(0deg);
}

.nav-group {
  display: grid;
  gap: 0.1rem;
}

.nav-sublist {
  display: none;
  gap: 0.35rem;
  padding-left: 0.75rem;
  border-left: 1px dashed var(--grid-line);
}

.nav-group.expanded .nav-sublist {
  display: grid;
}

.has-js .nav-static-fallback {
  display: none;
}

.nav-static-link {
  color: inherit;
  text-decoration: none;
}

html:not(.has-js) .mobile-menu-toggle {
  display: none;
}

html:not(.has-js),
html:not(.has-js) body {
  height: auto;
  min-height: 100%;
  overflow: auto;
}

html:not(.has-js) body {
  display: block;
}

html:not(.has-js) .layout {
  height: auto;
  min-height: 0;
  overflow: visible;
}

html:not(.has-js) .sidebar {
  display: block;
  position: relative;
  left: auto;
  top: auto;
  height: auto;
  min-height: 100%;
  transform: none;
}

html:not(.has-js) .sidebar-inner {
  height: auto;
  max-height: none;
  overflow: visible;
}

html:not(.has-js) .canvas {
  height: auto;
  overflow: visible;
}

html:not(.has-js) .nav-sublist,
html:not(.has-js) .nav-sublist-nested,
html:not(.has-js) .nav-sublist-deep,
html:not(.has-js) .nav-sublist-ultra {
  display: grid;
}

/* Nested nav groups (3-level hierarchy) */
.nav-group-nested {
  margin-left: 0.5rem;
  padding-left: 0.5rem;
  border-left: 1px solid rgba(var(--ink-rgb), 0.1);
}

.nav-parent-nested {
  font-size: 0.85rem;
  padding: 0.35rem 0.5rem;
  opacity: 0.85;
  white-space: nowrap;
}

.nav-sublist-nested {
  display: none;
  gap: 0.25rem;
  padding-left: 0.25rem;
}

.nav-group-nested.expanded .nav-sublist-nested {
  display: grid;
}

.nav-item-nested {
  font-size: 0.8rem;
  padding: 0.3rem 0.5rem;
}

.nav-item-nested .nav-summary {
  font-size: 0.7rem;
}

/* Deep nav groups (4-level hierarchy) */
.nav-group-deep {
  margin-left: 0.5rem;
  padding-left: 0.5rem;
  border-left: 1px solid rgba(var(--ink-rgb), 0.08);
}

.nav-parent-deep {
  font-size: 0.8rem;
  padding: 0.3rem 0.5rem;
  opacity: 0.8;
}

.nav-sublist-deep {
  display: none;
  gap: 0.2rem;
  padding-left: 0.25rem;
}

.nav-group-deep.expanded .nav-sublist-deep {
  display: grid;
}

.nav-item-deep {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
}

.nav-item-deep .nav-summary {
  font-size: 0.65rem;
}

/* Ultra-deep nav groups (5-level hierarchy) */
.nav-group-ultra {
  margin-left: 0.4rem;
  padding-left: 0.4rem;
  border-left: 1px solid rgba(var(--ink-rgb), 0.06);
}

.nav-parent-ultra {
  font-size: 0.75rem;
  padding: 0.25rem 0.4rem;
  opacity: 0.75;
}

.nav-sublist-ultra {
  display: none;
  gap: 0.15rem;
  padding-left: 0.2rem;
}

.nav-group-ultra.expanded .nav-sublist-ultra {
  display: grid;
}

.nav-item-ultra {
  font-size: 0.7rem;
  padding: 0.2rem 0.4rem;
}

.nav-item-ultra .nav-summary {
  font-size: 0.6rem;
}

.nav-base:hover,
.nav-base:focus-visible {
  border-color: var(--grid-line);
  border-left-color: var(--ink);
  background: rgba(var(--ink-rgb), 0.03);
}

.nav-base[aria-current="page"] {
  border-color: var(--grid-line);
  border-left-color: var(--ink);
  background: rgba(var(--ink-rgb), 0.05);
}

/* External links in nav */
.nav-external {
  all: unset;
  display: grid;
  gap: 0.35rem;
  padding: 0.65rem 0.9rem 0.75rem 1.1rem;
  border: 1px solid transparent;
  border-left: 2px solid transparent;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease;
  text-align: left;
  text-decoration: none;
  color: inherit;
}

.nav-external:hover,
.nav-external:focus-visible {
  border-color: var(--grid-line);
  border-left-color: var(--ink);
  background: rgba(var(--ink-rgb), 0.03);
}

.nav-external .nav-title {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
}

.nav-external-icon {
  font-size: 0.7em;
  color: var(--muted);
  opacity: 0.7;
  transition: opacity 160ms ease;
}

.nav-external:hover .nav-external-icon {
  opacity: 1;
}

/* Press release and content type indicators */
.nav-type-press-release .nav-title {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
}

.nav-type-icon {
  font-size: 0.65em;
  color: var(--muted);
  opacity: 0;
  transition: opacity 160ms ease;
}

.nav-type-press-release .nav-type-icon::before {
  content: '\25C9'; /* Unicode circle with dot - subtle signal indicator */
}

.nav-type-press-release:hover .nav-type-icon,
.nav-type-press-release:focus-visible .nav-type-icon {
  opacity: 0.7;
}

mark.hl {
  background: var(--highlight-bg);
  border-bottom: 1px solid var(--highlight-border);
  padding: 0 0.12rem;
  border-radius: 0.15rem;
}

/* External CTA link styling */
.external-cta {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.75rem 1.25rem;
  margin-top: 1.5rem;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 160ms ease, color 160ms ease;
}

.external-cta:hover,
.external-cta:focus {
  background: var(--ink);
  color: var(--surface);
  text-decoration: none;
}

/* External link indicator in content */
.doc-content a[target="_blank"]::after {
  content: " \2197";
  font-size: 0.75em;
  opacity: 0.6;
}

.doc-content a.external-cta[target="_blank"]::after {
  content: none;
}

.cmd {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(var(--surface-rgb), 0.65);
  backdrop-filter: blur(8px);
  padding: 1.5rem;
  /* Modal stacking level: sit above all page chrome and any page-effects hero
     (which is a stacking context via `isolation: isolate`), below the export
     overlays (9998/9999). Without this, a positioned hero paints over the
     palette's backdrop. */
  z-index: 9990;
}

.cmd[hidden] {
  display: none;
}

.cmd-surface {
  width: min(580px, 100%);
  background: var(--surface);
  border: 1px solid var(--grid-line);
  box-shadow: 0 18px 42px rgba(var(--ink-rgb), 0.12);
  display: grid;
  gap: 1rem;
  padding: 1.25rem 1.25rem 1rem;
}

.cmd-header {
  display: grid;
  gap: 0.6rem;
}

.cmd-title {
  font-size: 0.74rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.cmd-input {
  border: 1px solid var(--grid-line);
  background: rgba(var(--ink-rgb), 0.02);
  padding: 0.65rem 0.85rem;
  font: inherit;
  font-size: 0.95rem;
  outline: none;
}

.cmd-input:focus {
  border-color: rgba(var(--ink-rgb), 0.35);
  background: rgba(var(--ink-rgb), 0.04);
}

.cmd-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 16rem;
  overflow-y: auto;
  border-top: 1px dashed var(--grid-line);
}

.cmd-item {
  padding: 0.75rem;
  border-bottom: 1px dashed var(--grid-line);
  display: grid;
  gap: 0.3rem;
  cursor: pointer;
  min-width: 0;
}

.cmd-item:last-child {
  border-bottom: none;
}

.cmd-item[aria-selected="true"],
.cmd-item:hover {
  background: rgba(var(--ink-rgb), 0.05);
}

.cmd-item-title {
  font-size: 0.88rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.cmd-item-summary {
  font-size: 0.75rem;
  color: var(--muted);
}

.cmd-item-snippet {
  font-size: 0.78rem;
  color: var(--ink);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.cmd-item-score {
  justify-self: start;
  font-size: 0.65rem;
  color: var(--muted);
  border: 1px solid var(--grid-line);
  padding: 0.12rem 0.35rem;
  line-height: 1.2;
}

.cmd-item-group {
  font-size: 0.65rem;
  color: var(--muted);
  background: rgba(var(--ink-rgb), 0.08);
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  margin-right: 0.5rem;
  text-transform: none;
  letter-spacing: normal;
  font-weight: 500;
}

.cmd-loading {
  color: var(--muted);
  font-style: italic;
  text-align: center;
}

.cmd-more {
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: default;
}

.cmd-more:hover {
  background: none;
}

.canvas {
  /* Shell padding exposed as vars so full-bleed hero/banner primitives (#54)
     can break out by the exact same amount and stay in sync. */
  --pe-bleed-x: clamp(1.5rem, 7vw, 7rem);
  --pe-bleed-y: clamp(2rem, 5vw, 5.5rem);
  padding: var(--pe-bleed-y) var(--pe-bleed-x);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  /* Keep rows AND items at their natural (content) height. Without these, a
     fixed-height grid stretches its single child to the container, so the
     child's overflow is clipped instead of scrolling the canvas — content was
     unreachable on short/landscape viewports. */
  align-content: start;
  align-items: start;
  gap: 2.5rem;
  min-height: 0;
  min-width: 0;
  height: 100%;
  overflow-y: auto;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
}

.canvas > * {
  grid-column: 1;
  min-width: 0;
}

/* Custom scrollbar styling - minimal black line aesthetic */
.canvas::-webkit-scrollbar {
  width: 6px;
}

.canvas::-webkit-scrollbar-track {
  background: transparent;
}

.canvas::-webkit-scrollbar-thumb {
  background: var(--ink);
  border-radius: 3px;
}

.canvas::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

.doc-content {
  display: grid;
  gap: 1.75rem;
  line-height: 1.7;
  max-width: 78ch;
  /* Centre the content on every docs page so the layout stays consistent across
     viewports and TOC placements (no crammed-left / huge-right-margin pages). */
  margin-inline: auto;
  position: relative;
}

.doc-content h1,
.doc-content h2,
.doc-content h3,
.doc-content h4,
.doc-content h5,
.doc-content h6 {
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0;
}

.doc-content h1 { font-size: clamp(1.6rem, 1.6vw + 1.4rem, 2.2rem); }
.doc-content h2 { font-size: clamp(1.3rem, 1.3vw + 1.1rem, 1.6rem); }
.doc-content h3 { font-size: clamp(1.1rem, 1vw + 0.95rem, 1.3rem); }
.doc-content h4 { font-size: 1rem; }

.doc-content p {
  margin: 0;
  color: var(--ink);
}

.doc-content .doc-meta {
  color: var(--muted);
  font-size: 0.85rem;
  letter-spacing: 0;
  text-transform: uppercase;
}

/* The Fortémi info-icon sitting inline on the byline, right after the text. */
.doc-content .doc-meta .doc-fortemi-button-inline {
  vertical-align: middle;
  margin-inline-start: 0.2rem;
  text-transform: none;
}

.doc-content .doc-summary {
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.6;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.doc-fortemi-tools {
  position: absolute;
  top: 0.1rem;
  right: 0;
  z-index: 6;
}

.doc-fortemi-button {
  width: 1.45rem;
  height: 1.45rem;
  display: inline-grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.58;
}

.doc-fortemi-button:hover,
.doc-fortemi-button:focus-visible,
.doc-fortemi-button[aria-expanded="true"] {
  color: var(--ink);
  border-color: var(--grid-line);
  background: var(--surface);
  opacity: 1;
  outline: none;
}

.doc-fortemi-panel {
  position: absolute;
  top: 2rem;
  right: 0;
  z-index: 7;
  width: min(34rem, calc(100vw - 3rem));
  max-height: min(70vh, 36rem);
  overflow: auto;
  border: 1px solid var(--grid-line);
  background: var(--surface);
  box-shadow: 0 1rem 2.5rem rgba(var(--ink-rgb), 0.12);
  padding: 1rem;
  display: grid;
  gap: 1rem;
}

.doc-fortemi-panel[hidden] {
  display: none;
}

.doc-fortemi-section {
  display: grid;
  gap: 0.45rem;
}

.doc-fortemi-section h2 {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.doc-fortemi-subheading {
  margin-top: 0.35rem;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.doc-fortemi-row {
  display: grid;
  grid-template-columns: minmax(8rem, max-content) minmax(0, 1fr);
  gap: 1rem;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.5;
}

.doc-fortemi-key {
  color: var(--muted);
}

.doc-fortemi-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.doc-fortemi-chip {
  border: 1px solid var(--grid-line);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1;
  padding: 0.35rem 0.55rem;
}

.doc-fortemi-links {
  list-style: none;
  display: grid;
  gap: 0.25rem;
  padding: 0;
}

.doc-fortemi-link {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--grid-line);
  color: var(--ink);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  padding: 0;
  text-align: left;
}

.doc-content ul,
.doc-content ol {
  margin: 0;
  padding-left: 1.4rem;
  display: grid;
  gap: 0.5rem;
}

.doc-content li {
  line-height: 1.6;
}

.doc-content pre {
  background: rgba(var(--ink-rgb), 0.04);
  padding: 1rem 1.25rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  border: 1px solid var(--grid-line);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.5;
}

.doc-content code {
  font-family: var(--font-mono);
  background: rgba(var(--ink-rgb), 0.05);
  padding: 0.1rem 0.3rem;
  border-radius: 0.25rem;
}

.doc-content pre code {
  background: transparent;
  padding: 0;
}

/* Quick-copy control on code blocks (#89), enabled per tenant via codeCopy.
   Added by JS; the code stays fully selectable with JS off. */
.doc-content pre.has-code-copy { position: relative; }
.code-copy {
  position: absolute;
  top: 0.5rem; inset-inline-end: 0.5rem;
  display: inline-flex; align-items: center;
  padding: 0.25rem 0.55rem;
  font-family: var(--font-body, inherit);
  font-size: 0.72rem; font-weight: 600; line-height: 1;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--grid-line); border-radius: 6px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
/* Reveal on hover/focus; keyboard focus shows it too. */
.doc-content pre.has-code-copy:hover .code-copy,
.doc-content pre.has-code-copy:focus-within .code-copy,
.code-copy:focus-visible { opacity: 1; }
.code-copy:hover { color: var(--ink); border-color: var(--accent); }
.code-copy:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.code-copy.is-copied { color: var(--accent); border-color: var(--accent); }
/* Touch / no-hover devices: keep it visible (no hover affordance). */
@media (hover: none) {
  .doc-content pre.has-code-copy .code-copy { opacity: 1; }
}

/* ─────────────────────────────────────────────────────────
   Form embeds (#91) — opt-in third-party hosted forms (Tally first).
   The build emits only the hosted-form link (.form-embed__fallback), so a
   JS-off page is complete. The runtime swaps in the iframe (inline) or popup
   button (popup) and marks the container .is-enhanced, hiding the link.
   ───────────────────────────────────────────────────────── */
.form-embed { margin: 1.5rem 0; }
.form-embed__fallback {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 0.95rem;
  border: 1px solid var(--grid-line);
  border-radius: 0.5rem;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
}
.form-embed__fallback:hover { border-color: var(--accent); color: var(--accent); }
.form-embed__fallback:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* Once the runtime has injected the iframe / popup button, the link is redundant. */
.form-embed.is-enhanced .form-embed__fallback { display: none; }
.form-embed__frame {
  width: 100%;
  min-height: 18rem;
  border: 0;
  border-radius: 0.5rem;
  background: transparent;
}
.form-embed__button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border: 1px solid var(--accent);
  border-radius: 0.5rem;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
.form-embed__button:hover { filter: brightness(1.05); }
.form-embed__button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Site-wide affordance: a persistent floating control, every page. */
.form-embed--site {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  margin: 0;
  z-index: 40;
}
.form-embed--site .form-embed__fallback,
.form-embed--site .form-embed__button {
  border-radius: 999px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
}
.form-embed--site .form-embed__fallback {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

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

.doc-content th,
.doc-content td {
  border: 1px solid var(--grid-line);
  padding: 0.65rem 0.75rem;
  text-align: left;
}

.doc-content th {
  background: rgba(var(--ink-rgb), 0.04);
  font-weight: 600;
}

.doc-content blockquote {
  border-left: 3px solid rgba(var(--ink-rgb), 0.2);
  padding-left: 1rem;
  color: var(--muted);
}

.doc-content hr {
  border: none;
  border-bottom: 1px solid var(--ink);
  margin: 2rem 0;
}

.section-header {
  display: grid;
  gap: 0.75rem;
}

.section-header h1 {
  font-size: var(--step);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.section-header p {
  color: var(--muted);
  max-width: 54ch;
  line-height: 1.6;
}

.card-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
}

.card {
  border: 1px solid var(--grid-line);
  padding: 1.5rem;
  display: grid;
  gap: 0.75rem;
  background: rgba(var(--surface-rgb), 0.75);
  backdrop-filter: blur(2px);
}

.card h2 {
  font-size: 1rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.card p {
  color: var(--muted);
  margin: 0;
  line-height: 1.5;
}

/* Link grid for icon-based link cards */
.link-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  margin: 1.5rem 0;
}

.link-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--grid-line);
  text-decoration: none;
  color: inherit;
  transition: border-color 160ms ease, background 160ms ease;
}

.link-card:hover {
  border-color: var(--ink);
  background: rgba(var(--ink-rgb), 0.03);
  text-decoration: none;
}

.link-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.link-title {
  font-weight: 600;
  display: block;
}

.link-desc {
  font-size: 0.85rem;
  color: var(--muted);
  display: block;
}

.footnote {
  border-top: 1px solid var(--grid-line);
  font-size: 0.85rem;
  gap: 1rem;
}

.divider {
  flex: 1;
  border-bottom: 1px dashed var(--grid-line);
}

/* Mobile Menu Toggle Button */
.mobile-menu-toggle {
  display: block; /* visible on every viewport: collapses the sidebar on desktop, overlays it on mobile */
  position: relative;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--grid-line);
  background: transparent;
  cursor: pointer;
  transition: background 0.2s;
}
/* Sidebar nav collapse modes (configurable via data-nav-collapse; default "overlay").
   The drawer modes apply only to the default left-sidebar layout — positioned-nav
   demos (top/bottom/right) keep their own layout and hide the desktop toggle. */
@media (min-width: 60rem) {
  body[data-nav-position] .mobile-menu-toggle { display: none; }

  /* Overlay (default) + push share an absolute drawer inside .layout: no header-
     height math, and .layout's overflow:hidden clips it when slid off-canvas. */
  body[data-nav-collapse="overlay"]:not([data-nav-position]) .layout,
  body[data-nav-collapse="push"]:not([data-nav-position]) .layout {
    grid-template-columns: minmax(0, 1fr);
  }
  body[data-nav-collapse="overlay"]:not([data-nav-position]) .sidebar,
  body[data-nav-collapse="push"]:not([data-nav-position]) .sidebar {
    position: absolute;
    top: 0;
    left: 0;
    width: 19rem;
    height: 100%;
    z-index: 30;
    overflow-y: auto;
    /* Opaque as an overlay drawer: it sits over the content, so the translucent
       base sidebar background would let text bleed through. */
    background: var(--surface);
    transition: transform 0.3s ease;
    box-shadow: 2px 0 16px rgba(0, 0, 0, 0.1);
  }
  /* Overlay: hidden by default; the drawer slides over the full-width content. */
  body[data-nav-collapse="overlay"]:not([data-nav-position]) .sidebar {
    transform: translateX(-100%);
  }
  body[data-nav-collapse="overlay"]:not([data-nav-position]) .sidebar.mobile-open {
    transform: translateX(0);
  }
  /* Dim scrim behind the open overlay drawer (clicking it closes via the doc handler). */
  body[data-nav-collapse="overlay"]:not([data-nav-position]).menu-open .layout::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.18);
    z-index: 25;
  }
  /* Push: visible by default beside padded content; collapse slides it out. */
  body[data-nav-collapse="push"]:not([data-nav-position]) .sidebar {
    transform: translateX(0);
  }
  body[data-nav-collapse="push"]:not([data-nav-position]) .canvas {
    padding-left: 19rem;
    transition: padding-left 0.3s ease;
  }
  body[data-nav-collapse="push"]:not([data-nav-position]).nav-collapsed .sidebar {
    transform: translateX(-100%);
    box-shadow: none;
  }
  body[data-nav-collapse="push"]:not([data-nav-position]).nav-collapsed .canvas {
    padding-left: 0;
  }
  /* Instant: simply drop the sidebar column. */
  body[data-nav-collapse="instant"]:not([data-nav-position]).nav-collapsed .layout {
    grid-template-columns: minmax(0, 1fr);
  }
  body[data-nav-collapse="instant"]:not([data-nav-position]).nav-collapsed .sidebar {
    display: none;
  }

  html:not(.has-js) body[data-nav-collapse="overlay"]:not([data-nav-position]) .layout,
  html:not(.has-js) body[data-nav-collapse="push"]:not([data-nav-position]) .layout,
  html:not(.has-js) body[data-nav-collapse="instant"]:not([data-nav-position]) .layout {
    grid-template-columns: minmax(14rem, 0.28fr) minmax(0, 1fr);
  }

  html:not(.has-js) body[data-nav-collapse="overlay"]:not([data-nav-position]) .sidebar,
  html:not(.has-js) body[data-nav-collapse="push"]:not([data-nav-position]) .sidebar,
  html:not(.has-js) body[data-nav-collapse="instant"]:not([data-nav-position]) .sidebar {
    position: relative;
    width: auto;
    height: auto;
    transform: none;
    box-shadow: none;
  }

  html:not(.has-js) body[data-nav-collapse="push"]:not([data-nav-position]) .canvas {
    padding-left: clamp(2rem, 5vw, 5.5rem);
  }
}

.mobile-menu-toggle:hover {
  background: rgba(var(--ink-rgb), 0.05);
}


.menu-icon {
  display: block;
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 2px;
  background: var(--ink);
  transform: translate(-55%, -50%);
  transition: background 0.3s;
}

.menu-icon::before,
.menu-icon::after {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  width: 20px;
  height: 2px;
  background: var(--ink);
  transform: translateX(-52%);
  transform-origin: center;
  transition: transform 0.3s, top 0.3s;
}

.menu-icon::before {
  top: -6px;
}

.menu-icon::after {
  top: 6px;
}

.mobile-menu-toggle[aria-expanded="true"] .menu-icon {
  background: transparent;
}

.mobile-menu-toggle[aria-expanded="true"] .menu-icon::before {
  transform: translateX(-52%) rotate(45deg);
  top: 0;
}

.mobile-menu-toggle[aria-expanded="true"] .menu-icon::after {
  transform: translateX(-52%) rotate(-45deg);
  top: 0;
}

/* Tablet and Mobile Styles */
@media (max-width: 960px) {
  body {
    overflow-x: hidden;
  }

  body.menu-open {
    overflow: hidden;
  }

  .mobile-menu-toggle {
    display: block;
  }

  .topbar {
    padding: 1rem;
    gap: 1rem;
    position: relative;
    z-index: 100;
  }

  .brand {
    flex: 1;
    font-size: 1.2rem;
  }

  .layout {
    grid-template-columns: 1fr;
    /* No explicit height: the body grid's 1fr row already sizes the layout to
       the exact space left by the header/footer, at any viewport/orientation.
       The old calc(100vh - 120px) assumed a fixed chrome height and overflowed
       (footer clipped) when the header/footer were taller. */
    position: relative;
  }

  .sidebar {
    position: fixed;
    top: 60px;
    left: -100%;
    width: 85%;
    max-width: 320px;
    height: calc(100dvh - 60px);
    background: var(--surface);
    border-right: 2px solid var(--ink);
    z-index: 99;
    transition: left 0.3s ease;
    overflow-y: auto;
  }

  .sidebar.mobile-open {
    left: 0;
  }

  html:not(.has-js) .layout {
    grid-template-columns: 1fr;
  }

  html:not(.has-js) .sidebar {
    position: relative;
    top: auto;
    left: auto;
    width: auto;
    max-width: none;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--grid-line);
    transform: none;
    z-index: auto;
  }

  .sidebar-inner {
    height: 100%;
    padding: 1.5rem;
    overflow-y: auto;
  }

  .nav {
    display: grid;
    gap: 0.5rem;
  }

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

  .nav-sublist {
    padding-left: 1rem;
  }

  .canvas {
    padding: 1.5rem 0.65rem;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    max-width: 100%;
    min-width: 0;
    scrollbar-gutter: unset;
  }

  /* Minimal mobile scrollbar */
  .canvas::-webkit-scrollbar {
    width: 3px;
  }

  .canvas::-webkit-scrollbar-track {
    background: transparent;
  }

  .canvas::-webkit-scrollbar-thumb {
    background: rgba(var(--ink-rgb), 0.3);
    border-radius: 2px;
  }

  .section {
    max-width: 100%;
    min-width: 0;
    overflow: visible;
  }

  .ghost-label {
    display: none;
  }

  .ghost-button {
    padding: 0.6rem;
    min-width: auto;
  }

  .ghost-icon {
    font-size: 1.2rem;
  }

  /* Content adjustments */
  .content {
    font-size: 0.95rem;
    max-width: 100%;
    overflow-wrap: break-word;
    word-wrap: break-word;
  }

  .doc-content {
    padding-right: 1rem;
    max-width: 100%;
    min-width: 0;
    overflow-wrap: break-word;
    word-break: break-word;
  }

  .doc-content table {
    display: block;
    overflow-x: auto;
    max-width: 100%;
  }

  .doc-content pre {
    max-width: 100%;
  }

  .content h2 {
    font-size: 1.4rem;
  }

  .content h3 {
    font-size: 1.2rem;
  }

  .card-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .card {
    max-width: 100%;
    overflow: hidden;
  }

  pre {
    font-size: 0.85rem;
    overflow-x: auto;
    max-width: calc(100vw - 3rem);
    margin-left: -0.5rem;
    margin-right: -0.5rem;
    padding: 1rem 0.75rem;
  }

  table {
    display: block;
    overflow-x: auto;
    max-width: 100%;
  }

  /* Prevent images from causing overflow */
  img {
    max-width: 100%;
    height: auto;
  }

  /* Command palette mobile */
  .cmd-surface {
    width: 95%;
    max-width: 400px;
    max-height: 80vh;
  }

  /* Footer mobile */
  .footnote {
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem;
    text-align: center;
    font-size: 0.8rem;
  }

  .divider {
    display: none;
  }

  /* Special content elements - ensure responsive sizing */
  .mermaid-diagram {
    margin: 1rem 0;
  }

  .mermaid-content {
    max-height: 50vh;
  }

  .mermaid-content svg {
    min-width: 500px;
  }

  .arch-diagram,
  .spec-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }

  .content-box .box-content {
    font-size: 0.7rem;
    line-height: 1.4;
    max-height: 50vh;
    padding: 0.75rem;
  }

  /* HTML blocks with embedded tables/diagrams */
  .html-block {
    margin: 1rem 0;
    border: 1px solid var(--grid-line);
    border-radius: 6px;
    padding: 0;
  }

  .html-block .arch-diagram {
    min-width: 450px;
    border: none;
    border-radius: 0;
  }

  .html-block .arch-diagram caption {
    border-radius: 6px 6px 0 0;
  }

  /* Ensure all SVGs scale properly */
  svg {
    max-width: 100%;
    height: auto;
  }

  /* Feature grids and lists */
  .feature-grid,
  .feature-list {
    display: block;
  }

  .feature-grid > *,
  .feature-list > * {
    margin-bottom: 1rem;
  }

  /* HTML blocks with custom content */
  .html-block {
    max-width: 100%;
    overflow-x: auto;
  }

  /* Bottom navigation responsive */
  .bottom-nav__inner {
    flex-direction: column;
    gap: 0.5rem;
    align-items: stretch;
  }

  .bottom-nav .bottom-nav-item {
    max-width: 100%;
    width: 100%;
    margin: 0;
    position: relative;
  }

  .bottom-nav .bottom-nav-prev,
  .bottom-nav .bottom-nav-next {
    margin-left: 0;
    margin-right: 0;
  }

  .bottom-nav .bottom-nav-chevron {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    font-size: 1.1rem;
    color: var(--muted);
    pointer-events: none;
  }

  .bottom-nav .bottom-nav-prev .bottom-nav-chevron {
    left: 0.5rem;
  }

  .bottom-nav .bottom-nav-next .bottom-nav-chevron {
    right: 0.5rem;
  }

  .bottom-nav .bottom-nav-link {
    display: block;
    width: 100%;
    text-align: center;
    white-space: normal;
    padding: 0.6rem 2rem;
    font-size: 0.85rem;
  }

  .bottom-nav .bottom-nav-spacer {
    display: none;
  }
}

/* Small mobile screens */
@media (max-width: 480px) {
  .topbar {
    padding: 0.75rem;
  }

  .brand {
    font-size: 1rem;
    letter-spacing: 0.1em;
  }

  .brand-sub {
    display: none;
  }

  .sidebar {
    width: 90%;
  }

  .canvas {
    padding: 1rem 0.75rem;
  }

  .doc-content {
    padding-right: 0.5rem;
  }

  pre {
    max-width: calc(100vw - 2rem);
    margin-left: -0.25rem;
    margin-right: -0.25rem;
    padding: 0.75rem 0.5rem;
    font-size: 0.8rem;
  }

  .content h1 {
    font-size: 1.5rem;
  }

  .content h2 {
    font-size: 1.25rem;
  }

  .content h3 {
    font-size: 1.1rem;
  }

  /* Export modal mobile */
  .export-loading-modal {
    width: 95%;
    max-width: 400px;
    padding: 2rem 1.5rem;
  }

  .export-loading-title {
    font-size: 1rem;
  }

  .export-loading-subtitle {
    font-size: 0.8rem;
  }

  /* Command palette even smaller */
  .cmd-surface {
    width: 100%;
    border-radius: 0;
    max-height: 100vh;
    max-height: 100dvh;
    height: 100vh;
    height: 100dvh;
  }
}

@media print {
  mark.hl {
    background: transparent;
    border-bottom: 1px solid rgba(var(--ink-rgb), 0.2);
  }
}

/* Export Options Modal */
.export-options-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(var(--surface-rgb), 0.86);
  backdrop-filter: blur(6px);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.export-options-overlay.active {
  opacity: 1;
}

.export-options-modal {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--grid-line);
  border-radius: 8px;
  padding: 1.25rem;
  width: min(360px, 100%);
  box-shadow: 0 1rem 2.5rem rgba(var(--ink-rgb), 0.12);
}

.export-options-header {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 1.5rem;
  text-align: center;
  font-family: var(--font-mono);
}

.export-options-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.export-option-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 1rem 1.25rem;
  border: 1px solid var(--grid-line);
  border-radius: 6px;
  background: rgba(var(--surface-rgb), 0.35);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.export-option-btn:hover,
.export-option-btn:focus-visible {
  border-color: var(--ink);
  background: rgba(var(--surface-rgb), 0.7);
  outline: none;
}

.export-option-title {
  color: var(--ink);
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}

.export-option-desc {
  font-size: 0.8rem;
  color: var(--muted);
}

.export-cancel-btn {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
  transition: color 160ms ease, border-color 160ms ease;
}

.export-cancel-btn:hover,
.export-cancel-btn:focus-visible {
  color: var(--ink);
  border-color: var(--grid-line);
  outline: none;
}

/* Export Loading Overlay */
.export-loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(var(--surface-rgb), 0.9);
  backdrop-filter: blur(6px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.export-loading-overlay.active {
  opacity: 1;
}

.export-loading-modal {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--grid-line);
  border-radius: 8px;
  padding: 2rem;
  width: min(630px, 100%);
  box-shadow: 0 1rem 2.5rem rgba(var(--ink-rgb), 0.12);
  position: relative;
  overflow: hidden;
}

.export-loading-header {
  margin-bottom: 2rem;
  text-align: center;
}

.export-loading-title {
  color: var(--ink);
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
  font-family: var(--font-mono);
}

.export-loading-subtitle {
  color: var(--muted);
  font-size: 0.9rem;
  letter-spacing: 0.05em;
}

.export-loading-progress {
  margin-bottom: 2rem;
}

.export-loading-bar {
  height: 4px;
  background: var(--grid-line);
  border-radius: 999px;
  margin-bottom: 1rem;
  position: relative;
  overflow: hidden;
}

.export-loading-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.3s ease;
  position: relative;
}

.export-loading-fill::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 20px;
  background: linear-gradient(90deg, transparent, rgba(var(--surface-rgb), 0.45));
  animation: shimmer 1s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-20px); }
  100% { transform: translateX(20px); }
}

.export-loading-status-container {
  min-height: 20px;
  display: flex;
  align-items: center;
}

.export-loading-status {
  font-size: 0.85rem;
  color: var(--muted);
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

.export-loading-scanner {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  overflow: hidden;
  opacity: 0.3;
}

.scanner-line {
  position: absolute;
  width: 100px;
  height: 100%;
  background: linear-gradient(90deg,
    transparent,
    var(--accent) 20%,
    var(--accent) 80%,
    transparent);
  animation: scan 2s infinite linear;
}

@keyframes scan {
  0% { transform: translateX(-100px); }
  100% { transform: translateX(calc(100% + 100px)); }
}

.export-loading-modal::before {
  content: none;
}

.export-loading-modal::after {
  content: none;
}

@keyframes borderPulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.6; }
}

/* ─────────────────────────────────────────────────────────
   Mermaid Diagram Styles
   ───────────────────────────────────────────────────────── */

.mermaid-diagram {
  display: flex;
  flex-direction: column;
  margin: 1.5rem 0;
  background: var(--surface);
  border: 1px solid var(--grid-line);
  border-radius: 6px;
  overflow: hidden;
}

.mermaid-controls {
  display: flex;
  gap: 0.25rem;
  padding: 0.5rem;
  background: rgba(var(--ink-rgb), 0.03);
  border-bottom: 1px solid var(--grid-line);
}

.mermaid-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--grid-line);
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  color: var(--ink);
  transition: background 0.15s, border-color 0.15s;
}

.mermaid-btn:hover {
  background: rgba(var(--ink-rgb), 0.05);
  border-color: var(--ink);
}

.mermaid-btn:active {
  background: rgba(var(--ink-rgb), 0.1);
}

.mermaid-content {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 1rem;
  max-height: 70vh;
}

.mermaid-content svg {
  display: block;
  transition: transform 0.15s ease;
}

.mermaid-diagram svg {
  max-width: none;
  height: auto;
}


/* Hide mermaid code blocks before rendering to prevent FOUC */
pre:has(code.language-mermaid) {
  opacity: 0.5;
  position: relative;
}

pre:has(code.language-mermaid)::after {
  content: 'Loading diagram...';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.875rem;
  color: var(--muted);
}

/* Error state for failed diagram renders */
.mermaid-error-message {
  padding: 0.5rem 1rem;
  margin-bottom: 0.5rem;
  background: rgba(229, 57, 53, 0.1);
  border-left: 3px solid #e53935;
  color: #c62828;
  font-size: 0.875rem;
  border-radius: 0 4px 4px 0;
}

.mermaid-error {
  border-left: 3px solid #e53935;
  background: rgba(229, 57, 53, 0.05);
}

/* ─────────────────────────────────────────────────────────
   Content Box / Panel Styles
   Usage: ```box or ```box:Title
   ───────────────────────────────────────────────────────── */

.content-box {
  margin: 1.5rem 0;
  border: 1px solid var(--grid-line);
  border-radius: 6px;
  background: var(--surface);
  overflow: hidden;
  min-height: 50px;
}

.content-box .box-title {
  padding: 0.75rem 1rem;
  font-weight: 600;
  font-size: 0.9rem;
  background: rgba(var(--ink-rgb), 0.03);
  border-bottom: 1px solid var(--grid-line);
  color: var(--ink);
}

.content-box .box-content {
  margin: 0;
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.5;
  white-space: pre;
  overflow-x: auto;
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  display: block !important;
  visibility: visible !important;
  color: var(--ink) !important;
  min-height: 20px;
}

/* Override doc-content pre styles for box-content */
.doc-content .content-box pre.box-content {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 1rem;
}

/* ─────────────────────────────────────────────────────────
   Media Block Styles
   Usage: ```media - renders audio, video, or click-to-load embeds
   ───────────────────────────────────────────────────────── */

.media-block {
  margin: 1.5rem 0;
}

.media-block audio,
.media-block video,
.media-embed-frame iframe {
  display: block;
  width: 100%;
}

.media-block video,
.media-embed-frame {
  aspect-ratio: var(--media-aspect, 16 / 9);
  background: color-mix(in srgb, var(--grid-line) 35%, transparent);
}

.media-embed-frame {
  display: grid;
  place-items: center;
  border: 1px solid var(--grid-line);
}

.media-embed-frame iframe {
  height: 100%;
  border: 0;
}

.media-embed-load {
  appearance: none;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--surface);
  padding: 0.75rem 1rem;
  font: inherit;
  cursor: pointer;
}

.media-embed-load:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.media-embed-privacy,
.media-block figcaption {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.media-transcript {
  font-weight: 600;
}

.media-fallback {
  margin: 1rem 0;
  padding: 1rem;
  border: 1px solid var(--grid-line);
  background: color-mix(in srgb, var(--grid-line) 18%, transparent);
}

/* ─────────────────────────────────────────────────────────
   HTML Block Styles
   Usage: ```html - renders raw HTML
   ───────────────────────────────────────────────────────── */

.html-block {
  margin: 1.5rem 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Architecture diagram table styling */
.arch-diagram {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  border: 2px solid var(--ink);
  font-family: var(--font-body);
  font-size: 0.9rem;
}

.arch-diagram caption {
  font-weight: 700;
  font-size: 1.1rem;
  padding: 0.75rem;
  background: var(--ink);
  color: var(--surface);
  caption-side: top;
}

.arch-diagram td {
  padding: 0.75rem;
  vertical-align: top;
  border: 1px solid var(--grid-line);
}

.arch-diagram .component {
  background: rgba(var(--ink-rgb), 0.03);
  border: 1px solid var(--grid-line);
  border-radius: 4px;
  padding: 0.75rem;
  text-align: center;
}

.arch-diagram .component-title {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.arch-diagram .component-desc {
  font-size: 0.8rem;
  color: var(--muted);
}

/* Specification table styling */
.spec-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.9rem;
}

.spec-table th,
.spec-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border: 1px solid var(--grid-line);
}

.spec-table th {
  background: rgba(var(--ink-rgb), 0.05);
  font-weight: 600;
}

.spec-table tr:nth-child(even) {
  background: rgba(var(--ink-rgb), 0.02);
}

.spec-table td:first-child {
  width: 40%;
}

.spec-table td:last-child {
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

/* Layer stack diagram styling */
.layer-stack {
  display: flex;
  flex-direction: column;
  margin: 1.5rem 0;
  border: 2px solid var(--ink);
  border-radius: 6px;
  overflow: hidden;
}

.layer-stack .layer {
  padding: 1rem 1.25rem;
  text-align: center;
  border-bottom: 1px solid var(--grid-line);
}

.layer-stack .layer:last-child {
  border-bottom: none;
}

.layer-stack .layer:first-child {
  background: rgba(var(--ink-rgb), 0.02);
}

.layer-stack .layer:nth-child(2) {
  background: rgba(var(--ink-rgb), 0.04);
}

.layer-stack .layer:nth-child(3) {
  background: rgba(var(--ink-rgb), 0.06);
}

.layer-stack .layer-title {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.layer-stack .layer-desc,
.layer-stack .layer-detail {
  font-size: 0.85rem;
  color: var(--muted);
}

.arch-diagram .full-width {
  background: rgba(var(--ink-rgb), 0.05);
}

/* ─────────────────────────────────────────────────────────
   Bottom Page Navigation (Prev/Next)
   ───────────────────────────────────────────────────────── */

.bottom-nav {
  /* Full-width separator: the border-top spans the section. The buttons sit in
     .bottom-nav__inner, which is centred to the content width on desktop so they
     align with the page above instead of the screen edges. */
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--grid-line);
}

.bottom-nav__inner {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.bottom-nav.mobile-only {
  display: none;
}

@media (max-width: 960px) {
  .bottom-nav.mobile-only {
    display: block;
  }
}

@media (max-width: 560px) {
  .bottom-nav__inner {
    flex-direction: column;
    align-items: stretch;
  }
  .bottom-nav .bottom-nav-item,
  .bottom-nav .bottom-nav-prev,
  .bottom-nav .bottom-nav-next {
    width: 100%;
    max-width: none;
    margin-left: 0;
  }
  .bottom-nav .bottom-nav-link {
    flex: 1 1 auto;
    min-width: 0;
    white-space: normal;
    text-align: center;
  }
  .bottom-nav .bottom-nav-spacer {
    display: none;
  }
}

/* Align the buttons with the centred content above (matches .doc-content),
   keeping the border-top full width. Only where the centred layout applies. */
@media (min-width: 60rem) {
  .bottom-nav__inner {
    max-width: 78ch;
    margin-inline: auto;
  }
  .section:has(.page-toc--right) .bottom-nav__inner {
    max-width: calc(78ch + 14rem + 2.5rem);
  }
}

.bottom-nav-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  max-width: 48%;
}

.bottom-nav-prev {
  flex-direction: row;
}

.bottom-nav-next {
  flex-direction: row;
  margin-left: auto;
}

.bottom-nav-chevron {
  font-size: 1.5rem;
  font-weight: 300;
  color: var(--muted);
  line-height: 1;
}

.bottom-nav-link {
  padding: 0.75rem 1rem;
  border: 1px solid var(--grid-line);
  border-radius: 6px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 500;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: border-color 0.15s, background 0.15s;
}

.bottom-nav-link:hover {
  border-color: var(--ink);
  background: rgba(var(--ink-rgb), 0.03);
}

.bottom-nav-spacer {
  flex: 1;
}

/* Blog post navigation (#55): a persistent three-up control — prev post,
   back-to-index, next post — always visible (a post with the sidebar hidden
   has no other way to move between posts). The prev/next items reuse the docs
   bottom-nav styling above; only the index affordance and layout differ. */
.bottom-nav--posts .bottom-nav__inner {
  align-items: stretch;
  gap: 0.75rem 1rem;
  flex-wrap: wrap;
}

.bottom-nav--posts .bottom-nav-next {
  margin-left: 0;
}

.bottom-nav-index {
  align-self: center;
  order: 0;
  padding: 0.5rem 1rem;
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--muted);
  border: 1px solid var(--grid-line);
  border-radius: 999px;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.bottom-nav-index:hover,
.bottom-nav-index:focus-visible {
  color: var(--ink);
  border-color: var(--ink);
  background: rgba(var(--ink-rgb), 0.03);
  text-decoration: none;
}

/* On narrow screens stack the index affordance below the prev/next pair so the
   two post links keep a comfortable target size. */
@media (max-width: 560px) {
  .bottom-nav--posts .bottom-nav-index {
    order: 1;
    flex-basis: 100%;
    text-align: center;
  }
}

/* ─────────────────────────────────────────────────────────
   Syntax Highlighting (Light theme)
   ───────────────────────────────────────────────────────── */

pre.highlighted {
  background: rgba(var(--ink-rgb), 0.03);
  color: var(--ink);
}

pre.highlighted code {
  color: var(--ink);
}

/* Tokens */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
  color: #6a737d;
  font-style: italic;
}

.token.punctuation {
  color: #24292e;
}

.token.property,
.token.tag,
.token.constant,
.token.symbol,
.token.deleted {
  color: #d73a49;
}

.token.boolean,
.token.number {
  color: #005cc5;
}

.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
  color: #22863a;
}

.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
  color: #d73a49;
}

.token.atrule,
.token.attr-value,
.token.keyword {
  color: #d73a49;
}

.token.function,
.token.class-name {
  color: #6f42c1;
}

.token.regex,
.token.important,
.token.variable {
  color: #e36209;
}

.token.important,
.token.bold {
  font-weight: bold;
}

.token.italic {
  font-style: italic;
}

/* ─────────────────────────────────────────────────────────
   Nav Position
   Activated by a [data-nav-position] attribute on <body>,
   injected at build time from a tenant's `navPosition` config
   ("left" | "right" | "top" | "bottom" | "hybrid"). The default
   (left) needs no attribute, so these rules cost nothing until a
   tenant opts in. Colors use var() so they track the active theme.
   ───────────────────────────────────────────────────────── */

/* Right: sidebar on the trailing edge. */
body[data-nav-position="right"] .layout {
  grid-template-columns: minmax(0, 1fr) minmax(15rem, 20rem);
}

body[data-nav-position="right"] .sidebar {
  order: 2;
  border-right: none;
  border-left: 1px solid var(--grid-line);
}

body[data-nav-position="right"] .canvas {
  order: 1;
}

/* Top / Bottom: sidebar becomes a horizontal nav bar. The single
   .layout column stacks the bar and the canvas in two rows. */
body[data-nav-position="top"] .layout,
body[data-nav-position="bottom"] .layout {
  grid-template-columns: 1fr;
}

body[data-nav-position="top"] .layout {
  grid-template-rows: auto minmax(0, 1fr);
}

body[data-nav-position="bottom"] .layout {
  grid-template-rows: minmax(0, 1fr) auto;
}

body[data-nav-position="top"] .sidebar {
  order: 1;
  border-right: none;
  border-bottom: 1px solid var(--grid-line);
}

body[data-nav-position="bottom"] .sidebar {
  order: 2;
  border-right: none;
  border-top: 1px solid var(--grid-line);
}

body[data-nav-position="top"] .canvas {
  order: 2;
}

body[data-nav-position="bottom"] .canvas {
  order: 1;
}

body[data-nav-position="top"] .sidebar,
body[data-nav-position="bottom"] .sidebar {
  overflow: visible;
}

body[data-nav-position="top"] .sidebar-inner,
body[data-nav-position="bottom"] .sidebar-inner {
  height: auto;
  max-height: 40vh;
  padding: clamp(0.75rem, 2vw, 1.25rem) clamp(1.25rem, 3vw, 2rem);
  overflow-x: auto;
  overflow-y: auto;
}

body[data-nav-position="top"] .nav,
body[data-nav-position="bottom"] .nav {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.25rem 1.5rem;
}

body[data-nav-position="top"] .nav-group,
body[data-nav-position="bottom"] .nav-group {
  min-width: max-content;
}

/* ─────────────────────────────────────────────────────────
   Nav Alignment
   Activated by a [data-nav-align] attribute on <body>, injected
   at build time from a tenant's `navAlign` config:
   "top" (default) | "spread" | "bottom" | "left" | "right".
   "top" is the default (see base `.nav { align-content: start }`)
   and needs no attribute. Vertical options (spread/bottom) tune how
   the list fills the sidebar column; horizontal options (left/right)
   set the item text edge. Scoped to the vertical (left/right) sidebar
   grid; horizontal nav bars (data-nav-position top/bottom) are
   unaffected.
   ───────────────────────────────────────────────────────── */

/* Spread: distribute groups across the full column (legacy look). */
body[data-nav-align="spread"] .nav {
  align-content: stretch;
}

/* Bottom: pack the list against the bottom of the sidebar. */
body[data-nav-align="bottom"] .nav {
  align-content: end;
}

/* Left: explicit leading-edge text (matches the default). */
body[data-nav-align="left"] .nav {
  text-align: left;
}

/* Right: trailing-edge text for the whole list. */
body[data-nav-align="right"] .nav {
  text-align: right;
}

body[data-nav-align="right"] .nav-parent-with-content .nav-summary {
  justify-content: flex-end;
}

/* ─────────────────────────────────────────────────────────
   Blog Layout (layout: "blog")
   Activated by body[data-layout="blog"] (+ data-blog-sidebar),
   injected at build time. Reshapes the docs grid into a reading-
   first blog: a chronological index of post cards, and post pages
   with hero, byline, and tags. No motion here — that is Phase 2.
   ───────────────────────────────────────────────────────── */

/* Sidebar hidden → single centered reading column. */
body[data-layout="blog"][data-blog-sidebar="hidden"] .layout {
  grid-template-columns: minmax(0, 1fr);
}
body[data-layout="blog"][data-blog-sidebar="hidden"] .sidebar {
  display: none;
}
/* …but in a mixed docs + blog site the nav drawer must still open on a blog
   route so a reader can reach the docs navigation. When the overlay/mobile drawer
   is open (`.sidebar.mobile-open`), restore the sidebar so it slides in as the
   drawer rather than the toggle just dimming the screen (#90 follow-up). */
body[data-layout="blog"][data-blog-sidebar="hidden"] .sidebar.mobile-open {
  display: block;
}

/* Sidebar rail → content + a narrow posts/tags rail on the trailing edge. */
body[data-layout="blog"][data-blog-sidebar="rail"] .layout {
  grid-template-columns: minmax(0, 1fr) minmax(13rem, 17rem);
}
body[data-layout="blog"][data-blog-sidebar="rail"] .sidebar {
  order: 2;
  border-right: none;
  border-left: 1px solid var(--grid-line);
}

/* Reading-first canvas: centered with a comfortable max width. */
body[data-layout="blog"] .canvas {
  margin-inline: auto;
  width: 100%;
  max-width: 72rem;
}

/* Index — chronological card grid. */
.blog-index-head h1 { margin-bottom: 0.25rem; }
.blog-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr));
  gap: clamp(1.25rem, 3vw, 2rem);
  margin-top: clamp(1.5rem, 4vw, 2.5rem);
}
.blog-card {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--grid-line);
  border-radius: 14px;
  overflow: hidden;
  background: rgba(var(--surface-rgb), 0.6);
  /* The whole card is one click target (the title link is stretched over it
     below), so it reads and behaves as a clickable tile — a pointer cursor, not
     a text caret. */
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.blog-card:hover,
.blog-card:focus-within {
  border-color: var(--accent);
  box-shadow: 0 6px 20px rgba(var(--ink-rgb), 0.10);
  transform: translateY(-2px);
}
/* Stretched link: the title's anchor covers the entire card, so a click
   anywhere navigates to the post and no card text shows a text I-beam. The
   title stays the single, labelled link for assistive tech. */
.blog-card-title a::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
}
.blog-card-hero { display: block; aspect-ratio: 2 / 1; overflow: hidden; }
.blog-card-hero img { width: 100%; height: 100%; object-fit: cover; display: block; }
.blog-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: clamp(1rem, 2.5vw, 1.4rem);
}
.blog-card-meta {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: baseline;
}
.blog-card-dot { color: var(--muted); opacity: 0.6; }
.blog-card-title { font-size: 1.2rem; line-height: 1.3; margin: 0; }
.blog-card-title a { color: inherit; text-decoration: none; }
.blog-card-title a:hover { text-decoration: underline; }
.blog-card-summary { margin: 0; color: var(--muted); font-size: 0.92rem; line-height: 1.55; }
.blog-card-tags,
.post-tags {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.25rem 0 0;
  padding: 0;
}
.blog-card-tags li,
.post-tags li {
  font-size: 0.72rem;
  color: var(--muted);
  border: 1px solid var(--grid-line);
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
}
.blog-empty { color: var(--muted); margin-top: 2rem; }

/* Post page hero + tags. */
.post-hero { margin: 0 0 clamp(1.25rem, 3vw, 2rem); border-radius: 14px; overflow: hidden; }
.post-hero img { width: 100%; height: auto; display: block; aspect-ratio: 2 / 1; object-fit: cover; }
body[data-layout="blog"] .post-tags { margin-top: 1.25rem; }

/* The byline tag list is injected inside .doc-content, whose list styling would
   otherwise turn each tag into a full-width grid row. Re-assert the pill layout
   with higher specificity so tags read as small inline pills, not bars. */
.doc-content .post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}
.doc-content .post-tags li {
  display: inline-flex;
  align-items: center;
  width: auto;
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--muted);
  border: 1px solid var(--grid-line);
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
}
.doc-content .post-tags li::before { content: none; }

/* ─────────────────────────────────────────────────────────
   Page effects (#51) — opt-in, accessible.
   Reveal-on-scroll base state is hidden ONLY when JS is present
   (html.has-js) AND motion is allowed; so JS-off and reduced-
   motion readers always see the content immediately. The JS
   (src/lib/page-effects.54b29946706a.js) adds .is-revealed as elements enter view.
   ───────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: no-preference) {
  html.has-js [data-reveal] {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 600ms ease, transform 600ms ease;
    will-change: opacity, transform;
  }
  html.has-js [data-reveal].is-revealed {
    opacity: 1;
    transform: none;
  }
  /* Staggered reveal (#74): children of a [data-reveal-stagger] container share
     the reveal transition but each carries an incremental --reveal-delay (set by
     JS), so they arrive in a wave. Same has-js + no-preference gating, so JS-off
     and reduced-motion readers see every child at once. */
  html.has-js [data-reveal-stagger] > * {
    opacity: 0;
    transform: translateY(14px);
    transition: opacity 600ms ease var(--reveal-delay, 0ms), transform 600ms ease var(--reveal-delay, 0ms);
    will-change: opacity, transform;
  }
  html.has-js [data-reveal-stagger] > *.is-revealed {
    opacity: 1;
    transform: none;
  }
}

/* Living scroll: content blocks reveal as they enter view. Layout-agnostic —
   works on any markdown page (docs or blog) via the body flag; `data-blog-living-scroll`
   is the back-compat alias. Hidden base state is keyed on the flag (present at
   first paint, so no flash) and scoped under html.has-js + no-preference —
   JS-off and reduced-motion readers get the full content immediately. The effect
   (livingScroll) adds .is-living-revealed. */
@media (prefers-reduced-motion: no-preference) {
  html.has-js body[data-living-scroll] .doc.markdown .doc-content > *,
  html.has-js body[data-blog-living-scroll] .doc.markdown .doc-content > * {
    opacity: 0;
    transform: translateY(14px);
    transition: opacity 600ms ease, transform 600ms ease;
    will-change: opacity, transform;
  }
  html.has-js body[data-living-scroll] .doc.markdown .doc-content > .is-living-revealed,
  html.has-js body[data-blog-living-scroll] .doc.markdown .doc-content > .is-living-revealed {
    opacity: 1;
    transform: none;
  }
}

/* Accordion (#72): production disclosure on native <details>. Works with zero JS
   and is keyboard-operable; `.pe-accordion[data-pe-single]` adds single-open
   grouping (a JS enhancement). Theme-token styled. */
.pe-accordion { display: grid; gap: 0.6rem; margin: 1.5rem 0; }
.pe-accordion > details {
  border: 1px solid var(--grid-line);
  border-radius: 8px;
  background: rgba(var(--surface-rgb), 0.7);
  overflow: hidden;
}
.pe-accordion > details > summary {
  cursor: pointer;
  padding: 0.9rem 1.1rem;
  font-weight: 700;
  color: var(--ink);
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.pe-accordion > details > summary::-webkit-details-marker { display: none; }
/* Open/closed affordance that doesn't rely on color alone. */
.pe-accordion > details > summary::after { content: "+"; font-weight: 400; opacity: 0.6; }
.pe-accordion > details[open] > summary::after { content: "\2212"; } /* minus */
.pe-accordion > details > summary:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
.pe-accordion > details > *:not(summary) {
  margin: 0;
  padding: 0 1.1rem 1.05rem;
  color: var(--muted);
}
/* Smooth open/close so the disclosure doesn't pop and jolt the layout. The
   ::details-content height transition (newer browsers) animates the reveal; a
   content fade softens it everywhere else. Progressive enhancement — browsers
   without ::details-content just snap, as before. Gated under reduced-motion. */
.pe-accordion { interpolate-size: allow-keywords; }
@media (prefers-reduced-motion: no-preference) {
  .pe-accordion > details::details-content {
    height: 0;
    overflow: clip;
    transition: height 280ms ease, content-visibility 280ms allow-discrete;
  }
  .pe-accordion > details[open]::details-content { height: auto; }
  .pe-accordion > details[open] > :not(summary) { animation: pe-accordion-reveal 260ms ease; }
}
@keyframes pe-accordion-reveal { from { opacity: 0; transform: translateY(-4px); } }

/* Figure zoom (#76): the figure shows its image normally (JS-off baseline). The
   effect wraps the image in .pe-zoom-trigger and opens .pe-zoom-dialog (native
   <dialog>) on activate. Theme-token styled; no motion. */
.pe-figure { margin: 1.5rem 0; }
.pe-figure img { display: block; max-width: 100%; height: auto; }
.pe-zoom-trigger {
  display: block; width: 100%; padding: 0; margin: 0;
  border: 0; background: none; cursor: zoom-in;
}
.pe-zoom-trigger:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.pe-zoom-dialog {
  max-width: 92vw; max-height: 92vh;
  padding: 0; border: 0; border-radius: 10px;
  background: rgb(var(--surface-rgb));
  overflow: hidden;
}
.pe-zoom-dialog::backdrop { background: rgba(0, 0, 0, 0.72); }
.pe-zoom-dialog img { display: block; max-width: 92vw; max-height: 86vh; width: auto; height: auto; }
.pe-zoom-close {
  position: absolute; top: 0.5rem; right: 0.5rem; z-index: 1;
  width: 2.25rem; height: 2.25rem; border-radius: 50%;
  border: 0; background: rgba(0, 0, 0, 0.55); color: #fff;
  font-size: 1.4rem; line-height: 1; cursor: pointer;
}
.pe-zoom-close:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Scroll-snap sections (#77): a self-contained, opt-in snap region for
   landing/portfolio content. CSS-only — no runtime. `proximity` (not `mandatory`)
   snapping plus a bounded scroll region means keyboard users are never trapped:
   the panels remain individually reachable and the region scrolls normally.
   Scoped to .pe-snap so ordinary docs content is untouched. */
.pe-snap {
  max-height: 80vh;
  overflow-y: auto;
  scroll-snap-type: y proximity;
  border: 1px solid var(--grid-line);
  border-radius: 10px;
  margin: 1.5rem 0;
}
.pe-snap__panel {
  scroll-snap-align: start;
  min-height: 60vh;
  display: grid;
  place-content: center;
  gap: 0.5rem;
  padding: 2rem;
  text-align: center;
  border-bottom: 1px solid var(--grid-line);
}
.pe-snap__panel:last-child { border-bottom: 0; }
/* Smooth glide to snap points only when motion is welcome; reduced-motion snaps
   instantly. The snap itself is layout, not motion. */
@media (prefers-reduced-motion: no-preference) {
  .pe-snap { scroll-behavior: smooth; }
}

/* On-this-page TOC + scroll-spy (#73). Generated by the pageToc effect when a
   tenant opts in (data-page-toc). The active link is marked aria-current="true". */
.page-toc { font-size: 0.85rem; }
.page-toc__disc { border: 0; }
.page-toc__title {
  margin: 0 0 0.5rem;
  font-size: 0.7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
}
.page-toc__title::-webkit-details-marker { display: none; }
/* Expand/collapse affordance for the menu (narrow/portrait); hidden on the wide rail. */
.page-toc__title::after { content: "▾"; font-size: 0.8em; opacity: 0.7; }
.page-toc__disc[open] > .page-toc__title::after { content: "▴"; }
.page-toc__title:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* Pin toggle: wide rail only (enabled in the >=60rem block). Pinned = accent;
   unpinned = a dimmed, tilted pin. */
.page-toc__pin {
  display: none;
  align-items: center; justify-content: center; flex: 0 0 auto;
  margin-inline-start: auto;
  width: 1.55rem; height: 1.55rem; padding: 0;
  border: 1px solid transparent; border-radius: 6px;
  background: transparent; color: var(--muted);
  cursor: pointer; line-height: 0;
  transition: color 0.15s ease, background 0.15s ease, transform 0.15s ease, opacity 0.15s ease;
}
.page-toc__pin:hover { background: rgba(127, 127, 127, 0.14); color: var(--ink); }
.page-toc__pin:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.page-toc__pin[aria-pressed="true"] { color: var(--accent); }
.page-toc__pin[aria-pressed="false"] { transform: rotate(45deg); opacity: 0.65; }
/* Prev / next section controls. */
.page-toc__controls { display: flex; gap: 0.4rem; margin-bottom: 0.65rem; }
.page-toc__btn {
  flex: 1;
  font-size: 0.72rem; padding: 0.3rem 0.4rem;
  border: 1px solid var(--grid-line); border-radius: 6px;
  background: none; color: var(--muted); cursor: pointer;
}
.page-toc__btn:hover:not(:disabled) { color: var(--ink); border-color: var(--accent); }
.page-toc__btn:disabled { opacity: 0.4; cursor: default; }
.page-toc__btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.page-toc ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.3rem; }
.page-toc__item--sub { padding-left: 0.9rem; }
.page-toc a {
  display: block;
  color: var(--muted); text-decoration: none;
  border-left: 2px solid transparent; padding-left: 0.6rem;
}
.page-toc a:hover { color: var(--ink); }
.page-toc a[aria-current="true"] { color: var(--accent); border-left-color: var(--accent); }
.page-toc a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* Top placement: a bordered block above the content. */
.page-toc--top {
  border: 1px solid var(--grid-line); border-radius: 8px;
  padding: 1rem 1.1rem; margin: 0 0 1.5rem;
  background: rgba(var(--surface-rgb), 0.5);
}
/* Nav-style design, shared by the left and right placements: a plain list with the
   main nav's leaf / hover / active treatment — no card, no pin, no collapse. The
   placement class only decides where it lives (sidebar vs right gutter). */
.page-toc--navstyle .page-toc__disc { display: block; }
.page-toc--navstyle .page-toc__title {
  pointer-events: none; cursor: default;
  margin: 0 0 0.6rem; padding-inline: 1.1rem;
  font-size: 0.82rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted);
}
.page-toc--navstyle .page-toc__title::after { display: none; }
.page-toc--navstyle .page-toc__body { display: grid; gap: 0.6rem; }
.page-toc--navstyle .page-toc__controls { margin: 0; padding-inline: 1.1rem; gap: 0.4rem; }
.page-toc--navstyle .page-toc__btn { flex: 1; font-size: 0.72rem; padding: 0.28rem 0.4rem; }
.page-toc--navstyle ol { gap: 0.1rem; }
.page-toc--navstyle .page-toc__item--sub { padding-left: 0; }
.page-toc--navstyle a {
  padding: 0.4rem 0.9rem 0.4rem 1.1rem;
  border: 1px solid transparent; border-left: 2px solid transparent;
  color: var(--ink); font-size: 0.86rem; line-height: 1.4;
  transition: border-color 160ms ease, background 160ms ease;
}
.page-toc--navstyle .page-toc__item--sub a { padding-left: 1.7rem; font-size: 0.82rem; color: var(--muted); }
.page-toc--navstyle a:hover {
  color: var(--ink); border-color: var(--grid-line); border-left-color: var(--ink);
  background: rgba(var(--ink-rgb), 0.03);
}
.page-toc--navstyle a[aria-current="true"] {
  color: var(--ink); border-color: var(--grid-line); border-left-color: var(--ink);
  background: rgba(var(--ink-rgb), 0.05); font-weight: 600;
}
/* Left: stacked under the site nav in the sidebar (divider above). */
.page-toc--left {
  margin: 0;
  padding-top: 1.2rem;
  border-top: 1px solid var(--grid-line);
}
@media (min-width: 60rem) {
  /* Right: the same nav-style list in a sticky right gutter (the rail's spot, the
     left nav's look) — persistent, no pin/collapse. */
  .doc-content:has(> .page-toc--right) {
    max-width: calc(78ch + 14rem + 2.5rem);
    padding-inline-end: calc(14rem + 2.5rem);
  }
  .doc-content:has(> .page-toc--right) > :not(.page-toc--right) { min-width: 0; }
  .doc-content:has(> .page-toc--right) > table,
  .doc-content:has(> .page-toc--right) > pre { display: block; max-width: 100%; overflow-x: auto; }
  .doc-content > .page-toc--right {
    position: absolute; top: 0; inset-inline-end: 0; width: 14rem; height: 100%;
  }
  .doc-content > .page-toc--right > .page-toc__disc {
    position: sticky; top: 1rem; display: block;
  }
  /* Scroll only the heading list (not the whole panel), so the title + prev/next
     above it never scroll out of reach on a long outline. Bound it to clear the
     fixed chrome — topbar, the panel header, and the footer — so it never runs
     past the fold or under the footer (~21rem of height-independent chrome). */
  .doc-content > .page-toc--right .page-toc__list {
    max-height: calc(100vh - 21rem);
    overflow-y: auto;
    scrollbar-width: thin;
  }
  .doc-content:has(> .page-toc--right) .doc-fortemi-tools { right: calc(14rem + 2.5rem); }
}
/* Collapse toggle for the right placement: a chevron in the header that rotates
   when collapsed. (pointer-events:auto re-enables it inside the label header.) */
.page-toc__collapse {
  pointer-events: auto;
  flex: 0 0 auto; margin-inline-start: auto;
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.5rem; height: 1.5rem; padding: 0;
  border: 1px solid transparent; border-radius: 6px;
  background: transparent; color: var(--muted);
  font-size: 1.05rem; line-height: 0; cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}
.page-toc__collapse:hover { background: rgba(127, 127, 127, 0.14); color: var(--ink); }
.page-toc__collapse:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.page-toc__collapse > span { display: inline-block; transition: transform 0.2s ease; }
.page-toc--right.is-collapsed .page-toc__collapse > span { transform: rotate(180deg); }
@media (min-width: 60rem) {
  /* Collapsed: free the content to full width; shrink the sticky disc to a small
     handle showing just the chevron. */
  .doc-content:has(> .page-toc--right.is-collapsed) {
    /* Keep the same centred host (inherits max-width + margin from above) so the
       page doesn't reflow edge-to-edge on collapse — the prose just reclaims the
       freed gutter and the chevron handle sits at its right. */
    padding-inline-end: 2rem;
  }
  .page-toc--right.is-collapsed { pointer-events: none; }
  .page-toc--right.is-collapsed > .page-toc__disc {
    pointer-events: auto;
    width: max-content; margin-inline-start: auto;
    background: var(--surface);
    border: 1px solid var(--grid-line); border-radius: 8px;
    box-shadow: -2px 3px 12px rgba(0, 0, 0, 0.07);
  }
  .page-toc--right.is-collapsed .page-toc__title { margin: 0; padding: 0.2rem; }
  .page-toc--right.is-collapsed .page-toc__title-text { display: none; }
  .page-toc--right.is-collapsed .page-toc__body { display: none; }
}
/* Rail placement: a real sticky right column on wide viewports. The content host
   (.doc-content, which holds the markdown body — the full-bleed hero lives outside
   it) becomes a 2-column grid only when it carries a rail TOC, so content never
   overlaps the rail (the old float + sticky let content scroll under the rail).
   Below 60rem it collapses to a bordered top block. */
@media (min-width: 60rem) {
  /* Widen the content host and reserve a right gutter for the rail. The prose
     keeps its single-column flow (and its 1.75rem block gap); the rail is taken
     OUT of the flow (absolute, full-height) so it never adds grid rows, stretches
     a row, or inflates the page height — a sticky inner panel does the sticking.
     (A grid-row span here is a trap: `1 / -1` stretches row 1, and a big end line
     creates thousands of phantom rows whose gaps blow the page to ~300k px.) */
  /* Pinned (default): reserve the gutter and hold the rail open beside the prose. */
  .doc-content:has(> .page-toc--rail:not(.is-unpinned)) {
    max-width: calc(78ch + 14rem + 2.5rem);
    padding-inline-end: calc(14rem + 2.5rem);
  }
  /* Unpinned: the prose reclaims the full width for a focused, full-screen read;
     the rail collapses to a hover-peek handle on the trailing edge. */
  .doc-content:has(> .page-toc--rail.is-unpinned) {
    max-width: none;
    padding-inline-end: 0;
  }
  .doc-content:has(> .page-toc--rail) > :not(.page-toc--rail) {
    min-width: 0;
  }
  /* Wide tables/pre scroll within the prose column rather than overflowing the rail. */
  .doc-content:has(> .page-toc--rail) > table,
  .doc-content:has(> .page-toc--rail) > pre {
    display: block;
    max-width: 100%;
    overflow-x: auto;
  }
  .page-toc__pin { display: inline-flex; }
  .doc-content > .page-toc--rail {
    position: absolute;
    top: 0;
    inset-inline-end: 0;
    width: 14rem;
    height: 100%;
  }
  /* The sticky panel sticks within the full-height absolute rail. */
  .doc-content > .page-toc--rail > .page-toc__disc {
    position: sticky;
    top: 1rem;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 6rem);
    overflow: hidden;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
  }
  .doc-content > .page-toc--rail .page-toc__body {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
  }
  .doc-content > .page-toc--rail .page-toc__controls,
  .doc-content > .page-toc--rail .page-toc__title {
    flex: 0 0 auto;
  }
  .doc-content > .page-toc--rail .page-toc__list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: thin;
  }
  /* Unpinned: the full-height rail is click-through; only its disc is interactive.
     The disc is a floating card at the trailing edge — collapsed it shows only the
     prev/next controls; hover/focus (or a tap, held briefly) expands the title and
     the heading list. It is a child of the document (absolute within .doc-content),
     so it overlays the prose without reflowing anything. Reveal is class-driven, so
     the box never re-triggers :hover and stutters. */
  .doc-content > .page-toc--rail.is-unpinned { pointer-events: none; z-index: 5; }
  .doc-content > .page-toc--rail.is-unpinned > .page-toc__disc {
    pointer-events: auto;
    margin-inline-start: auto;
    width: 14rem;
    padding: 0.55rem 0.7rem;
    background: var(--surface);
    border: 1px solid var(--grid-line);
    border-radius: 10px;
    box-shadow: -2px 3px 14px rgba(0, 0, 0, 0.08);
    transition: box-shadow 0.2s ease;
  }
  /* Collapsed: fold the title and the heading list away, leaving only prev/next. */
  .doc-content > .page-toc--rail.is-unpinned:not(.is-peeking) > .page-toc__disc > .page-toc__title,
  .doc-content > .page-toc--rail.is-unpinned:not(.is-peeking) > .page-toc__disc .page-toc__list {
    max-height: 0; opacity: 0; overflow: hidden;
    margin-block: 0; padding-block: 0;
    transition: max-height 0.2s ease, opacity 0.15s ease;
  }
  /* Revealed: expand the title + heading list back in. */
  .doc-content > .page-toc--rail.is-unpinned.is-peeking > .page-toc__disc {
    box-shadow: -8px 6px 26px rgba(0, 0, 0, 0.16);
  }
  .doc-content > .page-toc--rail.is-unpinned.is-peeking > .page-toc__disc > .page-toc__title {
    max-height: 2rem; opacity: 1;
    transition: max-height 0.22s ease, opacity 0.2s ease;
  }
  .doc-content > .page-toc--rail.is-unpinned.is-peeking > .page-toc__disc .page-toc__list {
    max-height: 70vh; opacity: 1;
    transition: max-height 0.25s ease, opacity 0.2s ease;
  }
  /* Wide rail: the pin is the only control — drop the vertical-collapse triangle
     and keep the "On this page" header as a plain label. */
  .page-toc--rail > .page-toc__disc > .page-toc__title { cursor: default; }
  .page-toc--rail > .page-toc__disc > .page-toc__title::after { display: none; }
  /* Keep the Fortémi info icon clear of the rail when pinned; when unpinned the
     prose is full-width, so it returns to the prose edge. */
  .doc-content:has(> .page-toc--rail:not(.is-unpinned)) .doc-fortemi-tools {
    right: calc(14rem + 2.5rem);
  }
}
/* Narrow / portrait: a compact, collapsible "On this page" card (the disc starts
   collapsed via JS), so it never dominates the screen; prev/next stay reachable. */
@media (max-width: 59.99rem) {
  .page-toc {
    border: 1px solid var(--grid-line); border-radius: 8px;
    padding: 0.85rem 1rem; margin: 0 0 1.5rem;
    background: rgba(var(--surface-rgb), 0.5);
  }
  .page-toc--rail,
  .page-toc--right {
    position: static;
    width: auto;
    height: auto;
    z-index: auto;
    pointer-events: auto;
  }
  .page-toc--rail > .page-toc__disc,
  .page-toc--right > .page-toc__disc {
    position: static;
    display: block;
    max-height: none;
    overflow: visible;
    box-shadow: none;
  }
  .page-toc--rail .page-toc__pin,
  .page-toc--right .page-toc__collapse {
    display: none;
  }
  .page-toc--navstyle .page-toc__title {
    pointer-events: auto;
    cursor: pointer;
    margin: 0;
    padding-inline: 0;
    font-size: 0.72rem;
  }
  .page-toc--navstyle .page-toc__title::after {
    display: inline;
  }
  .page-toc--navstyle .page-toc__body {
    gap: 0.65rem;
  }
  .page-toc--navstyle .page-toc__controls {
    padding-inline: 0;
  }
  .page-toc--navstyle a {
    padding: 0.38rem 0.55rem;
  }
  .page-toc--navstyle .page-toc__item--sub a {
    padding-left: 1rem;
  }
  .page-toc__disc[open] > .page-toc__title { margin-bottom: 0.65rem; }
}

/* Scrollytelling (#78): a sticky stage beside a column of content steps. The
   active step's stage layer crossfades in. JS-off shows the steps as content and
   the stage layers statically (the swap is gated under html.has-js). */
.pe-scrolly { display: grid; gap: 2rem; margin: 1.5rem 0; }
@media (min-width: 60rem) {
  .pe-scrolly { grid-template-columns: 1fr 1fr; align-items: start; }
}
.pe-scrolly__stage {
  position: sticky; top: 2rem;
  min-height: 60vh; display: grid;
  border: 1px solid var(--grid-line); border-radius: 10px; overflow: hidden;
  background: rgba(var(--surface-rgb), 0.5);
}
.pe-scrolly__stage > [data-pe-step] {
  grid-area: 1 / 1;
  display: grid; place-content: center;
  padding: 2rem; text-align: center;
}
.pe-scrolly__steps > [data-pe-step] {
  min-height: 80vh;
  display: grid; align-content: center;
}
html.has-js .pe-scrolly__stage > [data-pe-step] { opacity: 0; }
html.has-js .pe-scrolly__stage > [data-pe-step].is-active { opacity: 1; }
@media (prefers-reduced-motion: no-preference) {
  .pe-scrolly__stage > [data-pe-step] { transition: opacity 400ms ease; }
}

/* Reading-progress indicator (opt-in via body[data-reading-progress]). */
.reading-progress {
  position: fixed;
  inset: 0 0 auto 0;
  height: 3px;
  z-index: 50;
  pointer-events: none;
  background: transparent;
}
.reading-progress-fill {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
}

/* ─────────────────────────────────────────────────────────
   Hero & banner primitives (#54) — opt-in, layout-agnostic,
   theme-token aware, accessible. Activated by .pe-* classes
   and data-* hooks; usable by hand (fenced ```html, .js
   modules, .public/+overrides) or emitted from a declarative
   frontmatter `hero` / `banner` block. Parallax/sticky are
   progressive (src/lib/page-effects.54b29946706a.js) and reduced-motion
   gated — with JS off or reduced motion the hero is a static,
   fully-readable banner.
   ───────────────────────────────────────────────────────── */
.pe-hero {
  position: relative;
  display: flex;
  align-items: center;
  min-height: var(--pe-hero-height, clamp(20rem, 46vh, 34rem));
  padding: clamp(2rem, 6vw, 5rem) clamp(1.5rem, 5vw, 4rem);
  border-radius: 14px;
  overflow: hidden;
  isolation: isolate; /* keep the bg/scrim z-order local to the hero */
  background: rgba(var(--ink-rgb), 0.04);
  color: var(--ink);
}

/* Full-bleed: break out of the canvas padding to span the content area
   edge-to-edge (never under the sidebar), and square the corners. Reuses the
   canvas bleed vars, so it tracks the shell padding exactly and never forces a
   horizontal scrollbar. */
.pe-hero--full-bleed,
.pe-banner--full-bleed {
  margin-inline: calc(var(--pe-bleed-x, 0px) * -1);
  border-radius: 0;
}
/* When the hero leads the page, pull it flush to the top of the canvas. A
   sticky hero is excluded: it needs its natural top so it can flow into place
   and then pin at the content-box top, rather than being glued there. */
.canvas > .pe-hero--full-bleed:first-child:not(.pe-hero--sticky) {
  margin-top: calc(var(--pe-bleed-y, 0px) * -1);
}

/* Background layer — image (via --pe-hero-image) or a <video>. Sits behind the
   scrim and content; slightly oversized so a parallax translate never reveals
   an edge. */
.pe-hero-bg {
  position: absolute;
  inset: -14% 0;
  z-index: -2;
  background-image: var(--pe-hero-image, none);
  background-size: cover;
  background-position: center;
  will-change: transform;
}
.pe-hero-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Scrim for legibility over media — bottom-weighted, tuned to the ink token so
   it reads in light and dark themes. Overlay text switches to the surface color
   for contrast against the inked scrim. */
.pe-hero--overlay .pe-hero-scrim {
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(
    to top,
    rgba(var(--ink-rgb), 0.72),
    rgba(var(--ink-rgb), 0.4) 45%,
    rgba(var(--ink-rgb), 0.14)
  );
}
.pe-hero--overlay {
  color: var(--surface);
}

.pe-hero-content {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: clamp(0.6rem, 1.5vw, 1rem);
  max-width: 42rem;
  width: 100%;
}
.pe-hero-content[data-pe-align="center"] {
  align-items: center;
  text-align: center;
  margin-inline: auto;
}
.pe-hero-content[data-pe-align="end"] {
  align-items: flex-end;
  text-align: right;
  margin-left: auto;
}

.pe-hero-eyebrow {
  margin: 0;
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.85;
}
.pe-hero-title {
  margin: 0;
  font-size: clamp(1.9rem, 4vw + 1rem, 3.4rem);
  line-height: 1.08;
}
.pe-hero-subtitle {
  margin: 0;
  font-size: clamp(1rem, 1vw + 0.9rem, 1.3rem);
  line-height: 1.5;
  opacity: 0.92;
}
.pe-hero-actions,
.pe-banner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.5rem;
}
.pe-hero-content[data-pe-align="center"] .pe-hero-actions { justify-content: center; }
.pe-hero-content[data-pe-align="end"] .pe-hero-actions { justify-content: flex-end; }

/* CTA button primitive — shared by hero + banner. */
.pe-cta {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.7rem 1.25rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.92rem;
  line-height: 1;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.15s;
}
.pe-cta:hover,
.pe-cta:focus-visible {
  text-decoration: none;
  transform: translateY(-1px);
}
.pe-cta--primary {
  background: var(--accent);
  color: var(--surface);
  border-color: var(--accent);
}
.pe-cta--primary:hover,
.pe-cta--primary:focus-visible {
  background: var(--ink);
  border-color: var(--ink);
}
.pe-cta--ghost {
  color: inherit;
  border-color: currentColor;
  background: transparent;
}
.pe-cta--ghost:hover,
.pe-cta--ghost:focus-visible {
  background: rgba(var(--surface-rgb), 0.14);
}
.pe-cta--plain {
  color: inherit;
  background: transparent;
  padding-inline: 0.25rem;
}
.pe-cta--plain:hover,
.pe-cta--plain:focus-visible {
  text-decoration: underline;
}

/* Sticky hero — pins to the top of the scroll container. Pure CSS (no motion),
   so it is not gated by reduced-motion. JS adds .is-stuck for optional styling
   of the pinned state. */
.pe-hero--sticky {
  position: sticky;
  top: 0;
  z-index: 5;
}
.pe-hero--sticky.is-stuck {
  box-shadow: 0 6px 24px rgba(var(--ink-rgb), 0.18);
}

/* Parallax — page-effects.js translates .pe-hero-bg on scroll. Under
   reduced-motion the layer is forced static. */
@media (prefers-reduced-motion: reduce) {
  .pe-hero-bg {
    transform: none !important;
  }
}

/* CTA band / banner primitive. */
.pe-banner {
  margin-block: clamp(2rem, 5vw, 3.5rem);
  padding: clamp(1.5rem, 4vw, 2.75rem) clamp(1.5rem, 5vw, 4rem);
  border-radius: 14px;
  background: rgba(var(--ink-rgb), 0.05);
  border: 1px solid var(--grid-line);
}
.pe-banner--full-bleed {
  border-left: 0;
  border-right: 0;
}
.pe-banner-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: clamp(1rem, 3vw, 2rem);
  max-width: 72rem;
  margin-inline: auto;
}
.pe-banner-text {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.pe-banner-title {
  margin: 0;
  font-size: clamp(1.2rem, 1.5vw + 0.9rem, 1.7rem);
  line-height: 1.2;
}
.pe-banner-sub {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

/* Let a hand-authored full-bleed hero/banner inside a fenced ```html block
   (wrapped in .html-block, which otherwise scrolls overflow) actually bleed. */
.html-block:has(.pe-hero--full-bleed),
.html-block:has(.pe-banner--full-bleed) {
  overflow: visible;
}

@media (max-width: 560px) {
  .pe-hero {
    align-items: flex-end;
    min-height: var(--pe-hero-height, clamp(22rem, 64vh, 34rem));
    padding: clamp(2rem, 10vw, 3rem) clamp(1rem, 6vw, 1.5rem);
  }
  .pe-hero-content {
    max-width: none;
  }
  .pe-hero-content[data-pe-align="center"],
  .pe-hero-content[data-pe-align="end"] {
    align-items: stretch;
    text-align: left;
  }
  .pe-hero-actions,
  .pe-banner-actions {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }
  .pe-cta {
    justify-content: center;
    width: 100%;
    min-height: 2.75rem;
    line-height: 1.2;
    white-space: normal;
    text-align: center;
  }
  .pe-banner-inner {
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
  }
}

/* Hybrid: a horizontal primary strip (built from the tenant's
   top-level sections) under the header, plus the full left rail.
   The build injects <nav class="nav-strip"> after </header>, so the
   body grid grows from three rows to four. */
body[data-nav-position="hybrid"] {
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}

.nav-strip {
  display: flex;
  align-items: stretch;
  gap: 0.25rem;
  padding: 0 clamp(1.5rem, 4vw, 4rem);
  overflow-x: auto;
  scrollbar-width: thin;
  border-bottom: 1px solid var(--grid-line);
  background: rgba(var(--surface-rgb), 0.85);
}

.nav-strip-link {
  display: inline-flex;
  align-items: center;
  padding: 0.6rem 0.9rem;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  transition: color 150ms ease, border-color 150ms ease;
}

.nav-strip-link:hover,
.nav-strip-link:focus-visible {
  color: var(--ink);
  border-bottom-color: var(--accent);
  text-decoration: none;
}

/* On small screens the base stylesheet pins .sidebar off-canvas
   (fixed, left: -100%). For top/bottom that would hide the bar, so
   restore in-flow rendering. The hybrid strip already flows inline. */
@media (max-width: 960px) {
  body[data-nav-position="top"] .sidebar,
  body[data-nav-position="bottom"] .sidebar {
    position: static;
    top: auto;
    left: auto;
    right: auto;
    width: auto;
    max-width: none;
    height: auto;
    z-index: auto;
    transition: none;
  }

  body[data-nav-position="right"] .sidebar {
    left: auto;
    right: -100%;
    border-left: 2px solid var(--ink);
    border-right: none;
  }

  body[data-nav-position="right"] .sidebar.mobile-open {
    left: auto;
    right: 0;
  }
}
