/* ==========================================================================
   1. ROOT VARIABLES & GLOBAL STYLES
   ========================================================================== */
:root {
  --bg: #0f1115;
  --panel: #161a22;
  --panel-2: #1b2130;
  --text: #e7edf3;
  --muted: #9aa5b1;
  --primary: #6c5ce7;
  --accent: #00b0ff;
  --border: rgba(255, 255, 255, .07);
  --border-2: rgba(255, 255, 255, .12);
  --error: #ff5555;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .25);
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  color-scheme: dark;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: radial-gradient(60vw 60vw at 75% -10%, #152033 0%, #0f1115 60%) no-repeat, var(--bg);
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

.container {
  max-width: 1400px; /* Увеличиваем ширину для чата */
  margin: 0 auto;
  padding: 24px;
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   2. HEADER & BRAND
   ========================================================================== */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  font-weight: 700;
  font-size: 20px;
}

.brand-badge {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--primary) 100%);
  box-shadow: var(--shadow);
}

/* ==========================================================================
   3. PANELS & GENERAL LAYOUT
   ========================================================================== */
.panel {
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.main-content-area {
  display: grid;
  grid-template-columns: 1fr; /* По умолчанию одна колонка */
  gap: 16px;
  align-items: start;
}

.main-content-area.with-chat {
  grid-template-columns: 1fr 320px; /* Две колонки, когда чат активен */
}

.toolbar {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 1.1fr 1.9fr;
  gap: 16px;
  align-items: start;
}

@media (max-width: 1200px) {
  .main-content-area.with-chat {
    grid-template-columns: 1fr; /* Снова одна колонка на средних экранах */
  }
}

@media (max-width: 980px) {
  .toolbar {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   4. SEARCH & RESULTS GRID
   ========================================================================== */
.search-panel {
  padding: 18px;
}

.search-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
}

.search-row input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 16px;
}

.search-row .icon {
  opacity: .8;
}

.nested-search {
  padding: 0;
  background: none;
  border: none;
  box-shadow: none;
  margin-bottom: 16px;
}

#selectionResults {
  max-height: 450px;
  overflow-y: auto;
  padding-right: 8px;
}

/* ==========================================================================
   5. BUTTONS & CHIPS
   ========================================================================== */
.btn {
  background: linear-gradient(135deg, var(--accent) 0%, var(--primary) 100%);
  color: #06121a;
  font-weight: 700;
  border: none;
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
}

.btn-ghost-old {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
}

.btn-ghost-old[disabled], .btn[disabled] {
  opacity: .5;
  cursor: not-allowed;
}

.chip-group {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.chip {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, .04);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
  user-select: none;
  transition: all .15s ease;
  opacity: .8;
}

.chip.enabled {
  opacity: 1;
}

.chip--active {
  background: var(--primary);
  border-color: transparent;
  color: #fafafa;
  box-shadow: 0 6px 18px rgba(108, 92, 231, .35);
  opacity: 1;
}

.chip:disabled {
  opacity: .35;
  cursor: not-allowed;
}

/* ==========================================================================
   HOST-ONLY CONTROLS STYLES
   ========================================================================== */
.host-only-disabled {
  opacity: 0.4 !important;
  cursor: not-allowed !important;
  pointer-events: none !important;
  filter: grayscale(70%);
}

.voice-item.host-only-disabled, 
.ep-item.host-only-disabled,
.chip.host-only-disabled {
  background: rgba(128, 128, 128, 0.1) !important;
  border-color: rgba(128, 128, 128, 0.2) !important;
  color: var(--muted) !important;
}

.btn.host-only-disabled {
  background: #4a4a4a !important;
  color: #888 !important;
}

.host-info {
  background: rgba(108, 92, 231, 0.1);
  border: 1px solid rgba(108, 92, 231, 0.3);
  border-radius: 8px;
  padding: 8px 12px;
  margin: 8px 0;
  font-size: 13px;
  color: var(--muted);
  display: none;
}

.host-info.show {
  display: block;
}

.host-info .icon {
  margin-right: 6px;
}

/* ==========================================================================
   6. ANIME CARD & GRID
   ========================================================================== */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.card {
  display: grid;
  grid-template-rows: auto auto;
  background: rgba(255, 255, 255, .03);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  transition: transform .2s ease, border-color .2s ease;
}

.card:hover {
  transform: translateY(-2px);
  border-color: var(--border-2);
}

.card-img {
  position: relative;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  background: #0a0b0f;
}

.card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  image-rendering: -webkit-optimize-contrast;
}

.card-img .overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, .65) 0%, rgba(0, 0, 0, 0) 55%);
}

.card-badges {
  position: absolute;
  top: 8px;
  left: 8px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.card-badge {
  background: rgba(0, 0, 0, .55);
  border: 1px solid var(--border-2);
  color: #eaf0ff;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: .2px;
  border-radius: 8px;
  padding: 3px 6px;
  backdrop-filter: blur(2px);
}

.card-body {
  padding: 12px;
}

.card .title {
  font-weight: 700;
  font-size: 15px;
  line-height: 1.3;
}

/* ==========================================================================
   7. SELECTION PAGE (Player View)
   ========================================================================== */
.selection {
  padding: 16px;
}

.section-title {
  font-weight: 700;
  margin: 8px 0;
}

/* плейсхолдер, если нет обложки */
.head-cover.no-img {
  display: grid; place-items: center;
  background: linear-gradient(135deg,#121723,#0e131b);
  color: var(--muted); font-size: 11px;
}
.head-cover.no-img::after { content: 'Нет обложки'; opacity: .8; }

/* ==========================================================================
   8. EPISODE & VOICE LISTS
   ========================================================================== */
.ep-panel, .voice-panel {
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  max-height: 420px;
  overflow: auto;
}

.ep-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}

.ep-item {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  background: rgba(255, 255, 255, .03);
  transition: all .15s ease;
  min-height: 48px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
}

.ep-item:hover {
  border-color: var(--border-2);
  transform: translateY(-1px);
}

.ep-item.active {
  background: rgba(108, 92, 231, .15);
  border-color: var(--primary);
}

.ep-num {
  font-weight: 800;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: rgba(108, 92, 231, .15);
  color: #dfe7ff;
  font-size: 14px;
}

.ep-name {
  font-size: 14px;
  line-height: 1.25;
  color: var(--text);
}

.voice-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}

