/* ===== WMM project page — mobile-first; sidebar layout ≥1024px ===== */

:root {
  /* UC Berkeley palette — refined */
  --c-blue:           #002b50;
  --c-blue-deep:      #001a33;
  --c-blue-mid:       #3B7EA1;
  --c-blue-soft:      #e6edf3;
  --c-blue-tint:      #f1f5f9;
  --c-gold:           #FDB515;
  --c-gold-deep:      #c9890b;
  --c-gold-soft:      #fff5d6;

  --c-bg:             #fafaf7;     /* warm off-white — paper feel */
  --c-bg-soft:        #f3f2ec;
  --c-bg-card:        #ffffff;
  --c-ink:            #0d1b2a;     /* near-black ink for body */
  --c-text:           #1e2a3a;
  --c-text-soft:      #475569;
  --c-text-mute:      #64748b;
  --c-text-faint:     #94a3b8;
  --c-border:         #e2e1d9;
  --c-border-soft:    #ecebe3;
  --c-line:           #d8d6c9;

  --c-link:           var(--c-blue);
  --c-link-hover:     var(--c-gold-deep);

  /* fluid spacing scale */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 2.5rem;
  --space-8: 3.5rem;
  --space-9: 5rem;
  --space-10: 7rem;

  /* layout */
  --sidebar-w:       186px;   /* thin fixed left bar (>=1024px) */
  --content-max:     1080px;
  --page-max:        1380px;  /* sidebar + content; centers entire page on wide screens */
  --reading-max:     68ch;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;

  /* type — Geist Mono everywhere */
  --font-display: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --font-body:    'Geist Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --font-mono:    'Geist Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  --fs-base: 1.0625rem; /* 17px */
  --lh-base: 1.65;

  /* shadow */
  --shadow-sm: 0 1px 2px rgba(13, 27, 42, 0.04), 0 2px 6px rgba(13, 27, 42, 0.04);
  --shadow-md: 0 4px 12px rgba(13, 27, 42, 0.06), 0 10px 28px rgba(13, 27, 42, 0.05);
  --shadow-lg: 0 10px 30px rgba(13, 27, 42, 0.10), 0 30px 70px rgba(13, 27, 42, 0.08);
}

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

html {
  scroll-behavior: smooth;
  /* keep section anchors below the (eventual) sticky sidebar/topbar */
  scroll-padding-top: 80px;
}

body {
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  background: var(--c-bg);
  color: var(--c-text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* subtle paper-grain background for editorial feel */
  background-image:
    radial-gradient(ellipse 1200px 800px at 80% -10%, rgba(253, 181, 21, 0.06), transparent 60%),
    radial-gradient(ellipse 900px 600px at -10% 30%, rgba(0, 43, 80, 0.04), transparent 70%);
  background-attachment: fixed;
}

a { color: var(--c-link); text-decoration: none; transition: color 0.15s ease; }
a:hover { color: var(--c-link-hover); }

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

::selection { background: var(--c-gold); color: var(--c-blue); }

:focus-visible {
  outline: 2px solid var(--c-gold);
  outline-offset: 3px;
  border-radius: 4px;
}

/* skip link — only visible on keyboard focus */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--c-blue);
  color: #fff;
  padding: var(--space-2) var(--space-4);
  z-index: 200;
  font-weight: 500;
}
.skip-link:focus {
  left: 0;
  outline: 2px solid var(--c-gold);
  outline-offset: 2px;
}

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

/* ===== Layout — sidebar + content column ===== */

.container {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

.sidebar {
  background: var(--c-bg);
  border-bottom: 1px solid var(--c-border);
  padding: var(--space-4);
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* Logo: inline in top-bar; ≥1680px fixed top-left (desktop CSS) */
.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--c-blue);
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.04em;
}
.logo:hover { color: var(--c-gold-deep); text-decoration: none; }

.logo-icon {
  display: block;
  height: 36px;
  width: auto;
  filter: drop-shadow(0 1px 4px rgba(0, 43, 80, 0.18));
}
/* Logo triads: continuous gentle spin (scroll-independent); paused under reduced motion */
@keyframes logo-triad-spin { to { transform: rotate(360deg); } }
.logo-triad {
  transform-box: view-box;
  animation: logo-triad-spin 6s linear infinite;
}
@media (prefers-reduced-motion: reduce) {
  .logo-triad { animation: none; }
}

/* Pose-frame chip shared by desktop rail thumb + mobile bar thumb */
.rail-thumb__chip {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  background: #fff4d2;
  border: 1.5px solid var(--c-gold-deep);
  border-radius: 5px;
  box-shadow: 0 1px 5px rgba(13, 27, 42, 0.22);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}
.rail-thumb__chip svg {
  display: block;
  width: 11px;
  height: 11px;
  transform: rotate(var(--rail-spin, 0deg));   /* spins as you scroll (JS-driven) */
  transform-origin: 50% 55%;                   /* about the triad joint */
}

/* Both rail variants hidden by default; each layout's MQ shows its own */
.rail-thumb { display: none; }
.rail-h { display: none; }

/* pulse+shake live on the inner chip so the outer centering translate survives */
@keyframes rail-thumb-jig {
  0%, 100% { transform: scale(1.18) rotate(-9deg); }
  50%      { transform: scale(1.34) rotate(9deg); }
}

.nav-section { margin-top: var(--space-4); }

.nav-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  list-style: none;
}

.nav-item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 500;
  background: transparent;
  color: var(--c-text-soft);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);   /* rounded-rect pill (desktop overrides to 0) */
  transition: all 0.18s ease;
  letter-spacing: 0.01em;
}
.nav-item:hover {
  background: var(--c-bg-card);
  color: var(--c-blue);
  border-color: var(--c-blue);
}
.nav-item.active,
.nav-item.parent-active {
  background: var(--c-blue);
  color: #fff;
  border-color: var(--c-blue);
}
.nav-item.active .nav-icon,
.nav-item.parent-active .nav-icon { color: var(--c-gold); }
.nav-icon { width: 15px; height: 15px; flex-shrink: 0; }

/* SHORT tab names in narrow bar, FULL names in desktop sidebar (user choice) */
.nav-label-full { display: none; }
.nav-label-short { display: inline; }

/* app short-names: only in ≥1024px left bar */
.nav-sublist { display: none; }

/* ===== Narrow (<1024px) top bar ===== */
@media (max-width: 1023px) {
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 50;
    padding: 8px max(8px, env(safe-area-inset-right)) 20px max(8px, env(safe-area-inset-left));
  }
  .sidebar-inner {
    flex-direction: row;
    align-items: center;
    flex-wrap: nowrap;
    gap: 8px;
  }
  .logo { flex: 0 0 44px; min-height: 44px; justify-content: center; }
  .logo-icon { height: 32px; width: 32px; }
  .nav-section { margin-top: 0; flex: 1 1 auto; min-width: 0; }
  .nav-list {
    flex-wrap: nowrap;
    gap: 2px;
    overflow-x: auto;
    scrollbar-width: thin;
  }
  .nav-list > li { flex: 1 0 auto; }
  .nav-item {
    width: 100%;
    min-width: 44px;
    min-height: 44px;
    justify-content: center;
    padding: 6px clamp(4px, 1vw, 10px);
    font-size: clamp(0.6875rem, 2.8vw, 0.85rem);
    white-space: nowrap;
    gap: 5px;
  }
  .nav-icon { display: none; }

  /* horizontal scroll-progress rail at bar's bottom */
  .rail-h {
    display: block;
    position: absolute;
    left: var(--space-4);
    right: var(--space-4);
    bottom: 7px;
    height: 3px;
    border-radius: 2px;
    background: var(--c-line);
  }
  .rail-h__fill {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: var(--scroll-progress, 0%);
    border-radius: 2px;
    background: linear-gradient(to right, var(--c-gold), var(--c-gold-deep));
    box-shadow: 0 0 6px rgba(253, 181, 21, 0.35);
  }
  .rail-h__thumb {
    position: absolute;
    top: 50%;
    /* clamp: chip fully on-screen at 0%/100% */
    left: clamp(14px, var(--scroll-progress, 0%), calc(100% - 14px));
    transform: translate(-50%, -50%);
    z-index: 2;
    padding: 6px;
    cursor: grab;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
  }
  .rail-h__thumb.dragging { cursor: grabbing; }
  .rail-h__thumb.dragging .rail-thumb__chip { transform: scale(1.2); }
}

.main-content {
  flex: 1 1 auto;
  width: 100%;
  padding: var(--space-6) var(--space-4) var(--space-8);
}

/* space-10 between top-level sections (space-9 felt too dense) */
.main-content > section,
.main-content > aside {
  max-width: var(--content-max);
  margin-inline: auto;
  margin-bottom: var(--space-10);
}

/* ===== HERO ===== */

.hero-section {
  padding-block: var(--space-7) var(--space-5);
}
/* hero only: tighter gap so teaser sits close (overrides space-9) */
.main-content > .hero-section { margin-bottom: var(--space-5); }

.hero-title-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}

.hero-section h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw + 0.4rem, 3.6rem);
  line-height: 1.05;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--c-blue);
  margin: 0;
}
.hero-section h1 em {
  font-style: normal;
  font-weight: 700;
  color: var(--c-gold-deep);
}

.hero-subtitle {
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 1.95vw + 0.4rem, 2.1rem);
  font-style: normal;
  font-weight: 700;
  color: var(--c-text);
  margin-bottom: var(--space-6);
  letter-spacing: -0.045em;
  line-height: 1.15;
  max-width: none;
}
@media (min-width: 760px) {
  .hero-subtitle { white-space: nowrap; }
}
.hero-subtitle em {
  font-style: italic;
  font-weight: 500;
  color: var(--c-gold-deep);
  font-variation-settings: 'opsz' 96, 'SOFT' 100;
}

.hero-description {
  font-size: 1.35rem;
  color: var(--c-blue);
  line-height: 1.55;
  margin-bottom: var(--space-3);
  max-width: none;
  font-weight: 700;
  letter-spacing: -0.035em;
}
.hero-description a {
  color: var(--c-blue);
  font-weight: 700;
  text-decoration: none;
  background: none;
  padding: 0;
  transition: color 0.2s ease;
}
.hero-description a:hover {
  color: var(--c-gold-deep);
  text-decoration: none;
  background: none;
}
.hero-description sup {
  color: var(--c-gold-deep);
  font-weight: 700;
  font-size: 0.68em;
  margin-left: 1px;
  background: none;
}
.hero-description-small {
  display: inline-block;
  margin-top: var(--space-3);
  font-size: 1.15rem;
  color: var(--c-text);
  font-weight: 600;
  letter-spacing: -0.025em;
}
.hero-description-small sup {
  color: var(--c-gold-deep);
  font-weight: 700;
  font-size: 0.7em;
}
.hero-venue {
  margin: var(--space-3) 0 0;
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--c-gold-deep);
}
.hero-venue span { font-weight: 600; }
@media (max-width: 767px) { .hero-venue { font-size: 0.9375rem; } }

.hero-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  padding-block: var(--space-6) 0;
}

.hero-link-wrapper {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.55rem 1.1rem 0.55rem 0.7rem;
  background: var(--c-bg-card);
  border: 1px solid var(--c-border);
  border-radius: 999px;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}
.hero-link-wrapper:hover {
  transform: translateY(-2px);
  border-color: var(--c-blue);
  box-shadow: var(--shadow-md);
}
.hero-link-wrapper:hover .hero-link {
  background: var(--c-gold);
  color: var(--c-blue);
}
.hero-link-wrapper:hover .hero-link-label {
  color: var(--c-blue);
}

.hero-link {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--c-blue);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}
.hero-link svg { width: 15px; height: 15px; }
.hero-link-label {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--c-text);
  letter-spacing: 0.01em;
}

/* ===== TEASER ===== */

.teaser {
  max-width: var(--content-max);
  margin-inline: auto;
  margin-bottom: var(--space-8);
}
.teaser-stage {
  overflow: hidden;
}

/* ===== QUESTION tagline card ===== */

.question {
  background: var(--c-gold-soft);
  border: 1px solid rgba(253, 181, 21, 0.45);
  border-radius: 14px;
  padding: var(--space-4) var(--space-6);
  width: fit-content;
  max-width: 100%;
  margin-block: var(--space-6);
  margin-inline: auto;
}

.tagline-text {
  font-family: var(--font-display);
  font-size: clamp(1rem, 1.1vw + 0.6rem, 1.45rem);
  font-weight: 700;
  font-style: normal;
  letter-spacing: -0.035em;
  line-height: 1.3;
  color: var(--c-blue);
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-3);
}
.tagline-text * {
  font: inherit !important;
  color: inherit !important;
  letter-spacing: inherit !important;
}
.tagline-line { display: block; }
.tagline-aka-prefix { margin-right: 0.35em; }
.tagline-quote {
  background: linear-gradient(180deg, transparent 55%, rgba(253, 181, 21, 0.6) 55%, rgba(253, 181, 21, 0.6) 96%, transparent 96%);
  padding: 0 0.2em 0.05em;
  border-radius: 3px;
}

/* ===== HERO CTA ROW ===== */
.hero-cta-row {
  max-width: var(--content-max);
  margin-inline: auto;
  margin-block: 0 var(--space-10);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-5);
}
.hero-cta-row .hero-links { padding-block: 0; }
.hero-cta-row .question { margin-block: 0; }

@media (min-width: 760px) {
  .hero-cta-row {
    flex-direction: row;
    align-items: center;
    gap: var(--space-6);
  }
  .hero-cta-row .hero-links {
    flex: 0 0 auto;
    flex-direction: column;
    align-items: stretch;   /* Paper/Code pills share one width */
  }
  .hero-cta-row .question {
    flex: 1 1 auto;
    width: auto;
    max-width: none;
    margin-inline: 0;
  }
}

/* ===== SECTION HEADERS ===== */

.section-header { margin-bottom: var(--space-6); }
.section-header h2 {
  font-family: var(--font-display);
  font-size: clamp(1.55rem, 1.7vw + 0.85rem, 2.2rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--c-blue);
  line-height: 1.1;
  display: inline-flex;
  align-items: baseline;
  gap: var(--space-3);
}
.section-header h2::before {
  content: counter(section, decimal);
  counter-increment: section;
  font-family: var(--font-mono);
  font-size: 0.55em;
  font-weight: 400;
  color: var(--c-gold-deep);
  letter-spacing: 0.05em;
  padding-top: 0.4em;
}

.main-content { counter-reset: section; }
.hero-section { counter-increment: section 0; }  /* don't number hero */

.section-header p {
  font-family: var(--font-display);
  font-style: normal;
  font-size: clamp(1.05rem, 0.5vw + 0.95rem, 1.25rem);  /* match .idea-grounding main body text */
  line-height: 1.65;
  color: var(--c-text-mute);
  margin-top: var(--space-3);
  text-align: justify;
  text-justify: inter-word;
  hyphens: auto;
}

/* ===== IDEA ===== */

.idea-pitch {
  font-family: var(--font-display);
  font-size: clamp(1.15rem, 0.7vw + 1rem, 1.4rem);
  line-height: 1.5;
  color: var(--c-blue);
  font-weight: 500;
  margin: 0 0 var(--space-6);
  padding: var(--space-5) 0 var(--space-5) var(--space-5);
  border-left: 3px solid var(--c-gold);
  letter-spacing: -0.012em;
}
.idea-pitch strong {
  font-weight: 700;
  color: var(--c-blue-deep);
  background: linear-gradient(180deg, transparent 65%, rgba(253,181,21,0.45) 65%);
  padding: 0 0.05em;
}

