/* ============================================================
   Тема оформления: CSS-переменные + светлая/тёмная тема
   Переключение — атрибутом data-theme="light" на <html>.
   ============================================================ */
:root {
  --bg: #12141c;
  --bg-alt: #171a24;
  --surface: #1c1f2b;
  --surface-hover: #202744;
  --border: #2a2e3f;
  --text: #eaeaf0;
  --text-dim: #9a9ab0;
  --text-bright: #ffffff;
  --accent: #5b6cff;
  --accent-hover: #4756d6;
  --accent-soft: rgba(91, 108, 255, 0.15);
  --success: #2e7d32;
  --success-hover: #245f27;
  --danger: #c0392b;
  --danger-hover: #992d22;
  --warning: #c58a1a;
  --warning-soft: rgba(197, 138, 26, 0.18);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  --radius: 12px;
}

html[data-theme="light"] {
  --bg: #f4f5fa;
  --bg-alt: #eceef6;
  --surface: #ffffff;
  --surface-hover: #eef0ff;
  --border: #dde0ee;
  --text: #23253a;
  --text-dim: #6b6f8a;
  --text-bright: #14152a;
  --accent: #4a5aeb;
  --accent-hover: #3946c4;
  --accent-soft: rgba(74, 90, 235, 0.10);
  --success: #2e7d32;
  --success-hover: #245f27;
  --danger: #c0392b;
  --danger-hover: #992d22;
  --warning: #a5680f;
  --warning-soft: rgba(165, 104, 15, 0.12);
  --shadow: 0 8px 24px rgba(30, 34, 70, 0.08);
}

* { box-sizing: border-box; }

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 0;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 30px 20px 60px;
}
.container.narrow { max-width: 400px; }
.container.wide { max-width: 1180px; }

/* ---------- Раскладка: плеер слева (всегда виден), каналы справа ---------- */
.layout {
  display: flex;
  align-items: flex-start;
  gap: 28px;
  margin-top: 20px;
}
.player-column {
  flex: 1 1 460px;
  min-width: 380px;
  max-width: 560px;
  position: sticky;
  top: 16px;
  align-self: flex-start;
}
.player-column .deck { margin-top: 0; }

/* ---------- Панель для видео-каналов (mpegts.js в <video>) ---------- */
.video-panel {
  margin-bottom: 16px;
  border-radius: 14px;
  overflow: hidden;
  background: #0b0b12;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}
.video-panel video {
  display: block;
  width: 100%;
  max-height: 420px;
  background: #000;
}
/* Обёртка над <video>, чтобы поверх картинки можно было позиционировать
   всплывающую плашку с названием файла (video-osd). */
.video-stage {
  position: relative;
}
/* Плашка "сейчас играет", которая на несколько секунд появляется поверх
   видео при старте канала и при смене файла в плейлисте, а затем сама
   плавно скрывается — не мешает постоянно висящему футеру под видео. */
.video-osd {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  max-width: calc(100% - 24px);
  width: fit-content;
  padding: 7px 14px;
  border-radius: 8px;
  background: rgba(10, 10, 16, 0.72);
  backdrop-filter: blur(4px);
  color: #fff;
  font-size: 0.88rem;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.4s ease, transform 0.4s ease;
  z-index: 2;
}
.video-osd.show {
  opacity: 1;
  transform: translateY(0);
}
.video-panel-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  background: #14141f;
}
.video-panel-title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.9rem;
  color: #cfd2e6;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.video-audio-badge {
  flex: 0 0 auto;
  font-size: 0.78rem;
  color: #cfd2e6;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}
