/* ============================================================
   Shared design system for the research briefings.
   Linked by index.html (Part 01) and emotion-ai.html (Part 02).
   :root holds the dark theme; [data-theme="light"] overrides it.
   ============================================================ */
/* =========================================================
   THEME TOKENS
   :root holds the DARK theme (the original design).
   [data-theme="light"] overrides only what changes.
   Every colour used anywhere on this page — CSS *and* the
   inline SVG diagrams — resolves through one of these.
   ========================================================= */
:root {
  color-scheme: dark;

  /* ---- surfaces ---- */
  --bg: #030712;
  --panel-bg: #0b0f19;
  --card-bg: #111827;
  --card-hover: #1f293d;
  --surface-deep: #040711;
  --surface-header: #090e1a;   /* table head, code-box head */
  --surface-tabs: #070a13;     /* simulator tab rail        */
  --surface-code: #030611;     /* <pre> block               */
  --nav-bg: rgba(3, 7, 18, 0.82);
  --panel-grad-a: rgba(11, 15, 25, 0.9);
  --panel-grad-b: rgba(4, 7, 17, 0.9);
  --card-grad-a: rgba(17, 24, 39, 0.85);
  --card-grad-b: rgba(11, 15, 25, 0.85);
  --scroll-thumb: #2b3555;

  /* ---- overlays (washes layered over a surface) ---- */
  --overlay-1: rgba(255, 255, 255, 0.015);
  --overlay-2: rgba(255, 255, 255, 0.02);
  --overlay-3: rgba(255, 255, 255, 0.05);
  --overlay-line: rgba(255, 255, 255, 0.08);
  --overlay-border: rgba(255, 255, 255, 0.12);
  --shadow-lg: rgba(0, 0, 0, 0.5);
  --shadow-md: rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 12px 24px var(--primary-glow);
  --grid-line: rgba(99, 102, 241, 0.05);
  --selection-bg: rgba(99, 102, 241, 0.35);
  --selection-ink: #fff;

  /* ---- lines ---- */
  --border: rgba(99, 102, 241, 0.2);
  --border-bright: rgba(99, 102, 241, 0.5);
  --hairline: rgba(148, 163, 184, 0.16);

  /* ---- UI accents (chrome, glow, borders) ---- */
  --primary: #6366f1;
  --primary-glow: rgba(99, 102, 241, 0.3);
  --accent-cyan: #06b6d4;
  --accent-green: #10b981;
  --accent-red: #ef4444;
  --accent-amber: #f59e0b;
  --accent-purple: #a855f7;

  /* ---- data-mark palette (validated for this dark surface:
         lightness band, chroma floor, CVD separation, contrast) ---- */
  --viz-1: #6366f1;  /* indigo  */
  --viz-2: #ef4444;  /* red     */
  --viz-3: #059669;  /* green   */
  --viz-4: #a855f7;  /* purple  */
  --viz-5: #d97706;  /* amber   */
  --viz-6: #0891b2;  /* cyan    */
  --viz-neutral: #475569;

  /* ---- ink ---- */
  --text-strong: #ffffff;   /* headings, display numbers */
  --text-bright: #e2e8f0;   /* emphasised body           */
  --text-main: #f9fafb;
  --text-sub: #9ca3af;
  --text-muted: #6b7280;
  --on-accent: #ffffff;     /* ink on a saturated fill — never themed */

  /* ---- accent inks: an accent used as TEXT on a tinted wash.
         Dark theme = pale tint; light theme = deep shade.        ---- */
  --ink-red: #fca5a5;
  --ink-red-soft: #fecaca;
  --ink-green: #6ee7b7;
  --ink-green-soft: #a7f3d0;
  --ink-indigo: #c7d2fe;
  --ink-indigo-soft: #a5b4fc;
  --ink-cyan: #67e8f9;
  --ink-cyan-bright: #22d3ee;
  --ink-amber: #fcd34d;
  --ink-purple: #c4b5fd;
  --ink-purple-soft: #e9d5ff;
  --ink-slate: #94a3b8;

  /* ---- syntax highlighting (fn/str/num reuse the ink tokens) ---- */
  --tok-kw-c: #c084fc;
  --tok-com-c: #64748b;
  --tok-cls-c: #fda4af;

  /* ---- diagram surfaces + lines (inline SVG) ---- */
  --svg-node: #111827;          /* boxed node fill             */
  --svg-panel: #0b0f19;         /* recessed panel fill         */
  --svg-halo: #0b0f19;          /* ring separating dot from bg */
  --svg-tint-red: #160d16;      /* danger-tinted panel         */
  --svg-tint-red-strong: #1a0c12;
  --svg-tint-purple: #160f24;
  --svg-line: rgba(99, 102, 241, 0.35);
  --svg-hairline: rgba(148, 163, 184, 0.16);
  --svg-hairline-soft: rgba(148, 163, 184, 0.1);

  /* ---- display gradients: --hero-grad for Part 01, --part-grad for Part 02 ---- */
  --hero-grad: linear-gradient(135deg, #fff 0%, #a5b4fc 48%, #22d3ee 100%);
  --part-grad: linear-gradient(135deg, #fff 0%, #c4b5fd 55%, #22d3ee 100%);
  --aurora-a-c: #4338ca;
  --aurora-b-c: #0e7490;
  --aurora-c-c: #7f1d1d;
  --aurora-op: 0.5;
  --aurora-op-c: 0.35;

  --font-code: 'JetBrains Mono', ui-monospace, monospace;

  --radius-lg: 20px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --shell: 1200px;
}

/* ============ LIGHT THEME ============ */
:root[data-theme="light"] {
  color-scheme: light;

  --bg: #f6f7fb;
  --panel-bg: #ffffff;
  --card-bg: #ffffff;
  --card-hover: #f1f5f9;
  --surface-deep: #f8fafc;
  --surface-header: #f1f5f9;
  --surface-tabs: #eef2f7;
  --surface-code: #f8fafc;
  --nav-bg: rgba(255, 255, 255, 0.86);
  --panel-grad-a: rgba(255, 255, 255, 0.96);
  --panel-grad-b: rgba(248, 250, 252, 0.96);
  --card-grad-a: rgba(255, 255, 255, 0.96);
  --card-grad-b: rgba(246, 247, 251, 0.96);
  --scroll-thumb: #c3cad8;

  --overlay-1: rgba(15, 23, 42, 0.015);
  --overlay-2: rgba(15, 23, 42, 0.025);
  --overlay-3: rgba(15, 23, 42, 0.05);
  --overlay-line: rgba(15, 23, 42, 0.09);
  --overlay-border: rgba(15, 23, 42, 0.13);
  --shadow-lg: rgba(15, 23, 42, 0.11);
  --shadow-md: rgba(15, 23, 42, 0.08);
  --shadow-glow: 0 12px 24px rgba(79, 70, 229, 0.28);
  --grid-line: rgba(79, 70, 229, 0.07);
  --selection-bg: rgba(79, 70, 229, 0.2);
  --selection-ink: #0f172a;

  --border: rgba(79, 70, 229, 0.2);
  --border-bright: rgba(79, 70, 229, 0.45);
  --hairline: rgba(15, 23, 42, 0.1);

  --primary: #4f46e5;
  --primary-glow: rgba(79, 70, 229, 0.25);
  --accent-cyan: #0e7490;
  --accent-green: #047857;
  --accent-red: #dc2626;
  --accent-amber: #b45309;
  --accent-purple: #7e22ce;

  /* re-validated for a white surface: same hue order, lifted
     chroma and dropped lightness so every mark clears 3:1 */
  --viz-1: #4f46e5;
  --viz-2: #dc2626;
  --viz-3: #047857;
  --viz-4: #9333ea;
  --viz-5: #b45309;
  --viz-6: #0e7490;
  --viz-neutral: #64748b;

  --text-strong: #0f172a;
  --text-bright: #1e293b;
  --text-main: #1f2937;
  --text-sub: #4b5563;
  --text-muted: #5b6573;

  /* These inks sit on a same-hue tinted chip (pills, severity tags),
     so they run a step darker than the plain-on-white accents above
     to clear 4.5:1 against that wash rather than against the page. */
  --ink-red: #b91c1c;
  --ink-red-soft: #991b1b;
  --ink-green: #065f46;
  --ink-green-soft: #064e3b;
  --ink-indigo: #4338ca;
  --ink-indigo-soft: #4f46e5;
  --ink-cyan: #0e7490;
  --ink-cyan-bright: #0891b2;
  --ink-amber: #92400e;
  --ink-purple: #6d28d9;
  --ink-purple-soft: #7e22ce;
  --ink-slate: #475569;

  --tok-kw-c: #7e22ce;
  --tok-com-c: #64748b;
  --tok-cls-c: #be123c;

  --svg-node: #ffffff;
  --svg-panel: #f1f5f9;
  --svg-halo: #ffffff;
  --svg-tint-red: #fef2f2;
  --svg-tint-red-strong: #fee2e2;
  --svg-tint-purple: #f5f3ff;
  --svg-line: rgba(79, 70, 229, 0.35);
  --svg-hairline: rgba(15, 23, 42, 0.14);
  --svg-hairline-soft: rgba(15, 23, 42, 0.09);

  --hero-grad: linear-gradient(135deg, #0f172a 0%, #4338ca 48%, #0e7490 100%);
  --part-grad: linear-gradient(135deg, #0f172a 0%, #6d28d9 55%, #0e7490 100%);
  --aurora-a-c: #a5b4fc;
  --aurora-b-c: #a5f3fc;
  --aurora-c-c: #fecaca;
  --aurora-op: 0.42;
  --aurora-op-c: 0.3;
}

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

html { scroll-behavior: smooth; scroll-padding-top: 90px; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background-color: var(--bg);
  color: var(--text-main);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Grid + vignette background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
  background-size: 40px 40px;
  -webkit-mask-image: radial-gradient(ellipse 90% 60% at 50% 0%, #000 25%, transparent 78%);
  mask-image: radial-gradient(ellipse 90% 60% at 50% 0%, #000 25%, transparent 78%);
  pointer-events: none;
  z-index: 0;
}

::selection { background: var(--selection-bg); color: var(--selection-ink); }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ============ NAVIGATION ============ */
nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  background: var(--nav-bg);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
}
.nav-container {
  max-width: var(--shell);
  margin: 0 auto;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 2rem;
}
.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--text-strong);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}
.logo svg { flex-shrink: 0; }
.logo-badge {
  background: linear-gradient(135deg, var(--accent-red), var(--accent-purple));
  font-size: 0.65rem;
  padding: 3px 9px;
  border-radius: 99px;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.05em;
}
.nav-links {
  display: flex;
  gap: 1.15rem;
  list-style: none;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 4px 0;
}
.nav-links::-webkit-scrollbar { display: none; }
.nav-links a {
  position: relative;
  color: var(--text-sub);
  text-decoration: none;
  font-size: 0.86rem;
  font-weight: 500;
  white-space: nowrap;
  transition: color 0.2s ease;
  padding-bottom: 3px;
}
.nav-links a::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 2px;
  border-radius: 2px;
  background: var(--accent-cyan);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.25s ease;
}
.nav-links a:hover { color: var(--text-bright); }
.nav-links a.active { color: var(--accent-cyan); }
.nav-links a.active::after,
.nav-links a:hover::after { transform: scaleX(1); }

/* theme toggle */
.theme-toggle {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  cursor: pointer;
  background: var(--overlay-3);
  border: 1px solid var(--border);
  color: var(--text-sub);
  transition: color .2s ease, background .2s ease, border-color .2s ease;
}
.theme-toggle:hover {
  color: var(--accent-cyan);
  border-color: var(--border-bright);
  background: var(--overlay-line);
}
.theme-toggle:focus-visible {
  outline: 2px solid var(--accent-cyan);
  outline-offset: 2px;
}
.theme-toggle svg { display: block; }
/* show the destination theme, not the current one:
   dark now → sun (click for light); light now → moon (click for dark) */
.theme-toggle .icon-moon { display: none; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: block; }
:root[data-theme="light"] .theme-toggle .icon-sun { display: none; }

/* scroll progress */
#progress {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--accent-cyan));
  z-index: 101;
  box-shadow: 0 0 12px var(--accent-cyan);
}

/* ============ HERO ============ */
.hero {
  position: relative;
  padding: 150px 2rem 70px;
  text-align: center;
  max-width: 1100px;
  margin: 0 auto;
  z-index: 1;
}
.aurora {
  position: absolute;
  border-radius: 50%;
  filter: blur(110px);
  pointer-events: none;
  z-index: -1;
  opacity: var(--aurora-op);
}
.aurora-a { width: 520px; height: 380px; background: var(--aurora-a-c); top: 20px; left: -60px; }
.aurora-b { width: 460px; height: 340px; background: var(--aurora-b-c); top: 90px; right: -40px; }
.aurora-c { width: 380px; height: 260px; background: var(--aurora-c-c); top: 300px; left: 40%; opacity: var(--aurora-op-c); }

.hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  background: rgba(239, 68, 68, 0.09);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--ink-red);
  padding: 7px 16px;
  border-radius: 99px;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 1.6rem;
}
.hero-tag span.dot {
  width: 8px; height: 8px;
  background: var(--accent-red);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--accent-red);
}
.hero h1 {
  font-size: clamp(2.3rem, 5.2vw, 4rem);
  font-weight: 900;
  line-height: 1.12;
  letter-spacing: -0.025em;
  margin-bottom: 1.4rem;
  background: var(--hero-grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero > p {
  font-size: 1.12rem;
  color: var(--text-sub);
  max-width: 780px;
  margin: 0 auto;
}

/* Key Statistics */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 1.25rem;
  margin-top: 3.25rem;
}
.stat-card {
  position: relative;
  background: linear-gradient(180deg, var(--card-grad-a), var(--card-grad-b));
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.6rem 1.25rem;
  text-align: left;
  overflow: hidden;
  transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 1.25rem; right: 1.25rem;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  opacity: 0.85;
}
.stat-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-bright);
  box-shadow: 0 18px 40px var(--shadow-md);
}
.stat-card.c-red { color: var(--accent-red); }
.stat-card.c-amber { color: var(--accent-amber); }
.stat-card.c-purple { color: var(--accent-purple); }
.stat-card.c-cyan { color: var(--accent-cyan); }
.stat-val {
  font-size: clamp(2rem, 4vw, 2.6rem);
  font-weight: 800;
  line-height: 1.05;
  color: currentColor;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
  /* proportional figures — never tabular on a display number */
}
.stat-lbl {
  font-size: 0.78rem;
  color: var(--text-sub);
  line-height: 1.45;
}
.stat-src {
  margin-top: 0.6rem;
  font-family: var(--font-code);
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ============ SECTIONS ============ */
section {
  position: relative;
  z-index: 1;
  max-width: var(--shell);
  margin: 0 auto;
  padding: 84px 2rem;
}
.section-header { margin-bottom: 2.75rem; }
.eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-code);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-cyan);
  margin-bottom: 0.9rem;
}
.eyebrow::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--border-bright), transparent);
}
.section-title {
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-strong);
  margin-bottom: 0.8rem;
  display: flex;
  align-items: center;
  gap: 12px;
}
.section-sub {
  color: var(--text-sub);
  font-size: 1.02rem;
  max-width: 760px;
}

