/*
 * fonts.css - self-hosted @font-face rules (Geist text, Geist Mono code, Bricolage Grotesque display). Licences: ASSETS.md.
 * Exports: font families "Geist", "Geist Mono", "Bricolage Grotesque" (latin subset) and metric fallbacks "Geist Fallback", "Bricolage Fallback". Stacks are in tokens.css.
 * Invariant: urls are relative to src/; the docs copy is rewritten to fonts/ by scripts/build.mjs.
 */
@font-face {
  font-family: "Geist";
  src: url("fonts/Geist-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: "Geist Mono";
  src: url("fonts/GeistMono-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: "Bricolage Grotesque";
  src: url("fonts/BricolageGrotesque-latin-opsz-normal.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
/* Metric-matched fallbacks (measured against the web fonts with canvas measureText on Arial) so the swap does not reflow text. */
@font-face {
  font-family: "Geist Fallback";
  src: local("Arial"), local("Helvetica"), local("Liberation Sans");
  size-adjust: 102.9%;
  ascent-override: 98.1%;
  descent-override: 28.2%;
  line-gap-override: 0%;
}
@font-face {
  font-family: "Bricolage Fallback";
  src: local("Arial"), local("Helvetica"), local("Liberation Sans");
  size-adjust: 93.5%;
  ascent-override: 99.5%;
  descent-override: 28.9%;
  line-gap-override: 0%;
}

/*
 * tokens.css - design tokens of every Bill & Ben web surface.
 * Exports: custom properties --bb-* (names fixed in .context/plans/web-refresh/00-architecture.md section 3).
 * Invariants: this file is the ONLY place for raw colours, durations and font names. #3399ff is the accent (links, focus, rings), never a fill
 * behind text; filled buttons and badges use --bb-color-primary-fill with white --bb-color-on-primary (>= 4.5:1); #ffff66 is a background behind dark text. Links and focus use --bb-color-link / --bb-color-focus.
 * Dark values are listed twice (explicit data attribute, and the OS preference unless light is forced); keep them equal.
 */
:root {
  --bb-color-bg: #ffffff;
  --bb-color-surface: #f5f8fc;
  --bb-color-surface-2: #e8eef6;
  --bb-color-surface-3: #eef2f6;
  --bb-color-hover: rgb(0 0 0 / 4%);
  --bb-color-selected: rgb(0 102 204 / 12%);
  --bb-color-text: #0b1220;
  --bb-color-text-muted: #4a5561;
  --bb-color-text-subtle: #5c6670;
  --bb-color-border: #c9d1d9;
  --bb-color-border-strong: #8a8a8a;
  --bb-color-edge: transparent;
  --bb-color-code-bg: #f6f8fa;
  --bb-color-chart-1: #0066cc;
  --bb-color-chart-2: #0f766e;
  --bb-color-chart-3: #b45309;
  --bb-color-chart-4: #7a3fd1;
  --bb-color-chart-5: #be123c;
  --bb-color-canvas-bg: #fafafa;
  --bb-color-canvas-dot: #d4d4d4;
  --bb-color-primary: #3399ff;
  --bb-color-primary-hover: #1f8bff;
  --bb-color-primary-border: #0066cc;
  --bb-color-primary-fill: #0072e5;
  --bb-color-primary-fill-hover: #005bb8;
  --bb-color-on-primary: #ffffff;
  --bb-color-link: #0066cc;
  --bb-color-focus: #0066cc;
  --bb-color-accent: #ffff66;
  --bb-color-on-accent: #0a0a0a;
  --bb-color-success: #1a7f37;
  --bb-color-warning: #8a5300;
  --bb-color-danger: #c62828;
  --bb-color-info: #0066cc;
  --bb-color-dot: #c9d1d9;
  --bb-color-agent-bill: #0066cc;
  --bb-color-agent-ben: #7a3fd1;
  --bb-color-agent-human: #8a5300;

  --bb-font-sans: "Geist", "Geist Fallback", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bb-font-mono: "Geist Mono", ui-monospace, Menlo, Consolas, monospace;
  --bb-font-display: "Bricolage Grotesque", "Bricolage Fallback", "Geist", "Geist Fallback", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bb-font-size-xs: 0.75rem;
  --bb-font-size-sm: 0.875rem;
  --bb-font-size-md: 1rem;
  --bb-font-size-lg: 1.25rem;
  --bb-font-size-xl: 1.5rem;
  --bb-font-size-2xl: 2rem;
  --bb-font-size-3xl: 2.75rem;
  --bb-font-size-hero: clamp(2.75rem, 6vw + 1rem, 5.5rem);
  --bb-font-size-display: clamp(2.75rem, 6vw, 4.5rem);
  --bb-line-height-tight: 1.2;
  --bb-line-height-normal: 1.6;
  --bb-font-weight-regular: 400;
  --bb-font-weight-medium: 500;
  --bb-font-weight-bold: 700;

  --bb-space-1: 4px;
  --bb-space-2: 8px;
  --bb-space-3: 12px;
  --bb-space-4: 16px;
  --bb-space-5: 24px;
  --bb-space-6: 32px;
  --bb-space-7: 48px;
  --bb-space-8: 64px;
  --bb-space-9: 96px;
  --bb-space-10: 128px;
  --bb-radius-sm: 6px;
  --bb-radius-md: 10px;
  --bb-radius-lg: 16px;
  --bb-radius-pill: 999px;
  --bb-radius-button: var(--bb-radius-pill);
  --bb-shadow-1: 0 1px 2px rgb(11 18 32 / 8%);
  --bb-shadow-2: 0 4px 12px rgb(11 18 32 / 10%);
  --bb-shadow-md: var(--bb-shadow-2);
  --bb-shadow-3: 0 12px 32px rgb(11 18 32 / 14%);
  --bb-glow-primary: 0 0 24px rgb(51 153 255 / 40%);

  --bb-motion-duration-fast: 120ms;
  --bb-motion-duration-base: 200ms;
  --bb-motion-duration-slow: 360ms;
  --bb-motion-duration-reveal: 600ms;
  --bb-motion-ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --bb-motion-ease-emphasized: cubic-bezier(0.2, 0, 0, 1.15);
  --bb-motion-ease-exit: cubic-bezier(0.4, 0, 1, 1);
  --bb-motion-distance: 12px;
  --bb-motion-duration-instant: 80ms;
  --bb-motion-duration-scene: 1200ms;
  --bb-motion-ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --bb-motion-ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --bb-motion-stagger: 60ms;
  --bb-motion-distance-lg: 40px;
  --bb-spring-snappy-stiffness: 420;
  --bb-spring-snappy-damping: 34;
  --bb-spring-gentle-stiffness: 170;
  --bb-spring-gentle-damping: 26;

  --bb-z-nav: 100;
  --bb-z-overlay: 200;
  --bb-z-toast: 300;
  --bb-z-tooltip: 400;
  --bb-content-max: 72rem;
  --bb-content-wide: 90rem;
  --bb-measure: 65ch;
  --bb-nav-height: 64px;
}

:root[data-theme="dark"],
[data-md-color-scheme="slate"] {
  --bb-color-bg: #121212;
  --bb-color-surface: #1a1a1a;
  --bb-color-surface-2: #222222;
  --bb-color-surface-3: #2a2a2a;
  --bb-color-hover: rgb(255 255 255 / 6%);
  --bb-color-selected: rgb(102 179 255 / 14%);
  --bb-color-text: #e6e6e6;
  --bb-color-text-muted: #a3a3a3;
  --bb-color-text-subtle: #8f8f8f;
  --bb-color-border: #2e2e2e;
  --bb-color-border-strong: #666666;
  --bb-color-edge: rgb(255 255 255 / 6%);
  --bb-color-primary: #3399ff;
  --bb-color-primary-hover: #5cadff;
  --bb-color-primary-border: #1f7ae0;
  --bb-color-primary-fill: #0072e5;
  --bb-color-primary-fill-hover: #005bb8;
  --bb-color-on-primary: #ffffff;
  --bb-color-link: #66b3ff;
  --bb-color-focus: #66b3ff;
  --bb-color-accent: #e6e65c;
  --bb-color-on-accent: #0a0a0a;
  --bb-color-success: #4cc38a;
  --bb-color-warning: #f5b84a;
  --bb-color-danger: #ff6b6b;
  --bb-color-info: #66b3ff;
  --bb-color-code-bg: #171717;
  --bb-color-chart-1: #66b3ff;
  --bb-color-chart-2: #2dd4bf;
  --bb-color-chart-3: #f5b84a;
  --bb-color-chart-4: #a78bfa;
  --bb-color-chart-5: #fb7185;
  --bb-color-dot: #333333;
  --bb-color-canvas-bg: #161616;
  --bb-color-canvas-dot: #2e2e2e;
  --bb-color-agent-bill: #66b3ff;
  --bb-color-agent-ben: #c4a7ff;
  --bb-color-agent-human: #e6e65c;
  --bb-shadow-1: 0 0 0 1px var(--bb-color-edge);
  --bb-shadow-2: 0 0 0 1px var(--bb-color-edge), 0 8px 24px rgb(0 0 0 / 45%);
  --bb-shadow-md: var(--bb-shadow-2);
  --bb-shadow-3: 0 0 0 1px var(--bb-color-edge), 0 8px 24px rgb(0 0 0 / 45%);
  --bb-glow-primary: 0 0 24px rgb(51 153 255 / 45%);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
      --bb-color-bg: #121212;
    --bb-color-surface: #1a1a1a;
    --bb-color-surface-2: #222222;
    --bb-color-surface-3: #2a2a2a;
    --bb-color-hover: rgb(255 255 255 / 6%);
    --bb-color-selected: rgb(102 179 255 / 14%);
    --bb-color-text: #e6e6e6;
    --bb-color-text-muted: #a3a3a3;
    --bb-color-text-subtle: #8f8f8f;
    --bb-color-border: #2e2e2e;
    --bb-color-border-strong: #666666;
    --bb-color-edge: rgb(255 255 255 / 6%);
    --bb-color-primary: #3399ff;
    --bb-color-primary-hover: #5cadff;
    --bb-color-primary-border: #1f7ae0;
    --bb-color-primary-fill: #0072e5;
    --bb-color-primary-fill-hover: #005bb8;
    --bb-color-on-primary: #ffffff;
    --bb-color-link: #66b3ff;
    --bb-color-focus: #66b3ff;
    --bb-color-accent: #e6e65c;
    --bb-color-on-accent: #0a0a0a;
    --bb-color-success: #4cc38a;
    --bb-color-warning: #f5b84a;
    --bb-color-danger: #ff6b6b;
    --bb-color-info: #66b3ff;
    --bb-color-code-bg: #171717;
    --bb-color-chart-1: #66b3ff;
    --bb-color-chart-2: #2dd4bf;
    --bb-color-chart-3: #f5b84a;
    --bb-color-chart-4: #a78bfa;
    --bb-color-chart-5: #fb7185;
    --bb-color-dot: #333333;
    --bb-color-canvas-bg: #161616;
    --bb-color-canvas-dot: #2e2e2e;
    --bb-color-agent-bill: #66b3ff;
    --bb-color-agent-ben: #c4a7ff;
    --bb-color-agent-human: #e6e65c;
    --bb-shadow-1: 0 0 0 1px var(--bb-color-edge);
    --bb-shadow-2: 0 0 0 1px var(--bb-color-edge), 0 8px 24px rgb(0 0 0 / 45%);
    --bb-shadow-md: var(--bb-shadow-2);
    --bb-shadow-3: 0 0 0 1px var(--bb-color-edge), 0 8px 24px rgb(0 0 0 / 45%);
    --bb-glow-primary: 0 0 24px rgb(51 153 255 / 45%);
  }
}

/* Reduced motion (00 D4): durations collapse, distance is zero, so nothing travels. */
@media (prefers-reduced-motion: reduce) {
  :root {
    --bb-motion-duration-fast: 0.01ms;
    --bb-motion-duration-base: 0.01ms;
    --bb-motion-duration-slow: 0.01ms;
    --bb-motion-duration-reveal: 0.01ms;
    --bb-motion-distance: 0;
    --bb-motion-distance-lg: 0;
    --bb-motion-duration-instant: 0.01ms;
    --bb-motion-duration-scene: 0.01ms;
    --bb-motion-stagger: 0ms;
  }
}

/*
 * base.css - element defaults on tokens: box model, body, headings, links, focus ring, selection and layout helpers.
 * Exports: .bb-sr-only, .bb-container, .bb-dot-grid. Invariant: only var(--bb-*) values, no raw colours.
 */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bb-color-bg);
  color: var(--bb-color-text);
  font: var(--bb-font-weight-regular) var(--bb-font-size-md) / var(--bb-line-height-normal) var(--bb-font-sans);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
  margin: 0 0 var(--bb-space-3);
  line-height: var(--bb-line-height-tight);
  font-weight: var(--bb-font-weight-bold);
  letter-spacing: -0.01em;
}
h1,
h2 {
  letter-spacing: -0.02em;
  font-optical-sizing: auto;
}
/* Display face for h1-h2 only; written as the font shorthand so family names stay in tokens.css. */
h1 { font: 700 var(--bb-font-size-3xl) / var(--bb-line-height-tight) var(--bb-font-display); }
h2 { font: 700 var(--bb-font-size-2xl) / var(--bb-line-height-tight) var(--bb-font-display); }
h3 { font-size: var(--bb-font-size-xl); }
h4 { font-size: var(--bb-font-size-lg); }

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

a {
  color: var(--bb-color-link);
  text-underline-offset: 0.2em;
}

code,
kbd,
pre {
  font: 0.9em var(--bb-font-mono);
}

:focus-visible {
  outline: 3px solid var(--bb-color-focus);
  outline-offset: 2px;
}

::selection {
  background: var(--bb-color-accent);
  color: var(--bb-color-on-accent);
}

.bb-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.bb-container {
  width: 100%;
  max-width: var(--bb-content-max);
  margin-inline: auto;
  padding-inline: var(--bb-space-4);
}

.bb-dot-grid {
  background-image: radial-gradient(var(--bb-color-dot) 1.5px, transparent 1.5px);
  background-size: var(--bb-space-5) var(--bb-space-5);
  mask-image: linear-gradient(to bottom, var(--bb-color-bg) 40%, transparent);
}

/*
 * components.css - shared component classes of 00 section 3.
 * Exports: .bb-btn(--primary|--secondary|--ghost|--danger), .bb-pill-nav, .bb-card, .bb-badge, .bb-highlight,
 * .bb-skeleton, .bb-field, .bb-table, .bb-tooltip, .bb-theme-toggle, .bb-bleed, .bb-container--wide, .bb-measure,
 * .bb-table--stack, .bb-empty, .bb-hint, .bb-drawer(+.bb-scrim), .bb-segmented. Invariants: tokens only; targets >= 24px (44px on touch);
 * tooltips open from [data-tooltip-open], never from :hover alone (WCAG 1.4.13, script decides).
 */
.bb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--bb-space-2);
  min-width: 24px;
  min-height: 24px;
  padding: var(--bb-space-2) var(--bb-space-4);
  border: 1px solid transparent;
  border-radius: var(--bb-radius-button);
  font: inherit;
  font-weight: var(--bb-font-weight-medium);
  text-decoration: none;
  cursor: pointer;
  transition:
    transform var(--bb-motion-duration-fast) var(--bb-motion-ease-standard),
    box-shadow var(--bb-motion-duration-base) var(--bb-motion-ease-standard),
    background-color var(--bb-motion-duration-fast) var(--bb-motion-ease-standard);
}
@media (pointer: coarse) {
  .bb-btn { min-height: 44px; min-width: 44px; }
}
.bb-btn:disabled,
.bb-btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}
.bb-btn--primary {
  background: var(--bb-color-primary-fill);
  color: var(--bb-color-on-primary);
  border-color: var(--bb-color-primary-border);
}
.bb-btn--primary:disabled,
.bb-btn--primary[aria-disabled="true"] {
  background: var(--bb-color-surface-2);
  color: var(--bb-color-text-muted);
  border-color: var(--bb-color-border-strong);
  opacity: 1;
}
.bb-btn--primary:hover:not(:disabled):not([aria-disabled="true"]) {
  background: var(--bb-color-primary-fill-hover);
  box-shadow: var(--bb-glow-primary);
}
.bb-btn--secondary {
  background: var(--bb-color-surface);
  color: var(--bb-color-text);
  border-color: var(--bb-color-border);
}
.bb-btn--secondary:hover:not(:disabled):not([aria-disabled="true"]) {
  background: var(--bb-color-surface-2);
}
.bb-btn--ghost {
  background: transparent;
  color: var(--bb-color-link);
}
.bb-btn--ghost:hover:not(:disabled):not([aria-disabled="true"]) {
  background: var(--bb-color-surface-2);
}
.bb-btn--danger {
  background: transparent;
  color: var(--bb-color-danger);
  border-color: var(--bb-color-danger);
}
.bb-btn--danger:hover:not(:disabled):not([aria-disabled="true"]) {
  background: var(--bb-color-surface-2);
}

