/* =========================================================
   SIMUL8 — Cyberpunk lab interface
   Tokens → base → shell → components → pages → responsive
   ========================================================= */

:root {
  --bg: #04060b;
  --bg-2: #070a12;
  --surface: rgba(10, 14, 24, 0.78);
  --surface-solid: #0a0e18;
  --surface-2: #0e1422;
  --surface-3: #141c2f;
  --line: rgba(120, 165, 230, 0.13);
  --line-2: rgba(120, 165, 230, 0.22);
  --line-hot: rgba(0, 229, 255, 0.45);
  --text: #e4ecf7;
  --muted: #8a97ad;
  --dim: #5a667c;
  --cyan: #00e5ff;
  --magenta: #ff2e88;
  --acid: #e8ff3a;
  --green: #2dffa0;
  --orange: #ff9d3d;
  --violet: #a37cff;
  --red: #ff4d6d;
  --cyan-soft: rgba(0, 229, 255, 0.1);
  --magenta-soft: rgba(255, 46, 136, 0.12);
  --on-accent: #001116;
  --glow-cyan: 0 0 0 1px rgba(0, 229, 255, 0.4), 0 0 22px rgba(0, 229, 255, 0.22);
  --glow-magenta: 0 0 0 1px rgba(255, 46, 136, 0.45), 0 0 22px rgba(255, 46, 136, 0.22);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --font-ui: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, sans-serif;
  --font-display: "Bahnschrift", "DIN Alternate", "Barlow Condensed", "Roboto Condensed", "Arial Narrow", "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", "SF Mono", "Roboto Mono", ui-monospace, Menlo, Consolas, monospace;
  --radius: 3px;
  --sidebar: 252px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --scanlines: 0.5;
  /* canvas palette */
  --cv-grid: rgba(0, 229, 255, 0.055);
  --cv-grid-strong: rgba(0, 229, 255, 0.13);
  --cv-axis: rgba(170, 195, 230, 0.45);
  --cv-text: #74839d;
  --cv-body: #effaff;
  --cv-glow: 1;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #eef2f7;
  --bg-2: #e6ebf3;
  --surface: rgba(255, 255, 255, 0.86);
  --surface-solid: #ffffff;
  --surface-2: #f5f7fb;
  --surface-3: #eaeef6;
  --line: rgba(20, 40, 80, 0.12);
  --line-2: rgba(20, 40, 80, 0.2);
  --line-hot: rgba(0, 140, 175, 0.55);
  --text: #0c1222;
  --muted: #4c586e;
  --dim: #7a859a;
  --cyan: #0089aa;
  --magenta: #d0186a;
  --acid: #7a8600;
  --green: #078a52;
  --orange: #c96400;
  --violet: #6a44d6;
  --red: #c8243f;
  --cyan-soft: rgba(0, 137, 170, 0.09);
  --magenta-soft: rgba(208, 24, 106, 0.08);
  --on-accent: #ffffff;
  --glow-cyan: 0 0 0 1px rgba(0, 137, 170, 0.45);
  --glow-magenta: 0 0 0 1px rgba(208, 24, 106, 0.45);
  --shadow: 0 14px 40px rgba(20, 40, 80, 0.12);
  --scanlines: 0;
  --cv-grid: rgba(0, 100, 140, 0.06);
  --cv-grid-strong: rgba(0, 100, 140, 0.13);
  --cv-axis: rgba(30, 50, 90, 0.45);
  --cv-text: #5a667c;
  --cv-body: #0c1222;
  --cv-glow: 0;
  color-scheme: light;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
body::before {
  content: "";
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(255, 46, 136, 0.13), transparent 60%),
    radial-gradient(800px 500px at 0% 10%, rgba(0, 229, 255, 0.11), transparent 60%),
    linear-gradient(var(--cv-grid) 1px, transparent 1px) 0 0 / 44px 44px,
    linear-gradient(90deg, var(--cv-grid) 1px, transparent 1px) 0 0 / 44px 44px,
    var(--bg);
}
:root[data-theme="light"] body::before {
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(208, 24, 106, 0.07), transparent 60%),
    radial-gradient(800px 500px at 0% 10%, rgba(0, 137, 170, 0.08), transparent 60%),
    linear-gradient(var(--cv-grid) 1px, transparent 1px) 0 0 / 44px 44px,
    linear-gradient(90deg, var(--cv-grid) 1px, transparent 1px) 0 0 / 44px 44px,
    var(--bg);
}
body::after {
  content: "";
  position: fixed; inset: 0; z-index: 90; pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 3px);
  opacity: var(--scanlines);
  mix-blend-mode: overlay;
}

a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
h1, h2, h3 { margin: 0; font-family: var(--font-display); font-weight: 700; letter-spacing: 0.01em; line-height: 1.08; }
h1 { font-size: clamp(30px, 4.2vw, 46px); text-transform: uppercase; letter-spacing: 0.02em; }
h2 { font-size: clamp(20px, 2.4vw, 26px); text-transform: uppercase; letter-spacing: 0.03em; }
h3 { font-size: 16px; text-transform: uppercase; letter-spacing: 0.05em; }
p { margin: 0; }
kbd {
  font: 600 10px/1 var(--font-mono);
  padding: 3px 5px; border-radius: 2px;
  border: 1px solid var(--line-2); color: var(--muted); background: var(--surface-2);
  letter-spacing: 0.04em; white-space: nowrap;
}
::selection { background: var(--magenta); color: #fff; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.i .fill, symbol .fill { fill: currentColor; stroke: none; }
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 200; background: var(--cyan); color: var(--on-accent); padding: 8px 12px; font-weight: 700; }
.skip-link:focus { left: 8px; }
[hidden] { display: none !important; }

