/* CastMany dashboard. Same design language as castmany.com: Manrope for
   headings, Inter for everything else, one accent, glass panels on a near-black
   ground, rows separated by hairlines rather than boxed. Every selector the
   dashboard JS relies on is kept. */
@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@600;700;800&family=Inter:wght@400;500;600&display=swap");

:root {
  --bg: #0b0e12;
  --panel: rgba(255, 255, 255, 0.035);
  --panel-2: rgba(0, 0, 0, 0.32);
  --panel-solid: #11161d;
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.14);
  --text: #f2f4f7;
  --text-2: #b9c1cc;
  --muted: #7d8794;
  --accent: #7cc4ff;
  --accent-2: #4f9dff;
  --live: #3ddc84;
  --warn: #f5b23f;
  --bad: #ff5c6c;
  --radius: 16px;
  --radius-s: 10px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

/* The browser's own [hidden] rule has the same specificity as a class, and an
   author stylesheet always wins the tie - so any element we toggle with
   `hidden` that also carries a display rule (.login, the dialogs) would stay on
   screen. Settle it once, here. */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body {
  background-image:
    radial-gradient(60% 40% at 80% -10%, rgba(79, 157, 255, 0.12), transparent 60%),
    radial-gradient(40% 30% at 0% 0%, rgba(124, 196, 255, 0.05), transparent 60%);
  background-attachment: fixed;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12.5px;
}
.muted {
  color: var(--muted);
}
.small {
  font-size: 12px;
}
.error {
  color: var(--bad);
  margin: 8px 0 0;
}
h1,
h2 {
  margin: 0;
  font-family: Manrope, Inter, system-ui, sans-serif;
  font-weight: 800;
  letter-spacing: -0.02em;
}
h1 {
  font-size: 26px;
}
h2 {
  font-size: 16px;
}

/* ── login ─────────────────────────────────────────────────────────────── */
.login {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}
.login-card {
  width: min(380px, 100%);
  background: var(--panel-solid);
  border: 1px solid var(--line-2);
  border-radius: 20px;
  padding: 32px 30px 28px;
  display: grid;
  gap: 10px;
  box-shadow: 0 40px 80px -30px rgba(0, 0, 0, 0.8);
}
.login-card h1 {
  display: flex;
  align-items: center;
  gap: 10px;
}
.login-card h1::before {
  content: "";
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--text) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32' fill='none' stroke='%230b0e12' stroke-width='3.2' stroke-linecap='round'%3E%3Cpath d='M7 16h8M15 16l6-6M15 16l6 6M15 16h10'/%3E%3C/svg%3E") center/18px no-repeat;
}
.login-card p {
  margin: 0 0 10px;
}
.login-card .btn {
  margin-top: 6px;
  justify-content: center;
}

/* ── chrome ────────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  height: 60px;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 14, 18, 0.72);
  backdrop-filter: blur(14px) saturate(140%);
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: Manrope, Inter, sans-serif;
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -0.02em;
}
.logo::before {
  content: "";
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: var(--text) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32' fill='none' stroke='%230b0e12' stroke-width='3.2' stroke-linecap='round'%3E%3Cpath d='M7 16h8M15 16l6-6M15 16l6 6M15 16h10'/%3E%3C/svg%3E") center/15px no-repeat;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  gap: 18px;
}

.panel {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.015));
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  padding: 20px 22px 22px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.actions {
  display: flex;
  gap: 8px;
}
.stats {
  display: flex;
  gap: 0;
  color: var(--muted);
  font-size: 12.5px;
  flex-wrap: wrap;
}
.stats > span {
  padding: 0 12px;
  border-left: 1px solid var(--line);
  white-space: nowrap;
}
.stats > span:first-child {
  border-left: 0;
  padding-left: 0;
}
.stats b {
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.head-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Preview. The muxer on the ingest side only runs while this is open, so the
   panel being closed really does cost nothing. */
.preview {
  position: relative;
  margin-bottom: 16px;
  background: #000;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  overflow: hidden;
}
.preview video {
  display: block;
  width: 100%;
  max-height: 46vh;
  aspect-ratio: 16 / 9;
  background: #000;
}
.preview-msg {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 12px;
}
.preview-msg:empty {
  display: none;
}

.banner {
  background: rgba(255, 92, 108, 0.1);
  border: 1px solid rgba(255, 92, 108, 0.35);
  color: #ffb3b8;
  border-radius: var(--radius-s);
  padding: 9px 12px;
  margin-bottom: 14px;
  font-size: 13px;
}

