:root {
  --bg: #0b0e11;
  --bg-raise: #12161b;
  --bg-raise-2: #171c22;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #e8ecef;
  --text-dim: #8a949d;
  --text-faint: #5a636b;
  --live: #2fe07b;
  --live-contrast: #062b16;
  --live-dim: rgba(47, 224, 123, 0.12);
  --glow: rgba(47, 224, 123, 0.05);
  --glow2: rgba(47, 224, 123, 0.03);
  --warn: #f5a623;
  --warn-dim: rgba(245, 166, 35, 0.12);
  --err: #f0564a;
  --err-dim: rgba(240, 86, 74, 0.12);
  --font-d: "Archivo", sans-serif;
  --font-m: "IBM Plex Mono", monospace;
}

:root[data-theme="light"] {
  --bg: #f1f2ee;
  --bg-raise: #ffffff;
  --bg-raise-2: #e7e9e3;
  --line: rgba(15, 25, 20, 0.09);
  --line-strong: rgba(15, 25, 20, 0.18);
  --text: #171b1e;
  --text-dim: #5b646b;
  --text-faint: #98a0a6;
  --live: #0f9d63;
  --live-contrast: #ffffff;
  --live-dim: rgba(15, 157, 99, 0.1);
  --glow: rgba(15, 157, 99, 0.06);
  --glow2: rgba(15, 157, 99, 0.04);
  --warn: #ad6c00;
  --warn-dim: rgba(173, 108, 0, 0.1);
  --err: #c8372c;
  --err-dim: rgba(200, 55, 44, 0.09);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  background-image:
    radial-gradient(1200px 600px at 70% -10%, var(--glow), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, var(--glow2), transparent 55%);
  color: var(--text);
  font-family: var(--font-d);
  font-size: 15px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background 0.25s, color 0.25s;
}

.hidden { display: none !important; }
.mono { font-family: var(--font-m); }

.wordmark { display: flex; align-items: center; gap: 10px; }
.wordmark h1 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.12em;
  font-stretch: 110%;
}
.wordmark h1 em {
  font-style: normal;
  font-weight: 300;
  color: var(--live);
  letter-spacing: 0.18em;
}
.wordmark.small h1 { font-size: 15px; }
.wordmark-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 12px var(--live-dim);
  animation: breathe 3s ease-in-out infinite;
}
@keyframes breathe { 50% { opacity: 0.45; box-shadow: 0 0 4px var(--live-dim); } }

.login-wrap {
  min-height: 100vh;
  display: grid; place-items: center;
  padding: 24px;
}
.login-card {
  width: min(400px, 100%);
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 40px 36px;
  animation: rise 0.5s cubic-bezier(0.2, 0.9, 0.3, 1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
.login-sub {
  color: var(--text-dim);
  font-size: 13px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  margin: 10px 0 34px;
}
.login-card label {
  display: block;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.login-card input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font-m);
  font-size: 16px;
  padding: 12px 14px;
  margin-bottom: 18px;
  outline: none;
  transition: border-color 0.15s;
}
.login-card input:focus { border-color: var(--live); }
.login-error, .dialog-error { color: var(--err); font-size: 13px; margin-top: 12px; min-height: 1em; }
.login-hint { color: var(--live); font-size: 13px; margin-top: 12px; min-height: 1em; }
#pass-fallback { margin-top: 18px; }
#pass-fallback summary {
  color: var(--text-faint);
  font-size: 12px;
  cursor: pointer;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}
#pass-fallback[open] summary { color: var(--text-dim); }
#code-step input {
  font-size: 26px;
  letter-spacing: 8px;
  text-align: center;
  font-family: var(--font-m);
}

.btn {
  font-family: var(--font-d);
  font-weight: 600;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--text);
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 13px;
  cursor: pointer;
  transition: transform 0.1s, background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--bg-raise-2); border-color: var(--text-faint); }
.btn:active { transform: scale(0.97); }
.btn-go {
  width: 100%;
  background: var(--live);
  border-color: var(--live);
  color: var(--live-contrast);
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 12px 16px;
}
.btn-go:hover { filter: brightness(1.08); }
.btn-ghost { border-color: transparent; color: var(--text-dim); }
.btn-mini {
  padding: 5px 10px;
  font-size: 12px;
  color: var(--text-dim);
  text-transform: lowercase;
  letter-spacing: 0.04em;
}
.btn-warn:hover { border-color: var(--warn); color: var(--warn); }
.btn-add { border-color: var(--live); color: var(--live); font-weight: 700; }
.btn-add:hover { background: var(--live-dim); }

