:root {
  color-scheme: dark;
  --bg: #0c0e12;
  --panel: #151821;
  --panel-2: #1c2030;
  --border: #2a2f42;
  --text: #e6e8ef;
  --muted: #8a93a8;
  --accent: #6ea8ff;
  --pos: #4ade80;
  --neg: #f87171;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: ui-sans-serif, system-ui, "Segoe UI", "Apple SD Gothic Neo", "Pretendard", sans-serif; }

.topbar { padding: 1rem 1.5rem; border-bottom: 1px solid var(--border); }
.topbar h1 { margin: 0; font-size: 1.25rem; letter-spacing: -0.01em; }
.topbar .sub { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.85rem; }

main { padding: 1.25rem; display: grid; gap: 1.25rem; max-width: 1280px; margin: 0 auto; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem;
}

.panel h2 { margin: 0 0 0.5rem; font-size: 1rem; color: var(--muted); font-weight: 600; }

.row { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: center; margin-bottom: 0.75rem; }
.row.controls { padding: 0.5rem 0; border-top: 1px dashed var(--border); border-bottom: 1px dashed var(--border); }

.file-pick { display: inline-flex; align-items: center; gap: 0.5rem; background: var(--panel-2); border: 1px solid var(--border); padding: 0.5rem 0.75rem; border-radius: 10px; cursor: pointer; }
.file-pick input { display: none; }

.meta { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem; }

.stage {
  position: relative;
  display: inline-block;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #000;
}
.stage video, .stage canvas {
  display: block;
  max-width: 100%;
  height: auto;
}
.stage canvas {
  position: absolute;
  top: 0;
  left: 0;
  cursor: crosshair;
  width: 100%;
  height: 100%;
}

button {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
}
button.active { background: var(--accent); border-color: var(--accent); color: #0b0e16; font-weight: 600; }
button.ghost { background: transparent; color: var(--muted); }
button.primary { background: var(--accent); color: #0b0e16; border-color: var(--accent); font-weight: 600; padding: 0.6rem 1.1rem; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.group { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.25rem 0.5rem; background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; }
.group-label { color: var(--muted); font-size: 0.8rem; padding-right: 0.35rem; }

.field { display: flex; flex-direction: column; gap: 0.25rem; min-width: 240px; }
.field.small { min-width: 100px; }
.field label { color: var(--muted); font-size: 0.75rem; }
.field input, .field select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.5rem 0.6rem;
  border-radius: 8px;
  font-size: 0.9rem;
}

.submit { padding-top: 0.25rem; }
.status { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem; }
.status.error { color: var(--neg); }
.status.ok { color: var(--pos); }

video#result { width: 100%; max-height: 540px; background: #000; border-radius: 8px; }
pre#metrics { background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 0.6rem 0.8rem; font-size: 0.8rem; overflow-x: auto; color: var(--muted); }

.panel.config details summary { cursor: pointer; color: var(--muted); }
.panel.config input { width: 100%; max-width: 560px; margin: 0.5rem 0; }
