:root {
  --bg: #0a0b0e;
  --bg-soft: #101218;
  --panel: #12141a;
  --panel-2: #16181f;
  --line: rgba(255, 255, 255, 0.075);
  --line-strong: rgba(255, 255, 255, 0.14);
  --ink: #eceef4;
  --muted: #8d92a4;
  --muted-dim: #666b7c;
  --accent: #7c8cff;
  --accent-soft: rgba(124, 140, 255, 0.14);
  --good: #4fd6a4;
  --warn: #ffb86b;
  --bad: #ff6b81;
  --radius: 16px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
code { font-family: var(--mono); font-size: 0.88em; color: var(--ink); background: rgba(255, 255, 255, 0.06); padding: 1px 5px; border-radius: 5px; }
.mono { font-family: var(--mono); }

.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(900px 480px at 78% -12%, rgba(124, 140, 255, 0.13), transparent 65%),
    radial-gradient(700px 420px at 8% 4%, rgba(79, 214, 164, 0.06), transparent 60%),
    linear-gradient(rgba(255, 255, 255, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.028) 1px, transparent 1px);
  background-size: auto, auto, 56px 56px, 56px 56px;
  mask-image: linear-gradient(180deg, #000 0%, rgba(0, 0, 0, 0.55) 55%, transparent 100%);
  z-index: 0;
}

/* ---------- top bar ---------- */

.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px 28px;
}

.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 13.5px; letter-spacing: -0.01em; }
.brand-dot {
  width: 9px; height: 9px; border-radius: 3px;
  background: linear-gradient(140deg, var(--accent), #4fd6a4);
  box-shadow: 0 0 16px rgba(124, 140, 255, 0.55);
}
.topbar-right { display: inline-flex; align-items: center; gap: 14px; }
.ghost-link { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.14em; color: var(--muted); }
.ghost-link:hover { color: var(--ink); }
button.ghost-link { appearance: none; background: none; border: 0; padding: 0; cursor: pointer; }
button.ghost-link.is-on { color: var(--good); }

.pill {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 11px; background: rgba(255, 255, 255, 0.02);
}
.pill-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted-dim); }
.pill[data-state="live"] { color: var(--good); border-color: rgba(79, 214, 164, 0.3); }
.pill[data-state="live"] .pill-dot { background: var(--good); box-shadow: 0 0 10px rgba(79, 214, 164, 0.7); }
.pill[data-state="error"] { color: var(--bad); border-color: rgba(255, 107, 129, 0.32); }
.pill[data-state="error"] .pill-dot { background: var(--bad); }
.pill[data-state="busy"] { color: var(--accent); border-color: rgba(124, 140, 255, 0.32); }
.pill[data-state="busy"] .pill-dot { background: var(--accent); animation: pulse 1.4s ease-in-out infinite; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

/* ---------- hero ---------- */

main { position: relative; z-index: 1; max-width: 1180px; margin: 0 auto; padding: 26px 28px 60px; }

.hero { padding: 34px 0 30px; border-bottom: 1px solid var(--line); }
.eyebrow {
  margin: 0 0 18px;
  font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.2em;
  color: var(--accent);
}
.hero h1 {
  margin: 0 0 20px;
  font-size: clamp(2.35rem, 5vw, 3.9rem);
  line-height: 0.99;
  letter-spacing: -0.038em;
  font-weight: 600;
}
.hero h1 .dim { color: var(--muted-dim); }
.lede { margin: 0; max-width: 60ch; color: var(--muted); font-size: 1.01rem; }

.specs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; margin: 32px 0 0; }
.specs div { border-left: 1px solid var(--line); padding-left: 14px; }
.specs dt { font-family: var(--mono); font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.16em; color: var(--muted-dim); margin-bottom: 3px; }
.specs dd { margin: 0; font-size: 13px; letter-spacing: -0.01em; }

/* ---------- workspace ---------- */