/* ── OBS panel ─────────────────────────────────────────────────────────── */
.obs-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
}
.field.wide {
  grid-column: 1 / -1;
}
.field label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 6px;
}
.copyrow {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: 8px 8px 8px 12px;
}
.copyrow code {
  flex: 1;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: thin;
  color: var(--text-2);
}

/* ── destinations ──────────────────────────────────────────────────────── */
.targets {
  display: grid;
  gap: 0;
  margin-top: 4px;
}
.row {
  display: grid;
  grid-template-columns: 4px minmax(140px, 1.3fr) 96px 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 13px 12px;
  border-top: 1px solid var(--line);
  border-radius: var(--radius-s);
  transition: background 0.15s ease;
}
.row:first-child {
  border-top: 0;
}
.row:hover {
  background: rgba(255, 255, 255, 0.025);
}
.row .swatch {
  width: 4px;
  height: 34px;
  border-radius: 2px;
  background: var(--muted);
}
.row .name {
  font-weight: 600;
  font-size: 14.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row .sub {
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row .metrics {
  display: flex;
  gap: 14px;
  color: var(--muted);
  font-size: 12px;
  flex-wrap: wrap;
}
.row .metrics b {
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.row .rowactions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}
.row.is-failing {
  background: rgba(255, 92, 108, 0.06);
}
.rowerror {
  grid-column: 2 / -1;
  color: #ffb3b8;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  text-align: center;
  white-space: nowrap;
  justify-self: start;
  min-width: 78px;
}
.badge.live {
  color: var(--live);
  border-color: rgba(61, 220, 132, 0.3);
  background: rgba(61, 220, 132, 0.1);
}
.badge.starting,
.badge.reconnecting {
  color: var(--warn);
  border-color: rgba(245, 178, 63, 0.35);
  background: rgba(245, 178, 63, 0.1);
}
.badge.failing {
  color: var(--bad);
  border-color: rgba(255, 92, 108, 0.35);
  background: rgba(255, 92, 108, 0.12);
}
.badge.waiting {
  color: var(--accent);
  border-color: rgba(79, 157, 255, 0.3);
  background: rgba(79, 157, 255, 0.1);
}
.behind {
  color: var(--warn);
}

.pill {
  font-size: 12px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.pill.live {
  color: var(--live);
  border-color: rgba(61, 220, 132, 0.35);
  background: rgba(61, 220, 132, 0.1);
}
.conn .via {
  color: var(--muted);
  font-weight: 400;
  font-size: 12px;
  margin-left: 4px;
}
.pill.reconnecting {
  color: var(--warn);
  border-color: rgba(245, 178, 63, 0.4);
  background: rgba(245, 178, 63, 0.1);
}
.pill.live::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 0 3px rgba(61, 220, 132, 0.18);
  margin-right: 8px;
  vertical-align: middle;
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}

.empty {
  text-align: center;
  padding: 32px 16px;
  border: 1px dashed var(--line-2);
  border-radius: var(--radius-s);
  margin-top: 8px;
}
.empty p {
  margin: 0 0 6px;
}

/* ── stream info ───────────────────────────────────────────────────────── */
.info-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 12px 16px;
}
.info-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.platform-picks {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}
.platform-picks label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}
.platform-picks input {
  width: auto;
  margin: 0;
  accent-color: var(--accent-2);
}
.platform-picks label.off {
  color: var(--muted);
  cursor: not-allowed;
}
#b-results {
  margin-top: 10px;
}
#b-results .bad {
  color: #ffb3b8;
}
#b-results .good {
  color: var(--live);
}

@media (max-width: 760px) {
  .info-grid {
    grid-template-columns: 1fr;
  }
}