/* ============ FIGURE / DIAGRAM SHELL ============ */
figure {
  margin: 2.5rem 0 0;
  background: linear-gradient(180deg, var(--panel-grad-a), var(--panel-grad-b));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.fig-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--hairline);
  background: var(--overlay-1);
}
.fig-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-strong);
  display: flex;
  align-items: center;
  gap: 9px;
}
.fig-kicker {
  font-family: var(--font-code);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}
.fig-scroll { overflow-x: auto; padding: 1.5rem; }
.fig-scroll svg { display: block; width: 100%; height: auto; }
.fig-scroll.wide svg { min-width: 720px; }
.fig-scroll.med svg { min-width: 560px; }
figcaption {
  padding: 0 1.5rem 1.35rem;
  font-size: 0.85rem;
  color: var(--text-sub);
  max-width: 900px;
}
figcaption b { color: var(--text-bright); font-weight: 600; }

/* SVG typography tokens */
.dg-h      { font: 700 13px 'Inter', sans-serif; fill: var(--text-main); }
.dg-t      { font: 600 12.5px 'Inter', sans-serif; fill: var(--text-bright); }
.dg-s      { font: 400 11px 'Inter', sans-serif; fill: var(--text-sub); }
.dg-xs     { font: 400 10px 'Inter', sans-serif; fill: var(--text-muted); }
.dg-cap    { font: 700 9.5px 'Inter', sans-serif; fill: var(--text-muted); letter-spacing: 1.4px; }
.dg-mono   { font: 500 10.5px 'JetBrains Mono', monospace; fill: var(--ink-slate); }
.dg-num    { font: 800 13px 'JetBrains Mono', monospace; fill: var(--text-strong); }
.dg-red    { fill: var(--ink-red); }
.dg-green  { fill: var(--ink-green); }
.dg-cyanf  { fill: var(--ink-cyan); }
.dg-amberf { fill: var(--ink-amber); }

