:root {
  --bg: #0f1117;
  --surface: #181b24;
  --surface-2: #20242f;
  --border: #2a2f3d;
  --text: #e7e9ee;
  --muted: #8b91a1;
  --accent: #5b8cff;
  --accent-hover: #4a7bf0;
  --green: #2fbf71;
  --yellow: #e0b341;
  --orange: #e08a41;
  --red: #e0584b;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  background: var(--accent);
  color: #fff;
  transition: background 0.15s;
}
button:hover { background: var(--accent-hover); }
button.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
button.secondary:hover { background: var(--border); }
button.danger { background: transparent; color: var(--red); border: 1px solid var(--border); }
button.danger:hover { background: rgba(224, 88, 75, 0.12); }
button.small { padding: 5px 10px; font-size: 13px; }

input {
  font: inherit;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 12px;
  width: 100%;
}
input:focus { outline: none; border-color: var(--accent); }

.muted { color: var(--muted); }
.error { color: var(--red); }

/* ---------- Login ---------- */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-card h1 { margin: 0; font-size: 22px; }
.login-card p { margin: 0; }

/* ---------- Layout ---------- */
header.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
header.topbar h1 { font-size: 18px; margin: 0; }
main {
  max-width: 880px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.card h2 { margin: 0 0 14px; font-size: 15px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }

.field-row { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.field-row label { width: 110px; color: var(--muted); flex-shrink: 0; }
.field-row .value {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  flex: 1;
  overflow-x: auto;
  white-space: nowrap;
}

/* ---------- Status badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  white-space: nowrap;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.live, .dot.active { background: var(--green); box-shadow: 0 0 8px var(--green); }
.dot.connecting { background: var(--yellow); }
.dot.reconnecting { background: var(--orange); }
.dot.failed, .dot.error { background: var(--red); }

/* ---------- Destinations ---------- */
.dest-list { display: flex; flex-direction: column; gap: 10px; }
.dest {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.dest .info { flex: 1; min-width: 0; }
.dest .name { font-weight: 600; }
.dest .url { color: var(--muted); font-size: 13px; font-family: ui-monospace, monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dest .err { color: var(--red); font-size: 12px; margin-top: 2px; }
.dest .actions { display: flex; gap: 8px; align-items: center; }

/* toggle switch */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.switch input { display: none; }
.slider {
  position: absolute; inset: 0; border-radius: 999px;
  background: var(--border); transition: 0.2s;
}
.slider::before {
  content: ""; position: absolute; height: 18px; width: 18px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: 0.2s;
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(20px); }

.add-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.add-form .full { grid-column: 1 / -1; }
.add-form .row { display: flex; gap: 10px; grid-column: 1 / -1; }

.hint { font-size: 13px; color: var(--muted); margin-top: 8px; }
.copy-btn { margin-left: 8px; }
.empty { color: var(--muted); padding: 16px; text-align: center; }

/* flash message */
.flash {
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.flash.ok { border-color: var(--green); color: #b8f0d0; background: rgba(47, 191, 113, 0.1); }
.flash.err { border-color: var(--red); color: #f3c3bd; background: rgba(224, 88, 75, 0.1); }

/* card header with action button */
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-head h2 { margin: 0; }

/* Twitch button */
.twitch-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #9146ff;
}
.twitch-btn:hover { background: #7d33e8; }

/* provider tag on a destination */
.tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 5px;
  margin-left: 8px;
  vertical-align: middle;
}
.tag.twitch { background: #9146ff; color: #fff; }

/* topbar right cluster */
.topbar-right { display: flex; align-items: center; gap: 12px; }

/* live control card */
.live-card { padding: 22px 24px; }
.live-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.live-row h2 { margin: 0 0 6px; }
.live-row p { margin: 0; max-width: 540px; }
.live-btn {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 14px 28px;
  border-radius: 10px;
  white-space: nowrap;
  flex-shrink: 0;
}
.live-btn.go { background: var(--green); }
.live-btn.go:hover { background: #28a862; }
.live-btn.stop { background: var(--red); }
.live-btn.stop:hover { background: #c94739; }
.live-btn:disabled { opacity: 0.6; cursor: default; }
