/* ==========================================================================
   TOKENCONTEXT — LIGHT AURORA & LUMINOUS GRADIENT EDITION
   Three.js + GSAP · Modern Light Gradients · High-Performance Scroll · Oct 2026
   ========================================================================== */

:root {
  --bg-deep: #05060B;
  --bg-card: rgba(14, 17, 32, 0.88);
  --bg-card-solid: #0B0E1A;
  --bg-hud: rgba(9, 12, 22, 0.90);
  --bg-elevated: #13182B;

  --text-primary: #F3F4F6;
  --text-bright: #FFFFFF;
  --text-secondary: #A1A9B8;
  --text-muted: #6B7485;

  /* Modern Light Open-Weights / Warm Gradient Palette (Soft Rose -> Tangerine -> Champagne -> Luminous Gold) */
  --amber-primary: #FBBF24;
  --amber-bright: #FDE68A;
  --rose-accent: #F472B6;
  --coral-accent: #FB923C;
  --grad-open: linear-gradient(135deg, #F472B6 0%, #FB923C 38%, #FBBF24 72%, #FDE68A 100%);
  --grad-open-subtle: linear-gradient(135deg, rgba(244, 114, 182, 0.14) 0%, rgba(251, 146, 60, 0.12) 50%, rgba(253, 230, 138, 0.10) 100%);
  --amber-dim: rgba(251, 191, 36, 0.14);
  --amber-border: rgba(251, 191, 36, 0.35);
  --amber-glow: rgba(244, 114, 182, 0.22);

  /* Modern Light Closed-API Gradient Palette (Soft Periwinkle -> Sky Blue -> Ice Cyan) */
  --blue-primary: #38BDF8;
  --blue-bright: #67E8F9;
  --violet-accent: #818CF8;
  --indigo-accent: #6366F1;
  --grad-closed: linear-gradient(135deg, #818CF8 0%, #60A5FA 35%, #38BDF8 72%, #67E8F9 100%);
  --grad-closed-subtle: linear-gradient(135deg, rgba(129, 140, 248, 0.15) 0%, rgba(56, 189, 248, 0.12) 100%);
  --blue-dim: rgba(56, 189, 248, 0.14);
  --blue-border: rgba(56, 189, 248, 0.35);

  /* Modern Light Aurora & Hero Text Gradients */
  --grad-aurora: linear-gradient(135deg, #67E8F9 0%, #818CF8 40%, #C084FC 75%, #F472B6 100%);
  --grad-spectrum: linear-gradient(90deg, #67E8F9 0%, #818CF8 30%, #C084FC 55%, #F472B6 78%, #FDE68A 100%);
  --grad-hero-text: linear-gradient(120deg, #FDE68A 0%, #F472B6 40%, #A78BFA 80%, #67E8F9 100%);

  --emerald-gpu: #10B981;
  --danger-over: #F43F5E;

  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-medium: rgba(255, 255, 255, 0.16);

  --font-serif: 'Instrument Serif', Georgia, 'Times New Roman', serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  --hud-top-height: 54px;
  --hud-bottom-height: 52px;
  --transition-fast: 160ms cubic-bezier(0.22, 1, 0.36, 1);
  --transition-smooth: 360ms cubic-bezier(0.22, 1, 0.36, 1);
}

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

html {
  scroll-behavior: auto;
  background-color: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

body {
  background-color: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* Custom Scrollbar with Soft Luminous Thumb */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-deep);
}
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #818CF8, #38BDF8);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--grad-aurora);
}

/* Utility Typography & Gradient Text */
.text-amber {
  background: var(--grad-open);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--amber-primary);
}
.text-blue {
  background: var(--grad-closed);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--blue-bright);
}
.text-white {
  color: var(--text-bright) !important;
  -webkit-text-fill-color: var(--text-bright) !important;
}
.serif-italic {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
}
.mono-num {
  font-family: var(--font-mono);
  letter-spacing: -0.03em;
}
.mono-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

/* ==========================================================================
   FIXED DUAL-LAYER GPU WEBGL STAGE + NEBULA AURORA GRADIENT BACKDROP
   ========================================================================== */
#canvas-stage {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  pointer-events: auto;
  overflow: hidden;
  background-color: var(--bg-deep);
  background-image:
    radial-gradient(circle at 75% 28%, rgba(129, 140, 248, 0.14) 0%, transparent 48%),
    radial-gradient(circle at 22% 72%, rgba(244, 114, 182, 0.10) 0%, transparent 50%),
    radial-gradient(circle at 60% 52%, rgba(56, 189, 248, 0.11) 0%, #05060B 76%),
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 100% 100%, 80px 80px, 80px 80px;
  will-change: transform;
  transform: translateZ(0);
}

#webgl-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
  pointer-events: none;
  will-change: transform;
  transform: translateZ(0);
}

#million-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  z-index: 2;
  cursor: grab;
  will-change: transform;
  transform: translateZ(0);
}