/* ---------------------------------------------------------
   SVG theming safety net.
   The diagrams carry their colours as presentation attributes
   (fill="var(--token)"). Chromium and Safari resolve var()
   there, but support is not universal. An author rule always
   outranks a presentation attribute, so these restate the same
   token as real CSS and guarantee every mark is painted -- and
   repainted on theme switch -- in every engine.
   --------------------------------------------------------- */
[fill="var(--ink-red)"] { fill: var(--ink-red); }
[fill="var(--ink-slate)"] { fill: var(--ink-slate); }
[fill="var(--svg-node)"] { fill: var(--svg-node); }
[fill="var(--svg-panel)"] { fill: var(--svg-panel); }
[fill="var(--svg-tint-purple)"] { fill: var(--svg-tint-purple); }
[fill="var(--svg-tint-red)"] { fill: var(--svg-tint-red); }
[fill="var(--svg-tint-red-strong)"] { fill: var(--svg-tint-red-strong); }
[fill="var(--viz-1)"] { fill: var(--viz-1); }
[fill="var(--viz-2)"] { fill: var(--viz-2); }
[fill="var(--viz-3)"] { fill: var(--viz-3); }
[fill="var(--viz-4)"] { fill: var(--viz-4); }
[fill="var(--viz-5)"] { fill: var(--viz-5); }
[fill="var(--viz-6)"] { fill: var(--viz-6); }
[fill="var(--viz-neutral)"] { fill: var(--viz-neutral); }
[stroke="var(--accent-cyan)"] { stroke: var(--accent-cyan); }
[stroke="var(--accent-green)"] { stroke: var(--accent-green); }
[stroke="var(--border-bright)"] { stroke: var(--border-bright); }
[stroke="var(--primary)"] { stroke: var(--primary); }
[stroke="var(--svg-hairline)"] { stroke: var(--svg-hairline); }
[stroke="var(--svg-hairline-soft)"] { stroke: var(--svg-hairline-soft); }
[stroke="var(--svg-halo)"] { stroke: var(--svg-halo); }
[stroke="var(--svg-line)"] { stroke: var(--svg-line); }
[stroke="var(--viz-1)"] { stroke: var(--viz-1); }
[stroke="var(--viz-2)"] { stroke: var(--viz-2); }
[stroke="var(--viz-3)"] { stroke: var(--viz-3); }
[stroke="var(--viz-4)"] { stroke: var(--viz-4); }
[stroke="var(--viz-5)"] { stroke: var(--viz-5); }
[stroke="var(--viz-6)"] { stroke: var(--viz-6); }
[stroke="var(--viz-neutral)"] { stroke: var(--viz-neutral); }