/* ── accounts ──────────────────────────────────────────────────────────── */
.conn {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 12px;
  border-top: 1px solid var(--line);
}
.conn:first-child {
  border-top: 0;
}
.conn .swatch {
  width: 4px;
  height: 32px;
  border-radius: 2px;
  flex: none;
}
.conn .grow {
  flex: 1;
  min-width: 0;
}
.conn .who {
  font-weight: 600;
}
.conn .sub {
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conn .sub.bad {
  color: #ffb3b8;
}
.conn select {
  width: auto;
  max-width: 210px;
  padding: 5px 8px;
  font-size: 12px;
}
.conn input.paste {
  width: 300px;
  padding: 6px 9px;
  font-size: 12px;
}
.conn .acts {
  display: flex;
  gap: 6px;
  flex: none;
}

/* The pairing code is the one thing on screen that matters mid-sign-in. */
.devicecode {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.14em;
  padding: 5px 12px;
  border-radius: 8px;
  background: rgba(79, 157, 255, 0.12);
  border: 1px solid rgba(79, 157, 255, 0.4);
  color: #cfe2ff;
  user-select: all;
}

/* ── chat ──────────────────────────────────────────────────────────────── */
.chat-feed {
  height: 280px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: 10px 12px;
  scrollbar-width: thin;
}
.chat-hint {
  margin: 0;
}
.msg {
  padding: 3px 0;
  line-height: 1.45;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.msg .who {
  font-weight: 600;
}
.msg .src {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 7px;
  vertical-align: middle;
}
.msg .badge-dot {
  font-size: 10px;
  margin-right: 4px;
  opacity: 0.85;
}
.msg .body {
  color: var(--text-2);
}
.msg .at {
  color: var(--muted);
  font-size: 11px;
  margin-left: 6px;
}
.chat-dot {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.chat-dot::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
}
.chat-dot.live::before {
  background: var(--live);
}
.chat-dot.connecting::before,
.chat-dot.reconnecting::before {
  background: var(--warn);
}

/* ── controls ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  padding: 8px 15px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.btn:hover:not(:disabled) {
  border-color: rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.08);
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn.primary {
  background: var(--text);
  border-color: var(--text);
  color: #0b0e12;
}
.btn.primary:hover:not(:disabled) {
  background: #fff;
  border-color: #fff;
}
.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-2);
}
.btn.ghost:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--line-2);
}
.btn.danger {
  color: var(--bad);
  border-color: rgba(255, 92, 108, 0.4);
}
.btn.tiny {
  padding: 5px 11px;
  font-size: 12px;
}

input,
select,
textarea {
  font: inherit;
  width: 100%;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-s);
  padding: 10px 12px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(79, 157, 255, 0.18);
}
label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-2);
}

/* ── dialogs ───────────────────────────────────────────────────────────── */
dialog {
  background: var(--panel-solid);
  color: var(--text);
  border: 1px solid var(--line-2);
  border-radius: 20px;
  padding: 26px;
  width: min(540px, calc(100vw - 32px));
  box-shadow: 0 40px 80px -30px rgba(0, 0, 0, 0.9);
}
dialog::backdrop {
  background: rgba(5, 7, 10, 0.7);
  backdrop-filter: blur(4px);
}
#target-form {
  display: grid;
  gap: 6px;
}
#target-form h2 {
  font-size: 20px;
  margin-bottom: 10px;
}
#target-form label {
  margin-top: 10px;
}
#platform-note {
  margin: 4px 0 0;
}
.dialog-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
  align-items: center;
}
.spacer {
  flex: 1;
}
#key-link {
  margin-left: 6px;
  color: var(--accent);
}

#log-dialog {
  width: min(860px, calc(100vw - 32px));
}
.log-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.log {
  margin: 0;
  max-height: 60vh;
  overflow: auto;
  background: #07090c;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  background: var(--text);
  color: #0b0e12;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
}

/* Folded-away section in the destination dialog: per-platform audio needs OBS
   set up for it, so it should not be the first thing a new streamer reads. */
details.advanced {
  margin: 14px 0 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: 10px 14px;
}
details.advanced summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  user-select: none;
  list-style: none;
  display: flex;
  justify-content: space-between;
}
details.advanced summary::-webkit-details-marker {
  display: none;
}
details.advanced summary::after {
  content: "+";
  color: var(--muted);
}
details.advanced[open] summary {
  color: var(--text);
  margin-bottom: 6px;
}
details.advanced[open] summary::after {
  content: "–";
}

@media (max-width: 760px) {
  .topbar {
    padding: 0 16px;
  }
  main {
    padding: 16px;
  }
  .panel {
    padding: 16px;
  }
  .obs-grid {
    grid-template-columns: 1fr;
  }
  .row {
    grid-template-columns: 4px 1fr auto;
  }
  .row .metrics,
  .rowerror {
    grid-column: 2 / -1;
  }
  .stats > span {
    padding: 0 8px;
  }
}