.voice-item:hover {
  background: rgba(255, 255, 255, .04);
}

.voice-item.active {
  background: rgba(108, 92, 231, .15);
  color: #fff;
}

.voice-item .badge {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .5px;
  color: #bcd6ff;
}

.voice-item .hd {
  margin-left: 8px;
  font-size: 10px;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: #c6ffd5;
}

/* ==========================================================================
   9. TABS & LOADER
   ========================================================================== */
.tabs {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tab {
  border: none;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
  padding: 6px 0;
}

.tab--active {
  color: var(--text);
  position: relative;
}

.tab--active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -6px;
  height: 2px;
  background: var(--primary);
}

.loader {
  margin: 16px 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .04);
  border: 1px dashed var(--border);
  color: var(--muted);
  font-size: 14px;
  display: none;
}

.loader.show {
  display: block;
}

/* ==========================================================================
   10. VIDEO PLAYER (PLYR)
   ========================================================================== */
.player-panel {
  padding: 12px;
}

.plyr__captions {
  pointer-events: none;
}

.player-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.player-shell {
  position: relative;
  padding-top: 56.25%; 
  background: #000;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.player-shell > * {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.plyr {
  --plyr-color-main: var(--accent);
  --plyr-video-background: #000;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  border: 1px solid var(--border);
  position: relative;
}

/* Не кадрировать видео внутри Plyr */
.plyr__video-wrapper > video,
.plyr video {
  object-fit: contain !important;
}

/* На всякий случай для постера Plyr (до старта проигрывания) */
.plyr--video .plyr__poster {
  background-size: contain !important;
  background-position: center !important;
}

/* Плеер в MP4-режиме */
.player-panel .plyr { 
  width: 100%; 
  height: auto; 
}

/* Снять фиксированную 16:9 обёртку у плеера в панели (только в НЕ-фуллскрине) */
body:not(.app-fullscreen-mode) .player-panel .plyr__video-wrapper {
  padding-bottom: 0 !important;
  height: auto !important;
  aspect-ratio: auto !important;
}

/* Видео — вписывать без кропа (только в НЕ-фуллскрине) */
body:not(.app-fullscreen-mode) .player-panel .plyr__video-wrapper > video {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
}

/* Контейнер Plyr во фуллскрине — на весь экран */
body.app-fullscreen-mode .plyr--fullscreen {
  width: 100vw !important;
  height: 100vh !important;
  border: 0 !important;
  border-radius: 0 !important;
}

/* Внутренняя обёртка — ровно во весь контейнер, без паддингов и без ratio */
body.app-fullscreen-mode .plyr--fullscreen .plyr__video-wrapper {
  padding: 0 !important;
  width: 100% !important;
  height: 100% !important;
  aspect-ratio: auto !important;
}

/* Перестраховка: :fullscreen псевдокласс */
.plyr:fullscreen .plyr__video-wrapper,
.plyr:-webkit-full-screen .plyr__video-wrapper {
  padding: 0 !important;
  width: 100% !important;
  height: 100% !important;
  aspect-ratio: auto !important;
}

/* Видео — вписать без кропа */
body.app-fullscreen-mode .plyr--fullscreen video {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
  object-position: center center !important;
  background: #000 !important;
}

/* Постер (на всякий) — без кропа */
.plyr--video .plyr__poster {
  background-size: contain !important;
  background-position: center !important;
}

/* (необязательно) поправка субтитров, чтобы не уезжали за нижний край */
.app-fullscreen-mode .plyr--fullscreen .plyr__captions {
  bottom: 48px; /* можно 56px, если у тебя высокие контролы */
}

.plyr--video .plyr__controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  background: linear-gradient(rgba(0,0,0,0), rgba(0,0,0,.75));
  padding: 10px;
}

.plyr__progress, .plyr__progress__buffer, .plyr__progress__played {
  display: block !important; visibility: visible !important; opacity: 1 !important;
}

.plyr__time { color: #fff !important; font-size: 13px !important; }
.plyr__captions { z-index: 15; bottom: 56px; }
.plyr--hide-controls .plyr__captions { bottom: 12px; }

@media (max-width: 640px) {
  .plyr__captions { bottom: 64px; }
  .plyr--hide-controls .plyr__captions { bottom: 10px; }
}

.plyr__controls.host-only-disabled {
    display: none !important;
}

/* ==========================================================================
   11. MISC & UTILITIES
   ========================================================================== */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .12); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ==========================================================================
   12. WATCH PARTY & CHAT
   ========================================================================== */
.watch-party-controls {
  margin-left: auto;
}

.watch-party-panel {
  padding: 16px;
  margin-bottom: 18px;
  border: 1px dashed var(--primary);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.wp-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.invite-link-wrapper {
    display: flex;
    gap: 8px;
}
.watch-party-panel input {
  flex-grow: 1;
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text);
  font-weight: 500;
}

.chat-container {
  padding: 12px;
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 80vh; /* Ограничиваем высоту */
}
.chat-header {
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
#participants-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    font-size: 13px;
}
.participant {
    background: rgba(255,255,255,0.05);
    padding: 4px 8px;
    border-radius: 8px;
}
.participant.host::after {
    content: ' 👑';
}
.participant.clickable { 
    cursor: pointer; 
}
.participant.clickable:hover { 
    outline: 1px dashed var(--border-2); 
}

