:root {
  color-scheme: dark;
  --bg: #08090c;
  --surface: #101218;
  --surface-2: #171a22;
  --line: #252936;
  --text: #f7f8fb;
  --muted: #8f96a6;
  --accent: #6d5dfc;
  --accent-2: #8c7fff;
  --success: #48d597;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 20% -10%, #1b1931 0, transparent 34rem), var(--bg); color: var(--text); }
button, input { font: inherit; }
button { color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.site-header, footer { width: min(1440px, 100%); margin: 0 auto; padding-inline: clamp(18px, 4vw, 56px); }
.site-header { height: 78px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: inline-flex; gap: 11px; align-items: center; color: inherit; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 39px; height: 39px; border-radius: 12px; background: linear-gradient(145deg, var(--accent-2), #5140dc); font: 800 20px/1 Georgia, serif; box-shadow: 0 8px 24px #6d5dfc38; }
.brand strong, .brand small { display: block; }
.brand strong { letter-spacing: -.02em; }
.brand small { margin-top: -2px; color: var(--muted); font-size: 10px; letter-spacing: .2em; }
.header-tools { display: flex; align-items: center; gap: 15px; }
.live-badge { display: flex; align-items: center; gap: 8px; color: #b6bdca; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.live-badge span { width: 7px; height: 7px; border-radius: 50%; background: #ff536b; box-shadow: 0 0 0 5px #ff536b1a; }
.admin-link, .install-button { padding: 8px 11px; border: 1px solid var(--line); border-radius: 10px; color: #aeb5c3; background: transparent; text-decoration: none; font-size: 11px; font-weight: 700; cursor: pointer; }
.admin-link:hover, .install-button:hover { border-color: #464b5b; color: #fff; }
.install-button { border-color: #6d5dfc66; color: #c7c1ff; background: #6d5dfc14; }
.install-button[hidden] { display: none; }
.install-dialog { width: min(400px, calc(100% - 28px)); padding: 25px; border: 1px solid var(--line); border-radius: 19px; color: var(--text); background: #12141b; box-shadow: 0 30px 90px #000b; }
.install-dialog::backdrop { background: #050609cc; backdrop-filter: blur(4px); }
.install-dialog h2 { margin-bottom: 12px; font-size: 23px; line-height: 1.15; }
.install-dialog > p:last-child { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.65; }
.dialog-close { position: absolute; top: 12px; right: 12px; width: 32px; height: 32px; border: 0; border-radius: 9px; color: var(--muted); background: #ffffff0a; font-size: 19px; cursor: pointer; }

.app-shell { width: min(1440px, 100%); min-height: calc(100vh - 138px); margin: 0 auto; padding: 18px clamp(18px, 4vw, 56px) 34px; display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(340px, .75fr); gap: clamp(22px, 3vw, 42px); align-items: start; }
.player-column, .channels-panel { min-width: 0; }
.player-heading, .panel-heading { display: flex; justify-content: space-between; align-items: end; gap: 16px; min-height: 56px; margin-bottom: 15px; }
.eyebrow { margin: 0 0 5px; color: var(--accent-2); font-size: 10px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
h1, h2 { margin: 0; line-height: 1.05; letter-spacing: -.035em; }
h1 { max-width: 70vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: clamp(22px, 3vw, 34px); }
h2 { font-size: 25px; }
.player-status { flex: none; padding: 7px 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: #101218cc; font-size: 11px; font-weight: 700; }
.player-status.playing { border-color: #48d59738; color: var(--success); }

.player-shell { width: 100%; position: relative; display: grid; place-items: center; overflow: hidden; border: 1px solid #20232c; border-radius: clamp(14px, 2.2vw, 26px); background: #000; box-shadow: 0 30px 80px #0008; }
.player-shell.retro-mode { aspect-ratio: 4 / 3; }
.player-shell.normal-mode { aspect-ratio: 16 / 9; }
.player-stage { position: absolute; inset: 0; overflow: hidden; background: #000; transform-origin: center; }
.retro-overlay { position: absolute; inset: 0; z-index: 10; pointer-events: none; background: url("retro-tv-overlay.webp") center / contain no-repeat; }
#tv-static, .main-video, .youtube-player { position: absolute; top: 20.5%; left: 19.5%; width: 52%; height: 50.5%; border:0; border-radius: 9% / 12%; object-fit: cover; background: #000; }
#tv-static { z-index: 6; }
.main-video, .youtube-player { z-index: 5; }
.youtube-player[hidden] { display:none; }
.normal-placeholder { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--muted); background: radial-gradient(circle, #1a1c25, #090a0d 65%); pointer-events: none; }
.normal-placeholder[hidden] { display: none; }
.normal-placeholder span { display: grid; place-items: center; width: 62px; height: 62px; padding-left: 4px; border: 1px solid #ffffff18; border-radius: 50%; background: #ffffff0a; color: #fff; }
.normal-placeholder p { margin: 0; font-size: 13px; }
.normal-mode .retro-overlay, .normal-mode #tv-static { display: none !important; }
.normal-mode .main-video, .normal-mode .youtube-player { inset: 0; width: 100%; height: 100%; border-radius: 0; object-fit: contain; }

.mode-control { margin-top: 15px; padding: 13px 16px; display: flex; align-items: center; gap: 13px; border: 1px solid var(--line); border-radius: 15px; background: linear-gradient(135deg, #151820, #111319); cursor: pointer; user-select: none; }
.mode-control:hover { border-color: #383d4d; }
.mode-control strong, .mode-control small { display: block; }
.mode-control strong { font-size: 13px; }
.mode-control small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track { display: block; position: relative; width: 44px; height: 24px; border-radius: 99px; background: #333744; transition: .2s; }
.switch-track span { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 2px 8px #0008; transition: .2s; }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent-2); outline-offset: 3px; }
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track span { transform: translateX(20px); }

.channels-panel { min-height: 500px; margin-top: 71px; padding: 20px; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 24px; background: linear-gradient(160deg, #13151c 0, #0e1015 70%); box-shadow: 0 26px 70px #0005; }
.search-box { width: 145px; height: 38px; display: flex; align-items: center; gap: 7px; padding: 0 11px; border: 1px solid var(--line); border-radius: 11px; background: #0b0d11; color: var(--muted); }
.search-box input { width: 100%; border: 0; outline: 0; color: var(--text); background: transparent; font-size: 12px; }
.search-box input::placeholder { color: #697080; }
.category-nav { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); flex: none; gap: 8px; margin: 0 0 15px; padding: 0; }
.cat-item { width: 100%; min-height: 38px; padding: 7px 6px; border: 1px solid var(--line); border-radius: 10px; background: #151820; color: #9aa1b0; font-size: 11px; line-height: 1.2; font-weight: 700; cursor: pointer; transition: .15s ease; }
.cat-item:hover { color: #fff; border-color: #3b4050; }
.cat-item.active { color: #fff; border-color: var(--accent); background: var(--accent); box-shadow: 0 7px 18px #6d5dfc34; }
.channel-list { flex: 1; min-height: 180px; max-height: 500px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; padding-right: 4px; scrollbar-color: #343846 transparent; scrollbar-width: thin; }
.channel-row { width: 100%; min-height: 68px; padding: 9px 12px; display: flex; align-items: center; gap: 12px; border: 1px solid transparent; border-radius: 13px; background: #181b23; text-align: left; cursor: pointer; transition: transform .15s, background .15s, border-color .15s; }
.channel-row:hover { transform: translateY(-1px); border-color: #323746; background: #1d202a; }
.channel-row.active-play { border-color: #6d5dfc88; background: linear-gradient(100deg, #272249, #191c25); }
.logo-box { flex: none; width: 46px; height: 46px; padding: 5px; object-fit: contain; border-radius: 10px; background: #0b0d12; }
.channel-copy { min-width: 0; flex: 1; }
.channel-copy strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.channel-copy small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.play-icon { display: grid; place-items: center; flex: none; width: 30px; height: 30px; padding-left: 2px; border-radius: 50%; background: #ffffff09; color: #b6bdca; font-size: 9px; }
.active-play .play-icon { background: var(--accent); color: white; }
.empty-state { min-height: 240px; display: grid; place-content: center; justify-items: center; gap: 10px; color: var(--muted); text-align: center; }
.empty-state p { max-width: 250px; margin: 0; font-size: 12px; line-height: 1.6; }
.loader { width: 22px; height: 22px; border: 2px solid #363a47; border-top-color: var(--accent-2); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

footer { min-height: 60px; display: flex; justify-content: space-between; align-items: center; border-top: 1px solid #191c23; color: #686f7e; font-size: 10px; letter-spacing: .04em; }

@media (max-width: 900px) {
  .site-header { height: 68px; }
  .app-shell { grid-template-columns: 1fr; gap: 28px; padding-top: 8px; }
  .channels-panel { height: auto; min-height: 460px; padding: 0; border: 0; background: transparent; box-shadow: none; }
  .channels-panel { margin-top: 0; }
  .channel-list { max-height: none; overflow: visible; }
  .channel-row { min-height: 72px; border-color: #212530; }
}

@media (max-width: 560px) {
  .site-header, .app-shell, footer { padding-inline: 12px; }
  .site-header { height: 62px; }
  .live-badge { font-size: 0; }
  .header-tools { gap: 9px; }
  .admin-link { padding: 7px 9px; font-size: 10px; }
  .install-button { position: fixed; z-index: 40; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); padding: 11px 14px; border-color: var(--accent); color: #fff; background: var(--accent); box-shadow: 0 10px 30px #0008; }
  .app-shell { padding-top: 5px; padding-bottom: 26px; gap: 30px; }
  .player-heading { margin-inline: 4px; }
  .player-status { display: none; }
  h1 { max-width: 88vw; font-size: 23px; }
  .player-shell { width: calc(100% + 24px); margin-left: -12px; border-inline: 0; border-radius: 0; }
  .player-shell.retro-mode { aspect-ratio: 1 / 1; }
  .retro-mode .player-stage { top: 0; bottom: auto; width: 100%; height: auto; aspect-ratio: 4 / 3; transform: scale(1.27); transform-origin: center top; }
  .normal-mode .player-stage { transform: none; }
  .mode-control { margin: 12px 0 0; }
  .mode-control small { font-size: 10px; }
  .panel-heading { align-items: center; }
  .search-box { width: 135px; }
  .category-nav { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-right: 0; padding-right: 0; }
  footer { gap: 14px; padding-block: 20px; }
  footer span:last-child { text-align: right; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