.bb-pill-nav {
  position: sticky;
  top: 0;
  z-index: var(--bb-z-nav);
  display: flex;
  align-items: center;
  gap: var(--bb-space-1);
  min-height: var(--bb-nav-height);
  padding: var(--bb-space-2) var(--bb-space-4);
  background: color-mix(in srgb, var(--bb-color-surface) 82%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--bb-color-border);
}
.bb-pill-nav a:not(.bb-btn) {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: var(--bb-space-2) var(--bb-space-4);
  border-radius: var(--bb-radius-pill);
  color: var(--bb-color-text);
  text-decoration: none;
  transition: background-color var(--bb-motion-duration-fast) var(--bb-motion-ease-standard);
}
.bb-pill-nav a:not(.bb-btn):hover { background: var(--bb-color-surface-2); }
.bb-pill-nav a[aria-current],
.bb-pill-nav a.is-active {
  background: var(--bb-color-surface-2);
  font-weight: var(--bb-font-weight-medium);
}
@media (pointer: coarse) {
  .bb-pill-nav a { min-height: 44px; }
}

.bb-card {
  padding: var(--bb-space-5);
  background: var(--bb-color-surface);
  border: 1px solid var(--bb-color-border);
  border-radius: var(--bb-radius-lg);
  box-shadow: var(--bb-shadow-1);
}

