:root {
  --bg:        #0d0b10;
  --panel:     #15121a;
  --panel-2:   #1d1925;
  --line:      #2a2433;
  --text:      #ece7f2;
  --muted:     #9a90a8;
  --accent:    #c9a4ff;
  --live:      #ff5c7a;
  --bar-h:     72px;
  --nav-w:     300px;
}

* { box-sizing: border-box; }

/* Author `display` rules below (.icon, svg) outrank the UA stylesheet's
   [hidden]{display:none}, so state the intent explicitly. */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}

body { display: flex; }

svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- sidebar ---------- */

#sidebar {
  width: var(--nav-w);
  flex: 0 0 var(--nav-w);
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
}
.brand h1 { font-size: 15px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; margin: 0; flex: 1; }
.brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
#closeNav { display: none; font-size: 26px; line-height: 1; }

#channels { flex: 1; overflow-y: auto; padding: 8px; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }

/* One flat, single-click list -- no accordion, no subsections. */
.row {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  margin-bottom: 2px;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.row:hover { background: var(--panel-2); }
.row.on { background: color-mix(in srgb, var(--accent) 14%, transparent); }

/* Channel avatars are square, playlist covers are 16:9 -- crop, don't squash. */
.row img { width: 34px; height: 34px; border-radius: 50%; flex: 0 0 34px; background: var(--panel-2); object-fit: cover; }

.row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.row-title { font-size: 13.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: 11px; color: var(--muted); letter-spacing: .04em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row.on .row-title { color: var(--accent); }

.pip { width: 6px; height: 6px; border-radius: 50%; flex: 0 0 6px; background: var(--live); }
.live-pip { animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.row-ico { width: 15px; height: 15px; flex: 0 0 15px; color: var(--muted); }
.row:hover .row-ico, .row.on .row-ico { color: var(--accent); }

/* ---------- hidden stations ---------- */

#hidden-wrap { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); }
.hidden-head .row-title { color: var(--muted); font-weight: 400; }
.hidden-eye { width: 34px; height: 18px; flex: 0 0 34px; color: var(--muted); }
.hidden-head .chev { transition: transform .18s ease; }
.hidden-head[aria-expanded="true"] .chev { transform: rotate(180deg); }
.hidden-list .row { opacity: .5; }
.hidden-list .row:hover { opacity: 1; }

/* ---------- station menu ---------- */

#menu {
  position: fixed;
  z-index: 20;
  min-width: 172px;
  padding: 5px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 10px 30px #000a;
}
.menu-head {
  padding: 6px 9px 7px;
  margin-bottom: 3px;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.menu-item {
  display: block;
  width: 100%;
  padding: 7px 9px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.menu-item:hover, .menu-item:focus-visible { background: color-mix(in srgb, var(--accent) 16%, transparent); outline: none; }

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bar-h) + 18px);
  transform: translateX(-50%);
  z-index: 20;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--text);
  box-shadow: 0 8px 24px #0008;
}

.stamp { display: flex; align-items: center; gap: 10px; padding: 11px 18px; border-top: 1px solid var(--line); font-size: 11px; color: var(--muted); }
.stamp #stamp { flex: 1; min-width: 0; }
.repo-link { display: inline-flex; color: var(--muted); }
.repo-link:hover { color: var(--accent); }
.gitlab-ico { width: 16px; height: 16px; fill: currentColor; stroke: none; }

/* ---------- stage ---------- */

#stage { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }

#player-wrap {
  flex: 1;
  position: relative;
  background: #000;
  display: grid;
  place-items: center;
  min-height: 0;
  overflow: hidden;
}
#player, #player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* YouTube's own controls are off (controls:0), and its pause overlay offers a
   "More videos" grid that navigates the iframe away from the station. The bar
   below drives everything, so swallow clicks on the video surface. */
#shield { position: absolute; inset: 0; z-index: 2; }
#shield.off { display: none; }

#idle { text-align: center; padding: 24px; z-index: 1; pointer-events: none; }
#idle.hide { display: none; }
.idle-title { font-size: 21px; font-weight: 600; margin: 0 0 6px; }
.idle-sub { color: var(--muted); margin: 0; font-size: 14px; }

/* ---------- bar ---------- */

#bar {
  height: var(--bar-h);
  flex: 0 0 var(--bar-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 18px;
  background: var(--panel);
  border-top: 1px solid var(--line);
}

.icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--text);
  cursor: pointer;
}
.icon:hover:not(:disabled) { background: var(--panel-2); }
.icon:disabled { opacity: .3; cursor: default; }
.icon.primary { background: var(--accent); color: #1a1220; }
.icon.primary:hover:not(:disabled) { background: #d9bcff; }

#openNav { display: none; }

#now { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
#now-title { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#now-sub { font-size: 11.5px; color: var(--muted); letter-spacing: .05em; text-transform: uppercase; }

#vol-wrap { display: flex; align-items: center; gap: 9px; color: var(--muted); }
#vol { width: 96px; accent-color: var(--accent); cursor: pointer; }

#scrim { display: none; position: fixed; inset: 0; background: #000a; z-index: 5; }

/* ---------- idle: chrome retracts, video goes edge to edge ---------- */

#sidebar, #bar { transition: margin .4s cubic-bezier(.4,0,.2,1), opacity .3s ease; }

body.idle #sidebar { margin-left: calc(var(--nav-w) * -1); opacity: 0; }
body.idle #bar     { margin-bottom: calc(var(--bar-h) * -1); opacity: 0; }
body.idle          { cursor: none; }

/* An iframe ignores object-fit, so size the 16:9 box to overflow the smaller
   axis instead -- the CSS equivalent of `object-fit: cover`. */
/* YT.Player REPLACES the #player div with the iframe (same id), so target
   #player itself -- a descendant `#player iframe` selector matches nothing. */
body.idle #player {
  inset: auto;
  top: 50%;
  left: 50%;
  width: 100vw;
  height: 56.25vw;         /* 100vw / (16/9) */
  min-width: 177.7778vh;   /* 100vh * (16/9) */
  min-height: 100vh;
  transform: translate(-50%, -50%);
}

@media (prefers-reduced-motion: reduce) {
  #sidebar, #bar { transition: none; }
}

/* ---------- mobile ---------- */

@media (max-width: 780px) {
  #sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 6;
    transform: translateX(-100%);
    transition: transform .22s ease;
  }
  body.nav-open #sidebar { transform: none; }
  body.nav-open #scrim { display: block; }
  #openNav, #closeNav { display: grid; }
  #vol { width: 62px; }
}