#million-canvas:active {
  cursor: grabbing;
}

#canvas-vignette {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background:
    radial-gradient(circle at 55% 50%, transparent 52%, rgba(5, 6, 11, 0.70) 100%),
    linear-gradient(180deg, rgba(5, 6, 11, 0.65) 0%, transparent 14%, transparent 86%, rgba(5, 6, 11, 0.80) 100%);
}

/* ==========================================================================
   TOP & BOTTOM FIXED HUD BARS
   ========================================================================== */
.hud-bar {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 40;
  background: var(--bg-hud);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
}

.top-bar {
  top: 0;
  height: var(--hud-top-height);
  border-bottom: 1px solid var(--border-subtle);
}

.hud-left,
.hud-center,
.hud-right {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.brand-logo {
  text-decoration: none;
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  display: inline-flex;
  align-items: center;
  transition: opacity var(--transition-fast);
}
.brand-logo:hover {
  opacity: 0.85;
}
.logo-light {
  color: var(--text-primary);
}
.logo-amber {
  background: var(--grad-open);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.logo-muted {
  color: var(--text-muted);
}

.hud-divider,
.hud-dot {
  color: var(--text-muted);
}

.hud-chip-btn {
  background: var(--grad-open-subtle);
  border: 1px solid var(--amber-border);
  color: var(--amber-bright);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.07em;
  padding: 0.26rem 0.65rem;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all var(--transition-fast);
}
.hud-chip-btn:hover {
  background: var(--grad-open);
  color: #05060B;
  font-weight: 600;
  transform: translateY(-1px);
}
.chip-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--rose-accent);
  box-shadow: 0 0 8px var(--rose-accent);
  animation: pulseDot 2s infinite;
}

.gpu-telemetry-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  padding: 0.24rem 0.6rem;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.14), rgba(14, 165, 233, 0.14));
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #34D399;
  font-size: 0.63rem;
  letter-spacing: 0.06em;
}
.gpu-led {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--emerald-gpu);
  box-shadow: 0 0 8px var(--emerald-gpu);
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.8); }
}

.hud-center {
  color: var(--text-secondary);
}

.live-counter-box {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  padding: 0.26rem 0.72rem;
  border-radius: 6px;
  background: linear-gradient(135deg, rgba(244, 114, 182, 0.10), rgba(129, 140, 248, 0.10));
  border: 1px solid var(--border-subtle);
}
.counter-value {
  background: var(--grad-open);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 600;
  font-size: 0.84rem;
}
.counter-label {
  color: var(--text-muted);
  font-size: 0.62rem;
}

.hud-action-btn {
  background: transparent;
  border: 1px solid var(--border-medium);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  padding: 0.28rem 0.65rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.hud-action-btn:hover,
.hud-action-btn.gpu-btn-active {
  border-color: var(--coral-accent);
  color: var(--amber-bright);
  background: var(--grad-open-subtle);
}

/* Bottom Chapter Bar */
.bottom-bar {
  bottom: 0;
  height: var(--hud-bottom-height);
  border-top: 1px solid var(--border-subtle);
  flex-direction: column;
  justify-content: center;
  padding: 0;
}

.chapter-nav-list {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  height: calc(100% - 3px);
  padding: 0 1rem;
  overflow-x: auto;
}

.chapter-nav-item {
  text-decoration: none;
  color: var(--text-muted);
  padding: 0.4rem 0.9rem;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  transition: all var(--transition-fast);
  position: relative;
  white-space: nowrap;
}
.chapter-nav-item:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}
.chapter-nav-item.active {
  color: var(--amber-bright);
  background: var(--grad-open-subtle);
}
.chapter-nav-item.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 14%;
  right: 14%;
  height: 2px;
  background: var(--grad-open);
  border-radius: 2px;
}
.ch-num {
  color: var(--text-secondary);
  font-weight: 600;
}
.chapter-nav-item.active .ch-num {
  color: var(--coral-accent);
}

.scroll-progress-track {
  width: 100%;
  height: 3px;
  background: rgba(255, 255, 255, 0.05);
}
.scroll-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--grad-spectrum);
  transition: width 80ms linear;
}

