:root {
  --bg: #07080b;
  --bg-2: #101218;
  --line: rgba(244, 236, 220, 0.1);
  --text: #f6f1e8;
  --muted: #a3988c;
  --gold: #e7c27a;
  --gold-2: #f0d7a2;
  --live: #ff3b30;
  --danger: #ffb4a8;
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
  font-family: "Outfit", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }

.app {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
}

.rail {
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, #0d0f14, #090a0d 40%);
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  position: sticky;
  top: 0;
  height: 100dvh;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 22px 20px 12px;
}
.mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 30% 20%, #fff4d4, var(--gold) 42%, #8a6430);
  color: #1a1208;
  font-family: "Newsreader", serif;
  font-weight: 600;
  font-size: 22px;
}
.brand h1 { margin: 0; font-size: 18px; letter-spacing: 0.01em; font-weight: 560; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }

.search, .select, .field input, .field textarea, .field select {
  width: 100%;
  background: #0c0e12;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  outline: none;
}
.search:focus, .field input:focus, .field textarea:focus, .field select:focus, .select:focus {
  border-color: rgba(231, 194, 122, 0.7);
}

.search-wrap { padding: 8px 16px 10px; }

.chips {
  display: flex;
  gap: 8px;
  overflow: auto;
  padding: 0 16px 12px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip, .ghost, .gold, .icon-btn {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  padding: 7px 12px;
  color: var(--muted);
  white-space: nowrap;
}
.chip.active, .gold {
  background: var(--gold);
  color: #1b140b;
  border-color: transparent;
  font-weight: 620;
}
.list { overflow: auto; padding: 0 10px 24px; }
.channel {
  width: 100%;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 14px;
  padding: 8px;
}
.channel:hover, .channel.active { background: rgba(255, 248, 236, 0.05); }
.channel.active { outline: 1px solid rgba(231, 194, 122, 0.35); }
.logo, .logo-fallback {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: #181b21;
  object-fit: contain;
  padding: 4px;
}
.logo-fallback {
  display: grid;
  place-items: center;
  color: var(--gold);
  font-weight: 680;
}
.channel b { display: block; font-weight: 560; font-size: 14px; }
.channel small { color: var(--muted); font-size: 12px; }
.num { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; padding-right: 4px; }

.stage-wrap {
  min-width: 0;
  padding: 22px 22px 40px;
  background:
    radial-gradient(900px 420px at 70% -10%, rgba(231, 194, 122, 0.16), transparent 60%),
    var(--bg);
}
.frame {
  position: relative;
  background: #000;
  border-radius: 22px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255,255,255,0.06);
}
video { width: 100%; height: 100%; display: block; background: #000; object-fit: contain; }
.veil, .osd {
  position: absolute;
  inset: 0;
}
.veil {
  display: grid;
  place-items: center;
  background: rgba(0,0,0,0.55);
  text-align: center;
  padding: 24px;
}
.veil[hidden], .osd[hidden] { display: none; }
.spinner {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: var(--gold);
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.veil h2 { margin: 0 0 6px; font-weight: 560; font-size: 22px; }
.veil p { margin: 0; color: var(--muted); }

.osd {
  background: linear-gradient(180deg, rgba(0,0,0,0.45), transparent 30%, transparent 55%, rgba(0,0,0,0.72));
  opacity: 0;
  transition: opacity 0.25s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px;
}
.frame:hover .osd, .frame:focus-within .osd, .osd.show { opacity: 1; }
.osd-top, .osd-bottom { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(0,0,0,0.45);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  letter-spacing: 0.12em;
}
.live i {
  width: 8px; height: 8px; border-radius: 50%; background: var(--live);
  box-shadow: 0 0 0 4px rgba(255, 59, 48, 0.2);
}
.pill {
  background: rgba(0,0,0,0.5);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--gold-2);
}
.osd-bottom { align-items: flex-end; }
.controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.icon-btn {
  width: 40px; height: 40px; padding: 0; display: grid; place-items: center;
  background: rgba(0,0,0,0.45); color: white; border-radius: 12px;
}
.select {
  width: auto;
  background: rgba(0,0,0,0.55);
  border-radius: 12px;
  padding: 8px 10px;
}
.buffer {
  position: absolute;
  left: 16px; right: 16px; bottom: 68px;
  height: 3px;
  background: rgba(255,255,255,0.16);
  border-radius: 99px;
  overflow: hidden;
}
.buffer span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #8a6430, var(--gold));
}

.meta {
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 18px 6px 0;
}
.meta img, .meta .logo-fallback { width: 64px; height: 64px; border-radius: 18px; }
.kicker { color: var(--live); letter-spacing: 0.16em; font-size: 11px; font-weight: 680; }
.meta h2 { margin: 2px 0; font-size: 28px; font-weight: 560; letter-spacing: -0.03em; }
.meta p { margin: 0; color: var(--muted); }
.stat { margin-left: auto; color: var(--gold-2); font-size: 13px; text-align: right; }
.toast {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: #1b1712;
  border: 1px solid rgba(231, 194, 122, 0.4);
  color: var(--gold-2);
  padding: 10px 14px;
  border-radius: 999px;
  z-index: 5;
}

.empty { color: var(--muted); padding: 20px; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .rail { position: relative; height: auto; min-height: 0; border-right: 0; border-top: 1px solid var(--line); }
  .stage-wrap { padding: 12px; }
  .meta h2 { font-size: 22px; }
  .stat { display: none; }
  .frame { border-radius: 16px; }
}