.idea-grounding {
  font-family: var(--font-display);
  font-size: clamp(1.05rem, 0.5vw + 0.95rem, 1.25rem);
  line-height: 1.65;
  color: var(--c-text);
  max-width: 78ch;
  margin: var(--space-6) auto 0;
  padding: 0;
  text-align: justify;
  text-justify: inter-word;
  hyphens: auto;
}
/* inside the 40/60 grid: drop centering/max-width so it fills the 40% cell */
.state-action-grid .idea-grounding {
  max-width: none;
  margin: 0;
  padding: 0;
}
/* section-1 grounding fills the column; 78ch cap stays for Applications (.lt-grounding) */
#idea > .idea-grounding {
  max-width: none;
}
.idea-grounding strong {
  font-weight: 700;
  color: var(--c-blue-deep);
}
.idea-grounding em {
  font-style: normal;
  font-weight: 600;
  color: var(--c-blue);
  background: linear-gradient(180deg, transparent 65%, rgba(253,181,21,0.45) 65%);
  padding: 0 0.05em;
}
.idea-grounding a {
  color: var(--c-blue);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  font-weight: 600;
}
.idea-grounding a:hover { color: var(--c-gold-deep); }

/* ===== SE(3) SCENE ===== */

.se3-scene {
  position: relative;
  width: 100%;
  max-width: var(--content-max);
  margin: var(--space-6) auto var(--space-7);
}
/* stage = canvas positioning context for hint + toggle */
.se3-stage {
  position: relative;
  width: 100%;
}

.se3-canvas {
  display: block;
  width: 100%;
  /* 21:9 for the full-width scene */
  aspect-ratio: 21 / 9;
  background: transparent;
  cursor: grab;
  /* touch: one-finger scrolls page, two-finger orbits (set in JS) */
  touch-action: pan-y;
}
.se3-canvas.is-dragging { cursor: grabbing; }

.se3-hint {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(13, 27, 42, 0.72);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  pointer-events: none;        /* never intercepts orbit drag */
  opacity: 0;
  transition: opacity 0.5s ease 0.3s;  /* fade in 0.3s after canvas appears */
  white-space: nowrap;
}
.se3-scene.is-visible .se3-hint { opacity: 1; }
.se3-scene.has-interacted .se3-hint { opacity: 0; transition-delay: 0s; }
.se3-hint-icon {
  width: 14px; height: 14px; fill: currentColor; flex-shrink: 0;
}
@media (prefers-reduced-motion: reduce) {
  .se3-hint { display: none; }
}

.se3-controls {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 2;
  pointer-events: none;        /* row itself is inert; children opt in */
}

.se3-toggle {
  pointer-events: auto;        /* re-enable: row was inert */
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid rgba(13, 27, 42, 0.10);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(4px);
  color: var(--c-ink);
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.18s ease, transform 0.12s ease, background 0.18s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.se3-toggle:hover  { opacity: 1.0; background: rgba(255, 255, 255, 0.95); }
.se3-toggle:active { transform: scale(0.92); }
.se3-toggle:focus-visible { outline: 2px solid var(--c-gold); outline-offset: 2px; }
.se3-toggle-icon { width: 16px; height: 16px; fill: currentColor; }

.se3-frame-timing {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.se3-frame-timing:hover { opacity: 0.65; }
.se3-frame-timing:focus-within { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  .se3-frame-timing { transition: none; }
}

.se3-frame-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  min-height: 44px;
  flex-shrink: 0;
  border: 1px solid rgba(13, 27, 42, 0.10);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--c-ink);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  white-space: nowrap;
  pointer-events: auto;
}
.se3-frame-control input {
  width: 4em;
  min-height: 44px;
  padding: 0 4px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  font: inherit;
}
.se3-frame-control input:focus-visible {
  outline: 2px solid var(--c-gold);
  outline-offset: 1px;
}
@media (max-width: 700px) {
  .se3-controls {
    position: relative;
    bottom: auto;
    left: auto;
    transform: none;
    justify-content: center;
  }
  .se3-controls .se3-hint { display: none; }
}

.se3-fallback {
  text-align: center;
  color: var(--c-text-mute);
  font-family: var(--font-mono);
  padding: var(--space-6);
}

/* ===== STATE vs ACTION ===== */

#state-action {
  position: relative;
  width: 100%;
  margin: var(--space-6) auto var(--space-7);
}
.state-action-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
  align-items: start;
  font-family: var(--font-display);
  font-size: clamp(1.05rem, 0.5vw + 0.95rem, 1.25rem);
  max-width: none;
  margin-inline: auto;
  padding: 0;
}
@media (min-width: 820px) {
  .state-action-grid {
    /* 2fr 3fr (≈40/60): gap subtracts from tracks; %+gap overflows */
    grid-template-columns: 2fr 3fr;
    gap: var(--space-3);
    align-items: center;
  }
}

.state-action-h {
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 0.6vw + 1.2rem, 1.7rem);
  font-weight: 700;
  color: var(--c-ink);
  letter-spacing: -0.01em;
  margin: 0 0 var(--space-3);
  line-height: 1.2;
}

.legend-swatch {
  display: inline-block;
  width: 0.75em;
  height: 0.75em;
  border-radius: 2px;
  vertical-align: -0.05em;
  margin-right: 0.25em;
  border: 1px solid rgba(0, 0, 0, 0.12);
}
.legend-swatch--state  { background: #002b50; }
.legend-swatch--target { background: #FDB515; }

.state-action-viz {
  width: 100%;
}
.gripper-stage {
  position: relative;
  width: 100%;
  /* transparent, matches .se3-stage */
  background: transparent;
  overflow: hidden;
}
.gripper-canvas {
  display: block;
  width: 100%;
  /* 16:10 here ≈ text-column height; FOV auto-adapts (ResizeObserver) */
  aspect-ratio: 16 / 10;
  background: transparent;
  cursor: grab;
  touch-action: pan-y;
}
.gripper-canvas.is-dragging { cursor: grabbing; }
.gripper-fallback {
  padding: var(--space-4);
  text-align: center;
  color: var(--c-text-soft);
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

/* ===== POSE LANGUAGE figure ===== */

#pose-language {
  position: relative;
  width: 100%;
  max-width: var(--content-max);
  margin: var(--space-10) auto var(--space-10);
  padding-inline: 0;
}

/* 3-up: token | connector column | grid; stacks on mobile */
.pose-language-stage {
  --cell-w: 50px;
  --cell-h: 46px;
  --cell-gap: 22px;
  --row-gap: 18px;
  /* context context | t-1 t t+1 | dots | t+N-1 | row-label */
  --grid-cols:
    var(--cell-w) var(--cell-w)
    var(--cell-w) var(--cell-w) var(--cell-w)
    48px
    var(--cell-w)
    max-content;
  position: relative;
  display: grid;
  gap: 0;
  grid-template-columns: 1fr;       /* mobile: stack */
  margin: 0;
  align-items: stretch;
}
@media (min-width: 820px) {
  .pose-language-stage {
    grid-template-columns:
      minmax(0, 1fr)        /* grid (left) */
      18px                  /* visual gap to token */
      max-content;          /* token (right, hug content) */
    column-gap: 0;
  }
  /* force grid to col 1, token to col 3 (visual flip, DOM unchanged) */
  .pose-card--grid  { grid-column: 1; grid-row: 1; }
  .pose-card--token { grid-column: 3; grid-row: 1; }
}

.pose-card {
  position: relative;
  padding: 16px 14px 14px;
  background: #f4f3ec;       /* soft paper-gray, matches the figure */
  border: 1px solid #d8d6c9;
  border-radius: 12px;
}
/* grid plate: no chrome — cells float like the paper figure */
.pose-card--grid {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 6px 0 4px;
}

/* Plate header: mono caps at top-left */
.pose-card__h {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0 0 2px;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--c-ink);
}

/* --- token zoom card --- */
.pose-card--token {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  align-self: center;
  padding: 4px 12px 12px;
}

.token-section {
  position: relative;
  padding: 14px 12px 12px;
  background: #ffffff;
  border: 1.5px dashed var(--c-line);
  border-radius: 12px;
}
/* “Value”/“Attr” pill; suppressed when data-pill missing */
.token-section:not([data-pill])::before { content: none; }
.token-section::before {
  content: attr(data-pill);
  position: absolute;
  top: -11px;
  left: 12px;
  padding: 3px 11px;
  background: #ffffff;
  border: 1px solid var(--c-border);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--c-text-soft);
}
.token-section::after {
  content: attr(data-meta);
  position: absolute;
  top: -13px;
  right: 12px;
  padding: 3px 11px 4px;
  background: var(--c-gold);
  color: var(--c-blue);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.84rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  box-shadow: 0 1px 0 rgba(13, 27, 42, 0.12);
}
.token-section:not([data-meta])::after { content: none; }

/* gold When/What pills pair with the Where badge above */
.row-badge {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  margin-left: auto;          /* push to the RIGHT edge of the row */
  padding: 2px 8px 3px;
  background: var(--c-gold);
  color: var(--c-blue);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  box-shadow: 0 1px 0 rgba(13, 27, 42, 0.10);
}

.token-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
}
.token-row + .token-row { margin-top: 4px; }

.token-icon {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  color: var(--c-ink);
}
.token-icon--triad {
  /* keep the triad arrows crisp; no drop-shadow */
  filter: none;
}

.token-row__text {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 1.02rem;
  color: var(--c-ink);
  min-width: 0;
}
.token-row__key {
  font-size: 1.08rem;
  font-weight: 700;
}
.token-row__key em {
  font-style: italic;
  font-weight: 700;
  color: var(--c-ink);
}

   /* no extra cue; the dashed lines speak */

/* --- dashed zoom connector (endpoints by pose-zoom-lines.js) --- */
.pose-zoom-connector {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  z-index: 1;
}
.pose-zoom-connector .zl {
  stroke: var(--c-line);
  stroke-width: 2.6;
  stroke-dasharray: 5 5;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

@media (max-width: 1199px) {
  .pose-zoom-connector .zl {
    stroke: #b78c3b;
    stroke-width: 1.8;
  }
}

/* --- token grid plate --- */
.pose-card--grid {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 18px 18px 12px;
}

.token-grid {
  display: grid;
  gap: var(--row-gap);
}

.token-grid__row {
  display: grid;
  grid-template-columns: var(--grid-cols);
  align-items: center;
  gap: var(--cell-gap);
  position: relative;
}

.token-grid__label {
  padding-left: 14px;
  font-family: var(--font-mono);
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: 0.005em;
  color: var(--row-color);
  line-height: 1.15;
  white-space: normal;
}

.cell {
  position: relative;
  width: var(--cell-w);
  height: var(--cell-h);
  border-radius: 8px;
  background: var(--cell-fill);
  border: 3px solid var(--cell-stroke);
  box-shadow: 0 1px 0 rgba(13, 27, 42, 0.04);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: cell-pulse 6s calc(var(--i, 0) * 0.55s) infinite ease-in-out;
}

.cell-triad {
  width: 68%;
  height: 68%;
  display: block;
  pointer-events: none;
}

.cell--ctx {
  background: transparent;
  border-style: dashed;
  border-width: 2.5px;
  border-color: var(--cell-stroke);
}
/* dashed context cells: faded triad */
.cell--ctx .cell-triad { opacity: 0.45; }

/* zoom-anchor cell: static bright ring (target of the dashed lines) */
.cell--zoom-anchor {
  box-shadow:
    0 0 0 3px rgba(255, 255, 255, 0.95),
    0 0 0 6px var(--cell-stroke),
    0 2px 4px rgba(13, 27, 42, 0.10);
  animation: none;
}

.cell--dots {
  background: transparent;
  border: none;
  width: auto;
  box-shadow: none;
  animation: none;
}
.dots-h, .dots-v { display: block; }
.dots-h {
  width: 100%;
  height: 14px;
  fill: var(--c-ink);
}
.dots-v {
  width: 12px;
  height: 36px;
  fill: var(--c-ink);
}

@keyframes cell-pulse {
  0%, 100% { filter: brightness(1.00); transform: translateY(0); }
  50%      { filter: brightness(1.05); transform: translateY(-0.5px); }
}
@media (prefers-reduced-motion: reduce) {
  .cell { animation: none; }
}

/* Row palette (page-wide; .token-grid__row + .train-row + .inf-row), user-chosen: action=teal, state=navy, object=gold, joint=brown */
.token-grid__row[data-entity="action"],
.train-row[data-entity="action"],
.inf-row[data-entity="action"] {
  --cell-fill:   #c1dcd9;
  --cell-stroke: #3f8f8c;
  --row-color:   #265f5d;
}
.token-grid__row[data-entity="state"],
.train-row[data-entity="state"],
.inf-row[data-entity="state"] {
  --cell-fill:   #c8d6e6;
  --cell-stroke: #3B7EA1;
  --row-color:   #002b50;
}
.token-grid__row[data-entity="object"],
.train-row[data-entity="object"],
.inf-row[data-entity="object"] {
  --cell-fill:   #ffe7a3;
  --cell-stroke: #c9890b;
  --row-color:   #8a5b08;
}
.token-grid__row[data-entity="joint"],
.train-row[data-entity="joint"],
.inf-row[data-entity="joint"] {
  --cell-fill:   #ead4b3;
  --cell-stroke: #8a5a2b;
  --row-color:   #6b4520;
}

/* ⋮ row implies more entity rows; same --grid-cols so dots align */
.token-grid__more {
  display: grid;
  grid-template-columns: var(--grid-cols);
  align-items: center;
  gap: var(--cell-gap);
  pointer-events: none;
}
.token-grid__more > span {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 36px;
}

/* time axis: tick per cell column, arrow at right; same --grid-cols */
.token-grid__axis {
  display: grid;
  grid-template-columns: var(--grid-cols);
  align-items: center;
  gap: var(--cell-gap);
  margin-top: 22px;
  padding-top: 18px;
  font-family: var(--font-mono);
  font-size: 1.02rem;
  color: var(--c-ink);
  text-align: center;
  position: relative;
}
/* axis SVG endpoints written by pose-axis-line.js */
.axis-line {
  position: absolute;
  top: -2px;
  left: 0;
  width: 100%;
  height: 20px;
  overflow: visible;
  pointer-events: none;
}
.axis-line .axis-path {
  stroke: var(--c-ink);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}
.axis-line .axis-arrow {
  fill: var(--c-ink);
}
/* per-label tick mark, drawn above the label text */
.token-grid__axis .ax {
  position: relative;
}
.token-grid__axis .ax::before {
  content: "";
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  width: 2.5px;
  height: 8px;
  background: var(--c-ink);
  border-radius: 1px;
}
/* context labels/ticks: softer to match wavy line */
.token-grid__axis .ax--ctx {
  color: var(--c-text-soft);
  font-weight: 600;
  font-size: 0.92rem;
  letter-spacing: 0.04em;
  text-transform: lowercase;
}
.token-grid__axis .ax--ctx::before {
  opacity: 0.55;
  height: 6px;
  top: -12px;
}
/* trailing spacer lets the arrow head pass the last column */
.token-grid__axis .ax--time::before { display: none; }
.token-grid__axis .ax em {
  font-style: italic;
  font-weight: 700;
  color: var(--c-ink);
}

.pose-language-foot {
  margin-top: var(--space-7);
  max-width: none;
  margin-inline: auto;
}

/* ===== FLEXIBLE SEQ MODELING — (B) Training ===== */
#flexible-modeling {
  position: relative;
  width: 100%;
  max-width: 1040px;
  margin: var(--space-10) auto var(--space-10);
  padding-inline: 0;
}
#flexible-modeling .section-header { margin-bottom: var(--space-6); }

.flex-step-h {
  font-family: var(--font-mono);
  /* h3 step tier: between h2 and h4, clearly above 20px body */
  font-size: clamp(1.4rem, 0.6vw + 1.2rem, 1.7rem);
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--c-ink);
  margin: 0 0 var(--space-4);
}

