:root {
  --bg: #07090f;
  --bg-2: #0b1019;
  --panel: rgba(14, 20, 31, 0.78);
  --panel-solid: #0e141f;
  --line: #1c2534;
  --line-2: #273246;
  --text: #e6edf7;
  --muted: #8a97ab;
  --cyan: #3fe0d0;
  --violet: #8b7bff;
  --pink: #ff5fa2;
  --amber: #ffb547;
  --green: #3ddc84;
  --red: #ff5b6b;
  --radius: 16px;
  --font: "Space Grotesk", system-ui, -apple-system, Segoe UI, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: inherit; }
code, .mono { font-family: var(--mono); }
img, svg, canvas { display: block; }

.bg-grid {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(139, 123, 255, 0.18), transparent 60%),
    radial-gradient(700px 500px at 0% 20%, rgba(63, 224, 208, 0.12), transparent 60%),
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px) 0 0 / 44px 44px,
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px) 0 0 / 44px 44px,
    var(--bg);
}

/* ───── nav ───── */
.nav {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px clamp(16px, 4vw, 48px);
  background: rgba(7, 9, 15, 0.7);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 600; font-size: 18px; letter-spacing: -0.01em; }
.brand b { color: var(--cyan); font-weight: 700; }
.nav-links { display: flex; gap: 26px; font-size: 14px; }
.nav-links a { text-decoration: none; color: var(--muted); transition: color .2s; }
.nav-links a:hover { color: var(--text); }
.nav-gh { color: var(--text) !important; border: 1px solid var(--line-2); padding: 4px 12px; border-radius: 999px; }

