/* =============================================================
   Ball-on-Plate — Design System
   Modern Ink palette + editorial typography + smooth animations
============================================================= */

@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:ital,opsz,wght@0,8..60,400..600;1,8..60,400..500&family=Inter:wght@400;500;600&display=swap');

:root {
  /* Brand accent */
  --berkeley-blue: #2f43c4;
  --berkeley-blue-light: #6b78d6;
  --berkeley-gold: #2f43c4;
  --berkeley-gold-dark: #2f43c4;

  /* Neutrals */
  --bg: #ffffff;
  --bg-soft: #f7f8fa;
  --bg-dark: #16181d;
  --surface: #ffffff;
  --text: #16181d;
  --text-soft: #5b626e;
  --text-muted: #8a909a;
  --border: #e9ecf0;

  /* Accents */
  --accent-violet: #6643a0;
  --accent-green: #288c5a;
  --accent-red: #b41e28;

  /* Spacing */
  --pad-xs: 0.5rem;
  --pad-sm: 1rem;
  --pad-md: 2rem;
  --pad-lg: 4rem;
  --pad-xl: 8rem;

  /* Typography */
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-display: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Menlo, monospace;

  /* Radius + Shadow */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(22, 24, 29, 0.04);
  --shadow-md: 0 4px 14px rgba(22, 24, 29, 0.05);
  --shadow-lg: 0 12px 36px rgba(22, 24, 29, 0.07);

  /* Transitions */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* =============================================================
   Reset & base
============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.15rem;
  line-height: 1.62;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

a { color: var(--berkeley-blue); text-decoration: none; transition: color 0.2s var(--ease-out); }
a:hover { color: var(--berkeley-blue-light); }

::selection { background: var(--berkeley-blue); color: #fff; }

/* =============================================================
   Typography
============================================================= */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--text);
}

h1 { font-size: clamp(2.5rem, 5.5vw, 4.5rem); font-weight: 700; }
h2 { font-size: clamp(1.875rem, 3.5vw, 2.75rem); }
h3 { font-size: clamp(1.375rem, 2.4vw, 1.75rem); }
h4 { font-size: 1.125rem; font-weight: 600; }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--berkeley-gold-dark);
  font-weight: 600;
  margin-bottom: var(--pad-sm);
}

.lead {
  font-size: clamp(1.125rem, 1.8vw, 1.375rem);
  line-height: 1.55;
  color: var(--text-soft);
  font-weight: 400;
}

code, pre {
  font-family: var(--font-mono);
  font-size: 0.875em;
}

code:not(pre code) {
  background: var(--bg-soft);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  color: var(--berkeley-blue);
  font-size: 0.85em;
}

pre {
  background: var(--bg-dark);
  color: #c8d6e5;
  padding: var(--pad-md);
  border-radius: var(--radius-md);
  overflow-x: auto;
  line-height: 1.6;
  font-size: 0.875rem;
  margin: var(--pad-md) 0;
}

pre code { color: inherit; background: none; padding: 0; }

/* =============================================================
   Layout
============================================================= */
.container {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 var(--pad-md);
}

.container-narrow { max-width: 768px; }

section {
  padding: var(--pad-lg) 0;
  position: relative;
}
/* The `.hero` rule (below) sets its own padding to clear the fixed nav.
   The generic `section { padding: var(--pad-lg) 0 }` default would otherwise
   stack with the hero's own padding-top. */
section.spacious { padding: var(--pad-xl) 0; }

/* =============================================================
   Navbar
============================================================= */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  padding: 1.25rem 0;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s var(--ease-out), background 0.3s;
}
.nav.scrolled {
  border-bottom-color: var(--border);
  background: rgba(255, 255, 255, 0.96);
}
.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 var(--pad-md);
}
.brand {
  display: flex; align-items: center; gap: 0.6rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--berkeley-blue);
  letter-spacing: -0.01em;
}
.brand-acc {
  color: var(--berkeley-gold);
  font-weight: 700;
}
.brand .dot {
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--berkeley-gold);
  box-shadow: 0 0 0 4px rgba(47, 67, 196, 0.18);
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(47, 67, 196, 0.18); }
  50% { box-shadow: 0 0 0 9px rgba(47, 67, 196, 0.06); }
}

.nav-links {
  list-style: none;
  display: flex;
  gap: 2rem;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 500;
}
.nav-links a {
  color: var(--text-soft);
  position: relative;
  transition: color 0.2s var(--ease-out);
}
.nav-links a::after {
  content: '';
  position: absolute;
  left: 0; bottom: -6px;
  width: 0; height: 2px;
  background: var(--berkeley-gold);
  transition: width 0.3s var(--ease-out);
}
.nav-links a:hover { color: var(--berkeley-blue); }
.nav-links a:hover::after { width: 100%; }
.nav-links a.active { color: var(--berkeley-blue); }
.nav-links a.active::after { width: 100%; }

/* Hamburger button. Visible only on mobile/tablet (<=920px); on desktop
   the nav-links are inline and the button collapses. */
.nav-toggle {
  display: none;
  width: 44px;
  height: 44px;
  padding: 0;
  background: transparent;
  border: 0;
  cursor: pointer;
  position: relative;
  z-index: 110;
  border-radius: 8px;
  color: var(--berkeley-blue);
}
.nav-toggle-bar {
  display: block;
  position: absolute;
  left: 11px;
  width: 22px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  transition: transform 0.25s var(--ease-out),
              opacity 0.2s var(--ease-out),
              top 0.25s var(--ease-out);
}
.nav-toggle-bar:nth-child(1) { top: 14px; }
.nav-toggle-bar:nth-child(2) { top: 21px; }
.nav-toggle-bar:nth-child(3) { top: 28px; }
.nav.is-open .nav-toggle-bar:nth-child(1) { top: 21px; transform: rotate(45deg); }
.nav.is-open .nav-toggle-bar:nth-child(2) { opacity: 0; }
.nav.is-open .nav-toggle-bar:nth-child(3) { top: 21px; transform: rotate(-45deg); }

.nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.36);
  z-index: 95;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s var(--ease-out);
}

/* Hide the drawer icons on desktop so the inline nav reads exactly as before. */
.nav-ic { display: none; }

@media (max-width: 920px) {
  /* `backdrop-filter` on `.nav` creates a containing block for `position:
     fixed` descendants, which clips the drawer to the nav's own height.
     Drop the blur on mobile and fall back to a near-solid bar; the drawer
     can then be properly viewport-anchored. */
  .nav {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(255, 255, 255, 0.97);
  }
  .nav-toggle { display: block; }

  .nav-links {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(88vw, 360px);
    padding: 5.25rem 1.5rem 2rem;
    margin: 0;
    background: var(--bg, #ffffff);
    border-left: 1px solid var(--border);
    box-shadow: -16px 0 40px -16px rgba(15, 23, 42, 0.18);
    flex-direction: column;
    align-items: stretch;
    gap: 0.25rem;
    font-size: 1rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    transform: translateX(100%);
    transition: transform 0.32s var(--ease-out);
    z-index: 100;
  }
  .nav-links li { width: 100%; }
  .nav-links > li > a,
  .nav-dropdown-label {
    display: block;
    padding: 0.85rem 0.5rem;
    border-radius: 8px;
  }
  .nav-links a::after { display: none; }
  .nav-links a:hover,
  .nav-links a.active {
    background: color-mix(in srgb, var(--berkeley-blue) 8%, transparent);
  }
  .nav-dropdown-menu {
    padding: 0.25rem 0 0.5rem 1rem !important;
    gap: 0;
  }
  .nav-dropdown-menu a {
    padding: 0.6rem 0.5rem;
    font-size: 0.95rem;
  }

  /* Line icons sit on the left of each drawer entry; on desktop they
     stay hidden so the inline bar reads identically to before. */
  .nav-ic {
    display: inline-block;
    vertical-align: -0.2em;
    width: 1.05em;
    height: 1.05em;
    margin-right: 0.7rem;
    color: var(--berkeley-gold-dark);
    flex-shrink: 0;
  }
  .nav-links > li > a,
  .nav-dropdown-label {
    display: inline-flex;
    align-items: center;
  }
  .nav-dropdown-menu a {
    display: inline-flex;
    align-items: center;
  }
  .nav-dropdown-menu .nav-ic {
    color: var(--text-muted);
    width: 0.95em;
    height: 0.95em;
  }
  /* Active link: icon adopts the Berkeley blue accent too. */
  .nav-links a.active .nav-ic {
    color: var(--berkeley-blue);
  }

  .nav-backdrop { display: block; }
  .nav.is-open .nav-links { transform: translateX(0); }
  .nav.is-open .nav-backdrop { opacity: 1; pointer-events: auto; }

  /* Body scroll lock while the drawer is open. */
  body.nav-locked { overflow: hidden; }
}

/* =============================================================
   Hero
============================================================= */
.hero {
  min-height: 100vh;
  display: flex;
  /* Anchor content at the top with enough padding to clear the fixed nav.
     `safe center` previously let the title drift up behind the nav on shorter
     viewports; flex-start with a hard padding-top guarantees clearance. */
  align-items: flex-start;
  position: relative;
  overflow: hidden;
  padding-top: 8rem;
  padding-bottom: 4rem;
}
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(at 80% 20%, rgba(47, 67, 196, 0.08) 0%, transparent 50%),
    radial-gradient(at 10% 80%, rgba(47, 67, 196, 0.05) 0%, transparent 60%);
  pointer-events: none;
}
.hero-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 4rem;
  align-items: center;
}
@media (max-width: 980px) {
  .hero-grid { grid-template-columns: 1fr; }
}
.hero-text { max-width: 620px; }
.hero h1 { margin-bottom: 1.25rem; }
.hero h1 .accent {
  background: linear-gradient(110deg, var(--berkeley-blue) 0%, var(--berkeley-gold-dark) 80%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.hero .lead { margin-bottom: 2.25rem; }
.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 2.5rem;
}

/* =============================================================
   Hero animated ball-on-plate
============================================================= */
.scene {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  max-width: 480px;
  margin: 0 auto;
  perspective: 800px;
}
.scene-frame {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-style: preserve-3d;
  animation: tilt 9s ease-in-out infinite;
}
.plate {
  width: 78%;
  height: 78%;
  background: linear-gradient(145deg, #f3e2c2, #e6c98a);
  border-radius: 16px;
  position: relative;
  transform-style: preserve-3d;
  box-shadow:
    0 24px 64px rgba(22, 24, 29, 0.20),
    inset 0 -2px 6px rgba(180, 130, 50, 0.5),
    inset 0 2px 6px rgba(255, 250, 230, 0.55);
}
.plate::before, .plate::after {
  content: '';
  position: absolute;
  width: 8%; height: 8%;
  background: var(--bg-dark);
  border-radius: 4px;
  opacity: 0.85;
}
.plate::before { top: 6%; left: 6%; }
.plate::after { bottom: 6%; right: 6%; }
.plate-marker-tr, .plate-marker-bl {
  position: absolute;
  width: 8%; height: 8%;
  background: var(--bg-dark);
  border-radius: 4px;
  opacity: 0.85;
}
.plate-marker-tr { top: 6%; right: 6%; }
.plate-marker-bl { bottom: 6%; left: 6%; }

.ball {
  position: absolute;
  top: 50%; left: 50%;
  width: 14%; height: 14%;
  background: radial-gradient(circle at 30% 25%, #f25a6a 0%, #b41e28 60%, #6b0f15 100%);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow:
    0 6px 14px rgba(180, 30, 40, 0.35),
    inset -2px -3px 6px rgba(0, 0, 0, 0.25);
  animation: orbit 9s ease-in-out infinite;
  z-index: 5;
}
@keyframes tilt {
  0%, 100% { transform: rotateX(8deg) rotateY(-12deg) rotateZ(-2deg); }
  25%      { transform: rotateX(-10deg) rotateY(8deg)  rotateZ(3deg); }
  50%      { transform: rotateX(6deg)  rotateY(14deg)  rotateZ(-4deg); }
  75%      { transform: rotateX(-6deg) rotateY(-8deg)  rotateZ(2deg); }
}
@keyframes orbit {
  0%, 100% { transform: translate(-30%, -65%); }
  25%      { transform: translate(-65%, -30%); }
  50%      { transform: translate(-50%, -10%); }
  75%      { transform: translate(-20%, -45%); }
}

/* Reference trajectory ring underneath */
.scene-ring {
  position: absolute;
  inset: 16%;
  border: 2px dashed rgba(47, 67, 196, 0.25);
  border-radius: 50%;
  animation: spin 30s linear infinite;
  pointer-events: none;
}
@keyframes spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }

/* =============================================================
   Buttons
============================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.875rem 1.625rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.25s var(--ease-spring);
  font-family: var(--font-sans);
}
.btn-primary {
  background: var(--berkeley-blue);
  color: white;
}
.btn-primary:hover {
  background: color-mix(in srgb, var(--berkeley-blue) 88%, #000);
  color: white;
}
.btn-ghost {
  background: transparent;
  color: var(--berkeley-blue);
  border-color: var(--border);
}
.btn-ghost:hover {
  border-color: var(--berkeley-blue);
  background: var(--berkeley-blue);
  color: white;
}
.btn .arrow {
  transition: transform 0.25s var(--ease-out);
}
.btn:hover .arrow { transform: translateX(4px); }

/* =============================================================
   Cards
============================================================= */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--pad-md);
  transition: transform 0.4s var(--ease-out), box-shadow 0.4s var(--ease-out), border-color 0.4s;
  position: relative;
  overflow: hidden;
}
.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--berkeley-gold), var(--berkeley-blue));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.5s var(--ease-out);
}
.card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-md);
  border-color: var(--berkeley-gold);
}
.card:hover::before { transform: scaleX(1); }
.card-num {
  font-family: var(--font-display);
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--berkeley-gold-dark);
  line-height: 1;
  margin-bottom: 1rem;
}
.card h3 { margin-bottom: 0.6rem; font-size: 1.25rem; }
.card p { color: var(--text-soft); font-size: 0.9375rem; line-height: 1.55; margin-bottom: 1rem; }
.card-link {
  font-size: 0.875rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--berkeley-blue);
}
.card-link .arrow { transition: transform 0.25s var(--ease-out); }
.card:hover .card-link .arrow { transform: translateX(4px); }