/* ==========================================================================
   FLOATING STAGE OVERLAY HUD (TOP-RIGHT CONTEXT METER + 3D CAMERA CONTROLS)
   ========================================================================== */
.stage-overlay-hud {
  display: none !important;
}

.stage-hud-top-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  margin-bottom: 0.25rem;
}

.stage-hud-kicker {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gpu-badge-mini {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  color: var(--amber-bright);
  background: var(--grad-open-subtle);
  border: 1px solid var(--amber-border);
  padding: 0.1rem 0.42rem;
  border-radius: 4px;
  white-space: nowrap;
}

.stage-hud-main {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
}

.stage-hud-number {
  font-family: var(--font-mono);
  font-size: 1.62rem;
  font-weight: 600;
  background: var(--grad-open);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.03em;
}

.stage-hud-unit {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  color: var(--text-muted);
  letter-spacing: 0.08em;
}

.stage-hud-sub {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.2rem;
  margin-bottom: 0.6rem;
}

.stage-hud-bar-track {
  width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 0.65rem;
}

.stage-hud-bar-fill {
  height: 100%;
  background: var(--grad-spectrum);
  border-radius: 99px;
  transition: width 350ms cubic-bezier(0.22, 1, 0.36, 1);
}

.stage-camera-controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.3rem;
}

.cam-preset-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.05em;
  padding: 0.28rem 0.35rem;
  border-radius: 5px;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.cam-preset-btn:hover,
.cam-preset-btn.active {
  background: var(--grad-open-subtle);
  border-color: var(--coral-accent);
  color: var(--amber-bright);
}

/* ==========================================================================
   FLOATING RACE HUD PANEL (SECTION 03 CONTROLS & SKYLINE PILLS - REMOVED)
   ========================================================================== */
.race-hud-panel {
  display: none !important;
}

.race-hud-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.45rem;
}

.race-legend {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.07em;
  color: var(--text-secondary);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}
.swatch-amber {
  background: var(--grad-open);
  box-shadow: 0 0 10px var(--amber-glow);
}
.swatch-blue {
  background: var(--grad-closed);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.35);
}

.race-filter-group {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 2px;
}

.race-filter-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  padding: 0.25rem 0.65rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.race-filter-btn:hover {
  color: var(--text-bright);
}
.race-filter-btn.active {
  background: var(--grad-open);
  color: #05060B;
  font-weight: 700;
}

.race-hud-caption {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.55rem;
}

.race-pills-strip {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 0.35rem;
  padding-bottom: 4px;
  scrollbar-width: thin;
}
.race-pills-strip::-webkit-scrollbar {
  height: 4px;
}
.race-pills-strip::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 2px;
}
.race-pills-strip::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
}

.race-pill {
  flex-shrink: 0;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 0.2rem 0.46rem;
  font-family: var(--font-mono);
  font-size: 0.61rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: all var(--transition-fast);
}
.race-pill.open {
  border-color: rgba(251, 146, 60, 0.38);
}
.race-pill.closed {
  border-color: rgba(56, 189, 248, 0.38);
}
.race-pill:hover,
.race-pill.selected {
  transform: translateY(-1px);
}
.race-pill.open:hover,
.race-pill.open.selected {
  background: var(--grad-open-subtle);
  border-color: var(--coral-accent);
}
.race-pill.closed:hover,
.race-pill.closed.selected {
  background: var(--grad-closed-subtle);
  border-color: var(--blue-primary);
}
.pill-name {
  color: var(--text-primary);
  font-weight: 500;
}
.race-pill.open .pill-tok {
  color: var(--amber-bright);
}
.race-pill.closed .pill-tok {
  color: var(--blue-bright);
}

/* ==========================================================================
   FLOATING CANVAS HOVER TOOLTIP
   ========================================================================== */
.canvas-tooltip {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 60;
  width: 280px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border-medium);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -110%);
  transition: opacity 120ms ease;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.76);
}

.canvas-tooltip.visible {
  opacity: 1;
}

.tooltip-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.3rem;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
}

.tooltip-badge {
  padding: 0.12rem 0.48rem;
  border-radius: 4px;
  font-weight: 600;
}
.tooltip-badge.badge-open {
  background: var(--grad-open-subtle);
  color: var(--amber-bright);
  border: 1px solid var(--amber-border);
}
.tooltip-badge.badge-closed {
  background: var(--grad-closed-subtle);
  color: var(--blue-bright);
  border: 1px solid var(--blue-border);
}

.tooltip-date {
  color: var(--text-muted);
}