.video-stop-btn {
  flex: 0 0 auto;
  /* У переменных --deck-ink/--deck-btn нет значения вне .deck (эта кнопка
     стоит вне него в разметке) - без fallback здесь текст откатывался на
     унаследованный светлый цвет, а на :hover фон становился белым (#fff),
     из-за чего текст исчезал. Задаём fallback явно. */
  background: linear-gradient(180deg, #f2ede2, var(--deck-btn, #e7e1d3));
  border: 1px solid #8d8570;
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: var(--deck-ink, #2b2823);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.2);
}
.video-stop-btn:hover { background: #fff; color: var(--deck-ink, #2b2823); }
.video-stop-btn:active { transform: translateY(1px); box-shadow: none; }
.video-stop-btn .ico { font-size: 11px; }

.channels-column {
  flex: 1 1 320px;
  min-width: 260px;
}

/* ---------- Плавающая кнопка "Выбрать канал" (только мобильные экраны) ---------- */
.mobile-select-channel-btn {
  display: none;
}

@media (max-width: 980px) {
  .layout {
    flex-direction: column;
    gap: 16px;
  }
  .player-column {
    flex: none;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--bg);
    padding-bottom: 10px;
    box-shadow: 0 8px 12px -8px rgba(0, 0, 0, 0.35);
  }

  .channels-column {
    width: 100%;
    min-width: 0;
  }

  .mobile-select-channel-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 40;
    background: linear-gradient(180deg, var(--accent), var(--accent-hover));
    color: #fff;
    border: none;
    border-radius: 999px;
    padding: 13px 20px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 10px 20px -6px rgba(0, 0, 0, 0.45);
  }
  .mobile-select-channel-btn:active { transform: translateY(1px); }
  .mobile-select-channel-icon { font-size: 16px; }
  .mobile-select-channel-arrow { font-size: 11px; opacity: 0.85; }
}

/* ---------- Заголовок блока со списками каналов ---------- */
.channels-column-title {
  margin: 24px 0 12px;
  font-size: 18px;
  color: var(--text-bright);
}

/* ---------- Всплывающее окно со списком каналов выбранной категории ---------- */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, 0.55);
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop.open {
  display: flex;
}

.channel-modal {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 480px;
  max-height: min(640px, 85vh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.channels-overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border);
}
.channels-overlay-title { margin: 0; font-size: 18px; color: var(--text-bright); flex: 1; min-width: 0; }
.channels-back-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  width: 38px;
  height: 38px;
  min-width: 38px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.category-row-modal { margin: 0; }
.channels-close-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  width: 38px;
  height: 38px;
  min-width: 38px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.channel-modal-body {
  padding: 14px 18px 18px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.channel-modal-group-heading {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 6px 0 -2px;
}
.channel-modal-group-heading:first-child { margin-top: 0; }

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}
.page-header-text { flex: 1; min-width: 0; }

h1 {
  color: var(--text-bright);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 28px;
}
.subtitle { color: var(--text-dim); margin-top: 0; }

/* ---------- Переключатель темы (солнце/луна) ---------- */
.theme-toggle {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  width: 42px;
  height: 42px;
  min-width: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.theme-toggle:hover { border-color: var(--accent); transform: translateY(-1px); }

/* ---------- Списки тем (Музыка / Аудиокниги) — карточки в один ряд ---------- */
.category-row {
  margin: 0 0 24px;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 14px;
}

.category-card {
  flex: 1 1 140px;
  min-width: 140px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: border-color 0.15s ease, transform 0.1s ease, background 0.15s ease;
}
.category-card:hover { border-color: var(--accent); background: var(--surface-hover); }
.category-card:active { transform: translateY(1px); }
.category-card.is-empty { opacity: 0.65; }

.category-card-icon { font-size: 26px; line-height: 1; }
.category-card-label {
  font-weight: 600;
  color: var(--text-bright);
  font-size: 16px;
  text-align: center;
}
.category-card-count {
  color: var(--text-dim);
  font-size: 13px;
}

.category-row-note { flex: 1 1 100%; margin-top: -10px; }

/* ---------- Карточки каналов ---------- */
.channels-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.channel-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 18px;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.1s ease;
}
.channel-item:hover { border-color: var(--accent); }
.channel-item.active { border-color: var(--accent); background: var(--surface-hover); }

.channel-item .meta { color: var(--text-dim); font-size: 13px; }
.badge {
  background: var(--border);
  color: var(--text-dim);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 12px;
  white-space: nowrap;
}
.badge.live { background: var(--success); color: #fff; }
.badge-warning { background: var(--warning-soft); color: var(--warning); }

.player-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  margin-top: 20px;
  box-shadow: var(--shadow);
}
#now-playing { margin-bottom: 12px; color: var(--text); }
audio { width: 100%; }

.empty-note {
  color: var(--text-dim);
  padding: 14px 18px;
}

.form-box { display: flex; flex-direction: column; gap: 10px; }
.form-box label { color: var(--text-dim); font-size: 13px; }
input[type=text], input[type=password], input[type=file] {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  color: var(--text);
}

