:root {
  color-scheme: dark;
  --bg: #0c111b;
  --bg-elevated: #141b28;
  --bg-input: #0f1623;
  --border: #263043;
  --border-strong: #344258;
  --text: #e7edf7;
  --text-muted: #93a1b8;
  --accent: #5470ff;
  --accent-hover: #6b83ff;
  --green: #2fbf71;
  --amber: #e0a83a;
  --red: #f0546a;
  --radius: 14px;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 15% -10%, #1b2740 0%, var(--bg) 55%) fixed;
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

a { color: var(--accent-hover); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5rem; }
h1 { font-size: 1.6rem; letter-spacing: -0.01em; }
h2 { font-size: 1.1rem; }
h3 { font-size: 0.95rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }

code {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.1em 0.35em;
  font-size: 0.9em;
}

/* ---------- Layout ---------- */

.container {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  background: rgba(12, 17, 27, 0.85);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
}
.brand:hover { text-decoration: none; }
.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 4px rgba(240, 84, 106, 0.18);
}

.nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.95rem;
}
.nav a { color: var(--text-muted); }
.nav a:hover { color: var(--text); text-decoration: none; }
.user { color: var(--text-muted); font-size: 0.85rem; }
.inline-form { margin: 0; }

/* ---------- Cards and text ---------- */

.hero { margin-bottom: 1.5rem; }
.lede { color: var(--text-muted); margin: 0; font-size: 1.02rem; }

.grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.card {
  background: linear-gradient(180deg, var(--bg-elevated), #111826);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.auth-card { max-width: 420px; margin: 2rem auto; }

.muted { color: var(--text-muted); }
.small { font-size: 0.83rem; }
.center { text-align: center; }

.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1rem; }

.steps { margin: 0; padding-left: 1.2rem; color: var(--text-muted); }
.steps li { margin-bottom: 0.45rem; }

.plain-list { list-style: none; margin: 0 0 1rem; padding: 0; }
.plain-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
}
.plain-list li:last-child { border-bottom: none; }

.status { display: flex; align-items: center; gap: 0.55rem; margin: 0 0 0.35rem; font-weight: 600; }
.status-live { color: var(--green); }
.status-idle { color: var(--text-muted); }

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--text-muted);
  flex: 0 0 auto;
}
.dot-green { background: var(--green); box-shadow: 0 0 8px rgba(47, 191, 113, 0.7); }
.dot-amber { background: var(--amber); }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}
.btn:hover { background: #1b2536; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-ghost { background: transparent; }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.85rem; }
.btn-block { width: 100%; }

.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- Forms ---------- */

.field { margin-bottom: 0.9rem; }
.field label { display: block; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.35rem; }

input[type="text"],
input[type="password"],
.field input {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  color: var(--text);
  font: inherit;
}
input:focus { outline: 2px solid rgba(84, 112, 255, 0.45); outline-offset: 1px; border-color: var(--accent); }

.field-error { color: var(--red); font-size: 0.82rem; margin: 0.3rem 0 0; }

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-bottom: 1rem;
  cursor: pointer;
}
.checkbox input { accent-color: var(--accent); }

/* ---------- Alerts ---------- */

.flashes { display: grid; gap: 0.5rem; margin-bottom: 1rem; }
.flash, .alert {
  border-radius: 10px;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
}
.flash-success { border-color: rgba(47, 191, 113, 0.5); background: rgba(47, 191, 113, 0.1); }
.flash-error, .alert-error { border-color: rgba(240, 84, 106, 0.5); background: rgba(240, 84, 106, 0.1); color: #ffd9df; }
.alert { margin-top: 1rem; }

.capture-info {
  margin: 0.6rem 0 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.capture-info[hidden] { display: none; }

/* ---------- Video ---------- */

.stream-layout {
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(0, 1fr) 300px;
}
.watch-layout { display: grid; gap: 1rem; }

.video-card { padding: 1rem; }
.side-card h2 { margin-bottom: 0.75rem; }
.side-card h3 { margin-top: 1.25rem; }
.side-card .row { display: flex; justify-content: space-between; margin: 0.25rem 0; color: var(--text-muted); }
.side-card .row strong { color: var(--text); }

.video-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #05080e;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.video-wrap video { width: 100%; height: 100%; object-fit: contain; background: #05080e; display: block; }

.video-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1rem;
  text-align: center;
  color: var(--text-muted);
  background: rgba(5, 8, 14, 0.72);
}
.video-placeholder[hidden] { display: none; }

.badge {
  position: absolute;
  top: 0.65rem;
  left: 0.65rem;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.badge-live { background: var(--red); color: #fff; }

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.9rem;
}
.controls .checkbox { margin: 0; }

.watch-video { aspect-ratio: 16 / 9; }

.unmute {
  position: absolute;
  right: 0.65rem;
  bottom: 0.65rem;
  background: rgba(12, 17, 27, 0.85);
}

.player-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.player-meta { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.player-actions { display: flex; gap: 0.5rem; }

.pill {
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 0.82rem;
}

.copy-row { display: flex; gap: 0.5rem; }
.copy-row input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  color: var(--text-muted);
  font: inherit;
  font-size: 0.8rem;
}

.viewer-row { font-size: 0.9rem; }

.url-list {
  list-style: none;
  margin: 0.5rem 0 0.75rem;
  padding: 0;
  display: grid;
  gap: 0.3rem;
}
.url-list code {
  display: block;
  overflow-wrap: anywhere;
  font-size: 0.78rem;
}

.cast-help {
  margin-top: 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-elevated);
  padding: 0.75rem 1rem;
}
.cast-help[open] { padding-bottom: 1rem; }

.cast-help summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
}
.cast-help summary::marker { color: var(--accent); }

.cast-body { color: var(--text-muted); font-size: 0.9rem; }
.cast-body h3 {
  margin: 1rem 0 0.4rem;
  font-size: 0.8rem;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.cast-body p { margin: 0 0 0.5rem; }
.cast-body ul { margin: 0 0 0.5rem; padding-left: 1.2rem; }
.cast-body li { margin-bottom: 0.3rem; }

/* ---------- Responsive ---------- */

@media (max-width: 820px) {
  .stream-layout { grid-template-columns: minmax(0, 1fr); }
  .site-header { flex-wrap: wrap; }
  .nav { gap: 0.75rem; font-size: 0.9rem; }
}

@media (max-width: 480px) {
  .container { padding: 1rem 0.85rem 2rem; }
  h1 { font-size: 1.35rem; }
  .user { display: none; }
}
