/* ==========================================================================
   NexoraZentrix — Spatial Engine
   Self-contained stylesheet. No CDN, no build step.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens
   -------------------------------------------------------------------------- */
:root {
  /* Surfaces: cool, near-black, slightly blue — instrument panel at night */
  --void:        #05060a;
  --deep:        #080a12;
  --surface:     #0d1018;
  --raised:      #131826;
  --line:        rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.18);

  /* Ink */
  --ink:         #e9edf7;
  --ink-soft:    #a8b1c6;
  --ink-mute:    #6d7791;

  /* Signal colours — one per discipline, used as data encoding not decor */
  --logic:       #5eead4;
  --stats:       #34d399;
  --tensor:      #a78bfa;
  --semantic:    #fbbf24;
  --attention:   #f472b6;
  --synth:       #818cf8;
  --agent:       #fb7185;
  --dsa:         #fb923c;   /* sorting bars: orange, distinct from amber NLP */
  --net:         #a3e635;   /* link-light green for the network lab */

  --cyan:        #35e7f0;
  --pink:        #ff4d9d;

  /* Type */
  --display: "Space Grotesk", "Segoe UI", Inter, system-ui, sans-serif;
  --body:    "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono:    "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;

  /* Scale (1.25 minor third off 16px) */
  --t-xs:  0.75rem;
  --t-sm:  0.875rem;
  --t-base: 1rem;
  --t-md:  1.25rem;
  --t-lg:  1.563rem;
  --t-xl:  1.953rem;
  --t-2xl: 2.441rem;
  --t-3xl: 3.052rem;
  --t-4xl: 4.2rem;

  --r-sm: 6px;
  --r:    12px;
  --r-lg: 20px;

  --gutter: clamp(1.25rem, 4vw, 2.5rem);
  --measure: 66ch;
}

/* --------------------------------------------------------------------------
   2. Reset
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--void);
  color: var(--ink);
  font-family: var(--body);
  font-size: var(--t-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

img, svg, video, canvas { display: block; max-width: 100%; }
button, input, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

h1, h2, h3, h4 {
  font-family: var(--display);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.05;
  margin: 0;
  text-wrap: balance;
}

p { margin: 0; }

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

::selection { background: rgba(53, 231, 240, 0.3); color: #fff; }

/* --------------------------------------------------------------------------
   3. Layout primitives
   -------------------------------------------------------------------------- */
.shell {
  width: 100%;
  max-width: 1200px;
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.section { padding-block: clamp(2.5rem, 5vw, 4rem); position: relative; z-index: 2; }
.section--tight { padding-block: clamp(1.75rem, 3vw, 2.5rem); }

.grid { display: grid; gap: 1.5rem; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }

.stack   { display: flex; flex-direction: column; }
.stack-2 { gap: 0.5rem; }
.stack-4 { gap: 1rem; }
.stack-6 { gap: 1.5rem; }
.stack-8 { gap: 2rem; }

.row { display: flex; align-items: center; gap: 1rem; }
.row--between { justify-content: space-between; }
.row--top { align-items: flex-start; }

.center { text-align: center; align-items: center; }
.measure { max-width: var(--measure); }
.mx-auto { margin-inline: auto; }

/* --------------------------------------------------------------------------
   4. Type helpers
   -------------------------------------------------------------------------- */
.h-hero {
  font-size: clamp(2.8rem, 9vw, var(--t-4xl));
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 0.95;
}
.h-1 { font-size: clamp(2rem, 5.5vw, var(--t-3xl)); }
.h-2 { font-size: clamp(1.6rem, 4vw, var(--t-2xl)); }
.h-3 { font-size: var(--t-lg); }
.h-4 { font-size: var(--t-md); }

.lede {
  font-size: clamp(1.02rem, 2vw, var(--t-md));
  color: var(--ink-soft);
  font-weight: 400;
  line-height: 1.55;
}
.prose { color: var(--ink-soft); max-width: var(--measure); }
.prose + .prose { margin-top: 0.9rem; }
.small { font-size: var(--t-sm); color: var(--ink-soft); }
.dim   { color: var(--ink-mute); }
.mono  { font-family: var(--mono); font-size: var(--t-sm); font-variant-numeric: tabular-nums; }

/* Gradient wordmark — used once, on the hero only */
.txt-gradient {
  background: linear-gradient(103deg, #ffffff 18%, #b8c6e8 52%, #5f7396 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.txt-neon {
  color: var(--cyan);
  text-shadow: 0 0 28px rgba(53, 231, 240, 0.45);
}

.decrypt-text { font-family: var(--display); }

/* --------------------------------------------------------------------------
   5. Chrome: nav, progress, cursor
   -------------------------------------------------------------------------- */
#global-progress {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  width: 0%;
  background: linear-gradient(90deg, var(--cyan), var(--tensor), var(--pink));
  z-index: 300;
  transition: width 0.1s linear;
}

.nav {
  position: fixed;
  inset-block-start: 0;
  inset-inline: 0;
  z-index: 100;
  padding: 0.9rem var(--gutter);
  background: rgba(5, 6, 10, 0.55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid transparent;
  transition: background 0.3s, border-color 0.3s;
}
.nav.is-stuck {
  background: rgba(5, 6, 10, 0.88);
  border-bottom-color: var(--line);
}
.nav__inner {
  max-width: 1200px;
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.nav__links {
  display: flex;
  align-items: center;
  gap: 1.75rem;
  font-size: var(--t-sm);
  color: var(--ink-soft);
}
.nav__links a { transition: color 0.2s; }
.nav__links a:hover { color: var(--ink); }

.brand { display: flex; align-items: center; gap: 0.7rem; font-family: var(--display); font-weight: 700; letter-spacing: -0.04em; font-size: 1.15rem; }
.brand__mark { width: auto; height: 3.2rem; flex: none; }

.kbd {
  font-family: var(--mono);
  font-size: 10px;
  padding: 0.15em 0.45em;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: rgba(0,0,0,0.5);
  color: var(--ink-soft);
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.38rem 0.75rem;
  border-radius: var(--r-sm);
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.btn-ghost:hover { background: rgba(255,255,255,0.1); border-color: var(--line-strong); }

/* Custom cursor — suppressed on touch/coarse pointers */
#cursor-dot, #cursor-ring {
  position: fixed;
  top: 0; left: 0;
  border-radius: 50%;
  pointer-events: none;
  z-index: 400;
  transform: translate(-50%, -50%);
  will-change: transform;
}
#cursor-dot {
  width: 6px; height: 6px;
  background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan);
}
#cursor-ring {
  width: 34px; height: 34px;
  border: 1px solid rgba(255,255,255,0.35);
  transition: width 0.25s, height 0.25s, border-color 0.25s, opacity 0.25s;
}
@media (hover: none), (pointer: coarse) {
  #cursor-dot, #cursor-ring { display: none; }
}
html.has-custom-cursor,
html.has-custom-cursor a,
html.has-custom-cursor button,
html.has-custom-cursor .magnetic-target { cursor: none; }
html.has-custom-cursor input[type="text"] { cursor: text; }

/* --------------------------------------------------------------------------
   6. Surfaces
   -------------------------------------------------------------------------- */
.glass-surface {
  background: rgba(19, 24, 38, 0.82);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--line);
}

.spatial-card {
  position: relative;
  border-radius: var(--r-lg);
  background:
    linear-gradient(168deg, rgba(255,255,255,0.055), rgba(255,255,255,0.012) 45%),
    var(--surface);
  border: 1px solid var(--line);
  overflow: hidden;
  isolation: isolate;
  transform-style: preserve-3d;
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1),
              border-color 0.3s, box-shadow 0.35s;
}
/* Mouse-tracked glare */
.spatial-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background: radial-gradient(
    380px circle at var(--mouse-x, 50%) var(--mouse-y, 50%),
    rgba(255, 255, 255, 0.07),
    transparent 62%
  );
  opacity: 0;
  transition: opacity 0.35s;
  pointer-events: none;
}
.spatial-card:hover::before { opacity: 1; }
.spatial-card:hover { border-color: var(--line-strong); }
.spatial-content { position: relative; z-index: 1; }

.pad   { padding: clamp(1.25rem, 3vw, 2rem); }
.pad-l { padding: clamp(1.5rem, 4vw, 2.75rem); }

