/* TvTube — три колонки: каналы · программа · экран */

:root {
  --bg: #0f1012;
  --card: #17181b;
  --raised: #202125;
  --hover: #26272c;
  --line: #2a2c31;
  --text: #ececee;
  --muted: #9c9da6;
  --dim: #6c6d75;
  --red: #ff2321;
  --red-btn: #e21f1d;
  --red-text: #ff5d55;
  --red-soft: rgba(255, 35, 33, .12);
  --radius: 12px;
  --radius-sm: 8px;
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { display: block; }
button, input, select { font: inherit; color: inherit; }

/* ---------- Сетка ---------- */
.tt {
  display: grid;
  grid-template-columns: 300px 360px minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas:
    "head guide view"
    "cat  guide view"
    "cat  foot  view";
  gap: 12px;
  height: 100vh;
  height: 100dvh;
  padding: 12px;
}
.tt-head  { grid-area: head; }
.tt-cat   { grid-area: cat; }
.tt-guide { grid-area: guide; }
.tt-foot  { grid-area: foot; }
.tt-view  { grid-area: view; }

.tt-head, .tt-cat, .tt-guide, .tt-view, .tt-foot {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 0;
}

/* ---------- Шапка: логотип и поиск ---------- */
.tt-head { padding: 14px 14px 12px; border-bottom-left-radius: 0; border-bottom-right-radius: 0; border-bottom: 0; }
.tt-head + .tt-view { }
.tt-logo { display: block; width: 128px; margin: 0 auto 12px; }
.tt-logo img { width: 128px; height: auto; }
.tt-find { display: grid; grid-template-columns: 1fr; gap: 8px; }
.tt-find__q, .tt-find__cat {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
}
.tt-find__q::placeholder { color: var(--dim); }
.tt-find__q:focus, .tt-find__cat:focus { border-color: var(--red); }
.tt-find__cat { cursor: pointer; }
.tt-find__cat option { background: var(--card); }

/* ---------- Список каналов ---------- */
.tt-cat {
  display: flex;
  flex-direction: column;
  margin-top: -12px;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  border-top: 0;
}
.tt-cat__bar {
  display: flex;
  justify-content: space-between;
  padding: 8px 16px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--dim);
}
.tt-cat__count { color: var(--muted); }
.tt-cat__list { flex: 1; overflow-y: auto; padding: 6px; min-height: 0; }
.tt-cat__empty { padding: 20px 12px; color: var(--muted); font-size: 14px; text-align: center; }

