/* ============ shared base ============ */
:root {
  --bg: #0a0b0d;
  --panel: #14161a;
  --panel-2: #1c1f25;
  --border: #2a2e36;
  --text: #e8eaed;
  --text-dim: #9aa0a6;
  --accent: #4ade80;       /* green for "live / good" */
  --accent-dim: #2f7d4f;
  --warn: #fbbf24;         /* amber for "warning" */
  --bad: #ef4444;          /* red for "error / offline" */
  --link: #60a5fa;
  --shadow: 0 8px 28px rgba(0,0,0,0.5);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; }
a { color: var(--link); }

/* ============ status pills ============ */
.pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  font-size: 13px;
  white-space: nowrap;
}
.pill .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-dim);
  box-shadow: 0 0 0 0 currentColor;
}
.pill.good .dot { background: var(--accent); animation: pulse 2.4s infinite; }
.pill.warn .dot { background: var(--warn); }
.pill.bad  .dot { background: var(--bad); }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(74,222,128,0.4); }
  50%      { box-shadow: 0 0 0 6px rgba(74,222,128,0); }
}

/* ============ watcher (fullscreen video stage) ============ */
.stage {
  position: fixed; inset: 0;
  background: #000;
  display: grid;
  place-items: center;
  cursor: pointer;
}
#video {
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
}
.overlay {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: radial-gradient(circle at center, rgba(20,22,26,0.85), rgba(0,0,0,0.95));
  text-align: center; padding: 24px;
  pointer-events: none;
}
.overlay.hidden { display: none; }
.overlay h1 { font-size: 28px; margin: 0 0 8px; font-weight: 600; }
.overlay p  { color: var(--text-dim); margin: 4px 0; max-width: 480px; }
.overlay .spinner {
  width: 38px; height: 38px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--accent);
  animation: spin 1s linear infinite;
  margin: 0 auto 18px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.stats {
  position: fixed; top: 12px; right: 12px;
  padding: 10px 12px;
  background: rgba(10,11,13,0.78);
  border: 1px solid var(--border);
  border-radius: 8px;
  font: 12px/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color: var(--text-dim);
  backdrop-filter: blur(6px);
  display: none;
}
.stats.visible { display: block; }
.stats b { color: var(--text); font-weight: 600; }
.hint {
  position: fixed; bottom: 12px; left: 50%; transform: translateX(-50%);
  font-size: 12px; color: var(--text-dim);
  background: rgba(10,11,13,0.6);
  border: 1px solid var(--border);
  padding: 4px 10px; border-radius: 999px;
  pointer-events: none;
  opacity: 0; transition: opacity .4s;
}
.hint.visible { opacity: 1; }

/* ============ streamer (control panel layout) ============ */
.layout {
  min-height: 100%;
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 0;
}
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }

.preview-wrap {
  background: #000;
  position: relative;
  display: grid; place-items: center;
  min-height: 320px;
}
#preview {
  width: 100%; height: 100%;
  object-fit: contain; transform: scaleX(-1); /* mirror */
  background: #000;
}
.preview-empty {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  color: var(--text-dim); text-align: center; padding: 24px;
}

.panel {
  background: var(--panel);
  border-left: 1px solid var(--border);
  padding: 22px 22px 28px;
  display: flex; flex-direction: column; gap: 18px;
  overflow-y: auto;
}
@media (max-width: 900px) { .panel { border-left: 0; border-top: 1px solid var(--border); } }

.panel h1 {
  margin: 0; font-size: 18px; font-weight: 600;
  display: flex; align-items: center; gap: 10px;
}
.panel h2 {
  margin: 12px 0 4px; font-size: 11px;
  text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--text-dim); font-weight: 600;
}

.steps { display: flex; flex-direction: column; gap: 10px; }
.step {
  display: flex; gap: 10px;
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  align-items: flex-start;
}
.step .num {
  flex: 0 0 22px; height: 22px;
  border-radius: 50%; background: var(--border); color: var(--text-dim);
  display: grid; place-items: center; font-size: 12px; font-weight: 600;
}
.step.done   .num { background: var(--accent-dim); color: #042; }
.step.active .num { background: var(--accent); color: #042; }
.step .body { flex: 1; }
.step .title { font-weight: 500; }
.step .desc { color: var(--text-dim); font-size: 12px; margin-top: 2px; }

.row { display: flex; gap: 8px; align-items: center; }
.row label { flex: 1; color: var(--text-dim); font-size: 13px; }

select, input[type="text"], input[type="range"] {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  outline: none;
}
select:focus, input:focus { border-color: var(--accent); }
input[type="range"] { padding: 0; }

.btn {
  appearance: none; border: 0; cursor: pointer;
  padding: 12px 16px; border-radius: 8px;
  background: var(--accent); color: #042;
  font-weight: 600; font-size: 14px;
  transition: filter .12s, transform .12s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); }
.btn.danger    { background: var(--bad); color: #fff; }
.btn.block { width: 100%; }

.url-box {
  display: flex; gap: 6px;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px;
}
.url-box code {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding: 4px 6px; font: 12px ui-monospace, monospace; color: var(--text);
}
.url-box button {
  appearance: none; border: 0; background: var(--accent); color: #042;
  border-radius: 4px; padding: 4px 10px; font-weight: 600; cursor: pointer;
}

.metrics {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px;
  font: 12px ui-monospace, monospace;
}
.metrics .k { color: var(--text-dim); }
.metrics .v { color: var(--text); text-align: right; }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--border);
  padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow);
  font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .25s;
  z-index: 100;
}
.toast.visible { opacity: 1; }
.toast.bad { border-color: var(--bad); }

.error-box {
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.4);
  color: #fecaca;
  padding: 10px 12px; border-radius: 8px;
  font-size: 13px;
}
.error-box ul { margin: 6px 0 0 18px; padding: 0; }
.error-box li { margin: 2px 0; }
