:root {
  --bg: #0e0f13;
  --panel: #171922;
  --line: #262a38;
  --fg: #e7e9f0;
  --dim: #8a90a6;
  --accent: #6ee7ff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

header {
  padding: 18px 24px 6px;
}
h1 { margin: 0; font-size: 22px; letter-spacing: 0.3px; }
h1 .sub { color: var(--dim); font-weight: 400; }
.tagline { margin: 4px 0 0; color: var(--dim); font-size: 13px; }

main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 20px;
  padding: 16px 24px 40px;
  align-items: start;
}
@media (max-width: 880px) { main { grid-template-columns: 1fr; } }

/* Keep the video pinned in view while the controls sidebar scrolls past it. */
.stage {
  min-width: 0;
  position: sticky;
  top: 16px;
  align-self: start;
}

#out {
  /* Fill the column width, but cap so the 4:3 frame fits the viewport height
     without scrolling (height = 0.75 × width, so 96vh wide → 72vh tall). */
  width: min(100%, 96vh);
  height: auto;
  margin: 0 auto;
  background: #000;
  border: 1px solid var(--line);
  border-radius: 10px;
  display: block;
  /* SMOOTH upscale, not nearest-neighbour: tape is a soft analog signal with no
     hard pixel grid, so the low-fi look must come from the signal's limited
     bandwidth (soft edges) — not from fabricated blocky pixels on the way to screen. */
  image-rendering: auto;
}

.readout {
  display: flex;
  gap: 18px;
  align-items: center;
  margin-top: 8px;
  font-size: 13px;
  color: var(--dim);
}
.readout strong { color: var(--accent); font-variant-numeric: tabular-nums; }

#vid, .hidden { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; left: -9999px; }

.panel { display: flex; flex-direction: column; gap: 16px; }
.group {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
}
.group h2 { margin: 0 0 10px; font-size: 14px; text-transform: uppercase; letter-spacing: 1px; color: var(--dim); }
.group h2 small { text-transform: none; letter-spacing: 0; color: var(--dim); font-weight: 400; }

.row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.row.controls { justify-content: space-between; }
.row small { color: var(--dim); font-size: 11px; }

button {
  background: #222637; color: var(--fg); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 12px; cursor: pointer; font-size: 13px;
}
button:hover { border-color: var(--accent); }
button.active { background: var(--accent); color: #06222a; border-color: var(--accent); font-weight: 600; }

label.file { display: inline-block; cursor: pointer; color: var(--accent); font-size: 13px; }
label.file input { display: none; }

input[type="text"] {
  flex: 1; min-width: 120px; background: #0c0e15; color: var(--fg);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font-size: 13px;
}
code { background: #0c0e15; padding: 1px 5px; border-radius: 4px; color: var(--accent); font-size: 11px; }

select {
  background: #0c0e15; color: var(--fg);
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: 13px;
}

.cliprow { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--dim); flex: none; }
#clip { flex: 0 0 96px; width: 96px; }

.toggle { display: block; margin-bottom: 12px; font-size: 13px; color: var(--dim); }

/* preset (look) picker */
.presetnav { flex-wrap: nowrap; align-items: flex-start; }
.presetnav button { flex: none; padding: 7px 10px; }
.presetname { flex: 1; min-width: 0; text-align: center; }
.presetname strong { display: block; font-size: 14px; }
.presetname strong.custom::after { content: " *"; color: var(--dim); }
.presetname small { display: block; color: var(--dim); font-size: 11px; line-height: 1.35; margin-top: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chips button { padding: 4px 9px; font-size: 12px; border-radius: 999px; }

.slider { margin-bottom: 14px; }
.slider label { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.slider output { color: var(--accent); font-variant-numeric: tabular-nums; }
.slider input[type="range"] { width: 100%; accent-color: var(--accent); }
.slider small { color: var(--dim); font-size: 11px; }

.hint { color: var(--dim); font-size: 12px; border-top: 1px solid var(--line); padding-top: 10px; margin: 6px 0 0; }

.telemetry { color: var(--accent); font-variant-numeric: tabular-nums; }

.cleanlink { color: var(--accent); font-size: 12px; text-decoration: none; white-space: nowrap; }
.cleanlink:hover { text-decoration: underline; }

/* Clean output (?clean=1): just the filtered canvas, full-frame, no chrome.
   This is what OBS Browser Source / a screen recorder should point at. The
   pixelated upscale keeps the chunky low-res camcorder look when it's blown up. */
body.clean { background: #000; overflow: hidden; }
body.clean header,
body.clean .panel,
body.clean .readout { display: none; }
body.clean main { display: block; padding: 0; }
body.clean .stage { position: static; }
body.clean #out {
  width: 100vw; height: 100vh; object-fit: contain;
  border: 0; border-radius: 0; image-rendering: auto;
}

/* auto-generated per-stage control blocks */
.fxstage { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.fxstage:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.fxhead { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; margin-bottom: 10px; cursor: pointer; }
.fxnone { color: var(--dim); font-size: 12px; font-style: italic; margin-bottom: 6px; }

.srcstatus {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--line);
  background: #0c0e15;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.45;
  word-break: break-word;
}
.srcstatus::before {
  content: "";
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--dim); flex: none;
  margin-top: 5px;
}
.srcstatus.idle    { color: var(--dim); }
.srcstatus.idle::before { background: var(--dim); }
.srcstatus.loading { color: #ffd479; border-color: #5a4a1f; }
.srcstatus.loading::before { background: #ffd479; animation: pulse 1s ease-in-out infinite; }
.srcstatus.ok      { color: #7ee787; border-color: #2c5132; }
.srcstatus.ok::before { background: #7ee787; }
.srcstatus.error   { color: #ff8a8a; border-color: #5a2424; background: #1c1113; }
.srcstatus.error::before { background: #ff8a8a; }

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