.eyebrow {
  display: inline-block;
  font: 600 11px/1.2 var(--font-mono);
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--cyan);
}
.lede { color: var(--muted); max-width: 62ch; margin-top: 10px; font-size: 15px; }

/* ---------- shell ---------- */
.app-shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh; z-index: 40;
  display: flex; flex-direction: column; gap: 6px;
  padding: 20px 14px 16px;
  background: linear-gradient(180deg, rgba(8, 12, 22, 0.92), rgba(5, 8, 14, 0.96));
  border-right: 1px solid var(--line);
  overflow-y: auto;
}
:root[data-theme="light"] .sidebar { background: rgba(255, 255, 255, 0.92); }
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 18px; }
.brand-mark {
  width: 40px; height: 40px; display: grid; place-items: center;
  border: 1px solid var(--line-hot); background: var(--cyan-soft);
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
}
.brand-mark svg { width: 26px; height: 26px; fill: none; stroke: var(--cyan); stroke-width: 1.6; filter: drop-shadow(0 0 4px var(--cyan)); }
.brand-mark svg circle { fill: var(--magenta); stroke: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-name { font: 800 22px/1 var(--font-display); letter-spacing: 0.12em; }
.brand-name b { color: var(--magenta); text-shadow: 0 0 12px rgba(255, 46, 136, 0.6); }
.brand-sub { font: 600 9px/1 var(--font-mono); letter-spacing: 0.22em; color: var(--dim); margin-top: 6px; }

.side-label { font: 600 10px/1 var(--font-mono); letter-spacing: 0.16em; color: var(--dim); padding: 14px 10px 8px; }
.nav-list, .lab-links { display: flex; flex-direction: column; gap: 2px; }
.nav-item, .lab-link {
  position: relative;
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; border-radius: var(--radius);
  color: var(--muted); font-weight: 500;
  transition: color 0.15s, background 0.15s;
}
.nav-item > span:not(.nav-count) { flex: 1; }
.nav-item kbd { opacity: 0; transition: opacity 0.15s; }
.nav-item:hover kbd { opacity: 1; }
.nav-item:hover, .lab-link:hover { color: var(--text); background: var(--cyan-soft); }
.nav-item.active { color: var(--text); background: linear-gradient(90deg, var(--cyan-soft), transparent); }
.nav-item.active::before {
  content: ""; position: absolute; left: -14px; top: 6px; bottom: 6px; width: 3px;
  background: var(--cyan); box-shadow: 0 0 12px var(--cyan);
}
.nav-item.active .i { color: var(--cyan); }
.nav-count { font: 600 10px/1 var(--font-mono); padding: 3px 6px; border-radius: 2px; background: var(--magenta-soft); color: var(--magenta); }
.lab-link { font-size: 13px; padding: 7px 10px; }
.lab-link .lab-code { font: 600 9.5px/1 var(--font-mono); color: var(--dim); margin-left: auto; letter-spacing: 0.08em; }
.lab-link .live { color: var(--green); }
.ldot { width: 7px; height: 7px; flex: none; transform: rotate(45deg); background: var(--c, var(--cyan)); box-shadow: 0 0 8px var(--c, var(--cyan)); }
.c-cyan { --c: var(--cyan); } .c-green { --c: var(--green); } .c-violet { --c: var(--violet); }
.c-magenta { --c: var(--magenta); } .c-orange { --c: var(--orange); } .c-acid { --c: var(--acid); }

.sidebar-bottom { margin-top: auto; padding-top: 18px; display: grid; gap: 10px; }
.sys-card { border: 1px solid var(--line); background: var(--surface-2); padding: 10px 12px; display: grid; gap: 7px; font: 500 11px/1.2 var(--font-mono); color: var(--muted); }
.sys-row { display: flex; align-items: center; gap: 8px; }
.sys-row strong { color: var(--text); letter-spacing: 0.08em; }
.sys-val { margin-left: auto; color: var(--cyan); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--dim); flex: none; }
.dot.ok { background: var(--green); box-shadow: 0 0 8px var(--green); animation: pulse 2.4s infinite; }
.side-foot { display: flex; justify-content: space-between; font: 600 10px/1 var(--font-mono); letter-spacing: 0.12em; color: var(--dim); padding: 0 4px; }
.version { color: var(--magenta); }
.scrim { position: fixed; inset: 0; z-index: 35; background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(2px); }

.main-area { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px;
  height: 62px; padding: 0 28px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--line);
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.crumbs { display: flex; gap: 9px; align-items: center; font: 600 12px/1 var(--font-mono); letter-spacing: 0.1em; color: var(--dim); text-transform: uppercase; white-space: nowrap; }
.crumbs strong { color: var(--text); }
.crumbs .sep { color: var(--magenta); }
.cmd-trigger {
  margin-left: auto; display: flex; align-items: center; gap: 10px;
  min-width: 280px; height: 38px; padding: 0 8px 0 12px;
  border: 1px solid var(--line-2); background: var(--surface-2); color: var(--dim);
  border-radius: var(--radius); transition: border-color 0.15s, box-shadow 0.15s;
}
.cmd-trigger span { flex: 1; text-align: left; font-size: 13px; }
.cmd-trigger:hover { border-color: var(--line-hot); box-shadow: var(--glow-cyan); color: var(--muted); }
.topbar-right { display: flex; gap: 6px; }
.mobile-menu { display: none; }

.icon-btn {
  width: 38px; height: 38px; display: inline-grid; place-items: center; flex: none;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--muted);
  border-radius: var(--radius); transition: color 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.icon-btn:hover { color: var(--cyan); border-color: var(--line-hot); box-shadow: var(--glow-cyan); }
.icon-btn.sm { width: 32px; height: 32px; }
.icon-btn.sm .i { width: 16px; height: 16px; }