/* Instrument screen — where canvases live */
.lab-screen {
  position: relative;
  background:
    linear-gradient(rgba(53,231,240,0.055) 1px, transparent 1px) 0 0 / 100% 26px,
    linear-gradient(90deg, rgba(53,231,240,0.055) 1px, transparent 1px) 0 0 / 26px 100%,
    radial-gradient(ellipse at 50% 0%, #0b1220, #04060c 72%);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
}
.lab-screen canvas { width: 100%; height: 100%; }

.screen-hint {
  position: absolute;
  bottom: 0.6rem; left: 0.7rem;
  font-family: var(--mono);
  font-size: 10px;
  color: rgba(255,255,255,0.4);
  pointer-events: none;
  z-index: 2;
}

/* --------------------------------------------------------------------------
   7. Badges, pills, readouts
   -------------------------------------------------------------------------- */
.sim-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  border: 1px solid rgba(53,231,240,0.28);
  background: rgba(53,231,240,0.08);
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
}

.pulse-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex: none;
  background: currentColor;
  box-shadow: 0 0 0 0 currentColor;
  animation: pulse 2.4s ease-out infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(255,255,255,0.35); }
  70%  { box-shadow: 0 0 0 9px rgba(255,255,255,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,255,255,0); }
}

.readout {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: var(--t-sm);
}
.readout dt { color: var(--ink-mute); }
.readout dd { margin: 0; color: var(--ink); font-variant-numeric: tabular-nums; }

.readout--hero {
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: rgba(255,255,255,0.04);
  padding: 0.75rem 0.9rem;
  align-items: center;
}
.readout--hero dd { font-size: var(--t-lg); font-weight: 700; }

.chip {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: var(--r-sm);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  border: 1px solid currentColor;
  background: color-mix(in srgb, currentColor 10%, transparent);
}

/* --------------------------------------------------------------------------
   8. Controls
   -------------------------------------------------------------------------- */
.nx-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: rgba(255,255,255,0.12);
  border-radius: 2px;
  outline: none;
}
.nx-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan);
  cursor: pointer;
  border: none;
  transition: transform 0.2s;
}
.nx-slider::-moz-range-thumb {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan);
  border: none;
  cursor: pointer;
}
.nx-slider::-webkit-slider-thumb:hover { transform: scale(1.25); }
.nx-slider.pink::-webkit-slider-thumb { background: var(--pink); box-shadow: 0 0 10px var(--pink); }
.nx-slider.pink::-moz-range-thumb     { background: var(--pink); box-shadow: 0 0 10px var(--pink); }

.field-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--ink-mute);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.1rem;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: var(--t-sm);
  cursor: pointer;
  transition: transform 0.2s, background 0.2s, border-color 0.2s, opacity 0.2s;
}
.btn:active { transform: scale(0.98); }
.btn--solid { background: var(--ink); color: #05060a; }
.btn--solid:hover { background: #fff; }
.btn--quiet { background: rgba(255,255,255,0.08); color: var(--ink); border-color: var(--line); }
.btn--quiet:hover { background: rgba(255,255,255,0.15); }
.btn--tiny {
  padding: 0.3rem 0.65rem;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.06em;
  border-radius: 5px;
  border: 1px solid currentColor;
  background: rgba(255, 255, 255, 0.06);
  background: color-mix(in srgb, currentColor 12%, transparent);
}
.btn--tiny:hover { background: rgba(255, 255, 255, 0.16); background: color-mix(in srgb, currentColor 26%, transparent); }

.text-input {
  width: 100%;
  background: rgba(0,0,0,0.45);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  padding: 0.55rem 0.7rem;
  font-family: var(--mono);
  font-size: var(--t-sm);
  color: var(--semantic);
}
.text-input:focus { outline: none; border-color: var(--semantic); }

/* --------------------------------------------------------------------------
   9. Command palette
   -------------------------------------------------------------------------- */
#cmd-palette {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: min(18vh, 9rem);
  padding-inline: 1rem;
  background: rgba(3, 4, 8, 0.8);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s;
}
#cmd-palette.is-open { opacity: 1; pointer-events: auto; }
#cmd-box {
  width: 100%;
  max-width: 34rem;
  border-radius: var(--r);
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0,0,0,0.7), 0 0 60px rgba(53,231,240,0.08);
  transform: scale(0.96) translateY(-8px);
  transition: transform 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}
#cmd-palette.is-open #cmd-box { transform: scale(1) translateY(0); }
#cmd-input {
  width: 100%;
  background: transparent;
  border: 0;
  padding: 1rem;
  font-family: var(--mono);
  font-size: var(--t-sm);
  color: var(--ink);
  border-bottom: 1px solid var(--line);
}
#cmd-input:focus { outline: none; }
#cmd-input::placeholder { color: var(--ink-mute); }
#cmd-results { padding: 0.5rem; max-height: 46vh; overflow-y: auto; }
.cmd-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-radius: var(--r-sm);
  background: transparent;
  border: 0;
  color: var(--ink-soft);
  font-size: var(--t-sm);
  cursor: pointer;
}
.cmd-item:hover, .cmd-item.is-active { background: rgba(255,255,255,0.09); color: #fff; }
.cmd-item__key { font-family: var(--mono); font-size: 10px; color: var(--ink-mute); }
.cmd-empty { padding: 1rem; font-size: var(--t-sm); color: var(--ink-mute); }

/* --------------------------------------------------------------------------
   10. Cinematic origin
   -------------------------------------------------------------------------- */
#cinematic-origin { position: relative; height: 400vh; background: #000; z-index: 0; }
.cinematic__pin {
  position: sticky;
  top: 0;
  height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
#brain-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.78;
}
.cinematic__veil {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 40%, transparent 30%, rgba(5,6,10,0.75) 100%),
    linear-gradient(to bottom, rgba(5,6,10,0.55), transparent 28%, transparent 62%, var(--void));
}
.caption-deck {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  padding-inline: var(--gutter);
  pointer-events: none;
  z-index: 3;
}
.caption {
  grid-area: 1 / 1;
  opacity: 0;
  transition: opacity 0.45s ease;
  max-width: 44rem;
}
.caption[data-active="true"] { opacity: 1; }

.scroll-cue {
  position: absolute;
  bottom: 2.2rem;
  left: 50%;
  translate: -50% 0;
  z-index: 4;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  color: var(--ink-mute);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  transition: opacity 0.4s;
}
.scroll-cue__rail {
  width: 1px; height: 42px;
  background: linear-gradient(var(--cyan), transparent);
  animation: railDrop 2.2s ease-in-out infinite;
}
@keyframes railDrop {
  0%, 100% { transform: scaleY(0.35); transform-origin: top; opacity: 0.4; }
  50%      { transform: scaleY(1); transform-origin: top; opacity: 1; }
}

/* --------------------------------------------------------------------------
   11. Main stage
   -------------------------------------------------------------------------- */
.stage {
  position: relative;
  z-index: 10;
  background: var(--void);
  border-top: 1px solid var(--line);
  box-shadow: 0 -30px 70px rgba(0,0,0,0.9);
}
#space-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: 0.55;
}
.hero {
  position: relative;
  min-height: 88svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 1.6rem;
  z-index: 2;
}
#hero-rings {
  position: absolute;
  top: 50%; left: 50%;
  translate: -50% -50%;
  width: min(820px, 130vw);
  height: min(820px, 130vw);
  z-index: -1;
  pointer-events: none;
  opacity: 0.9;
}

.section-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  text-align: center;
  margin-bottom: 2.5rem;
}

/* --------------------------------------------------------------------------
   12. CPU chip
   -------------------------------------------------------------------------- */
#cpu-chip {
  filter: drop-shadow(0 0 16px rgba(53,231,240,0.45));
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1), filter 0.3s;
}
#cpu-chip:hover { transform: scale(1.06); }
.cpu-core, .cpu-trace {
  stroke-dasharray: 1200;
  stroke-dashoffset: 1200;
  transition: stroke-dashoffset 1.8s cubic-bezier(0.16, 1, 0.3, 1), stroke 0.3s;
}
.cpu-active .cpu-core, .cpu-active .cpu-trace { stroke-dashoffset: 0; }
.overclocked .cpu-core  { stroke: var(--pink) !important; }
.overclocked .cpu-trace { stroke: var(--pink) !important; }
.overclocked { filter: drop-shadow(0 0 22px var(--pink)) !important; }
.cpu-die { transition: fill 0.3s, opacity 0.3s; }
.overclocked .cpu-die { fill: var(--pink); }