/* in | arrow | WMM | arrow | out; top-aligned so arrows line up with grids */
.flex-train-stage {
  display: grid;
  grid-template-columns: auto 36px auto 36px auto;
  align-items: start;
  justify-content: center;
  column-gap: 18px;
  margin: 0;
  background: var(--c-bg-soft);
  border: 1px solid var(--c-border);
  border-radius: 14px;
  padding: 26px 22px;
}

.train-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.flex-caption {
  font-family: var(--font-mono);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--c-text-soft);
  text-align: center;
  line-height: 1.35;
  margin: 0;
}
.flex-caption strong { color: var(--c-ink); font-weight: 800; }
.flex-caption em { font-style: italic; color: var(--c-text-soft); font-weight: 600; }

.flex-train-note {
  font-family: var(--font-body);
  font-size: clamp(1.05rem, 0.5vw + 0.95rem, 1.25rem);
  line-height: 1.65;
  color: var(--c-text);
  max-width: 70ch;
  margin: var(--space-5) 0 0;
}

.train-grid {
  /* match (A) figure cell scale — one visual family */
  --t-cell-w: 50px;
  --t-cell-h: 46px;
  --t-cell-gap: 14px;
  --t-row-gap: 14px;
  display: grid;
  gap: var(--t-row-gap);
}
.train-row {
  display: grid;
  /* ctx ctx | t-1 t | dots | t+N-1  ==  6 cells per row */
  grid-template-columns:
    var(--t-cell-w) var(--t-cell-w)
    var(--t-cell-w) var(--t-cell-w)
    32px
    var(--t-cell-w);
  gap: var(--t-cell-gap);
  align-items: center;
}

.train-row .cell {
  width: var(--t-cell-w);
  height: var(--t-cell-h);
  border-radius: 7px;
  border-width: 2.5px;
  animation: none;             /* no pulse here — keep the diagram still */
  overflow: hidden;
}
.train-row .cell--dots {
  width: auto;
  border: none;
  background: transparent;
  overflow: visible;
}
.train-row .cell--dots .dots-h {
  width: 100%;
  height: 11px;
}

/* per-token noise overlay: fractal-noise data URI; opacity = --noise (0..1) */

/* typed --noise so it can transition */
@property --noise {
  syntax: '<number>';
  inherits: true;
  initial-value: 0;
}

.cell--noisy { position: relative; transition: --noise 0.55s ease-in-out, background-position 0.6s ease-in-out; }
.cell--noisy .cell-triad { position: relative; z-index: 1; }
.cell--noisy .cell-triad { opacity: calc(1 - var(--noise, 0) * 0.95); transition: opacity 0.55s ease-in-out; }
.cell--noisy .noise-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='1.8' numOctaves='3' seed='11' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.10  0 0 0 0 0.10  0 0 0 0 0.10  0 0 0 1.6 -0.2'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  background-size: 80px 80px;
  /* clamp visible opacity so mid noise still reads */
  opacity: clamp(0, calc(var(--noise, 0) * 1.05), 1);
  mix-blend-mode: multiply;
  transition: opacity 0.55s ease-in-out, background-position 0.6s ease-in-out;
}

/* ===== (B) TRAINING animation (states set by training-animation.js) ===== */

.flex-train-stage {
  position: relative;
  transition: background 0.4s ease-out;
}
.flex-train-stage::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(253, 181, 21, 0.16), transparent 60%);
  opacity: 0;
  border-radius: inherit;
  transition: opacity 0.55s ease-out;
}
.flex-train-stage.is-flowing::before { opacity: 1; }

.flex-arrow svg path {
  transition: stroke 0.25s ease-out, filter 0.25s ease-out;
}
.flex-train-stage.is-flowing .flex-arrow svg path {
  stroke: var(--c-gold-deep);
  filter: drop-shadow(0 0 3.5px rgba(253, 181, 21, 0.85));
}