.page-wrap { padding: 28px 28px 0; max-width: 1480px; width: 100%; margin: 0 auto; flex: 1; display: flex; flex-direction: column; }
.page { display: none; animation: pageIn 0.35s var(--ease); }
.page.active { display: block; }
.page-footer {
  margin-top: auto; padding: 36px 0 26px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px;
  font: 600 10.5px/1.4 var(--font-mono); letter-spacing: 0.12em; color: var(--dim); text-transform: uppercase;
  border-top: 1px solid var(--line); margin-top: 48px;
}

/* ---------- buttons ---------- */
.btn {
  --cut: 9px;
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  height: 44px; padding: 0 20px;
  font: 700 13px/1 var(--font-ui); letter-spacing: 0.06em; text-transform: uppercase;
  clip-path: polygon(var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut));
  transition: transform 0.15s var(--ease), filter 0.15s, background 0.15s, color 0.15s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--cyan); color: var(--on-accent); }
.btn-primary:hover { filter: brightness(1.12) drop-shadow(0 0 10px var(--cyan)); }
.btn-ghost { background: var(--line-2); color: var(--text); position: relative; }
.btn-ghost::before { content: ""; position: absolute; inset: 1px; background: var(--surface-solid); clip-path: inherit; z-index: -1; }
.btn-ghost { isolation: isolate; }
.btn-ghost:hover { background: var(--line-hot); color: var(--cyan); }
.btn-magenta { background: var(--magenta); color: #fff; }
.btn-danger { background: var(--red); color: #fff; }
.btn-sm { height: 36px; padding: 0 14px; font-size: 11.5px; --cut: 7px; }
.btn-xs { height: 30px; padding: 0 11px; font-size: 10.5px; gap: 6px; --cut: 6px; }
.btn-xs .i { width: 14px; height: 14px; }
.btn[disabled] { opacity: 0.4; pointer-events: none; }
.text-link { display: inline-flex; align-items: center; gap: 6px; color: var(--cyan); font: 600 12px/1 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; }
.text-link .i { width: 15px; height: 15px; transition: transform 0.15s; }
.text-link:hover .i { transform: translateX(3px); }
.text-link.small { font-size: 11px; }

/* ---------- panels ---------- */
.panel {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  backdrop-filter: blur(8px);
}
.panel::before, .panel::after, .corner {
  content: ""; position: absolute; width: 12px; height: 12px; pointer-events: none;
  border-color: var(--cyan); border-style: solid; opacity: 0.85;
}
.panel::before, .corner.tl { top: -1px; left: -1px; border-width: 2px 0 0 2px; }
.panel::after, .corner.br { bottom: -1px; right: -1px; border-width: 0 2px 2px 0; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.panel-head h3 { margin-top: 6px; }
.section-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin: 44px 0 18px; flex-wrap: wrap; }
.section-head h2 { margin-top: 8px; }

/* ---------- HOME ---------- */
.hero {
  position: relative; overflow: hidden;
  min-height: 430px; padding: 48px 44px;
  border: 1px solid var(--line-2);
  background:
    radial-gradient(600px 300px at 80% 20%, var(--magenta-soft), transparent 70%),
    linear-gradient(135deg, var(--surface-2), var(--surface-solid));
  display: grid; align-items: center;
}
.hero-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.hero-content { position: relative; max-width: 600px; z-index: 1; }
.kicker { display: inline-flex; align-items: center; gap: 10px; font: 600 11px/1 var(--font-mono); letter-spacing: 0.18em; color: var(--green); padding: 7px 10px; border: 1px solid var(--line); background: var(--surface); }
.kicker-sep { color: var(--magenta); }
.blink { width: 8px; height: 8px; background: var(--green); box-shadow: 0 0 10px var(--green); animation: blink 1.2s steps(2) infinite; }
.hero h1 { font-size: clamp(42px, 7vw, 84px); line-height: 0.92; margin: 22px 0 18px; text-transform: uppercase; letter-spacing: 0.01em; }
.hero h1 em { font-style: normal; color: transparent; background: linear-gradient(90deg, var(--cyan), var(--magenta)); -webkit-background-clip: text; background-clip: text; filter: drop-shadow(0 0 18px rgba(0, 229, 255, 0.25)); }
.hero-lede { color: var(--muted); font-size: 16px; max-width: 48ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }
.hero-hud {
  position: absolute; right: 24px; top: 24px; z-index: 1;
  min-width: 170px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--line-2); backdrop-filter: blur(8px);
  font: 500 12px/1.2 var(--font-mono);
}
.hud-title { font-size: 10px; letter-spacing: 0.16em; color: var(--magenta); margin-bottom: 8px; }
.hud-row { display: flex; justify-content: space-between; gap: 16px; padding: 4px 0; border-top: 1px dashed var(--line); color: var(--dim); }
.hud-row b { color: var(--text); font-weight: 600; }

/* glitch title */
.glitch { position: relative; }
.glitch::before, .glitch::after {
  content: attr(data-text); position: absolute; inset: 0; pointer-events: none; opacity: 0;
  font: inherit; letter-spacing: inherit;
}
.glitch::before { color: var(--cyan); transform: translate(-2px, 0); clip-path: inset(10% 0 60% 0); }
.glitch::after { color: var(--magenta); transform: translate(2px, 0); clip-path: inset(55% 0 15% 0); }
.glitch.run::before { animation: glitchA 0.6s steps(2) 1; }
.glitch.run::after { animation: glitchB 0.6s steps(2) 1; }

.stat-strip {
  display: grid; grid-template-columns: repeat(4, 1fr); margin: 0; border: 1px solid var(--line); border-top: 0;
  background: var(--surface);
}
.stat-strip div { padding: 16px 20px; border-right: 1px solid var(--line); }
.stat-strip div:last-child { border-right: 0; }
.stat-strip dt { font: 600 10px/1 var(--font-mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--dim); }
.stat-strip dd { margin: 8px 0 0; font: 700 26px/1 var(--font-display); color: var(--text); }

.lab-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.lab-card {
  position: relative; text-align: left; overflow: hidden;
  display: flex; flex-direction: column; gap: 10px; min-height: 196px; padding: 20px;
  background: var(--surface); border: 1px solid var(--line);
  transition: border-color 0.2s, transform 0.2s var(--ease), box-shadow 0.2s;
}
.lab-card::after { content: ""; position: absolute; inset: auto 0 0 0; height: 2px; background: var(--c); opacity: 0.35; transition: opacity 0.2s; }
.lab-card:hover { transform: translateY(-3px); border-color: var(--c); box-shadow: 0 0 0 1px var(--c), 0 12px 30px rgba(0, 0, 0, 0.3); }
.lab-card:hover::after { opacity: 1; box-shadow: 0 0 14px var(--c); }
.lab-card-top { display: flex; justify-content: space-between; align-items: center; }
.lab-icon { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid var(--c); color: var(--c); background: color-mix(in srgb, var(--c) 10%, transparent); }
.lab-icon .i { width: 22px; height: 22px; }
.tag { font: 600 9.5px/1 var(--font-mono); letter-spacing: 0.12em; padding: 5px 7px; border: 1px solid var(--line-2); color: var(--muted); text-transform: uppercase; }
.tag.online { color: var(--green); border-color: color-mix(in srgb, var(--green) 50%, transparent); }
.lab-card strong { font: 700 20px/1.1 var(--font-display); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 6px; }
.lab-card small { color: var(--muted); font-size: 13px; }
.lab-card-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; font: 600 11px/1 var(--font-mono); letter-spacing: 0.08em; color: var(--dim); text-transform: uppercase; }
.lab-card-foot .i { width: 16px; height: 16px; color: var(--c); }
.lab-card.dev { opacity: 0.82; }
.lab-card.dev strong { color: var(--muted); }