/* --------------------------------------------------------------------------
   13. Curriculum cards (with artwork)
   -------------------------------------------------------------------------- */
.curr-card {
  display: flex;
  flex-direction: column;
  min-height: 21rem;
  --accent: var(--cyan);
  border-top: 1px solid rgba(255,255,255,0.2);
}
.curr-card::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  top: 0;
  height: 2px;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 3;
}
.curr-card:hover::after { opacity: 1; }
.curr-card:hover {
  box-shadow: 0 22px 60px -24px color-mix(in srgb, var(--accent) 55%, transparent);
}

.curr-card__art {
  position: relative;
  aspect-ratio: 5 / 3;          /* matches the 800x480 artwork exactly */
  flex: none;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  background: radial-gradient(ellipse at 50% 120%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 70%), #080b13;
}
.curr-card__art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.4s;
  opacity: 0.92;
}
.curr-card:hover .curr-card__art img { transform: scale(1.06); opacity: 1; }

.curr-card__body {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 1.35rem 1.4rem 1.5rem;
  flex: 1;
}
.curr-card__eyebrow {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--accent);
}
.curr-card__go {
  margin-top: auto;
  padding-top: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: var(--t-sm);
  color: var(--ink-mute);
  transition: color 0.25s, gap 0.25s;
}
.curr-card:hover .curr-card__go { color: var(--accent); gap: 0.75rem; }
.curr-card__go svg { width: 15px; height: 15px; }

/* Wide feature card */
.curr-card--wide {
  min-height: 0;
  flex-direction: row;
  align-items: stretch;
}
.curr-card--wide .curr-card__art {
  width: 40%;
  aspect-ratio: auto;
  height: auto;
  border-bottom: 0;
  border-right: 1px solid var(--line);
}
.curr-card--wide .curr-card__art img {
  object-fit: contain;
  padding: 1.25rem;
}
.curr-card--wide .curr-card__body { justify-content: center; padding: clamp(1.5rem, 4vw, 2.75rem); }

/* Half-width card — two of these sit side by side under the wide feature card.
   The artwork keeps its 800x480 source but is cropped to 2:1 so these don't
   tower over the one-third-width cards above them. */
.curr-card--half .curr-card__art { aspect-ratio: 2 / 1; }
.curr-card--half .curr-card__body { padding: 1.5rem 1.6rem 1.6rem; }

/* Reveal */
.card-hidden {
  opacity: 0;
  transform: translateY(28px);
}
.card-visible {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.7s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}
.card-overclock {
  box-shadow: 0 0 44px rgba(255, 77, 157, 0.42) !important;
  border-color: rgba(255, 77, 157, 0.55) !important;
}

/* --------------------------------------------------------------------------
   14. Attention heatmap + token pills
   -------------------------------------------------------------------------- */
#attn-tokens { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.token-pill {
  padding: 0.18rem 0.55rem;
  border-radius: 5px;
  font-family: var(--mono);
  font-size: 11px;
  background: rgba(251,191,36,0.1);
  border: 1px solid rgba(251,191,36,0.3);
  color: var(--semantic);
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}
.token-pill:hover, .token-pill.is-focus {
  background: var(--semantic);
  color: #05060a;
  transform: translateY(-2px);
}
#attn-heatmap {
  display: grid;
  gap: 3px;
  padding: 0.5rem;
  background: #04060c;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}
.attn-cell {
  width: 24px; height: 24px;
  border-radius: 3px;
  background: var(--semantic);
  transition: outline-color 0.15s, transform 0.15s;
  outline: 1px solid transparent;
}
.attn-cell:hover { outline-color: #fff; transform: scale(1.12); }

/* --------------------------------------------------------------------------
   15. Topic pages
   -------------------------------------------------------------------------- */
.topic-hero {
  position: relative;
  padding-block: clamp(7rem, 15vw, 10rem) clamp(3rem, 7vw, 5rem);
  overflow: hidden;
  border-bottom: 1px solid var(--line);
}
.topic-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(60rem 26rem at 18% -10%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%),
    linear-gradient(180deg, #080b13, var(--void));
  z-index: -1;
}
.topic-hero__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: clamp(1.5rem, 5vw, 3.5rem);
  align-items: center;
}
.topic-hero__art {
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  overflow: hidden;
  background: #080b13;
}

.crumb {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-mute);
  margin-bottom: 1.1rem;
  transition: color 0.2s;
}
.crumb:hover { color: var(--cyan); }

.concept-list { display: grid; gap: 0.9rem; padding: 0; margin: 0; list-style: none; }
.concept-list li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.85rem;
  align-items: start;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: var(--t-sm);
}
.concept-list li:last-child { border-bottom: 0; }
.concept-list b { color: var(--ink); font-weight: 600; display: block; font-size: var(--t-base); }
.concept-list svg { width: 20px; height: 20px; color: var(--accent); margin-top: 2px; }

.formula {
  font-family: var(--mono);
  font-size: var(--t-sm);
  padding: 1rem 1.1rem;
  border-radius: var(--r);
  background: #04060c;
  border: 1px solid var(--line);
  color: var(--accent);
  overflow-x: auto;
  white-space: nowrap;
}

.next-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.35rem 1.5rem;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--surface);
  transition: border-color 0.25s, background 0.25s;
}
.next-link:hover { border-color: var(--line-strong); background: var(--raised); }

/* --------------------------------------------------------------------------
   16. Footer
   -------------------------------------------------------------------------- */
.footer {
  position: relative;
  z-index: 20;
  border-top: 1px solid var(--line);
  background: var(--deep);
  padding-block: 3rem;
}
.footer__inner {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: center;
  justify-content: space-between;
}
.footer__links { display: flex; flex-wrap: wrap; gap: 1.25rem; font-size: var(--t-sm); color: var(--ink-mute); }
.footer__links a:hover { color: var(--ink); }

/* --------------------------------------------------------------------------
   17. Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 960px) {
  .grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-3 { grid-column: span 2; }
  .topic-hero__grid { grid-template-columns: 1fr; }
  .lab-split { flex-direction: column; }
  .lab-split > * { width: 100% !important; }
}
@media (max-width: 720px) {
  .nav__links { display: none; }
  .nav__links--compact { display: flex; gap: 0.75rem; }
  .grid--2, .grid--3 { grid-template-columns: minmax(0, 1fr); }
  .span-2, .span-3 { grid-column: span 1; }
  .curr-card--wide { flex-direction: column; }
  .curr-card--wide .curr-card__art { width: 100%; aspect-ratio: 5 / 3; border-right: 0; border-bottom: 1px solid var(--line); }
  .curr-card--wide .curr-card__art img { padding: 0.75rem; }
  #attn-heatmap { gap: 2px; }
  .attn-cell { width: 18px; height: 18px; }
}

/* --------------------------------------------------------------------------
   18. Motion & print
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .card-hidden { opacity: 1; transform: none; }
  .cpu-core, .cpu-trace { stroke-dashoffset: 0; }
  #cursor-dot, #cursor-ring { display: none; }
}

/* Utility escape hatches used sparingly in markup */
.flex-1 { flex: 1; }
.h-full { height: 100%; }
.w-full { width: 100%; }
.rel { position: relative; }
.mt-auto { margin-top: auto; }
.hide { display: none !important; }

/* --------------------------------------------------------------------------
   19. Topic-page demo components
   -------------------------------------------------------------------------- */

/* Tokeniser inspector */
#tok-out {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: flex-end;
  min-height: 7rem;
}
.tok {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 0.5rem 0.55rem 0.55rem;
  border-radius: var(--r-sm);
  background: rgba(251, 191, 36, 0.07);
  border: 1px solid rgba(251, 191, 36, 0.28);
}
.tok--cont { background: rgba(255,255,255,0.03); border-color: var(--line); }
.tok__text { font-family: var(--mono); font-size: 13px; color: var(--semantic); }
.tok--cont .tok__text { color: var(--ink-soft); }
.tok__id { font-family: var(--mono); font-size: 9px; color: var(--ink-mute); }
.tok__vec { display: flex; align-items: flex-end; gap: 2px; height: 42px; }
.tok__vec i { width: 4px; border-radius: 2px; display: block; }