.tooltip-title {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  line-height: 1.15;
  color: var(--text-bright);
}

.tooltip-vendor {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-secondary);
  margin-bottom: 0.55rem;
}

.tooltip-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.45rem 0;
  margin-bottom: 0.45rem;
}

.tt-metric-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.58rem;
  color: var(--text-muted);
  letter-spacing: 0.06em;
}

.tt-metric-val {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-primary);
}

.tooltip-note {
  font-size: 0.74rem;
  color: var(--text-secondary);
  line-height: 1.38;
}

/* ==========================================================================
   SCROLLYTELLING MAIN LAYOUT & NARRATIVE CARDS
   ========================================================================== */
#scrolly-main {
  position: relative;
  z-index: 10;
  pointer-events: none;
}

.chapter-section {
  position: relative;
  padding-top: var(--hud-top-height);
}

.section-header-banner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 4rem 2rem 0;
}

.part-kicker {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--amber-bright);
  background: linear-gradient(135deg, rgba(244, 114, 182, 0.16), rgba(129, 140, 248, 0.16));
  border: 1px solid var(--amber-border);
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  backdrop-filter: blur(10px);
}

.scrolly-step {
  min-height: 92vh;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  max-width: 1440px;
  margin: 0 auto;
  padding: 3rem clamp(2rem, 5vw, 4.5rem);
}

.hero-step {
  min-height: 100vh;
  justify-content: flex-start;
}

.narrative-card {
  pointer-events: auto;
  width: 100%;
  max-width: 530px;
  background: linear-gradient(160deg, rgba(14, 18, 36, 0.90) 0%, rgba(8, 10, 22, 0.92) 100%);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 1.85rem 2rem;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.55);
  contain: content;
  will-change: transform;
  transition: border-color var(--transition-smooth), transform var(--transition-smooth), box-shadow var(--transition-smooth);
}

.scrolly-step.active .narrative-card {
  border-color: rgba(255, 255, 255, 0.24);
  box-shadow: 0 28px 64px rgba(0, 0, 0, 0.78);
}

.narrative-card.highlight-amber-border,
.scrolly-step.active .narrative-card.highlight-amber-border {
  border-color: var(--amber-border);
  box-shadow: 0 24px 60px rgba(244, 114, 182, 0.18);
}

.hero-card {
  max-width: 585px;
  padding: 2.3rem 2.5rem;
}

.eyebrow-tag {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.tag-index {
  background: var(--grad-open);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 600;
}
.tag-sep {
  color: var(--text-muted);
}

.hero-title {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: clamp(2.8rem, 5.5vw, 4.4rem);
  line-height: 1.04;
  letter-spacing: -0.02em;
  color: var(--text-bright);
  margin-bottom: 1.15rem;
}

.hero-lead {
  font-size: 1.04rem;
  line-height: 1.68;
  color: var(--text-secondary);
  margin-bottom: 1.15rem;
}

.hero-gpu-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 1.45rem;
}
.gpu-chip {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  padding: 0.24rem 0.55rem;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.gpu-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--emerald-gpu);
  box-shadow: 0 0 6px var(--emerald-gpu);
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.scroll-cue-btn {
  background: var(--grad-aurora);
  color: #080A14;
  border: none;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 0.74rem 1.3rem;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  box-shadow: 0 4px 20px rgba(129, 140, 248, 0.28);
  transition: all var(--transition-fast);
}
.scroll-cue-btn:hover {
  filter: brightness(1.08);
  transform: translateY(-2px);
}
.scroll-arrow {
  display: inline-block;
  animation: bounceDown 1.6s infinite;
}

@keyframes bounceDown {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(3px); }
}

.secondary-cue-btn {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  border: 1px solid var(--border-medium);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  padding: 0.7rem 1.1rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.secondary-cue-btn:hover {
  color: var(--text-bright);
  border-color: var(--text-secondary);
}

/* Step Cards Inner Elements */
.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.65rem;
}

.meta-step {
  font-weight: 600;
  color: var(--text-secondary);
}