/* ============ INTERACTIVE SIMULATOR ============ */
.sim-card {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 24px 50px var(--shadow-lg);
}
.sim-tabs {
  display: flex;
  background: var(--surface-tabs);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.sim-tabs::-webkit-scrollbar { display: none; }
.sim-tab {
  padding: 1rem 1.4rem;
  font-size: 0.84rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-sub);
  cursor: pointer;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  transition: all 0.2s ease;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sim-tab:hover { color: var(--text-bright); background: var(--overlay-2); }
.sim-tab.active {
  color: var(--text-strong);
  background: var(--panel-bg);
  border-bottom-color: var(--accent-cyan);
}
.sim-body {
  padding: 1.75rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}
@media (max-width: 850px) { .sim-body { grid-template-columns: 1fr; } }

.code-panel {
  background: var(--surface-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1.15rem;
  font-family: var(--font-code);
  font-size: 0.8rem;
  line-height: 1.75;
  min-width: 0;
}
.code-panel.is-danger { border-color: rgba(239,68,68,0.42); box-shadow: inset 0 0 40px rgba(239,68,68,0.05); }
.code-header {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 1rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--overlay-line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.code-body { white-space: pre-wrap; word-break: break-word; }
.code-body strong { font-weight: 700; color: var(--text-strong); }

.text-green { color: var(--accent-green); }
.text-red { color: var(--accent-red); }
.text-amber { color: var(--accent-amber); }
.text-purple { color: var(--accent-purple); }
.text-cyan { color: var(--accent-cyan); }
.text-sub { color: var(--text-sub); }
.text-muted { color: var(--text-muted); }

.poison-block {
  display: block;
  background: rgba(239, 68, 68, 0.13);
  border-left: 3px solid var(--accent-red);
  color: var(--ink-red-soft);
  padding: 8px 10px;
  margin: 8px 0;
  border-radius: 0 6px 6px 0;
}
.ok-block {
  display: block;
  background: rgba(16, 185, 129, 0.1);
  border-left: 3px solid var(--accent-green);
  color: var(--ink-green-soft);
  padding: 8px 10px;
  margin: 8px 0;
  border-radius: 0 6px 6px 0;
}

/* ============ TAXONOMY ============ */
.taxonomy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.25rem;
}
.tax-card {
  position: relative;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.6rem;
  overflow: hidden;
  transition: all 0.3s ease;
}
.tax-card::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: currentColor;
  opacity: 0.75;
}
.tax-card.sev-c { color: var(--accent-red); }
.tax-card.sev-h { color: var(--accent-amber); }
.tax-card:hover {
  border-color: var(--border-bright);
  transform: translateY(-4px);
  background: var(--card-hover);
}
.tax-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}
.tax-title {
  font-size: 1.03rem;
  font-weight: 700;
  color: var(--text-strong);
  display: flex;
  align-items: center;
  gap: 10px;
  line-height: 1.35;
}
.tax-icon {
  flex-shrink: 0;
  width: 34px; height: 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--overlay-3);
  border: 1px solid var(--overlay-border);
}
@supports (background: color-mix(in srgb, red 10%, transparent)) {
  .tax-icon {
    background: color-mix(in srgb, currentColor 16%, transparent);
    border-color: color-mix(in srgb, currentColor 40%, transparent);
  }
}
.tax-icon svg { stroke: currentColor; }
.tax-body { font-size: 0.89rem; color: var(--text-sub); }
.sev-tag {
  flex-shrink: 0;
  font-size: 0.66rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.sev-critical { background: rgba(239,68,68,0.16); color: var(--ink-red); border: 1px solid rgba(239,68,68,0.4); }
.sev-high { background: rgba(245,158,11,0.16); color: var(--ink-amber); border: 1px solid rgba(245,158,11,0.4); }

/* ============ TIMELINE ============ */
.timeline {
  position: relative;
  padding-left: 2rem;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 2px;
  background: linear-gradient(180deg, var(--accent-cyan), var(--accent-amber) 45%, var(--accent-red));
  opacity: 0.55;
  border-radius: 2px;
}
.timeline-step { position: relative; margin-bottom: 2.4rem; }
.timeline-step:last-child { margin-bottom: 0; }
.timeline-node {
  position: absolute;
  left: -2.55rem;
  top: 2px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--bg);
  border: 3px solid var(--accent-cyan);
}
.timeline-step.danger .timeline-node { border-color: var(--accent-red); box-shadow: 0 0 14px var(--accent-red); }
.timeline-step.warn .timeline-node { border-color: var(--accent-amber); }
.timeline-step.good .timeline-node { border-color: var(--accent-green); box-shadow: 0 0 14px var(--accent-green); }
.timeline-step.good .timeline-date { color: var(--accent-green); }
.timeline-date {
  font-family: var(--font-code);
  font-size: 0.74rem;
  color: var(--accent-cyan);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.35rem;
}
.timeline-step.warn .timeline-date { color: var(--accent-amber); }
.timeline-step.danger .timeline-date { color: var(--accent-red); }
.timeline-h { font-size: 1.1rem; font-weight: 700; color: var(--text-strong); margin-bottom: 0.4rem; }
.timeline-p { color: var(--text-sub); font-size: 0.93rem; }
.timeline-p em { color: var(--text-bright); font-style: italic; }