.home-split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 44px; }
.quick-list { display: grid; gap: 8px; }
.quick-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; text-align: left; width: 100%;
  border: 1px solid var(--line); background: var(--surface-2); transition: border-color 0.15s, background 0.15s;
}
.quick-item:hover { border-color: var(--line-hot); background: var(--cyan-soft); }
.quick-item .qi-icon { width: 34px; height: 34px; display: grid; place-items: center; color: var(--cyan); border: 1px solid var(--line-2); flex: none; }
.quick-item .qi-text { flex: 1; min-width: 0; }
.quick-item strong { display: block; font-size: 13.5px; font-weight: 600; }
.quick-item small { display: block; color: var(--dim); font: 500 11px/1.3 var(--font-mono); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quick-item > .i { color: var(--dim); width: 16px; height: 16px; }
.empty-mini { color: var(--dim); font-size: 13px; padding: 14px; border: 1px dashed var(--line-2); text-align: center; }

/* ---------- DISCOVER ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head h1 { margin-top: 10px; }
.head-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.search-box {
  display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 14px; min-width: 280px;
  border: 1px solid var(--line-2); background: var(--surface-2); color: var(--dim);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-box:focus-within { border-color: var(--line-hot); box-shadow: var(--glow-cyan); }
.search-box input { flex: 1; min-width: 0; background: none; border: 0; outline: none; color: var(--text); }
.search-box.wide { width: 100%; margin-bottom: 18px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.chip {
  height: 32px; padding: 0 13px; font: 600 11px/1 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase;
  border: 1px solid var(--line-2); color: var(--muted); background: var(--surface-2); transition: all 0.15s;
}
.chip:hover { color: var(--text); border-color: var(--line-hot); }
.chip.active { background: var(--cyan); border-color: var(--cyan); color: var(--on-accent); }
.chip b { font-weight: 600; opacity: 0.6; margin-left: 4px; }

.discover-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }
.sim-card {
  display: flex; flex-direction: column; text-align: left; overflow: hidden;
  border: 1px solid var(--line); background: var(--surface);
  transition: border-color 0.2s, transform 0.2s var(--ease), box-shadow 0.2s;
}
.sim-card:hover { transform: translateY(-3px); border-color: var(--line-hot); box-shadow: var(--glow-cyan); }
.sim-art { position: relative; height: 150px; border-bottom: 1px solid var(--line); background: linear-gradient(160deg, var(--surface-3), var(--surface-solid)); overflow: hidden; }
.sim-art svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.sim-art .art-grid { stroke: var(--cv-grid-strong); stroke-width: 1; }
.sim-art .art-main { stroke: var(--cyan); stroke-width: 2.4; fill: none; filter: drop-shadow(0 0 5px var(--cyan)); }
.sim-art .art-alt { stroke: var(--magenta); stroke-width: 1.6; fill: none; stroke-dasharray: 5 5; }
.sim-art .art-dim { stroke: var(--cv-axis); stroke-width: 1; fill: none; stroke-dasharray: 3 5; }
.sim-art .art-body { fill: var(--cv-body); filter: drop-shadow(0 0 6px var(--cyan)); }
.sim-art .art-acc { fill: var(--magenta); }
.sim-art .art-index { position: absolute; left: 12px; top: 10px; font: 600 10px/1 var(--font-mono); letter-spacing: 0.14em; color: var(--dim); }
.sim-body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.sim-body strong { font: 700 18px/1.15 var(--font-display); text-transform: uppercase; letter-spacing: 0.04em; }
.sim-body p { color: var(--muted); font-size: 13px; }
.tag-row { display: flex; flex-wrap: wrap; gap: 5px; }
.tag-row span { font: 600 9.5px/1 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; padding: 4px 6px; background: var(--cyan-soft); color: var(--cyan); }
.sim-open { margin-top: auto; padding-top: 8px; display: flex; justify-content: space-between; align-items: center; font: 600 11px/1 var(--font-mono); letter-spacing: 0.1em; color: var(--cyan); text-transform: uppercase; }
.sim-open .i { width: 16px; height: 16px; }
.roadmap { margin-top: 12px; }
.roadmap-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.road-card { padding: 16px; border: 1px dashed var(--line-2); background: var(--surface-2); text-align: left; transition: border-color 0.15s; }
.road-card:hover { border-color: var(--c); }
.road-card header { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
.road-card strong { font: 700 14px/1 var(--font-display); text-transform: uppercase; letter-spacing: 0.06em; }
.road-card ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.road-card li { font: 500 11.5px/1.35 var(--font-mono); color: var(--muted); }
.road-card li::before { content: "› "; color: var(--c); }

.empty-state { grid-column: 1 / -1; display: grid; justify-items: center; gap: 10px; text-align: center; padding: 56px 20px; border: 1px dashed var(--line-2); background: var(--surface); }
.empty-state .i { width: 36px; height: 36px; color: var(--cyan); }
.empty-state p { color: var(--muted); max-width: 44ch; }

/* ---------- LAB / WORKSPACE ---------- */
.ws-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; margin-bottom: 20px; }
.ws-head h1 { margin-top: 10px; }
.ws-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.ws-grid {
  display: grid; gap: 14px;
  grid-template-columns: minmax(0, 1fr) 360px;
  grid-template-areas: "stage side" "metrics side" "chart side";
  grid-template-rows: auto auto 1fr;
  align-items: start;
}
.stage-card { grid-area: stage; padding: 0; overflow: hidden; }
.ws-side { grid-area: side; display: grid; gap: 14px; position: sticky; top: 76px; }
.metrics { grid-area: metrics; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.chart-card { grid-area: chart; }

.stage-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px 10px 16px; border-bottom: 1px solid var(--line); }
.stage-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.stage-tools { display: flex; gap: 6px; }
.unit { font: 600 10px/1 var(--font-mono); letter-spacing: 0.14em; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-pill { display: inline-flex; align-items: center; gap: 7px; height: 24px; padding: 0 9px; font: 700 10px/1 var(--font-mono); letter-spacing: 0.14em; border: 1px solid var(--line-2); color: var(--muted); }
.status-pill[data-state="running"] { color: var(--green); border-color: color-mix(in srgb, var(--green) 50%, transparent); }
.status-pill[data-state="running"] .dot { background: var(--green); box-shadow: 0 0 8px var(--green); animation: pulse 1.2s infinite; }
.status-pill[data-state="complete"] { color: var(--acid); border-color: color-mix(in srgb, var(--acid) 45%, transparent); }
.status-pill[data-state="complete"] .dot { background: var(--acid); }
.status-pill[data-state="rewound"] { color: var(--magenta); border-color: color-mix(in srgb, var(--magenta) 45%, transparent); }
.status-pill[data-state="rewound"] .dot { background: var(--magenta); }
.status-pill[data-state="paused"] .dot { background: var(--cyan); }

.stage { position: relative; height: clamp(320px, 50vh, 520px); background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--cyan) 4%, transparent), transparent 70%), var(--bg-2); }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: pan-y; }
.stage-overlay { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); display: flex; align-items: center; gap: 0; pointer-events: none; font: 600 10.5px/1 var(--font-mono); letter-spacing: 0.08em; white-space: nowrap; background: var(--surface); border: 1px solid var(--line); }
.stage-readout { color: var(--cyan); padding: 6px 8px; }
.stage-hint { color: var(--muted); padding: 6px 8px; border-left: 1px solid var(--line); }
.stage:fullscreen { height: 100vh; }
.stage:fullscreen .stage-hint::after { content: " · Esc to exit"; }