/* =============================================================
   Tags / pills
============================================================= */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.85rem;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.8rem;
  color: var(--text-soft);
  font-weight: 500;
  transition: all 0.2s;
}
.tag:hover {
  background: var(--berkeley-gold);
  border-color: var(--berkeley-gold);
  color: #fff;
}
.tag .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--berkeley-gold);
}

/* =============================================================
   Section headers
============================================================= */
.section-head {
  max-width: 720px;
  margin-bottom: var(--pad-lg);
}
.section-head h2 { margin-bottom: 1rem; }
.section-head .lead { font-size: 1.125rem; }

/* =============================================================
   Stats / metrics
============================================================= */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 2.5rem;
  margin: var(--pad-md) 0;
}
.stat-num {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 5vw, 3.75rem);
  font-weight: 700;
  color: var(--berkeley-blue);
  line-height: 1;
  letter-spacing: -0.025em;
}
.stat-label {
  margin-top: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-soft);
  font-weight: 500;
}
.stat-num .unit {
  font-size: 0.55em;
  color: var(--berkeley-gold-dark);
  margin-left: 0.15em;
  font-weight: 500;
}

/* =============================================================
   Footer
============================================================= */
footer {
  border-top: 1px solid var(--border);
  padding: var(--pad-md) 0;
  margin-top: var(--pad-xl);
  background: var(--bg-soft);
}
footer .footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--pad-md);
  flex-wrap: wrap;
  font-size: 0.875rem;
  color: var(--text-soft);
}
footer a { color: var(--text-soft); }
footer a:hover { color: var(--berkeley-blue); }

/* =============================================================
   Reveal-on-scroll utility
============================================================= */
.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition:
    opacity 0.8s var(--ease-out),
    transform 0.8s var(--ease-out);
}
.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}
.reveal-delay-1 { transition-delay: 0.08s; }
.reveal-delay-2 { transition-delay: 0.16s; }
.reveal-delay-3 { transition-delay: 0.24s; }
.reveal-delay-4 { transition-delay: 0.32s; }

/* =============================================================
   Page-level (used on subpages)
============================================================= */
.page-hero {
  /* Hero starts at top of page; the nav (position: fixed) floats above it.
     padding-top must be ≥ nav height to keep the title clear of the nav.
     Background matches the body so the translucent nav blends seamlessly. */
  padding: 8rem 0 4rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.page-hero .eyebrow { color: var(--berkeley-gold-dark); }
.page-hero h1 { font-size: clamp(2.5rem, 4.5vw, 3.75rem); margin-bottom: 1rem; }
.page-hero .lead { max-width: 720px; }

.prose { max-width: 760px; }
.prose p { margin-bottom: 1.25rem; color: var(--text-soft); font-size: 1.0625rem; }
.prose h2 { margin: 3rem 0 1rem; }
.prose h3 { margin: 2rem 0 0.75rem; color: var(--berkeley-blue); }
.prose ul, .prose ol { margin: 1rem 0 1.5rem 1.25rem; }
.prose li { margin-bottom: 0.5rem; color: var(--text-soft); }
.prose strong { color: var(--berkeley-blue); font-weight: 600; }
.prose img { border-radius: var(--radius-md); margin: 2rem 0; box-shadow: var(--shadow-sm); }
.prose figure { margin: 2rem 0; }
.prose figcaption { font-size: 0.875rem; color: var(--text-muted); text-align: center; margin-top: 0.6rem; font-style: italic; }

.callout {
  border-left: 3px solid var(--berkeley-gold);
  background: linear-gradient(90deg, rgba(47, 67, 196, 0.08), transparent);
  padding: 1.25rem 1.5rem;
  margin: 2rem 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.callout p { margin-bottom: 0; color: var(--text); }

/* =============================================================
   PDF embed
============================================================= */
.pdf-embed {
  width: 100%;
  height: 600px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin: 2rem 0;
  background: var(--bg-soft);
}

/* =============================================================
   Code blocks with syntax tone
============================================================= */
.kw   { color: #f78c6c; }
.str  { color: #c3e88d; }
.num  { color: #f78c6c; }
.com  { color: #546e7a; font-style: italic; }
.fn   { color: #82aaff; }

/* =============================================================
   v2 — Block components for schematic layouts
============================================================= */

/* --- Step flow (horizontal numbered blocks with arrows) --- */
.step-flow {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin: 2.5rem 0;
}
.step {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.5rem 1.25rem 1.25rem;
  position: relative;
  transition: transform 0.3s var(--ease-out), border-color 0.3s, box-shadow 0.3s;
}
.step:hover {
  transform: translateY(-3px);
  border-color: var(--berkeley-gold);
  box-shadow: var(--shadow-sm);
}
.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  background: var(--berkeley-blue);
  color: white;
  border-radius: 50%;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 0.85rem;
}
.step h4 {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: -0.01em;
  margin-bottom: 0.4rem;
  color: var(--berkeley-blue);
}
.step .formula {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  background: var(--bg-soft);
  color: var(--berkeley-blue);
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-sm);
  margin: 0.6rem 0;
  border-left: 3px solid var(--berkeley-gold);
}
.step p {
  font-size: 0.85rem;
  color: var(--text-soft);
  line-height: 1.5;
  margin: 0;
}

/* --- Equation tile --- */
.eq-tile {
  background: var(--bg-dark);
  color: #c8d6e5;
  border-radius: var(--radius-md);
  padding: 1.4rem 1.6rem;
  font-family: var(--font-mono);
  font-size: 1rem;
  margin: 1.5rem 0;
  position: relative;
  overflow-x: auto;
  border-top: 3px solid var(--berkeley-gold);
}
.eq-tile .label {
  position: absolute;
  top: 0.6rem; right: 0.85rem;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(47, 67, 196, 0.85);
}

/* --- Key-value list (definition) --- */
.kv {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.85rem;
  margin: 1.5rem 0;
  padding: 0;
  list-style: none;
}
.kv li {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  font-size: 0.875rem;
}
.kv .k {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--berkeley-gold-dark);
  margin-bottom: 0.3rem;
  font-weight: 600;
}
.kv .v {
  color: var(--text);
  font-weight: 500;
}

/* --- Big pill: green plus / red minus --- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.6rem 1rem;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 500;
  margin: 0.25rem;
  border: 1px solid;
}
.pill.plus  { background: rgba(40,140,90,0.10);  border-color: rgba(40,140,90,0.30);  color: var(--accent-green); }
.pill.minus { background: rgba(180,30,40,0.10);  border-color: rgba(180,30,40,0.30);  color: var(--accent-red); }
.pill .badge {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.95rem;
  width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: currentColor;
  color: white;
}

/* --- Node-graph mini (CSS only) --- */
.graph {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem;
  align-items: center;
  margin: 1.5rem 0 0.5rem;
}
.graph .node {
  background: var(--surface);
  border: 1.5px solid var(--berkeley-blue);
  border-radius: var(--radius-md);
  padding: 0.85rem 0.5rem;
  text-align: center;
  font-size: 0.78rem;
  font-family: var(--font-mono);
  color: var(--berkeley-blue);
  box-shadow: var(--shadow-sm);
}
.graph .node.vision { border-color: var(--berkeley-gold-dark); color: var(--berkeley-gold-dark); background: rgba(47, 67, 196,0.06); }
.graph .node.firmware { border-color: var(--text-muted); color: var(--text-soft); background: var(--bg-soft); }
.graph .arrow {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--berkeley-blue);
  position: relative;
}
.graph .arrow::before {
  content: '';
  display: block;
  height: 2px;
  background: linear-gradient(90deg, var(--berkeley-blue), var(--berkeley-gold));
  margin-bottom: 0.35rem;
  border-radius: 1px;
  animation: dataflow 2s linear infinite;
}
.graph .topic {
  display: block;
  background: var(--bg-soft);
  border: 1px dashed var(--border);
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  margin-top: 0.2rem;
  font-size: 0.65rem;
  color: var(--text-muted);
}
@keyframes dataflow {
  0%   { background-position: 0% 50%; }
  100% { background-position: 100% 50%; }
}

/* --- Spec strip (4 quick facts) --- */
.spec-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin: 1.5rem 0;
  background: var(--surface);
}
.spec-strip > div {
  padding: 1.25rem;
  border-right: 1px solid var(--border);
}
.spec-strip > div:last-child { border-right: none; }
.spec-strip .num {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--berkeley-blue);
  letter-spacing: -0.01em;
}
.spec-strip .num .unit { font-size: 0.65em; color: var(--berkeley-gold-dark); margin-left: 0.15em; font-weight: 500; }
.spec-strip .lab { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.25rem; }

/* --- Section heading minimal --- */
.h-tight { margin-top: 3rem; margin-bottom: 1rem; }
.h-tight + p { color: var(--text-soft); font-size: 0.95rem; max-width: 580px; }

/* --- Color hints inside text --- */
.hl-blue { color: var(--berkeley-blue); font-weight: 600; }
.hl-gold { color: var(--berkeley-gold-dark); font-weight: 600; }
.hl-green { color: var(--accent-green); font-weight: 600; }
.hl-red { color: var(--accent-red); font-weight: 600; }
.hl-violet { color: var(--accent-violet); font-weight: 600; }

/* =============================================================
   v3 — KaTeX equation tiles & colored term highlights
============================================================= */
.math-block {
  background: linear-gradient(135deg, #fefdf9 0%, #fbf6e8 100%);
  border: 1px solid var(--border);
  border-left: 4px solid var(--berkeley-gold);
  border-radius: var(--radius-md);
  padding: 1.5rem 1.75rem;
  margin: 1.5rem 0;
  font-size: 1.05rem;
  text-align: center;
  position: relative;
  box-shadow: var(--shadow-sm);
  /* Long display equations exceed the column on phones. Let them scroll
     horizontally inside the tile rather than blowing out the layout. */
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.math-block .katex-display > .katex {
  /* Don't let KaTeX force the whole tile to its natural width — keep the
     scroll boundary on .math-block instead. */
  max-width: 100%;
}
.math-block .label {
  position: absolute;
  top: 0.5rem; right: 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--berkeley-gold-dark);
  font-weight: 600;
}
.math-block .katex-display {
  margin: 0.5rem 0;
}

/* Colored PID terms — match slide deck */
.term-p { color: #288c5a; }
.term-i { color: #2f43c4; }
.term-d { color: #b41e28; }
.term-blue { color: var(--berkeley-blue); }
.term-gold { color: var(--berkeley-gold-dark); }

/* Inline equation chip */
.eq-chip {
  display: inline-flex;
  align-items: center;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.65rem;
  font-size: 0.95rem;
  margin: 0.15rem 0.2rem;
}

/* Big highlighted result */
.result-box {
  background: linear-gradient(135deg, var(--berkeley-blue), #1a4880);
  color: white;
  border-radius: var(--radius-md);
  padding: 1.5rem 2rem;
  text-align: center;
  margin: 2rem 0;
  font-size: 1.2rem;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}
.result-box::before {
  content: '';
  position: absolute;
  top: -50%; right: -10%;
  width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(47, 67, 196,0.15) 0%, transparent 60%);
  pointer-events: none;
}
.result-box .label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  opacity: 0.7;
  margin-bottom: 0.6rem;
  display: block;
}
.result-box .katex-display { margin: 0; }
.result-box .katex-display .katex { color: white; }

/* Inline plate-ball schematic SVG sizing */
.svg-schema {
  width: 100%;
  max-width: 480px;
  margin: 2rem auto;
  display: block;
}

/* Step now supports KaTeX */
.step .formula .katex {
  font-size: 0.85rem !important;
}

/* =============================================================
   v4 — Storyline scroll: progress bar, side-reveal, custom SVG
============================================================= */

/* --- Top progress bar --- */
.scroll-progress {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--berkeley-blue), var(--berkeley-gold));
  z-index: 200;
  transition: width 0.05s linear;
}

/* --- Reveal from sides ---
   On mobile/tablet the 40 px translate pushes the hidden element past
   the viewport edge, briefly causing horizontal scroll measurements.
   Cut the distance on small screens; the entrance still reads. */
.reveal-l {
  opacity: 0;
  transform: translateX(-40px);
  transition: opacity 0.9s var(--ease-out), transform 0.9s var(--ease-out);
}
.reveal-l.is-visible { opacity: 1; transform: translateX(0); }

.reveal-r {
  opacity: 0;
  transform: translateX(40px);
  transition: opacity 0.9s var(--ease-out), transform 0.9s var(--ease-out);
}
.reveal-r.is-visible { opacity: 1; transform: translateX(0); }

@media (max-width: 920px) {
  .reveal-l { transform: translateX(-12px); }
  .reveal-r { transform: translateX(12px); }
}

.reveal-scale {
  opacity: 0;
  transform: scale(0.92);
  transition: opacity 0.9s var(--ease-out), transform 0.9s var(--ease-spring);
}
.reveal-scale.is-visible { opacity: 1; transform: scale(1); }

/* --- Staggered children reveal --- */
.stagger > * {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s var(--ease-out), transform 0.7s var(--ease-out);
}
.stagger.is-visible > *:nth-child(1) { transition-delay: 0.05s; opacity: 1; transform: translateY(0); }
.stagger.is-visible > *:nth-child(2) { transition-delay: 0.15s; opacity: 1; transform: translateY(0); }
.stagger.is-visible > *:nth-child(3) { transition-delay: 0.25s; opacity: 1; transform: translateY(0); }
.stagger.is-visible > *:nth-child(4) { transition-delay: 0.35s; opacity: 1; transform: translateY(0); }
.stagger.is-visible > *:nth-child(5) { transition-delay: 0.45s; opacity: 1; transform: translateY(0); }
.stagger.is-visible > *:nth-child(6) { transition-delay: 0.55s; opacity: 1; transform: translateY(0); }

/* --- Story section --- */
.story-section {
  padding: 7rem 0;
  position: relative;
}
.story-section + .story-section { border-top: 1px solid var(--border); }
.story-section.alt { background: var(--bg-soft); }

/* Physics page: the derivation is split into many short steps, so each story
   section runs much tighter than the airy ones on the home. */
body.physics-page .story-section { padding: 3.25rem 0; }

.story-grid {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: 5rem;
  align-items: center;
}
@media (max-width: 980px) { .story-grid { grid-template-columns: 1fr; gap: 3rem; } }
.story-grid.flip { direction: rtl; }
.story-grid.flip > * { direction: ltr; }

.story-text h2 { margin-bottom: 1.25rem; font-size: clamp(1.875rem, 3vw, 2.5rem); }
.story-text .lead { font-size: 1.0625rem; margin-bottom: 1.75rem; }

/* --- Custom SVG diagrams (inline) --- */
.diagram {
  width: 100%;
  max-width: 540px;
  margin: 0 auto;
  display: block;
}
.diagram .anim-draw {
  stroke-dasharray: 600;
  stroke-dashoffset: 600;
  transition: stroke-dashoffset 1.4s var(--ease-out);
}
.is-visible .anim-draw { stroke-dashoffset: 0; }

/* --- Pipeline horizontal flow with animated arrows --- */
.pipeline {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  align-items: center;
  margin: 2rem 0;
}
.pipeline .pblock {
  background: var(--surface);
  border: 1.5px solid var(--berkeley-blue);
  border-radius: var(--radius-md);
  padding: 1.1rem 0.6rem;
  text-align: center;
  position: relative;
  transition: transform 0.4s var(--ease-spring), box-shadow 0.4s, background 0.4s;
  box-shadow: var(--shadow-sm);
}
.pipeline .pblock:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  background: linear-gradient(135deg, #ffffff, #fef9ed);
}
.pipeline .pblock .pnum {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--berkeley-gold-dark);
  letter-spacing: 0.12em;
  font-weight: 600;
  margin-bottom: 0.4rem;
}
.pipeline .pblock h4 {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  margin-bottom: 0.3rem;
  color: var(--berkeley-blue);
}
.pipeline .pblock .pf {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-soft);
}
.pipeline .pconn {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  position: relative;
}
.pipeline .pconn svg { width: 100%; height: 24px; }