.bb-badge {
  display: inline-block;
  padding: 0 var(--bb-space-2);
  border: 1px solid var(--bb-color-border);
  border-radius: var(--bb-radius-pill);
  background: var(--bb-color-surface-2);
  color: var(--bb-color-text);
  font-size: var(--bb-font-size-xs);
  font-weight: var(--bb-font-weight-medium);
}

.bb-highlight {
  background: var(--bb-color-accent);
  color: var(--bb-color-on-accent);
  padding: 0 var(--bb-space-1);
  border-radius: var(--bb-radius-sm);
}

.bb-skeleton {
  display: block;
  min-height: 1em;
  border-radius: var(--bb-radius-sm);
  background: linear-gradient(
    90deg,
    var(--bb-color-surface-2) 25%,
    var(--bb-color-surface) 50%,
    var(--bb-color-surface-2) 75%
  );
  background-size: 200% 100%;
  animation: bb-shimmer 1.4s linear infinite;
}
@media (prefers-reduced-motion: reduce) {
  .bb-skeleton { animation: none; background: var(--bb-color-surface-2); }
}

.bb-field {
  display: flex;
  flex-direction: column;
  gap: var(--bb-space-1);
}
.bb-field label { font-weight: var(--bb-font-weight-medium); }
.bb-field input,
.bb-field select,
.bb-field textarea {
  min-height: 24px;
  padding: var(--bb-space-2) var(--bb-space-3);
  border: 1px solid var(--bb-color-text-muted);
  border-radius: var(--bb-radius-md);
  background: var(--bb-color-bg);
  color: var(--bb-color-text);
  font: inherit;
}
.bb-field [aria-invalid="true"] { border-color: var(--bb-color-danger); }
.bb-field .bb-field-error { color: var(--bb-color-danger); font-size: var(--bb-font-size-sm); }
@media (pointer: coarse) {
  .bb-field input,
  .bb-field select { min-height: 44px; }
}

