:root {
  --bg: #0b0d10;
  --bg-elev: #12161c;
  --line: #243041;
  --text: #e8eef6;
  --muted: #8a9bb0;
  --accent: #e11d48;
  --accent-soft: rgba(225, 29, 72, 0.18);
  --ok: #34d399;
  --chip: #1a2230;
  --chip-active: #e11d48;
  --radius: 10px;
  --font-display: "Bebas Neue", Impact, sans-serif;
  --font-body: "IBM Plex Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
}

body {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background:
    radial-gradient(1200px 600px at 10% -10%, #1a2436 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #2a1520 0%, transparent 50%),
    var(--bg);
}

.noise {
  pointer-events: none;
  position: fixed;
  inset: 0;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: 0;
}

.topbar, .workspace, .toolbar, .stage, .footer {
  position: relative;
  z-index: 1;
}

.workspace {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 0;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 13, 16, 0.72);
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
}

.brand-mark {
  font-family: var(--font-display);
  letter-spacing: 0.08em;
  font-size: 0.95rem;
  color: #fff;
  background: var(--accent);
  padding: 0.2rem 0.45rem 0.05rem;
  border-radius: 4px;
  animation: pulse 1.8s ease-in-out infinite;
}

.brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 2rem;
  letter-spacing: 0.04em;
  font-weight: 400;
  line-height: 1;
}

.status {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.85rem;
}

.mode-toggle {
  display: flex;
  gap: 0.35rem;
}

.mode-btn {
  min-width: 2.2rem;
  height: 2rem;
  border: 1px solid var(--line);
  background: var(--chip);
  color: var(--muted);
  border-radius: 6px;
  font: 600 0.75rem var(--font-body);
  cursor: pointer;
}

.mode-btn.active {
  color: #fff;
  border-color: var(--accent);
  background: var(--accent-soft);
}

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.85rem 0.75rem;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: rgba(11, 13, 16, 0.55);
  scrollbar-width: thin;
}

.chip {
  flex: 0 0 auto;
  width: 100%;
  border: 1px solid var(--line);
  background: var(--chip);
  color: var(--text);
  border-radius: 8px;
  padding: 0.65rem 0.8rem;
  font: 600 0.78rem/1.2 var(--font-body);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}

.chip:hover { border-color: #4a607a; transform: translateX(2px); }

.chip.active {
  background: var(--chip-active);
  border-color: var(--chip-active);
  color: #fff;
}

.stage {
  padding: 1rem 1.25rem 1.25rem;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.channel-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  flex: 0 0 auto;
}

.nav-btn {
  border: 1px solid var(--line);
  background: var(--chip);
  color: var(--text);
  border-radius: 8px;
  padding: 0.55rem 1rem;
  font: 600 0.82rem/1 var(--font-body);
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.nav-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.nav-label {
  min-width: 8rem;
  text-align: center;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--muted);
}

.player-shell {
  flex: 1;
  height: auto;
  min-height: 360px;
  display: grid;
  gap: 0.75rem;
}

.player-shell.single { grid-template-columns: 1fr; grid-template-rows: 1fr; }
.player-shell.quad { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.player-shell.all {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  grid-auto-rows: minmax(200px, 1fr);
  height: auto;
  min-height: 100%;
}

.player-slot {
  position: relative;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 0;
  display: flex;
  flex-direction: column;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

.player-frame {
  flex: 1;
  background: #000;
  position: relative;
  min-height: 0;
}

.player-frame iframe,
.player-frame iframe.yt-embed,
.player-frame .yt-embed,
.player-frame video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
}

.player-frame .placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.95rem;
  padding: 1rem;
  text-align: center;
}

.player-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  border-top: 1px solid var(--line);
  background: rgba(18, 22, 28, 0.95);
  font-size: 0.82rem;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.6);
  animation: ping 1.6s infinite;
}

.meta-name { font-weight: 600; }
.meta-src {
  margin-left: auto;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.7rem;
}

.footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 1.25rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.72; }
}

@keyframes ping {
  0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.55); }
  70% { box-shadow: 0 0 0 8px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

@media (max-width: 800px) {
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .toolbar {
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .chip {
    width: auto;
    white-space: nowrap;
  }

  .chip:hover { transform: translateY(-1px); }

  .player-shell.quad { grid-template-columns: 1fr; grid-template-rows: repeat(4, minmax(180px, 1fr)); height: auto; }
  .brand h1 { font-size: 1.6rem; }
  .status { display: none; }
}