.transport { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.transport-buttons { display: flex; gap: 6px; }
.t-btn { width: 40px; height: 40px; display: grid; place-items: center; border: 1px solid var(--line-2); color: var(--muted); background: var(--surface-2); transition: all 0.15s; }
.t-btn:hover { color: var(--cyan); border-color: var(--line-hot); }
.t-btn.play {
  width: 52px; background: var(--cyan); border-color: var(--cyan); color: var(--on-accent);
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
}
.t-btn.play:hover { color: var(--on-accent); filter: brightness(1.12) drop-shadow(0 0 8px var(--cyan)); }
.t-btn.play.is-running { background: var(--magenta); border-color: var(--magenta); color: #fff; }
.timeline { flex: 1; min-width: 180px; display: flex; align-items: center; gap: 12px; }
.time-readout { font: 600 13px/1 var(--font-mono); color: var(--text); min-width: 76px; text-align: right; }
.speed { display: flex; border: 1px solid var(--line-2); }
.speed button { height: 34px; padding: 0 10px; font: 600 11px/1 var(--font-mono); color: var(--muted); border-right: 1px solid var(--line); }
.speed button:last-child { border-right: 0; }
.speed button:hover { color: var(--text); background: var(--cyan-soft); }
.speed button.active { background: var(--cyan-soft); color: var(--cyan); box-shadow: inset 0 -2px 0 var(--cyan); }

input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: transparent; cursor: pointer; --fill: 0%; }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; background: linear-gradient(90deg, var(--cyan) var(--fill), var(--line-2) var(--fill)); }
input[type="range"]::-moz-range-track { height: 4px; background: var(--line-2); }
input[type="range"]::-moz-range-progress { height: 4px; background: var(--cyan); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; margin-top: -5px; background: var(--surface-solid); border: 2px solid var(--cyan); transform: rotate(45deg); box-shadow: 0 0 10px var(--cyan); }
input[type="range"]::-moz-range-thumb { width: 11px; height: 11px; border-radius: 0; background: var(--surface-solid); border: 2px solid var(--cyan); transform: rotate(45deg); box-shadow: 0 0 10px var(--cyan); }
input[type="range"]:disabled { opacity: 0.4; cursor: default; }