.chat-messages {
  flex-grow: 1;
  overflow-y: auto;
  padding: 10px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-message {
    padding: 8px 12px;
    border-radius: 12px;
    max-width: 90%;
    line-height: 1.4;
}
.chat-message.system {
    background: transparent;
    color: var(--muted);
    font-size: 12px;
    text-align: center;
    font-style: italic;
    padding: 0;
}
.chat-message.other {
    background: var(--panel-2);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}
.chat-message.mine {
    background: var(--primary);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}
.chat-message .sender {
    font-weight: 700;
    font-size: 13px;
    margin-bottom: 4px;
    opacity: 0.8;
}

.chat-form {
  display: flex;
  gap: 8px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.chat-form input {
    flex-grow: 1;
    background: rgba(255,255,255, .04);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 12px;
    color: var(--text);
}
.chat-form button {
    flex-shrink: 0;
    padding: 8px;
    width: 42px;
}

/* ==========================================================================
13. FULLSCREEN CHAT OVERLAY (compact glass card, fixed, toggle)
========================================================================== */

/* Переменная для управления высотой чата */
:root {
  --chat-offset-bottom: 45px; /* Добавляем переменную для управления позицией */
}

/* Ручка чата — скрыта вне фуллскрина */
.chat-handle {
  position: fixed;
  right: 20px;
  bottom: 24px; /* немного выше базово */
  z-index: 2003 !important; /* выше чата */
  background: rgba(229, 231, 235, 0.92);
  color: #111827;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 12px;
  width: 44px;
  height: 44px;
  cursor: pointer;
  display: none;
  place-items: center;
  box-shadow: 0 8px 24px rgba(0,0,0,0.28), 0 2px 8px rgba(0,0,0,0.12);
  transition: transform .15s ease, opacity .2s ease, box-shadow .2s ease, background .2s ease, color .2s ease;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  pointer-events: auto !important;
}
.chat-handle:hover { transform: translateY(-1px); }
.chat-handle.is-active { 
  box-shadow: 0 10px 28px rgba(0,0,0,0.32), 0 3px 10px rgba(0,0,0,0.14);
  background: rgba(108, 92, 231, 0.95);
  color: #fff;
}
.chat-handle svg { width: 18px; height: 18px; }

/* Ручка видна только во фуллскрине */
.plyr--fullscreen .chat-handle,
body.app-fullscreen-mode .chat-handle {
  display: grid !important;
}

/* Когда контролы Plyr видимы — поднимаем ручку ещё выше */
body.app-fullscreen-mode.plyr-controls-visible .chat-handle {
  bottom: calc(var(--fs-controls-h, 56px) + 32px + env(safe-area-inset-bottom, 0px)) !important;
}

/* Чат — компактная «стеклянная» карточка справа снизу (fixed) */
.plyr--fullscreen #chat-container,
body.app-fullscreen-mode #chat-container {
  position: fixed !important;
  right: calc(16px + env(safe-area-inset-right, 0px)) !important;
  bottom: calc(var(--chat-offset-bottom) + env(safe-area-inset-bottom, 0px)) !important;

  /* переопределяем возможные старые */
  top: auto !important;
  height: auto !important;

  z-index: 2002 !important;

  /* Уже и ниже + адаптив */
  width: clamp(240px, 28vw, 320px) !important;
  max-height: clamp(240px, 60vh, 480px) !important;

  display: flex !important;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border-radius: 14px;

  /* более прозрачный фон */
  background: var(--fs-chat-bg, rgba(22, 26, 34, 0.80));
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.10);
  box-shadow: -10px 12px 30px rgba(0,0,0,0.35);

  overflow: hidden;
  transform: translateX(calc(100% + 12px)); /* закрыт — за правым краем (открывается влево) */
  opacity: 0;
  visibility: hidden;
  transition: transform .35s cubic-bezier(0.22, 1, 0.36, 1), 
              opacity .35s cubic-bezier(0.22, 1, 0.36, 1),
              visibility .35s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: auto !important;
}

/* Когда контролы видимы — поднимаем чат над ними */
body.app-fullscreen-mode.plyr-controls-visible #chat-container {
  bottom: calc(var(--fs-controls-h, 56px) + var(--chat-offset-bottom) + 16px + env(safe-area-inset-bottom, 0px)) !important;
}

/* Открыт — выезжает влево */
.plyr--fullscreen #chat-container.is-open,
body.app-fullscreen-mode #chat-container.is-open {
  transform: translateX(0) !important;
  opacity: 1 !important;
  visibility: visible !important;
}

/* Закрыт — анимация закрытия */
.plyr--fullscreen #chat-container.is-closing,
body.app-fullscreen-mode #chat-container.is-closing {
  transform: translateX(calc(100% + 12px)) !important;
  opacity: 0 !important;
  visibility: hidden !important;
}

/* Верхняя панель — без крестика (убираем кнопку закрытия) */
.fs-chat-controls { display: none; }
.plyr--fullscreen #chat-container .fs-chat-controls,
body.app-fullscreen-mode #chat-container .fs-chat-controls {
  display: flex !important;
  padding: 8px 12px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
/* скрываем саму кнопку закрытия */
.plyr--fullscreen #chat-container .fs-chat-close-btn,
body.app-fullscreen-mode #chat-container .fs-chat-close-btn {
  display: none !important;
}

/* Контент: без заголовка; тёмный контрастный инпут */
.plyr--fullscreen #chat-container .chat-header,
body.app-fullscreen-mode #chat-container .chat-header {
  display: none !important;
}
.plyr--fullscreen #chat-container .chat-messages,
body.app-fullscreen-mode #chat-container .chat-messages {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
}

.plyr--fullscreen #chat-container .chat-form,
body.app-fullscreen-mode #chat-container .chat-form {
  margin-top: 4px;
}