/* ============ BLUEPRINT ============ */
.blueprint-card {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: clamp(1.35rem, 3vw, 2.4rem);
}
.flowchart-visual {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin: 2.5rem 0 2.75rem;
}
.flow-node {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.4rem;
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: 1.25rem;
  align-items: center;
  position: relative;
  transition: border-color .25s ease, transform .25s ease;
}
.flow-node:hover { border-color: var(--border-bright); transform: translateX(4px); }
.flow-node::after {
  content: '';
  position: absolute;
  bottom: -1.5rem;
  left: 30px;
  width: 2px; height: 1.5rem;
  background: linear-gradient(180deg, var(--border-bright), transparent);
}
.flow-node:last-child::after { display: none; }
.flow-num {
  width: 52px; height: 52px;
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-code);
  font-weight: 800;
  font-size: 1.05rem;
}
.flow-num.n1 { background: rgba(99,102,241,0.18); border: 1px solid var(--primary); color: var(--ink-indigo); }
.flow-num.n2 { background: rgba(168,85,247,0.18); border: 1px solid var(--accent-purple); color: var(--ink-purple-soft); }
.flow-num.n3 { background: rgba(239,68,68,0.18); border: 1px solid var(--accent-red); color: var(--ink-red); }
.flow-node h3 { color: var(--text-strong); font-size: 1.05rem; margin-bottom: 0.3rem; }
.flow-node p { font-size: 0.89rem; color: var(--text-sub); }
.flow-node code, .timeline-p code, .tax-body code {
  font-family: var(--font-code);
  font-size: 0.85em;
  background: rgba(99,102,241,0.12);
  border: 1px solid rgba(99,102,241,0.25);
  padding: 1px 5px;
  border-radius: 5px;
  color: var(--ink-indigo);
}

