:root {
  color-scheme: dark;
  --bg: #090c0a;
  --panel: #111713;
  --raise: #1b251e;
  --line: #2b3b30;
  --accent: #88faaa;
  --ink: #07180d;
  --text: #eef7f0;
  --muted: #a6b8aa;
  --mono: "Cascadia Mono", "IBM Plex Mono", Consolas, monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, sans-serif;
}
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:disabled { opacity: .52; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app {
  display: grid;
  grid-template-columns: clamp(17rem, 28vw, 22rem) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  gap: 1.25rem;
  padding: 1.25rem;
}
.sidebar, .stage {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 1.15rem;
}
.sidebar { gap: .65rem; padding: 1rem; }
.brand { display: flex; align-items: center; gap: .7rem; margin: .2rem 0 .8rem; }
.brand-icon {
  display: grid;
  place-items: center;
  width: 2.3rem;
  height: 2.3rem;
  border-radius: .7rem;
  background: var(--accent);
}
.brand-icon::before {
  content: '';
  margin-left: .12rem;
  border-block: .35rem solid transparent;
  border-left: .55rem solid var(--ink);
}
.logo { font-size: 1.55rem; font-weight: 650; letter-spacing: -.045em; }
.logo b { color: var(--accent); }
.sidebar label, .count { color: var(--muted); font-size: .8rem; font-weight: 600; }
select, input[type=search] {
  width: 100%;
  min-height: 2.7rem;
  padding: .58rem .75rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: .65rem;
  font-size: .9rem;
}
input::placeholder { color: var(--muted); }
.chips {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: .4rem;
  overflow-x: auto;
  padding: .25rem;
  scrollbar-width: thin;
}
.chips:empty { display: none; }
.chip {
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--muted);
  padding: .38rem .75rem;
  border-radius: 999px;
  font-size: .8rem;
  white-space: nowrap;
}
.chip:hover { color: var(--text); }
.chip[aria-pressed=true] { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.count { min-height: 1rem; }
.channels { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; padding: .2rem .3rem; }
.channel {
  display: flex;
  align-items: center;
  gap: .7rem;
  width: 100%;
  min-height: 3.5rem;
  margin-bottom: .25rem;
  padding: .45rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: .7rem;
  text-align: left;
}
.channel:hover { background: var(--raise); }
.channel[aria-current=true] { background: #30291f; border-color: #906a40; }
.channel[aria-current=true] .ch-name { color: var(--accent); }
.channel img, .logo-img {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: .55rem;
  object-fit: contain;
  background: var(--bg);
  flex-shrink: 0;
}
.ch-info, .meta { min-width: 0; }
.ch-info { display: grid; gap: .14rem; }
.ch-name, .ch-group, .meta h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-name { font-size: .9rem; font-weight: 650; }
.ch-group, .badge { font-size: .76rem; color: var(--muted); }
.empty { color: var(--muted); padding: 1rem .5rem; text-align: center; font-size: .9rem; }
.more {
  width: 100%;
  margin-top: .5rem;
  padding: .65rem;
  background: var(--raise);
  border: 1px solid var(--line);
  border-radius: .65rem;
}
.more:hover { border-color: var(--accent); }

.stage { overflow: hidden; }
.video-wrap { flex: 1; min-height: 0; position: relative; background: #080a10; }
video { display: block; width: 100%; height: 100%; object-fit: contain; }
.video-wrap:fullscreen { width: 100%; height: 100%; }
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: .8rem;
  background: radial-gradient(ellipse at center, #22293a, #0b0e16 75%);
  text-align: center;
  padding: 1rem;
}
.overlay p { margin: 0; font-weight: 600; }
.recovery-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .45rem; }
.overlay button {
  background: var(--accent);
  color: var(--ink);
  border: 0;
  padding: .6rem 1rem;
  border-radius: .65rem;
  font-weight: 650;
}
.spinner {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.info {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .85rem 1rem;
  border-top: 1px solid var(--line);
}
.meta { flex: 1; }
.meta h1 { margin: 0 0 .2rem; font-size: clamp(.95rem, 2vw, 1.25rem); }
.badge { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions { display: flex; gap: .3rem; }
.actions select { width: auto; max-width: 8rem; min-height: 2.5rem; padding: .35rem; font-size: .76rem; }
.actions button {
  width: 2.5rem;
  height: 2.5rem;
  background: var(--raise);
  border: 1px solid var(--line);
  border-radius: .6rem;
  font-size: 1.2rem;
  line-height: 1;
}
.actions button:hover:enabled, .actions button[aria-pressed=true] { color: var(--accent); border-color: #906a40; }

@media (max-width: 760px) {
  .app { display: flex; flex-direction: column; height: auto; min-height: 100dvh; gap: .65rem; padding: .65rem; }
  .stage { order: -1; }
  .video-wrap { flex: none; aspect-ratio: 16 / 9; max-height: 48dvh; }
  .sidebar { min-height: 22rem; height: max(22rem, calc(100dvh - min(56vw, 48dvh) - 5.5rem)); }
}
@media (max-width: 420px) {
  .info { padding: .65rem; gap: .4rem; }
  .info .logo-img { display: none; }
  .actions button { width: 2.15rem; height: 2.35rem; }
  .info:has(#quality:not([hidden])) { flex-wrap: wrap; }
  .info:has(#quality:not([hidden])) .meta { flex-basis: 100%; }
}
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

svg { width: 1.1em; height: 1.1em; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.symbols, .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.intro {
  min-height: 100dvh;
  display: grid;
  align-items: center;
  padding: clamp(.85rem, 5vw, 4rem);
  background: repeating-linear-gradient(0deg, #08160d44 0 1px, transparent 1px 4px), radial-gradient(ellipse at 50% 45%, #152d1a, #050706 73%);
  font-family: var(--mono);
}
.intro-shell {
  width: min(100%, 59rem);
  margin: auto;
  border: 1px solid #375943;
  box-shadow: 0 0 75px #68ff9112, inset 0 0 40px #122f1a88;
  background: #080f0ad9;
}
.intro-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .85rem clamp(.9rem, 4vw, 2.5rem);
  border-bottom: 1px solid #375943;
  color: var(--accent);
  font-size: clamp(.72rem, 2.4vw, .9rem);
  letter-spacing: .06em;
}
.signal, .live::before { flex: none; width: .5rem; height: .5rem; border-radius: 50%; background: var(--accent); box-shadow: 0 0 14px var(--accent); }
.text-button { margin-left: auto; color: var(--muted); background: transparent; border: 0; text-decoration: underline; text-underline-offset: .2em; padding: .3rem; }
.intro-content { display: grid; justify-items: center; text-align: center; padding: clamp(1.6rem, 6vw, 4.25rem) 1rem; }
.glitch { position: relative; color: var(--accent); font-size: clamp(6rem, 24vw, 15rem); font-weight: 900; line-height: .88; letter-spacing: -.09em; padding-right: .09em; text-shadow: 0 0 .3em #7dff9d48; }
.glitch::before, .glitch::after { position: absolute; inset: 0; content: attr(data-text); pointer-events: none; }
.glitch::before { color: #c1ffe1; clip-path: inset(29% 0 60%); animation: glitch 4s steps(1) infinite; }
.glitch::after { color: #55df97; clip-path: inset(68% 0 18%); animation: glitch 5s steps(1) infinite reverse; }
@keyframes glitch { 0%, 7%, 100% { transform: translateX(0); } 2%, 5% { transform: translateX(-.035em); } 4% { transform: translateX(.06em); } }
.intro h1 { margin: 1rem 0 1.35rem; text-transform: uppercase; letter-spacing: .13em; font-size: clamp(.9rem, 3vw, 1.45rem); }
#terminal { width: min(100%, 29rem); min-height: 7rem; text-align: left; padding: .75rem 1rem; margin: 0; border-left: 1px solid #386f49; color: #a7d8b6; white-space: pre-wrap; line-height: 1.5; font: .85rem/1.5 var(--mono); }
#terminal::after { content: ' ▋'; color: var(--accent); animation: blink 1.1s steps(1) infinite; }
.intro-static .glitch::before, .intro-static .glitch::after, .intro-static #terminal::after { animation: none; }
@keyframes blink { 50% { opacity: 0; } }
progress { accent-color: var(--accent); }
#boot-progress { width: min(100%, 29rem); height: .45rem; margin: .8rem 0 1.65rem; }
button, select, input { transition: border-color .16s ease, background-color .16s ease, color .16s ease; }
.primary { background: var(--accent); color: var(--ink); border: 1px solid var(--accent); padding: .72rem 1.15rem; border-radius: .45rem; font-weight: 750; }
.primary:hover:enabled { background: #c1ffd1; }
.workspace { max-width: 114rem; margin: auto; }
.topbar { height: 4.3rem; display: flex; justify-content: space-between; align-items: center; padding: 0 clamp(.75rem, 3vw, 1.5rem); border-bottom: 1px solid var(--line); }
.topbar .brand { margin: 0; }
.brand-icon { color: var(--ink); }
.brand-icon::before { display: none; }
.brand-icon svg { width: 1.6rem; height: 1.6rem; }
.topbar nav, .sidebar-heading, .dialog-heading { display: flex; align-items: center; gap: .45rem; }
.topbar button, .sidebar-heading button, .player-tools button, dialog button:not(.primary) {
  background: var(--raise); border: 1px solid var(--line); border-radius: .55rem; padding: .46rem .66rem;
}
.topbar button svg { margin-right: .34rem; }
.topbar button:hover, .sidebar-heading button:hover, .player-tools button:hover, dialog button:hover { border-color: var(--accent); }
.app { height: calc(100dvh - 4.3rem); }
.app:has(.sidebar[hidden]) { grid-template-columns: minmax(0,1fr); }
.sidebar-heading, .dialog-heading { justify-content: space-between; }
.sidebar-heading h2, dialog h2 { font-size: 1.05rem; margin: .2rem 0; }
.channels.cards { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); align-content: start; gap: .45rem; }
.cards .channel { flex-direction: column; justify-content: center; background: var(--bg); border-color: var(--line); text-align: center; min-width: 0; padding: .65rem .3rem; }
.cards .ch-info { width: 100%; }
.cards .empty, .cards .more, .cards .skeleton { grid-column: 1 / -1; }
.channel[aria-current=true], .cards .channel[aria-current=true] { background: #1e3826; border-color: #4a8960; }
.actions button:hover:enabled, .actions button[aria-pressed=true] { border-color: var(--accent); }
.video-wrap { background: #040705; }
.overlay { background: repeating-linear-gradient(0deg,#16271b33 0 1px,transparent 1px 5px), radial-gradient(ellipse at center, #1b3121, #080d09 75%); }
#player-mark { width: 3.4rem; height: 3.4rem; color: var(--accent); opacity: .7; }
.overlay:has(.spinner:not([hidden])) #player-mark { display: none; }
.live { display: inline-flex; gap: .4rem; align-items: center; font: .72rem var(--mono); color: var(--accent); text-transform: uppercase; }
.live::before { content: ''; width: .38rem; height: .38rem; }
.player-tools { display: flex; gap: .45rem; flex-wrap: wrap; align-items: center; padding: .58rem .9rem; border-top: 1px solid var(--line); font-size: .82rem; }
.player-tools select { width: auto; max-width: 100%; min-height: 2rem; padding: .25rem .4rem; }
.player-tools [aria-pressed=true], #layout[aria-pressed=true] { border-color: var(--accent); color: var(--accent); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(8rem,1fr)); margin: 0; padding: .6rem .9rem; gap: .6rem; border-top: 1px solid var(--line); font: .76rem var(--mono); }
.stats dt { color: var(--muted); }
.stats dd { margin: .25rem 0 0; overflow-wrap: anywhere; }
video[data-fit=cover] { object-fit: cover; }
video[data-fit=fill] { object-fit: fill; }
.skeleton { height: 14rem; border-radius: .65rem; background: repeating-linear-gradient(to bottom, var(--raise) 0 2.6rem, transparent 2.6rem 3.1rem); animation: shimmer 1.1s ease-in-out infinite alternate; }
@keyframes shimmer { to { opacity: .36; } }
dialog { color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: .85rem; width: min(37rem, calc(100vw - 1.25rem)); max-height: calc(100dvh - 2rem); padding: 1.2rem; }
dialog::backdrop { background: #000c; }
dialog h1 { margin: 0 0 .5rem; font-size: 1.25rem; }
dialog form { display: grid; gap: .65rem; margin-bottom: 1rem; }
dialog label { display: grid; gap: .25rem; color: var(--muted); }
dialog input { min-width: 0; padding: .5rem .65rem; background: var(--bg); border: 1px solid var(--line); border-radius: .45rem; }
#download-form { grid-template-columns: repeat(2,minmax(0,1fr)); }
#download-size, #download-form .primary { grid-column: 1 / -1; }
#download-size:empty, #login-error:empty { display: none; }
#jobs { padding: 0; list-style: none; display: grid; gap: .55rem; }
#jobs li { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem; padding: .55rem; border: 1px solid var(--line); border-radius: .5rem; }
#jobs a { color: var(--accent); }
#toast { position: fixed; z-index: 5; bottom: 1rem; right: 1rem; max-width: calc(100vw - 2rem); background: var(--raise); padding: .7rem 1rem; border: 1px solid var(--accent); border-radius: .6rem; }
@media (max-width: 760px) {
  .app { height: auto; min-height: calc(100dvh - 4.3rem); }
  .cinema .video-wrap { max-height: 75dvh; }
}
@media (max-width: 420px) { .topbar nav button:has(svg) span { display: none; } .topbar button svg { margin: 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