/* Узкие экраны */
@media (max-width: 480px) {
  .plyr--fullscreen #chat-container,
  body.app-fullscreen-mode #chat-container {
    width: min(86vw, 320px) !important;
    max-height: min(64vh, 500px) !important;
  }
}

/* === Chat: скрыт по умолчанию, при открытии вылетает влево от кнопки === */

/* Кнопка чуть выше и левее */
.chat-handle {
  right: 15px !important;
  bottom: 60px !important;
}
body.app-fullscreen-mode.plyr-controls-visible .chat-handle {
  bottom: calc(var(--fs-controls-h, 56px) + 36px + env(safe-area-inset-bottom, 0px)) !important;
}

.plyr--fullscreen #chat-container,
body.app-fullscreen-mode #chat-container {
  right: calc(16px + 72px + env(safe-area-inset-right, 0px)) !important;
}

@media (max-width: 480px) {
  .plyr--fullscreen #chat-container,
  body.app-fullscreen-mode #chat-container {
    right: calc(12px + 56px + env(safe-area-inset-right, 0px)) !important;
  }
}

/* Тёмный, контрастный инпут */
.plyr--fullscreen #chat-container .chat-form input,
body.app-fullscreen-mode #chat-container .chat-form input {
  background: rgba(13, 16, 22, 0.95) !important;
  color: #e9eef6 !important;
  border: 1px solid rgba(255, 255, 255, 0.18) !important;
  caret-color: #e9eef6 !important;
}
.plyr--fullscreen #chat-container .chat-form input::placeholder,
body.app-fullscreen-mode #chat-container .chat-form input::placeholder {
  color: rgba(233, 238, 246, 0.6) !important;
}
.plyr--fullscreen #chat-container .chat-form input:focus,
body.app-fullscreen-mode #chat-container .chat-form input:focus {
  outline: none !important;
  border-color: rgba(99, 102, 241, 0.7) !important;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.28) !important;
}

/* На случай системной настройки "уменьшить анимацию" — без анимации */
@media (prefers-reduced-motion: reduce) {
  .plyr--fullscreen #chat-container,
  body.app-fullscreen-mode #chat-container {
    transition: none !important;
  }
}

/* Дополнительные классы для быстрой настройки позиции чата */
.chat-raised {
  --chat-offset-bottom: 80px !important;
}

.chat-very-raised {
  --chat-offset-bottom: 120px !important;
}

.chat-low {
  --chat-offset-bottom: 8px !important;
}

/* ==========================================================================
   LANDING SECTIONS
   ========================================================================== */

/* Лента под поиском */
.landing-sections { display: grid; gap: 16px; margin-top: 16px; }
.landing-section { display: grid; gap: 10px; }
.landing-title { font-weight: 800; font-size: 16px; display:flex; align-items:center; justify-content:space-between; }

/* Карусель-обёртка */
.carousel { position: relative; }

/* обёртка вокруг ряда с кнопками, должна уметь сжиматься в Grid */
.caro-wrap {
  position: relative;
  width: 100%;
  min-width: 0;          /* ключевая строка — не даём растягиваться до max-content */
  overflow: visible;     /* можно hidden/clip, если хочешь обрезать стрелку */
}

/* секция-предок тоже может сжиматься в Grid */
.landing-section { min-width: 0; }

/* отключаем фейды, чтобы ничего не перекрывало подписи */
.caro-fade { display: none !important; }

/* сам ряд — переводим на flex-ленту */
.landing-row {
  width: 100%;
  display: flex;
  flex-wrap: nowrap;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 6px;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;     /* тач-скролл по оси X */
  scrollbar-width: none;
}
.landing-row::-webkit-scrollbar { display: none; }

/* каждая карточка фиксирована по ширине (как было через clamp) */
.landing-row > .card {
  flex: 0 0 clamp(140px, 14vw, 190px);
  scroll-snap-align: start;
}

/* стрелки — оставляем, но без тени и вне ряда (чтобы не перекрывали подписи) */
.caro-btn {
  position: absolute; top: 50%; transform: translateY(-50%);
  z-index: 3; width: 28px; height: 28px; border-radius: 999px;
  display: grid; place-items: center;
  background: rgba(31,41,55,.9);
  border: 1px solid var(--border-2);
  color: #e5e7eb; cursor: pointer;
  transition: background .15s ease, transform .15s ease, opacity .15s ease;
  box-shadow: none;
}
.caro-btn:hover { background: rgba(55,65,81,.95); }
.caro-btn:active { transform: translateY(-50%) scale(.97); }
.caro-btn[disabled]{ opacity:.35; pointer-events:none; }
.caro-left  { left: -18px; }
.caro-right { right: -18px; }
.caro-btn svg { width: 14px; height: 14px; }

/* отключаем фейды, чтобы ничего не перекрывало подписи */
.caro-fade { display: none !important; }

@media (max-width: 640px) {
  .caro-btn { display: none; } /* на мобилке — тач‑скролл, без кнопок */
}

/* Предпочтения «меньше анимации» */
@media (prefers-reduced-motion: reduce) {
  .caro-btn { transition: none; }
  .landing-row { scroll-behavior: auto; }
}

/* Вариант карточки «постер 5:7» */
.card--poster .card-img { aspect-ratio: 5 / 7; } /* фиксированная высота по ширине */
.card--poster .card-body .title { font-size: 14px; }

/* Бейдж «Эпизод N» */
.badge-episode {
  display:inline-block; padding: 4px 8px; border-radius: 8px;
  background: rgba(0,0,0,.55); border:1px solid rgba(255,255,255,.15);
  color:#eaf0ff; font-weight:800; font-size:11px; letter-spacing:.2px;
}

/* ==========================================================================
   SEARCH RESULTS COMPACT CARDS
   ========================================================================== */

/* Head cover styles for larger display */
.head-cover {
    object-fit: cover;
    border-radius: 8px;
    width: 100%;
    height: auto;
    max-height: 400px;
}