.ch {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  border-left: 3px solid transparent;
}
.ch[hidden] { display: none; }
.ch:hover { background: var(--hover); }
.ch.is-on { background: var(--raised); border-left-color: var(--red); }
.ch__logo { width: 44px; height: 44px; flex-shrink: 0; }
.ch__txt { display: flex; flex-direction: column; min-width: 0; }
.ch__name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch__now { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch__now:empty { display: none; }
.ch.is-on .ch__now { color: var(--red-text); }

/* Логотипы каналов: белая рамка вокруг картинки, чтобы рисунок не упирался в край */
.ch__logo, .air__logo, .info__logo, .tile__logo {
  box-sizing: border-box;
  padding: 3px;
  background: #fff;
  border-radius: 8px;
  object-fit: contain;
}
.air__logo { padding: 2px; border-radius: 6px; }
.info__logo { padding: 4px; border-radius: 10px; }

/* ---------- Средняя колонка: программа ---------- */
.tt-guide { display: flex; flex-direction: column; overflow: hidden; }
.gd-head { flex-shrink: 0; padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.gd-title { font-size: 17px; font-weight: 700; line-height: 1.3; }
.gd-sub { display: block; margin-top: 2px; font-size: 13px; color: var(--muted); }
.gd-list { flex: 1; overflow-y: auto; min-height: 0; padding: 4px 6px 8px; }
.gd-empty { padding: 24px 12px; color: var(--muted); font-size: 14px; text-align: center; }

.days { flex-shrink: 0; display: flex; gap: 4px; padding: 8px 10px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.days::-webkit-scrollbar { display: none; }
.days__b {
  flex-shrink: 0;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: none;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}
.days__b:hover { color: var(--text); }
.days__b.is-on { background: var(--red-btn); border-color: var(--red-btn); color: #fff; }

.prog { list-style: none; }
.pr { display: grid; grid-template-columns: 48px 1fr; gap: 8px; padding: 9px 10px; border-radius: var(--radius-sm); }
.pr + .pr { border-top: 1px solid var(--line); }
.pr.is-now + .pr, .pr + .pr.is-now { border-top-color: transparent; }
.pr__time { font-size: 13px; font-variant-numeric: tabular-nums; color: var(--muted); padding-top: 1px; }
.pr__t { font-size: 14px; font-weight: 600; }
.pr__g { display: block; margin-top: 2px; font-size: 12px; color: var(--dim); }
.pr__about { margin-top: 6px; font-size: 13px; color: var(--muted); line-height: 1.5; }
.pr details summary { cursor: pointer; list-style: none; }
.pr details summary::-webkit-details-marker { display: none; }
.pr details summary::after { content: " +"; color: var(--dim); font-size: 13px; }
.pr details[open] summary::after { content: " −"; }
.pr.is-past { opacity: .5; }
.pr.is-now { background: var(--red-soft); }
.pr.is-now .pr__time { color: var(--red-text); font-weight: 700; }
.pr.is-now .pr__time::after { content: "в эфире"; display: block; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.age { display: inline-block; padding: 0 4px; border: 1px solid var(--line); border-radius: 4px; font-size: 11px; color: var(--dim); vertical-align: 1px; }

.bar { display: block; height: 3px; margin-top: 6px; background: var(--line); border-radius: 2px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--red); }

/* «Сейчас в эфире» на главной и в разделах */
.air { display: flex; gap: 10px; padding: 9px 8px; border-radius: var(--radius-sm); }
.air + .air { border-top: 1px solid var(--line); }
.air:hover { background: var(--hover); }
.air__logo { width: 36px; height: 36px; padding: 2px; flex-shrink: 0; }
.air__body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.air__ch { font-size: 12px; color: var(--muted); }
.air__t { color: var(--dim); font-variant-numeric: tabular-nums; }
.air__show { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Подвал (под программой) ---------- */
.tt-foot { padding: 10px 14px; font-size: 12px; color: var(--dim); line-height: 1.6; }
.tt-foot a { color: var(--muted); }
.tt-foot a:hover { color: var(--text); }
.tt-foot__cats { margin-bottom: 4px; }

/* ---------- Правая колонка ---------- */
.tt-view { display: flex; flex-direction: column; overflow: hidden; }
.view-scroll { flex: 1; overflow-y: auto; min-height: 0; padding: 22px 26px 28px; }

.pl { position: relative; background: #000; aspect-ratio: 16 / 9; flex-shrink: 0; max-height: 62vh; }
.pl__video { width: 100%; height: 100%; display: block; background: #000; object-fit: contain; }
.pl__msg {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 20px; text-align: center; background: rgba(10, 10, 12, .92);
}
.pl__msg[hidden] { display: none; }
.pl__msg-t { font-size: 18px; font-weight: 700; }
.pl__msg-s { max-width: 420px; font-size: 14px; color: var(--muted); }
.pl__sound {
  position: absolute; left: 14px; top: 14px;
  padding: 8px 14px; border: 0; border-radius: var(--radius-sm);
  background: var(--red-btn); color: #fff; font-weight: 600; font-size: 14px; cursor: pointer;
}
.pl__sound[hidden] { display: none; }

.btn {
  display: inline-block; padding: 9px 18px; border: 0; border-radius: var(--radius-sm);
  background: var(--red-btn); color: #fff; font-weight: 600; font-size: 14px; cursor: pointer;
}
.btn:hover { background: var(--red); }

.crumbs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; font-size: 13px; color: var(--dim); }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--text); }

.info { padding-top: 16px; }
.info__head { display: flex; align-items: center; gap: 14px; }
.info__logo { width: 56px; height: 56px; padding: 4px; flex-shrink: 0; }
h1 { font-size: 24px; line-height: 1.25; font-weight: 700; letter-spacing: -.01em; }
.nowline { margin-top: 12px; font-size: 14px; color: var(--text); }
.nowline:empty { display: none; }
.nowline b { color: var(--red-text); font-weight: 600; }
.muted { color: var(--muted); }
.info__text { margin-top: 12px; font-size: 15px; color: #c9cad0; line-height: 1.65; max-width: 860px; }

.hero { margin-bottom: 22px; }
.hero h1 { font-size: 28px; }
.lead { margin-top: 10px; font-size: 16px; color: #c9cad0; line-height: 1.6; max-width: 820px; }
.hero .muted { margin-top: 8px; font-size: 14px; }
.hero .btn { margin-top: 14px; }

.block { margin-top: 26px; }
.block__title { font-size: 17px; font-weight: 700; margin-bottom: 12px; }
.block__title a { color: var(--red-text); }
.block--text p { color: #c9cad0; line-height: 1.65; max-width: 860px; }
.block--text p + p { margin-top: 10px; }
.block--text a, .lead a { color: var(--red-text); }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.tile {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  min-height: 80px;
  padding: 12px 14px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--raised);
  overflow: hidden;
  transition: border-color .15s, background-color .15s;
}
.tile:hover { border-color: rgba(255, 35, 33, .55); background: var(--hover); }
.tile__logo { width: 56px; height: 56px; flex-shrink: 0; padding: 4px; border-radius: 10px; }
.tile__body { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.tile__name { font-weight: 700; font-size: 15px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile__now { font-size: 13px; color: #c9cad0; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile__time { font-size: 12px; color: var(--dim); font-variant-numeric: tabular-nums; }
.tile__bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--line); }
.tile__bar > span { display: block; height: 100%; background: var(--red); }

/* Компактные плитки: «Ещё в разделе» */
.tiles--sm { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.tiles--sm .tile { min-height: 64px; padding: 9px 12px; gap: 10px; }
.tiles--sm .tile__logo { width: 44px; height: 44px; padding: 3px; border-radius: 8px; }
.tiles--sm .tile__name { font-size: 14px; }
.tiles--sm .tile__now { font-size: 12px; -webkit-line-clamp: 1; white-space: nowrap; text-overflow: ellipsis; display: block; }
.tiles--sm .tile__time { display: none; }

.cats { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.cat { display: block; padding: 12px 14px; border: 1px solid var(--line); border-left: 3px solid var(--red); border-radius: var(--radius-sm); background: var(--raised); }
.cat:hover { background: var(--hover); }
.cat__name { display: flex; justify-content: space-between; font-weight: 700; }
.cat__n { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.cat__ex { display: block; margin-top: 2px; font-size: 13px; color: var(--muted); }

.genres { margin-top: 20px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; }
.chips li { padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: 13px; color: var(--muted); }
.chips span { color: var(--text); font-weight: 600; margin-left: 2px; }

/* ---------- Полосы прокрутки ---------- */
.tt-cat__list, .gd-list, .view-scroll { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.tt-cat__list::-webkit-scrollbar, .gd-list::-webkit-scrollbar, .view-scroll::-webkit-scrollbar { width: 6px; }
.tt-cat__list::-webkit-scrollbar-thumb, .gd-list::-webkit-scrollbar-thumb, .view-scroll::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

/* ---------- Ноутбуки ---------- */
@media (max-width: 1250px) {
  .tt { grid-template-columns: 270px 310px minmax(0, 1fr); }
  .view-scroll { padding: 18px 20px 24px; }
}

/* ---------- Планшеты и телефоны: колонки друг под другом ---------- */
@media (max-width: 900px) {
  body { overflow: auto; }
  .tt {
    display: flex;
    flex-direction: column;
    height: auto;
    padding: 0;
    gap: 0;
  }
  .tt-head, .tt-cat, .tt-guide, .tt-view, .tt-foot { border-radius: 0; border-left: 0; border-right: 0; }
  .tt-head { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
  .tt-logo { width: 84px; margin: 0; flex-shrink: 0; }
  .tt-logo img { width: 84px; }
  .tt-find { flex: 1; grid-template-columns: 1fr 120px; gap: 6px; }
  .tt-find__q, .tt-find__cat { height: 36px; font-size: 14px; }
  .tt-view { overflow: visible; border-top: 0; }
  .view-scroll { overflow: visible; padding: 16px; }
  .pl { max-height: none; }
  .tt-guide { max-height: 70vh; margin-top: 10px; }
  .tt-cat { margin-top: 10px; border-top: 1px solid var(--line); }
  .tt-cat__bar { border-top: 0; }
  .tt-cat__list { max-height: 80vh; }
  .tt-foot { margin-top: 10px; padding: 14px 16px 20px; }
  h1, .hero h1 { font-size: 21px; }
  .lead { font-size: 15px; }
}

@media (max-width: 480px) {
  .tt-find { grid-template-columns: 1fr 96px; }
  .tiles { grid-template-columns: 1fr; }
  .cats { grid-template-columns: 1fr; }
  .tiles--sm { grid-template-columns: 1fr 1fr; }
  .tiles--sm .tile { flex-direction: column; align-items: flex-start; gap: 6px; }
  .tt-find__cat { font-size: 13px; padding: 0 8px; }
  .info__logo { width: 44px; height: 44px; }
}