.workspace { display: grid; grid-template-columns: 1.02fr 1fr; gap: 18px; margin-top: 30px; }
.panel {
  background: linear-gradient(180deg, var(--panel), var(--bg-soft));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; }
.panel-head h2 { margin: 0; font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.18em; color: var(--muted); }
.panel-actions { display: inline-flex; gap: 12px; }

.text-btn {
  appearance: none; border: 0; background: none; padding: 0; cursor: pointer;
  font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--muted-dim); transition: color 0.15s ease;
}
.text-btn:hover { color: var(--accent); }

/* dropzone */
.dropzone {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.012);
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.18s ease, background 0.18s ease;
}
.dropzone:hover, .dropzone.is-drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone.has-image { border-style: solid; border-color: var(--line); background: #08090c; }
.dropzone img { width: 100%; height: 100%; object-fit: contain; display: block; }
.dropzone-empty { text-align: center; color: var(--muted); padding: 22px; }
.dropzone-empty svg { color: var(--muted-dim); margin-bottom: 8px; }
.dropzone-empty p { margin: 2px 0; font-size: 13.5px; }
.dropzone-empty strong { color: var(--ink); font-weight: 600; }

/* fields */
.field { display: flex; flex-direction: column; gap: 7px; }
.field-head { display: flex; align-items: baseline; justify-content: space-between; }
.field label { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.14em; color: var(--muted); }
.field output { font-family: var(--mono); font-size: 11px; color: var(--ink); }
.hint { margin: 0; font-size: 11.5px; color: var(--muted-dim); }

textarea {
  width: 100%; resize: vertical; min-height: 84px;
  background: #0c0e13; color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 12px; font-family: var(--sans); font-size: 13.5px; line-height: 1.5;
  transition: border-color 0.15s ease;
}
textarea:focus { outline: none; border-color: rgba(124, 140, 255, 0.55); }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 22px; background: transparent; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track { height: 3px; border-radius: 3px; background: rgba(255, 255, 255, 0.12); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 13px; height: 13px; margin-top: -5px;
  border-radius: 50%; background: var(--ink); border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px var(--line-strong);
}
input[type="range"]::-moz-range-track { height: 3px; border-radius: 3px; background: rgba(255, 255, 255, 0.12); }
input[type="range"]::-moz-range-thumb { width: 13px; height: 13px; border-radius: 50%; background: var(--ink); border: 2px solid var(--bg); }

.check { display: inline-flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--muted); }
.check input { accent-color: var(--accent); }

.advanced { border-top: 1px solid var(--line); padding-top: 12px; }
.advanced summary {
  cursor: pointer; list-style: none;
  font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.14em; color: var(--muted);
}
.advanced summary::-webkit-details-marker { display: none; }
.advanced summary::before { content: "+ "; color: var(--muted-dim); }
.advanced[open] summary::before { content: "– "; }
.advanced-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 14px; }

/* run button */
.run {
  margin-top: auto;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 13px 18px;
  border: 0; border-radius: 10px;
  background: linear-gradient(180deg, #8f9dff, #6f80f5);
  color: #0a0b0e; font-family: var(--sans); font-size: 14px; font-weight: 600; letter-spacing: -0.01em;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.18s ease, filter 0.18s ease;
  box-shadow: 0 10px 26px -14px rgba(124, 140, 255, 0.9);
}
.run:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 16px 32px -16px rgba(124, 140, 255, 1); }
.run:active:not(:disabled) { transform: translateY(0); }
.run:disabled { cursor: progress; filter: saturate(0.55) brightness(0.8); }
.run-timer { font-family: var(--mono); font-size: 11px; font-weight: 500; opacity: 0.75; }

/* ---------- stage ---------- */

.stage { position: relative; min-height: 320px; flex: 1; display: flex; flex-direction: column; }
.stage-empty {
  margin: auto; text-align: center; color: var(--muted);
  border: 1px dashed var(--line); border-radius: 12px; padding: 34px 20px; width: 100%;
}
.stage-empty p { margin: 3px 0; font-size: 13px; }