.bb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--bb-font-size-sm);
}
.bb-table th,
.bb-table td {
  padding: var(--bb-space-2) var(--bb-space-3);
  border-bottom: 1px solid var(--bb-color-border);
  text-align: start;
}
.bb-table th {
  background: var(--bb-color-surface);
  font-weight: var(--bb-font-weight-medium);
}

.bb-tooltip {
  position: absolute;
  z-index: var(--bb-z-tooltip);
  max-width: 20rem;
  padding: var(--bb-space-2) var(--bb-space-3);
  border-radius: var(--bb-radius-md);
  background: var(--bb-color-text);
  color: var(--bb-color-bg);
  font-size: var(--bb-font-size-sm);
  box-shadow: var(--bb-shadow-2);
  opacity: 0;
  visibility: hidden;
  transition:
    opacity var(--bb-motion-duration-fast) var(--bb-motion-ease-standard),
    visibility var(--bb-motion-duration-fast);
}
[data-tooltip-open] > .bb-tooltip,
.bb-tooltip[data-tooltip-open] {
  opacity: 1;
  visibility: visible;
}

/* Button lift and press (web-polish 02). Reduced motion zeroes the transform. */
.bb-btn:hover:not(:disabled):not([aria-disabled="true"]) {
  transform: translateY(-1px);
}
.bb-btn:not(.bb-btn--primary):hover:not(:disabled):not([aria-disabled="true"]) {
  box-shadow: var(--bb-shadow-2);
}
.bb-btn:active:not(:disabled):not([aria-disabled="true"]) {
  transform: scale(0.98);
}
@media (prefers-reduced-motion: reduce) {
  .bb-btn:hover:not(:disabled):not([aria-disabled="true"]),
  .bb-btn:active:not(:disabled):not([aria-disabled="true"]) { transform: none; }
}