/* ───── hero ───── */
.hero {
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 40px; align-items: center;
  max-width: 1240px; margin: 0 auto;
  padding: clamp(48px, 9vw, 110px) clamp(16px, 4vw, 48px) 60px;
}
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 12px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--cyan); margin: 0 0 18px;
}
.eyebrow .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 12px var(--cyan); animation: blink 2s infinite; }
h1 { font-size: clamp(40px, 6.4vw, 78px); line-height: 1.02; letter-spacing: -0.035em; margin: 0 0 22px; font-weight: 700; }
.grad { background: linear-gradient(92deg, var(--cyan), var(--violet) 55%, var(--pink)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lede { color: var(--muted); font-size: clamp(16px, 1.6vw, 18px); max-width: 560px; margin: 0 0 30px; }
.lede em { color: var(--text); font-style: normal; border-bottom: 1px dashed var(--cyan); }
.cta { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 40px; }

.hero-stats { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; max-width: 560px; }
.hero-stats li { background: var(--bg-2); padding: 14px 16px; }
.hero-stats b { display: block; font-size: 24px; font-family: var(--mono); font-weight: 600; }
.hero-stats span { font-size: 12px; color: var(--muted); }

.hero-visual { position: relative; max-width: 460px; width: 100%; justify-self: center; }
.iris-svg { width: 100%; height: auto; filter: drop-shadow(0 30px 80px rgba(63, 224, 208, .15)); }
.spin-slow { transform-origin: 200px 200px; animation: spin 40s linear infinite; }
.spin-rev { transform-origin: 200px 200px; animation: spin 90s linear infinite reverse; }
.pulse { animation: pulse 2.4s ease-in-out infinite; }
.scanline { animation: scan 3.6s ease-in-out infinite; }
.tag {
  position: absolute; font-family: var(--mono); font-size: 12px;
  background: rgba(11, 16, 25, .85); border: 1px solid var(--line-2); border-radius: 10px;
  padding: 7px 11px; backdrop-filter: blur(8px); white-space: nowrap;
  animation: float 6s ease-in-out infinite;
}
.tag span { color: var(--cyan); margin-right: 4px; }
.tag .ok { color: var(--green); font-weight: 600; }
.tag-a { top: 12%; left: -6%; }
.tag-b { bottom: 14%; right: -4%; animation-delay: -2s; }
.tag-c { bottom: 2%; left: 4%; animation-delay: -4s; }
.tag-c span { color: var(--pink); }

/* ───── buttons ───── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font: 600 15px var(--font); text-decoration: none; cursor: pointer;
  padding: 12px 20px; border-radius: 12px; border: 1px solid transparent;
  transition: transform .15s, background .2s, border-color .2s, opacity .2s;
  color: var(--text); background: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--cyan), #22b3c7); color: #031014; box-shadow: 0 8px 30px rgba(63, 224, 208, .25); }
.btn-primary:hover:not(:disabled) { box-shadow: 0 10px 36px rgba(63, 224, 208, .4); }
.btn-ghost { border-color: var(--line-2); background: rgba(255,255,255,.02); }
.btn-ghost:hover:not(:disabled) { border-color: var(--cyan); }
.btn-sm { padding: 9px 14px; font-size: 14px; border-radius: 10px; }
.btn-danger { background: rgba(255, 91, 107, .12); border-color: rgba(255, 91, 107, .5); color: #ffc3c9; box-shadow: none; }
.link { background: none; border: 0; color: var(--muted); font: 12px var(--mono); cursor: pointer; padding: 0; }
.link:hover { color: var(--cyan); }

/* ───── sections ───── */
.section { max-width: 1240px; margin: 0 auto; padding: 70px clamp(16px, 4vw, 48px); }
.section-head { margin-bottom: 28px; max-width: 720px; }
.section-head h2, .stack h2 { font-size: clamp(28px, 3.6vw, 42px); letter-spacing: -0.025em; margin: 0 0 10px; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }

/* ───── toolbar ───── */
.toolbar { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.tool-group { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pill { position: relative; cursor: pointer; user-select: none; }
.pill input { position: absolute; opacity: 0; pointer-events: none; }
.pill span {
  display: inline-block; font-size: 13px; padding: 7px 12px; border-radius: 999px;
  border: 1px solid var(--line-2); color: var(--muted); transition: all .2s;
}
.pill input:checked + span { color: var(--text); border-color: var(--cyan); background: rgba(63, 224, 208, .1); }
.pill input:focus-visible + span { outline: 2px solid var(--cyan); outline-offset: 2px; }

/* ───── lab ───── */
.lab { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 18px; }
.lab-main, .lab-side { display: flex; flex-direction: column; gap: 18px; min-width: 0; }

.stage {
  position: relative; aspect-ratio: 16 / 10; width: 100%;
  background: #04060a; border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: grid; place-items: center;
}
.stage canvas#output { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; opacity: 0; transition: opacity .3s; }
.stage.active canvas#output { opacity: 1; }
.stage.mirrored canvas#output, .eye-row.mirrored .eye-canvas { transform: scaleX(-1); }
.stage-empty { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; padding: 20px; }
.stage.active .stage-empty { display: none; }
.stage-empty h3 { margin: 18px 0 4px; font-size: 20px; }
.stage-empty p { margin: 2px 0; color: var(--muted); }
.empty-iris {
  width: 96px; height: 96px; margin: 0 auto; border-radius: 50%;
  background: radial-gradient(circle, #03050a 0 26%, #1c7f86 27% 60%, #3fe0d0 61% 66%, transparent 67%);
  box-shadow: 0 0 0 1px var(--line-2), 0 0 0 14px rgba(63,224,208,.05), 0 0 50px rgba(63,224,208,.25);
  animation: pulse 2.4s ease-in-out infinite;
}
.hud { position: absolute; top: 12px; left: 12px; display: flex; gap: 6px; flex-wrap: wrap; }
.hud-right { left: auto; right: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px;
  padding: 5px 10px; border-radius: 999px; color: var(--muted);
  background: rgba(7, 9, 15, .75); border: 1px solid var(--line-2); backdrop-filter: blur(6px);
}
.chip i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.chip.loading i { background: var(--amber); animation: blink 1s infinite; }
.chip.ok { color: var(--text); } .chip.ok i { background: var(--green); box-shadow: 0 0 8px var(--green); }
.chip.err { color: #ffc3c9; } .chip.err i { background: var(--red); }
.drop-hint {
  position: absolute; inset: 10px; border: 2px dashed var(--cyan); border-radius: 12px;
  display: none; place-items: center; font-weight: 600; background: rgba(63,224,208,.08);
}
.stage.dragging .drop-hint { display: grid; }

.eye-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.eye-card, .panel, .metric, .val-card, .steps li {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  backdrop-filter: blur(10px);
}
.eye-card { padding: 14px; }
.eye-card header, .panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 8px; }
.eye-card h4, .panel h4 { margin: 0; font-size: 14px; font-weight: 600; }
.eye-card h4 small { color: var(--muted); font-weight: 400; }
.eye-canvas { width: 100%; height: auto; aspect-ratio: 16 / 9; border-radius: 10px; background: #04060a; }
.eye-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px 10px; margin: 12px 0 10px; }
.eye-stats div { min-width: 0; }
.eye-stats .wide { grid-column: span 2; }
.eye-stats dt { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.eye-stats dd { margin: 0; font-family: var(--mono); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meter { height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; }
.meter span { display: block; height: 100%; width: 0; border-radius: 6px; background: var(--cyan); transition: width .2s, background .2s; }
.eye-row.mirrored [data-eye="right"] { order: 2; }

.verdict {
  font: 600 11px var(--mono); letter-spacing: .06em; padding: 4px 9px; border-radius: 6px;
  border: 1px solid var(--line-2); color: var(--muted);
}
.verdict.pass { color: var(--green); border-color: rgba(61,220,132,.5); background: rgba(61,220,132,.1); }
.verdict.fail { color: var(--red); border-color: rgba(255,91,107,.5); background: rgba(255,91,107,.1); }
.verdict.occl { color: var(--amber); border-color: rgba(255,181,71,.5); background: rgba(255,181,71,.1); }

.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.metric { padding: 12px 14px; min-width: 0; }
.metric .label { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.metric b { display: block; font-family: var(--mono); font-size: 20px; font-weight: 600; margin: 2px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metric small { color: var(--muted); font-size: 11px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.panel { padding: 14px; }
.chart { width: 100%; height: auto; aspect-ratio: 560 / 150; }
.legend { display: flex; align-items: center; gap: 6px; font: 11px var(--mono); color: var(--muted); }
.legend i { width: 10px; height: 3px; border-radius: 2px; display: inline-block; margin-left: 6px; }
.lg-r { background: var(--cyan); } .lg-l { background: var(--violet); } .lg-t { background: var(--amber); }
.panel-gaze canvas { width: 100%; max-width: 300px; height: auto; aspect-ratio: 1; margin: 0 auto; }

/* ───── pipeline ───── */
.steps { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; counter-reset: s; }
.steps li { padding: 22px; position: relative; overflow: hidden; transition: border-color .25s, transform .25s; }
.steps li:hover { border-color: var(--line-2); transform: translateY(-2px); }
.steps li::after { content: ""; position: absolute; inset: auto -40% -60% auto; width: 200px; height: 200px; background: radial-gradient(circle, rgba(63,224,208,.12), transparent 70%); }
.step-n { font: 600 12px var(--mono); color: var(--cyan); }
.steps h3 { margin: 6px 0 8px; font-size: 19px; }
.steps p { color: var(--muted); margin: 0 0 12px; font-size: 14.5px; }
.formula {
  display: inline-block; max-width: 100%; overflow-x: auto; vertical-align: top; font-size: 12.5px; color: var(--text);
  background: rgba(255,255,255,.03); border: 1px solid var(--line-2); border-radius: 8px; padding: 6px 10px;
}
code:not(.formula) { color: var(--cyan); font-size: .92em; }

/* ───── validation ───── */
.val-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.val-card { padding: 22px; }
.val-card h3 { display: flex; align-items: center; gap: 10px; margin: 0 0 8px; font-size: 18px; }
.val-card h3 small { margin-left: auto; font: 500 12px var(--mono); color: var(--muted); }
.val-card p { color: var(--muted); font-size: 14.5px; margin: 0 0 14px; }
.sw { width: 12px; height: 12px; border-radius: 4px; }
.sw-pink { background: var(--pink); } .sw-amber { background: var(--amber); } .sw-cyan { background: var(--cyan); } .sw-violet { background: var(--violet); }
.verdict-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; margin-top: 22px; color: var(--muted); font-size: 14px; }
.verdict-legend .verdict + .verdict, .verdict-legend .verdict { margin-left: 8px; }

.stack { padding-top: 20px; }
.chips { list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-wrap: wrap; gap: 10px; }
.chips li { border: 1px solid var(--line-2); border-radius: 999px; padding: 8px 16px; font-size: 14px; background: rgba(255,255,255,.02); }

.footer { border-top: 1px solid var(--line); padding: 28px clamp(16px, 4vw, 48px); text-align: center; color: var(--muted); font-size: 13px; }
.footer a { color: var(--cyan); text-decoration: none; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 30px); opacity: 0;
  background: var(--panel-solid); border: 1px solid var(--line-2); border-radius: 12px;
  padding: 12px 18px; font-size: 14px; transition: all .3s; pointer-events: none; z-index: 50; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { border-color: rgba(255,91,107,.6); }

/* ───── animation ───── */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes scan { 0% { transform: translateY(40px); opacity: 0; } 15%, 85% { opacity: .8; } 100% { transform: translateY(360px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ───── responsive ───── */
@media (max-width: 1080px) {
  .lab { grid-template-columns: minmax(0, 1fr); }
  .lab-side { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lab-side .metric-grid { grid-column: 1 / -1; grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .panel-gaze { grid-column: 1 / -1; }
}
@media (max-width: 860px) {
  .hero { grid-template-columns: minmax(0, 1fr); }
  .hero-visual { max-width: 360px; order: -1; }
  .steps, .val-grid { grid-template-columns: 1fr 1fr; }
  .lab-side .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  .nav-links a:not(.nav-gh) { display: none; }
  .hero-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .steps, .val-grid, .eye-row, .lab-side { grid-template-columns: minmax(0, 1fr); }
  .lab-side .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .eye-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stage { aspect-ratio: 4 / 3; }
  .tag-a { left: 0; } .tag-b { right: 0; }
  .toolbar .tool-group { width: 100%; }
}
