:root {
  color-scheme: dark;
  --bg: #0a0d12;
  --panel: #111720;
  --line: #293241;
  --muted: #8c98a8;
  --text: #edf3f8;
  --accent: #ffd166;
  --accent2: #68a7ff;
  --danger: #ff6b78;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 80% -10%, rgba(42, 104, 90, .24), transparent 34rem),
    radial-gradient(circle at 5% 40%, rgba(47, 73, 123, .16), transparent 34rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, Pretendard, "Noto Sans KR", system-ui, sans-serif;
}

header, main { width: min(1480px, calc(100% - 40px)); margin-inline: auto; }

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 34px 0 22px;
}

h1 { margin: 4px 0 0; font-size: clamp(1.5rem, 3vw, 2.35rem); letter-spacing: -.04em; }
.eyebrow { margin: 0; color: var(--accent); font: 700 .7rem/1.2 ui-monospace, monospace; letter-spacing: .18em; }

.badge { display: flex; gap: 9px; align-items: center; border: 1px solid var(--line); border-radius: 999px; padding: 9px 13px; color: var(--muted); font-size: .82rem; }
.badge span { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 12px var(--danger); }
.badge.online span { background: var(--accent); box-shadow: 0 0 12px var(--accent); }

main { display: grid; gap: 16px; padding-bottom: 44px; }
.panel { background: color-mix(in srgb, var(--panel) 94%, transparent); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 15px 50px rgba(0,0,0,.16); }

.control-bar { display: flex; flex-wrap: wrap; gap: 18px; align-items: end; padding: 16px 18px; }
.control-bar label { display: grid; gap: 7px; min-width: 130px; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; }
.control-bar label:has(input[type="range"]) { grid-template-columns: 1fr auto; }
.control-bar label:has(input[type="range"]) input { grid-column: 1 / -1; }
select, button { border: 1px solid var(--line); border-radius: 8px; background: #0c1118; color: var(--text); padding: 10px 12px; }
button { cursor: pointer; font-weight: 700; }
button.primary { background: var(--accent); border-color: var(--accent); color: #052116; }
button:disabled { opacity: .42; cursor: default; }
.actions { display: flex; gap: 8px; margin-left: auto; }
output { color: var(--text); }

.viewer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.viewer-card { min-width: 0; overflow: hidden; }
.card-title { min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 11px 14px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: .78rem; }
.card-title > div { display: flex; align-items: center; gap: 10px; color: var(--text); }
.step { display: inline-grid; place-items: center; width: 27px; height: 27px; border: 1px solid #4a586b; border-radius: 7px; font: 700 .75rem ui-monospace, monospace; }
.step.accent { border-color: var(--accent); color: var(--accent); }

.media-stage { position: relative; display: grid; place-items: center; min-height: 300px; aspect-ratio: 16 / 10; overflow: hidden; background: #030507; }
video, #resultCanvas { display: block; width: 100%; height: 100%; object-fit: contain; }
.placeholder { position: absolute; inset: 0; display: grid; place-items: center; color: #667383; background: repeating-linear-gradient(135deg, transparent 0 12px, rgba(255,255,255,.012) 12px 24px); }
.overlay-controls { display: flex; flex-wrap: wrap; gap: 18px; padding: 12px 14px; border-top: 1px solid var(--line); color: var(--muted); font: .75rem ui-monospace, monospace; }
.overlay-controls label { display: flex; gap: 6px; align-items: center; }

.metrics { display: grid; grid-template-columns: repeat(8, 1fr); overflow: hidden; }
.metrics div { min-width: 0; display: grid; gap: 5px; padding: 15px 17px; border-right: 1px solid var(--line); }
.metrics div:last-child { border-right: 0; }
.metrics span { color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .07em; }
.metrics strong { font: 700 1.05rem ui-monospace, monospace; overflow: hidden; text-overflow: ellipsis; }

.diagnostics { min-width: 0; overflow: hidden; }
pre { max-height: 320px; margin: 0; padding: 18px; overflow: auto; color: #b9c8d7; font: .76rem/1.55 ui-monospace, SFMono-Regular, Consolas, monospace; }

@media (max-width: 960px) {
  .viewer-grid { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: repeat(4, 1fr); }
  .metrics div:nth-child(4) { border-right: 0; }
  .metrics div:nth-child(-n+4) { border-bottom: 1px solid var(--line); }
}

@media (max-width: 620px) {
  header, main { width: min(100% - 20px, 1480px); }
  header { align-items: flex-start; gap: 16px; }
  .badge { font-size: 0; padding: 10px; }
  .actions { width: 100%; margin-left: 0; }
  .actions button { flex: 1; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .metrics div { border-bottom: 1px solid var(--line); }
  .metrics div:nth-child(2n) { border-right: 0; }
  .media-stage { min-height: 220px; }
}