.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
  font-size: 14px;
}
.btn:hover { background: var(--accent-hover); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: var(--danger-hover); }
.btn-success { background: var(--success); }
.btn-success:hover { background: var(--success-hover); }
.btn-secondary { background: var(--border); color: var(--text); text-decoration:none; padding: 10px 16px; border-radius: 8px; display: inline-block;}
.btn-secondary:hover { background: var(--surface-hover); }

.flash {
  background: var(--accent-soft);
  border-left: 4px solid var(--accent);
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 16px;
  color: var(--text);
}

.admin-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.admin-header-actions { display: flex; align-items: center; gap: 10px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 18px;
}

.channel-title { display: flex; justify-content: space-between; align-items: center; }
.status { padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: bold; }
.status.on { background: var(--success); color: #fff; }
.status.off { background: var(--border); color: var(--text-dim); }

/* ---------- Вкладки-фильтры "Музыка" / "Аудиокниги" ---------- */
.category-tabs {
  display: flex;
  gap: 10px;
  margin: 12px 0 18px;
  flex-wrap: wrap;
}
.category-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 20px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.category-tab:hover {
  border-color: var(--accent);
  color: var(--text-bright);
}
.category-tab.is-active {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}
.category-tab .badge {
  background: var(--border);
  color: var(--text-dim);
}
.category-tab.is-active .badge {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
}

/* ---------- Разделы каналов по теме вещания ---------- */
.channel-category-section {
  margin-bottom: 26px;
}
.channel-category-section.is-hidden {
  display: none;
}
.channel-category-heading {
  margin: 0 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.channel-category-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
  margin-bottom: 10px;
}
.channel-category-heading-row .channel-category-heading {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0;
}
.category-bulk-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.start-all-btn,
.stop-all-btn,
.delete-all-btn {
  font-size: 13px;
  padding: 7px 14px;
  white-space: nowrap;
}
.start-all-btn[disabled],
.stop-all-btn[disabled],
.delete-all-btn[disabled] { opacity: 0.6; cursor: not-allowed; }

/* ---------- Сетка карточек каналов ---------- */
.channels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
  align-items: start;
  margin-top: 12px;
}
.channel-card {
  margin-bottom: 0;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.channel-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

/* ---------- Компактная шапка карточки (всегда видна) ----------
   Раньше шапка была одной строкой на flex-wrap, и то, где именно перенос
   строки происходил, зависело от длины названия канала — из-за этого
   карточки с разными названиями выглядели по-разному (у одних карточек
   кнопки оказывались на первой строке, у других — переезжали на вторую).
   Теперь раскладка зафиксирована явно: верхняя строка — только название
   со статусом, нижняя — кнопки. Так все карточки выглядят одинаково
   независимо от текста. */
.channel-header {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.channel-header-top {
  display: flex;
  align-items: center;
}
.channel-header-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.channel-toggle {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 10px 10px;
  background: none;
  border: none;
  padding: 4px 2px;
  margin: 0;
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: left;
  width: 100%;
  min-width: 0;
}
.channel-toggle-chevron {
  color: var(--accent);
  font-size: 13px;
  flex: none;
  margin-top: 2px;
  transition: transform 0.15s ease;
}
.channel-card.expanded .channel-toggle-chevron { transform: rotate(90deg); }
.channel-name {
  font-weight: 600;
  color: var(--text-bright);
  font-size: 16px;
  white-space: normal;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  word-break: break-word;
  flex: 1 1 auto;
  min-width: 0;
}
.badge-listeners { flex: none; }
.channel-header-actions { display: flex; gap: 8px; flex: none; }
/* Кнопки быстрых действий и переименования не должны открывать модалку —
   клик по ним останавливает всплытие в JS; курсор тоже подсказывает, что
   это самостоятельные элементы управления, а не часть открывающей зоны. */
.channel-header-actions, .channel-rename-toggle, .channel-rename-inline { cursor: default; }

.channel-rename-toggle {
  background: var(--border);
  border: none;
  color: var(--text-dim);
  border-radius: 8px;
  width: 30px;
  height: 30px;
  min-width: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  flex: none;
}
.channel-rename-toggle:hover { background: var(--surface-hover); color: var(--accent); }

.channel-rename-inline {
  display: none;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.channel-rename-inline.open { display: flex; }
.channel-rename-inline input[type=text] { min-width: 160px; flex: 1 1 200px; }

/* ---------- Модальное окно карточки канала ----------
   Тело карточки больше не разворачивается внутри сетки (это и вызывало
   "дёргание" при сотнях треков в списках — браузер пересчитывал раскладку
   всей грид-сетки на каждом кадре анимации). Вместо этого .channel-body
   превращается в лёгкий плавающий диалог поверх страницы: он вынут из
   потока (position: fixed), поэтому открытие/закрытие вообще не трогает
   раскладку сетки карточек, независимо от объёма содержимого внутри.

   Важно: JS переносит .channel-body из карточки прямо в <body> (см.
   admin.html). Без этого переноса position: fixed переставало бы работать
   относительно окна браузера, как только у родительской .channel-card
   появлялся transform (например, от hover-эффекта подъёма карточки) — по
   спецификации CSS элемент с transform становится новой "точкой отсчёта"
   для fixed-потомков, и диалог резко прыгал бы в другое место при наведении
   мыши на карточку позади него. Вынеся диалог в <body>, мы избавляемся от
   этого класса багов целиком, а не только от конкретного hover-эффекта. */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 11, 18, 0.6);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease;
  z-index: 150;
}
.modal-overlay.open { opacity: 1; visibility: visible; }
body.modal-open { overflow: hidden; }

.channel-body {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -48%) scale(0.97);
  width: min(640px, calc(100vw - 32px));
  max-height: min(82vh, 720px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  cursor: default;
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
}
.channel-body.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.channel-modal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex: none;
}
.channel-modal-title {
  font-weight: 700;
  font-size: 17px;
  color: var(--text-bright);
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.channel-modal-close {
  background: var(--border);
  border: none;
  color: var(--text-dim);
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 15px;
  flex: none;
}
.channel-modal-close:hover { background: var(--surface-hover); color: var(--text); }

.channel-modal-scroll {
  padding: 16px 20px 22px;
  overflow-y: auto;
  flex: 1 1 auto;
}

@media (max-width: 640px) {
  .channel-body {
    width: calc(100vw - 20px);
    max-height: 88vh;
  }
}

/* ---------- Компактная строка статистики (бейджи вместо отдельных <p>) ---------- */
.channel-stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}