/* --- PID law big colored equation --- */
.pid-eq {
  background: linear-gradient(135deg, #fcfaf2, #fef3da);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem 1.5rem;
  text-align: center;
  margin: 2rem 0;
  font-size: 1.5rem;
  font-family: var(--font-mono);
  position: relative;
  box-shadow: var(--shadow-sm);
}
.pid-eq .lhs { color: var(--berkeley-blue); }
.pid-eq .term { padding: 0.2em 0.5em; border-radius: 6px; margin: 0 0.15em; display: inline-block; transition: transform 0.3s var(--ease-spring); }
.pid-eq:hover .term-pp { transform: translateY(-3px); }
.pid-eq .term-pp { background: rgba(40,140,90,0.15);  color: #287a4a; }
.pid-eq .term-ii { background: rgba(196,130,14,0.15); color: #8d5e0a; }
.pid-eq .term-dd { background: rgba(180,30,40,0.15); color: #8e1a23; }

/* --- Plate + ball mini schematic for "wiring" section --- */
.plate-svg {
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
}

/* --- Big number / claim --- */
.claim {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--berkeley-blue);
  max-width: 720px;
}
.claim em {
  font-style: normal;
  background: linear-gradient(110deg, var(--berkeley-gold-dark), var(--berkeley-gold));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

/* --- Comparison split (PID vs Residual) --- */
.compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 2rem 0;
}
@media (max-width: 720px) { .compare { grid-template-columns: 1fr; } }
.compare .col {
  border-radius: var(--radius-md);
  padding: 1.5rem 1.25rem;
  text-align: center;
}
.compare .col.pid {
  background: linear-gradient(135deg, #fef3da, #fbe5b4);
  border: 1px solid rgba(196,130,14,0.3);
}
.compare .col.res {
  background: linear-gradient(135deg, #e0ecf5, #c8def0);
  border: 1px solid rgba(47, 67, 196,0.3);
}
.compare .col h4 {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 0.6rem;
}
.compare .col.pid h4 { color: var(--berkeley-gold-dark); }
.compare .col.res h4 { color: var(--berkeley-blue); }
.compare .col .val {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}
.compare .col.pid .val { color: var(--berkeley-gold-dark); }
.compare .col.res .val { color: var(--berkeley-blue); }
.compare .col .lab {
  font-size: 0.8rem;
  color: var(--text-soft);
  margin-top: 0.2rem;
}

/* =============================================================
   v5 — Better pipeline flow
============================================================= */
.flow-chain {
  display: flex;
  align-items: stretch;
  justify-content: center;
  flex-wrap: nowrap;
  gap: 0;
  margin: 3rem 0 1rem;
}
@media (max-width: 980px) {
  .flow-chain { flex-direction: column; align-items: center; }
}

.fc-step {
  flex: 1 1 0;
  min-width: 0;
  background: linear-gradient(180deg, var(--surface), #fdfbf6);
  border: 1.5px solid var(--berkeley-blue);
  border-radius: var(--radius-md);
  padding: 1.25rem 0.85rem;
  text-align: center;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.35s var(--ease-spring), box-shadow 0.35s, border-color 0.35s;
  box-shadow: var(--shadow-sm);
}
.fc-step:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-md);
  border-color: var(--berkeley-gold);
}
.fc-step.fc-final {
  background: linear-gradient(180deg, #fef9ed, #fdf2d4);
  border-color: var(--berkeley-gold-dark);
}

.fc-step .fc-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--berkeley-blue);
  color: white;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 0.65rem;
}
.fc-step.fc-final .fc-num { background: var(--berkeley-gold-dark); }

.fc-step h4 {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--berkeley-blue);
  margin-bottom: 0.4rem;
}
.fc-step .fc-formula {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  background: var(--bg-soft);
  border-left: 3px solid var(--berkeley-gold);
  padding: 0.5rem 0.6rem;
  margin: 0.5rem 0;
  border-radius: 4px;
  color: var(--berkeley-blue);
  text-align: left;
}
.fc-step .fc-formula .katex { font-size: 0.85rem !important; }
.fc-step .fc-desc {
  font-size: 0.78rem;
  color: var(--text-soft);
  line-height: 1.45;
  margin-top: 0.3rem;
}

/* connector */
.fc-arrow {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  position: relative;
}
@media (max-width: 980px) {
  .fc-arrow { width: auto; height: 60px; transform: rotate(90deg); }
}
.fc-arrow svg { width: 100%; height: 30px; overflow: visible; }
.fc-arrow .signal {
  position: absolute;
  top: -16px; left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--berkeley-gold-dark);
  white-space: nowrap;
  background: var(--bg);
  padding: 0 0.25rem;
}
.fc-arrow .signal .katex { font-size: 0.78rem !important; color: var(--berkeley-gold-dark); }

/* I/O strip above pipeline */
.fc-io {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 0.4rem;
  gap: 1rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.fc-io .a { color: var(--berkeley-blue); }
.fc-io .b { color: var(--berkeley-gold-dark); }

/* =============================================================
   v6 — Pillar cards with icons
============================================================= */
.pillar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
  margin: 0;
}
.pillar {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem 1.75rem 1.75rem;
  overflow: hidden;
  transition: transform 0.45s var(--ease-spring), box-shadow 0.45s, border-color 0.45s;
}
.pillar::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
  padding: 2px;
  background: linear-gradient(135deg, transparent 30%, var(--berkeley-gold) 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.45s var(--ease-out);
  pointer-events: none;
}
.pillar:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-lg);
  border-color: transparent;
}
.pillar:hover::before { opacity: 1; }

.pillar-num {
  position: absolute;
  top: 1.2rem;
  right: 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  color: var(--berkeley-gold-dark);
  font-weight: 700;
  background: var(--bg-soft);
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
}

.pillar-icon {
  width: 56px; height: 56px;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #fef9ed, #fcedca);
  border-radius: 14px;
  transition: transform 0.5s var(--ease-spring), background 0.4s;
}
.pillar:hover .pillar-icon {
  transform: rotate(-6deg) scale(1.08);
  background: linear-gradient(135deg, #fcedca, #f5d77a);
}
.pillar-icon svg {
  width: 32px; height: 32px;
  color: var(--berkeley-blue);
  transition: color 0.4s;
}
.pillar:hover .pillar-icon svg { color: var(--berkeley-gold-dark); }

.pillar h3 {
  font-size: 1.4rem;
  margin-bottom: 0.5rem;
}
.pillar > p {
  color: var(--text-soft);
  font-size: 0.95rem;
  line-height: 1.55;
  margin-bottom: 1.25rem;
}

.pillar-features {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--border);
}
.pillar-features li {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.85rem;
  color: var(--text-soft);
  transition: transform 0.3s var(--ease-out);
}
.pillar:hover .pillar-features li { transform: translateX(3px); }
.pillar-features li:hover { color: var(--berkeley-blue); }
.pillar-features .ic {
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-soft);
  border-radius: 6px;
  color: var(--berkeley-gold-dark);
  flex-shrink: 0;
}
.pillar-features .ic svg { width: 13px; height: 13px; }

.pillar-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 1.25rem;
  padding: 0.4rem 0.85rem;
  background: linear-gradient(135deg, rgba(47, 67, 196,0.06), rgba(47, 67, 196,0.10));
  border: 1px solid rgba(47, 67, 196,0.12);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--berkeley-blue);
  font-weight: 500;
}
.pillar-tag .katex { font-size: 0.85rem !important; }

/* =============================================================
   v7 — Vertical stepped pipeline with transitions
============================================================= */
.vstep-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-width: 880px;
  margin: 0 auto;
}
.vstep {
  background: var(--surface);
  border: 1.5px solid var(--berkeley-blue);
  border-radius: var(--radius-md);
  padding: 1.5rem 1.75rem 1.6rem;
  position: relative;
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 1.2rem;
  align-items: start;
  box-shadow: var(--shadow-sm);
  transition: transform 0.4s var(--ease-out), box-shadow 0.4s, border-color 0.4s;
}
.vstep:hover {
  transform: translateY(-3px);
  border-color: var(--berkeley-gold);
  box-shadow: var(--shadow-md);
}
.vstep.final {
  border-color: var(--berkeley-gold-dark);
  background: linear-gradient(145deg, #fffaee, #fef3da);
}

.vstep .vnum {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--berkeley-blue);
  line-height: 1;
  letter-spacing: -0.03em;
  text-align: center;
  background: var(--bg-soft);
  border-radius: 12px;
  padding: 0.7rem 0;
}
.vstep.final .vnum { color: var(--berkeley-gold-dark); background: #fff5d8; }

.vstep h4 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: var(--berkeley-blue);
  letter-spacing: -0.01em;
}
.vstep .vmath {
  background: var(--bg-soft);
  border-left: 3px solid var(--berkeley-gold);
  padding: 0.65rem 0.9rem;
  margin: 0.6rem 0;
  border-radius: 4px;
  font-size: 1rem;
  overflow-x: auto;
}
.vstep .vdesc {
  color: var(--text-soft);
  font-size: 0.95rem;
  line-height: 1.55;
}