.metric { position: relative; padding: 14px 14px 12px; border: 1px solid var(--line); background: var(--surface); overflow: hidden; min-width: 0; }
.metric::before { content: ""; position: absolute; left: 0; top: 0; width: 22px; height: 2px; background: var(--cyan); box-shadow: 0 0 8px var(--cyan); }
.metric:nth-child(2)::before { background: var(--magenta); box-shadow: 0 0 8px var(--magenta); }
.metric:nth-child(3)::before { background: var(--acid); box-shadow: 0 0 8px var(--acid); }
.metric:nth-child(4)::before { background: var(--green); box-shadow: 0 0 8px var(--green); }
.metric span { display: block; font: 600 10px/1.2 var(--font-mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--dim); }
.metric strong { display: block; margin: 9px 0 6px; font: 600 clamp(16px, 1.6vw, 21px)/1 var(--font-mono); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metric small { display: block; font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.field-label { display: block; font: 600 10px/1 var(--font-mono); letter-spacing: 0.14em; color: var(--dim); margin: 14px 0 8px; }
.panel-head + .field-label { margin-top: 0; }
.select {
  width: 100%; height: 42px; padding: 0 36px 0 12px; appearance: none;
  border: 1px solid var(--line-2); border-radius: 0; background: var(--surface-2);
  background-image: linear-gradient(45deg, transparent 50%, var(--cyan) 50%), linear-gradient(135deg, var(--cyan) 50%, transparent 50%);
  background-position: calc(100% - 17px) 18px, calc(100% - 12px) 18px; background-size: 5px 5px; background-repeat: no-repeat;
  font-weight: 600; cursor: pointer;
}
.select:focus { outline: none; border-color: var(--line-hot); box-shadow: var(--glow-cyan); }
.select option { background: var(--surface-solid); color: var(--text); }
.select-inline { width: auto; height: 32px; margin-top: 6px; font: 700 13px/1 var(--font-display); text-transform: uppercase; letter-spacing: 0.06em; background-position: calc(100% - 17px) 13px, calc(100% - 12px) 13px; }
.model-index { font: 800 30px/1 var(--font-display); color: transparent; -webkit-text-stroke: 1px var(--line-hot); }
.model-desc { color: var(--muted); font-size: 13px; margin-top: 12px; }
.preset-list { display: flex; flex-wrap: wrap; gap: 6px; }
.preset {
  padding: 7px 10px; text-align: left; border: 1px solid var(--line-2); background: var(--surface-2); transition: all 0.15s;
}
.preset b { display: block; font: 600 12px/1.2 var(--font-ui); }
.preset small { display: block; font: 500 10px/1.2 var(--font-mono); color: var(--dim); margin-top: 3px; }
.preset:hover, .preset.active { border-color: var(--magenta); background: var(--magenta-soft); }
.preset.active b { color: var(--magenta); }

.params { display: grid; gap: 16px; }
.param-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; }
.param-top label { font-size: 13px; font-weight: 600; }
.param-top label i { font-style: normal; font-family: var(--font-mono); color: var(--magenta); margin-right: 6px; }
.param-num { display: flex; align-items: center; gap: 5px; font: 500 11px/1 var(--font-mono); color: var(--dim); }
.param-num input {
  width: 74px; height: 28px; padding: 0 7px; text-align: right;
  border: 1px solid var(--line-2); background: var(--surface-2); color: var(--cyan); font: 600 12px/1 var(--font-mono);
  -moz-appearance: textfield;
}
.param-num input::-webkit-inner-spin-button { -webkit-appearance: none; }
.param-num input:focus { outline: none; border-color: var(--line-hot); box-shadow: var(--glow-cyan); }
.range-hints { display: flex; justify-content: space-between; font: 500 10px/1 var(--font-mono); color: var(--dim); }
.footnote { margin-top: 14px; font-size: 11.5px; color: var(--dim); border-top: 1px dashed var(--line); padding-top: 12px; }

.equations { display: grid; gap: 6px; }
.eq { font: 500 13.5px/1.3 var(--font-mono); padding: 9px 12px; border-left: 2px solid var(--cyan); background: var(--cyan-soft); color: var(--text); overflow-x: auto; white-space: nowrap; }
.assumptions { margin: 0 0 14px; padding: 0; list-style: none; display: grid; gap: 5px; }
.assumptions li { font-size: 12.5px; color: var(--muted); padding-left: 16px; position: relative; }
.assumptions li::before { content: ""; position: absolute; left: 2px; top: 7px; width: 6px; height: 6px; border: 1px solid var(--acid); transform: rotate(45deg); }

.chart-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.chart-title { display: flex; flex-direction: column; }
.chart-tools { display: flex; gap: 6px; }
.chart-stats { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 12px 0 6px; font: 500 11px/1.2 var(--font-mono); color: var(--dim); }
.chart-stats b { color: var(--text); font-weight: 600; margin-left: 5px; }
.chart-box { position: relative; height: 230px; }
.chart-box canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; font: 500 11px/1.3 var(--font-mono); color: var(--muted); }
.chart-legend span { display: inline-flex; align-items: center; gap: 7px; }
.chart-legend i { width: 16px; height: 2px; background: var(--c); box-shadow: 0 0 6px var(--c); }
.chart-legend i.dash { background: repeating-linear-gradient(90deg, var(--c) 0 4px, transparent 4px 7px); box-shadow: none; }
.chart-legend button { color: var(--dim); display: inline-grid; place-items: center; }
.chart-legend button:hover { color: var(--red); }
.chart-legend button .i { width: 12px; height: 12px; }