.big-token-readout {
  display: flex;
  align-items: baseline;
  gap: 0.65rem;
  margin: 0.35rem 0 0.85rem;
}
.readout-num {
  font-family: var(--font-mono);
  font-size: 2.5rem;
  font-weight: 600;
  background: var(--grad-open);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1;
}
.readout-caption {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.step-heading {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: clamp(1.85rem, 3vw, 2.35rem);
  line-height: 1.12;
  color: var(--text-bright);
  margin-bottom: 0.75rem;
}

.narrative-body {
  font-size: 0.98rem;
  line-height: 1.65;
  color: var(--text-secondary);
}
.narrative-body strong {
  color: var(--text-primary);
  font-weight: 500;
}

.card-interactive-hint {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* Token Chips (Step 1.1) */
.token-sample-box {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.75rem;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}
.token-chip {
  padding: 0.18rem 0.5rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
}
.token-chip.active-token {
  background: var(--grad-open);
  color: #05060B;
  font-weight: 700;
  box-shadow: 0 0 12px var(--amber-glow);
}

/* Mini Scale Bars */
.mini-scale-bar {
  margin-top: 1.05rem;
}
.mini-scale-bar .mini-scale-fill {
  height: 5px;
  border-radius: 99px;
  margin-bottom: 0.35rem;
}
.fill-blue {
  background: var(--grad-closed);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.45);
}
.fill-amber {
  background: var(--grad-open);
  box-shadow: 0 0 12px var(--amber-glow);
}
.fill-over {
  background: linear-gradient(90deg, #F472B6 0%, #FBBF24 90%, var(--danger-over) 90%);
}
.mini-scale-label {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

/* Formula Pills & Book Comparison (Part II) */
.formula-pill {
  margin-top: 1.1rem;
  padding: 0.5rem 0.75rem;
  background: var(--grad-open-subtle);
  border: 1px solid var(--amber-border);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  color: var(--amber-bright);
}

.book-comparison-bars {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.comp-row {
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
}
.comp-label {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-secondary);
}
.comp-track {
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 99px;
  overflow: hidden;
}
.comp-fill {
  height: 100%;
  border-radius: 99px;
}

/* ==========================================================================
   WIDE MODEL LEDGER EXPLORER CARD (STEP 3.6)
   ========================================================================== */
.wide-step {
  justify-content: center;
}

.wide-explorer-card {
  max-width: 1040px;
  width: 100%;
}

.explorer-top-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.25rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.explorer-controls {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.ledger-search-input {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-medium);
  color: var(--text-bright);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 0.44rem 0.75rem;
  border-radius: 8px;
  width: 265px;
  outline: none;
  transition: border-color var(--transition-fast);
}
.ledger-search-input:focus {
  border-color: var(--coral-accent);
}

.inline-filter-pills {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 3px;
}

.table-filter-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.07em;
  padding: 0.38rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.table-filter-btn.active {
  background: var(--grad-open);
  color: #05060B;
  font-weight: 700;
}

.model-ledger-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 0.65rem;
  max-height: 400px;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.ledger-item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 0.72rem 0.85rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
  gap: 0.24rem;
}
.ledger-item:hover,
.ledger-item.active-model {
  transform: translateY(-2px);
}
.ledger-item.is-open:hover,
.ledger-item.is-open.active-model {
  border-color: var(--coral-accent);
  background: var(--grad-open-subtle);
}
.ledger-item.is-closed:hover,
.ledger-item.is-closed.active-model {
  border-color: var(--blue-primary);
  background: var(--grad-closed-subtle);
}

.ledger-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--text-muted);
}
.ledger-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 4px;
}
.ledger-dot.open {
  background: var(--grad-open);
}
.ledger-dot.closed {
  background: var(--grad-closed);
}

.ledger-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-bright);
}

.ledger-tokens {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 600;
}
.ledger-item.is-open .ledger-tokens {
  color: var(--amber-bright);
}
.ledger-item.is-closed .ledger-tokens {
  color: var(--blue-bright);
}

.ledger-pages {
  font-family: var(--font-mono);
  font-size: 0.64rem;
  color: var(--text-muted);
}

/* ==========================================================================
   CHAPTER 04 — CODA & TRY IT YOURSELF (9 OCTOBER 2026 FRONTIER CARDS)
   ========================================================================== */
.coda-section {
  background: linear-gradient(180deg, transparent 0%, rgba(7, 9, 18, 0.94) 16%, #05060B 100%);
  padding-bottom: calc(var(--hud-bottom-height) + 3rem);
}

.coda-step {
  min-height: auto;
  justify-content: center;
  padding-top: 5rem;
}

.coda-container {
  pointer-events: auto;
  width: 100%;
  max-width: 1140px;
  margin: 0 auto;
}

.coda-hero-block {
  margin-bottom: 5rem;
}

.coda-giant-title {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: clamp(3rem, 6vw, 5rem);
  line-height: 1.02;
  color: var(--text-bright);
  margin-bottom: 1.25rem;
}

.coda-lead {
  font-size: 1.12rem;
  line-height: 1.68;
  color: var(--text-secondary);
  max-width: 760px;
  margin-bottom: 2.2rem;
}
.coda-lead strong {
  color: var(--text-bright);
}

.inline-text-link {
  color: var(--amber-bright);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.coda-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}

.coda-stat-card {
  background: linear-gradient(155deg, rgba(16, 20, 36, 0.92) 0%, rgba(10, 12, 23, 0.95) 100%);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 1.6rem 1.5rem;
  position: relative;
  overflow: hidden;
}
.coda-stat-card::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--grad-spectrum);
  opacity: 0.65;
}