/* ============ CODE BOX ============ */
.code-box {
  background: var(--surface-code);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin: 1.5rem 0;
}
.code-box-header {
  background: var(--surface-header);
  padding: 0.7rem 1.1rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-sub);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-family: var(--font-code);
}
.copy-btn {
  background: rgba(99,102,241,0.14);
  border: 1px solid var(--border-bright);
  color: var(--ink-indigo);
  font-family: var(--font-code);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all .2s ease;
  white-space: nowrap;
}
.copy-btn:hover { background: rgba(99,102,241,0.28); color: var(--text-strong); }
pre {
  padding: 1.25rem;
  overflow-x: auto;
  font-family: var(--font-code);
  font-size: 0.8rem;
  line-height: 1.75;
  color: var(--text-bright);
  tab-size: 4;
}
.tok-kw  { color: var(--tok-kw-c); }
.tok-fn  { color: var(--ink-cyan); }
.tok-str { color: var(--ink-green); }
.tok-com { color: var(--tok-com-c); font-style: italic; }
.tok-num { color: var(--ink-amber); }
.tok-cls { color: var(--tok-cls-c); }

/* ============ PAPERS ============ */
.papers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.25rem;
}
.paper-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1rem;
  transition: border-color .25s ease, transform .25s ease;
}
.paper-card:hover { border-color: var(--border-bright); transform: translateY(-3px); }
.paper-tag {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 6px;
  background: rgba(6,182,212,0.14);
  color: var(--ink-cyan);
  border: 1px solid rgba(6,182,212,0.3);
  width: fit-content;
  margin-bottom: 0.85rem;
  letter-spacing: 0.03em;
}
.paper-card h3 { font-size: 1.05rem; color: var(--text-strong); margin-bottom: 0.55rem; line-height: 1.35; }
.paper-card p { font-size: 0.87rem; color: var(--text-sub); }
.paper-meta {
  font-family: var(--font-code);
  font-size: 0.72rem;
  color: var(--ink-cyan);
  padding-top: 0.9rem;
  border-top: 1px solid var(--hairline);
}

