/* ============================
   NEBULA — Design Tokens
   ============================ */
:root {
  --a: oklch(0.75 0.18 200);   /* accent A */
  --b: oklch(0.65 0.22 320);   /* accent B */
  --bg-0: oklch(0.13 0.03 260);
  --bg-1: oklch(0.18 0.04 270);
  --ink-0: oklch(0.97 0.01 260);
  --ink-1: oklch(0.82 0.02 260);
  --ink-2: oklch(0.62 0.02 260);
  --line: color-mix(in oklab, var(--ink-0) 12%, transparent);
  --glass-bg: color-mix(in oklab, var(--bg-1) 55%, transparent);
  --glass-brd: color-mix(in oklab, var(--ink-0) 18%, transparent);
  --shadow-lg: 0 30px 80px -20px oklch(0 0 0 / 0.6), 0 8px 30px -8px oklch(0 0 0 / 0.4);
  --radius: 18px;
  --radius-sm: 10px;
  --dur-fast: 180ms;
  --dur: 320ms;
  --ease: cubic-bezier(.2,.7,.2,1);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg-0);
  color: var(--ink-0);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, sans-serif;
  font-feature-settings: 'ss01','cv11','tnum';
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  letter-spacing: -0.01em;
}
.mono { font-family: 'JetBrains Mono', ui-monospace, 'SF Mono', Consolas, monospace; font-feature-settings: 'tnum','ss01'; }

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input[type=range] { -webkit-appearance: none; appearance: none; background: transparent; }

/* ============================
   Canvas + Ambient Layers
   ============================ */