.stat-big-value {
  font-family: var(--font-serif);
  font-size: clamp(2.6rem, 4.5vw, 3.8rem);
  line-height: 1;
  margin-bottom: 0.5rem;
}

.stat-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text-primary);
  margin-bottom: 0.45rem;
}

.stat-sub {
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.45;
}

/* Frontier Cards */
.coda-subtitle {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: clamp(2.4rem, 4.5vw, 3.6rem);
  line-height: 1.08;
  color: var(--text-bright);
  margin-bottom: 1rem;
}

.frontier-cards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

.frontier-model-card {
  text-decoration: none;
  background: linear-gradient(160deg, rgba(17, 21, 38, 0.92) 0%, rgba(10, 12, 22, 0.96) 100%);
  border: 1px solid var(--border-medium);
  border-radius: 12px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
}
.frontier-model-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--grad-open);
  opacity: 0.85;
  transition: opacity var(--transition-fast);
}
.frontier-model-card.closed-accent-card::before {
  background: var(--grad-closed);
}
.frontier-model-card:hover {
  border-color: var(--coral-accent);
  transform: translateY(-4px);
  box-shadow: 0 20px 44px rgba(244, 114, 182, 0.18);
}
.frontier-model-card.closed-accent-card:hover {
  border-color: var(--blue-primary);
  box-shadow: 0 20px 44px rgba(56, 189, 248, 0.2);
}
.frontier-model-card:hover::before {
  opacity: 1;
}

.f-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.f-model-name {
  font-family: var(--font-serif);
  font-size: 1.7rem;
  color: var(--text-bright);
}

.f-context-badge {
  font-family: var(--font-mono);
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--amber-bright);
  background: var(--grad-open-subtle);
  border: 1px solid var(--amber-border);
  padding: 0.24rem 0.55rem;
  border-radius: 6px;
  white-space: nowrap;
}
.f-context-badge.badge-blue-cta {
  color: var(--blue-bright);
  background: var(--grad-closed-subtle);
  border-color: var(--blue-border);
}

.f-model-slug {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
  margin-bottom: 0.85rem;
}

.f-model-desc {
  font-size: 0.86rem;
  color: var(--text-muted);
  line-height: 1.55;
  margin-bottom: 1.25rem;
}

.f-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 0.66rem;
}

.f-price {
  color: var(--text-primary);
  font-weight: 600;
}

.f-open-tag {
  color: var(--amber-bright);
}
.f-closed-tag {
  color: var(--blue-bright);
}

.coda-footnote {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.coda-cta-row {
  display: flex;
  align-items: center;
  gap: 1.4rem;
  flex-wrap: wrap;
  margin-bottom: 4rem;
}

.btn-primary-amber {
  text-decoration: none;
  background: var(--grad-open);
  color: #05060B;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  padding: 0.9rem 1.5rem;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  box-shadow: 0 12px 28px var(--amber-glow);
  transition: all var(--transition-fast);
}
.btn-primary-amber:hover {
  filter: brightness(1.08);
  transform: translateY(-2px);
}

.coda-docs-link {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-secondary);
  text-decoration: underline;
  text-underline-offset: 4px;
  transition: color var(--transition-fast);
}
.coda-docs-link:hover {
  color: var(--text-bright);
}

.coda-footer {
  border-top: 1px solid var(--border-subtle);
  padding-top: 1.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.09em;
  color: var(--text-muted);
}

.footer-credit {
  color: var(--text-secondary);
}