/* ============ TABLE ============ */
.table-responsive {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--panel-bg);
}
table { width: 100%; border-collapse: collapse; font-size: 0.86rem; min-width: 860px; }
th, td { padding: 0.95rem 1.1rem; text-align: left; border-bottom: 1px solid var(--hairline); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
th {
  background: var(--surface-header);
  color: var(--text-sub);
  font-weight: 700;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
tbody tr:hover td { background: rgba(99,102,241,0.04); }
tr.row-featured td { background: rgba(99,102,241,0.09); }
tr.row-featured:hover td { background: rgba(99,102,241,0.13); }
tr.row-featured td:first-child { box-shadow: inset 3px 0 0 var(--primary); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 7px;
  white-space: nowrap;
  line-height: 1.3;
}
.pill svg { flex-shrink: 0; }
.pill-yes { background: rgba(5,150,105,0.15); color: var(--ink-green); border: 1px solid rgba(5,150,105,0.4); }
.pill-no  { background: rgba(71,85,105,0.2); color: var(--ink-slate); border: 1px solid rgba(71,85,105,0.5); }
.pill-warn{ background: rgba(217,119,6,0.15); color: var(--ink-amber); border: 1px solid rgba(217,119,6,0.45); }

.meter {
  display: flex;
  align-items: center;
  gap: 9px;
}
.meter-track {
  display: flex;
  gap: 2px; /* 2px surface gap between segments */
  width: 74px;
}
.meter-seg {
  height: 8px;
  flex: 1;
  border-radius: 2px;
  background: rgba(99,102,241,0.16);
}
.meter-seg.on { background: var(--viz-1); }
.meter-seg.on.hi { background: var(--viz-3); }
.meter-seg.on.lo { background: var(--viz-5); }
.meter-val { font-family: var(--font-code); font-size: 0.74rem; color: var(--text-sub); }

/* ============ CHART BITS ============ */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.4rem;
  padding: 0 1.5rem 1.1rem;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-sub);
}
.legend-swatch {
  width: 11px; height: 11px;
  border-radius: 3px;
  flex-shrink: 0;
}
.legend-item b { color: var(--text-bright); font-weight: 600; }
details.table-view {
  margin: 0 1.5rem 1.4rem;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  overflow: hidden;
}
details.table-view summary {
  cursor: pointer;
  padding: 0.6rem 0.95rem;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-sub);
  background: var(--overlay-2);
  list-style: none;
  user-select: none;
}
details.table-view summary::-webkit-details-marker { display: none; }
details.table-view summary::before { content: '▸ '; color: var(--accent-cyan); }
details.table-view[open] summary::before { content: '▾ '; }
details.table-view table { min-width: 0; font-size: 0.8rem; }
details.table-view th { position: static; }
details.table-view td, details.table-view th { padding: 0.55rem 0.95rem; }
.num-cell { font-family: var(--font-code); font-variant-numeric: tabular-nums; }

/* ============ SANDBOX ============ */
.sandbox-card {
  background: linear-gradient(180deg, rgba(99,102,241,0.06), transparent 60%), var(--panel-bg);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin-top: 2.5rem;
}
.sandbox-card h3 { color: var(--text-strong); margin-bottom: 0.4rem; font-size: 1.1rem; }
.sandbox-card > p { color: var(--text-sub); font-size: 0.9rem; margin-bottom: 1.4rem; }
.btn {
  background: linear-gradient(135deg, var(--primary), var(--accent-purple));
  color: var(--on-accent);
  border: none;
  padding: 0.8rem 1.6rem;
  border-radius: 10px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 9px;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 12px 24px var(--primary-glow); }
.btn:active { transform: translateY(0); }
.log-line { display: block; opacity: 0; }
.log-line.shown { opacity: 1; }
.log-time { color: var(--text-muted); }

footer {
  border-top: 1px solid var(--border);
  padding: 3.5rem 2rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  position: relative;
  z-index: 1;
}
footer strong { color: var(--text-sub); }

/* ============ RESOURCES ============ */
.src-link { color: var(--ink-cyan); text-decoration: none; font-weight: 600; }
.src-link:hover { text-decoration: underline; }
.res-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.25rem; }
.res-col {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
}
.res-col h4 {
  color: var(--text-strong); font-size: 0.92rem; margin-bottom: 1rem;
  display: flex; align-items: center; gap: 9px;
}
.res-list { list-style: none; display: flex; flex-direction: column; gap: 0.9rem; }
.res-list li {
  font-size: 0.84rem; color: var(--text-sub); line-height: 1.5;
  padding-left: 0.9rem; border-left: 2px solid var(--border);
}
.res-list a { color: var(--ink-indigo); font-weight: 600; text-decoration: none; }
.res-list a:hover { color: var(--text-strong); text-decoration: underline; }
.res-meta {
  display: block; font-family: var(--font-code); font-size: 0.68rem;
  color: var(--text-muted); margin-top: 3px;
}
.steps { counter-reset: s; list-style: none; display: flex; flex-direction: column; gap: 1.05rem; }
.steps li { position: relative; padding-left: 2.5rem; font-size: 0.88rem; color: var(--text-sub); }
.steps li b { color: var(--text-strong); display: block; margin-bottom: 2px; font-weight: 600; }
.steps li::before {
  counter-increment: s; content: counter(s);
  position: absolute; left: 0; top: 0;
  width: 27px; height: 27px; border-radius: 8px;
  background: rgba(99,102,241,0.18); border: 1px solid var(--primary);
  color: var(--ink-indigo); font-family: var(--font-code); font-size: 0.74rem; font-weight: 700;
  display: grid; place-items: center;
}