#scene {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  display: block;
  z-index: 0;
}
.grid {
  position: fixed; inset: 0;
  z-index: 1;
  pointer-events: none;
  background-image:
    linear-gradient(to right, var(--line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--line) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: radial-gradient(ellipse 65% 50% at 50% 55%, black 0%, transparent 80%);
  opacity: 0.35;
  animation: gridDrift 40s linear infinite;
}
@keyframes gridDrift {
  from { background-position: 0 0, 0 0; }
  to   { background-position: 72px 72px, 72px 72px; }
}
.vignette {
  position: fixed; inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    radial-gradient(ellipse 90% 65% at 50% 45%, transparent 40%, oklch(0 0 0 / 0.55) 100%),
    linear-gradient(to bottom, oklch(0 0 0 / 0.35), transparent 20%, transparent 75%, oklch(0 0 0 / 0.45));
}

/* ============================
   Glass Primitive
   ============================ */
.glass {
  background: var(--glass-bg);
  border: 1px solid var(--glass-brd);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  box-shadow: var(--shadow-lg), inset 0 1px 0 color-mix(in oklab, var(--ink-0) 15%, transparent);
  border-radius: var(--radius);
}

/* ============================
   Top Bar
   ============================ */
.topbar {
  position: fixed; z-index: 10;
  top: 20px; left: 20px; right: 20px;
  display: flex; align-items: center; gap: 20px;
  padding: 12px 16px;
  border-radius: 999px;
}
.brand { display: flex; align-items: center; gap: 12px; padding-right: 12px; border-right: 1px solid var(--line); }
.brand-dot {
  width: 26px; height: 26px; border-radius: 50%;
  background: conic-gradient(from 0deg, var(--a), var(--b), var(--a));
  box-shadow: 0 0 24px color-mix(in oklab, var(--a) 60%, transparent);
  animation: spin 8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-name { font-weight: 700; letter-spacing: 0.14em; font-size: 13px; }
.brand-sub  { font-size: 10.5px; color: var(--ink-2); letter-spacing: 0.08em; }

.topnav { display: flex; gap: 6px; margin-left: 4px; }
.nav-pill {
  padding: 7px 14px; border-radius: 999px;
  font-size: 12px; letter-spacing: 0.05em;
  color: var(--ink-1);
  border: 1px solid transparent;
  transition: all var(--dur-fast) var(--ease);
}
.nav-pill:hover { color: var(--ink-0); background: color-mix(in oklab, var(--ink-0) 6%, transparent); }
.nav-pill.active {
  color: var(--ink-0);
  background: color-mix(in oklab, var(--a) 20%, transparent);
  border-color: color-mix(in oklab, var(--a) 50%, transparent);
  box-shadow: 0 0 20px color-mix(in oklab, var(--a) 35%, transparent);
}

.status { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 11px; letter-spacing: 0.14em; color: var(--ink-1); padding-left: 12px; border-left: 1px solid var(--line); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: oklch(0.82 0.20 145); box-shadow: 0 0 10px oklch(0.82 0.20 145 / 0.9); animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.45; transform: scale(0.85); } }

/* ============================
   Side Panels
   ============================ */
.panel {
  position: fixed; z-index: 10;
  top: 96px; bottom: 96px;
  width: 260px;
  padding: 22px 20px;
  display: flex; flex-direction: column; gap: 18px;
}
.panel-left  { left: 20px; }
.panel-right { right: 20px; }
.panel-title {
  font-size: 10.5px; letter-spacing: 0.22em; color: var(--ink-2);
  padding-bottom: 12px; border-bottom: 1px solid var(--line);
}

/* Metrics */
.metric { display: flex; flex-direction: column; gap: 6px; }
.metric-label { font-size: 10.5px; letter-spacing: 0.18em; color: var(--ink-2); }
.metric-value { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 22px; font-weight: 600; letter-spacing: -0.02em; display: flex; align-items: baseline; gap: 6px; }
.metric-value small { font-size: 10.5px; color: var(--ink-2); font-weight: 400; letter-spacing: 0.08em; }
.metric-bar { height: 4px; background: color-mix(in oklab, var(--ink-0) 8%, transparent); border-radius: 999px; overflow: hidden; }
.metric-bar-fill { height: 100%; width: 60%; background: linear-gradient(90deg, var(--a), var(--b)); border-radius: 999px; transition: width var(--dur) var(--ease); box-shadow: 0 0 10px color-mix(in oklab, var(--a) 60%, transparent); }

.legend { display: flex; flex-direction: column; gap: 8px; margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); font-size: 11px; color: var(--ink-1); }
.legend > div { display: flex; align-items: center; gap: 10px; }
.sw { width: 10px; height: 10px; border-radius: 3px; }
.sw-a { background: var(--a); box-shadow: 0 0 8px color-mix(in oklab, var(--a) 60%, transparent); }
.sw-b { background: var(--b); box-shadow: 0 0 8px color-mix(in oklab, var(--b) 60%, transparent); }
.sw-c { background: oklch(0.90 0.15 90); box-shadow: 0 0 8px oklch(0.90 0.15 90 / 0.6); }

/* Controls */
.control { display: flex; flex-direction: column; gap: 8px; }
.control-head { display: flex; justify-content: space-between; font-size: 11px; letter-spacing: 0.12em; color: var(--ink-1); }
.control-value { font-family: 'JetBrains Mono', monospace; color: var(--ink-0); }
input[type=range] {
  width: 100%;
  height: 4px;
  background: color-mix(in oklab, var(--ink-0) 10%, transparent);
  border-radius: 999px;
  outline: none;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: linear-gradient(135deg, var(--a), var(--b));
  border: 2px solid var(--bg-0);
  box-shadow: 0 0 12px color-mix(in oklab, var(--a) 70%, transparent);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease);
}
input[type=range]::-webkit-slider-thumb:hover { transform: scale(1.2); }
input[type=range]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: linear-gradient(135deg, var(--a), var(--b));
  border: 2px solid var(--bg-0);
  cursor: pointer;
}

.palette { display: flex; flex-direction: column; gap: 10px; margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); }
.palette-title { font-size: 10.5px; letter-spacing: 0.22em; color: var(--ink-2); }
.palette-swatches { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.sw-btn {
  aspect-ratio: 1;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--a), var(--b));
  border: 2px solid transparent;
  transition: all var(--dur-fast) var(--ease);
  position: relative;
}
.sw-btn:hover { transform: translateY(-2px); }
.sw-btn.active { border-color: var(--ink-0); box-shadow: 0 0 16px color-mix(in oklab, var(--ink-0) 40%, transparent); }