/* Diffusion */
#diffusion-canvas { width: 100%; height: 340px; }

/* Agent loop */
.agent-ring { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.6rem; }
.phase-node {
  padding: 0.7rem 0.5rem;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.025);
  text-align: center;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-mute);
  transition: border-color 0.3s, color 0.3s, background 0.3s;
}
.phase-node.is-active {
  border-color: var(--agent);
  color: var(--agent);
  background: rgba(251, 113, 133, 0.1);
}
#agent-log {
  height: 16rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.85rem;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
}
#agent-log:empty::after {
  content: "The log is empty. Start the loop to watch the agent work.";
  color: var(--ink-mute);
  font-family: var(--body);
  font-size: var(--t-sm);
  margin: auto;
  text-align: center;
  max-width: 24ch;
}
.agent-line {
  display: grid;
  grid-template-columns: 4.6rem 1fr;
  gap: 0.7rem;
  align-items: baseline;
  animation: lineIn 0.3s ease both;
}
@keyframes lineIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.agent-line__tag { color: var(--ink-mute); font-size: 10px; letter-spacing: 0.06em; }
.agent-line__body { color: var(--ink-soft); }
.agent-line--plan    .agent-line__tag { color: var(--cyan); }
.agent-line--act     .agent-line__tag { color: var(--semantic); }
.agent-line--reflect .agent-line__tag { color: var(--attention); }
.agent-line--done    .agent-line__tag { color: var(--stats); }
.agent-line--done    .agent-line__body { color: var(--ink); }

@media (max-width: 560px) {
  .agent-ring { grid-template-columns: repeat(2, 1fr); }
  .agent-line { grid-template-columns: 1fr; gap: 0.15rem; }
}

/* Selected state for the small segmented buttons. Uses a stronger tint plus an
   inset ring rather than inverting, because currentColor is the accent itself. */
.btn--tiny.is-active {
  background: rgba(255, 255, 255, 0.1);
  background: color-mix(in srgb, currentColor 34%, transparent);
  box-shadow: inset 0 0 0 1px currentColor;
  font-weight: 600;
}

/* Toggle state for the regular-size quiet buttons (e.g. "Cut a cable"). The tone
   comes from a --tone custom property set inline, defaulting to the brand cyan. */
.btn--quiet.is-active {
  color: var(--tone, var(--cyan));
  border-color: var(--tone, var(--cyan));
  background: rgba(255, 255, 255, 0.1);
  background: color-mix(in srgb, var(--tone, var(--cyan)) 16%, transparent);
}

/* --------------------------------------------------------------------------
   16. Clickable glossary terms + popover
   -------------------------------------------------------------------------- */
.term {
  display: inline;
  color: var(--accent, var(--cyan));
  border-bottom: 1.5px dotted color-mix(in srgb, var(--accent, var(--cyan)) 65%, transparent);
  cursor: pointer;
  font-weight: 600;
  padding: 0 0.05em;
  border-radius: 3px;
  transition: background 0.15s;
}
.term:hover, .term:focus-visible { background: color-mix(in srgb, var(--accent, var(--cyan)) 16%, transparent); }
.term:focus-visible { outline: 1.5px solid var(--accent, var(--cyan)); outline-offset: 2px; }

.term-popover {
  position: fixed;
  width: 320px;
  max-width: calc(100vw - 24px);
  z-index: 80;
  padding: 1.1rem 1.2rem;
  border-radius: 14px;
  opacity: 0;
  transform: translateY(-6px) scale(0.98);
  transition: opacity 0.16s ease, transform 0.16s ease;
  pointer-events: none;
}
.term-popover.is-open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.term-popover::before {
  content: "";
  position: absolute;
  left: var(--arrow-x, 24px);
  top: calc(var(--arrow-flip, 0) * 100% - 6px);
  width: 12px; height: 12px;
  background: inherit;
  border: inherit;
  transform: translateX(-50%) rotate(45deg);
  border-radius: 2px;
  clip-path: polygon(0 0, 100% 0, 100% 100%);
}
.term-popover__close {
  position: absolute; top: 0.5rem; right: 0.6rem;
  width: 24px; height: 24px; border: 0; background: transparent;
  color: var(--ink-mute); font-size: 18px; line-height: 1; cursor: pointer;
}
.term-popover__close:hover { color: var(--ink); }
.term-popover__title { font-family: var(--display); font-weight: 600; color: var(--ink); margin: 0 0 0.5rem; padding-right: 1.5rem; }
.term-popover__def { font-size: var(--t-sm); color: var(--ink-soft); line-height: 1.55; margin: 0; }
.term-popover__related { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.8rem; }
.term-popover__chip {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.02em;
  color: var(--accent, var(--cyan)); background: color-mix(in srgb, var(--accent, var(--cyan)) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent, var(--cyan)) 40%, transparent);
  border-radius: 999px; padding: 0.28rem 0.65rem; cursor: pointer;
}
.term-popover__chip:hover { background: color-mix(in srgb, var(--accent, var(--cyan)) 24%, transparent); }

/* --------------------------------------------------------------------------
   17. Algorithm gallery — sub-nav, mode chips, module rhythm
   -------------------------------------------------------------------------- */
.algo-subnav {
  position: sticky; top: 64px; z-index: 20;
  display: flex; gap: 0.4rem; overflow-x: auto; scrollbar-width: none;
  padding: 0.7rem var(--gutter); margin-bottom: -0.5rem;
  background: linear-gradient(to bottom, var(--void) 70%, transparent);
}
.algo-subnav::-webkit-scrollbar { display: none; }
.algo-subnav a {
  flex: none; font-family: var(--mono); font-size: 11px; letter-spacing: 0.04em;
  color: var(--ink-mute); border: 1px solid var(--line); border-radius: 999px;
  padding: 0.4rem 0.85rem; white-space: nowrap; transition: color 0.15s, border-color 0.15s;
}
.algo-subnav a:hover, .algo-subnav a.is-active { color: var(--ink); border-color: var(--line-strong); }

.module-kicker {
  display: flex; align-items: center; gap: 0.6rem;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent, var(--cyan)); margin-bottom: 0.6rem;
}
.module-kicker__n {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 6px;
  background: color-mix(in srgb, var(--accent, var(--cyan)) 16%, transparent);
  font-size: 10px;
}

.pseudocode-toggle {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-family: var(--mono); font-size: 11px; color: var(--ink-mute);
  cursor: pointer; background: none; border: 0; padding: 0;
}
.pseudocode-toggle:hover { color: var(--ink); }
.pseudocode-toggle svg { width: 12px; height: 12px; transition: transform 0.2s; }
.pseudocode-toggle[aria-expanded="true"] svg { transform: rotate(90deg); }
.pseudocode-block {
  font-family: var(--mono); font-size: 12px; line-height: 1.7; color: var(--ink-soft);
  background: rgba(255,255,255,0.03); border: 1px solid var(--line);
  border-radius: 10px; padding: 1rem 1.2rem; margin-top: 0.7rem;
  white-space: pre-wrap; display: none;
}
.pseudocode-block.is-open { display: block; }

.readout-line {
  min-height: 1.6em; font-family: var(--mono); font-size: var(--t-sm);
  color: var(--ink-soft); transition: opacity 0.15s;
}

@media (max-width: 640px) {
  .algo-subnav { top: 56px; }
}

/* --------------------------------------------------------------------------
   19. Tic-tac-toe board (minimax lab)
   -------------------------------------------------------------------------- */