.stream-link-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 10px 0;
}

@media (max-width: 640px) {
  .channels-grid { grid-template-columns: 1fr; }
}

.actions { display: flex; gap: 10px; margin: 14px 0; }
.upload-section { display: flex; flex-direction: column; gap: 14px; border-top: 1px solid var(--border); padding-top: 14px; }
.inline-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
code { background: var(--bg); padding: 2px 6px; border-radius: 4px; }
a { color: var(--accent); }

.meta-inline { color: var(--text-dim); font-size: 13px; margin-left: 6px; }

.category-select-row { margin: 8px 0 4px; }

.mode-section, .playlists-section {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.mode-section h4, .playlists-section h4 { margin: 0 0 4px; color: var(--text); font-size: 14px; }

.radio-label { display: flex; align-items: center; gap: 6px; color: var(--text); font-size: 14px; cursor: pointer; }

select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
}

.playlist-block {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.playlist-block.playlist-active { border-color: var(--accent); }
.playlist-block-header { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.playlist-playback-options { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }

.channel-details {
  border-top: 1px solid var(--border);
  margin-top: 14px;
  padding-top: 4px;
}
.channel-details > summary {
  cursor: pointer;
  list-style: none;
  color: var(--text-dim);
  font-size: 13px;
  padding: 10px 0;
  user-select: none;
}
.channel-details > summary::-webkit-details-marker { display: none; }
.channel-details > summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 8px;
  color: var(--accent);
  transition: transform 0.15s ease;
}
.channel-details[open] > summary::before { transform: rotate(90deg); }
.channel-details > summary:hover { color: var(--text); }
.channel-details[open] > summary { color: var(--text); border-bottom: 1px solid var(--border); margin-bottom: 10px; }
.channel-details .mode-section { border-top: none; margin-top: 0; padding-top: 0; }

.tiny-form { gap: 0; }
.btn-small { padding: 6px 10px; font-size: 12px; }

/* ---------- Переключатели тем вещания (админка) ---------- */
.category-toggle-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}
.category-toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.category-toggle-label {
  min-width: 110px;
  font-weight: 600;
  color: var(--text);
}
.switch {
  position: relative;
  width: 46px;
  height: 26px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  padding: 0;
  flex: none;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.switch .switch-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: transform 0.15s ease, background-color 0.15s ease;
}
.switch.on {
  background: var(--success);
  border-color: var(--success);
}
.switch.on .switch-knob {
  transform: translateX(20px);
  background: #fff;
}

