:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0c0e10;
  color: #f4f5f5;
  --line: #2b3034;
  --muted: #9da5aa;
  --surface: #141719;
  --surface-2: #1b1f22;
  --accent: #23c483;
  --danger: #ff6464;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; background: #0c0e10; }
body { overflow: hidden; }
button, input, select { font: inherit; letter-spacing: 0; }
button { color: inherit; }
.app-bar {
  height: 58px; display: flex; align-items: center; gap: 12px; padding: 0 18px;
  border-bottom: 1px solid var(--line); background: #111315; position: relative; z-index: 20;
}
.brand { color: #fff; text-decoration: none; display: flex; align-items: center; gap: 9px; font-size: 17px; font-weight: 700; }
.brand-mark { width: 28px; height: 28px; display: grid; place-items: center; background: var(--accent); color: #07110d; border-radius: 5px; font-weight: 900; }
.connection { margin-left: auto; display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; }
.status-dot, .route-dot { width: 8px; height: 8px; border-radius: 50%; background: #72797e; flex: 0 0 auto; }
.connection.online .status-dot, .route-dot.p2p { background: var(--accent); box-shadow: 0 0 0 3px rgb(35 196 131 / 14%); }
.connection.error .status-dot { background: var(--danger); }
.icon-button { width: 36px; height: 36px; border: 0; background: transparent; display: grid; place-items: center; cursor: pointer; border-radius: 5px; }
.icon-button:hover { background: #25292c; }
.icon-button svg { width: 19px; height: 19px; }
.workspace { height: calc(100vh - 58px); display: grid; grid-template-columns: minmax(270px, 330px) minmax(0, 1fr); }
.catalog { min-height: 0; border-right: 1px solid var(--line); background: #111315; display: flex; flex-direction: column; }
.catalog-tools { padding: 14px; display: grid; gap: 10px; border-bottom: 1px solid var(--line); }
.search-field { height: 40px; display: flex; align-items: center; gap: 9px; padding: 0 11px; background: var(--surface-2); border: 1px solid #343a3e; border-radius: 6px; }
.search-field:focus-within { border-color: var(--accent); }
.search-field svg { width: 17px; color: var(--muted); }
.search-field input { width: 100%; border: 0; outline: 0; background: transparent; color: #fff; min-width: 0; }
select { height: 38px; padding: 0 10px; color: #e7e9ea; background: var(--surface-2); border: 1px solid #343a3e; border-radius: 6px; }
.catalog-count { padding: 10px 14px 7px; color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; }
.channel-list { min-height: 0; overflow-y: auto; padding: 0 7px 12px; }
.channel-row { width: 100%; min-height: 56px; padding: 8px; display: flex; align-items: center; gap: 10px; border: 0; background: transparent; text-align: left; cursor: pointer; border-radius: 6px; }
.channel-row:hover { background: #1b1f22; }
.channel-row.active { background: #20332b; box-shadow: inset 3px 0 var(--accent); }
.channel-logo { width: 38px; height: 38px; flex: 0 0 auto; display: grid; place-items: center; border: 1px solid #363c40; background: #fff; color: #202426; border-radius: 5px; overflow: hidden; font-size: 13px; font-weight: 800; }
.channel-logo img { width: 100%; height: 100%; object-fit: contain; }
.channel-logo.large { width: 46px; height: 46px; }
.channel-copy { min-width: 0; }
.channel-copy strong, .channel-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel-copy strong { font-size: 14px; font-weight: 650; }
.channel-copy span { margin-top: 3px; font-size: 12px; color: var(--muted); }
.load-more { margin: 0 14px 14px; height: 38px; border: 1px solid #3a4044; background: var(--surface-2); border-radius: 6px; cursor: pointer; }
.player-pane { min-width: 0; min-height: 0; overflow-y: auto; padding: 22px clamp(16px, 3vw, 44px) 36px; }
.video-shell { width: 100%; aspect-ratio: 16/9; max-height: calc(100vh - 300px); min-height: 280px; background: #050606; position: relative; overflow: hidden; border: 1px solid #24282b; border-radius: 6px; }
video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.player-empty, .player-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 12px; background: #090b0c; color: var(--muted); }
.player-empty svg { width: 40px; height: 40px; }
.spinner { width: 28px; height: 28px; border: 3px solid #394045; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.now-playing { min-height: 74px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); }
.channel-identity { min-width: 0; display: flex; align-items: center; gap: 12px; }
.channel-identity h1 { margin: 0; font-size: 18px; line-height: 1.25; overflow-wrap: anywhere; }
.channel-identity p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.live-badge { display: flex; align-items: center; gap: 6px; padding: 5px 7px; color: #ff8a8a; border: 1px solid #5d3030; border-radius: 4px; font-size: 11px; font-weight: 800; }
.live-badge span { width: 6px; height: 6px; border-radius: 50%; background: #ff6464; }
.metrics-strip { display: grid; grid-template-columns: repeat(5, minmax(90px, 1fr)); border-bottom: 1px solid var(--line); }
.metrics-strip > div { min-width: 0; padding: 16px 12px; border-right: 1px solid var(--line); }
.metrics-strip > div:first-child { padding-left: 0; }
.metrics-strip > div:last-child { border-right: 0; }
.metric-label { display: block; color: var(--muted); font-size: 11px; margin-bottom: 6px; }
.metrics-strip strong { font-size: 16px; overflow-wrap: anywhere; }
.controls-row { min-height: 60px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.toggle-row { display: flex; align-items: center; gap: 11px; cursor: pointer; }
.toggle-row > span:first-child { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.toggle-row svg { width: 17px; color: var(--muted); }
.toggle-row input { position: absolute; opacity: 0; pointer-events: none; }
.toggle { width: 38px; height: 22px; padding: 2px; border-radius: 12px; background: #3b4145; transition: background .2s; }
.toggle::after { content: ""; display: block; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s; }
.toggle-row input:checked + .toggle { background: var(--accent); }
.toggle-row input:checked + .toggle::after { transform: translateX(16px); }
.route-status { color: var(--muted); display: flex; align-items: center; gap: 7px; font-size: 12px; }
.error-banner { min-height: 48px; padding: 8px 10px; display: flex; align-items: center; gap: 9px; background: #321d20; border: 1px solid #653038; border-radius: 6px; color: #ffb6bb; font-size: 13px; }
.error-banner > svg { width: 18px; flex: 0 0 auto; }
.error-banner span { flex: 1; }
.mobile-only, .scrim { display: none; }
@media (max-width: 780px) {
  body { overflow: auto; }
  .mobile-only { display: grid; }
  .workspace { height: calc(100dvh - 58px); display: block; }
  .catalog { position: fixed; z-index: 30; top: 58px; bottom: 0; left: 0; width: min(88vw, 340px); transform: translateX(-102%); visibility: hidden; pointer-events: none; transition: transform .2s, visibility 0s linear .2s; box-shadow: 15px 0 40px #0008; }
  .catalog.open { transform: translateX(0); visibility: visible; pointer-events: auto; transition-delay: 0s; }
  .scrim { position: fixed; z-index: 25; inset: 58px 0 0; background: #000a; }
  .scrim:not([hidden]) { display: block; }
  .player-pane { height: 100%; padding: 12px 12px 28px; }
  .video-shell { min-height: 0; max-height: none; }
  .metrics-strip { grid-template-columns: repeat(2, 1fr); }
  .metrics-strip > div { border-bottom: 1px solid var(--line); }
  .metrics-strip > div:nth-child(even) { border-right: 0; }
  .metrics-strip > div:first-child { padding-left: 12px; }
  .controls-row { align-items: flex-start; flex-direction: column; padding: 14px 0; }
  .connection span:last-child { display: none; }
}
@media (max-width: 420px) {
  .brand > span:last-child { display: none; }
  .channel-identity h1 { font-size: 16px; }
  .metrics-strip strong { font-size: 15px; }
}
