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

:root {
  --bg:        #0d0f12;
  --surface:   #161b22;
  --border:    #30363d;
  --text:      #e6edf3;
  --muted:     #8b949e;
  --accent:    #58a6ff;
  --live:      #3fb950;
  --reconnect: #d29922;
  --offline:   #f85149;
  --radius:    8px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 16px 48px;
}

/* ── Header ────────────────────────────────────────────────── */
header {
  padding: 24px 0 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background 0.3s, box-shadow 0.3s;
}

.dot--active {
  background: var(--live);
  box-shadow: 0 0 8px var(--live);
}

.dot--inactive {
  background: var(--muted);
  box-shadow: none;
}

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 16px;
}

.card h2 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 16px;
}

/* ── Form ──────────────────────────────────────────────────── */
.form-row {
  display: flex;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  margin-bottom: 14px;
}

.field--sm {
  max-width: 110px;
  flex: none;
}

label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

input[type="text"],
input[type="password"],
select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 8px 12px;
  font-size: 14px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
  appearance: none;
}

input[type="text"]:focus,
input[type="password"]:focus,
select:focus {
  border-color: var(--accent);
}

input::placeholder {
  color: #484f58;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b949e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
  cursor: pointer;
}

/* ── Toggle ────────────────────────────────────────────────── */
.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.toggle-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.toggle-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 24px;
  cursor: pointer;
  transition: background 0.2s;
}

.slider::before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: var(--muted);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}

.toggle input:checked + .slider {
  background: #1f4620;
}

.toggle input:checked + .slider::before {
  transform: translateX(20px);
  background: var(--live);
}

/* ── Scene mapping ─────────────────────────────────────────── */
.hint {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 16px;
}

.scene-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.scene-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.state-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 3px 10px;
  border-radius: 4px;
  min-width: 90px;
  text-align: center;
  flex-shrink: 0;
}

.state-live      { background: #122116; color: var(--live);      border: 1px solid #1f4620; }
.state-reconnect { background: #1e1908; color: var(--reconnect); border: 1px solid #3a2d00; }
.state-offline   { background: #200d0d; color: var(--offline);   border: 1px solid #3d1212; }

.scene-row select {
  flex: 1;
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s, background 0.15s;
}

.btn:hover { opacity: 0.85; }
.btn:active { opacity: 0.7; }

.btn--primary {
  background: var(--accent);
  color: #0d1117;
}

.btn--secondary {
  background: var(--border);
  color: var(--text);
  margin-top: 4px;
}

/* ── Actions row ────────────────────────────────────────────── */
.actions {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 4px 0;
}

/* ── Status messages ────────────────────────────────────────── */
.status-msg {
  font-size: 13px;
  color: var(--muted);
  margin-top: 10px;
  display: block;
}

.status-ok    { color: var(--live); }
.status-error { color: var(--offline); }

/* ── Status card ────────────────────────────────────────────── */
.card--status {
  border-color: #21262d;
}

.status-grid {
  display: flex;
  gap: 32px;
  margin-bottom: 20px;
}

.status-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.status-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.bitrate-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  transition: color 0.3s;
}

.bitrate-ok   { color: var(--live); }
.bitrate-warn { color: var(--reconnect); }

/* ── Stream action buttons ──────────────────────────────────── */
.stream-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn--start {
  background: #122116;
  color: var(--live);
  border: 1px solid #1f4620;
}

.btn--start:hover {
  background: #1a3020;
  opacity: 1;
}

.btn--stop {
  background: #200d0d;
  color: var(--offline);
  border: 1px solid #3d1212;
}

.btn--stop:hover {
  background: #2d1010;
  opacity: 1;
}


/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 480px) {
  .form-row { flex-direction: column; }
  .field--sm { max-width: 100%; }
  .status-grid { gap: 16px; flex-wrap: wrap; }
}