.ttt-board {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
  width: 168px; height: 168px; flex: none;
}
.ttt-cell {
  display: flex; align-items: center; justify-content: center;
  font-family: var(--display); font-size: 1.7rem; font-weight: 600;
  background: rgba(255,255,255,0.035); border: 1px solid var(--line);
  border-radius: 8px; color: var(--ink); cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.ttt-cell:hover:not(:disabled) { border-color: var(--line-strong); background: rgba(255,255,255,0.06); }
.ttt-cell:disabled { cursor: default; }
.ttt-cell.is-x { color: var(--cyan); }
.ttt-cell.is-o { color: var(--pink); }
.ttt-row { display: flex; gap: 1.4rem; align-items: center; flex-wrap: wrap; }

[id$="-weight-row"], [id$="-temp-row"] { transition: opacity 0.2s; }

/* --------------------------------------------------------------------------
   20. Power chip — click-to-reveal gate between the cinematic video and the
   algorithm gallery. Blue and idle by default; a click flips it to a glowing
   red "on" state and fades the rest of the page in beneath it.
   -------------------------------------------------------------------------- */
.power-gate-section { padding-bottom: clamp(1.5rem,5vw,3rem); }

.power-chip {
  --chip-blue: var(--cyan);
  --chip-red: #ff3344;
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
  background: none;
  border: 0;
  padding: 1.2rem 1.6rem;
  cursor: pointer;
  color: var(--chip-blue);
  transition: color 0.5s ease;
}
.power-chip.is-on { color: var(--chip-red); }
.power-chip:focus-visible { outline: 1.5px solid currentColor; outline-offset: 6px; border-radius: 12px; }

.power-chip__glow {
  position: absolute;
  top: 50%; left: 50%;
  width: 78px; height: 78px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: currentColor;
  filter: blur(20px);
  opacity: 0.4;
  animation: chip-breathe 2.6s ease-in-out infinite;
  pointer-events: none;
}
.power-chip.is-on .power-chip__glow { animation-duration: 1.3s; opacity: 0.55; }

.power-chip__ring {
  position: absolute;
  top: 50%; left: 50%;
  width: 64px; height: 64px;
  margin: -32px 0 0 -32px;
  border-radius: 50%;
  border: 2px solid currentColor;
  opacity: 0;
  pointer-events: none;
}
.power-chip--pulse-once .power-chip__ring { animation: chip-ring-expand 0.85s cubic-bezier(.2,.7,.3,1); }

.power-chip__svg {
  position: relative;
  width: 64px; height: 64px;
  filter: drop-shadow(0 0 10px currentColor);
  transition: filter 0.5s ease;
}
.power-chip__body { transition: stroke 0.5s ease; }
.power-chip__pins { color: inherit; opacity: 0.85; }
.power-chip__core {
  fill: currentColor;
  transform-origin: 32px 32px;
  animation: chip-core-pulse 2.6s ease-in-out infinite;
}
.power-chip.is-on .power-chip__core { animation-duration: 1.3s; }

.power-chip__label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.power-chip.is-on .power-chip__label { color: var(--ink-soft); }

@keyframes chip-breathe {
  0%, 100% { opacity: 0.32; transform: translate(-50%, -50%) scale(0.94); }
  50%      { opacity: 0.52; transform: translate(-50%, -50%) scale(1.08); }
}
@keyframes chip-core-pulse {
  0%, 100% { opacity: 0.75; transform: scale(0.9); }
  50%      { opacity: 1;    transform: scale(1.15); }
}
@keyframes chip-ring-expand {
  0%   { opacity: 0.65; transform: scale(0.5); }
  100% { opacity: 0;    transform: scale(2.4); }
}

@media (prefers-reduced-motion: reduce) {
  .power-chip__glow, .power-chip__core { animation: none; }
  .power-chip--pulse-once .power-chip__ring { animation: none; }
}

/* Gated reveal ----------------------------------------------------------- */
.algo-content > * {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.algo-content.is-revealed > * { opacity: 1; transform: none; }

@media (prefers-reduced-motion: no-preference) {
  .algo-content.is-revealed > *:nth-child(1) { transition-delay: 0s; }
  .algo-content.is-revealed > *:nth-child(2) { transition-delay: 0.06s; }
  .algo-content.is-revealed > *:nth-child(3) { transition-delay: 0.12s; }
  .algo-content.is-revealed > *:nth-child(4) { transition-delay: 0.18s; }
  .algo-content.is-revealed > *:nth-child(5) { transition-delay: 0.24s; }
  .algo-content.is-revealed > *:nth-child(6) { transition-delay: 0.3s; }
  .algo-content.is-revealed > *:nth-child(7) { transition-delay: 0.36s; }
  .algo-content.is-revealed > *:nth-child(8) { transition-delay: 0.42s; }
  .algo-content.is-revealed > *:nth-child(n+9) { transition-delay: 0.46s; }
}
@media (prefers-reduced-motion: reduce) {
  .algo-content > * { transform: none; transition: opacity 0.2s linear; }
}


/* --------------------------------------------------------------------------
   21. Rule-based reasoning
       Module E — forward / backward chaining lab      (prefix  cl-)
       Module F — expert system                         (prefix  es-)
   Kept in one appended block so nothing above is touched.
   -------------------------------------------------------------------------- */
#chaining-lab [hidden], #expert-lab [hidden] { display: none !important; }

/* ---- shared small parts --------------------------------------------------- */
.cl-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; min-width: 0; }
.cl-legend {
  display: flex; flex-wrap: wrap; gap: 0.35rem 1.1rem;
  font-family: var(--mono); font-size: 10.5px; color: var(--ink-mute);
}
.cl-legend i {
  display: inline-block; width: 10px; height: 10px; border-radius: 3px;
  margin-right: 0.4rem; vertical-align: -1px; border: 1.5px solid currentColor;
  background: color-mix(in srgb, currentColor 18%, transparent);
}
.cl-legend i.is-round { border-radius: 50%; }

.cl-fact {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-family: var(--mono); font-size: 10.5px; line-height: 1.2;
  padding: 0.24rem 0.6rem; border-radius: 999px;
  border: 1px solid var(--line-strong); color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.04);
}
.cl-fact--given   { color: var(--cyan);  border-color: color-mix(in srgb, var(--cyan) 55%, transparent);  background: color-mix(in srgb, var(--cyan) 10%, transparent); }
.cl-fact--derived { color: var(--stats); border-color: color-mix(in srgb, var(--stats) 55%, transparent); background: color-mix(in srgb, var(--stats) 10%, transparent); }
.cl-fact--no      { color: var(--pink);  border-color: color-mix(in srgb, var(--pink) 50%, transparent);  background: color-mix(in srgb, var(--pink) 8%, transparent); }
.cl-fact--new     { animation: cl-pop 0.9s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes cl-pop {
  0%   { transform: scale(0.6); opacity: 0; }
  40%  { transform: scale(1.12); opacity: 1; box-shadow: 0 0 14px 2px color-mix(in srgb, currentColor 55%, transparent); }
  100% { transform: scale(1); box-shadow: none; }
}
button.cl-fact { cursor: pointer; }
button.cl-fact:hover { border-color: currentColor; }

.cl-panel {
  border: 1px solid var(--line); border-radius: var(--r);
  background: rgba(255, 255, 255, 0.03);
  padding: 0.8rem 0.9rem; display: flex; flex-direction: column; gap: 0.55rem; min-width: 0;
}
.cl-panel__title {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--ink-mute); margin: 0;
}
.cl-empty { font-family: var(--mono); font-size: 11px; color: var(--ink-mute); margin: 0; }

.cl-log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.25rem; font-family: var(--mono); font-size: 10.5px; color: var(--ink-soft); }
.cl-log li { display: flex; gap: 0.45rem; line-height: 1.4; }
.cl-log li b { color: var(--ink); font-weight: 500; }
.cl-log .is-ok  { color: var(--stats); }
.cl-log .is-bad { color: var(--pink); }
.cl-log .is-fire { color: var(--semantic); }