.footer-action-link {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.footer-action-link:hover {
  border-color: var(--coral-accent);
  color: var(--amber-bright);
}

/* ==========================================================================
   MODALS (PAGE INSPECTOR & CONTEXT CALCULATOR)
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(5, 6, 11, 0.84);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-panel {
  width: 100%;
  max-width: 780px;
  max-height: 88vh;
  overflow-y: auto;
  background: linear-gradient(160deg, #101426 0%, #090C18 100%);
  border: 1px solid var(--border-medium);
  border-radius: 14px;
  padding: 1.6rem 1.8rem;
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.78);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.2rem;
}

.modal-kicker {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  color: var(--amber-bright);
  display: block;
  margin-bottom: 0.2rem;
}

.modal-title {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 1.9rem;
  color: var(--text-bright);
}

.modal-close-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  transition: all var(--transition-fast);
}
.modal-close-btn:hover {
  color: var(--text-bright);
  border-color: var(--coral-accent);
}

.modal-controls-bar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.page-slider-wrap {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.page-slider-wrap input[type="range"],
#calc-token-slider {
  flex: 1;
  accent-color: var(--coral-accent);
  cursor: pointer;
}

.page-quick-jumps,
.calc-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.jump-btn,
.calc-preset-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  padding: 0.28rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.jump-btn:hover,
.calc-preset-btn:hover,
.calc-preset-btn.active {
  background: var(--grad-open-subtle);
  border-color: var(--coral-accent);
  color: var(--amber-bright);
}

.inspector-stats-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-secondary);
  padding: 0.65rem 0.85rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  margin-bottom: 1rem;
}

.printed-page-sheet {
  background: #0F1322;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 1.25rem;
  font-family: var(--font-serif);
  font-size: 1.06rem;
  line-height: 1.75;
  color: var(--text-primary);
  max-height: 310px;
  overflow-y: auto;
}

.printed-page-sheet .tok-word {
  display: inline-block;
  padding: 0 2px;
  border-radius: 3px;
  transition: background 120ms ease;
}
.printed-page-sheet .tok-word:hover {
  background: var(--grad-open-subtle);
  color: var(--amber-bright);
}
.printed-page-sheet .tok-word.first-tok {
  background: var(--grad-open);
  color: #05060B;
  font-weight: 700;
  padding: 0 5px;
}

/* Calculator Modal Specifics */
.calc-input-group {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 1.25rem;
}

.calc-number-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

#calc-token-input {
  background: #14192D;
  border: 1px solid var(--border-medium);
  color: var(--amber-bright);
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 600;
  padding: 0.45rem 0.8rem;
  border-radius: 8px;
  width: 220px;
}

.calc-unit-tag {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.calc-results-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

.calc-result-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 0.95rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.c-res-label {
  font-family: var(--font-mono);
  font-size: 0.64rem;
  color: var(--text-muted);
  letter-spacing: 0.07em;
}

.c-res-val {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-bright);
}

.c-res-sub {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.calc-cost-box {
  background: var(--grad-open-subtle);
  border: 1px solid var(--amber-border);
  border-radius: 10px;
  padding: 0.95rem 1.1rem;
}

.calc-cost-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-top: 0.6rem;
}

.cost-pill {
  background: rgba(7, 9, 18, 0.72);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.cost-model {
  font-family: var(--font-mono);
  font-size: 0.63rem;
  color: var(--text-secondary);
}

.cost-val {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  color: var(--text-bright);
}

/* ==========================================================================
   RESPONSIVE BREAKPOINTS (MOBILE / TABLET / DESKTOP)
   ========================================================================== */
@media (max-width: 1120px) {
  .hud-center,
  .gpu-telemetry-pill {
    display: none;
  }
  .coda-stats-grid,
  .frontier-cards-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 820px) {
  .top-bar {
    padding: 0 0.85rem;
  }
  .hud-chip-btn,
  #btn-shader-mode {
    display: none;
  }
  .stage-overlay-hud {
    display: none !important;
  }
  .coda-stats-grid,
  .frontier-cards-grid {
    grid-template-columns: 1fr;
  }
  .scrolly-step {
    padding: 2rem 1rem;
    align-items: center;
    justify-content: center;
  }
  .narrative-card {
    padding: 1.35rem 1.4rem;
    max-width: 480px;
  }
  .hero-card {
    padding: 1.45rem 1.5rem;
    max-width: 500px;
  }
  .hero-title {
    font-size: clamp(2rem, 4.5vw, 2.5rem);
    line-height: 1.1;
  }
  .hero-lead {
    font-size: 0.92rem;
    line-height: 1.55;
  }
  .calc-results-grid,
  .calc-cost-row {
    grid-template-columns: 1fr;
  }
  .race-pills-strip {
    display: none;
  }
  .race-hud-panel {
    left: 1rem;
    right: 1rem;
    max-width: none;
  }
}