.flex-arrow__pop {
  fill: #FFE26A;             /* warm gold core, lighter than the deep gold */
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
  will-change: transform, opacity;
  filter:
    drop-shadow(0 0 1.5px #fff8d6)
    drop-shadow(0 0 3.5px rgba(253, 181, 21, 0.95))
    drop-shadow(0 0 8px rgba(253, 181, 21, 0.65))
    drop-shadow(0 0 14px rgba(253, 181, 21, 0.32));
}
.flex-train-stage.is-flowing .flex-arrow__pop {
  animation: train-arrow-pop 0.86s ease-out infinite;
}
@keyframes train-arrow-pop {
  /* arc timeline; viewBox 0 0 40 22 → 1 unit ≈ 1px */
  0%   { transform: translate(0px,  0px)  scale(0.10); opacity: 0; }
  10%  { transform: translate(1px, -5px)  scale(1.55); opacity: 1; }
  28%  { transform: translate(8px, -2px)  scale(1.10); opacity: 1; }
  46%  { transform: translate(13px, 0px)  scale(0.95); opacity: 1; }
  64%  { transform: translate(18px, -3px) scale(1.18); opacity: 1; }
  82%  { transform: translate(24px, -1px) scale(1.05); opacity: 1; }
  95%  { transform: translate(28px, 0px)  scale(0.95); opacity: 0.85; }
  100% { transform: translate(30px, 0px)  scale(0.10); opacity: 0; }
}

.model-box {
  position: relative;
  isolation: isolate;
  transition: box-shadow 0.25s ease-out, filter 0.25s ease-out, transform 0.4s ease-out;
}
.model-box::before {
  content: '';
  position: absolute;
  inset: -14px;
  border-radius: 22px;
  background: radial-gradient(closest-side,
              rgba(253, 181, 21, 0.55),
              rgba(253, 181, 21, 0.18) 55%,
              transparent 80%);
  opacity: 0;
  pointer-events: none;
  z-index: -1;
  transform: scale(0.85);
}
.model-box.is-shining::before { animation: wmm-aura 1.5s ease-out; }
@keyframes wmm-aura {
  0%   { opacity: 0;    transform: scale(0.80); }
  35%  { opacity: 0.95; transform: scale(1.15); }
  100% { opacity: 0;    transform: scale(1.45); }
}
.model-box::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 12px;
  border: 2px solid var(--c-gold);
  opacity: 0;
  pointer-events: none;
  z-index: -1;
}
.model-box.is-shining::after { animation: wmm-burst 1.5s ease-out; }
@keyframes wmm-burst {
  0%   { opacity: 0;   transform: scale(1.00); border-width: 2px; }
  18%  { opacity: 0.8; transform: scale(1.04); border-width: 3px; }
  100% { opacity: 0;   transform: scale(1.45); border-width: 0.5px; }
}
.model-box.is-shining {
  animation: wmm-shine 1.5s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes wmm-shine {
  0%   { box-shadow: 0 2px 8px rgba(13, 27, 42, 0.18);                                                                              filter: brightness(1)    saturate(1);    transform: scale(1); }
  35%  { box-shadow: 0 0 0 4px rgba(253, 181, 21, 0.36), 0 0 36px 12px rgba(253, 181, 21, 0.60), 0 4px 14px rgba(13, 27, 42, 0.30); filter: brightness(1.22) saturate(1.18); transform: scale(1.025); }
  65%  { box-shadow: 0 0 0 3px rgba(253, 181, 21, 0.22), 0 0 26px 8px rgba(253, 181, 21, 0.40),  0 3px 12px rgba(13, 27, 42, 0.25); filter: brightness(1.12) saturate(1.10); transform: scale(1.012); }
  100% { box-shadow: 0 2px 8px rgba(13, 27, 42, 0.18);                                                                              filter: brightness(1)    saturate(1);    transform: scale(1); }
}

.model-box__label {
  background-image: linear-gradient(100deg, #ffffff 28%, #FDB515 50%, #ffffff 72%);
  background-size: 280% 100%;
  background-position: 100% 0;
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  color: #ffffff;             /* fallback */
}
.model-box.is-shining .model-box__label {
  animation: wmm-text-shimmer 1.5s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes wmm-text-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* re-noise kiss: dark ink jolt + noise slam (JS drives --noise) */
.train-block--in .cell.is-rekissing {
  animation: train-cell-noise-jolt 0.50s cubic-bezier(0.22, 1.3, 0.36, 1) both;
}
@keyframes train-cell-noise-jolt {
  0%   { transform: scale(1)    translate(0, 0); box-shadow: 0 0 0 0 rgba(13, 27, 42, 0); }
  20%  { transform: scale(1.16) translate(-0.8px, 0.6px);
         box-shadow: 0 0 0 1.5px rgba(13, 27, 42, 0.45), 0 2px 10px rgba(13, 27, 42, 0.20); }
  40%  { transform: scale(0.96) translate(0.8px, -0.5px);
         box-shadow: 0 0 0 1px rgba(13, 27, 42, 0.22); }
  100% { transform: scale(1)    translate(0, 0); box-shadow: 0 0 0 0 rgba(13, 27, 42, 0); }
}
/* suppress slow transition during re-noise so the pop is instant */
.train-block--in .cell.is-rekissing .noise-overlay {
  transition: opacity 0.06s linear;
}
.train-block--in .cell.is-rekissing .noise-overlay {
  animation: train-noise-amp 0.50s ease-out both;
}
@keyframes train-noise-amp {
  0%   { filter: contrast(1)    saturate(1); }
  20%  { filter: contrast(1.45) saturate(1.20); }
  100% { filter: contrast(1)    saturate(1); }
}

/* right block invisible until first emerge; still occupies layout */
.train-block--out .cell:not(.cell--dots) {
  transition: opacity 0.28s ease-out, transform 0.28s ease-out;
}
.train-block--out .cell--dots,
.train-block--out .flex-caption {
  transition: opacity 0.45s ease-out, transform 0.45s ease-out;
}
.train-block--out.is-hidden .cell:not(.cell--dots) {
  opacity: 0;
  transform: scale(0.55);
  pointer-events: none;
}
.train-block--out.is-hidden .cell--dots,
.train-block--out.is-hidden .flex-caption {
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
}
.train-block--out.is-emerging .cell--dots,
.train-block--out.is-emerging .flex-caption {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.45s ease-out 0.15s, transform 0.45s ease-out 0.15s;
}
.train-block--out.is-emerging .cell:not(.cell--dots) {
  transition: none;
  animation: train-cell-emerge 0.65s cubic-bezier(0.22, 1.45, 0.34, 1) both;
}
@keyframes train-cell-emerge {
  0%   { opacity: 0; transform: scale(0.40) rotate(-8deg);
         box-shadow: 0 0 0 0 rgba(253, 181, 21, 0); }
  40%  { opacity: 1; transform: scale(1.16) rotate(3deg);
         box-shadow: 0 0 0 5px rgba(253, 181, 21, 0.45), 0 0 22px 6px rgba(253, 181, 21, 0.50); }
  70%  { opacity: 1; transform: scale(0.97) rotate(-1deg);
         box-shadow: 0 0 0 2px rgba(253, 181, 21, 0.18), 0 0 10px 2px rgba(253, 181, 21, 0.22); }
  100% { opacity: 1; transform: scale(1)    rotate(0);
         box-shadow: 0 0 0 0 rgba(253, 181, 21, 0); }
}

.train-block--out.is-emerging .cell:not(.cell--dots) .cell-triad {
  animation: train-triad-pop 0.65s ease-out both;
  animation-delay: inherit;   /* match the parent cell's stagger */
}
@keyframes train-triad-pop {
  0%   { filter: drop-shadow(0 0 0 rgba(253, 181, 21, 0))    brightness(1.4); }
  40%  { filter: drop-shadow(0 0 4px rgba(253, 181, 21, 0.85)) brightness(1.15); }
  100% { filter: drop-shadow(0 0 0 rgba(253, 181, 21, 0))    brightness(1); }
}

@media (prefers-reduced-motion: reduce) {
  .flex-arrow__pop,
  .model-box.is-shining,
  .model-box.is-shining::before,
  .model-box.is-shining::after,
  .model-box.is-shining .model-box__label,
  .train-block--in .cell.is-rekissing,
  .train-block--in .cell.is-rekissing .noise-overlay,
  .train-block--out.is-emerging .cell:not(.cell--dots),
  .train-block--out.is-emerging .cell:not(.cell--dots) .cell-triad { animation: none !important; }
  .train-block--out.is-hidden .cell:not(.cell--dots),
  .train-block--out.is-hidden .cell--dots,
  .train-block--out.is-hidden .flex-caption { opacity: 1; transform: none; }
  .flex-train-stage::before { display: none; }
  .cell--noisy, .cell--noisy .cell-triad, .cell--noisy .noise-overlay { transition: none; }
  .train-block--out .cell:not(.cell--dots) { transition: none; }
}

.flex-arrow {
  width: 36px;
  height: 22px;
  color: var(--c-text-soft);
  display: flex;
  align-items: center;
  justify-content: center;
}
.flex-arrow svg { width: 100%; height: 100%; display: block; }

.model-box {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 14px 22px;
  min-width: 110px;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #ffffff;
  background: var(--c-blue);
  border: 2px solid var(--c-gold);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(13, 27, 42, 0.18);
  line-height: 1.3;
}
.model-box__label { display: block; }
/* arrows/box centered on the GRID stack (~113px half-height) */
.flex-arrow { margin-top: calc(113px - 11px); }
.model-box  { margin-top: calc(113px - 60px); }

@media (max-width: 900px) {
  .flex-train-stage {
    grid-template-columns: 1fr;
    row-gap: 14px;
    padding: 18px 14px;
  }
  .flex-train-stage > * { justify-self: center; }
  .flex-arrow svg { transform: rotate(90deg); }
  .flex-arrow, .model-box { margin-top: 0; }
}

/* --- (C) INFERENCE masks --- */
.flex-step-h--c {
  margin-top: var(--space-7);
  display: flex;
  align-items: center;
  gap: 0.9em;
  flex-wrap: wrap;
}

.inf-legend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.80rem;
  font-weight: 600;
  color: var(--c-text-soft);
  letter-spacing: 0.02em;
  text-transform: none;
  margin-left: 0.6em;
}

.inf-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.inf-item {
  display: grid;
  grid-template-columns: 1fr 30%;
  align-items: center;
  column-gap: var(--space-5);
  padding: var(--space-3) 0;
  border-top: 1px dashed var(--c-border);
}
.inf-item:first-child { border-top: none; padding-top: 0; }

.inf-item__h {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--c-ink);
  margin: 0 0 8px;
}
.inf-item__num {
  color: var(--c-gold-deep);
  margin-right: 0.45em;
  font-weight: 800;
}
.inf-text p {
  font-family: var(--font-body);
  font-size: clamp(1.05rem, 0.5vw + 0.95rem, 1.25rem);  /* match .idea-grounding main body text */
  line-height: 1.65;
  color: var(--c-text);
  margin: 0;
  max-width: 70ch;
}

.inf-figure {
  --i-cell: clamp(20px, 1.8vw, 28px);
  --i-gap: 6px;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

/* per-figure Noisy/Clean legend column, left of each mini-grid */
.inf-legend-vert {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.60rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--c-text-soft);
  line-height: 1;
  align-self: flex-start;
  height: calc(3 * var(--i-cell) + 2 * var(--i-gap));
  padding: 2px 0;
  min-width: 38px;
}
.inf-legend-vert__top { color: var(--c-gold-deep); }
.inf-legend-vert__bot { color: var(--c-blue); }
.inf-legend-vert__bar {
  flex: 1;
  width: 8px;
  margin: 4px 0;
  background: linear-gradient(180deg, var(--c-gold) 0%, var(--c-blue) 100%);
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px rgba(13, 27, 42, 0.18);
}

.inf-grid {
  display: grid;
  gap: var(--i-gap);
}
.inf-row {
  display: grid;
  grid-template-columns: 70px repeat(5, var(--i-cell));
  gap: var(--i-gap);
}
.inf-row__label {
  align-self: center;
  font-family: var(--font-mono);
  font-size: 0.625rem;
  line-height: 1.2;
  text-align: right;
  white-space: nowrap;
  color: var(--c-text-soft);
}
.inference-time-axis {
  display: block;
  width: 174px;
  padding-top: 4px;
  border-top: 1px solid var(--c-text-mute);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  color: var(--c-text-soft);
}
.inf-grid > .inference-time-axis {
  width: auto;
  margin-left: calc(70px + var(--i-gap));
}
.om-infer-fig .inference-time-axis { flex: 1; width: auto; }
/* .inf-row borders inherit --cell-stroke from the page-wide palette; only FILL is overridden */

.inf-cell {
  display: block;
  width: var(--i-cell);
  height: var(--i-cell);
  border-radius: 5px;
  border: 3px solid var(--cell-stroke);
  box-shadow: 0 1px 0 rgba(13, 27, 42, 0.08);
}
.inf-cell.c-clean { background: var(--c-blue); }
.inf-cell.c-noisy { background: var(--c-gold); }

@media (min-width: 901px) {
  .inf-text { container-type: inline-size; }
  .inf-item__h { font-size: min(1.2rem, 2.8cqw); }
}

@media (max-width: 900px) {
  .inf-item {
    grid-template-columns: 1fr;
    row-gap: var(--space-3);
  }
  .inf-figure { justify-content: flex-start; }
}

/* ===== (D) NETWORK ARCHITECTURE — all DOM+CSS, no SVG/canvas ===== */

/* NOTE: never set container-type on #network-arch — containment scopes the section counter, renders “01” and breaks doc numbering */

.net-arch-stage {
  --net-arch-width: 1092px;
  --net-arch-height: 340px;
  --net-arch-scale: clamp(0.25, calc((100vw - 32px) / var(--net-arch-width)), 1);
  display: block;
  position: relative;
  width: 100%;
  height: calc(var(--net-arch-height) * var(--net-arch-scale));
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  overflow: hidden;
  box-shadow: none;
}
.net-arch-stage > :not(.net-arch-html) {
  display: none !important;
}
.net-arch-html {
  position: relative;
  display: block;
  width: var(--net-arch-width);
  min-width: var(--net-arch-width);
  height: var(--net-arch-height);
  font-family: var(--font-mono);
  background: transparent;
  border-radius: 0;
  overflow: hidden;
  color: #0d1b2a;
  transform: scale(var(--net-arch-scale));
  transform-origin: top left;
}

.html-pose-panel,
.html-wmm-box {
  position: absolute;
  box-sizing: border-box;
}

.html-flow-arrow {
  position: absolute;
  width: 38px;
  height: 26px;
}
.html-flow-arrow::before,
.html-flow-arrow::after {
  content: "";
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
}
.html-flow-arrow::before {
  left: 0;
  width: 27px;
  height: 9px;
  background: #002b50;
  border-radius: 4px 0 0 4px;
}
.html-flow-arrow::after {
  right: 0;
  border-top: 13px solid transparent;
  border-bottom: 13px solid transparent;
  border-left: 13px solid #002b50;
}
.html-flow-arrow--two { left: 197px; top: 156px; }
.html-flow-arrow--three { left: 857px; top: 156px; }

.html-pose-panel {
  width: 170px;
  height: 165px;
  padding: 11px 11px 10px;
  border: 2px solid #e7ddc6;
  border-radius: 14px;
  background: #f5f2e9;
}
.html-pose-panel--input {
  left: 16px;
  top: 95px;
}
.html-pose-panel--output {
  position: relative;
  left: 0;
  top: 0;
}
.html-pose-grid {
  display: grid;
  gap: 6px;
}
.html-pose-row {
  display: grid;
  grid-template-columns: 34px 34px 30px 34px;
  align-items: center;
  gap: 4px;
}
.html-pose-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 2.6px solid var(--pose-stroke);
  border-radius: 8px;
  background: var(--pose-fill);
  box-sizing: border-box;
  overflow: hidden;
  isolation: isolate;
}
.html-pose-cell--dash { border-style: dashed; }
.html-pose-cell--noisy::after {
  content: "";
  position: absolute;
  /* noise extends past padding-box; overflow clips to rounded corners */
  inset: -2px;
  border-radius: 5px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='1.8' numOctaves='3' seed='11' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.10  0 0 0 0 0.10  0 0 0 0 0.10  0 0 0 1.6 -0.2'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  background-size: 64px 64px;
  opacity: clamp(0, calc(var(--noise, 0) * 1.05), 1);
  mix-blend-mode: multiply;
  pointer-events: none;
  z-index: 2;
}
.html-pose-triad {
  width: 28px;
  height: 28px;
  display: block;
  position: relative;
  z-index: 1;
  transform-origin: 50% 52%;
}
/* order matters: --noisy last (ties --dash at equal specificity) so its fade wins */
.html-pose-cell--dash .html-pose-triad { opacity: 0.45; }
.html-pose-cell--noisy .html-pose-triad { opacity: calc(1 - var(--noise, 0) * 0.7); }
.html-pose-cell--zoom-target {
  box-shadow:
    0 0 0 3px rgba(253, 181, 21, 0.24),
    0 0 0 1px rgba(13, 27, 42, 0.08);
}
/* fills/strokes mirror the hero teaser palette */
.html-pose-row--gold { --pose-fill: #d2e8e3; --pose-stroke: #3a9b8c; }
.html-pose-row--blue { --pose-fill: #d4e2ee; --pose-stroke: #5688af; }
.html-pose-row--slate { --pose-fill: #f7e8c4; --pose-stroke: #e0a12e; }
.html-pose-row--gold .html-pose-cell--dash { background: #eef6f3; }
.html-pose-row--blue .html-pose-cell--dash { background: #eef3f8; }
.html-pose-row--slate .html-pose-cell--dash { background: #fbf4e3; }
.html-pose-dots {
  color: #7a8492;
  font-weight: 900;
  letter-spacing: 2px;
}
.html-pose-caption {
  margin-top: 9px;
  font-size: 10px;
  letter-spacing: -0.1px;
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
  white-space: nowrap;
}

.html-wmm {
  position: absolute;
  left: 246px;
  top: 20px;
  width: 600px;
  height: 282px;
}
.html-prefix-pill {
  position: absolute;
  left: -244px;
  top: 36px;
  /* same fixed-size capsule as the attrs pill below (mirror pair) */
  width: 212px;
  box-sizing: border-box;
  text-align: center;
  padding: 6px 6px;
  border: 2px solid #001a33;
  border-radius: 999px;
  background: #002b50;
  color: #ffffff;
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
  z-index: 6;
}
.html-prefix-line {
  position: absolute;
  left: -38px;
  top: 51px;
  width: 562px;
  height: 4px;
  border-radius: 999px;
  background: #002b50;
  z-index: 3;
}
.html-prefix-note {
  position: absolute;
  right: 12px;
  top: 26px;
  color: #002b50;
  font-size: 12px;
  font-weight: 800;
  z-index: 6;
}
.html-wmm-box {
  left: 0;
  top: 0;
  width: 600px;
  height: 282px;
  border: 2.8px solid rgba(253, 181, 21, 0.98);
  border-radius: 24px;
  background: rgba(255, 253, 248, 0.78);
}
.html-wmm-inner {
  position: absolute;
  inset: 7px;
  border: 0;
  border-radius: 21px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.48), rgba(255, 248, 226, 0.22));
  pointer-events: none;
}
.html-wmm-box::before {
  content: none;
}
.html-wmm-box h3 {
  position: absolute;
  left: 0;
  top: 13px;
  width: 100%;
  margin: 0;
  text-align: center;
  font-size: 22px;
  font-weight: 800;
}
.html-prefix-rail {
  position: absolute;
  left: 22px;
  width: 552px;
  top: 51px;
  height: 35px;
  border-top: 0;
  display: grid;
  grid-template-columns: repeat(5, 104px);
  gap: 8px;
  z-index: 5;
}
.html-prefix-rail span {
  position: relative;
}
.html-prefix-rail span::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  width: 5px;
  height: 16px;
  background: #002b50;
  transform: translateX(-50%);
}
.html-prefix-rail span::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 15px;
  transform: translateX(-50%);
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 11px solid #002b50;
}
.html-attn-row {
  position: absolute;
  left: 22px;
  top: 88px;
  display: grid;
  grid-template-columns: repeat(5, 104px);
  gap: 8px;
}
.html-attn-panel {
  position: relative;
  width: 104px;
  height: 176px;
  padding: 0 3px 6px;
  border-radius: 12px;
  background: rgba(248, 249, 247, 0.86);
  box-sizing: border-box;
}
.html-attn-label {
  height: 24px;
  text-align: center;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}
.html-attn-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, 20px);
  grid-template-rows: repeat(4, 19px);
  gap: 3px;
  padding: 4px;
  width: max-content;
  margin-inline: auto;
  border-radius: 10px;
  background: rgba(236, 240, 241, 0.9);
  box-shadow:
    inset 0 0 0 1px rgba(13, 27, 42, 0.05),
    0 1px 0 rgba(13, 27, 42, 0.03);
}
.html-attn-cell {
  display: block;
  width: 20px;
  height: 19px;
  border-radius: 4px;
  box-sizing: border-box;
}
.html-reg-p { background: #b9addb; border: 1.5px dashed #18254a; }
.html-reg-q { background: #97cad4; border: 1.5px dashed #18254a; }
.html-reg-r { background: #cfe6ef; border: 1.5px dashed #18254a; }
.html-cell-token { background: #cacaca; border: 1.5px solid #8b8b8b; }
.html-attn-hl {
  position: absolute;
  z-index: 2;
  pointer-events: none;
  border: 2.5px solid #002b50;
  border-radius: 6px;
}
.html-attn-hl--all {
  inset: 3px;
}
.html-attn-hl--row {
  left: 4px;
  right: 4px;
  height: 19px;
}
.html-r1 { top: 4px; }
.html-r2 { top: 26px; }
.html-r3 { top: 48px; }
.html-r4 { top: 70px; }
.html-attn-hl--col {
  top: 3px;
  bottom: 3px;
  width: 16px;
}
.html-c1 { left: 4px; }
.html-c2 { left: 27px; }
.html-c3 { left: 50px; }
.html-c4 { left: 73px; }
.html-attn-more {
  position: absolute;
  right: -21px;
  top: 49px;
  color: #7a8492;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0;
}
.html-adaln {
  margin: 7px auto 0;
  width: 88px;
  height: 30px;
  position: relative;
  z-index: 3;
  overflow: visible;
  display: grid;
  place-items: center;
  border: 2px solid #FDB515;
  border-radius: 8px;
  background: #fff5d6;
  color: #64748b;
  font-size: 13px;
  font-weight: 800;
}
.html-adaln::before,
.html-adaln::after {
  content: none;
}
.html-adaln-rail {
  position: absolute;
  left: -80px;
  right: 32px;
  bottom: 15px;
  height: 30px;
  display: grid;
  grid-template-columns: 94px repeat(5, 104px);
  gap: 8px;
  pointer-events: none;
  z-index: 4;
}
.html-adaln-rail::after {
  content: "";
  position: absolute;
  left: 0;
  width: 604px;
  bottom: 0;
  height: 4px;
  border-radius: 999px;
  background: #FDB515;
}
.html-adaln-rail span {
  position: relative;
}
.html-adaln-rail span:nth-child(1) { grid-column: 2; }
.html-adaln-rail span:nth-child(2) { grid-column: 3; }
.html-adaln-rail span:nth-child(3) { grid-column: 4; }
.html-adaln-rail span:nth-child(4) { grid-column: 5; }
.html-adaln-rail span:nth-child(5) { grid-column: 6; }
.html-adaln-rail span::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 5px;
  height: 22px;
  background: #FDB515;
  transform: translateX(-50%);
}
.html-adaln-rail span::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 16px;
  width: 16px;
  height: 11px;
  background: #FDB515;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  transform: translateX(-50%);
}
.html-attr-pill {
  position: absolute;
  left: -244px;
  bottom: 2px;
  z-index: 5;
  /* mirror of the prefix pill above */
  width: 212px;
  box-sizing: border-box;
  text-align: center;
  padding: 6px 6px;
  border: 2px solid #c9890b;
  border-radius: 999px;
  background: #FDB515;
  color: #002b50;
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}

.html-output {
  position: absolute;
  left: 906px;
  top: 25px;
  width: 170px;
}
.html-register-legend {
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: 8px;
  margin-bottom: 14px;
  /* ONE dashed card holding both the registers + token keys */
  box-sizing: border-box;
  padding: 8px 10px;
  border: 2px dashed #8b8b8b;
  border-radius: 10px;
  background: #fffefa;
}
.html-legend-box {
  display: grid;
  grid-template-columns: repeat(3, 16px);
  gap: 7px;
  width: auto;
  justify-items: center;
  box-sizing: border-box;
}
.html-legend-box span {
  grid-column: 1 / -1;
  text-align: center;
  font-size: 11px;
  letter-spacing: -0.2px;
  line-height: 1;
}
.html-legend-box i {
  display: block;
  width: 16px;
  height: 18px;
  border-radius: 4px;
  box-sizing: border-box;
}
.html-legend-box--token {
  grid-template-columns: 1fr;
  width: auto;
}


.wmm-box {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  /* top padding fits hook arrows (~28px) + title (~22px) */
  padding: 44px 22px 14px 22px;
  background: #ffffff;
  /* tan OUTER + blue INNER (::before) concentric border, as in the paper */
  border: 2.4px solid #b39a63;
  border-radius: 16px;
  min-height: 220px;
  overflow: visible;             /* trunk extends OUT of left edge */
}
.wmm-box::before {
  content: "";
  position: absolute;
  inset: 4px;
  border: 2.2px solid #1c5fa8;
  border-radius: 12px;
  pointer-events: none;
  z-index: 0;
}

/* 5 attention panels in a row */

.attn-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.attn-grid {
  display: grid;
  grid-template-columns: repeat(4, var(--acell));
  grid-auto-rows: var(--acell);
  gap: var(--agap);
  padding: 3px;
  border-radius: 5px;
  /* warm→cool wash over the padded grid (paper look) */
  background: linear-gradient(135deg,
              rgba(240, 178, 70, 0.16) 0%,
              rgba(214, 206, 196, 0.06) 45%,
              rgba(70, 120, 200, 0.16) 100%);
}

/* overlay geometry: cell w=14, gap=3, pad=4 → x/y = 4 + i*17 */
.attn-hl {
  position: absolute;
  pointer-events: none;
  border: 3px solid #1559a8;
  border-radius: 5px;
  background: rgba(70, 140, 220, 0.05);
  box-shadow: 0 0 0 1px rgba(21, 89, 168, 0.15);
}
.attn-hl--all {
  inset: 1px;
}
/* row/col boxes: pad 3px, step = acell+agap, ~1px margin hairline */
.attn-hl--row {
  left: 1px;
  right: 1px;
  top: calc(2px + var(--row) * (var(--acell) + var(--agap)));
  height: calc(var(--acell) + 2px);
}
.attn-hl--col {
  top: 1px;
  bottom: 1px;
  left: calc(2px + var(--col) * (var(--acell) + var(--agap)));
  width: calc(var(--acell) + 2px);
}

.figure-block {
  background: var(--c-bg-card);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}

.figure-block .figure-image {
  width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  background: var(--c-bg-soft);
}

.figure-block figcaption {
  margin-top: var(--space-4);
  font-size: 0.95rem;
  font-family: var(--font-body);
  color: var(--c-text-mute);
  text-align: center;
  max-width: 70ch;
  margin-inline: auto;
}
.figure-block figcaption b {
  font-weight: 600;
  color: var(--c-blue);
}

/* ===== CAPABILITY GRID (legacy) ===== */

.cap-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}
@media (min-width: 720px) {
  .cap-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); }
}