/* ============================================================
   Дека Dual C 828 — визуальная стилизация плеера под кассетную деку.
   Цвета деки фиксированы (не завязаны на тему сайта) — это "фотография"
   реального устройства, а не элемент UI-темы.
   ============================================================ */
.deck {
  --deck-metal-1: #d9d2c1;
  --deck-metal-2: #c7bfab;
  --deck-metal-3: #b7ae98;
  --deck-ink: #2b2823;
  --deck-ink-soft: #55503f;
  --deck-panel: #26282a;
  --deck-panel-2: #1c1e1f;
  --deck-led-green: #34e06b;
  --deck-led-green-dim: #1f4f31;
  --deck-led-red: #ff3b3b;
  --deck-led-red-dim: #5e2323;
  --deck-led-teal: #37c6c1;
  --deck-led-amber: #e8a72e;
  --deck-btn: #e7e1d3;
  --deck-btn-shadow: #8d8570;
  margin-top: 24px;
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.35), rgba(0,0,0,0.06) 6%, rgba(0,0,0,0) 12%),
    linear-gradient(155deg, var(--deck-metal-1), var(--deck-metal-2) 55%, var(--deck-metal-3));
  border: 1px solid #94897149;
  box-shadow: 0 14px 34px rgba(0,0,0,0.35), inset 0 0 0 1px rgba(255,255,255,0.25);
  padding: 14px 18px 18px;
  color: var(--deck-ink);
  user-select: none;
  font-family: 'Segoe UI', Arial, sans-serif;
  position: relative;
}
.deck.powered-off { filter: grayscale(0.55) brightness(0.82); }

.deck-topbar {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding-bottom: 8px;
  margin-bottom: 10px;
  border-bottom: 1px solid rgba(0,0,0,0.18);
}
.deck-brand { font-family: Georgia, 'Times New Roman', serif; font-style: italic; font-size: 20px; font-weight: 700; }
.deck-model { font-weight: 700; letter-spacing: 1px; font-size: 15px; }
.deck-sub { font-size: 11px; color: var(--deck-ink-soft); }
.deck-motors { margin-left: auto; font-size: 11px; font-weight: 700; letter-spacing: 0.5px; }

.deck-body {
  display: flex;
  gap: 16px;
  align-items: stretch;
}
.deck-col { display: flex; flex-direction: column; align-items: center; }
.deck-col-left { gap: 4px; flex: 0 0 auto; padding-top: 4px; }
.deck-col-left .col-label { margin: 0 0 10px; }
.deck-col-center { flex: 1 1 auto; min-width: 0; }
.deck-col-right { flex: 0 0 195px; gap: 8px; }

.col-label { font-size: 9px; letter-spacing: 0.5px; color: var(--deck-ink-soft); font-weight: 600; }

