:root {
  --bg: #121826;
  --panel: #1a2336;
  --panel-2: #222d45;
  --line: #2c3a58;
  --text: #e9edf5;
  --muted: #94a0b8;
  --live: #ff5a4e;
  --accent: #5ab0ff;
  --radius: 8px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* иначе display:grid/flex перебивает атрибут hidden */
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app { display: grid; grid-template-columns: 340px minmax(0, 1fr); height: 100%; }

/* ---------- Боковая панель ---------- */
.side { display: flex; flex-direction: column; background: var(--panel); border-right: 1px solid var(--line); min-width: 0; min-height: 0; overflow: hidden; }
.brand-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 12px; border-bottom: 1px solid var(--line); }
.brand { font-size: 26px; font-weight: 800; letter-spacing: .06em; line-height: 1; }
.brand b { color: var(--live); }
.close-side { display: none; background: none; border: 0; font-size: 30px; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 6px; }

.side-head { padding: 12px; display: grid; gap: 8px; border-bottom: 1px solid var(--line); min-width: 0; }
.side-head input[type=search], .side-head select {
  width: 100%; min-width: 0; padding: 9px 11px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
}
.fav-only { color: var(--muted); font-size: 13px; display: flex; gap: 6px; align-items: center; }

.list { list-style: none; margin: 0; padding: 0; overflow-x: hidden; overflow-y: auto; flex: 1; min-height: 0; }
.ch { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; border-bottom: 1px solid var(--line); }
.ch:hover { background: var(--panel-2); }
.ch.active { background: var(--panel-2); box-shadow: inset 3px 0 0 var(--live); }
.ch-link { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 10px; align-items: center; padding: 9px 4px 9px 12px; min-width: 0; }
.ch .star { color: var(--muted); background: none; border: 0; cursor: pointer; font-size: 18px; padding: 8px 12px 8px 6px; }
.ch .star.on { color: #ffc94d; }
.logo { width: 44px; height: 32px; object-fit: contain; background: #fff1; border-radius: 4px; }
.logo.none { display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.mid { min-width: 0; }
.name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prog { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini { height: 2px; background: var(--line); margin-top: 5px; border-radius: 2px; overflow: hidden; }
.mini i { display: block; height: 100%; background: var(--live); }
.empty { padding: 24px 16px; color: var(--muted); list-style: none; }

.side-foot { padding: 12px 14px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 10px; }
.side-foot a { color: var(--accent); }
.side-foot a:hover { text-decoration: underline; }

/* ---------- Основная часть ---------- */
.main { min-width: 0; min-height: 0; overflow-y: auto; overflow-x: hidden; }

.home { padding: 28px 28px 48px; max-width: 1100px; }
.home h1 { font-size: 28px; margin: 0 0 10px; }
.home h2 { font-size: 18px; margin: 28px 0 12px; }
.lead { color: var(--muted); margin: 8px 0 0; max-width: 70ch; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.card { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 12px; align-items: center; padding: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.card:hover { border-color: var(--accent); }
.card .logo { width: 48px; height: 36px; }

/* Плеер без затемнения; сообщения — маленькая плашка, а не заливка поверх видео */
.player-wrap { position: relative; background: #000; width: 100%; aspect-ratio: 16 / 9; min-height: 220px; max-height: calc(100vh - 210px); }
video { width: 100%; height: 100%; display: block; background: #000; object-fit: contain; }
.msg { position: absolute; left: 50%; bottom: 60px; transform: translateX(-50%); max-width: 90%; padding: 8px 14px; border-radius: var(--radius); background: rgba(10, 14, 24, .85); font-size: 14px; text-align: center; pointer-events: none; }

.now { padding: 14px 20px 6px; }
.now-top { display: flex; align-items: center; gap: 10px; }
.now h1 { font-size: 20px; margin: 0; flex: 1; min-width: 0; }
.fav { background: none; border: 1px solid var(--line); border-radius: var(--radius); color: var(--muted); cursor: pointer; font-size: 18px; padding: 2px 10px; }
.fav[aria-pressed=true] { color: #ffc94d; border-color: #ffc94d66; }
.list-btn { display: none; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 12px; cursor: pointer; }
.now-title { margin: 6px 0 8px; font-size: 17px; }
.bar { height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; max-width: 560px; }
.bar i { display: block; height: 100%; background: var(--live); width: 0; }
.now-time { color: var(--muted); font-size: 13px; margin: 6px 0 0; min-height: 1.4em; }
.now .lead { font-size: 13px; }

.epg { padding: 10px 20px 30px; }
.epg-h { font-size: 16px; margin: 6px 0 10px; }
.days { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; }
.day { flex: none; padding: 6px 12px; border: 1px solid var(--line); background: transparent; border-radius: 999px; cursor: pointer; color: var(--muted); }
.day.active { background: var(--accent); border-color: var(--accent); color: #07131f; font-weight: 600; }
/* Программа прокручивается внутри своего блока, страница при этом не двигается */
.epg-list { list-style: none; margin: 0; padding: 0; max-width: 820px; position: relative; max-height: min(50vh, 440px); overflow-y: auto; }
.pr { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.pr .t { color: var(--muted); font-variant-numeric: tabular-nums; }
.pr .ti { font-weight: 600; }
.pr .ds { color: var(--muted); font-size: 13px; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pr.cur .t, .pr.cur .ti { color: var(--live); }
.pr.past { opacity: .55; }

/* ---------- Мобильная версия ---------- */
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; inset: 0; z-index: 10; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; }
  .close-side, .list-btn { display: block; }
  .player-wrap { max-height: none; }
  .home { padding: 20px 16px 40px; }
  .home h1 { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) { .side { transition: none; } }