/* transition between steps */
.vstep-transition {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 1.2rem;
  align-items: center;
  padding: 0.4rem 1.75rem;
  margin: 0.4rem 0;
}
.vstep-transition .arr {
  display: flex;
  justify-content: center;
}
.vstep-transition .arr svg {
  width: 26px; height: 26px;
}
.vstep-transition .note {
  color: var(--text-muted);
  font-size: 0.875rem;
  font-style: italic;
  line-height: 1.5;
}
.vstep-transition .note .sig {
  font-style: normal;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  background: linear-gradient(90deg, rgba(47, 67, 196,0.08), rgba(47, 67, 196,0.10));
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  color: var(--berkeley-blue);
  margin: 0 0.2rem;
}

/* =============================================================
   v8 — paper-style typography helpers
============================================================= */
.abstract {
  background: var(--bg-soft);
  border-left: 3px solid var(--berkeley-gold);
  padding: 1.25rem 1.5rem;
  margin: 1.5rem 0 2.5rem;
  font-size: 1.0625rem;
  line-height: 1.7;
  color: var(--text);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.abstract::before {
  content: "Abstract.";
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--berkeley-blue);
  margin-right: 0.4em;
  letter-spacing: -0.01em;
}
.section-h {
  margin-top: 3rem;
  margin-bottom: 0.5rem;
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--berkeley-blue);
  letter-spacing: -0.015em;
}
.section-num {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  color: var(--berkeley-gold-dark);
  font-weight: 600;
  margin-right: 0.6em;
}
.body-prose p {
  color: var(--text);
  font-size: 1rem;
  line-height: 1.7;
  margin-bottom: 1.1rem;
  max-width: 760px;
}
.fig {
  margin: 2rem 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}
.fig figcaption {
  margin-top: 0.85rem;
  font-size: 0.85rem;
  color: var(--text-soft);
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  text-align: center;
}
.fig .fig-num {
  font-style: normal;
  font-family: var(--font-sans);
  font-weight: 600;
  color: var(--berkeley-blue);
  margin-right: 0.4em;
  font-size: 0.85rem;
}
.notation-list {
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 1.5rem;
  row-gap: 0.6rem;
  margin: 1.25rem 0 2rem;
  padding: 1rem 1.25rem;
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
}
.notation-list dt {
  font-family: var(--font-mono);
  color: var(--berkeley-blue);
  font-weight: 500;
}
.notation-list dd { color: var(--text-soft); margin: 0; }

/* On narrow phones a `max-content` term column can be wider than the
   viewport (e.g. `R_{WP}(q) v^P`), pushing the value column off-screen.
   Stack term over value below 540 px instead. */
@media (max-width: 540px) {
  .notation-list {
    grid-template-columns: 1fr;
    row-gap: 0.25rem;
    padding: 1rem;
  }
  .notation-list dt { margin-top: 0.4rem; }
  .notation-list dt:first-of-type { margin-top: 0; }
}

/* =============================================================
   v9 — mini-cards for input/frame breakdown
============================================================= */
.minicard-stack {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.minicard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.95rem 1.1rem;
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 0.85rem;
  align-items: start;
  transition: transform 0.3s var(--ease-spring), box-shadow 0.3s, border-color 0.3s;
  position: relative;
  overflow: hidden;
}
.minicard::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--berkeley-gold);
  transform: scaleY(0);
  transform-origin: top;
  transition: transform 0.4s var(--ease-out);
}
.minicard:hover {
  transform: translateX(2px);
  box-shadow: var(--shadow-sm);
  border-color: var(--berkeley-gold);
}
.minicard:hover::before { transform: scaleY(1); }

.minicard .mc-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: 8px;
  background: linear-gradient(135deg, #fef9ed, #fcedca);
  color: var(--berkeley-blue);
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.92rem;
}
.minicard .mc-badge svg { width: 18px; height: 18px; color: var(--berkeley-blue); }
.minicard h4 {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.98rem;
  color: var(--berkeley-blue);
  margin-bottom: 0.25rem;
  letter-spacing: -0.005em;
}
.minicard p {
  color: var(--text-soft);
  font-size: 0.86rem;
  line-height: 1.5;
  margin: 0;
}
.minicard .mc-formula {
  display: inline-block;
  margin-top: 0.45rem;
  padding: 0.18rem 0.55rem;
  background: var(--bg-soft);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--berkeley-blue);
}
.minicard .mc-formula .katex { font-size: 0.85rem !important; }

/* =============================================================
   v10 — hero deck (2x2 mini-cards in hero abstract)
============================================================= */
.hero-deck {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.85rem;
  margin: 1.5rem 0 2.25rem;
}
@media (max-width: 540px) { .hero-deck { grid-template-columns: 1fr; } }

.hd-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.1rem 1rem 1.1rem;
  position: relative;
  overflow: hidden;
  transition: transform 0.4s var(--ease-spring), box-shadow 0.4s, border-color 0.4s;
  cursor: pointer;
  display: block;
  color: inherit;
  text-decoration: none;
}
.hd-card:hover { color: inherit; }
.hd-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--berkeley-gold), var(--berkeley-blue));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.5s var(--ease-out);
}
.hd-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--berkeley-gold);
}
.hd-card:hover::before { transform: scaleX(1); }

.hd-card .hd-head {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.5rem;
}
.hd-card .hd-icon {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #fef9ed, #fcedca);
  border-radius: 7px;
  color: var(--berkeley-blue);
  flex-shrink: 0;
  transition: transform 0.4s var(--ease-spring);
}
.hd-card:hover .hd-icon { transform: rotate(-8deg) scale(1.1); }
.hd-card .hd-icon svg { width: 16px; height: 16px; }
.hd-card .hd-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  color: var(--berkeley-gold-dark);
  text-transform: uppercase;
  font-weight: 600;
}
.hd-card .hd-text {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text);
  margin: 0;
}

/* === Controller variants (3-column grid inside Step 1 of the home pipeline) === */
.ctrl-variants {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.85rem;
  margin-top: 0.9rem;
}
@media (max-width: 920px) {
  .ctrl-variants { grid-template-columns: 1fr; }
}
.ctrl-card {
  background: #fdfcf8;
  border: 1px solid rgba(0,0,0,0.07);
  border-radius: 10px;
  padding: 0.85rem 0.95rem;
  position: relative;
  transition: transform 0.35s var(--ease-out), box-shadow 0.35s var(--ease-out), border-color 0.35s var(--ease-out);
  overflow: hidden;
}
.ctrl-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.5s var(--ease-out);
}
.ctrl-card.pid::before { background: var(--berkeley-blue); }
.ctrl-card.mpc::before { background: #4a7fa8; }
.ctrl-card.rl::before  { background: var(--berkeley-gold); }
.ctrl-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}
.ctrl-card:hover::before { transform: scaleX(1); }
.ctrl-card .ctrl-head {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.15rem;
}
.ctrl-card .ctrl-tag {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  padding: 0.12rem 0.4rem;
  border-radius: 4px;
  font-weight: 700;
  color: white;
}
.ctrl-card.pid .ctrl-tag { background: var(--berkeley-blue); }
.ctrl-card.mpc .ctrl-tag { background: #4a7fa8; }
.ctrl-card.rl  .ctrl-tag { background: var(--berkeley-gold); }
.ctrl-card .ctrl-name {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--text);
}
.ctrl-card .ctrl-meta {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.ctrl-card .vmath {
  font-size: 0.85rem;
  text-align: left;
  padding: 0.35rem 0.55rem;
  background: rgba(47, 67, 196,0.04);
  border-radius: 6px;
  overflow-x: auto;
}
.ctrl-card .ctrl-body {
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--text);
  margin: 0;
}

/* === Hero tag stack: split Real / Sim groups === */
.hero-stack {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.hero-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
.hero-row-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--berkeley-blue);
  font-weight: 700;
  padding-right: 0.35rem;
  border-right: 1px solid rgba(47, 67, 196,0.18);
  margin-right: 0.15rem;
}
.hero-row-label.sim {
  color: var(--berkeley-gold-dark);
  border-right-color: rgba(196,130,14,0.25);
}
.tag.sim {
  background: rgba(196,130,14,0.07);
  border-color: rgba(196,130,14,0.22);
}
.tag.sim .dot {
  background: var(--berkeley-gold);
}

/* === Closed-loop diagram animations === */
.loop-diagram { display: block; }
.ld-spin {
  transform-box: fill-box;
  transform-origin: center;
  animation: ld-spin 6s linear infinite;
}
@keyframes ld-spin { to { transform: rotate(360deg); } }

.ld-tilt {
  transform-box: fill-box;
  transform-origin: center;
  animation: ld-tilt 3.4s ease-in-out infinite;
}
@keyframes ld-tilt {
  0%, 100% { transform: rotate(-12deg); }
  50%      { transform: rotate(12deg); }
}

.ld-pulse {
  transform-box: fill-box;
  transform-origin: center;
  animation: ld-pulse 2.2s ease-in-out infinite;
}
@keyframes ld-pulse {
  0%, 100% { transform: scale(1);   opacity: 1; }
  50%      { transform: scale(1.6); opacity: 0.6; }
}

.ld-block rect { transition: filter 0.3s var(--ease-out); }
.ld-block:hover rect { filter: drop-shadow(0 4px 14px rgba(47, 67, 196,0.18)); }

/* === Hero CTA deck — four animated cards (PID / MPC / RL / ROS 2) === */
:root {
  --c-pid: #2f43c4;       /* PID — Berkeley blue */
  --c-mpc: #1d7e9c;       /* MPC — teal */
  --c-rl:  #2f43c4;       /* Residual PPO — Berkeley gold */
  --c-ros: #6643a0;       /* ROS 2 — purple */
}
.cta-deck {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
  max-width: 560px;
  margin-bottom: 0.25rem;
}
@media (min-width: 760px) {
  .cta-deck { grid-template-columns: 1fr 1fr; max-width: 580px; }
}
.cta-card {
  --c: var(--c-pid);
  position: relative;
  display: grid;
  grid-template-columns: 44px 1fr 14px;
  align-items: center;
  gap: 0.7rem;
  padding: 0.7rem 0.9rem;
  border-radius: 12px;
  background: #fdfcf8;
  border: 1px solid rgba(0,0,0,0.07);
  text-decoration: none;
  color: var(--text);
  overflow: hidden;
  transition: transform 0.4s var(--ease-out), box-shadow 0.4s var(--ease-out),
              border-color 0.4s var(--ease-out);
}
.cta-card.cta-pid { --c: var(--c-pid); }
.cta-card.cta-mpc { --c: var(--c-mpc); }
.cta-card.cta-rl  { --c: var(--c-rl);  }
.cta-card.cta-ros { --c: var(--c-ros); }
.cta-card::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--c);
  transition: width 0.3s var(--ease-out);
}
.cta-card::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, transparent 50%, color-mix(in srgb, var(--c) 11%, transparent) 100%);
  opacity: 0;
  transition: opacity 0.4s var(--ease-out);
  pointer-events: none;
}
.cta-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 22px rgba(0,0,0,0.08);
  border-color: color-mix(in srgb, var(--c) 35%, transparent);
}
.cta-card:hover::before { width: 5px; }
.cta-card:hover::after  { opacity: 1; }

.cta-card .cta-icon {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--c) 12%, #ffffff);
  border-radius: 10px;
  color: var(--c);
}
.cta-card .cta-icon svg {
  width: 30px; height: 30px;
  overflow: visible;
}
.cta-card .cta-body {
  display: flex; flex-direction: column; gap: 0.18rem;
  min-width: 0;
}
.cta-card .cta-title {
  font-family: var(--font-serif);
  font-size: 1.04rem;
  font-weight: 700;
  letter-spacing: 0.005em;
  line-height: 1.1;
  color: var(--text);
}
.cta-card .cta-sub {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.25;
}
.cta-card .cta-arrow {
  font-family: var(--font-serif);
  color: var(--c);
  opacity: 0.55;
  transform: translateX(-3px);
  transition: opacity 0.3s var(--ease-out), transform 0.3s var(--ease-out);
}
.cta-card:hover .cta-arrow { opacity: 1; transform: translateX(0); }

/* --- per-card icon animations --- */