/* ---------- EXPERIMENTS ---------- */
.saved-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.saved-card { position: relative; border: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; transition: border-color 0.15s; }
.saved-card:hover { border-color: var(--line-hot); }
.saved-top { display: flex; align-items: center; gap: 12px; padding: 16px 16px 12px; }
.saved-top .lab-icon { --c: var(--cyan); width: 38px; height: 38px; }
.saved-top strong { display: block; font-weight: 700; font-size: 15px; word-break: break-word; }
.saved-top small { display: block; font: 500 11px/1.3 var(--font-mono); color: var(--dim); margin-top: 3px; }
.saved-params { display: flex; flex-wrap: wrap; gap: 5px; padding: 0 16px 14px; }
.saved-params span { font: 500 10.5px/1 var(--font-mono); padding: 5px 7px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }
.saved-params span b { color: var(--cyan); font-weight: 600; }
.saved-actions { margin-top: auto; display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; border-top: 1px solid var(--line); }
.saved-actions button { height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: 600 10.5px/1 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); border-right: 1px solid var(--line); }
.saved-actions button:last-child { border-right: 0; }
.saved-actions button .i { width: 14px; height: 14px; }
.saved-actions button:hover { background: var(--cyan-soft); color: var(--cyan); }
.saved-actions .open { color: var(--cyan); }
.saved-actions .danger:hover { background: color-mix(in srgb, var(--red) 12%, transparent); color: var(--red); }

/* ---------- LEARN ---------- */
.learn-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 20px; align-items: start; }
.learn-tabs { display: grid; gap: 4px; position: sticky; top: 80px; }
.learn-tab { display: flex; align-items: center; gap: 10px; padding: 11px 12px; text-align: left; border: 1px solid transparent; color: var(--muted); font-weight: 600; font-size: 13.5px; }
.learn-tab small { margin-left: auto; font: 600 10px/1 var(--font-mono); color: var(--dim); }
.learn-tab:hover { color: var(--text); background: var(--cyan-soft); }
.learn-tab.active { color: var(--text); border-color: var(--line-hot); background: var(--cyan-soft); box-shadow: inset 3px 0 0 var(--cyan); }
.learn-body { display: grid; gap: 14px; }
.learn-body h2 { margin-top: 10px; }
.learn-body p { color: var(--muted); max-width: 70ch; }
.learn-hero { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.learn-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.var-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.var-table th, .var-table td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.var-table th { font: 600 10px/1 var(--font-mono); letter-spacing: 0.12em; color: var(--dim); text-transform: uppercase; }
.var-table td:first-child { font: 700 14px/1.2 var(--font-mono); color: var(--magenta); width: 54px; }
.var-table td:last-child { color: var(--muted); }
.check-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 9px; }
.check-list li { position: relative; padding-left: 22px; color: var(--muted); font-size: 13.5px; }
.check-list li::before { content: ""; position: absolute; left: 0; top: 6px; width: 8px; height: 8px; background: var(--cyan); box-shadow: 0 0 8px var(--cyan); transform: rotate(45deg); }
.check-list.try li::before { background: var(--magenta); box-shadow: 0 0 8px var(--magenta); }
.check-list.warn li::before { background: none; border: 1px solid var(--acid); box-shadow: none; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 16px; }
.step-card { padding: 14px; border: 1px solid var(--line); background: var(--surface-2); }
.step-card b { font: 800 26px/1 var(--font-display); color: transparent; -webkit-text-stroke: 1px var(--cyan); }
.step-card strong { display: block; margin-top: 8px; }
.step-card small { color: var(--muted); font-size: 12.5px; }
.callout { display: grid; gap: 4px; padding: 14px 16px; border: 1px solid color-mix(in srgb, var(--acid) 40%, transparent); background: color-mix(in srgb, var(--acid) 6%, transparent); margin-top: 14px; }
.callout strong { font: 700 11px/1 var(--font-mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--acid); }
.callout span { color: var(--muted); font-size: 13px; }

/* ---------- modal, palette, toast ---------- */
.modal-backdrop, .palette-backdrop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: rgba(2, 4, 8, 0.7); backdrop-filter: blur(6px); animation: fade 0.2s; }
:root[data-theme="light"] .modal-backdrop, :root[data-theme="light"] .palette-backdrop { background: rgba(20, 30, 50, 0.35); }
.modal { position: relative; width: min(520px, 100%); max-height: calc(100vh - 40px); overflow: auto; padding: 22px; background: var(--surface-solid); border: 1px solid var(--line-2); box-shadow: var(--shadow); animation: pop 0.25s var(--ease); }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.modal-head h2 { margin-top: 8px; font-size: 22px; }
.modal p { color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.form-input { width: 100%; height: 44px; padding: 0 12px; border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text); }
.form-input:focus { outline: none; border-color: var(--line-hot); box-shadow: var(--glow-cyan); }
.form-help { font-size: 12px; color: var(--dim); margin-top: 8px; }
.option-list { display: grid; gap: 8px; margin-top: 14px; }
.option { display: flex; align-items: center; gap: 12px; padding: 13px 14px; text-align: left; border: 1px solid var(--line-2); background: var(--surface-2); transition: all 0.15s; }
.option:hover { border-color: var(--line-hot); background: var(--cyan-soft); }
.option .i { color: var(--cyan); width: 20px; height: 20px; }
.option b { display: block; font-size: 14px; }
.option span { display: block; font-size: 12px; color: var(--muted); }
.shortcut-grid { display: grid; grid-template-columns: auto 1fr; gap: 9px 16px; align-items: center; font-size: 13px; color: var(--muted); }
.shortcut-grid div { display: flex; gap: 4px; }