.cap-card {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--c-blue-deep);
  color: #fff;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  padding: 0;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  display: block;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.cap-card:hover,
.cap-card:focus-visible {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--c-gold);
}
.cap-card:hover .cap-card-cta {
  background: var(--c-gold);
  color: var(--c-blue);
  transform: scale(1.05);
}

.cap-card-stage {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: inherit;
}

.cap-card-roll {
  display: flex;
  width: 100%;
  height: 100%;
  transition: transform 0.55s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}
.cap-card-frame {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  background: var(--c-bg-soft) center/cover no-repeat;
  display: block;
  filter: grayscale(100%) contrast(0.95);
  transition: filter 0.35s ease;
}
.cap-card:hover .cap-card-frame,
.cap-card:focus-visible .cap-card-frame {
  filter: grayscale(0%) contrast(1);
}

.cap-card-stage::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(13, 27, 42, 0.45) 0%, rgba(13, 27, 42, 0.05) 28%, rgba(13, 27, 42, 0.05) 62%, rgba(13, 27, 42, 0.78) 100%);
  pointer-events: none;
}

.cap-card-dots {
  position: absolute;
  top: calc(var(--space-3) + 0.4rem);
  right: calc(var(--space-3) + 1.85rem + 0.55rem);
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  pointer-events: none;
}
.cap-card-dots i {
  display: block;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
  transition: background 0.18s ease, width 0.18s ease;
}
.cap-card-dots i.is-active {
  background: var(--c-gold);
  width: 14px;
  border-radius: 3px;
}

.cap-card-label {
  position: absolute;
  left: var(--space-3);
  right: var(--space-3);
  bottom: var(--space-3);
  z-index: 2;
  font-family: var(--font-display);
  font-size: clamp(0.85rem, 0.4vw + 0.75rem, 1rem);
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.25;
  color: var(--c-blue-deep);
  background: linear-gradient(180deg, transparent 55%, rgba(253, 181, 21, 0.78) 55%, rgba(253, 181, 21, 0.78) 96%, transparent 96%);
  padding: 0.25rem 0.4rem 0.4rem;
  border-radius: 4px;
  width: fit-content;
  max-width: calc(100% - var(--space-6));
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cap-card-cta {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  z-index: 2;
  width: 1.85rem; height: 1.85rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  transition: all 0.18s ease;
}
.cap-card-cta svg { width: 0.95rem; height: 0.95rem; }

.cap-card::before {
  content: 'click';
  position: absolute;
  top: var(--space-3);
  left: var(--space-3);
  z-index: 2;
  padding: 0.22rem 0.65rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: #fff;
  background: rgba(13, 27, 42, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  pointer-events: none;
  transition: opacity 0.18s ease;
}
.cap-card:hover::before { opacity: 0; }

.cap-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: var(--space-4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}
.cap-modal.is-open {
  opacity: 1;
  pointer-events: auto;
}
.cap-modal[hidden] { display: none !important; }

.cap-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(13, 27, 42, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.cap-modal-panel {
  position: relative;
  z-index: 1;
  background: var(--c-bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: min(1200px, 96vw);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(8px) scale(0.985);
  transition: transform 0.22s ease;
}
.cap-modal.is-open .cap-modal-panel { transform: translateY(0) scale(1); }

.cap-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--c-border-soft);
  background: var(--c-bg-card);
}
.cap-modal-titles { min-width: 0; }
.cap-modal-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--c-blue);
  letter-spacing: -0.02em;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cap-modal-sub {
  font-family: var(--font-body);
  font-size: 0.82rem;
  color: var(--c-text-mute);
  margin: 0;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cap-modal-close {
  width: 2rem; height: 2rem;
  border-radius: 50%;
  border: 1px solid var(--c-border);
  background: var(--c-bg-card);
  color: var(--c-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}
.cap-modal-close svg { width: 16px; height: 16px; }
.cap-modal-close:hover {
  background: var(--c-blue);
  color: #fff;
  border-color: var(--c-blue);
}

.cap-modal-stage {
  position: relative;
  background: var(--c-blue-deep);
  aspect-ratio: 16 / 9;
  width: 100%;
  overflow: hidden;
}
.cap-modal-stage iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  transform: scale(1.35);
  transform-origin: center 58%;
}
.cap-modal-stage .cap-modal-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #cfd8dc;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  z-index: 2;
}

.cap-modal-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  width: 2.6rem; height: 2.6rem;
  border-radius: 50%;
  border: 0;
  background: rgba(13, 27, 42, 0.55);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: background 0.15s ease, transform 0.15s ease;
}
.cap-modal-arrow svg { width: 1.1rem; height: 1.1rem; }
.cap-modal-arrow:hover {
  background: var(--c-gold);
  color: var(--c-blue);
  transform: translateY(-50%) scale(1.06);
}
.cap-modal-arrow:disabled {
  opacity: 0.35;
  cursor: default;
}
.cap-modal-arrow--prev { left: var(--space-3); }
.cap-modal-arrow--next { right: var(--space-3); }

.cap-modal-hint {
  position: absolute;
  bottom: var(--space-3);
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  padding: 0.35rem 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: #fff;
  background: rgba(13, 27, 42, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  letter-spacing: 0.04em;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
}
.cap-modal-hint.is-visible { opacity: 1; }
.cap-modal-hint kbd {
  display: inline-block;
  padding: 0 0.35em;
  margin: 0 0.15em;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.75em;
}

.cap-modal-foot {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  background: var(--c-bg-soft);
  border-top: 1px solid var(--c-border-soft);
}
.cap-modal-caption {
  flex: 1 1 auto;
  font-size: 0.95rem;
  color: var(--c-text-soft);
  line-height: 1.6;
  margin: 0;
}
.cap-modal-caption b { color: var(--c-blue); font-weight: 600; }
.cap-modal-counter {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--c-text-mute);
  letter-spacing: 0.06em;
  background: var(--c-bg-card);
  border: 1px solid var(--c-border);
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}

body.cap-modal-open { overflow: hidden; }

@media (max-width: 720px) {
  .cap-modal-panel { width: 100%; max-height: 100vh; border-radius: 0; }
  .cap-modal { padding: 0; }
}

/* ===== VIDEO GALLERY ===== */

.video-gallery-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.video-gallery {
  display: flex;
  gap: var(--space-3);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  padding: 2px;
  scrollbar-width: thin;
  scrollbar-color: var(--c-line) transparent;
}
.video-gallery::-webkit-scrollbar { height: 6px; }
.video-gallery::-webkit-scrollbar-thumb { background: var(--c-line); border-radius: 3px; }
.video-gallery::-webkit-scrollbar-track { background: transparent; }

.video-slot {
  flex: 0 0 auto;
  scroll-snap-align: start;
  position: relative;
  width: min(380px, 78vw);
  aspect-ratio: 4 / 3;
  background: var(--c-blue-deep);
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--c-border);
}

.video-slot .gallery-video,
.video-slot .poster-fallback,
.video-slot .viser-embed,
.video-slot .viser-mount {
  width: 100%; height: 100%; display: block;
}

.video-slot .gallery-video { object-fit: cover; background: var(--c-blue-deep); }
.video-slot .poster-fallback {
  position: absolute; inset: 0;
  object-fit: cover; pointer-events: none;
}

.viser-embed { border: 0; }
.viser-mount {
  display: grid; place-items: center;
  background: var(--c-blue-deep); color: #e0f2fe;
  padding: var(--space-4); text-align: center;
}
.viser-mount--error { background: #7f1d1d; color: #fecaca; }

.gallery-nav {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1px solid var(--c-border);
  background: var(--c-bg-card);
  color: var(--c-text);
  font-size: 0.95rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}
.gallery-nav:hover { background: var(--c-blue); color: #fff; border-color: var(--c-blue); }
.gallery-nav:active { transform: scale(0.92); }

/* code inline */
code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--c-bg-soft);
  color: var(--c-blue);
  padding: 0.12em 0.4em;
  border-radius: 4px;
  border: 1px solid var(--c-border);
}

/* ===== RESULTS ===== */

.results-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
}

.result-block {
  background: var(--c-bg-card);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
}

.result-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.result-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 50%;
  background: var(--c-blue);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0;
  flex-shrink: 0;
}
.result-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--c-blue);
  letter-spacing: -0.025em;
  margin: 0;
}
.result-prose {
  color: var(--c-text);
  font-size: 1rem;
  line-height: 1.7;
  margin-bottom: var(--space-5);
}
.result-figure {
  margin: 0;
  box-shadow: none;
  padding: var(--space-4);
  background: var(--c-bg-soft);
  border-color: var(--c-border-soft);
}

/* ===== CITATION + ACK ===== */

.bibtex-wrap {
  background: var(--c-bg-card);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-6);
}
.bibtex-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-5);
  background: var(--c-bg-soft);
  border-bottom: 1px solid var(--c-border-soft);
}
.bibtex-label {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--c-gold-deep);
}
.copy-btn {
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--c-blue);
  background: transparent;
  border: 1px solid var(--c-border);
  border-radius: 999px;
  padding: 0.3rem 0.85rem;
  cursor: pointer;
  transition: all 0.15s ease;
}
.copy-btn:hover {
  background: var(--c-blue);
  color: #fff;
  border-color: var(--c-blue);
}
.copy-btn.copied {
  background: var(--c-gold);
  color: var(--c-blue);
  border-color: var(--c-gold);
}
.bibtex {
  font-family: var(--font-mono);
  font-size: 0.86rem;
  line-height: 1.6;
  color: var(--c-text);
  padding: var(--space-5);
  margin: 0;
  white-space: pre;
  overflow-x: auto;
  background: transparent;
}

.ack-block {
  background: var(--c-bg-card);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.ack-title {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--c-gold-deep);
  padding: var(--space-3) var(--space-5);
  background: var(--c-bg-soft);
  border-bottom: 1px solid var(--c-border-soft);
  margin: 0;
}
.ack-text {
  color: var(--c-text-soft);
  font-size: 0.98rem;
  line-height: 1.65;
  padding: var(--space-5);
  margin: 0;
}

/* ===== FOOTER ===== */

.site-footer {
  border-top: 1px solid var(--c-border);
  padding: var(--space-6) var(--space-5);
  color: var(--c-text-mute);
  font-size: 0.85rem;
  text-align: center;
  margin-top: var(--space-8);
  background: var(--c-bg-soft);
}
.site-footer a { color: var(--c-blue); }

/* ===== DESKTOP ≥1024px — fixed left bar + scroll rail ===== */
@media (min-width: 1024px) {
  .container {
    display: block;
    min-height: 100vh;
    padding-left: var(--sidebar-w);   /* reserve the fixed bar's column */
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    padding: 0;
    background: var(--c-bg);
    border: 0;
    z-index: 50;
    display: flex;
    overflow: hidden;                 /* rail stays pinned; inner scrolls */
  }

  /* rail: ::before track, ::after gold fill (height = --scroll-progress from main.js) */
  .sidebar::before,
  .sidebar::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 2px;
    border-radius: 1px;
  }
  .sidebar::before {
    bottom: 0;
    background: var(--c-line);
    opacity: 0.55;
  }
  .sidebar::after {
    height: var(--scroll-progress, 0%);
    background: linear-gradient(to bottom, var(--c-gold), var(--c-gold-deep));
    box-shadow: 0 0 6px rgba(253, 181, 21, 0.35);
  }
  /* thumb is fixed-positioned to escape .sidebar overflow:hidden; inherits --scroll-progress */
  .rail-thumb {
    display: block;
    position: fixed;
    left: var(--sidebar-w);
    /* clamp: chip fully on-screen at 0%/100% (inset ≈ half chip + hover scale) */
    top: clamp(16px, var(--scroll-progress, 0%), calc(100% - 16px));
    transform: translate(-50%, -50%);   /* positioner only — never animated */
    z-index: 51;
    padding: 6px;                       /* enlarge the grab target past the visual chip */
    cursor: grab;
    touch-action: none;                 /* JS owns the drag gesture */
    -webkit-user-select: none;
    user-select: none;
    will-change: top;                   /* hint the compositor: this moves every frame */
  }
  .rail-thumb.dragging { cursor: grabbing; }
  /* hover: playful pulse + shake to invite a grab */
  .rail-thumb:hover .rail-thumb__chip {
    box-shadow: 0 3px 11px rgba(13, 27, 42, 0.32);
    animation: rail-thumb-jig 0.5s ease-in-out infinite;
  }
  /* dragging: solid grabbed scale (no shake) */
  .rail-thumb.dragging .rail-thumb__chip {
    animation: none;
    transform: scale(1.3);
    box-shadow: 0 4px 14px rgba(13, 27, 42, 0.34);
  }
  @media (prefers-reduced-motion: reduce) {
    .rail-thumb:hover .rail-thumb__chip { animation: none; transform: scale(1.2); }
  }

  .sidebar-inner {
    width: 100%;
    max-height: 100vh;
    overflow-y: auto;                 /* scroll nav if it ever exceeds height */
    overscroll-behavior: contain;
    align-items: flex-start;          /* top + left aligned */
    gap: var(--space-4);
    padding: var(--space-6) 20px var(--space-5);
  }

  /* Logo: compact, centered in the bar. */
  .logo {
    flex-direction: row;
    align-items: center;
    align-self: stretch;
    justify-content: center;
    gap: 0.5rem;
  }
  .logo-icon { display: block; width: 72px; height: 72px; }   /* fixed square, centered */

  .nav-section { margin-top: 0; width: 100%; }
  .nav-list {
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 2px;
    align-items: stretch;
    width: 100%;
  }

  .nav-item {
    display: flex;
    align-items: center;
    width: 100%;
    background: transparent;
    border: 0;
    border-radius: 0;
    padding: 0.32rem 0.2rem;
    font-size: 0.9rem;
    color: var(--c-text-mute);
    font-weight: 500;
    letter-spacing: -0.01em;
  }
  .nav-item .nav-icon { display: none; }   /* keep the left bar text-only */
  /* desktop shows FULL tab names (narrow bar shows short) */
  .nav-label-full { display: inline; }
  .nav-label-short { display: none; }
  .nav-item:hover { background: transparent; color: var(--c-blue); border: 0; }
  .nav-item.active,
  .nav-item.parent-active {
    background: transparent;
    color: var(--c-blue);
    border: 0;
  }
  .nav-item.active { font-weight: 700; }
  /* gold underline sized to the active word */
  .nav-item.active span {
    padding-bottom: 2px;
    background: linear-gradient(var(--c-gold), var(--c-gold)) 0 100% / 100% 2px no-repeat;
  }

  /* app sub-list grouped by faint left rule */
  .nav-sublist {
    display: flex;
    flex-direction: column;
    list-style: none;
    gap: 1px;
    margin: 2px 0 4px 0.55rem;
    padding-left: 0.7rem;
    border-left: 1px solid var(--c-border);
  }
  .nav-subitem {
    display: block;
    padding: 0.2rem 0.2rem;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--c-text-mute);
    letter-spacing: -0.01em;
    text-decoration: none;
    position: relative;
    transition: color 0.15s ease;
  }
  .nav-subitem:hover { color: var(--c-blue); text-decoration: none; }
  .nav-subitem.active { color: var(--c-blue); font-weight: 600; }
  /* gold tick marks the active sub-item */
  .nav-subitem.active::before {
    content: '';
    position: absolute;
    left: calc(-0.7rem - 1px);
    top: 50%;
    transform: translateY(-50%);
    width: 2px;
    height: 0.95rem;
    background: var(--c-gold);
    border-radius: 1px;
  }

  .main-content {
    max-width: var(--content-max);
    margin-inline: auto;              /* center within the offset column */
    padding: var(--space-8) var(--space-5) var(--space-9);
  }
  .main-content > section { max-width: 100%; margin-inline: 0; }

  /* fit network fig to content width: 266px = bar 210 + pad 48 + 8 slack; cap 0.948 = 1024/1080 */
  .net-arch-stage {
    --net-arch-scale: clamp(0.25, calc((100vw - 266px) / var(--net-arch-width)), 0.948);
  }
}