/* Theme toggle: two stacked icons; the moon shows in light, the sun in dark, cross-fading with a quarter turn. */
.bb-theme-toggle {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--bb-radius-md);
  background: transparent;
  color: var(--bb-color-text);
  cursor: pointer;
}
.bb-theme-toggle:hover { background: var(--bb-color-hover); }
.bb-theme-toggle svg {
  grid-area: 1 / 1;
  width: 20px;
  height: 20px;
  transition:
    opacity var(--bb-motion-duration-base) var(--bb-motion-ease-standard),
    transform var(--bb-motion-duration-base) var(--bb-motion-ease-standard);
}
.bb-theme-toggle .bb-icon-sun { opacity: 0; transform: rotate(-90deg); }
:root[data-theme="dark"] .bb-theme-toggle .bb-icon-sun { opacity: 1; transform: none; }
:root[data-theme="dark"] .bb-theme-toggle .bb-icon-moon { opacity: 0; transform: rotate(90deg); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .bb-theme-toggle .bb-icon-sun { opacity: 1; transform: none; }
  :root:not([data-theme]) .bb-theme-toggle .bb-icon-moon { opacity: 0; transform: rotate(90deg); }
}
@media (prefers-reduced-motion: reduce) {
  .bb-theme-toggle svg { transform: none !important; }
}