/* ---- Module E layout ------------------------------------------------------ */
.cl-layout { display: grid; grid-template-columns: minmax(0, 1fr) 270px; gap: 1rem; align-items: stretch; }
.cl-screen { height: 480px; }
.cl-scroll { height: 100%; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.cl-scroll canvas { display: block; height: 100%; min-width: 680px; }
.cl-side { display: flex; flex-direction: column; gap: 0.8rem; min-width: 0; }

.cl-stack { display: flex; flex-direction: column; gap: 0.4rem; min-height: 2.2rem; }
.cl-stack__item {
  display: flex; justify-content: space-between; align-items: baseline; gap: 0.6rem;
  font-family: var(--mono); font-size: 11px;
  padding: 0.4rem 0.6rem; border-radius: 8px;
  color: var(--tensor);
  border: 1px solid color-mix(in srgb, var(--tensor) 50%, transparent);
  background: color-mix(in srgb, var(--tensor) 10%, transparent);
  animation: cl-drop 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
.cl-stack__item small { color: var(--ink-mute); font-size: 10px; }
.cl-stack__item.is-top { box-shadow: inset 0 0 0 1px var(--tensor); }
@keyframes cl-drop { from { transform: translateY(-10px); opacity: 0; } to { transform: none; opacity: 1; } }

.cl-compare { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.7rem; }
.cl-compare__cell {
  border: 1px dashed var(--line-strong); border-radius: var(--r-sm);
  padding: 0.6rem 0.8rem; font-family: var(--mono); font-size: 11px; color: var(--ink-mute); line-height: 1.5;
}
.cl-compare__cell b { display: block; font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; margin-bottom: 0.15rem; color: var(--ink-soft); font-weight: 500; }
.cl-compare__cell.is-set { border-style: solid; color: var(--ink-soft); }
.cl-compare__cell.is-set b { color: var(--accent); }

/* ---- Module F: architecture diagram -------------------------------------- */
.es-arch-screen { padding: 0.5rem; }
.es-arch-scroll { overflow-x: auto; scrollbar-width: thin; }
.es-arch { display: block; width: 100%; min-width: 640px; height: auto; }

.es-node { cursor: pointer; outline: none; --tone: var(--ink); }
.es-node[data-part="engine"] { --tone: var(--logic); }
.es-node[data-part="kb"]     { --tone: var(--tensor); }
.es-node[data-part="wm"]     { --tone: var(--cyan); }
.es-node[data-part="ui"]     { --tone: var(--semantic); }
.es-node[data-part="expl"]   { --tone: var(--attention); }
.es-node[data-part="expert"] { --tone: var(--dsa); }
.es-node[data-part="user"]   { --tone: var(--ink); }
.es-box { fill: rgba(255, 255, 255, 0.04); stroke: rgba(255, 255, 255, 0.2); stroke-width: 1.2; transition: stroke 0.25s, fill 0.25s, filter 0.25s; }
.es-node:hover .es-box, .es-node:focus-visible .es-box { stroke: color-mix(in srgb, var(--tone) 70%, transparent); }
.es-node.is-active .es-box {
  stroke: var(--tone);
  fill: color-mix(in srgb, var(--tone) 15%, transparent);
  filter: drop-shadow(0 0 9px color-mix(in srgb, var(--tone) 60%, transparent));
}
.es-node.is-selected .es-box { stroke-dasharray: 5 3; stroke: var(--tone); }
.es-bar { fill: var(--tone); opacity: 0.85; }
.es-t1 { font: 600 13px var(--display); fill: var(--ink); }
.es-t2 { font: 400 10px var(--mono); fill: var(--ink-mute); }
.es-t3 { font: 500 10px var(--mono); fill: var(--tone); }
.es-cap { font: 400 9px var(--mono); fill: var(--ink-mute); letter-spacing: 0.04em; }
.es-link { fill: none; stroke: rgba(255, 255, 255, 0.16); stroke-width: 1.4; stroke-dasharray: 3 4; transition: stroke 0.2s; }
.es-link.is-lit { stroke: var(--logic); stroke-dasharray: none; }
.es-packet rect { fill: #05060a; stroke-width: 1.3; }
.es-packet text { font: 500 9px var(--mono); text-anchor: middle; dominant-baseline: central; }

.es-partinfo {
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.03); padding: 0.7rem 0.9rem;
  font-size: var(--t-sm); color: var(--ink-soft); line-height: 1.55; min-height: 3.6rem;
}
.es-partinfo b { color: var(--ink); font-family: var(--display); }

/* ---- Module F: operations ------------------------------------------------- */
.es-op { display: flex; flex-direction: column; gap: 0.8rem; padding: 1rem 1.1rem; border: 1px solid var(--line); border-radius: var(--r); background: rgba(255, 255, 255, 0.025); }

.es-qcard {
  border: 1px solid color-mix(in srgb, var(--semantic) 55%, transparent);
  background: color-mix(in srgb, var(--semantic) 8%, transparent);
  border-radius: var(--r); padding: 0.9rem 1rem; display: flex; flex-direction: column; gap: 0.7rem;
  animation: cl-drop 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
.es-qcard__tag { font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--semantic); margin: 0; }
.es-qcard__q { font-family: var(--display); font-size: var(--t-md); color: var(--ink); margin: 0; line-height: 1.35; }

.es-results { display: flex; flex-direction: column; gap: 0.7rem; }
.es-advice {
  border: 1px solid color-mix(in srgb, var(--stats) 55%, transparent);
  background: color-mix(in srgb, var(--stats) 8%, transparent);
  border-radius: var(--r); padding: 0.9rem 1rem; display: flex; flex-direction: column; gap: 0.5rem;
  animation: cl-drop 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
.es-advice--none { border-color: color-mix(in srgb, var(--pink) 55%, transparent); background: color-mix(in srgb, var(--pink) 8%, transparent); }
.es-advice__tag { font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--stats); margin: 0; }
.es-advice--none .es-advice__tag { color: var(--pink); }
.es-advice__title { font-family: var(--display); font-size: var(--t-md); color: var(--ink); margin: 0; }
.es-advice__text { margin: 0; font-size: var(--t-sm); color: var(--ink-soft); line-height: 1.55; }

.es-panels { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr) minmax(0, 1.1fr); gap: 1rem; align-items: start; }
.es-scroll { max-height: 330px; overflow-y: auto; scrollbar-width: thin; padding-right: 0.2rem; }

.es-rule {
  --st: var(--line-strong);
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 0.6rem; align-items: start;
  padding: 0.5rem 0.6rem; border-radius: 8px;
  border: 1px solid var(--line); border-left: 3px solid var(--st);
  background: rgba(255, 255, 255, 0.025);
  font-size: 11.5px; color: var(--ink-soft); line-height: 1.5;
  transition: background 0.25s, border-color 0.25s, opacity 0.25s;
}
.es-rule + .es-rule { margin-top: 0.4rem; }
.es-rule__id { font-family: var(--mono); font-size: 10px; color: var(--ink-mute); padding-top: 0.15rem; }
.es-rule__txt b { color: var(--ink); font-weight: 500; }
.es-rule__txt em { font-style: normal; font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.08em; color: var(--ink-mute); }
.es-rule[data-state="test"]  { --st: var(--semantic); background: color-mix(in srgb, var(--semantic) 10%, transparent); }
.es-rule[data-state="fired"] { --st: var(--stats);    background: color-mix(in srgb, var(--stats) 9%, transparent); }
.es-rule[data-state="fail"]  { --st: var(--pink);     background: color-mix(in srgb, var(--pink) 7%, transparent); }
.es-rule[data-state="off"]   { opacity: 0.45; }
.es-rule.is-custom { border-style: dashed; border-left-style: solid; }
.es-rule__del { background: none; border: 0; color: var(--ink-mute); cursor: pointer; font-size: 15px; line-height: 1; padding: 0 0.15rem; }
.es-rule__del:hover { color: var(--pink); }
.es-rule__tools { display: flex; align-items: center; gap: 0.3rem; }

.es-switch { position: relative; display: inline-block; width: 28px; height: 16px; flex: none; }
.es-switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 2; }
.es-switch span { position: absolute; inset: 0; border-radius: 999px; background: rgba(255, 255, 255, 0.14); transition: background 0.2s; }
.es-switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--ink); transition: transform 0.2s; }
.es-switch input:checked + span { background: color-mix(in srgb, var(--stats) 70%, transparent); }
.es-switch input:checked + span::after { transform: translateX(12px); }
.es-switch input:focus-visible + span { outline: 1.5px solid var(--accent); outline-offset: 2px; }

.es-explain { display: flex; flex-direction: column; gap: 0.5rem; font-size: 12px; color: var(--ink-soft); line-height: 1.55; }
.es-explain p { margin: 0; }
.es-explain b { color: var(--ink); font-weight: 500; }
.es-explain__lead { font-family: var(--display); color: var(--ink); font-size: 13px; }
.es-tree, .es-tree ul { list-style: none; margin: 0; padding: 0; }
.es-tree ul { margin-left: 0.7rem; padding-left: 0.8rem; border-left: 1px dashed var(--line-strong); }
.es-tree li { padding: 0.25rem 0; animation: cl-drop 0.35s cubic-bezier(0.22, 1, 0.36, 1) both; }
.es-tree .es-tag { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.06em; color: var(--semantic); margin-left: 0.35rem; }
.es-tree .is-you { color: var(--cyan); }