/* ===== VERY WIDE ≥1680px — content sizing only ===== */
@media (min-width: 1680px) {

  .main-content {
    max-width: var(--content-max);
    margin-inline: auto;          /* center in viewport */
    padding: var(--space-8) var(--space-5) var(--space-9);
  }

  .main-content > section {
    max-width: 100%;
    margin-inline: 0;
  }

  

  .hero-section h1 {
    font-size: clamp(3rem, 4.5vw + 0.5rem, 5rem);
  }
}

@media (min-width: 1280px) {
  .video-slot { width: 340px; }
}

/* ===== APPLICATIONS (04.01–04.06) ===== */

#applications { counter-reset: app; }

.app-block {
  margin-block: var(--space-8) var(--space-9);
  scroll-margin-top: 80px;
}
.app-block:first-of-type { margin-top: var(--space-7); }
.app-block + .app-block {
  padding-top: var(--space-9);
  /* double rule = border-top + gradient 3px below (single rule is used within experiments) */
  border-top: 1px solid var(--c-line);
  background-image: linear-gradient(var(--c-line), var(--c-line));
  background-repeat: no-repeat;
  background-position: 0 3px;
  background-size: 100% 1px;
}

.app-head {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas:
    "tag title"
    ".   blurb";
  column-gap: var(--space-4);
  row-gap: var(--space-2);
  margin-bottom: var(--space-5);
  align-items: baseline;
}
.app-tag {
  grid-area: tag;
  counter-increment: app;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--c-gold-deep);
  letter-spacing: 0.05em;
  line-height: 1.2;
  white-space: nowrap;
  padding-top: 0.18em;
}
.app-tag::before {
  content: "4." counter(app, decimal);
}
.app-title {
  grid-area: title;
  font-family: var(--font-display);
  font-size: clamp(1.18rem, 0.6vw + 1.05rem, 1.55rem);
  font-weight: 700;
  color: var(--c-blue);
  letter-spacing: -0.02em;
  line-height: 1.18;
  margin: 0;
}
.app-blurb {
  grid-area: blurb;
  font-family: var(--font-body);
  font-size: 0.98rem;
  line-height: 1.6;
  color: var(--c-text-soft);
  max-width: 72ch;
  margin: 0;
}
.app-blurb em {
  font-style: italic;
  color: var(--c-blue-mid);
  font-weight: 600;
}
.app-blurb strong {
  font-weight: 700;
  color: var(--c-blue);
}

.app-grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: 1fr;
}

/* manipulator 8-up: 2 cols → 4x2 ≥980px; native 4:3 overrides 16:9 crop */
.app-grid--4 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 980px) {
  .app-grid--4 { grid-template-columns: repeat(4, 1fr); }
}
#app-manipulator .lt-fig video,
#app-manipulator .lt-fig img { aspect-ratio: 4 / 3; }
/* robot captions: larger bold blue */
#app-manipulator .lt-fig figcaption { font-size: 1.05rem; font-weight: 700; }
#app-manipulator .lt-fig figcaption strong,
#app-manipulator .lt-fig figcaption b { color: var(--c-blue); font-weight: 700; }
/* mask uses page-default blue=known / gold=generated */

/* slide-34: mask floats right; I/O row below; input flex 2, output flex 1 → equal heights */
#app-manipulator .mani-io {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  clear: both;
  margin-top: 0;
}
#app-manipulator .mani-io__in { flex: 2 1 0; margin: 0; min-width: 0; }
#app-manipulator .mani-io__out { flex: 1 1 0; margin: 0; min-width: 0; }
#app-manipulator .mani-io__pair { display: flex; gap: var(--space-3); }
#app-manipulator .mani-io__pair img { flex: 1 1 0; min-width: 0; }
#app-manipulator .mani-io__pair img,
#app-manipulator .mani-io__out video {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--c-bg-soft);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
}
#app-manipulator .mani-io__arrow {
  flex: 0 0 auto;
  align-self: center;
  font-size: 2rem;
  line-height: 1;
  color: var(--c-text-mute);
}
#app-manipulator .mani-io figcaption {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  text-align: left;
  color: var(--c-text-soft);
  margin-top: var(--space-3);
  line-height: 1.5;
}
#app-manipulator .mani-io figcaption b { color: var(--c-blue); font-weight: 700; }
/* desktop: pull mask into the title band */
#app-manipulator .mani-mask { margin: -5.5rem 0 0 var(--space-5); }
@media (max-width: 640px) {
  /* centered mask here → cancel the negative pull */
  #app-manipulator .mani-mask { margin: 0 auto var(--space-4); }
}
@media (max-width: 620px) {
  #app-manipulator .mani-io { flex-direction: column; align-items: stretch; }
  #app-manipulator .mani-io__arrow { align-self: center; transform: rotate(90deg); }
}
/* mono intro: skip justify+hyphens (matches .taco-intro) */
.mani-intro { text-align: left; hyphens: none; }

/* ===== LANGTABLE ===== */

.app-blog .app-head { margin-bottom: var(--space-5); }
.app-blog .app-blurb { max-width: 76ch; }

.lt-row { margin-top: var(--space-6); }
.lt-row + .lt-row {
  margin-top: var(--space-7);
  padding-top: var(--space-6);
  border-top: 1px solid var(--c-border-soft);
}

/* mini-mask badge: navy=known, gold=target */

/* i · inference mask floats right */
.lt-infer-fig {
  float: right;
  width: fit-content;
  margin: 0.1rem 0 0.8rem 1.9rem;
  padding: var(--space-3) var(--space-4);
  background: var(--c-bg-card);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.lt-infer-fig__cap {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--c-text-mute);
  text-align: center;
  margin-bottom: var(--space-4);
}
.lt-infer-fig__cap b { color: var(--c-blue); font-weight: 700; font-size: 1.04rem; }
.lt-infer-rows { display: flex; flex-direction: column; gap: 10px; }
.lt-infer-rw { display: flex; align-items: center; gap: 12px; }
.lt-infer-rw__lab {
  flex: 0 0 94px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1.1;
  text-align: right;
  white-space: nowrap;
  color: var(--c-text-soft);
}
.lt-infer-rw__cells { display: grid; width: 174px; min-width: 0; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.lt-infer-rw__cells i {
  width: 100%; height: auto; aspect-ratio: 1;
  border-radius: 4px;
  border: 3px solid var(--cs, var(--c-line));
}
.lt-infer-rw[data-entity="state"]  { --cs: #3B7EA1; }
.lt-infer-rw[data-entity="action"] { --cs: #3f8f8c; }
.lt-infer-rw[data-entity="object"] { --cs: #c9890b; }
.lt-infer-rw__cells i.k { background: var(--c-blue); }
.lt-infer-rw__cells i.t { background: var(--c-gold); }
/* short labels → tight label column */
.lt-infer-fig--lt .lt-infer-rw { justify-content: center; }
.lt-infer-fig--lt .lt-infer-rw__lab { flex-basis: 82px; }
.lt-infer-fig__leg {
  display: flex; align-items: center; justify-content: center; gap: 5px;
  margin-top: var(--space-3);
  padding-top: var(--space-2);
  border-top: 1px solid var(--c-border-soft);
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--c-text-mute);
}
.lt-infer-fig__leg i { width: 13px; height: 13px; border-radius: 2px; }
.lt-infer-fig__leg i.k { background: var(--c-blue); }
.lt-infer-fig__leg i.t { background: var(--c-gold); }

/* paragraph fills the row so text wraps the float */
.lt-grounding {
  max-width: none;
  margin: 0 0 var(--space-5);
  padding: 0;
}
/* run-in title for part i */
.lt-lead {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--c-blue);
}

.lt-figs--titled { clear: both; }
.lt-figs__div {
  align-self: stretch;
  width: 1px;
  background: var(--c-line);
  margin-inline: 6px;
}
.lt-figs--titled .lt-fig figcaption {
  text-align: center;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--c-text);
  margin-top: 10px;
}

/* reveal staging: Input → Gen1 → Gen2 → replay */
.lt-figs--titled .lt-fig {
  transition: opacity 0.45s ease, filter 0.45s ease;
}
.lt-figs--titled .lt-fig.is-dim { opacity: 0.28; filter: saturate(0.55); }
.lt-figs--titled .lt-fig.is-seen { opacity: 1; }
.lt-figs--titled .lt-fig.is-active video,
.lt-figs--titled .lt-fig.is-active img {
  box-shadow: 0 0 0 2px var(--c-gold), var(--shadow-sm);
  border-color: var(--c-gold);
}

.lt-figs {
  display: grid;
  grid-template-columns: 1fr auto 1fr 1fr;
  align-items: start;
  gap: var(--space-3);
}
.lt-fig { margin: 0; }
.lt-fig video,
.lt-fig img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--c-bg-soft);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
}
.lt-fig figcaption {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--c-text-soft);
  margin-top: 6px;
}
.lt-fig figcaption b { color: var(--c-blue); font-weight: 700; }

/* rollouts: full-width one-up scroller, 5.22:1 slots */
.lt-roll-head { margin-top: var(--space-6); }
/* arrows overlay the video edges */
.lt-roll-stage { position: relative; }
.lt-roll-stage .gallery-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  box-shadow: var(--shadow-sm);
}
.lt-roll-stage .gallery-nav.left { left: 10px; }
.lt-roll-stage .gallery-nav:not(.left) { right: 10px; }
.video-gallery--wide .video-slot {
  width: 100%;
  aspect-ratio: auto;
  overflow: visible;
  background: transparent;
  border: 0;
}
.video-gallery--wide .gallery-video {
  height: auto;
  aspect-ratio: 188 / 36;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  background: var(--c-bg-soft);
}

/* rollout caption: panels left, task right */

.lt-slot__task {
  width: fit-content;
  max-width: 100%;
  margin: 0 auto 10px;
  padding: 5px 13px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  background: var(--c-bg-card);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--c-text);
}
.lt-lang-key { color: var(--c-text-mute); font-weight: 700; margin-right: 0.4em; }
.lt-slot__legends {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 10px;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--c-text);
}
.lt-slot__legends span { text-align: center; }
/* MPC results bar plot */
.lt-bars { clear: both; margin: var(--space-5) 0 0; padding: var(--space-3) var(--space-4) var(--space-4); background: var(--c-bg-soft); border: 1px solid var(--c-border-soft); border-radius: var(--radius-md); }

.lt-bars__metric { font-family: var(--font-mono); font-size: 0.74rem; font-weight: 700; color: var(--c-text); margin: var(--space-3) 0 var(--space-2); }
.lt-bars__dir { font-weight: 400; font-size: 0.64rem; color: var(--c-text-mute); }