.stage-busy { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 4px; background: rgba(10, 11, 14, 0.86); border-radius: 12px; text-align: center; }
.stage-busy p { margin: 0; font-size: 13px; }
.spinner {
  width: 26px; height: 26px; margin-bottom: 12px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.12); border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.compare { position: relative; width: 100%; aspect-ratio: 4 / 3; border-radius: 12px; overflow: hidden; background: #08090c; border: 1px solid var(--line); touch-action: none; }
.compare img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.cmp-before-wrap { position: absolute; inset: 0; clip-path: inset(0 calc(100% - var(--pos, 50%)) 0 0); }
.cmp-divider { position: absolute; top: 0; bottom: 0; left: var(--pos, 50%); width: 1px; background: rgba(255, 255, 255, 0.65); pointer-events: none; }
.cmp-divider .grip {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(10, 11, 14, 0.82); border: 1px solid rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(6px);
}
.cmp-divider .grip::before, .cmp-divider .grip::after {
  content: ""; position: absolute; top: 50%; width: 0; height: 0; border: 4px solid transparent;
}
.cmp-divider .grip::before { left: 6px; transform: translateY(-50%); border-right-color: rgba(255, 255, 255, 0.75); }
.cmp-divider .grip::after { right: 6px; transform: translateY(-50%); border-left-color: rgba(255, 255, 255, 0.75); }
.cmp-range { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: ew-resize; }
.tag {
  position: absolute; bottom: 10px;
  font-family: var(--mono); font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.14em;
  color: rgba(255, 255, 255, 0.78); background: rgba(10, 11, 14, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 999px; padding: 3px 8px;
  backdrop-filter: blur(6px); pointer-events: none;
}
.tag-left { left: 10px; }
.tag-right { right: 10px; }

.log {
  margin-top: 4px; padding: 10px 12px; border-radius: 10px;
  background: #0a0c11; border: 1px solid var(--line);
  font-family: var(--mono); font-size: 11px; line-height: 1.6; color: var(--muted);
  max-height: 96px; overflow-y: auto;
}
.log-line { margin: 0; }
.log-line .t { color: var(--muted-dim); margin-right: 8px; }
.log-line.is-error { color: var(--bad); }
.log-line.is-ok { color: var(--good); }

/* ---------- examples & notes ---------- */

.examples { margin-top: 42px; }
.examples-head { display: flex; align-items: baseline; justify-content: space-between; gap: 18px; flex-wrap: wrap; }
.examples h2, .notes h2 { margin: 0 0 4px; font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.18em; color: var(--muted); }
.example-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-top: 14px; }
.example {
  appearance: none; text-align: left; cursor: pointer; padding: 0; overflow: hidden;
  border: 1px solid var(--line); border-radius: 12px; background: var(--panel);
  transition: border-color 0.16s ease, transform 0.16s ease;
}
.example:hover { border-color: rgba(124, 140, 255, 0.55); transform: translateY(-2px); }
.example img { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; }
.example span { display: block; padding: 10px 12px; font-size: 12px; color: var(--muted); }
.example span strong { color: var(--ink); font-weight: 500; }

.notes { margin-top: 48px; padding-top: 26px; border-top: 1px solid var(--line); }
.notes-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; margin-top: 14px; }
.notes-grid p { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.65; }
.notes-grid strong { color: var(--ink); font-weight: 600; }

footer {
  position: relative; z-index: 1;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  max-width: 1180px; margin: 0 auto; padding: 22px 28px 40px;
  border-top: 1px solid var(--line);
  font-size: 11.5px; color: var(--muted-dim);
}

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .specs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .notes-grid { grid-template-columns: 1fr; }
  .advanced-grid { grid-template-columns: 1fr; }
  main { padding: 18px 18px 40px; }
  .topbar { padding: 16px 18px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