.palette-backdrop { align-items: start; padding-top: 12vh; }
.palette { width: min(620px, 100%); background: var(--surface-solid); border: 1px solid var(--line-hot); box-shadow: var(--glow-cyan), var(--shadow); animation: pop 0.2s var(--ease); }
.palette-input { display: flex; align-items: center; gap: 12px; padding: 0 16px; height: 56px; border-bottom: 1px solid var(--line); color: var(--cyan); }
.palette-input input { flex: 1; background: none; border: 0; outline: none; font-size: 16px; color: var(--text); }
.palette-list { list-style: none; margin: 0; padding: 6px; max-height: 50vh; overflow: auto; }
.palette-group { font: 600 10px/1 var(--font-mono); letter-spacing: 0.14em; color: var(--dim); padding: 10px 10px 6px; text-transform: uppercase; }
.palette-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; cursor: pointer; color: var(--muted); }
.palette-item .i { color: var(--dim); }
.palette-item b { color: var(--text); font-weight: 600; }
.palette-item small { margin-left: auto; font: 500 11px/1 var(--font-mono); color: var(--dim); }
.palette-item.active { background: var(--cyan-soft); box-shadow: inset 2px 0 0 var(--cyan); }
.palette-item.active .i { color: var(--cyan); }
.palette-empty { padding: 24px; text-align: center; color: var(--dim); }
.palette-foot { display: flex; gap: 18px; padding: 10px 16px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--dim); }
.palette-foot kbd { margin-right: 4px; }

.toast-region { position: fixed; right: 20px; bottom: 20px; z-index: 120; display: grid; gap: 8px; justify-items: end; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px; max-width: 360px; padding: 12px 16px;
  background: var(--surface-solid); border: 1px solid var(--line-2); border-left: 3px solid var(--cyan);
  box-shadow: var(--shadow); font-size: 13px; pointer-events: auto;
  transform: translateX(20px); opacity: 0; transition: all 0.25s var(--ease);
}
.toast.show { transform: none; opacity: 1; }
.toast.success { border-left-color: var(--green); }
.toast.error { border-left-color: var(--red); }
.toast::before { content: "›"; font: 700 16px/1 var(--font-mono); color: var(--cyan); }
.toast.success::before { color: var(--green); }
.toast.error::before { color: var(--red); content: "!"; }

/* ---------- animations ---------- */
@keyframes pageIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(0.98); } }
@keyframes pulse { 50% { opacity: 0.35; } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes glitchA { 0% { opacity: 1; transform: translate(-3px, 1px); } 30% { transform: translate(3px, -1px); clip-path: inset(30% 0 40% 0); } 60% { transform: translate(-2px, 0); clip-path: inset(70% 0 5% 0); } 100% { opacity: 0; } }
@keyframes glitchB { 0% { opacity: 1; transform: translate(3px, -1px); } 30% { transform: translate(-3px, 1px); clip-path: inset(5% 0 75% 0); } 60% { transform: translate(2px, 0); clip-path: inset(45% 0 30% 0); } 100% { opacity: 0; } }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .ws-grid { grid-template-columns: minmax(0, 1fr) 320px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lab-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 960px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 280px; transform: translateX(-102%); transition: transform 0.3s var(--ease); box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .mobile-menu { display: inline-grid; }
  .topbar { padding: 0 16px; }
  .cmd-trigger { min-width: 0; width: 42px; padding: 0; justify-content: center; }
  .cmd-trigger span, .cmd-trigger kbd { display: none; }
  .page-wrap { padding: 20px 16px 0; }
  .ws-grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "stage" "side" "metrics" "chart"; grid-template-rows: none; }
  .ws-side { position: static; }
  .home-split, .learn-cols { grid-template-columns: 1fr; }
  .learn-layout { grid-template-columns: 1fr; }
  .learn-tabs { position: static; display: flex; overflow-x: auto; gap: 6px; padding-bottom: 4px; }
  .learn-tab { flex: none; border-color: var(--line); }
}
@media (max-width: 640px) {
  h1 { font-size: 30px; }
  .hero { padding: 28px 20px 150px; min-height: 0; }
  .hero h1 { font-size: 44px; }
  .hero-hud { left: 16px; right: 16px; top: auto; bottom: 16px; min-width: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .hud-title { grid-column: 1 / -1; margin: 0; }
  .hud-row { flex-direction: column; gap: 4px; border-top: 0; }
  .stat-strip { grid-template-columns: repeat(2, 1fr); }
  .stat-strip div:nth-child(2) { border-right: 0; }
  .stat-strip div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .lab-grid { grid-template-columns: 1fr; }
  .lab-card { min-height: 0; }
  .crumbs > span:first-child, .crumbs .sep { display: none; }
  .search-box { min-width: 0; width: 100%; }
  .stage { height: 340px; }
  .transport { gap: 10px; }
  .timeline { order: 3; flex-basis: 100%; }
  .speed { margin-left: auto; }
  .speed button { padding: 0 8px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .steps { grid-template-columns: 1fr; }
  .ws-actions { width: 100%; }
  .ws-actions .btn { flex: 1; }
  .head-actions { width: 100%; }
  .head-actions .btn { flex: 1; }
  .toast-region { left: 16px; right: 16px; bottom: 16px; justify-items: stretch; }
  .toast { max-width: none; }
  .stage-overlay { display: none; }
}

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

/* ---------- late additions ---------- */
.form-input.area { height: auto; min-height: 86px; padding: 10px 12px; resize: vertical; font: inherit; line-height: 1.5; }
.saved-notes { padding: 0 16px 12px; font-size: 12.5px; color: var(--muted); border-left: 2px solid var(--magenta); margin: 0 16px 12px; padding: 2px 0 2px 10px; }
.learn-what { margin-top: 12px; font-size: 15px; }
.learn-eq { margin-top: 12px; }
.panel > .eyebrow + h3, .panel > .eyebrow + h2 { margin-top: 8px; }
.panel > h3 + p, .panel > h2 + p { margin-top: 10px; }
.panel .check-list, .panel .var-table { margin-top: 12px; }