/* Layout primitives. */
.bb-bleed {
  width: 100vw;
  margin-inline: calc(50% - 50vw);
  background: var(--bb-bleed-bg, var(--bb-color-surface));
}
.bb-container--wide { max-width: var(--bb-content-wide); }
.bb-measure { max-width: var(--bb-measure); }

/* Below 768px every row becomes a card; cells show their column name from data-label. */
@media (max-width: 767.98px) {
  .bb-table--stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .bb-table--stack tr {
    display: block;
    margin-bottom: var(--bb-space-3);
    background: var(--bb-color-surface);
    border: 1px solid var(--bb-color-border);
    border-radius: var(--bb-radius-lg);
  }
  .bb-table--stack td { display: flex; justify-content: space-between; gap: var(--bb-space-3); }
  .bb-table--stack td::before { content: attr(data-label); color: var(--bb-color-text-muted); }
}

.bb-empty {
  display: grid;
  justify-items: center;
  gap: var(--bb-space-2);
  padding: var(--bb-space-8) var(--bb-space-4);
  text-align: center;
  color: var(--bb-color-text-muted);
}
.bb-empty > h2,
.bb-empty > h3 { margin: 0; color: var(--bb-color-text); }
.bb-empty > p { max-width: var(--bb-measure); margin: 0; }