/* PID equaliser: knobs drift along their bars */
.cta-pid .cta-eq .bar  { fill: color-mix(in srgb, var(--c-pid) 28%, #ffffff); }
.cta-pid .cta-eq .knob { fill: var(--c-pid); }
.cta-pid .cta-eq .k-p {
  animation: cta-pid-p 3.8s ease-in-out infinite;
  transform-origin: 22px 11.2px; transform-box: fill-box;
}
.cta-pid .cta-eq .k-i {
  animation: cta-pid-i 4.7s ease-in-out infinite;
  transform-origin: 22px 21.2px; transform-box: fill-box;
}
.cta-pid .cta-eq .k-d {
  animation: cta-pid-d 3.3s ease-in-out infinite;
  transform-origin: 22px 31.2px; transform-box: fill-box;
}
@keyframes cta-pid-p {
  0%,100% { transform: translateX(-6px); }
  50%     { transform: translateX(8px); }
}
@keyframes cta-pid-i {
  0%,100% { transform: translateX(8px); }
  50%     { transform: translateX(-7px); }
}
@keyframes cta-pid-d {
  0%,100% { transform: translateX(-3px); }
  50%     { transform: translateX(7px); }
}

/* MPC horizon: planning dots fade in one after another */
.cta-mpc .axis        { stroke: color-mix(in srgb, var(--c-mpc) 30%, #ffffff); stroke-width: 1.2; }
.cta-mpc .cta-curve   {
  stroke: var(--c-mpc); stroke-width: 1.8; stroke-linecap: round;
  stroke-dasharray: 60; stroke-dashoffset: 60;
  animation: cta-mpc-draw 3.6s ease-in-out infinite;
}
.cta-mpc .now  { fill: var(--c-mpc); }
.cta-mpc .step { fill: var(--c-mpc); opacity: 0.0; }
.cta-mpc .step.s1 { animation: cta-mpc-fade 3.6s ease-in-out 0.6s infinite; }
.cta-mpc .step.s2 { animation: cta-mpc-fade 3.6s ease-in-out 1.0s infinite; }
.cta-mpc .step.s3 { animation: cta-mpc-fade 3.6s ease-in-out 1.4s infinite; }
@keyframes cta-mpc-draw {
  0%   { stroke-dashoffset: 60; }
  55%  { stroke-dashoffset: 0; }
  85%  { stroke-dashoffset: 0; }
  100% { stroke-dashoffset: 60; }
}
@keyframes cta-mpc-fade {
  0%, 20%, 100% { opacity: 0; }
  40%, 80%      { opacity: 1; }
}

/* Residual PPO: a smooth baseline curve + a wiggly residual + ε node bobbing */
.cta-rl .rl-base     { stroke: color-mix(in srgb, var(--c-rl) 55%, #ffffff); stroke-width: 1.8; stroke-linecap: round; }
.cta-rl .rl-residual {
  stroke: var(--c-rl); stroke-width: 1.8; stroke-linecap: round; stroke-dasharray: 80;
  stroke-dashoffset: 80; animation: cta-rl-draw 4.2s ease-in-out infinite;
}
.cta-rl .rl-node     {
  transform-origin: 22px 13px; transform-box: fill-box;
  animation: cta-rl-bob 2.6s ease-in-out infinite;
}
.cta-rl .rl-node circle { fill: var(--c-rl); }
@keyframes cta-rl-draw {
  0%   { stroke-dashoffset: 80; }
  55%  { stroke-dashoffset: 0; }
  85%  { stroke-dashoffset: 0; }
  100% { stroke-dashoffset: 80; }
}
@keyframes cta-rl-bob {
  0%,100% { transform: translateY(0); }
  50%     { transform: translateY(-2.5px); }
}

/* ROS 2 node graph: edges glow softly, packet orbits via animateMotion */
.cta-ros .ros-edges line {
  stroke: color-mix(in srgb, var(--c-ros) 45%, #ffffff);
  stroke-width: 1.5;
}
.cta-ros .ros-node {
  fill: var(--c-ros);
  animation: cta-ros-pulse 2.6s ease-in-out infinite;
}
.cta-ros .ros-node:nth-of-type(2) { animation-delay: 0.65s; }
.cta-ros .ros-node:nth-of-type(3) { animation-delay: 1.3s;  }
.cta-ros .ros-node:nth-of-type(4) { animation-delay: 1.95s; }
.cta-ros .ros-packet { fill: var(--c-ros); }
@keyframes cta-ros-pulse {
  0%,100% { transform: scale(1);   opacity: 0.9; }
  50%     { transform: scale(1.18); opacity: 1; }
}

/* === Hero arm video (replaces the CSS plate placeholder) === */
.hero-arm {
  position: relative;
  display: block;
  width: 100%;
}
.hero-arm video {
  width: 100%;
  height: auto;
  display: block;
  background: transparent;
  filter: drop-shadow(0 14px 28px rgba(0,0,0,0.18));
}

/* Closed-loop diagram: pause animations until the hero video has finished its 2 laps */
.loop-diagram .ld-spin,
.loop-diagram .ld-tilt,
.loop-diagram .ld-pulse {
  animation-play-state: paused;
}
.loop-diagram.running .ld-spin,
.loop-diagram.running .ld-tilt,
.loop-diagram.running .ld-pulse {
  animation-play-state: running;
}

/* =============================================================
   Controller walk-through sections (PID / MPC / Residual PPO)
   — three sections, four cards each, one accent colour per scheme
============================================================= */
.ctrl-walk { --cw: var(--c-pid); }
.ctrl-walk-pid { --cw: var(--c-pid); }
.ctrl-walk-mpc { --cw: var(--c-mpc); }
.ctrl-walk-rl  { --cw: var(--c-rl);  }

/* Tint each controller section's background with a wash of its accent colour
   so the three sections (PID / MPC / Residual PPO) read as visually distinct
   as you scroll through them. Gold mixes very warm/yellow against the cream
   body bg, so it gets a softer percentage than the cooler blue/teal washes. */
.ctrl-walk-pid { background: color-mix(in srgb, var(--c-pid) 7%, var(--bg)); }
.ctrl-walk-mpc { background: color-mix(in srgb, var(--c-mpc) 8%, var(--bg)); }
.ctrl-walk-rl  { background: color-mix(in srgb, var(--c-rl)  5%, var(--bg)); }

.ctrl-walk .walk-head {
  max-width: 760px;
  margin: 0 auto 2.5rem;
  text-align: center;
}
.ctrl-walk .walk-head .eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
}
.ctrl-walk .walk-head h2 {
  margin-top: 0.6rem;
}

/* The letter pill (A/B/C) in the eyebrow */
.ctrl-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border-radius: 6px;
  background: var(--cw);
  color: #ffffff;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0;
}

/* ===== RICH SITE FOOTER (dark) ===== */
.site-footer {
  position: relative;
  margin-top: 4rem;
  padding: 3.5rem 0 1.6rem;
  background: #0e1218;
  color: rgba(255,255,255,0.78);
  border-top: 1px solid rgba(255,255,255,0.05);
  overflow: hidden;
  isolation: isolate;
}
.site-footer::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 92% 12%, rgba(196,130,14,0.18), transparent 55%),
    radial-gradient(circle at 4% 88%, rgba(0,80,160,0.22), transparent 50%);
  z-index: -2;
  pointer-events: none;
}
.footer-bg {
  position: absolute;
  inset: 0;
  z-index: -1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 4%;
  pointer-events: none;
}
.footer-bg svg {
  width: 340px;
  height: auto;
  opacity: 0.08;
  color: #ffffff;
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.7fr 1fr 1.1fr 1fr;
  gap: 2.4rem;
  margin-bottom: 2.4rem;
}
@media (max-width: 900px) {
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 2rem; }
}
@media (max-width: 540px) {
  .footer-grid { grid-template-columns: 1fr; gap: 1.6rem; }
}

.footer-brand-col {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}
.footer-logo {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.2rem;
  color: #ffffff;
  text-decoration: none;
  letter-spacing: -0.01em;
}
.footer-logo .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--berkeley-gold);
  box-shadow: 0 0 0 4px rgba(47, 67, 196,0.22);
  animation: pulse 2.4s ease-in-out infinite;
}
.footer-tagline {
  color: rgba(255,255,255,0.62);
  font-family: var(--font-display);
  font-style: italic;
  font-size: 0.92rem;
  margin: 0;
  max-width: 340px;
  line-height: 1.55;
}
.footer-gh-cta {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.8rem;
  padding: 0.7rem 1.1rem;
  background: var(--berkeley-blue);
  color: #fff;
  border-radius: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.92rem;
  text-decoration: none;
  width: fit-content;
  transition: background 0.25s var(--ease-out);
}
.footer-gh-cta:hover {
  background: color-mix(in srgb, var(--berkeley-blue) 88%, #000);
}
.footer-gh-cta svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.footer-col h5 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.78rem;
  color: var(--berkeley-gold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1.5px solid rgba(196,130,14,0.45);
}
.footer-col ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.footer-col a {
  color: rgba(255,255,255,0.65);
  font-family: var(--font-display);
  font-size: 0.92rem;
  text-decoration: none;
  position: relative;
  transition: color 0.25s, padding-left 0.25s var(--ease-out);
}
.footer-col a::before {
  content: '→';
  position: absolute;
  left: -16px;
  color: var(--berkeley-gold);
  opacity: 0;
  transition: opacity 0.25s var(--ease-out), left 0.25s var(--ease-out);
}
.footer-col a:hover {
  color: #ffffff;
  padding-left: 14px;
}
.footer-col a:hover::before {
  opacity: 1;
  left: 0;
}

.footer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 1.6rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  gap: 1rem;
  flex-wrap: wrap;
}
.footer-berkeley {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 0.85rem;
  color: rgba(255,255,255,0.55);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.footer-berkeley .footer-bear { font-size: 1.1em; }
.footer-authors {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 0.85rem;
  color: rgba(255,255,255,0.55);
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}
.footer-authors a {
  color: var(--berkeley-gold);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.25s;
}
.footer-authors a:hover { color: #ffd25e; }
.footer-authors .sep {
  color: rgba(255,255,255,0.30);
}

/* ===== NAV DROPDOWN (Control submenu) ===== */
.nav-dropdown {
  position: relative;
}
.nav-dropdown-label {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  cursor: default;
  color: var(--text-soft);
  transition: color 0.2s;
  /* font inherits from .nav so it matches the other nav links */
}
.nav-dropdown:hover .nav-dropdown-label,
.nav-dropdown:focus-within .nav-dropdown-label {
  color: var(--berkeley-blue);
}
.nav-dropdown:has(.active) .nav-dropdown-label {
  color: var(--berkeley-blue);
  font-weight: 600;
}
.nav-caret {
  font-size: 0.65em;
  transition: transform 0.25s var(--ease-out);
  display: inline-block;
  margin-top: 1px;
}
.nav-dropdown:hover .nav-caret,
.nav-dropdown:focus-within .nav-caret {
  transform: rotate(180deg);
}
.nav-dropdown-menu {
  position: absolute;
  top: calc(100% + 0.4rem);
  left: 50%;
  transform: translate(-50%, -4px);
  min-width: 220px;
  background: #ffffff;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 10px;
  padding: 0.4rem 0;
  list-style: none;
  margin: 0;
  box-shadow: 0 12px 28px rgba(0,0,0,0.10);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, transform 0.2s, visibility 0s linear 0.2s;
  z-index: 100;
}
.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
  transition: opacity 0.2s, transform 0.2s;
}
.nav-dropdown-menu li {
  display: block;
}
.nav-dropdown-menu a {
  display: block;
  padding: 0.5rem 1rem;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.92rem;
  color: var(--text);
  text-decoration: none;
  transition: background 0.2s, color 0.2s;
}
.nav-dropdown-menu a:hover,
.nav-dropdown-menu a.active {
  background: color-mix(in srgb, var(--berkeley-blue) 10%, #ffffff);
  color: var(--berkeley-blue);
}
/* Inside the mobile drawer (<= 920 px) the Control submenu must lose its
   desktop popover behaviour: drop the absolute positioning, the white
   background, and the hover trigger. Items appear inline, indented, and
   are always visible. */
@media (max-width: 920px) {
  .nav-dropdown { width: 100%; }
  .nav-dropdown-label {
    display: block;
    color: var(--text-soft);
    cursor: default;
  }
  .nav-dropdown:hover .nav-dropdown-label,
  .nav-dropdown:focus-within .nav-dropdown-label {
    /* Avoid the desktop hover glow inside the drawer (it changed colour
       and shifted the label, which read as a 'bug' on touch). */
    color: var(--text-soft);
  }
  .nav-dropdown-menu {
    position: static;
    transform: none;
    opacity: 1;
    visibility: visible;
    background: transparent;
    box-shadow: none;
    border: none;
    border-radius: 0;
    padding: 0 0 0 1rem;
    min-width: 0;
    transition: none;
  }
  .nav-dropdown:hover .nav-dropdown-menu,
  .nav-dropdown:focus-within .nav-dropdown-menu {
    /* Don't re-trigger the desktop translate animation on touch hover. */
    transform: none;
  }
  .nav-caret { display: none; }
}

/* ===== GITHUB REPO CARD ===== */
.gh-card {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 1.5rem;
  max-width: 720px;
  margin: 1.5rem auto 0;
  padding: 1.8rem 2rem;
  text-decoration: none;
  color: inherit;
  background: linear-gradient(135deg, #0f1419 0%, #1c2128 100%);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 18px;
  position: relative;
  overflow: hidden;
  isolation: isolate;
  transition: transform 0.4s var(--ease-out), box-shadow 0.4s var(--ease-out);
}
.gh-card::before {
  content: '';
  position: absolute;
  inset: -50%;
  background: conic-gradient(from 0deg,
              transparent 0deg,
              rgba(107,120,214,0.18) 90deg,
              transparent 180deg,
              rgba(47, 67, 196,0.25) 270deg,
              transparent 360deg);
  animation: ghSpin 9s linear infinite;
  z-index: -1;
}
.gh-card::after {
  content: '';
  position: absolute;
  inset: 2px;
  background: linear-gradient(135deg, #0f1419 0%, #1c2128 100%);
  border-radius: 16px;
  z-index: -1;
}
@keyframes ghSpin {
  to { transform: rotate(360deg); }
}
.gh-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 18px 40px rgba(0,0,0,0.35);
}
.gh-icon-wrap {
  width: 88px;
  height: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.04);
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}
.gh-icon {
  width: 54px;
  height: 54px;
  color: #ffffff;
  animation: ghPulse 3.4s ease-in-out infinite;
}
@keyframes ghPulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.08) rotate(-3deg); }
}
.gh-card:hover .gh-icon {
  animation-play-state: paused;
  transform: rotate(-10deg) scale(1.15);
  transition: transform 0.35s var(--ease-out);
}
.gh-content { color: #ffffff; }
.gh-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.45rem;
  letter-spacing: -0.01em;
  margin-bottom: 0.2rem;
}
.gh-subtitle {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 0.95rem;
  color: rgba(255,255,255,0.7);
  margin-bottom: 1rem;
}
.gh-cta {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--berkeley-blue-light);
  letter-spacing: 0.01em;
  transition: gap 0.25s var(--ease-out);
}
.gh-cta::after {
  content: '→';
  display: inline-block;
  transition: transform 0.25s var(--ease-out);
}
.gh-card:hover .gh-cta { gap: 0.7rem; }
.gh-card:hover .gh-cta::after { transform: translateX(3px); }
@media (max-width: 540px) {
  .gh-card { grid-template-columns: 1fr; text-align: center; padding: 1.5rem; }
  .gh-icon-wrap { margin: 0 auto; }
}