/* Fallback for missing images */
.no-img {
    background: linear-gradient(135deg, var(--accent-color) 0%, var(--primary-color) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    text-align: center;
    min-height: 200px;
}

/* ——— Результаты поиска: компактная сетка и карточки ——— */

/* делаем сетку немного плотнее только для #results */
#results.grid {
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
@media (min-width: 1600px) {
  #results.grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}

/* компактный вариант «постер» */
.card.card--result.card--poster { border-radius: 12px; overflow: hidden; }
.card--result .card-img { aspect-ratio: 5 / 7; background: #0b0e13; }
.card--result .card-img .overlay {
  background: linear-gradient(to top, rgba(0,0,0,.75) 0%, rgba(0,0,0,.0) 58%);
}
.card--result .card-body { padding: 10px; }
.card--result .card-body .title {
  font-size: 13.5px; font-weight: 800; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  line-clamp: 2;
}
.card--result .card-body .subtitle { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* компактные бейджи в углу */
.card--result .card-badges { top: 6px; left: 6px; gap: 6px; }
.card--result .card-badge,
.card--result .badge-episode {
  background: rgba(0,0,0,.55);
  border: 1px solid rgba(255,255,255,.14);
  font-size: 10px; font-weight: 800; letter-spacing: .2px;
  border-radius: 8px; padding: 3px 6px; color: #eaf0ff;
}

/* приятный hover/outline */
.card--result { transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease; }
.card--result:hover { transform: translateY(-2px); border-color: var(--border-2); box-shadow: 0 8px 22px rgba(0,0,0,.22); }
.card--result:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 12px; }

/* помогаем производительности при длинных списках */
#results .card { content-visibility: auto; contain-intrinsic-size: 280px 380px; }

/* супер-компакт режим */
#results.compact.grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }

/* ==========================================================================
   CUSTOMIZABLE SIZES & IMPROVED LAYOUT
   ========================================================================== */

:root{
  --head-cover-w: 64px;        /* шапка выбора: обложка слева (было 56) */
  --updates-w: 360px;          /* ширина колонки "Последние обновления" справа */
  --upd-cover-w: 72px;         /* превью в списке обновлений (было 64) */
  --upd-row-cover: 80px;       /* ширина мини-обложки в списке (было 76px) */
  --updates-panel-max: 860px;  /* максимальная ширина панели обновлений */
  --home-two-gap: 16px;        /* отступ между колонками в двухколоночном макете */
}

/* Шапка выбора */
.selection-head{
  display:grid;
  grid-template-columns: var(--head-cover-w) 1fr;
  gap:12px; align-items:center;
}
.head-cover{
  width: var(--head-cover-w);
  aspect-ratio: 5 / 7;
  border-radius: 8px; overflow: hidden;
  border: 1px solid var(--border);
  background:#0a0b0f;
}
.head-cover img{ width:100%; height:100%; object-fit:cover; display:block; }

/* Мета-строка */
.head-meta .title{ font-size:18px; font-weight:800; line-height:1.25; }
.head-meta .meta{ margin-top:6px; font-size:13px; color:var(--muted); display:flex; flex-wrap:wrap; gap:6px 12px; }
.head-meta .meta .star { color: #fbbf24; margin: 0 4px 0 6px; }
.head-meta .meta .sep { opacity: .6; margin: 0 6px; }
.head-meta .meta .item b { font-weight: 800; }

/* Лендинг под поиском: две колонки — слева main, справа updates */
.landing-layout{
  display:grid;
  grid-template-columns: 1fr var(--updates-w);
  gap:16px; align-items:start;
}
.landing-main{ min-width:0; } /* чтобы карусели не разламывали сетку */
.landing-aside{ min-width: var(--updates-w); display:grid; gap:12px; }

/* Карточка обновлений */
.updates-card { background: rgba(255,255,255,.03); border:1px solid var(--border); border-radius:12px; padding:10px; }
.updates-title { font-weight:800; margin:4px 0 8px; }
.updates-list { display:grid; gap:10px; }

/* Список обновлений «держится» при вертикальном скролле */
@media (min-width: 1101px){
  .landing-aside{ position: sticky; top: 12px; }
}

@media (max-width: 1100px){
  .landing-layout{ grid-template-columns: 1fr; }
  .landing-aside{ position: static; }
}

/* Список обновлений (увеличим обложку) */
.upd-item{ display:grid; grid-template-columns: var(--upd-cover-w) 1fr; gap:10px; align-items:center;
  padding:8px; border-radius:10px; transition:background .15s; cursor:pointer; }
.upd-item:hover{ background: rgba(255,255,255,.04); }
.upd-cover{
  position:relative;
  width: var(--upd-cover-w);
  aspect-ratio: 5 / 7;
  border-radius:8px; overflow:hidden;
  background:#0a0d12; border:1px solid var(--border);
}
.upd-cover img{ width:100%; height:100%; object-fit:cover; display:block; }
.upd-type, .upd-age{
  position:absolute; left:4px; font-size:10px; padding:2px 6px; border-radius:6px;
  border:1px solid rgba(255,255,255,.15);
}
.upd-type{ top:4px; background:rgba(0,0,0,.55); }
.upd-age{ bottom:4px; background:rgba(255,255,255,.08); border-color:rgba(255,255,255,.18); }
.upd-title{ font-weight:800; font-size:14px; line-height:1.25; margin-bottom:3px;
  display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; line-clamp:2; overflow:hidden; }
.upd-ep{ font-size:13px; }
.upd-ep .ep-num{ font-weight:800; }
.upd-ep .ep-extra{ color:var(--muted); margin-left:10px; font-size:12px; }
.upd-time{ font-size:12px; color:var(--muted); margin-top:2px; display:flex; align-items:center; gap:8px; }
.upd-new{ background: rgba(34,197,94,.15); color:#86efac; border:1px solid rgba(34,197,94,.35); font-size:10px; padding:2px 6px; border-radius:999px; }

/* Плотные карточки справа */
.landing-row{ display:grid; grid-auto-flow:column; grid-auto-columns: clamp(150px,16vw,190px);
  gap:12px; overflow-x:auto; padding-bottom:6px; scroll-snap-type:x proximity; }
.card.card--poster.card--result{ border-radius:12px; overflow:hidden; }
.card--result .card-img{ aspect-ratio:5/7; background:#0b0e13; }
.card--result .card-img .overlay{ background:linear-gradient(to top, rgba(0,0,0,.75) 0%, rgba(0,0,0,0) 58%); }
.card--result .card-body{ padding:10px; }
.card--result .card-body .title{ font-size:13.5px; font-weight:800; line-height:1.25;
  display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; line-clamp:2; overflow:hidden; }
.card--result .card-body .subtitle{ font-size:12px; color:var(--muted); margin-top:4px; }

/* ==========================================================================
   UPDATES GRID SECTION WITH PAGINATION
   ========================================================================== */

/* Секция сетки "Последние обновления" снизу */
.updates-grid-section { display:grid; gap:10px; margin-top: 18px; }
.updates-grid-section .landing-title { font-weight:800; font-size:16px; }

.updates-grid {
  display:grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
@media (min-width: 1600px){
  .updates-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}

.update-card.card--poster .card-img { aspect-ratio: 5 / 7; } /* постер 5:7 */
.update-card .card-badges { top:6px; left:6px; gap:6px; }
.update-card .badge-episode {
  background: rgba(0,0,0,.55); border:1px solid rgba(255,255,255,.14);
  font-size:10px; font-weight:800; border-radius:8px; padding:3px 6px; color:#eaf0ff;
}
.update-card .badge-type {
  background: rgba(0,0,0,.55); border:1px solid rgba(255,255,255,.14);
  font-size:10px; border-radius:6px; padding:2px 6px; color:#eaf0ff;
}
.update-card .card-body { padding: 10px; }
.update-card .card-body .title {
  font-size: 13.5px; font-weight: 800; line-height: 1.25;
  display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; line-clamp:2; overflow:hidden;
}
.update-card .card-body .subtitle { font-size:12px; color:var(--muted); margin-top:4px; }

.updates-more { display:flex; justify-content:center; margin-top: 10px; }
.updates-more .btn { min-width: 200px; }

/* ==========================================================================
   TWO-COLUMN HOME LAYOUT WITH ENHANCED UPDATES PANEL
   ========================================================================== */

/* Две колонки под блоком популярных: слева — обновления, справа — твой будущий блок */
.home-two {
  display: grid;
  grid-template-columns: 1fr 1fr;     /* 50/50 от ширины .container */
  gap: var(--home-two-gap);
  align-items: start;
  margin-top: 16px;
}
@media (max-width: 1100px){
  .home-two { grid-template-columns: 1fr; }
}

/* Левая половина — панель обновлений */
.updates-panel {
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 12px;
}
.updates-panel .panel-title {
  font-weight: 800; font-size: 16px; margin: 2px 2px 10px;
}

/* Панель обновлений — убираем любые маркеры и фокус‑рамки */
.updates-panel .updates-list,
.updates-panel .updates-list * {
  list-style: none !important;
}
.updates-panel .updates-list *:focus,
.updates-panel .updates-list *:focus-visible {
  outline: none !important;
  box-shadow: none !important;
}

/* Одна колонка, без маркеров (убираем «глючные квадраты») */
.updates-list, .upd-item { list-style: none; }
.updates-list {
  display: grid;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(255,255,255,.02);
}

/* Строка */
.upd-item {
  display: grid;
  grid-template-columns: var(--upd-row-cover) 1fr;
  gap: 10px;
  align-items: center;
  padding: 10px;
  transition: background .15s ease;
  cursor: pointer;
}
.upd-item + .upd-item { border-top: 1px solid var(--border); }
.upd-item:hover { background: rgba(255,255,255,.04); }

/* Обложка 5:7 — увеличили */
.upd-cover {
  position: relative;
  width: var(--upd-row-cover);
  aspect-ratio: 5 / 7;
  border-radius: 10px;
  overflow: hidden;
  background: #0a0d12;
  border: 1px solid var(--border);
}
.upd-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Тип (TV Сериал и т.п.) — умеренно контрастный */
.upd-type{
  position: absolute; top: 4px; left: 4px;
  font-size: 10px; padding: 2px 6px; border-radius: 6px;
  background: rgba(0,0,0,.65);
  color: #e8eefc;
  border: 1px solid rgba(255,255,255,.18);
}

/* Возраст — НЕ прозрачный, читаемый. Цвет по уровню. */
.upd-age{
  position: absolute; bottom: 4px; left: 4px;
  font-size: 10px; font-weight: 800;
  padding: 2px 6px; border-radius: 6px;
  color: #fff; border: none; letter-spacing: .2px;
  text-shadow: 0 1px 1px rgba(0,0,0,.35);
}
.upd-age.age-0  { background: #64748b; }   /* Нет/0+  — серо-синий */
.upd-age.age-12 { background: #2563eb; }   /* 12+ — понасыщеннее синего */
.upd-age.age-16 { background: #f59e0b; }   /* 16+     — янтарный */
.upd-age.age-18 { background: #ef4444; }   /* 18+     — красный */

/* Текст справа */
.upd-title {
  font-weight: 800; font-size: 14px; line-height: 1.25; margin-bottom: 3px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-clamp: 2; overflow: hidden;
}
/* Один ряд: «Эпизод 10 — Название» + обрезка в конце */
.upd-ep {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.upd-ep .ep-num  { font-weight: 800; }
.upd-ep .ep-name { opacity: .9; }
.upd-ep .ep-extra{ color: var(--muted); margin-left: 10px; font-size: 12px; }
.upd-time { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Кнопка «Показать ещё» */
.updates-more { display:flex; justify-content:center; margin-top: 10px; }
.updates-more .btn, .updates-more .btn-ghost-old { min-width: 220px; }

/* ==========================================================================
   NOW WATCHING PANEL (RIGHT COLUMN)
   ========================================================================== */

/* Правая колонка: панель «Сейчас смотрят» */
.now-panel {
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 12px;
}

.now-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 8px;
}
.now-title {
  font-weight: 800; font-size: 16px; display: flex; align-items: center; gap: 6px;
  cursor: pointer;
}
.now-title .arrow { opacity: .7; transition: transform .15s ease; }
.now-title:hover .arrow { transform: translateX(2px); opacity: 1; }

/* сегмент «За день / За неделю / За месяц» */
.now-filters { display: flex; align-items: center; gap: 6px; }
.now-pill {
  background: rgba(255,255,255,.06);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12px; padding: 4px 8px; border-radius: 999px; cursor: pointer;
}
.now-pill.active { background: var(--primary); color: #fff; border-color: transparent; }

/* три колонки (Завершённое / Онгоинг / Полнометражное) */
.now-cols { display: grid; grid-template-columns: 1fr; gap: 10px; }
.now-col { background: rgba(255,255,255,.02); border: 1px solid var(--border); border-radius: 10px; padding: 8px; }
.now-col .col-title { font-weight: 700; font-size: 13px; margin-bottom: 6px; color: var(--muted); }

/* элементы списка в колонке */
.now-item {
  display: grid; grid-template-columns: 44px 1fr; gap: 10px; align-items: center;
  padding: 6px; border-radius: 8px; cursor: pointer;
}
.now-item:hover { background: rgba(255,255,255,.04); }
.now-item + .now-item { margin-top: 2px; }

.now-thumb { width: 44px; height: 44px; border-radius: 8px; overflow: hidden; background:#0a0d12; border:1px solid var(--border); }
.now-thumb img { width:100%; height:100%; object-fit: cover; display:block; }

.now-name { font-size: 13px; font-weight: 700; line-height: 1.3; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.now-meta { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.now-meta .eye { display: inline-flex; align-items: center; gap: 4px; opacity: .9; }

/* правая мини‑панель — убираем маркеры/фокус/счётчики глаз */
.now-panel .updates-list, .now-panel .updates-list * { list-style:none !important; }
.now-panel .now-meta .eye { display: none !important; } /* НЕ показывать «сколько смотрят» */

/* возрастной бейдж (контрастный) */
.upd-age{
  position:absolute; bottom:4px; left:4px;
  font-size:10px; font-weight:800; padding:2px 6px; border-radius:6px;
  color:#fff; border:none; letter-spacing:.2px; text-shadow:0 1px 1px rgba(0,0,0,.35);
}
.upd-age.age-0  { background:#64748b; }
.upd-age.age-12 { background:#2563eb; }
.upd-age.age-16 { background:#f59e0b; }
.upd-age.age-18 { background:#ef4444; }

/* убираем любые outlines в панели, чтобы не было «квадратиков» */
.updates-panel .updates-list *:focus,
.updates-panel .updates-list *:focus-visible {
  outline:none !important; box-shadow:none !important;
}

/* большая вкладка (оверлей/страница) */
#now-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 100000;
  display: flex; align-items: center; justify-content: center;
}
.now-modal {
  width: min(1100px, 92vw); max-height: 86vh; overflow: hidden;
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
  border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
  display: grid; grid-template-rows: auto 1fr auto;
}
.now-modal-head {
  display:flex; align-items:center; justify-content: space-between; gap:10px; padding:12px;
  border-bottom: 1px solid var(--border);
}
.now-modal-filters { display:flex; align-items:center; gap:8px; }
.now-modal-body { padding: 12px; overflow: auto; }

/* тёмный селект в модалке */
.now-select {
  background: rgba(17,24,39,.95);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 26px 6px 8px;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23e7edf3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: calc(100% - 6px) 50%;
}
.now-select option {
  background: #111827;
  color: #e7edf3;
}

/* компактная сетка карточек в модалке (поместится больше в ряд) */
.now-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.now-grid .card.card--poster.card--result .card-img { aspect-ratio: 5 / 7; }
.now-grid .card.card--poster.card--result .card-body { padding: 8px; }
.now-grid .card.card--poster.card--result .card-body .title {
  font-size: 13px; font-weight: 800; line-height: 1.25;
  display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden;
  line-clamp: 2;
}
.now-grid .card.card--poster.card--result .card-body .subtitle { font-size: 12px; color: var(--muted); }
.now-modal-foot {
  display: flex; justify-content: center; padding: 10px; border-top: 1px solid var(--border);
}

.now-end {
  text-align: center;
  color: var(--muted);
  padding: 18px 8px 22px;
  opacity: .9;
}
.now-end .shrug {
  font-size: 18px;
  margin-bottom: 6px;
}

/* === RELATED under player === */
.related-panel {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255,255,255,.03);
}
.related-panel.hidden { display: none !important; }
.related-head {
  font-weight: 800;
  margin: 0 0 8px;
}
.related-body { display: grid; gap: 10px; }
.related-loader {
  color: var(--muted);
  font-size: 14px;
}
.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.related-card {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255,255,255,.02);
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}
.related-card:hover {
  background: rgba(255,255,255,.04);
  border-color: var(--border-2);
  transform: translateY(-1px);
}
.rel-cover {
  width: 92px; aspect-ratio: 5 / 7;
  border-radius: 8px; overflow: hidden;
  background: #0b0e13; border: 1px solid var(--border);
}
.rel-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rel-body { display: grid; gap: 4px; }
.rel-type { font-size: 12px; color: var(--accent); font-weight: 700; opacity: .9; }
.rel-title { font-weight: 800; font-size: 14px; line-height: 1.25; }
.rel-sub { font-size: 12px; color: var(--muted); }
.related-card.related-disabled {
  opacity: .5;
  filter: grayscale(60%);
  cursor: not-allowed;
  pointer-events: none; /* на всякий, ещё и в JS дублируем */
}

/* ============= MOBILE ADAPTATION (<= 900px / 640px / 480px) ============= */

/* Базовые отступы и шапка */
@media (max-width: 900px) {
  .container { padding: 16px; }
  header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .brand { font-size: 18px; }
}

/* Поисковая строка — воздуха больше, тапы крупнее */
@media (max-width: 640px) {
  .search-row { padding: 12px; gap: 8px; }
  .search-row input { font-size: 16px; }
  .btn, .btn-ghost-old { padding: 10px 14px; border-radius: 12px; }
  .chip { padding: 8px 14px; font-size: 14px; }
}

/* Результаты поиска: ужимаем карточки, больше колонок-«плиток» не делаем */
@media (max-width: 900px) {
  #results.grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
}
@media (max-width: 480px) {
  #results.grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
  .card--result .card-body .title { font-size: 13px; }
  .card--result .card-body .subtitle { font-size: 11.5px; }
}

/* Секция выбора: обложка и мета — в столбик на узких */
@media (max-width: 640px) {
  .selection-head { grid-template-columns: 1fr; gap: 10px; }
  .head-cover { width: 100%; aspect-ratio: 5/7; }
  .head-meta .title { font-size: 16px; }
}

/* Список эпизодов: комфортная высота, одна/две колонки */
@media (max-width: 900px) {
  .ep-panel, .voice-panel { max-height: min(50vh, 520px); }
  .ep-list { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}
@media (max-width: 640px) {
  .ep-list { grid-template-columns: 1fr; }
  .ep-item { min-height: 52px; }
  .ep-num { width: 32px; height: 32px; font-size: 13px; }
}

/* Озвучки/сабы: крупнее тапы, перенос */
@media (max-width: 640px) {
  .voice-item { padding: 10px 12px; gap: 8px; }
  .voice-item .badge { font-size: 10px; }
}

/* Плеер: гарантируем высоту и безопасную область */
@media (max-width: 900px) {
  .player-shell { min-height: 42vh; }
}
@media (max-width: 640px) {
  .player-shell { min-height: 48vh; }
  .plyr__captions { bottom: 64px; }
  .plyr--hide-controls .plyr__captions { bottom: 10px; }
}

/* Related-плитки — по одной колонке */
@media (max-width: 900px) {
  .related-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}
@media (max-width: 640px) {
  .related-grid { grid-template-columns: 1fr; }
  .related-card { grid-template-columns: 84px 1fr; }
}

/* «Сейчас смотрят» — сжатые колонки */
@media (max-width: 900px) {
  .now-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .now-col .now-item { grid-template-columns: 40px 1fr; gap: 8px; }
  .now-thumb { width: 40px; height: 40px; }
}

/* Главная (лендинг) — уже облегчена у тебя, но подстрахуемся */
@media (max-width: 900px) {
  .landing-layout { grid-template-columns: 1fr; }
  .landing-row > .card { flex: 0 0 clamp(130px, 36vw, 170px); }
}

/* Чат: на мобилках — как плавающий оверлей (как у тебя во фуллскрине) */
@media (max-width: 900px) {
  /* Показываем кнопку ручки вне фуллскрина */
  .chat-handle { display: grid !important; right: 15px !important; bottom: 60px !important; }

  /* Сам чат — фиксированный оверлей справа внизу (как во фуллскрине) */
  #chat-container {
    position: fixed !important;
    right: calc(12px + env(safe-area-inset-right, 0px)) !important;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px)) !important;
    top: auto !important;
    width: clamp(240px, 80vw, 340px) !important;
    max-height: clamp(260px, 64vh, 520px) !important;
    z-index: 2002 !important;
    display: flex !important;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    border-radius: 14px;
    background: rgba(22, 26, 34, 0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255,255,255,0.10);
    box-shadow: -10px 12px 30px rgba(0,0,0,0.35);
    overflow: hidden;
    transform: translateX(calc(100% + 12px));
    opacity: 0; visibility: hidden;
    transition: transform .32s cubic-bezier(0.22, 1, 0.36, 1),
                opacity .32s cubic-bezier(0.22, 1, 0.36, 1),
                visibility .32s cubic-bezier(0.22, 1, 0.36, 1);
    pointer-events: auto !important;
  }
  #chat-container.is-open {
    transform: translateX(0);
    opacity: 1; visibility: visible;
  }
  /* Тёмный инпут */
  #chat-container .chat-form input {
    background: rgba(13, 16, 22, 0.95) !important;
    color: #e9eef6 !important;
    border: 1px solid rgba(255,255,255,0.18) !important;
  }
  #chat-container .chat-header { display: none !important; }
}

/* Кнопки/чипы — тач-цели 44px */
@media (max-width: 640px) {
  .chip { min-height: 44px; display: inline-flex; align-items: center; }
  .btn, .btn-ghost-old { min-height: 44px; }
}

/* Элементы карусели — показатели hover уменьшить на тачах */
@media (hover: none) and (pointer: coarse) {
  .card:hover, .related-card:hover, .upd-item:hover { transform: none; }
}

/* Подправим «toolbar» и блоки рядом с плеером */
@media (max-width: 900px) {
  .toolbar { grid-template-columns: 1fr; gap: 12px; }
}

/* Безопасная зона iOS для оверлеев/кнопки чата */
@supports (padding: max(0px)) {
  @media (max-width: 900px) {
    .chat-handle { bottom: calc(60px + env(safe-area-inset-bottom, 0px)) !important; }
    #chat-container { right: calc(12px + env(safe-area-inset-right, 0px)) !important; }
  }
}