.bb-hint {
  display: flex;
  align-items: flex-start;
  gap: var(--bb-space-3);
  padding: var(--bb-space-3) var(--bb-space-4);
  background: var(--bb-color-selected);
  border: 1px solid var(--bb-color-border);
  border-radius: var(--bb-radius-md);
}
.bb-hint > p { flex: 1; margin: 0; }
.bb-hint > button { min-width: 44px; min-height: 44px; border: 0; background: transparent; color: inherit; cursor: pointer; }

.bb-scrim {
  position: fixed;
  inset: 0;
  z-index: var(--bb-z-overlay);
  background: rgb(0 0 0 / 50%);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--bb-motion-duration-base) var(--bb-motion-ease-standard), visibility var(--bb-motion-duration-base);
}
.bb-drawer {
  position: fixed;
  inset-block: 0;
  inset-inline-end: 0;
  z-index: var(--bb-z-overlay);
  width: min(24rem, 100vw);
  padding: var(--bb-space-5);
  overflow-y: auto;
  background: var(--bb-color-surface);
  border-inline-start: 1px solid var(--bb-color-border);
  box-shadow: var(--bb-shadow-3);
  transform: translateX(100%);
  transition: transform var(--bb-motion-duration-slow) var(--bb-motion-ease-out-expo);
}
.bb-drawer[data-open] { transform: none; }
.bb-drawer[data-open] + .bb-scrim,
.bb-scrim[data-open] { opacity: 1; visibility: visible; }
@media (prefers-reduced-motion: reduce) {
  .bb-drawer { transition: none; }
}

/* Radio group that looks like a segmented control: wrap radios in labels inside .bb-segmented. */
.bb-segmented {
  display: inline-flex;
  padding: 2px;
  background: var(--bb-color-surface-2);
  border: 1px solid var(--bb-color-border);
  border-radius: var(--bb-radius-md);
}
.bb-segmented label {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding-inline: var(--bb-space-3);
  border-radius: var(--bb-radius-sm);
  cursor: pointer;
}
.bb-segmented input { position: absolute; opacity: 0; pointer-events: none; }
.bb-segmented label:has(input:checked) { background: var(--bb-color-bg); box-shadow: var(--bb-shadow-1); }
.bb-segmented label:has(input:focus-visible) { outline: 3px solid var(--bb-color-focus); outline-offset: 2px; }

/* Brand: the two-bubble mark (brand/mark.svg, inlined) plus the wordmark in the display face. */
.bb-brand {
  display: inline-flex;
  align-items: center;
  gap: var(--bb-space-2);
  margin: 0;
  color: var(--bb-color-text);
  font-family: var(--bb-font-display);
  font-size: var(--bb-font-size-lg);
  font-weight: var(--bb-font-weight-bold);
  letter-spacing: -0.01em;
  text-decoration: none;
}
.bb-brand__mark { display: inline-grid; width: 28px; height: 28px; }
.bb-brand__mark svg { width: 100%; height: 100%; }