.es-select {
  background: rgba(0, 0, 0, 0.45); border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  padding: 0.45rem 0.55rem; font-family: var(--mono); font-size: 11.5px; color: var(--ink);
  min-width: 0; max-width: 100%;
}
.es-select:focus { outline: none; border-color: var(--accent); }
.es-select option { background: #0d1018; color: var(--ink); }
.es-builder { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.es-builder .field-label { color: var(--accent); }
.es-builder .text-input { color: var(--ink); width: 15rem; max-width: 100%; }

/* ---- Module F: "is it really AI?" checklist -------------------------------- */
.es-agent-wrap { border-top: 1px solid var(--line); padding-top: 1.1rem; display: flex; flex-direction: column; gap: 0.8rem; }
.es-agent { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0.6rem; }
.es-agent__item {
  position: relative; border: 1px solid var(--line); border-radius: 10px;
  padding: 0.7rem 0.75rem 0.75rem; background: rgba(255, 255, 255, 0.025);
  display: flex; flex-direction: column; gap: 0.25rem;
  transition: border-color 0.35s, background 0.35s;
}
.es-agent__item b { font-family: var(--display); font-size: 13px; color: var(--ink-soft); font-weight: 600; transition: color 0.35s; }
.es-agent__item span { font-size: 11px; color: var(--ink-mute); line-height: 1.4; }
.es-agent__item em { font-style: normal; font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.06em; color: var(--ink-mute); }
.es-agent__tick {
  position: absolute; top: 0.6rem; right: 0.6rem; width: 16px; height: 16px; border-radius: 50%;
  border: 1.5px solid var(--line-strong); display: flex; align-items: center; justify-content: center;
  color: transparent; font-size: 10px; line-height: 1; transition: all 0.35s;
}
.es-agent__item.is-on { border-color: color-mix(in srgb, var(--stats) 60%, transparent); background: color-mix(in srgb, var(--stats) 9%, transparent); }
.es-agent__item.is-on b { color: var(--ink); }
.es-agent__item.is-on .es-agent__tick { background: var(--stats); border-color: var(--stats); color: #05060a; }
.es-agent__item.is-new { animation: cl-pop 0.9s cubic-bezier(0.22, 1, 0.36, 1); }
.es-agent-note {
  margin: 0; font-size: var(--t-sm); color: var(--ink-soft); line-height: 1.55;
  padding: 0.75rem 0.9rem; border-radius: var(--r-sm); border: 1px solid var(--line); background: rgba(255, 255, 255, 0.025);
}
.es-agent-note.is-done { border-color: color-mix(in srgb, var(--stats) 55%, transparent); background: color-mix(in srgb, var(--stats) 8%, transparent); color: var(--ink); }

@media (max-width: 960px) {
  .cl-layout { grid-template-columns: minmax(0, 1fr); }
  .es-panels { grid-template-columns: minmax(0, 1fr); }
  .es-agent { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .es-scroll { max-height: 280px; }
}
@media (max-width: 560px) {
  .cl-compare { grid-template-columns: minmax(0, 1fr); }
  .es-agent { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cl-screen { height: 440px; }
}
@media (prefers-reduced-motion: reduce) {
  .cl-fact--new, .cl-stack__item, .es-qcard, .es-advice, .es-tree li, .es-agent__item.is-new { animation: none; }
}

.cl-swipe { display: none; }
@media (max-width: 720px) { .cl-swipe { display: block; } }

/* --------------------------------------------------------------------------
   ML page — sound toggle + generic mode-row helpers shared by the new labs
   -------------------------------------------------------------------------- */
.sound-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; flex: none;
  border-radius: 999px; border: 1px solid var(--line);
  background: rgba(255,255,255,0.06); color: var(--ink-soft);
  cursor: pointer; transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.sound-toggle:hover { background: rgba(255,255,255,0.12); color: var(--ink); }
.sound-toggle svg { width: 16px; height: 16px; }
.sound-toggle .icon-muted { display: none; }
.sound-toggle.is-muted .icon-on { display: none; }
.sound-toggle.is-muted .icon-muted { display: block; }

.mode-row { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }
.param-row { display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; }
.param-row .field-label { flex: none; }
.param-row .nx-slider { flex: 1; min-width: 8rem; max-width: 14rem; }

.legend-row { display: flex; gap: 1rem; flex-wrap: wrap; font-family: var(--mono); font-size: 10.5px; color: var(--ink-mute); }
.legend-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 0.4rem; vertical-align: middle; }
.legend-sq { display: inline-block; width: 9px; height: 9px; margin-right: 0.4rem; vertical-align: middle; }

.ml-stat-row { display: flex; gap: 1.4rem; flex-wrap: wrap; }

.qgrid-legend { display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; font-family: var(--mono); font-size: 10.5px; color: var(--ink-mute); }

@media (prefers-reduced-motion: reduce) {
  .wm-chip, .trace-log__line { animation: none; opacity: 1; transform: none; }
}

/* --------------------------------------------------------------------------
   Decision Tree lab (Module C) — its own bespoke component set: a live SVG
   tree diagram, a two-phase guided-build narration panel, candidate-split
   comparison bars, an impurity gauge, and a predict-mode trace readout.
   Scoped entirely to .dt-* so it never leans on another module's classes.
   -------------------------------------------------------------------------- */
.dt-tabs { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.dt-layout { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 1.2rem; align-items: stretch; }
@media (max-width: 900px) { .dt-layout { grid-template-columns: minmax(0,1fr); } }

.dt-tree-wrap {
  border: 1px solid var(--line); border-radius: var(--r);
  background: rgba(255,255,255,0.02);
  overflow: auto; height: 360px;
}
.dt-tree-svg { display: block; }
.dt-node rect, .dt-node circle {
  fill: #0b1220; stroke: rgba(255,255,255,0.28); stroke-width: 2;
  transition: stroke 0.3s, filter 0.3s;
}
.dt-node text {
  fill: var(--ink-mute); font-family: var(--mono); text-anchor: middle;
  dominant-baseline: central; pointer-events: none;
}
.dt-node__title { font-size: 10px; font-weight: 700; }
.dt-node__sub { font-size: 8.5px; }
.dt-node.is-leaf.cls-a rect, .dt-node.is-leaf.cls-a circle { stroke: var(--cyan); }
.dt-node.is-leaf.cls-b rect, .dt-node.is-leaf.cls-b circle { stroke: var(--pink); }
.dt-node.is-leaf.cls-a text.dt-node__title { fill: var(--cyan); }
.dt-node.is-leaf.cls-b text.dt-node__title { fill: var(--pink); }
.dt-node.is-focus rect { stroke: #fbbf24; filter: drop-shadow(0 0 7px #fbbf24); animation: dt-pulse 1s ease-in-out infinite; }
.dt-node.is-tracing rect, .dt-node.is-tracing circle { stroke: #fbbf24; filter: drop-shadow(0 0 5px #fbbf24); }
.dt-node.is-result rect, .dt-node.is-result circle { stroke: var(--green, #34d399); filter: drop-shadow(0 0 9px var(--green, #34d399)); }
@keyframes dt-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
@media (prefers-reduced-motion: reduce) { .dt-node.is-focus rect { animation: none; } }

.dt-edge { stroke: rgba(255,255,255,0.18); stroke-width: 1.6; transition: stroke 0.3s, stroke-width 0.3s; }
.dt-edge.is-tracing { stroke: #fbbf24; stroke-width: 2.6; }
.dt-cutoff { stroke: rgba(255,77,157,0.55); stroke-width: 1.2; stroke-dasharray: 5 4; }
.dt-cutoff-label { fill: rgba(255,77,157,0.85); font-family: var(--mono); font-size: 9px; }

.dt-gauge { position: relative; height: 8px; border-radius: 4px; background: rgba(255,255,255,0.08); overflow: hidden; }
.dt-gauge__fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--green,#34d399), var(--amber,#fbbf24) 55%, var(--pink)); transition: width 0.5s ease; }

.dt-cand-list { display: flex; flex-direction: column; gap: 0.4rem; }
.dt-cand-row { display: flex; align-items: center; gap: 0.6rem; font-family: var(--mono); font-size: 10.5px; color: var(--ink-mute); }
.dt-cand-row__label { flex: none; width: 7.2rem; }
.dt-cand-row__bar { flex: 1; height: 7px; border-radius: 4px; background: rgba(255,255,255,0.06); overflow: hidden; }
.dt-cand-row__bar > span { display: block; height: 100%; width: 0%; background: var(--ink-soft); transition: width 0.55s ease; }
.dt-cand-row.is-winner { color: var(--ink); }
.dt-cand-row.is-winner .dt-cand-row__bar > span { background: #fbbf24; }
.dt-cand-row__gain { flex: none; width: 3.6rem; text-align: right; }

.dt-list { display: flex; flex-direction: column; gap: 0.4rem; max-height: 280px; overflow-y: auto; padding-right: 0.35rem; }
.dt-row {
  display: flex; gap: 0.55rem; padding: 0.5rem 0.7rem;
  border: 1px solid var(--line); border-radius: 8px;
  font-family: var(--mono); font-size: 11px; color: var(--ink-mute);
  background: rgba(255,255,255,0.02); transition: border-color 0.3s, background 0.3s, color 0.3s;
}
.dt-row__id { flex: none; font-weight: 700; color: var(--accent); min-width: 2.2em; }
.dt-row.is-latest { border-color: var(--green, #34d399); background: color-mix(in srgb, var(--green, #34d399) 12%, transparent); color: var(--ink); }
.dt-empty { color: var(--ink-mute); font-style: italic; font-family: var(--mono); font-size: 11.5px; }

.dt-narration { font-family: var(--mono); font-size: 12.5px; line-height: 1.65; color: var(--ink-soft); min-height: 3.3em; }

.dt-predict-result {
  display: flex; align-items: center; gap: 0.9rem;
  border: 1px solid var(--line-strong); border-radius: var(--r);
  padding: 0.9rem 1.1rem; background: rgba(255,255,255,0.03);
  transition: border-color 0.3s, background 0.3s;
}
.dt-predict-result__icon { font-size: 1.7rem; line-height: 1; }
.dt-predict-result.cls-a { border-color: var(--cyan); background: color-mix(in srgb, var(--cyan) 8%, transparent); }
.dt-predict-result.cls-b { border-color: var(--pink); background: color-mix(in srgb, var(--pink) 8%, transparent); }

[data-dtree-panel] { display: none; }
[data-dtree-panel].is-active { display: block; }

/* --------------------------------------------------------------------------
   Modules D–I: random forest, SVM, Naive Bayes, logistic regression,
   polynomial regression, and the confusion-matrix / metrics instrument.
   -------------------------------------------------------------------------- */

/* Random forest — committee of mini trees */
.rf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 0.5rem; }
.rf-mini { position: relative; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: rgba(255,255,255,0.02); aspect-ratio: 1; opacity: 0; transform: scale(0.85); animation: rf-pop 0.4s ease forwards; }
.rf-mini canvas { display: block; width: 100%; height: 100%; }
.rf-mini__label { position: absolute; bottom: 2px; left: 4px; font-family: var(--mono); font-size: 8.5px; color: rgba(255,255,255,0.55); pointer-events: none; }
@keyframes rf-pop { to { opacity: 1; transform: scale(1); } }
.rf-vote-row { display: flex; align-items: center; gap: 0.6rem; font-family: var(--mono); font-size: 11px; color: var(--ink-mute); }
.rf-vote-row__bar { flex: 1; height: 9px; border-radius: 5px; background: rgba(255,255,255,0.07); overflow: hidden; }
.rf-vote-row__bar > span { display: block; height: 100%; width: 0%; transition: width 0.4s ease; }

/* SVM — drag cue */
.svm-drag-hint { font-family: var(--mono); font-size: 10.5px; color: var(--ink-mute); }
.svm-canvas-wrap { position: relative; }
.svm-canvas-wrap.is-dragging canvas { cursor: grabbing; }

/* Logistic regression — sigmoid companion */
.logreg-sig-wrap { border: 1px solid var(--line); border-radius: var(--r); background: rgba(255,255,255,0.02); height: 140px; }

/* Naive Bayes probability bars (shared row pattern, reused by other modules too) */
.prob-bar-row { display: grid; grid-template-columns: 6.5rem 1fr 3.4rem; align-items: center; gap: 0.6rem; }
.prob-bar-track { height: 9px; border-radius: 5px; background: rgba(255,255,255,0.08); overflow: hidden; }
.prob-bar-fill { height: 100%; width: 0%; transition: width 0.35s ease; }

/* Polynomial regression — error-vs-degree elbow chart */
.poly-elbow { display: flex; align-items: flex-end; gap: 3px; height: 72px; }
.poly-elbow__bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; }
.poly-elbow__seg { width: 100%; border-radius: 2px 2px 0 0; transition: height 0.4s ease; }
.poly-elbow__label { text-align: center; font-family: var(--mono); font-size: 9px; color: var(--ink-mute); margin-top: 3px; }

/* Confusion matrix + metrics instrument */
.cm-layout { display: grid; grid-template-columns: minmax(0,1.1fr) minmax(0,0.9fr); gap: 1.4rem; align-items: start; }
@media (max-width: 900px) { .cm-layout { grid-template-columns: minmax(0,1fr); } }
.cm-strip { position: relative; height: 92px; border: 1px solid var(--line); border-radius: var(--r); background: rgba(255,255,255,0.02); overflow: hidden; }
.cm-strip__pt { position: absolute; width: 8px; height: 8px; border-radius: 50%; transform: translate(-50%, -50%); transition: box-shadow 0.25s ease; }
.cm-strip__threshold { position: absolute; top: 0; bottom: 0; width: 2px; background: #fbbf24; cursor: ew-resize; box-shadow: 0 0 8px #fbbf24; }
.cm-strip__threshold::after { content: ""; position: absolute; top: -6px; left: 50%; transform: translateX(-50%); width: 14px; height: 14px; border-radius: 50%; background: #fbbf24; }
.cm-legend { display: flex; gap: 1rem; flex-wrap: wrap; font-family: var(--mono); font-size: 10px; color: var(--ink-mute); }

.cm-grid { display: grid; grid-template-columns: auto 1fr 1fr; grid-template-rows: auto 1fr 1fr; gap: 4px; font-family: var(--mono); }
.cm-grid__corner, .cm-grid__hdr { display: flex; align-items: center; justify-content: center; font-size: 9.5px; color: var(--ink-mute); text-align: center; padding: 0.3rem; }
.cm-cell {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 10px; padding: 0.8rem 0.4rem; min-height: 74px;
  border: 1px solid var(--line-strong); background: rgba(255,255,255,0.03);
  transition: background 0.3s, border-color 0.3s;
}
.cm-cell__n { font-size: 1.5rem; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.cm-cell__label { font-size: 9px; color: var(--ink-mute); margin-top: 0.15rem; letter-spacing: 0.04em; }
.cm-cell.is-tp { border-color: var(--green, #34d399); background: color-mix(in srgb, var(--green,#34d399) 12%, transparent); }
.cm-cell.is-tn { border-color: var(--cyan); background: color-mix(in srgb, var(--cyan) 10%, transparent); }
.cm-cell.is-fp { border-color: var(--pink); background: color-mix(in srgb, var(--pink) 12%, transparent); }
.cm-cell.is-fn { border-color: #fb923c; background: color-mix(in srgb, #fb923c 12%, transparent); }

.metric-row { display: grid; grid-template-columns: 1fr auto; gap: 0.4rem 0.8rem; align-items: baseline; font-family: var(--mono); font-size: 12px; }
.metric-row dt { color: var(--ink-mute); }
.metric-row dd { margin: 0; color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.metric-row dd.is-hero { font-size: 1.1rem; color: var(--accent); }

.err-bars { display: flex; align-items: center; height: 90px; gap: 3px; border-bottom: 1px solid var(--line); }
.err-bar { flex: 1; position: relative; height: 100%; display: flex; align-items: center; justify-content: center; }
.err-bar__seg { position: absolute; left: 20%; right: 20%; border-radius: 2px; transition: height 0.35s ease, top 0.35s ease; }