/* ===== TECH STACK (Code page) ===== */
.tech-stack {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  max-width: 1080px;
  margin: 1.4rem auto 0;
}
@media (max-width: 880px) { .tech-stack { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px) { .tech-stack { grid-template-columns: repeat(2, 1fr); } }

.tech-card {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 1.2rem 0.8rem 1rem;
  background: linear-gradient(160deg, #fdfcf8 0%, color-mix(in srgb, var(--tech-c, #2f43c4) 8%, #fdfcf8) 100%);
  border: 1px solid color-mix(in srgb, var(--tech-c, #2f43c4) 15%, transparent);
  border-radius: 14px;
  box-shadow: 0 3px 12px rgba(0,0,0,0.05);
  transition: transform 0.4s var(--ease-out), box-shadow 0.4s var(--ease-out), border-color 0.4s var(--ease-out);
}
.tech-card::after {
  content: '';
  position: absolute;
  top: -20px; right: -20px;
  width: 80px; height: 80px;
  border-radius: 50%;
  background: radial-gradient(circle at center, color-mix(in srgb, var(--tech-c) 30%, transparent), transparent 70%);
  opacity: 0.5;
  transition: transform 0.5s var(--ease-out), opacity 0.5s var(--ease-out);
  z-index: -1;
  transform: scale(0.85);
}
.tech-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 14px 30px color-mix(in srgb, var(--tech-c) 20%, rgba(0,0,0,0.08));
  border-color: color-mix(in srgb, var(--tech-c) 45%, transparent);
}
.tech-card:hover::after { transform: scale(1.15); opacity: 0.85; }
.tech-card:hover .tech-icon { transform: rotate(-8deg) scale(1.1); }
.tech-icon {
  width: 38px;
  height: 38px;
  color: var(--tech-c);
  margin-bottom: 0.55rem;
  transition: transform 0.45s var(--ease-out);
}
.tech-icon svg { width: 100%; height: 100%; display: block; }
.tech-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.98rem;
  color: var(--tech-c);
  letter-spacing: -0.005em;
}
.tech-tag {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* ===== REPO TREE ===== */
.repo-tree {
  max-width: 720px;
  margin: 1.4rem auto 0;
  padding: 1.5rem 1.8rem;
  background: linear-gradient(160deg, #fdfcf8 0%, color-mix(in srgb, var(--berkeley-blue) 4%, #fdfcf8) 100%);
  border: 1px solid rgba(47, 67, 196,0.12);
  border-radius: 14px;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.85;
}
.repo-line {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  white-space: nowrap;
}
.repo-line--root  { padding-left: 0; font-weight: 700; }
.repo-line--l1    { padding-left: 1.4rem; }
.repo-line--l2    { padding-left: 2.8rem; }
.repo-icon {
  font-size: 0.95rem;
  filter: grayscale(0.2);
}
.repo-c-real   { filter: hue-rotate(15deg); }
.repo-c-sim    { filter: hue-rotate(-30deg); }
.repo-c-design { filter: hue-rotate(80deg); }
.repo-c-web    { filter: hue-rotate(-60deg); }
.repo-name {
  color: var(--berkeley-blue);
  font-weight: 600;
}
.repo-note {
  color: var(--text-muted);
  font-style: italic;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 0.82rem;
  margin-left: 0.4rem;
}
@media (max-width: 640px) {
  .repo-line { white-space: normal; flex-wrap: wrap; }
  .repo-tree { font-size: 0.78rem; padding: 1.1rem 1.2rem; }
}

/* ===== TEAM PAGE ===== */
.team-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1.3rem;
  max-width: 1100px;
  margin: 0 auto;
}
@media (max-width: 980px) { .team-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 540px) { .team-grid { grid-template-columns: 1fr; } }

.team-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 1.6rem 1.1rem 1.3rem;
  background: linear-gradient(160deg, #fdfcf8 0%, color-mix(in srgb, var(--berkeley-blue) 5%, #fdfcf8) 100%);
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 16px;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 3px 12px rgba(0,0,0,0.05);
  transition: transform 0.4s var(--ease-out), box-shadow 0.4s var(--ease-out), border-color 0.4s var(--ease-out);
}
a.team-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 14px 30px rgba(47, 67, 196,0.14);
  border-color: color-mix(in srgb, var(--berkeley-blue) 35%, transparent);
}
.team-card--placeholder { cursor: default; opacity: 0.85; }

.team-avatar {
  position: relative;
  width: 110px; height: 110px;
  border-radius: 50%;
  overflow: hidden;
  margin-bottom: 1rem;
  background: linear-gradient(135deg,
              color-mix(in srgb, var(--berkeley-blue) 22%, #ffffff) 0%,
              color-mix(in srgb, var(--berkeley-gold) 25%, #ffffff) 100%);
  box-shadow: 0 4px 14px rgba(47, 67, 196,0.18), inset 0 0 0 3px #ffffff;
}
.team-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
/* fallback initials shown via data-initials when the <img> fails to load and hides itself */
.team-avatar::before {
  content: attr(data-initials);
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 2.2rem;
  letter-spacing: -0.02em;
  color: var(--berkeley-blue);
  z-index: 0;
}
.team-avatar img { position: relative; z-index: 1; }

.team-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--berkeley-blue);
  letter-spacing: -0.005em;
  margin-bottom: 0.2rem;
}
.team-affil {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.7rem;
}
.team-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}
.team-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.6rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--berkeley-blue) 10%, #ffffff);
  color: var(--berkeley-blue);
  font-family: var(--font-display);
  font-style: italic;
  font-size: 0.78rem;
  font-weight: 600;
  transition: background 0.25s, color 0.25s;
}
a.team-card:hover .team-link {
  background: var(--berkeley-blue);
  color: #ffffff;
}
.team-link--muted {
  background: rgba(0,0,0,0.04);
  color: var(--text-muted);
  font-weight: 500;
  font-style: italic;
}
.team-footer-note {
  margin: 2.2rem auto 0;
  text-align: center;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* ===== SHAPES GALLERY (sim2real intro) ===== */
.shapes-gallery {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  max-width: 980px;
  margin: 0.5rem auto 0;
}
@media (max-width: 760px) { .shapes-gallery { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 420px) { .shapes-gallery { grid-template-columns: 1fr; } }

.shape-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem 0.6rem 0.9rem;
  text-decoration: none;
  background: linear-gradient(155deg, #fdfcf8 0%, color-mix(in srgb, var(--berkeley-gold) 10%, #fdfcf8) 100%);
  border: 1px solid rgba(196,130,14,0.18);
  border-radius: 14px;
  box-shadow: 0 3px 12px rgba(0,0,0,0.05);
  transition: transform 0.4s var(--ease-out), box-shadow 0.4s var(--ease-out), border-color 0.4s var(--ease-out);
}
.shape-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 14px 30px rgba(196,130,14,0.18);
  border-color: color-mix(in srgb, var(--berkeley-gold) 50%, transparent);
}
.shape-svg {
  width: 100%;
  max-width: 150px;
  height: auto;
  aspect-ratio: 1 / 1;
}
.shape-label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--berkeley-blue);
  margin-top: 0.45rem;
  letter-spacing: -0.005em;
}
.shapes-gallery-caption {
  margin: 1rem auto 0;
  max-width: 980px;
  text-align: center;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* ===== SIM2REAL PAGE ===== */
.s2r-hero {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  min-height: 360px;
}
.s2r-hero-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: -2;
  filter: saturate(0.85) contrast(0.95);
}
.s2r-hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg,
              rgba(255, 255, 255,0.92) 0%,
              rgba(255, 255, 255,0.78) 60%,
              rgba(255, 255, 255,0.96) 100%);
  z-index: -1;
}
.s2r-hero .container {
  position: relative;
  z-index: 1;
}

/* Side-by-side split: left half = real, right half = rviz */
.s2r-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
  max-width: 1180px;
  margin: 1.5rem auto 0;
}
@media (max-width: 760px) {
  .s2r-split { grid-template-columns: 1fr; }
}
.s2r-half {
  margin: 0;
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  border: 4px solid var(--berkeley-blue);
  box-shadow: 0 8px 22px rgba(47, 67, 196,0.18);
  background: #111;
  transition: transform 0.4s var(--ease-out), box-shadow 0.4s var(--ease-out), border-color 0.4s var(--ease-out);
}
.s2r-half:has(.s2r-tag-real) { border-color: var(--berkeley-gold); box-shadow: 0 8px 22px rgba(196,130,14,0.22); }
.s2r-half:has(.s2r-tag-rviz) { border-color: var(--berkeley-blue); box-shadow: 0 8px 22px rgba(47, 67, 196,0.22); }
.s2r-half:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 36px rgba(0,0,0,0.18);
}
.s2r-half figcaption {
  position: absolute;
  bottom: 0.8rem;
  left: 0.8rem;
  margin: 0;
  display: flex;
  gap: 0.5rem;
  z-index: 2;
}

/* Full-width single video */
.s2r-figure {
  margin: 1.5rem auto 0;
  max-width: 1180px;
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  border: 4px solid var(--berkeley-gold);
  box-shadow: 0 8px 22px rgba(196,130,14,0.22);
  background: #111;
}
.s2r-figure figcaption {
  position: absolute;
  bottom: 0.9rem;
  left: 0.9rem;
  margin: 0;
  z-index: 2;
}

