:root {
  --bg: #0f1115;
  --bg-card: #171a21;
  --text: #e9ecf1;
  --text-dim: #9aa3b2;
  --accent: #4f8cff;
  --star: #ffb020;
  --border: #262b36;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }

.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

.site-header {
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
}
.site-header .wrap { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.logo { display: flex; align-items: center; flex: none; }
.logo__img { display: block; height: 44px; width: auto; }
.genre-nav { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.9rem; color: var(--text-dim); }

.site-search { position: relative; flex: 1 1 200px; max-width: 320px; }
.site-search__input {
  width: 100%; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); padding: 8px 12px; font-size: 0.9rem;
}
.site-search__input:focus { outline: none; border-color: var(--accent); }
.site-search__results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 20;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px;
  max-height: 360px; overflow-y: auto; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.site-search__item {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.site-search__item:last-child { border-bottom: none; }
.site-search__item:hover { background: rgba(79, 140, 255, 0.12); }
.site-search__logo { flex: none; width: 32px; height: 32px; border-radius: 6px; background: #fff; overflow: hidden; display: block; }
.site-search__logo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.site-search__no-logo {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff; font-weight: 700; text-transform: uppercase; font-size: 0.9rem;
}
.site-search__name { display: block; font-size: 0.88rem; font-weight: 600; }
.site-search__genre { display: block; font-size: 0.76rem; color: var(--text-dim); }
.site-search__empty { padding: 12px; color: var(--text-dim); font-size: 0.85rem; }

main.wrap { padding: 28px 16px 60px; }

h1 { font-size: 1.6rem; margin: 0 0 8px; }
h2 { font-size: 1.15rem; margin: 0 0 14px; color: var(--text-dim); font-weight: 600; }

.block { margin-bottom: 40px; }

/* Блоки "Самые прослушиваемые"/"Советуем послушать" на главной — ровно 2
   полных ряда на любой ширине (раньше auto-fill давал "рваный" последний
   ряд в зависимости от точной ширины экрана). Фиксированное число колонок
   по брейкпоинтам + CSS сам прячет лишние карточки сверх columns*2 — во
   view (home()) всегда тянем с запасом (HOME_BLOCK_SIZE = 12), тут только
   решаем, сколько из них показать. Каталог станций жанра (.station-list)
   этим не ограничен — это отдельный класс, см. ниже. */
.station-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.station-grid .station-card:nth-child(n+5) { display: none; }

@media (min-width: 600px) {
  .station-grid { grid-template-columns: repeat(4, 1fr); }
  .station-grid .station-card:nth-child(n+5) { display: flex; }
  .station-grid .station-card:nth-child(n+9) { display: none; }
}

@media (min-width: 900px) {
  .station-grid { grid-template-columns: repeat(6, 1fr); }
  .station-grid .station-card:nth-child(n+9) { display: flex; }
}

/* Полный список станций жанра/поиска — тут не ограничиваем количество,
   обычный резиновый auto-fill (сколько влезет, все показываем). */
.station-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
}

.station-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
}
.station-card__logo {
  position: relative; display: block; width: 64px; height: 64px;
  border-radius: 8px; background: #fff; overflow: hidden;
}
.station-card__logo img { display: block; width: 100%; height: 100%; object-fit: contain; }
.station-card__no-logo {
  display: none;
  width: 64px; height: 64px; border-radius: 8px; background: var(--accent);
  color: #fff; align-items: center; justify-content: center;
  font-size: 1.4rem; font-weight: 700; text-transform: uppercase;
}
/* Нет логотипа (пустое поле) ИЛИ картинка не загрузилась (битая ссылка) —
   в обоих случаях показываем заглушку с первой буквой вместо пустоты/крестика. */
.station-card__logo--empty { background: transparent; }
.station-card__logo--empty .station-card__no-logo { display: flex; }
.station-card__name { font-weight: 600; font-size: 0.92rem; }
.station-card__genre { font-size: 0.78rem; color: var(--text-dim); }
.station-card__rating { font-size: 0.78rem; color: var(--star); }
.station-card__rating small { color: var(--text-dim); }

.genre-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.genre-chip {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 20px; padding: 8px 16px; font-size: 0.9rem;
}

.station-page__head { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.station-page__logo {
  position: relative; display: block; width: 84px; height: 84px; flex: none;
  border-radius: 12px; background: #fff; overflow: hidden;
}
.station-page__logo img { display: block; width: 100%; height: 100%; object-fit: contain; }
.station-page__no-logo {
  display: none;
  width: 84px; height: 84px; border-radius: 12px; background: var(--accent);
  color: #fff; align-items: center; justify-content: center;
  font-size: 1.8rem; font-weight: 700; text-transform: uppercase;
}
.station-page__logo--empty { background: transparent; }
.station-page__logo--empty .station-page__no-logo { display: flex; }
.station-page__meta { color: var(--text-dim); font-size: 0.9rem; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.flag-icon { width: 32px; height: auto; border-radius: 2px; vertical-align: middle; }
.station-page__description { color: var(--text-dim); max-width: 640px; }
/* .station-page__official-link убран (2026-08-23) — официальный сайт теперь
   кнопка внутри .station-page__actions (см. ниже), а не отдельная строка
   с "голым" текстом ссылки. */

/* SEO: скрыто визуально, но доступно поисковикам/скринридерам (главная H1) */
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.breadcrumbs { margin-bottom: 16px; }
.breadcrumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; font-size: 0.85rem; color: var(--text-dim); }
.breadcrumbs li:not(:last-child)::after { content: "›"; margin-left: 6px; color: var(--text-dim); }
.breadcrumbs a { color: var(--text-dim); text-decoration: underline; }
.breadcrumbs a:hover { color: var(--accent); }
.breadcrumbs [aria-current="page"] { color: var(--text); }

.report-broken { margin-top: 12px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.report-broken__btn {
  background: transparent; border: 1px solid var(--border); color: var(--text-dim);
  border-radius: 6px; padding: 6px 12px; font-size: 0.85rem; cursor: pointer;
}
.report-broken__btn:hover { border-color: var(--accent); color: var(--accent); }
.report-broken__btn:disabled { opacity: 0.6; cursor: default; }
.report-broken__hint { font-size: 0.85rem; color: var(--text-dim); }

.player {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px; margin-bottom: 20px;
}
/* Обложка трека ("Сейчас играет") — квадратная, поэтому специально не
   мельчим: 100px по умолчанию, 150px от планшета и шире (см. main.css
   брейкпоинты 600/900px, тот же подход, что у station-grid). Без обложки
   трека (не нашли/нет метаданных) сюда подставляется логотип станции
   (см. player.js updateCover) — так что место НЕ пустует почти никогда. */
.player__cover {
  position: relative; display: block; flex: none;
  width: 100px; height: 100px; border-radius: 10px;
  background: #fff; overflow: hidden;
}
.player__cover img { display: block; width: 100%; height: 100%; object-fit: contain; }
.player__cover-fallback {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff; font-size: 2rem; font-weight: 700; text-transform: uppercase;
}
/* КРИТИЧЕСКИ ВАЖНО: без этого правила атрибут hidden на этом элементе не
   работает вообще. У браузера по умолчанию есть встроенное правило
   [hidden] { display: none }, но наше собственное правило .player__cover-fallback
   { display: flex } выше — того же веса (специфичности) и, как стиль автора,
   побеждает стиль браузера по умолчанию. Из-за этого буква-заглушка
   показывалась ВСЕГДА, поверх настоящей обложки трека, даже когда JS
   корректно ставил hidden — картинка была на месте и грузилась, но её было
   не видно (баг найден и исправлен 2026-08-23 после долгой отладки). */
.player__cover-fallback[hidden] { display: none; }
@media (min-width: 600px) {
  .player__cover { width: 150px; height: 150px; }
  .player__cover-fallback { font-size: 3rem; }
}
.player__toggle {
  width: 52px; height: 52px; border-radius: 50%; border: none;
  background: var(--accent); color: #fff; font-size: 1.3rem; cursor: pointer;
}
.player__info { display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; min-width: 0; }
.player__status { color: var(--text-dim); font-size: 0.9rem; }
.player__now-playing { color: var(--text); font-size: 0.88rem; font-weight: 600; }

.player__volume { display: flex; align-items: center; gap: 8px; flex: none; }
.player__mute {
  background: none; border: none; color: var(--text-dim); font-size: 1.1rem;
  cursor: pointer; padding: 4px; line-height: 1;
}
.player__mute:hover { color: var(--text); }
.player__volume-slider {
  width: 90px; accent-color: var(--accent); cursor: pointer;
}

/* Предупреждение про http-поток (station_detail.html, is_http_stream) —
   тёплый жёлтый, не тревожный красный: станция играет, просто не в нашем
   плеере, а в новой вкладке (см. player.js) — это не поломка сайта. */
.player__http-warning {
  background: rgba(217, 153, 0, 0.12); border: 1px solid rgba(217, 153, 0, 0.35);
  color: #d99900; border-radius: 10px; padding: 10px 14px;
  font-size: 0.88rem; line-height: 1.4; margin: -8px 0 20px;
}

.rating { margin-bottom: 24px; }
.rating__stars { font-size: 1.6rem; cursor: pointer; }
.rating__star { color: #3a4051; }
.rating__star.is-filled { color: var(--star); }
.rating[data-can-rate="0"] .rating__stars { cursor: not-allowed; opacity: 0.5; }
.rating__summary { display: block; color: var(--text-dim); font-size: 0.85rem; margin-top: 4px; }
.rating__hint { color: var(--text-dim); font-size: 0.8rem; margin: 4px 0 0; }

.site-footer {
  border-top: 1px solid var(--border);
  color: var(--text-dim); font-size: 0.82rem;
  padding: 20px 0; margin-top: 40px;
}
.site-footer p { margin: 0 0 6px; }
.site-footer p:last-child { margin-bottom: 0; }
.site-footer a { color: var(--text-dim); text-decoration: underline; }
.site-footer a:hover { color: var(--accent); }

/* Страница "О проекте" — читаемая ширина текста и разметка заголовков,
   в отличие от .wrap (1100px), рассчитанного на карточки станций. */
.legal-page { max-width: 720px; }
.legal-page h1 { margin-bottom: 20px; }
.legal-page h2 { color: var(--text); font-size: 1.05rem; margin: 28px 0 10px; }
.legal-page h2:first-of-type { margin-top: 0; }
.legal-page p { color: var(--text-dim); margin: 0 0 12px; }
.legal-page a { color: var(--accent); text-decoration: underline; }

/* Кнопки "Что играло" / "Хит-парад" на странице станции (см.
   station_detail.html). Были обычными подчёркнутыми ссылками — Денис
   попросил (2026-08-23) сделать нормальными кнопками, не "прошловековыми
   ссылками". Заливка акцентным цветом — та же логика, что у крупных
   интерактивных элементов на сайте (.player__toggle), а не просто
   обводка, как у второстепенного .report-broken__btn: это не служебное
   действие, а полноценный переход на отдельную страницу-фичу. */
.station-page__actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 4px 0 20px; }
.station-page__action-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--accent); color: #fff; font-weight: 600; font-size: 0.9rem;
  padding: 10px 18px; border-radius: 999px; text-decoration: none;
  transition: filter 0.15s, transform 0.15s;
}
/* color: #fff явно на hover — иначе глобальное правило "a:hover { color: var(--accent) }"
   перебивает белый текст кнопки (по специфичности) синим, тем же цветом, что и
   фон кнопки — текст визуально "пропадает", хотя физически он на месте.
   Баг замечен Денисом 2026-08-23 на кнопках "Что играло"/"Хит-парад". */
.station-page__action-btn:hover { filter: brightness(1.12); transform: translateY(-1px); color: #fff; }
.station-page__action-icon { font-size: 1rem; line-height: 1; }
/* Официальный сайт станции (2026-08-23) — та же кнопка-"таблетка", но
   контурная, не залитая: это переход НА ЧУЖОЙ сайт (target="_blank"), а
   не на страницу самого RadioIce, как у двух предыдущих кнопок —
   заливкой сознательно не уравниваем, чтобы визуально не выглядело
   одинаково важным "остаться у нас" и "уйти на другой сайт". */
.station-page__action-btn--outline {
  background: transparent; border: 1px solid var(--border); color: var(--text);
}
.station-page__action-btn--outline:hover {
  filter: none; border-color: var(--accent); color: var(--accent);
}

/* Короткий вводный абзац на страницах "Что играло"/"Хит-парад" (2026-08-23,
   SEO-текст под H1 — та же роль, что у .station-page__description на
   странице станции: живой текст с ключевыми словами для поисковика, не
   просто голый список треков). */
.playlist-page__intro { color: var(--text-dim); max-width: 640px; margin: 4px 0 16px; }

/* Взаимная ссылка между "Что играло" и "Хит-парад" (теперь две отдельные
   страницы — см. station_playlist.html / station_chart.html) — младшая
   кнопка-"призрак" (обводка, не заливка): это переход в СОСЕДНЮЮ часть
   той же фичи, а не основной call-to-action страницы. */
.playlist-cross-link { margin: 4px 0 24px; }
.playlist-cross-link a {
  display: inline-flex; align-items: center;
  background: transparent; border: 1px solid var(--border); color: var(--text-dim);
  font-size: 0.85rem; font-weight: 600; padding: 8px 14px; border-radius: 999px;
  text-decoration: none; transition: border-color 0.15s, color 0.15s;
}
.playlist-cross-link a:hover { border-color: var(--accent); color: var(--accent); }

/* Страница "Играло на станции" (история эфира + хит-парад) —
   station_playlist.html. Обложка трека — тот же паттерн "картинка ИЛИ
   заглушка-буква", что у .station-card__logo (см. выше), НО заглушка тут
   на отдельном модификаторе-классе (.playlist-cover--empty), а не на
   нативном атрибуте hidden — сознательно, после истории с
   .player__cover-fallback[hidden] (см. комментарий там): проще не
   наступать второй раз на те же грабли со специфичностью, чем помнить
   добавлять [hidden]-переопределение для каждого нового блока с обложкой. */
.playlist-cover {
  position: relative; display: block; flex: none;
  width: 48px; height: 48px; border-radius: 6px; background: var(--bg-card);
  border: 1px solid var(--border); overflow: hidden;
}
.playlist-cover--sm { width: 36px; height: 36px; border-radius: 5px; }
.playlist-cover img { display: block; width: 100%; height: 100%; object-fit: cover; }
.playlist-cover__fallback {
  display: none; position: absolute; inset: 0; align-items: center; justify-content: center;
  background: var(--accent); color: #fff; font-weight: 700; text-transform: uppercase; font-size: 1.1rem;
}
.playlist-cover--sm .playlist-cover__fallback { font-size: 0.9rem; }
.playlist-cover--empty .playlist-cover__fallback { display: flex; }

.playlist-empty { color: var(--text-dim); font-size: 0.9rem; }

.playlist-chart { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.playlist-chart__item {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px;
}
.playlist-chart__rank {
  flex: none; width: 24px; text-align: center; color: var(--text-dim); font-weight: 700;
}
.playlist-chart__meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.playlist-chart__title { font-weight: 600; font-size: 0.92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.playlist-chart__count { color: var(--text-dim); font-size: 0.8rem; }

.playlist-day__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 10px; }
.playlist-day__head h2 { margin: 0; }
.playlist-day__nav { display: flex; gap: 16px; font-size: 0.85rem; }
.playlist-day__nav a { color: var(--accent); text-decoration: underline; }
.playlist-day__nav-disabled { color: var(--text-dim); opacity: 0.5; }
.playlist-day__list { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.playlist-day__row {
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--border); padding: 6px 0;
}
.playlist-day__time { flex: none; width: 44px; color: var(--text-dim); font-size: 0.82rem; font-variant-numeric: tabular-nums; }

/* "Добавить радиостанцию" (submit_station.html) — простая форма, без
   генератора форм/фреймворка на фронте: поля идут через {% for field in
   form %}, стилизуем по тегу, а не по классу (Django не проставляет
   классы виджетам сам по себе). */
.submit-station p { max-width: 640px; }
.submit-form { max-width: 480px; display: flex; flex-direction: column; gap: 16px; margin-top: 20px; }
.submit-form__field { display: flex; flex-direction: column; gap: 6px; }
.submit-form__field label { font-size: 0.85rem; color: var(--text-dim); font-weight: 600; }
.submit-form input[type="text"],
.submit-form input[type="url"],
.submit-form input[type="file"],
.submit-form textarea {
  width: 100%; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); padding: 9px 12px; font-size: 0.92rem;
  font-family: inherit;
}
.submit-form input[type="file"] { padding: 8px; }
.submit-form textarea { resize: vertical; min-height: 70px; }
.submit-form input:focus, .submit-form textarea:focus { outline: none; border-color: var(--accent); }
.submit-form__field--error input,
.submit-form__field--error textarea { border-color: #e0554f; }
.submit-form__error { color: #e0554f; font-size: 0.8rem; margin: 0; }
.submit-form__submit { align-self: flex-start; border: none; cursor: pointer; }
.submit-form__notice {
  max-width: 640px; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px 18px; color: var(--text-dim);
}
.submit-form__notice--ok { border-color: var(--accent); color: var(--text); }
.playlist-day__title { font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