/* Footer: full-bleed band, one hairline on top, link columns. Rendered from src/site-links.json by each surface. */
.bb-footer {
  padding-block: var(--bb-space-8) var(--bb-space-5);
  background: var(--bb-color-surface-2);
  border-top: 1px solid var(--bb-color-border);
}
.bb-footer__grid { display: grid; gap: var(--bb-space-6); grid-template-columns: 1fr; }
@media (min-width: 480px) { .bb-footer__grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .bb-footer__grid { grid-template-columns: 1.4fr repeat(3, 1fr); } }
.bb-footer__about { display: grid; gap: var(--bb-space-3); align-content: start; }
.bb-footer__about p { margin: 0; color: var(--bb-color-text-muted); max-width: 32ch; }
.bb-footer__theme { margin: 0; justify-self: start; }
.bb-footer__heading { margin: 0 0 var(--bb-space-3); font-size: var(--bb-font-size-sm); color: var(--bb-color-text-muted); font-weight: var(--bb-font-weight-medium); }
.bb-footer ul { margin: 0; padding: 0; list-style: none; display: grid; gap: var(--bb-space-1); }
.bb-footer a { display: inline-flex; align-items: center; min-height: 24px; color: var(--bb-color-text-muted); text-decoration: none; }
.bb-footer a:hover, .bb-footer a:focus-visible { color: var(--bb-color-text); text-decoration: underline; }
@media (pointer: coarse) { .bb-footer a { min-height: 44px; } }
.bb-footer__bottom {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--bb-space-3);
  margin-top: var(--bb-space-6);
  padding-top: var(--bb-space-4);
  border-top: 1px solid var(--bb-color-border);
  color: var(--bb-color-text-muted);
  font-size: var(--bb-font-size-sm);
}
.bb-footer__bottom p { margin: 0; display: flex; flex-wrap: wrap; gap: var(--bb-space-4); }
/* Text-only button that reads like the footer links (the analytics opt-out). */
.bb-footer__linkbtn { all: unset; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.bb-footer__linkbtn:focus-visible { outline: 2px solid var(--bb-color-focus, currentColor); outline-offset: 2px; border-radius: 2px; }
/* Compact footer (console sign-in and settings): one row, no link columns. */
.bb-footer--compact { padding-block: var(--bb-space-4); }
.bb-footer--compact .bb-footer__grid { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--bb-space-4); }
.bb-footer--compact .bb-footer__about { display: flex; flex-wrap: wrap; align-items: center; gap: var(--bb-space-4); }

/*
 * motion.css - keyframes, scroll reveal and view transitions. Exports: bb-fade-up, bb-fade, bb-shimmer, bb-pop, .bb-reveal, .bb-stagger, .bb-qa-static.
 * Invariants: all durations and distances come from tokens (zero under reduced motion); content is visible without motion:
 * the hidden state exists only when initReveal() set .bb-js and the browser lacks scroll-driven animations.
 */
@keyframes bb-fade-up {
  from { opacity: 0; transform: translateY(var(--bb-motion-distance)); }
  to { opacity: 1; transform: none; }
}
@keyframes bb-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes bb-shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}
@keyframes bb-pop {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: view()) {
    .bb-reveal {
      animation: bb-fade-up var(--bb-motion-duration-reveal) var(--bb-motion-ease-standard) both;
      animation-timeline: view();
      animation-range: entry 0% entry 60%;
    }
  }
  @supports not (animation-timeline: view()) {
    .bb-js .bb-reveal:not(.is-visible) {
      opacity: 0;
      transform: translateY(var(--bb-motion-distance));
    }
    .bb-js .bb-reveal {
      transition:
        opacity var(--bb-motion-duration-reveal) var(--bb-motion-ease-standard),
        transform var(--bb-motion-duration-reveal) var(--bb-motion-ease-standard);
    }
  }
  @view-transition {
    navigation: auto;
  }
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: var(--bb-motion-duration-base);
  animation-timing-function: var(--bb-motion-ease-standard);
}

/* Children of .bb-stagger set --i (0, 1, 2...) and wait i * stagger before their own animation starts. */
.bb-stagger > * {
  animation-delay: calc(var(--i, 0) * var(--bb-motion-stagger));
  transition-delay: calc(var(--i, 0) * var(--bb-motion-stagger));
}

/* Print and the screenshot harness (.bb-qa-static on <html>) must see every reveal, never a half-faded one. */
@media print {
  .bb-reveal { opacity: 1 !important; transform: none !important; animation: none !important; }
}
.bb-qa-static .bb-reveal {
  opacity: 1 !important;
  transform: none !important;
  animation: none !important;
  transition: none !important;
}