/* Designer + execution pair */
.s2r-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  max-width: 1180px;
  margin: 1.5rem auto 0;
}
@media (max-width: 760px) {
  .s2r-pair { grid-template-columns: 1fr; }
}
.s2r-pair-card {
  margin: 0;
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  border: 4px solid var(--berkeley-blue);
  box-shadow: 0 8px 22px rgba(47, 67, 196,0.18);
  background: #111;
  transition: transform 0.4s var(--ease-out), border-color 0.4s var(--ease-out), box-shadow 0.4s var(--ease-out);
}
.s2r-pair-card:has(.s2r-tag-design) { border-color: #6643a0; box-shadow: 0 8px 22px rgba(102,67,158,0.22); }
.s2r-pair-card:has(.s2r-tag-real)   { border-color: var(--berkeley-gold); box-shadow: 0 8px 22px rgba(196,130,14,0.22); }
.s2r-pair-card:hover { transform: translateY(-4px); box-shadow: 0 16px 36px rgba(0,0,0,0.18); }
.s2r-pair-card figcaption {
  position: absolute;
  bottom: 0.8rem;
  left: 0.8rem;
  right: 0.8rem;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  z-index: 2;
}

/* The actual video element */
.s2r-video {
  display: block;
  width: 100%;
  height: auto;
  background: #111;
}
.s2r-video--wide {
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

/* Floating tags / badges */
.s2r-tag {
  display: inline-block;
  padding: 0.32rem 0.7rem;
  border-radius: 999px;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.s2r-tag-real {
  background: rgba(196,130,14,0.92);
  color: #fff;
  box-shadow: 0 2px 10px rgba(196,130,14,0.35);
}
.s2r-tag-rviz {
  background: rgba(47, 67, 196,0.92);
  color: #fff;
  box-shadow: 0 2px 10px rgba(47, 67, 196,0.35);
}
.s2r-tag-design {
  background: rgba(102,67,158,0.92);
  color: #fff;
  box-shadow: 0 2px 10px rgba(102,67,158,0.35);
}
.s2r-cap {
  color: #fff;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 0.85rem;
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}

/* ===== BIBLIOGRAPHY ===== */
.bibliography {
  list-style: decimal;
  padding-left: 1.6rem;
  margin: 1.2rem 0 0;
  font-size: 0.92rem;
  line-height: 1.6;
}
.bibliography li {
  margin-bottom: 0.85rem;
  color: var(--text);
  padding-left: 0.3rem;
}
.bibliography li::marker {
  color: var(--berkeley-blue);
  font-weight: 700;
  font-family: var(--font-mono);
  font-size: 0.88rem;
}
.bibliography .bib-authors  { font-family: var(--font-display); }
.bibliography .bib-title    { font-style: italic; color: var(--text); }
.bibliography .bib-venue    { color: var(--text-muted); font-family: var(--font-display); }
.bibliography .bib-link {
  color: var(--berkeley-blue);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  border-bottom: 1px dotted color-mix(in srgb, var(--berkeley-blue) 40%, transparent);
  transition: color 0.2s, border-color 0.2s;
  /* Long URLs (e.g. doi.org/10.1016/j.patcog.2014.x) would otherwise punch
     out of narrow columns on mobile and force the whole page to scroll. */
  word-break: break-all;
  overflow-wrap: anywhere;
}
.bibliography .bib-link:hover {
  color: var(--berkeley-gold);
  border-bottom-color: var(--berkeley-gold);
}

/* Side decorations: project-themed silhouettes anchored to each section's
   empty side margin. Sized to actually fit (depends on viewport - container).
   Hidden when there isn't enough side space. */
.doc-section, .story-section { position: relative; overflow: hidden; }
.section-decor {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: clamp(160px, 18vw, 260px);
  height: auto;
  opacity: 0.13;
  pointer-events: none;
  z-index: 0;
  color: var(--berkeley-blue);
}
.section-decor--right { right: 0.5rem; }
.section-decor--left  { left: 0.5rem; transform: translateY(-50%) scaleX(-1); }
.section-decor--gold   { color: var(--berkeley-gold); }
.section-decor--purple { color: #6643a0; }
.section-decor svg { width: 100%; height: auto; display: block; }
.doc-section > .container, .story-section > .container { position: relative; z-index: 1; }
@media (max-width: 1280px) { .section-decor { display: none; } }

/* Documentation page section bands: alternating full-width backgrounds so each § N reads as its own block while the reader scrolls. */
.doc-section {
  padding: 2.4rem 0 2.6rem;
}
.doc-section--alt {
  background: var(--bg-soft);
}
.doc-section > .container.body-prose {
  padding-top: 0;
  padding-bottom: 0;
}
.doc-section .section-h:first-child {
  margin-top: 0.5rem;
}

/* ROS cards: topic/field name in monospace + small message-type subtitle.
   Wider grid so long topic names like /scaled_joint_trajectory_controller/joint_trajectory fit on one line. */
.ctrl-walk.ros-cards .walk-grid { max-width: 1180px; }
.ctrl-walk.ros-cards .walk-card { padding: 1.4rem 1.3rem 1.1rem; }
/* When the total card count is odd, the last card lands alone on its row;
   stretch it across both columns so the grid does not leave a visible gap. */
@media (min-width: 701px) {
  .ctrl-walk.ros-cards .walk-grid > .walk-card:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }
}
.ctrl-walk.ros-cards .walk-card h4.ros-topic {
  font-family: var(--font-mono);
  font-size: 0.92rem;
  color: var(--cw);
  font-weight: 600;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
  margin: 0 2.6rem 0.15rem 0;
}
.ctrl-walk.ros-cards .walk-card .ros-msg {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  font-style: normal;
  margin: 0 0 0.55rem;
  letter-spacing: 0;
}
.ctrl-walk.ros-cards .walk-card .ros-direction {
  color: var(--cw);
  font-weight: 600;
  font-size: 0.88rem;
  margin: 0.2rem 0 0.35rem;
}

/* Node-graph cards: serif title (vs monospace topic name) so they don't visually collide with the topic cards */
.ctrl-walk.ros-cards.ros-nodes .walk-card h4.ros-topic {
  font-family: var(--font-display);
  font-size: 1.05rem;
  letter-spacing: -0.005em;
  text-transform: none;
}
.ctrl-walk.ros-cards.ros-nodes .walk-card .ros-msg {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 0.78rem;
  text-transform: lowercase;
  letter-spacing: 0.02em;
}

/* ===== ONE CONTROL CYCLE — clockwise serpentine layout (3 over, 3 back) ===== */
.cycle-clock-wrap {
  margin: 1.8rem 0 2.5rem;
}
.cycle-clock {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(2, auto);
  gap: 1.1rem 1.3rem;
  max-width: 1180px;
  margin: 0 auto;
  position: relative;
}
@media (max-width: 760px) {
  .cycle-clock { grid-template-columns: 1fr; }
  /* The `.pos-N` rules below force grid-column 2/3, which don't exist
     when the grid collapses to one column. Cards would sit off-screen
     to the right. Force them back into the single column. */
  .cycle-clock .cycle-card { grid-column: 1 !important; grid-row: auto !important; }
}
/* clockwise grid placement: 1→2→3 across top, then 4 (right), 5 (mid), 6 (left) reading right-to-left */
.cycle-card.pos-1 { grid-column: 1; grid-row: 1; }
.cycle-card.pos-2 { grid-column: 2; grid-row: 1; }
.cycle-card.pos-3 { grid-column: 3; grid-row: 1; }
.cycle-card.pos-4 { grid-column: 3; grid-row: 2; }
.cycle-card.pos-5 { grid-column: 2; grid-row: 2; }
.cycle-card.pos-6 { grid-column: 1; grid-row: 2; }

.cycle-card {
  position: relative;
  isolation: isolate;
  background: linear-gradient(155deg, #fdfcf8 0%, #fdfcf8 60%, color-mix(in srgb, var(--berkeley-blue) 7%, #fdfcf8) 100%);
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 14px;
  padding: 1.1rem 1.2rem 1rem;
  box-shadow: 0 3px 12px rgba(0,0,0,0.06);
  transition: transform 0.35s var(--ease-out), box-shadow 0.35s var(--ease-out), border-color 0.35s var(--ease-out);
}
.cycle-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--berkeley-blue);
  border-radius: 14px 14px 0 0;
  opacity: 0.85;
}
.cycle-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 24px rgba(0,0,0,0.10);
  border-color: color-mix(in srgb, var(--berkeley-blue) 30%, transparent);
}
.cycle-card h5 {
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--berkeley-blue);
  margin: 0 0 0.4rem;
  letter-spacing: -0.005em;
}
.cycle-card p {
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--text);
  margin: 0;
}
.cycle-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--berkeley-blue);
  color: #ffffff;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.82rem;
  margin-bottom: 0.5rem;
  box-shadow: 0 2px 6px rgba(47, 67, 196,0.25);
}
.cycle-loop-note {
  margin: 1.4rem auto 0;
  max-width: 1180px;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 0.92rem;
  color: var(--text-muted);
  text-align: center;
}
.cycle-loop-note::before {
  content: '↻  ';
  color: var(--berkeley-blue);
  font-style: normal;
  font-weight: 700;
}

/* Arrows between cycle cards. Top row reads left-to-right (→), right column drops down (↓),
   bottom row reads right-to-left (←). On mobile the grid collapses to one column and all arrows become ↓. */
.cycle-card::after {
  position: absolute;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.6rem;
  color: var(--berkeley-blue);
  background: transparent;
  pointer-events: none;
  line-height: 1;
  z-index: 3;
}
@media (min-width: 761px) {
  /* top row, going right */
  .cycle-card.pos-1::after,
  .cycle-card.pos-2::after {
    content: '→';
    top: 50%; right: -1.4rem;
    transform: translate(0, -50%);
  }
  /* top-right → bottom-right */
  .cycle-card.pos-3::after {
    content: '↓';
    bottom: -1.6rem; right: 50%;
    transform: translate(50%, 0);
  }
  /* bottom row, going left */
  .cycle-card.pos-4::after,
  .cycle-card.pos-5::after {
    content: '←';
    top: 50%; left: -1.4rem;
    transform: translate(0, -50%);
  }
  /* pos-6 has no arrow — the loop-note handles the close */
}
@media (max-width: 760px) {
  /* single-column stack: every card except the last gets a down arrow */
  .cycle-card.pos-1::after,
  .cycle-card.pos-2::after,
  .cycle-card.pos-3::after,
  .cycle-card.pos-4::after,
  .cycle-card.pos-5::after {
    content: '↓';
    bottom: -1.4rem; left: 50%;
    transform: translate(-50%, 0);
  }
}

/* 2 x 2 grid of step cards (1-col on mobile; 2-col on tablet+desktop for breathing room) */
.ctrl-walk .walk-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.1rem;
  max-width: 980px;
  margin: 0 auto;
}
@media (max-width: 700px) {
  .ctrl-walk .walk-grid { grid-template-columns: 1fr; }
}

.ctrl-walk .walk-card {
  position: relative;
  isolation: isolate;
  background: linear-gradient(155deg, #fdfcf8 0%, #fdfcf8 60%, color-mix(in srgb, var(--cw) 6%, #fdfcf8) 100%);
  border: 1px solid rgba(0,0,0,0.07);
  border-radius: 14px;
  padding: 1.35rem 1.2rem 1.15rem;
  overflow: hidden;
  transition: transform 0.4s var(--ease-out), box-shadow 0.4s var(--ease-out),
              border-color 0.4s var(--ease-out), background 0.4s var(--ease-out);
}
.ctrl-walk .walk-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg,
              var(--cw) 0%,
              color-mix(in srgb, var(--cw) 60%, transparent) 100%);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.5s var(--ease-out);
}
/* Decorative glow blob behind the icon, scales on hover; sits behind content via z-index in isolated context */
.ctrl-walk .walk-card::after {
  content: '';
  position: absolute;
  top: -28px; right: -28px;
  width: 110px; height: 110px;
  border-radius: 50%;
  background: radial-gradient(circle at center,
              color-mix(in srgb, var(--cw) 28%, transparent) 0%,
              transparent 70%);
  opacity: 0.55;
  transform: scale(0.85);
  transition: transform 0.55s var(--ease-out), opacity 0.55s var(--ease-out);
  pointer-events: none;
  z-index: -1;
}
.ctrl-walk .walk-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 14px 32px rgba(0,0,0,0.10),
              0 0 0 1px color-mix(in srgb, var(--cw) 25%, transparent);
  border-color: color-mix(in srgb, var(--cw) 35%, transparent);
  background: linear-gradient(155deg, #ffffff 0%, #fdfcf8 55%, color-mix(in srgb, var(--cw) 10%, #fdfcf8) 100%);
}
.ctrl-walk .walk-card:hover::before { transform: scaleX(1); }
.ctrl-walk .walk-card:hover::after {
  transform: scale(1.15);
  opacity: 0.85;
}
.ctrl-walk .walk-card:hover .walk-card-icon {
  transform: rotate(-6deg) scale(1.08);
  color: color-mix(in srgb, var(--cw) 90%, #000);
}
.ctrl-walk .walk-card:hover .walk-num {
  transform: scale(1.08);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--cw) 35%, transparent);
}

/* Icon: sits top-right, color = current controller accent */
.ctrl-walk .walk-card-icon {
  position: absolute;
  top: 1rem; right: 1rem;
  width: 32px; height: 32px;
  color: var(--cw);
  opacity: 0.55;
  transition: transform 0.45s var(--ease-out), opacity 0.45s var(--ease-out), color 0.45s var(--ease-out);
  z-index: 1;
}
.ctrl-walk .walk-card-icon svg { width: 100%; height: 100%; display: block; }
.ctrl-walk .walk-card:hover .walk-card-icon { opacity: 1; }