/* ==========================================================================
   IPHONE & COMPACT MOBILE (<= 520px — e.g. iPhone 14 Pro 390x844)
   ========================================================================== */
@media (max-width: 520px) {
  :root {
    --hud-top-height: 44px;
    --hud-bottom-height: 42px;
  }

  .top-bar {
    padding: 0 0.65rem;
    padding-top: env(safe-area-inset-top, 0);
    height: calc(var(--hud-top-height) + env(safe-area-inset-top, 0));
  }

  .brand-logo {
    font-size: 0.74rem;
    letter-spacing: 0.03em;
  }

  .hud-right {
    gap: 0.4rem;
  }

  .live-counter-box {
    padding: 0.18rem 0.42rem;
    gap: 0;
    border-radius: 5px;
  }

  .counter-value {
    font-size: 0.70rem;
    line-height: 1;
  }

  .counter-label {
    display: none !important; /* Prevents 2-line wrap and collision on 390px screens */
  }

  .hud-action-btn {
    font-size: 0.58rem;
    padding: 0.20rem 0.45rem;
    letter-spacing: 0.05em;
  }

  .bottom-bar {
    height: calc(var(--hud-bottom-height) + env(safe-area-inset-bottom, 0));
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  .chapter-nav-list {
    gap: 0.15rem;
    padding: 0 0.35rem;
    justify-content: flex-start;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .chapter-nav-item {
    padding: 0.22rem 0.42rem;
    font-size: 0.55rem;
    gap: 0.2rem;
  }

  .section-header-banner {
    padding: 1.25rem 0.75rem 0;
    text-align: center;
  }

  .part-kicker {
    font-size: 0.58rem;
    letter-spacing: 0.1em;
    padding: 0.24rem 0.65rem;
  }

  .scrolly-step {
    padding: 0.85rem 0.75rem;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .hero-step {
    min-height: 100vh;
    min-height: 100dvh;
    align-items: center;
    justify-content: center;
  }

  .narrative-card,
  .hero-card {
    padding: 0.95rem 1.05rem;
    border-radius: 12px;
    width: 100%;
    max-width: min(360px, 92vw);
    margin: 0 auto;
    max-height: calc(100dvh - var(--hud-top-height) - var(--hud-bottom-height) - env(safe-area-inset-top, 0) - env(safe-area-inset-bottom, 0) - 1.5rem);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55);
  }

  .eyebrow-tag {
    font-size: 0.54rem;
    letter-spacing: 0.05em;
    margin-bottom: 0.35rem;
    flex-wrap: wrap;
    line-height: 1.25;
    gap: 0.3rem;
  }

  .hero-title {
    font-size: 1.5rem;
    line-height: 1.12;
    margin-bottom: 0.45rem;
  }

  .hero-lead {
    font-size: 0.76rem;
    line-height: 1.42;
    margin-bottom: 0.55rem;
  }

  .step-narrative,
  .narrative-body {
    font-size: 0.76rem;
    line-height: 1.42;
  }

  .step-title {
    font-size: 1.3rem;
    line-height: 1.15;
    margin-bottom: 0.42rem;
  }

  .card-meta {
    font-size: 0.56rem;
    margin-bottom: 0.35rem;
  }

  .big-token-readout {
    margin-bottom: 0.45rem;
    gap: 0.35rem;
  }

  .readout-num {
    font-size: 1.55rem;
    line-height: 1.05;
  }

  .readout-caption {
    font-size: 0.58rem;
  }

  .card-interactive-hint {
    font-size: 0.60rem;
    line-height: 1.35;
    margin-top: 0.45rem;
  }

  .hero-gpu-strip {
    gap: 0.25rem;
    margin-bottom: 0.65rem;
  }

  .gpu-chip {
    font-size: 0.52rem;
    padding: 0.14rem 0.38rem;
    border-radius: 4px;
  }

  .hero-actions {
    gap: 0.45rem;
  }

  .scroll-cue-btn {
    font-size: 0.64rem;
    padding: 0.42rem 0.75rem;
    border-radius: 6px;
  }

  .secondary-cue-btn {
    font-size: 0.64rem;
    padding: 0.40rem 0.70rem;
    border-radius: 6px;
  }

  .coda-giant-title {
    font-size: 1.75rem;
    line-height: 1.1;
    margin-bottom: 0.5rem;
  }

  .coda-lead {
    font-size: 0.80rem;
    line-height: 1.45;
  }

  .f-model-name {
    font-size: 1.1rem;
  }

  .modal-panel {
    width: 95vw;
    max-height: 88vh;
    padding: 1rem;
  }
}