/* ============================
   Hero
   ============================ */
.hero {
  position: fixed; z-index: 5;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: min(680px, 60vw);
  text-align: center;
  pointer-events: none;
}
.hero-eyebrow {
  font-size: 11px;
  letter-spacing: 0.42em;
  color: var(--ink-2);
  margin-bottom: 22px;
  animation: fadeUp 900ms var(--ease) both;
}
.hero-title {
  font-size: clamp(38px, 6vw, 76px);
  line-height: 1.03;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0 0 22px;
}
.hero-title .h-line { display: block; animation: fadeUp 1000ms var(--ease) both; }
.hero-title .h-line:nth-child(2) { animation-delay: 120ms; }
.hero-title .grad {
  background: linear-gradient(120deg, var(--a) 0%, var(--b) 55%, var(--a) 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  animation: fadeUp 1000ms var(--ease) 120ms both, gradShift 6s ease-in-out infinite;
}
@keyframes gradShift { 50% { background-position: 100% 0; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.hero-lede {
  max-width: 480px; margin: 0 auto 30px;
  color: var(--ink-1); font-size: 15px; line-height: 1.55;
  animation: fadeUp 1100ms var(--ease) 240ms both;
}
.hero-cta { display: inline-flex; gap: 10px; pointer-events: auto; animation: fadeUp 1100ms var(--ease) 360ms both; }
.cta {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 13px; letter-spacing: 0.02em; font-weight: 500;
  transition: all var(--dur-fast) var(--ease);
  border: 1px solid transparent;
}
.cta.primary {
  background: linear-gradient(120deg, var(--a), var(--b));
  color: oklch(0.15 0.02 260);
  font-weight: 600;
  box-shadow: 0 8px 30px -6px color-mix(in oklab, var(--a) 55%, transparent), inset 0 1px 0 oklch(1 0 0 / 0.4);
}
.cta.primary:hover { transform: translateY(-2px); box-shadow: 0 14px 40px -6px color-mix(in oklab, var(--a) 70%, transparent), inset 0 1px 0 oklch(1 0 0 / 0.5); }
.cta.ghost {
  color: var(--ink-0);
  background: color-mix(in oklab, var(--ink-0) 6%, transparent);
  border-color: var(--glass-brd);
  backdrop-filter: blur(10px);
}
.cta.ghost:hover { background: color-mix(in oklab, var(--ink-0) 12%, transparent); }

/* ============================
   Bottom Dock
   ============================ */
.dock {
  position: fixed; z-index: 10;
  left: 50%; bottom: 20px;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 18px;
  padding: 12px 22px;
  border-radius: 999px;
  max-width: min(920px, calc(100vw - 40px));
}
.dock-item { display: flex; flex-direction: column; line-height: 1.1; gap: 3px; }
.dock-key { font-size: 9.5px; letter-spacing: 0.22em; color: var(--ink-2); }
.dock-val { font-size: 12px; color: var(--ink-0); display: flex; align-items: center; gap: 7px; }
.dock-sep { width: 1px; height: 26px; background: var(--line); }
.dock-spacer { flex: 1; min-width: 12px; }
.dock-hint { font-size: 11px; color: var(--ink-2); letter-spacing: 0.02em; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--a); box-shadow: 0 0 8px var(--a); animation: pulse 1.6s ease-in-out infinite; }

/* ============================
   Responsive fallbacks
   ============================ */
@media (max-width: 1100px) {
  .panel { width: 220px; padding: 18px 16px; }
  .hero { width: 70vw; }
}
@media (max-width: 860px) {
  .panel { display: none; }
  .hero { width: 88vw; }
  .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 14px; border-radius: 22px; }
  .topnav { order: 3; width: 100%; overflow-x: auto; padding-top: 4px; border-top: 1px solid var(--line); }
  .dock-hint { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