.ctrl-walk .walk-num {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg,
              color-mix(in srgb, var(--cw) 22%, #ffffff) 0%,
              color-mix(in srgb, var(--cw) 10%, #ffffff) 100%);
  color: var(--cw);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 0.6rem;
  box-shadow: 0 1px 4px color-mix(in srgb, var(--cw) 18%, transparent);
  transition: transform 0.35s var(--ease-out), box-shadow 0.35s var(--ease-out);
}
.ctrl-walk .walk-card h4 {
  font-family: var(--font-serif);
  font-size: 1.02rem;
  font-weight: 600;
  margin: 0 0 0.45rem;
  color: var(--text);
}
.ctrl-walk .walk-card p {
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--text);
  margin: 0;
}

/* Summary equation under each section */
.ctrl-walk .walk-eq {
  margin: 2.25rem auto 0.6rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  font-size: 1.15rem;
  font-family: var(--font-serif);
}
.ctrl-walk .walk-eq-lhs {
  color: var(--text);
  font-style: italic;
}
.ctrl-walk .walk-eq-plus {
  color: var(--text-muted);
  font-weight: 600;
}
.ctrl-walk .walk-eq-term {
  padding: 0.45rem 0.85rem;
  border-radius: 10px;
  background: rgba(0,0,0,0.04);
  color: var(--text);
}
.walk-eq-pid-p   { background: rgba(47, 67, 196,0.10);   color: var(--c-pid); }
.walk-eq-pid-i   { background: rgba(29,126,156,0.13); color: var(--c-mpc); }
.walk-eq-pid-d   { background: rgba(196,130,14,0.13); color: #a36a06; }
.walk-eq-mpc-q   { background: rgba(29,126,156,0.13); color: var(--c-mpc); }
.walk-eq-mpc-r   { background: rgba(178,30,40,0.11);  color: #8a181f; }
.walk-eq-rl-base { background: rgba(40,140,90,0.12);  color: #1b6943; }
.walk-eq-rl-resid{ background: rgba(102,67,158,0.13); color: #5d3a9a; }

.ctrl-walk .walk-eq-cap {
  text-align: center;
  font-size: 0.88rem;
  color: var(--text-muted);
  margin: 0.2rem auto 0;
}
.hl-pid-p   { color: var(--c-pid);   font-weight: 600; }
.hl-pid-i   { color: var(--c-mpc);   font-weight: 600; }
.hl-pid-d   { color: #a36a06;        font-weight: 600; }
.hl-mpc-q   { color: var(--c-mpc);   font-weight: 600; }
.hl-mpc-r   { color: #8a181f;        font-weight: 600; }
.hl-rl-base { color: #1b6943;        font-weight: 600; }
.hl-rl-resid{ color: #5d3a9a;        font-weight: 600; }

.ctrl-walk .walk-cta {
  text-align: center;
  margin-top: 1.6rem;
}

/* === Generic horizontal-scroll wrapper for wide tables on small screens ===
   Wrap any wide <table> in <div class="table-scroll"> so it scrolls inside
   the column instead of forcing the page wider. */
.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 1.5rem 0;
}
.table-scroll > table { margin: 0; min-width: 480px; }

/* === Keep inline math on one line (KaTeX) ===
   Without this rule narrow columns (e.g. the per-card text in the controller
   walk-through) can break a single inline expression across lines, splitting
   variables and operators awkwardly. On phones the prose column is already
   so narrow that a single expression like ``R_{WP}(q) ∈ SO(3)`` would punch
   out of the column; allow wrapping there. */
.katex { white-space: nowrap; }
.katex-display { white-space: normal; }
@media (max-width: 540px) {
  .katex { white-space: normal; }
}

/* === Residual-PPO quantitative payoff block (head-to-head drop rate) === */
.rl-payoff {
  margin: 2.0rem auto 0.5rem;
  max-width: 720px;
}
.rl-payoff-lead {
  text-align: center;
  font-size: 0.94rem;
  color: var(--text);
  margin: 0 auto 1.2rem;
  max-width: 600px;
}

/* =============================================================
   Setup page — reference frames layout + hardware card grid
============================================================= */
.frames-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
  margin: 1.5rem 0 1.5rem;
}
@media (max-width: 880px) {
  .frames-layout { grid-template-columns: 1fr; }
}
.frames-cards {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.frame-card {
  --c: var(--berkeley-blue);
  display: grid;
  grid-template-columns: 50px 1fr;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  background: #fdfcf8;
  border: 1px solid rgba(0,0,0,0.07);
  border-radius: 12px;
  position: relative;
  overflow: hidden;
  transition: transform 0.35s var(--ease-out), box-shadow 0.35s var(--ease-out),
              border-color 0.35s var(--ease-out);
}
.frame-card.frame-world  { --c: var(--berkeley-blue); }
.frame-card.frame-plate  { --c: var(--berkeley-gold-dark); }
.frame-card.frame-image  { --c: #4a7fa8; }
.frame-card.frame-camera { --c: #6643a0; }
.frame-card::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--c);
}
.frame-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.06);
  border-color: color-mix(in srgb, var(--c) 30%, transparent);
}
.frame-card .frame-icon {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  background: color-mix(in srgb, var(--c) 12%, #ffffff);
  color: var(--c);
}
.frame-card .frame-icon svg { width: 30px; height: 30px; }
.frame-card .frame-body { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; }
.frame-card .frame-tag {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  color: var(--c);
  font-weight: 600;
}
.frame-card h4 {
  font-family: var(--font-serif);
  font-size: 1.0rem;
  margin: 0 0 0.3rem;
  font-weight: 600;
  color: var(--text);
}
.frame-card p {
  font-size: 0.88rem;
  line-height: 1.55;
  margin: 0;
  color: var(--text);
}

.fig-arm {
  margin: 0;
}
.fig-arm .diagram { width: 100%; display: block; margin: 0 auto; }

/* Hardware grid */
.hardware-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 1.5rem 0 2rem;
}
@media (min-width: 1100px) {
  .hardware-grid:not(.hardware-grid--2) { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 640px) {
  .hardware-grid { grid-template-columns: 1fr; }
}
/* Modifier: keep a strict 2-per-row layout even on wide screens. Used for the
   vision pipeline where four cards read better as 2 × 2 than 3 + 1. */
.hardware-grid.hardware-grid--2 { grid-template-columns: 1fr 1fr; }
.hw-card {
  background: #fdfcf8;
  border: 1px solid rgba(0,0,0,0.07);
  border-radius: 12px;
  padding: 1.15rem 1.15rem 1.1rem;
  position: relative;
  overflow: hidden;
  transition: transform 0.35s var(--ease-out), box-shadow 0.35s var(--ease-out),
              border-color 0.35s var(--ease-out);
}
.hw-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 2.5px;
  background: linear-gradient(90deg, var(--berkeley-blue), var(--berkeley-gold));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.45s var(--ease-out);
}
.hw-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 24px rgba(0,0,0,0.07);
  border-color: rgba(47, 67, 196,0.18);
}
.hw-card:hover::before { transform: scaleX(1); }

.hw-card .hw-figure {
  width: 100%;
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: linear-gradient(135deg, #fef9ed, #fbf3dc);
  margin-bottom: 0.9rem;
  overflow: hidden;
}
.hw-card .hw-figure svg {
  width: 100%;
  height: 100%;
  display: block;
}
.hw-card h4 {
  font-family: var(--font-serif);
  font-size: 1.04rem;
  margin: 0 0 0.2rem;
  font-weight: 600;
  color: var(--text);
}
.hw-card .hw-spec {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--berkeley-gold-dark);
  letter-spacing: 0.02em;
  margin-bottom: 0.55rem;
}
.hw-card p {
  font-size: 0.88rem;
  line-height: 1.55;
  margin: 0;
  color: var(--text);
}

/* Slim page-hero used when there is no abstract paragraph below the title. */
/* =============================================================
   Mobile / tablet polish pass
   These rules override the desktop defaults below the listed
   breakpoint. Adding to the bottom keeps the cascade simple: any
   prior rule wins on desktop, mobile-specific tightening wins on
   small screens via the media query alone.
============================================================= */

/* Tablet (<= 768 px). Mainly shrink generous padding around the hero
   and page-hero so the user lands on content, not whitespace. */
@media (max-width: 768px) {
  .hero {
    padding-top: 6rem;
    padding-bottom: 2.5rem;
    min-height: 0;
  }
  .page-hero {
    padding: 6rem 0 2.5rem;
  }
  .math-block {
    padding: 1rem 1.1rem;
    font-size: 1rem;
  }
  /* Stop any image / SVG from punching out of its container. */
  img, svg, video, canvas { max-width: 100%; height: auto; }
  /* Inline SVGs that rely on an inline width attribute (common in the
     control / mpc / physics figures) get a height fallback. */
  figure svg, .svg-schema svg, .fc-arrow svg, figure img {
    max-width: 100%;
    height: auto;
  }
}

/* Phone (<= 480 px). Tightens container padding and bumps touch targets
   so a 375 px-wide screen still has a usable content column. */
@media (max-width: 480px) {
  .container { padding: 0 1rem; }
  .hero { padding-top: 5rem; padding-bottom: 2rem; }
  .page-hero { padding: 5rem 0 2rem; }
  .math-block { padding: 0.85rem 0.85rem; margin: 1rem 0; }
  .math-block .label { position: static; display: block; margin-bottom: 0.25rem; }
  /* 44x44 px minimum tap target on the primary CTA. */
  .btn { padding: 0.95rem 1.4rem; min-height: 44px; }
  /* Drop fixed minimums on the table-scroll wrapper so very narrow
     screens (<= 360 px) still don't show a double scrollbar. */
  .table-scroll > table { min-width: 360px; }
  /* Eq-tile + svg-schema: keep them inside the 1rem container padding. */
  .eq-tile { padding: 1rem 1rem; }
  .svg-schema { max-width: 100%; padding: 0; }
}

/* Narrow phone (<= 380 px). Last-resort knock-down for iPhone SE
   portrait, small Androids, foldables in folded mode. */
@media (max-width: 380px) {
  h1, .page-hero h1 { font-size: clamp(2rem, 8vw, 2.4rem); }
  .hero-deck { gap: 0.75rem; }
  .nav .brand { font-size: 0.95rem; }
}

/* =============================================================
   Home hero on mobile (<= 720 px)
   Order: eyebrow + H1, then arm video peeking out, then the 4
   system-overview cards that sit on top of the video's lower
   half. The cards stay full (icon + label + text) but become a
   tight 2 x 2 grid.
============================================================= */
@media (max-width: 720px) {
  .hero {
    padding-top: 5.5rem;
    padding-bottom: 2.25rem;
    min-height: 0;
  }

  /* Single column flow: eyebrow + H1 + video + cards + CTA + rows. */
  .hero-grid { display: block; }
  .hero-text { display: block; }

  /* Video sits in the natural flow right after the headline. */
  .hero-arm {
    margin: 1.25rem auto -3.5rem;     /* negative bottom lets cards overlap */
    max-width: 320px;
    position: relative;
    z-index: 1;
  }
  .hero-arm video {
    opacity: 1;
    filter: drop-shadow(0 12px 28px rgba(47, 67, 196, 0.14));
  }

  /* Cards overlap the bottom of the video, so the upper part of the arm
     peeks out above the card grid. */
  .hero-text > .hero-deck {
    position: relative;
    z-index: 2;
    margin-top: 0;
  }

  .hero-deck {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.6rem;
    margin: 0 0 1.5rem;
  }
  .hd-card { padding: 0.85rem 0.95rem; background: var(--surface); }
  .hd-card .hd-head { gap: 0.45rem; margin-bottom: 0.45rem; }
  .hd-card .hd-icon { width: 26px; height: 26px; border-radius: 6px; }
  .hd-card .hd-icon svg { width: 14px; height: 14px; }
  .hd-card .hd-label { font-size: 0.65rem; letter-spacing: 0.1em; }
  .hd-card .hd-text { font-size: 0.8rem; line-height: 1.45; }
  /* Always reveal the top accent stripe on touch. */
  .hd-card::before { transform: scaleX(1); }

  /* Controller CTA deck stacks. */
  .cta-deck { grid-template-columns: 1fr; gap: 0.6rem; }

  /* hero-row tag chips: keep them compact on a single line if possible. */
  .hero-row { gap: 0.4rem; }
  .hero-row-label { font-size: 0.7rem; }
  .hero-row .tag { font-size: 0.78rem; padding: 0.25rem 0.55rem; }
}

@media (max-width: 480px) {
  /* On the very smallest phones drop the card body font a touch so all
     four blurbs fit above the fold without making cards too tall. */
  .hd-card .hd-text { font-size: 0.74rem; line-height: 1.4; }
  .hero-arm { max-width: 260px; margin-bottom: -3rem; }
}

.page-hero.page-hero-slim {
  padding: 7rem 0 2.25rem;
}
.page-hero.page-hero-slim h1 {
  margin-bottom: 0;
}