.panel { max-width: 1180px; margin: 0 auto; padding: 20px clamp(14px, 3vw, 32px) 60px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 0 22px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 26px;
}
.topbar-status { display: flex; align-items: center; gap: 14px; }
.onair {
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.22em;
  padding: 7px 16px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  color: var(--text-faint);
  transition: all 0.3s;
}
.onair-live {
  color: var(--live-contrast);
  background: var(--live);
  border-color: var(--live);
  box-shadow: 0 0 24px var(--live-dim);
  animation: pulse-live 2s ease-in-out infinite;
}
@keyframes pulse-live { 50% { box-shadow: 0 0 8px var(--glow); } }
.uptime { color: var(--text-dim); font-size: 14px; }
.topbar-side { display: flex; align-items: center; gap: 6px; }
.theme-btn { font-size: 18px; line-height: 1; padding: 6px 10px; }
.theme-btn-float { position: absolute; top: 18px; right: 18px; }
.login-wrap { position: relative; }

.grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 18px;
  align-items: start;
}
.card-log { grid-column: 1 / -1; }
@media (max-width: 860px) { .grid { grid-template-columns: 1fr; } }

.card {
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px 22px;
  animation: rise 0.5s cubic-bezier(0.2, 0.9, 0.3, 1) both;
}
.card-dests { animation-delay: 0.06s; }
.card-log { animation-delay: 0.12s; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.card-head h2 {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.head-actions { display: flex; gap: 8px; }

.led {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--text-faint);
  transition: all 0.3s;
}
.led-live { background: var(--live); box-shadow: 0 0 10px var(--live-dim); animation: breathe 2s infinite; }

.telemetry { display: grid; gap: 8px; margin-bottom: 20px; }
.telemetry > div {
  display: flex; justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: 7px;
  font-size: 13px;
}
.t-label { color: var(--text-faint); }
.t-value { color: var(--text); font-weight: 500; }

.ingest { border-top: 1px solid var(--line); padding-top: 16px; }
.ingest-label {
  font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--text-faint); margin-bottom: 8px;
}
.ingest-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.ingest-row code {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.dest-list { display: grid; gap: 12px; }
.dest {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--line);
  border-left: 3px solid var(--text-faint);
  border-radius: 10px;
  padding: 14px 16px;
  transition: border-color 0.3s;
}
.dest[data-status="LIVE"] { border-left-color: var(--live); }
.dest[data-status="STARTING"], .dest[data-status="RECONNECTING"] { border-left-color: var(--warn); }
.dest[data-status="FAILED"] { border-left-color: var(--err); }

.dest-mark {
  width: 42px; height: 42px;
  border-radius: 9px;
  display: grid; place-items: center;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.02em;
}
.mark-YOUTUBE { background: rgba(255, 0, 0, 0.14); color: #ff5c5c; }
.mark-FACEBOOK { background: rgba(24, 119, 242, 0.16); color: #6ea8ff; }
.mark-TWITCH { background: rgba(145, 70, 255, 0.16); color: #b88cff; }
.mark-CUSTOM { background: rgba(255, 255, 255, 0.08); color: var(--text-dim); }

.dest-info h3 { font-size: 15px; font-weight: 700; }
.dest-meta { font-size: 12px; color: var(--text-faint); margin-top: 3px; }
.dest-err {
  font-size: 11px; color: var(--err); margin-top: 4px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 420px;
}

.dest-side { display: flex; align-items: center; gap: 10px; }
.badge {
  font-family: var(--font-m);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-raise-2);
  color: var(--text-faint);
}
.badge-LIVE { background: var(--live-dim); color: var(--live); }
.badge-STARTING, .badge-RECONNECTING { background: var(--warn-dim); color: var(--warn); }
.badge-FAILED { background: var(--err-dim); color: var(--err); }
.badge-STOPPING { background: var(--warn-dim); color: var(--warn); }

.empty { color: var(--text-faint); font-size: 14px; padding: 18px 0; text-align: center; }

.event-log {
  max-height: 260px;
  overflow-y: auto;
  display: flex; flex-direction: column-reverse;
  gap: 6px;
  font-size: 12px;
}
.ev { display: flex; gap: 12px; padding: 4px 8px; border-radius: 5px; }
.ev:hover { background: var(--bg); }
.ev-ts { color: var(--text-faint); flex-shrink: 0; }
.ev-INFO { color: var(--text-dim); }
.ev-WARNING { color: var(--warn); }
.ev-ERROR { color: var(--err); }

dialog {
  background: var(--bg-raise);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  color: var(--text);
  padding: 30px 32px;
  width: min(440px, 92vw);
  margin: auto;
}
dialog::backdrop { background: rgba(4, 6, 8, 0.75); backdrop-filter: blur(3px); }
dialog h3 { font-size: 18px; font-weight: 800; margin-bottom: 20px; letter-spacing: 0.02em; }
dialog label {
  display: block;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 14px;
}
dialog input[type="text"], dialog input[type="password"], dialog select {
  width: 100%;
  margin-top: 6px;
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font-m);
  font-size: 14px;
  padding: 10px 12px;
  outline: none;
}
dialog input:focus, dialog select:focus { border-color: var(--live); }
dialog .check {
  display: flex; align-items: center; gap: 10px;
  text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--text);
}
dialog .check input { accent-color: var(--live); width: 16px; height: 16px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.dialog-actions .btn-go { width: auto; }

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: var(--bg-raise-2); border-radius: 4px; }