.round-btn {
  width: 44px; height: 44px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #f4f0e6, var(--deck-btn) 55%, var(--deck-btn-shadow) 100%);
  border: 1px solid #7d745c;
  box-shadow: 0 3px 6px rgba(0,0,0,0.35), inset 0 1px 1px rgba(255,255,255,0.7);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: var(--deck-ink);
}
.round-btn:active { box-shadow: inset 0 2px 4px rgba(0,0,0,0.4); transform: translateY(1px); }
.power-btn.is-on { background: radial-gradient(circle at 35% 30%, #cdf6d9, #6fdb8d 55%, #2e8f4d 100%); }

.phones-jack {
  width: 30px; height: 30px; border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #57534a, #201f1c 70%);
  border: 1px solid #14130f;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
}
.jack-hole { width: 8px; height: 8px; border-radius: 50%; background: #000; }

.knob-wrap { padding: 4px 0; }
.knob {
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #4a4a4a, #1a1a1a 70%);
  border: 1px solid #000;
  box-shadow: 0 3px 6px rgba(0,0,0,0.5), inset 0 1px 2px rgba(255,255,255,0.15);
  position: relative;
  cursor: grab;
}
.knob:active { cursor: grabbing; }
.knob .knob-mark {
  position: absolute; top: 3px; left: 50%; width: 2px; height: 40%;
  background: #e5e5e5; transform-origin: bottom center; transform: translateX(-50%);
  border-radius: 2px;
}
.mode-knob { width: 34px; height: 34px; }
.big-knob { width: 58px; height: 58px; margin: 0 auto; }

/* ---------- Кассетное окно ---------- */
.cassette-frame {
  background: linear-gradient(180deg, #efe9dc, #d8d1bf);
  border: 1px solid #a89f89;
  border-radius: 6px;
  box-shadow: inset 0 2px 5px rgba(0,0,0,0.25), inset 0 -2px 0 rgba(255,255,255,0.4);
  padding: 8px 10px 10px;
  height: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
}
.cassette-frame-label {
  font-size: 9px; font-weight: 700; letter-spacing: 0.6px;
  color: var(--deck-ink-soft); margin-bottom: 6px;
}
.cassette {
  position: relative;
  background: linear-gradient(180deg, #171614, #050505);
  border-radius: 4px;
  flex: 1 1 auto;
  min-height: 150px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.05);
  overflow: hidden;
}
.cassette-visualizer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  opacity: 1;
  filter: brightness(1.15) saturate(1.3) contrast(1.05);
}
.cassette-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  z-index: 2;
  opacity: 1;
  pointer-events: none;
  transition: opacity 0.6s ease;
}
/* Пока идёт поток — делаем кассету полупрозрачной, чтобы просвечивала визуализация */
.cassette.is-playing .cassette-image {
  opacity: 0;
}

.cassette-plate {
  background: linear-gradient(180deg, #ff8a3d, #e8672a);
  color: #241300;
  padding: 14px 20px;
  border-radius: 4px;
  text-align: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex: 1 1 100%;
  min-width: 0;
  min-height: 64px;
}
.cassette-plate-name {
  font-weight: 800; font-size: 15px; letter-spacing: 0.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  position: relative;
}
.cassette-plate-track {
  font-size: 12px; margin-top: 5px; opacity: 0.85;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  position: relative;
}

/* Бегущая строка: включается через JS (класс is-marquee), когда текст не помещается */
.cassette-plate-name .marquee-inner,
.cassette-plate-track .marquee-inner {
  display: inline-block;
  white-space: nowrap;
  will-change: transform;
}
.cassette-plate-name.is-marquee,
.cassette-plate-track.is-marquee {
  text-overflow: clip;
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 18px, #000 calc(100% - 18px), transparent 100%);
          mask-image: linear-gradient(90deg, transparent 0, #000 18px, #000 calc(100% - 18px), transparent 100%);
}
.cassette-plate-name.is-marquee .marquee-inner,
.cassette-plate-track.is-marquee .marquee-inner {
  animation-name: cassette-marquee-scroll;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}
@keyframes cassette-marquee-scroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}
@media (prefers-reduced-motion: reduce) {
  .cassette-plate-name.is-marquee .marquee-inner,
  .cassette-plate-track.is-marquee .marquee-inner {
    animation: none;
  }
}

/* ---------- Правая колонка: счётчик, LED, VU-метры ---------- */
.counter-block {
  background: var(--deck-panel-2);
  border-radius: 4px;
  width: 100%;
  padding: 6px 8px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.05);
}
.counter-display {
  font-family: 'Consolas', monospace;
  background: #100f0d;
  color: #ffcf5c;
  font-size: 14px;
  font-weight: 700;
  padding: 3px 6px;
  border-radius: 2px;
  letter-spacing: 1px;
  min-width: 118px;
  text-align: right;
  white-space: nowrap;
}
.counter-buttons { display: flex; flex-direction: column; gap: 3px; }
.mini-btn {
  font-size: 8px; font-weight: 700; letter-spacing: 0.3px;
  background: var(--deck-btn); border: 1px solid #8d8570; border-radius: 3px;
  padding: 2px 5px; cursor: pointer; color: var(--deck-ink);
}
.mini-btn:active { transform: translateY(1px); }

.led-row { display: flex; align-items: center; gap: 5px; font-size: 9px; font-weight: 600; color: var(--deck-ink-soft); width: 100%; }
.led { width: 8px; height: 8px; border-radius: 50%; background: #3a3a3a; box-shadow: inset 0 0 2px rgba(0,0,0,0.6); flex: none; }
.led-text { margin-right: 6px; }
.led-teal.is-on { background: var(--deck-led-teal); box-shadow: 0 0 6px var(--deck-led-teal); }
.led-amber.is-on { background: var(--deck-led-amber); box-shadow: 0 0 6px var(--deck-led-amber); }

.meter-panel {
  background: var(--deck-panel);
  border-radius: 4px;
  width: 100%;
  padding: 6px 8px 4px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.05);
}
.meter-scale-row { display: flex; justify-content: flex-end; gap: 10px; font-size: 7px; color: #8d9096; text-transform: uppercase; padding: 0 2px; }
.meter-line { display: flex; align-items: center; gap: 6px; margin: 2px 0; }
.meter-tag { font-size: 8px; color: #b7bbc2; width: 42px; flex: none; font-weight: 600; }
.meter-side { font-size: 8px; color: #8d9096; width: 30px; flex: none; text-align: right; }
.meter-line-scale { justify-content: flex-start; }
.meter-scale-numbers { font-size: 7px; color: #6d7176; letter-spacing: 1px; }

.led-bar { display: flex; gap: 2px; flex: 1 1 auto; min-width: 0; }
.led-bar span {
  flex: 1 1 0;
  height: 7px;
  border-radius: 1px;
  background: var(--deck-led-green-dim);
}
.led-bar span:nth-last-child(-n+2) { background: var(--deck-led-red-dim); }
.led-bar span.lit { background: var(--deck-led-green); box-shadow: 0 0 3px var(--deck-led-green); }
.led-bar span.lit:nth-last-child(-n+2) { background: var(--deck-led-red); box-shadow: 0 0 4px var(--deck-led-red); }

/* ---------- Транспортные кнопки ---------- */
.deck-transport, .deck-lowerbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.deck-transport { justify-content: space-between; align-items: center; }
.deck-transport-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.transport-buttons { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.transport-left {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1 1 320px;
  min-width: 0;
}
.transport-left .deck-lowerbar { margin-top: 0; }

/* ---------- RECORD LEVEL — панель в правой колонке (счётчик / LED / метры) ---------- */
.record-level-panel {
  background: var(--deck-panel-2);
  border-radius: 4px;
  width: 100%;
  padding: 8px 8px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.05);
}
.record-level-panel .record-level-title {
  font-size: 9px;
  letter-spacing: 1px;
  color: #b7bbc2;
}
.record-level-panel .record-level-controls { display: flex; align-items: center; gap: 18px; }
.record-level-panel .big-knob { width: 44px; height: 44px; }
.record-level-panel .mic-jacks { flex-direction: column; gap: 2px; font-size: 8px; color: #8d9096; }
.record-level-panel .knob-column { gap: 3px; }
.record-level-panel .knob-side-label { font-size: 9px; color: #b7bbc2; }
.transport-btn, .filter-btn {
  background: linear-gradient(180deg, #f2ede2, var(--deck-btn));
  border: 1px solid #8d8570;
  border-radius: 4px;
  padding: 8px 10px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: var(--deck-ink);
  cursor: pointer;
  display: flex; align-items: center; gap: 5px;
  box-shadow: 0 2px 3px rgba(0,0,0,0.2);
}
.transport-btn:hover, .filter-btn:hover { background: #fff; }
.transport-btn:active, .filter-btn:active { transform: translateY(1px); box-shadow: none; }
.transport-btn .ico { font-size: 11px; }
.transport-btn .ico.dot { color: var(--deck-led-red); }
.transport-btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.transport-btn.is-active, .filter-btn.is-active {
  background: linear-gradient(180deg, #ffe9a8, #f0c96a);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.3);
}

.deck-lowerbar { justify-content: flex-end; }
.filter-row { display: flex; align-items: center; gap: 6px; }
.dolby-logo { font-size: 10px; font-weight: 700; letter-spacing: 1px; color: var(--deck-ink-soft); }

/* ---------- Record level (общие стили колонок ручек) ---------- */
.record-level-title { font-size: 9px; font-weight: 700; letter-spacing: 1px; color: var(--deck-ink-soft); white-space: nowrap; }
.record-level-controls { display: flex; align-items: center; gap: 26px; }
.knob-column { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.knob-side-label { font-size: 10px; font-weight: 700; }
.mic-jacks { display: flex; align-items: center; gap: 8px; font-size: 9px; font-weight: 700; color: var(--deck-ink-soft); }
.mic-word { letter-spacing: 1px; }

.sr-status {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

@media (max-width: 720px) {
  .deck-body { flex-direction: column; }
  .deck-col-left { flex-direction: row; align-items: center; gap: 14px; }
  .deck-col-left .col-label { margin: 0; }
  .deck-col-right { flex: none; width: 100%; }
  .deck-transport { justify-content: center; }
  .deck-transport-row { justify-content: center; }
  .deck-lowerbar { justify-content: center; }
  .deck-motors { margin-left: 0; }
  .record-level-controls { gap: 16px; }
  .transport-buttons { justify-content: center; }

  .cassette-plate { flex: 1 1 100%; align-self: auto; }
}

/* ============================================================
   Мобильные экраны (телефоны, ~480px и уже)
   ============================================================ */
@media (max-width: 480px) {
  html { -webkit-text-size-adjust: 100%; }

  .container { padding: 16px 12px 40px; }

  .page-header { gap: 10px; }
  h1 { font-size: 20px; gap: 8px; }
  .subtitle { font-size: 13px; }
  .theme-toggle { width: 38px; height: 38px; min-width: 38px; font-size: 16px; }

  /* Кнопки и интерактивные элементы — увеличиваем область нажатия */
  a, button, .switch, .transport-btn, .filter-btn, .mini-btn,
  .round-btn, .channel-item, .category-card {
    touch-action: manipulation;
  }
  .btn, .btn-secondary { padding: 11px 14px; font-size: 14px; }

  /* ---------- Дека: убираем лишние отступы, чтобы всё помещалось ---------- */
  .deck { padding: 12px 10px 14px; }
  .deck-topbar { flex-wrap: wrap; row-gap: 2px; }
  .deck-sub { display: none; }
  .deck-motors { font-size: 10px; }

  .deck-body { gap: 12px; }

  .cassette-frame { padding: 6px 7px 8px; }
  .cassette { padding: 0 8px; min-height: 130px; }
  .cassette-plate { flex: 1 1 100%; min-width: 0; padding: 8px 10px; }
  .cassette-plate-name { font-size: 12px; }
  .cassette-plate-track { font-size: 10px; }

  .counter-display { font-size: 12px; min-width: 0; letter-spacing: 0.5px; padding: 3px 5px; }
  .mini-btn { padding: 6px 8px; font-size: 9px; }
  .counter-buttons { flex-direction: row; gap: 6px; }
  .counter-block { flex-wrap: wrap; }

  .meter-scale-numbers { letter-spacing: 0; font-size: 6px; }
  .meter-tag { width: 34px; font-size: 7px; }
  .meter-side { width: 24px; font-size: 7px; }

  .record-level-panel .record-level-controls { gap: 12px; }
  .record-level-panel .big-knob { width: 40px; height: 40px; }

  .transport-buttons { width: 100%; }
  .transport-btn { flex: 1 1 0; justify-content: center; padding: 10px 6px; }
  .filter-row { flex-wrap: wrap; justify-content: center; width: 100%; margin-top: 6px; }
  .filter-btn { flex: 1 1 auto; padding: 9px 8px; }
  .dolby-logo { width: 100%; text-align: center; }

  /* ---------- Список каналов ---------- */
  .category-row { gap: 8px; }
  .category-card { padding: 14px 8px; }
  .category-card-icon { font-size: 22px; }
  .category-card-label { font-size: 13px; }
  .category-card-count { font-size: 11px; }
  .channel-item { padding: 12px 14px; flex-wrap: wrap; gap: 6px; }
  .channel-item .meta { font-size: 12px; }

  /* ---------- Админка / формы ---------- */
  .admin-header { flex-wrap: wrap; gap: 10px; }
  .admin-header h1 { font-size: 19px; }
  .admin-header-actions { width: 100%; justify-content: flex-end; }
  .card { padding: 14px 14px; }
  .inline-form { gap: 8px; }
  .inline-form input[type=text], .inline-form select { flex: 1 1 140px; }
  .channel-header { gap: 8px; }
  .channel-header-bottom { flex-wrap: wrap; }
  .channel-header-actions { flex: 1 1 auto; }
  .channel-header-actions form, .channel-header-actions .btn { flex: 1 1 auto; }
  .category-toggle-row { flex-wrap: wrap; row-gap: 4px; }
  .category-toggle-label { min-width: 0; flex: 1 1 auto; }
  .playlist-block-header { gap: 8px; }
  .actions { flex-wrap: wrap; }
  .actions form, .actions .btn { flex: 1 1 auto; width: 100%; }

  input[type=text], input[type=password], select, .inline-form input[type=file] {
    font-size: 16px;
  }
}