/* MPC right column: mask over results, floated right */
.lt-mpc-right { float: right; width: min(300px, 44%); margin: 0.1rem 0 var(--space-3) 2.8rem; }
.lt-mpc-right .lt-infer-fig { float: none; width: auto; margin: 0; }
.lt-mpc-res2 { margin: var(--space-3) 0 0; padding: var(--space-3) var(--space-4); background: var(--c-bg-soft); border: 1px solid var(--c-border-soft); border-radius: var(--radius-md); }
.lt-mpc-res2__cap { font-family: var(--font-mono); font-size: 0.78rem; color: var(--c-text-mute); text-align: center; margin-bottom: var(--space-2); }
.lt-mpc-res2__cap b { color: var(--c-blue); font-weight: 700; }
.lt-mpc-res2__legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 14px;
  margin-bottom: var(--space-3);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--c-text-soft);
}
.lt-mpc-res2__legend span { display: inline-flex; align-items: center; gap: 5px; }
.lt-mpc-res2__legend i { width: 12px; height: 12px; border-radius: 2px; }
.lt-vbars { display: flex; justify-content: center; align-items: flex-end; gap: var(--space-3); padding-top: 16px; }
.lt-vbar-group { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.lt-vbar-pair { display: flex; align-items: flex-end; gap: 8px; height: 44px; }
.lt-vbar { width: 22px; border-radius: 3px 3px 0 0; position: relative; }
.lt-vbar__v { position: absolute; top: -14px; left: 50%; transform: translateX(-50%); font-family: var(--font-mono); font-size: 0.6rem; color: var(--c-text-soft); white-space: nowrap; }
.lt-vbar--plain { background: #d8d4c6; }
.lt-vbar--mpc { background: var(--c-gold); }
.lt-vbar--mpc .lt-vbar__v { color: var(--c-blue); font-weight: 700; }
.lt-vbar-group__lab { font-family: var(--font-mono); font-size: 0.68rem; font-weight: 700; color: var(--c-text-soft); }
.lt-vbar-group__delta { font-family: var(--font-mono); font-size: 0.76rem; font-weight: 700; color: #1f8a3b; }
/* two mini bar-charts: success | steps */
.lt-vcharts { display: flex; justify-content: space-between; gap: var(--space-3); }
.lt-vchart { flex: 1 1 0; min-width: 0; }
.lt-vchart__lab { font-family: var(--font-mono); font-size: 0.68rem; font-weight: 700; color: var(--c-text); text-align: center; }
.lt-vgroup__dir { font-weight: 400; color: var(--c-text-mute); }

.lt-grounding--mpc { margin-bottom: 0; }
.lt-mpc {
  --mpc-columns: minmax(0, 1fr) clamp(70px, 9vw, 110px) minmax(0, 2fr);
  clear: both;
  margin: 0;
  padding-top: var(--space-4);
}
.lt-mpc-panels,
.lt-mpc-captions {
  display: grid;
  grid-template-columns: var(--mpc-columns);
  gap: clamp(6px, 1.2vw, 16px);
  align-items: center;
}
.lt-mpc-goal {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
}
.lt-mpc-value {
  font-family: var(--font-mono);
  font-size: clamp(0.6rem, 0.85vw, 0.8rem);
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
  color: var(--c-blue);
}
.lt-mpc-value__arrow { display: block; font-size: 3rem; line-height: 1; }
.lt-mpc-video-crop {
  position: relative;
  overflow: hidden;
  aspect-ratio: 32 / 9;
  border-radius: var(--radius-sm);
  background: var(--c-bg-soft);
}
.lt-mpc-video-crop > video {
  position: absolute;
  top: 0;
  right: 0;
  display: block;
  height: 100%;
  width: auto;
  max-width: none;
}
.lt-mpc-captions {
  margin-top: 10px;
  align-items: start;
  font-family: var(--font-mono);
  font-size: clamp(0.625rem, 1vw, 0.9rem);
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
  color: var(--c-blue);
}
.lt-mpc-result-captions {
  grid-column: 3;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 640px) {
  .lt-figs { grid-template-columns: 1fr; }
  .lt-figs__div { width: 60%; height: 1px; justify-self: center; align-self: auto; margin-block: var(--space-2); }
  .lt-infer-fig { float: none; width: fit-content; margin: 0 auto var(--space-4); }
  .lt-mpc-right { float: none; width: 300px; max-width: 100%; margin: 0 auto var(--space-4); }

  

                /* keep the grid icon, drop the label */
  
    /* fit panels+task on the short strip */
  .lt-roll-head { margin-top: var(--space-5); }
}

/* ===== RETARGETING ===== */

/* i · mask: labels | context exemplars (2 known) | causal window (4) */
.rt-mask { width: max-content; max-width: 100%; margin-inline: auto; }
.rt-mask__caps,
.rt-mask__body,
.rt-mask__time { display: grid; grid-template-columns: 62px 58px 122px 28px; column-gap: 20px; }
.rt-mask__caps { align-items: end; margin-bottom: 9px; }
.rt-mask__cap { font-family: var(--font-mono); font-size: 0.44rem; letter-spacing: 0; line-height: 1.2; color: var(--c-text-mute); text-align: center; }
.rt-mask__cap--ex  { grid-column: 2; }
.rt-mask__cap--inf { grid-column: 3; }
.rt-mask__body { align-items: center; }
.rt-mask__time { margin-top: 10px; }
.rt-mask__time .inference-time-axis { grid-column: 3; width: auto; }
.rt-mask__labels { display: grid; grid-template-rows: 1fr 1fr; align-items: center; justify-items: end; align-self: stretch; }
.rt-mask__rlab { font-family: var(--font-mono); font-size: 0.72rem; line-height: 1.1; text-align: right; color: var(--c-text-soft); }
.rt-mask__ctx,
.rt-mask__win { display: grid; grid-auto-rows: 26px; gap: 6px; }
.rt-mask__ctx { grid-template-columns: repeat(2, 26px); position: relative; }
.rt-mask__win { grid-template-columns: repeat(4, 26px); }
.rt-mask__ctx::before {
  content: ""; position: absolute; inset: -7px -9px;
  border: 1.5px dashed var(--c-text-mute); border-radius: 7px; opacity: 0.7;
}
.rt-mask i { width: 26px; height: 26px; border-radius: 4px; border: 1.5px solid rgba(0, 0, 0, 0.1); }
.rt-mask i.k { background: var(--c-blue); }
.rt-mask i.t { background: var(--c-gold); }

/* dashed frame echoes the mask context block */
/* context cube + human + robot share one baseline (fixed img height) */
.rt-io3 { display: flex; align-items: flex-start; justify-content: center; gap: clamp(12px, 2.4vw, 30px); }
.rt-io3 .lt-fig { margin: 0; }
.rt-io3 .rt-io__img,
.rt-io3 .rt-io3__ctx-img {
  display: block; height: clamp(150px, 16.5vw, 226px); width: auto; max-width: 100%;
  aspect-ratio: auto; object-fit: contain;
  background: var(--c-bg-card); border: 1px solid var(--c-border); border-radius: var(--radius-sm);
}
.rt-io3 .rt-io3__ctx-img { border: 2px dashed var(--c-text-mute); }
.rt-io3 figcaption strong { color: var(--c-blue); font-weight: 700; }
.rt-io3__sep { align-self: flex-start; width: auto; height: clamp(150px, 16.5vw, 226px); margin-inline: 2px; display: flex; align-items: center; justify-content: center; font-size: 1.7rem; line-height: 1; color: var(--c-text-mute); opacity: 0.75; }

/* honest 0-based bars; min-width keeps the slow PHUMA bar legible */
.rt-bars {
  float: right;
  width: min(330px, 46%);
  margin: 0.1rem 0 var(--space-3) 1.9rem;
  padding: var(--space-3) var(--space-4) var(--space-4);
  background: var(--c-bg-soft);
  border: 1px solid var(--c-border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.rt-bars__metric { font-family: var(--font-mono); font-size: 0.74rem; font-weight: 700; color: var(--c-text); margin: var(--space-3) 0 var(--space-2); }
.rt-bars__dir { font-weight: 400; font-size: 0.62rem; color: var(--c-text-mute); }
.rt-bar-row { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-2); }
.rt-bar-row__task { flex: 0 0 46px; font-family: var(--font-mono); font-size: 0.68rem; font-weight: 700; color: var(--c-text-soft); }
.rt-bar-track { flex: 1 1 auto; min-width: 0; display: flex; }
.rt-bar { height: 15px; border-radius: 3px; display: flex; align-items: center; justify-content: flex-end; min-width: max-content; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06); }
.rt-bar__val { font-family: var(--font-mono); font-size: 0.6rem; line-height: 1; padding: 0 6px; white-space: nowrap; }
.rt-bar--base { background: #d8d4c6; }
.rt-bar--base .rt-bar__val { color: #6b6553; }
.rt-bar--ours { background: var(--c-gold); }
.rt-bar--ours .rt-bar__val { color: var(--c-blue); font-weight: 700; }

/* ii · matrix: 4 methods × (kin | phys) + input */
.rt-cmp {
  clear: both;
  margin: 0 0 var(--space-3);
  display: grid;
  grid-template-columns: 1fr minmax(50px, auto) 1fr 1fr 1fr;
  grid-template-areas:
    "nav    .      h-gmr  h-phu  h-our"
    "v-hum  l-kin  gmr-k  phu-k  our-k"
    "v-hum  l-phy  gmr-p  phu-p  our-p";
  gap: 7px 9px;
  align-items: stretch;
}
/* mask subtitle darker for legibility */
#app-retargeting .lt-infer-fig__cap { color: var(--c-text-soft); }
.rt-cmp__h {
  font-family: var(--font-mono);
  font-size: 0.92rem;
  font-weight: 700;
  text-align: center;
  color: var(--c-text-soft);
  align-self: end;
}
.rt-cmp__h--ours { color: var(--c-blue); }
.rt-cmp__rl {
  font-family: var(--font-mono);
  font-size: 1.12rem;
  font-weight: 800;
  line-height: 1.3;
  color: var(--c-text-soft);
  text-align: right;
  align-self: center;
  white-space: nowrap;
}
.rt-cmp__rl[style*="l-kin"] { align-self: start; margin-top: 6px; color: #c0392b; }
.rt-cmp__rl[style*="l-phy"] { align-self: end; margin-bottom: 6px; color: #b87c0a; }
.rt-cmp__v {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  background: var(--c-bg-card);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
}
.rt-cmp__human { grid-area: v-hum; margin: 0; align-self: center; display: flex; flex-direction: column; gap: 10px; }
.rt-cmp__hlab { font-family: var(--font-mono); font-size: 1.12rem; font-weight: 800; text-align: center; color: var(--c-blue); }
.rt-cmp__v--ours { border-color: var(--c-gold); }

/* ii · example prev/next nav */
.rt-cmp-nav { grid-area: nav; align-self: center; justify-self: start; display: flex; align-items: center; justify-content: flex-start; gap: var(--space-2); margin: 0; font-family: var(--font-mono); }
.rt-cmp-nav__lab { font-size: 0.7rem; color: var(--c-text-mute); margin-right: var(--space-1); }
.rt-cmp-nav__btn { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 26px; padding: 0; border: 1px solid var(--c-border); border-radius: var(--radius-sm); background: var(--c-bg-card); color: var(--c-text-soft); font-size: 0.66rem; cursor: pointer; transition: background 0.15s, border-color 0.15s, color 0.15s; }
.rt-cmp-nav__btn:hover { border-color: var(--c-blue); color: var(--c-blue); background: var(--c-bg-soft); }
.rt-cmp-nav__btn:focus-visible { outline: 2px solid var(--c-blue); outline-offset: 2px; }
.rt-cmp-nav__ind { min-width: 38px; text-align: center; font-size: 0.72rem; font-weight: 700; color: var(--c-text-soft); }

/* iii · wild: input + human|Ours|physics, 2 examples via prev/next */
.rt-wild { margin: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.rt-wild-nav { display: flex; align-items: center; gap: var(--space-2); margin: 0; font-family: var(--font-mono); }
.rt-wild-nav__lab { font-size: 0.7rem; color: var(--c-text-mute); margin-right: var(--space-1); }
.rt-wild-nav__btn { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 26px; padding: 0; border: 1px solid var(--c-border); border-radius: var(--radius-sm); background: var(--c-bg-card); color: var(--c-text-soft); font-size: 0.66rem; cursor: pointer; transition: background 0.15s, border-color 0.15s, color 0.15s; }
.rt-wild-nav__btn:hover { border-color: var(--c-blue); color: var(--c-blue); background: var(--c-bg-soft); }
.rt-wild-nav__btn:focus-visible { outline: 2px solid var(--c-blue); outline-offset: 2px; }
.rt-wild-nav__ind { min-width: 38px; text-align: center; font-size: 0.72rem; font-weight: 700; color: var(--c-text-soft); }
.rt-wild__item { margin: 0; display: flex; align-items: stretch; gap: var(--space-3); }
.rt-wild__cell { margin: 0; display: flex; flex-direction: column; min-width: 0; }
.rt-wild__cell--src { flex: 0 0 32%; }      /* ~16:9 input at the matched height */
.rt-wild__cell--triple { flex: 1 1 auto; }
.rt-wild__src {
  flex: 1 1 0;            /* fill the stretched cell -> equal height to the triple */
  min-height: 0;
  width: 100%;
  aspect-ratio: auto;     /* height is flex-driven, not aspect-driven */
  object-fit: cover;
  display: block;
  background: var(--c-bg-soft);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
}
.rt-wild__triple {
  flex: 0 0 auto;         /* keep cropped aspect height -> drives the row height */
  width: 100%;
  aspect-ratio: 1440 / 380;   /* crop dead sky off the native 1440x512 */
  object-fit: cover;
  object-position: center 78%;
  display: block;
  background: var(--c-bg-soft);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
}
.rt-wild__cap {
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--c-text-soft);
  text-align: center;
}
.rt-wild__cell--src .rt-wild__cap { text-align: start; }
/* right caption: each label tinted to its figure colour (AA >= 4.5 on --c-bg) */
.rt-wild__k { font-weight: 600; }
.rt-wild__k--hum { color: #356a8e; }   /* human       -> blue figure  (5.6:1) */
.rt-wild__k--our { color: #b5483a; }   /* Ours        -> coral figure (5.1:1) */
.rt-wild__k--phy { color: #8f6608; }   /* physics sim -> gold figure  (4.9:1) */
.rt-wild__sep { color: var(--c-text-soft); opacity: 0.55; }

/* iv · dark cards (light text, AA) */
.rt-embod { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); margin-top: var(--space-2); }
.rt-embod__card {
  margin: 0;
  padding: var(--space-3);
  background: #23262b;
  border: 1px solid #34383f;
  border-radius: var(--radius-lg);
}
.rt-embod__cap {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: #e8e6df;
  text-align: center;
  margin-bottom: 10px;
}
.rt-embod__cap b { color: var(--c-gold); font-weight: 700; }
.rt-embod__pair { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.rt-embod__vid {
  width: 100%;
  aspect-ratio: 5 / 4;
  object-fit: cover;
  object-position: 88% center;
  display: block;
  background: #1a1d21;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius-md);
}

@media (max-width: 640px) {
  .rt-bars { float: none; width: 100%; max-width: 360px; margin: 0 auto var(--space-4); }
  .rt-io3 { flex-direction: column; align-items: center; gap: var(--space-4); }
  .rt-io3 .rt-io__img { height: auto; width: 100%; max-width: 440px; aspect-ratio: auto; }
  .rt-io3 .rt-io3__ctx-img { height: auto; width: 100%; max-width: 300px; aspect-ratio: auto; }
  .rt-io3__sep { width: auto; height: auto; margin-block: 0; align-self: center; transform: rotate(90deg); }
  .rt-cmp {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "nav    nav"
      "v-hum  v-hum"
      "l-kin  l-phy"
      "h-gmr  h-gmr"
      "gmr-k  gmr-p"
      "h-phu  h-phu"
      "phu-k  phu-p"
      "h-our  h-our"
      "our-k  our-p";
  }
  .rt-cmp-nav { justify-self: center; justify-content: center; }
  .rt-cmp__v--human { width: 60%; justify-self: center; }
  .rt-cmp__rl { text-align: center; align-self: end; font-weight: 700; }
  .rt-cmp__rl[style*="l-kin"], .rt-cmp__rl[style*="l-phy"] { align-self: end; margin: 0; }
  .rt-wild-nav { justify-content: center; }
  .rt-wild__item { flex-direction: column; align-items: stretch; }
  .rt-wild__cell--src { flex: none; width: 56%; }
  .rt-wild__src { flex: none; height: auto; aspect-ratio: 16 / 9; }
  .rt-wild__cell--src .rt-wild__cap { text-align: start; }
  .rt-embod { grid-template-columns: 1fr; }
}

/* ===== REDUCED MOTION ===== */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ===== TRACEGEN ===== */
.lt-ref {
  color: var(--c-blue);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}
.lt-ref:hover { color: var(--c-gold-deep); }
.tg-io {
  clear: both;
  margin-top: var(--space-5);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  column-gap: var(--space-4);
  row-gap: var(--space-3);
  align-items: center;
}
.tg-io__media {
  width: 100%;
  height: auto;
  aspect-ratio: 896 / 384;
  object-fit: contain;
  background: var(--c-bg-soft);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  display: block;
}
.tg-io__in  { grid-column: 1; grid-row: 1; }
.tg-io__out { grid-column: 3; grid-row: 1; }
.tg-io__arrow {
  grid-column: 2;
  grid-row: 1;
  align-self: center;
  color: var(--c-text-mute);
  font-size: 2rem;
  line-height: 1;
}
.tg-io__cap {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  color: var(--c-text-soft);
  text-align: center;
  margin: 0;
}
.tg-io__cap--in  { grid-column: 1; grid-row: 2; }
.tg-io__cap--out { grid-column: 3; grid-row: 2; }
.tg-io__cap strong { color: var(--c-blue); font-weight: 700; }

/* vertical bars (global .lt-vbars) */
/* full-width results table (matches the gallery above) */
.tg-bars { max-width: none; margin-inline: 0; padding: var(--space-4) var(--space-5) var(--space-5); }
.tg-bars__title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.12rem;
  color: var(--c-blue);
  text-align: center;
  margin-bottom: var(--space-2);
}
.tg-bars__leg { display: flex; align-items: center; justify-content: center; gap: 7px; font-family: var(--font-mono); font-size: 0.78rem; color: var(--c-text-mute); margin-bottom: var(--space-4); }
.tg-bars__leg i { width: 12px; height: 12px; border-radius: 2px; display: inline-block; }
.tg-bars__leg i.tg { background: #d8d4c6; }
.tg-bars__leg i.ours { background: var(--c-gold); }
.tg-bars__cols { display: flex; }
.tg-bars__col { flex: 1 1 0; min-width: 0; padding-inline: var(--space-4); }
.tg-bars__col + .tg-bars__col { border-left: 1px solid var(--c-border-soft); }
.tg-bars .lt-bars__metric { text-align: center; margin-top: 0; }
.tg-bars .lt-vbars { justify-content: space-between; gap: 0; padding-top: 22px; padding-inline: var(--space-2); }
.tg-bars .lt-vbar-pair { height: 92px; gap: 20px; }
.tg-bars .lt-vbar { width: 42px; }
.tg-bars .lt-vbar__v { font-size: 0.66rem; }
.tg-bars .lt-vbar-group { gap: 6px; }
.tg-bars .lt-vbar-group__lab { font-size: 0.72rem; }
.tg-bars .lt-vbar-group__delta { font-size: 0.82rem; }
@media (max-width: 620px) {
  .tg-io { grid-template-columns: 1fr; }
  .tg-io__in   { grid-column: 1; grid-row: 1; }
  .tg-io__cap--in  { grid-column: 1; grid-row: 2; }
  .tg-io__arrow { grid-column: 1; grid-row: 3; transform: rotate(90deg); }
  .tg-io__out  { grid-column: 1; grid-row: 4; }
  .tg-io__cap--out { grid-column: 1; grid-row: 5; }
}

/* gallery 2/3 + error chart 1/3 */
.tg-results {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--space-6);
  align-items: center;
  margin-top: var(--space-5);
}
.tg-results > .lt-roll-stage { min-width: 0; margin: 0; }
.tg-results > .tg-bars { margin: 0; min-width: 0; padding: var(--space-4); }
/* chart stacks Droid over EpicKitchen */
.tg-results .tg-bars__title { font-size: 1.05rem; line-height: 1.3; }
.tg-results .tg-bars__leg { margin-bottom: var(--space-3); }
.tg-results .tg-bars__cols { flex-direction: column; gap: var(--space-3); }
.tg-results .tg-bars__col { padding-inline: 0; }
.tg-results .tg-bars__col + .tg-bars__col {
  border-left: 0;
  border-top: 1px solid var(--c-border-soft);
  margin-top: var(--space-3);
  padding-top: var(--space-3);
}
.tg-results .tg-bars .lt-bars__metric { font-size: 0.8rem; margin: 0 0 var(--space-1); }
.tg-results .tg-bars .lt-vbars { padding-top: 20px; padding-inline: var(--space-2); }
.tg-results .tg-bars .lt-vbar-pair { height: 72px; gap: 10px; }
.tg-results .tg-bars .lt-vbar { width: 30px; }
.tg-results .tg-bars .lt-vbar__v { font-size: 0.66rem; top: -14px; }
.tg-results .tg-bars .lt-vbar-group { gap: 5px; }
.tg-results .tg-bars .lt-vbar-group__lab { font-size: 0.74rem; }
.tg-results .tg-bars .lt-vbar-group__delta { font-size: 0.74rem; text-align: center; line-height: 1.3; }
/* ≤tablet: gallery over chart */
@media (max-width: 820px) {
  .tg-results { grid-template-columns: 1fr; gap: var(--space-4); align-items: stretch; }
  .tg-results > .tg-bars { max-width: 460px; margin-inline: auto; padding: var(--space-4) var(--space-5); }
}

/* one scene per view (2D over 3D × 3 methods) */
.video-gallery--tg .video-slot {
  width: 100%;
  aspect-ratio: 768 / 672;
  overflow: hidden;
  background: var(--c-bg-soft);
  scroll-snap-align: center;
}
.video-gallery--tg .gallery-video { width: 150%; max-width: none; height: 100%; margin-left: -50%; object-fit: contain; background: var(--c-bg-soft); }
.tg-slot__tag {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: #fff;
  background: rgba(15, 23, 42, 0.66);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
}
.tg-cmp-cap {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  margin-bottom: var(--space-2);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 400;
  text-align: center;
}
.tg-cmp-cap span { padding: 4px 0; color: var(--c-text-mute); }
.tg-cmp-cap span + span { border-left: 1px solid var(--c-border-soft); }
.tg-cmp-cap .is-ours { color: var(--c-blue); }

/* ===== OMOMO ===== */
/* mask + IO in a right rail; intro + comparison centered beside */
#app-omomo .lt-row { display: flex; flex-direction: row-reverse; align-items: center; gap: clamp(1.5rem, 4vw, 3rem); }
.om-rail { flex: 0 0 min(500px, 46%); }
#app-omomo .lt-row > .om-left { flex: 1 1 auto; min-width: 0; }
.om-left .lt-grounding { margin: 0 0 var(--space-4); }
.om-left .lt-grounding:last-child { margin-bottom: 0; }
.om-rail .lt-infer-fig { float: none; width: auto; margin: 0; }   /* mask fills the rail width */
/* 13 steps / 120 frames; cells stretch + waypoint state */
.om-cells { flex: 1 1 auto; grid-template-columns: repeat(13, minmax(0, 1fr)); gap: 4px; }
.om-cells i { width: auto; height: auto; aspect-ratio: 1; border-width: 2px; border-radius: 3px; }
.lt-infer-rw__cells i.w { background: var(--c-blue-mid); }   /* waypoint fill — only OMOMO rows carry .w, so no leak to LangTable */
/* compact header: title + legend share top band */
.om-cap {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 4px 14px;
  text-align: left; margin-bottom: var(--space-3);
}
.om-cap__t { white-space: nowrap; }
.om-cap .om-leg { margin: 0; padding: 0; border-top: none; }   /* legend inline in header, not a bottom block */
.om-leg i.w { background: var(--c-blue-mid); }
/* inline known/generated emphasis tying to the mask legend; both >=5:1 on --c-bg and --c-bg-soft (AA) */

/* input→output pair under the mask */
.om-io { grid-template-columns: 1fr 1fr; gap: var(--space-3); margin-top: var(--space-3); }
.om-io .lt-fig img,
.om-io .lt-fig video {
  aspect-ratio: 512 / 438;
  object-fit: contain;
  background: var(--c-bg-soft);
}
.om-io .lt-fig figcaption { text-align: center; }
.om-io .lt-fig figcaption b { color: var(--c-blue); font-weight: 700; }
/* GT|CHOIS|Ours strip ≈3:1 */
.video-gallery--wide.om-cmp .gallery-video { aspect-ratio: 1740 / 578; }
/* six seeds 1x6 = 6:1 */
.video-gallery--wide.om-div .gallery-video { aspect-ratio: 2880 / 480; }

@media (max-width: 720px) {
  #app-omomo .lt-row { flex-direction: column; align-items: stretch; gap: var(--space-4); }
  .om-rail { flex: none; }
}

/* ===== TACO ===== */
.taco-intro { max-width: 82ch; margin: 0 0 var(--space-5); text-align: left; hyphens: none; }   /* mono copy: skip justify+hyphens */

/* stacked; 3-across when room */
.taco-modes {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-5);
  max-width: 420px;
  margin-inline: auto;
}
@media (min-width: 760px) {
  .taco-modes {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-4);
    max-width: none;
    margin-inline: 0;
  }
}
.taco-mode { display: flex; flex-direction: column; gap: var(--space-3); min-width: 0; }

/* SAME .lt-infer-fig component as apps 1-4 (blue=known, gold=generated), unfloated */
.taco-mask { float: none; width: auto; margin: 0; }
.taco-mask .lt-infer-rw[data-entity="hand"] { --cs: #3B7EA1; }

/* green caption: in the clip, green = known input */
.taco-cap { margin: 0; text-align: center; font-family: var(--font-mono); font-size: 0.86rem; line-height: 1.5; color: var(--c-text-soft); }
.taco-cap b { color: #1f8a3b; font-weight: 700; }   /* green = the known mesh shown in the clip */

/* stronger ring+shadow lifts arrows off light renders */
.taco-roll .gallery-nav {
  background: rgba(255, 255, 255, 0.94);
  border-color: var(--c-border);
  box-shadow: 0 1px 7px rgba(0, 24, 48, 0.22);
}

/* JS step = slot width + 12px (--space-3 gap) → one snap slot per click */
.video-gallery--taco .video-slot {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--c-bg-soft);
}
.video-gallery--taco .gallery-video {
  object-fit: cover;                 /* square clip in square slot: exact fit */
  background: var(--c-bg-soft);
}
/* scene counter, bottom-left overlay */
.taco-slot__cap {
  position: absolute;
  left: 0;
  bottom: 0;
  margin: 0;
  padding: 4px 9px 5px;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  line-height: 1;
  color: #fff;
  background: rgba(0, 18, 36, 0.62);
  border-top-right-radius: var(--radius-md);
}
.taco-slot__cap span { opacity: 0.62; margin-left: 3px; }

@media (max-width: 1199px) {
  .pose-language-stage {
    --cell-w: clamp(24px, calc(5vw + 8px), 40px);
    --cell-h: var(--cell-w);
    --cell-gap: clamp(4px, 1vw, 8px);
    --row-gap: var(--space-4);
    --grid-cols: repeat(5, var(--cell-w)) 20px var(--cell-w) 64px;
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    gap: var(--space-6);
  }
  .pose-card--grid,
  .pose-card--token { grid-column: 1; min-width: 0; }
  .pose-card--token {
    grid-row: 1;
    width: max-content;
    max-width: 100%;
    justify-self: center;
  }
  .pose-card--grid {
    grid-row: 2;
    width: max-content;
    max-width: 100%;
    padding: var(--space-2) 0;
  }
  .token-grid__label {
    padding-left: var(--space-1);
    font-size: 0.8125rem;
    line-height: 1.25;
  }
  .token-grid__axis {
    margin-top: var(--space-2);
    font-size: 0.75rem;
  }
  .token-grid__axis .ax--ctx {
    grid-column: span 2;
    font-size: 0.75rem;
  }
  .token-grid__axis .ax--ctx + .ax--ctx { display: none; }
  .pose-card--token .token-row { gap: var(--space-2); }
  .pose-card--token .token-row__key { font-size: 0.9375rem; }
  .flex-train-stage {
    grid-template-columns: minmax(0, 1fr);
    row-gap: 14px;
    padding: 18px 14px;
  }
  .flex-train-stage > * { justify-self: center; }
  .flex-arrow svg { transform: rotate(90deg); }
  .flex-arrow, .model-box { margin-top: 0; }
}

@media (max-width: 1023px) {
  .main-content {
    padding: 24px max(16px, env(safe-area-inset-right)) 40px max(16px, env(safe-area-inset-left));
  }
  .hero-section { padding-block: 4px 0; }
  .hero-title-row { margin-bottom: 12px; }
  .hero-section h1 { font-size: clamp(1.625rem, 4vw + 0.5rem, 2.125rem); line-height: 1.15; }
  .hero-subtitle { font-size: 1rem; line-height: 1.5; margin-bottom: 16px; white-space: normal; text-wrap: pretty; }
  .hero-description { font-size: 0.875rem; line-height: 1.7; letter-spacing: -0.025em; }
  .hero-description a { white-space: nowrap; }
  .hero-description-small { font-size: 0.8125rem; line-height: 1.6; margin-top: 8px; }
  .teaser { margin-bottom: 24px; }
  .hero-cta-row { flex-direction: column; align-items: stretch; margin-bottom: 48px; gap: 16px; }
  .hero-cta-row .hero-links { flex-direction: row; justify-content: center; }
  .hero-cta-row .question { width: 100%; padding: 14px 16px; }
  .tagline-text { font-size: 0.9375rem; line-height: 1.5; gap: 6px; }
  .section-header h2 { font-size: clamp(1.375rem, 2vw + 1rem, 1.625rem); line-height: 1.25; }
  .teaser-v2 .tsv2 {
    width: 100%;
    flex-direction: row;
    align-items: center;
    gap: 12px;
  }
  .teaser-v2 .tsv2-box { width: 144px; padding: 10px 5px; border-radius: 12px; }
  .teaser-v2 .tsv2-title { font-size: 12px; line-height: 1.4; margin-bottom: 8px; }
  .teaser-v2 .tsv2-plot { padding: 2px 0 18px 24px; }
  .teaser-v2 .tsv2-grid { grid-template-columns: 24px 24px 10px 24px; grid-template-rows: repeat(3, 24px); gap: 6px 5px; }
  .teaser-v2 .tsv2-triad { width: 20px; height: 20px; }
  .teaser-v2 .tsv2-ylab,
  .teaser-v2 .tsv2-xlab { font-size: 11px; }
  .teaser-v2 .tsv2-tasks {
    display: flex;
    grid-template-columns: none;
    flex: 1 1 0;
    min-width: 0;
    min-height: 0;
    gap: 12px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scrollbar-width: thin;
    scrollbar-color: var(--c-line) transparent;
    padding: 2px 2px 8px;
  }
  .teaser-v2 .tsv2-task {
    flex: 0 0 136px;
    height: auto;
    width: auto;
    min-width: 0;
    gap: 8px;
    scroll-snap-align: start;
  }
  .teaser-v2 .tsv2-tile { width: 100%; height: auto; aspect-ratio: 1; }
  .teaser-v2 .tsv2-cap {
    position: static;
    transform: none;
    white-space: normal;
    font-size: 0.75rem;
    line-height: 1.4;
  }
  .teaser-v2 .tsv2-flow { display: none; }
  .teaser-scroll-hint { display: block; text-align: right; font-size: 0.75rem; line-height: 1.5; margin-top: 8px; color: var(--c-text-soft); }
}

@media (max-width: 359px) {
  .teaser-v2 .tsv2 { gap: 4px; }
  .teaser-v2 .tsv2-box { width: 140px; padding-inline: 3px; }
}

@media (min-width: 1024px) {
  .teaser-scroll-hint { display: none; }
}

@media (max-width: 819px) {
  .cell { border-width: 2px; border-radius: 5px; }
  .train-grid {
    --t-cell-w: clamp(30px, 7vw, 46px);
    --t-cell-h: clamp(32px, 7vw, 44px);
    --t-cell-gap: clamp(6px, 1.5vw, 12px);
  }
}

@media (max-width: 767px) {
  html { scroll-padding-top: 88px; -webkit-text-size-adjust: 100%; }
  body { background-attachment: scroll; }
  .main-content > section,
  .main-content > aside { margin-bottom: 64px; }
  .section-header p,
  .idea-grounding { text-align: left; hyphens: none; padding-inline: 0; }
  .state-action-grid { padding-inline: 0; min-width: 0; }
  .state-action-grid > * { min-width: 0; }
  #pose-language,
  #flexible-modeling { padding-inline: 0; margin-block: 64px; }
  .pose-language-foot { margin-top: 24px; }
  .token-row { gap: 6px; }
  .token-row__text { flex-wrap: wrap; gap: 2px 6px; font-size: 0.875rem; }
  .token-row__key { font-size: 0.9375rem; }
  .row-badge { font-size: 0.625rem; padding-inline: 6px; }
  .token-section { padding-inline: 8px; }
  .flex-train-stage { grid-template-columns: minmax(0, 1fr); padding: 18px 10px; }
  .train-block { min-width: 0; max-width: 100%; }
  .inf-item { grid-template-columns: minmax(0, 1fr); }
  .inf-figure { justify-content: center; padding-block: 12px; }
  .inf-legend { margin-left: 0; }
  .app-head { grid-template-columns: auto minmax(0, 1fr); gap: 8px; }
  .app-title { font-size: 1.1875rem; line-height: 1.4; overflow-wrap: anywhere; }
  .app-blurb { grid-column: 1 / -1; }
  .app-block { margin-bottom: 56px; scroll-margin-top: 0; }
  .app-block + .app-block { padding-top: 40px; }
  .lt-infer-fig { max-width: 100%; padding-inline: 10px; }
  .rt-mask__caps,
  .rt-mask__body,
  .rt-mask__time { grid-template-columns: 50px 46px 98px 22px; column-gap: 12px; }
  .rt-mask__ctx,
  .rt-mask__win { grid-auto-rows: 20px; }
  .rt-mask__ctx { grid-template-columns: repeat(2, 20px); }
  .rt-mask__win { grid-template-columns: repeat(4, 20px); }
  .rt-mask i { width: 20px; height: 20px; }
  .app-grid--4 { gap: 16px 10px; }
  #app-manipulator .lt-fig figcaption { font-size: 0.875rem; }
  .video-gallery { overscroll-behavior-x: contain; }
  .se3-frame-control input { font-size: 16px; width: 3em; }
}


@media (max-width: 767px), (pointer: coarse) {
  .gallery-nav,
  .rt-cmp-nav__btn,
  .rt-wild-nav__btn,
  .se3-toggle { min-width: 44px; min-height: 44px; }
  .copy-btn { min-height: 44px; padding-inline: 16px; }
  .se3-toggle { opacity: 1; }
}