.nav-sep { width: 1px; height: 16px; background: var(--border-bright); align-self: center; flex-shrink: 0; }
.eyebrow.p2 { color: var(--ink-purple); }

/* ============ PART 02 CHROME ============
   emotion-ai.html reuses the hero, retinted from red/indigo to purple. */
/* background-image, not the `background` shorthand: the shorthand would
   reset background-clip to border-box and paint over the clipped text. */
.hero-alt h1 { background-image: var(--part-grad); }
.hero-tag.p2 {
  background: rgba(168,85,247,0.1);
  border-color: rgba(168,85,247,0.35);
  color: var(--ink-purple);
  letter-spacing: 0.16em;
}
.hero-tag.p2 span { font-size: 0.7em; line-height: 1; }
.logo-badge.alt { background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan)); }

/* cross-page nav link — reads as a destination, not a section */
.nav-cross { color: var(--ink-purple) !important; font-weight: 600; }
.nav-cross::after { background: var(--accent-purple) !important; }

/* ============ PAGER (link to the other briefing) ============ */
.pager-wrap {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 0 2rem 5rem;
  position: relative;
  z-index: 1;
}
.pager {
  display: block;
  text-decoration: none;
  background: linear-gradient(180deg, var(--card-grad-a), var(--card-grad-b));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem 1.9rem;
  transition: border-color .25s ease, transform .25s ease, box-shadow .25s ease;
}
.pager:hover {
  border-color: var(--border-bright);
  transform: translateY(-3px);
  box-shadow: 0 18px 40px var(--shadow-md);
}
.pager-dir {
  display: block;
  font-family: var(--font-code);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-purple);
  margin-bottom: 0.6rem;
}
.pager-title {
  display: block;
  font-size: clamp(1.15rem, 2.4vw, 1.5rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: var(--text-strong);
  margin-bottom: 0.55rem;
}
.pager-sub { display: block; color: var(--text-sub); font-size: 0.92rem; max-width: 760px; }

@media (max-width: 860px) {
  .pager-wrap { padding: 0 1.15rem 3.5rem; }
  .pager { padding: 1.35rem 1.35rem; }
}

.callout {
  border-left: 3px solid var(--accent-amber);
  background: rgba(245,158,11,0.07);
  padding: 1.1rem 1.35rem; border-radius: 0 12px 12px 0;
  margin: 1.75rem 0; font-size: 0.9rem; color: var(--text-sub);
}
.callout b { color: var(--ink-amber); }
.callout.danger { border-color: var(--accent-red); background: rgba(239,68,68,0.07); }
.callout.danger b { color: var(--ink-red); }
.callout.good { border-color: var(--accent-green); background: rgba(16,185,129,0.07); }
.callout.good b { color: var(--ink-green); }

/* ============ REVEAL ANIMATION ============ */
@media (prefers-reduced-motion: no-preference) {
  .reveal {
    opacity: 0;
    transform: translateY(18px);
    transition: opacity .7s cubic-bezier(.16,1,.3,1), transform .7s cubic-bezier(.16,1,.3,1);
  }
  .reveal.in { opacity: 1; transform: none; }
  .aurora { animation: drift 18s ease-in-out infinite alternate; }
  .aurora-b { animation-delay: -6s; }
  .aurora-c { animation-delay: -12s; }
  @keyframes drift {
    from { transform: translate3d(0,0,0) scale(1); }
    to   { transform: translate3d(24px,-18px,0) scale(1.08); }
  }
  .pulse-node { animation: pulse 2.4s ease-in-out infinite; transform-origin: center; }
  @keyframes pulse { 0%,100% { opacity: .35; } 50% { opacity: .9; } }
}

@media (max-width: 860px) {
  .nav-container { padding: 0 1rem; gap: 1rem; height: 64px; }
  .logo-text, .logo-badge { display: none; }
  section { padding: 60px 1.15rem; }
  .hero { padding: 120px 1.15rem 50px; }
  .fig-scroll { padding: 1rem; }
  .fig-head { padding: 0.9rem 1rem; }
  figcaption { padding: 0 1rem 1.2rem; }
  .legend { padding: 0 1rem 1rem; }
  details.table-view { margin: 0 1rem 1.2rem; }
  .sim-body { padding: 1.15rem; }
}

/* ============ SURVEY TABLES ============
   Seven columns have to sit inside the 1200px shell, so these run
   tighter than the default table and drop the 860px floor that would
   otherwise force a scrollbar at desktop width. */
.survey-table { min-width: 0; font-size: 0.8rem; }
.survey-table th,
.survey-table td { padding: 0.72rem 0.62rem; }
.survey-table th { font-size: 0.64rem; letter-spacing: 0.04em; }
@media (max-width: 1100px) {
  .survey-table { min-width: 940px; }
}
