/* Общая разметка всех сайтов. Цвета, шрифты, скругления — переменные из sites/<id>/theme.css.
   Тема может переопределять и любые правила ниже. */
:root {
  --bg: #0f0f12; --panel: #18181d; --line: #2a2a31; --text: #ececf1; --text-soft: #c9c9d3; --muted: #9a9aa6;
  --accent: #ff4d6d; --accent-text: #fff;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif; --font-head: var(--font);
  --radius: 10px; --radius-sm: 8px; --max: 1200px;
  --poster-ratio: 3 / 4; --grid-min: 150px;
  --empty-poster: linear-gradient(160deg, #3a2030, #1b1b28 70%); --empty-poster-text: #f3d6de;
  --header-bg: rgba(15,15,18,.92);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 var(--font);
  -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
main { max-width: var(--max); margin: 0 auto; padding: 20px 16px 48px; }
h1, h2 { font-family: var(--font-head); }
h1 { font-size: 22px; margin: 4px 0 16px; }
h2 { font-size: 17px; margin: 24px 0 10px; }
.muted, .empty { color: var(--muted); font-weight: 400; }

/* шапка */
.top { position: sticky; top: 0; z-index: 5; display: flex; gap: 16px; align-items: center; padding: 10px 16px;
  background: var(--header-bg); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.logo { display: flex; align-items: center; gap: 8px; font-family: var(--font-head); font-weight: 700; font-size: 18px; color: var(--accent); white-space: nowrap; }
.logo img { width: 26px; height: 26px; }
.search { display: flex; gap: 8px; flex: 1; min-width: 0; max-width: 460px; margin-left: auto; }
.search input { flex: 1; min-width: 0; background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 8px 12px; font: inherit; font-size: 16px; /* меньше 16px — iOS увеличивает страницу при фокусе */ }
.search input:focus { outline: none; border-color: var(--muted); }

/* вступление, жанры, крошки */
.intro { color: var(--text-soft); max-width: 760px; margin: -6px 0 14px; }
.genres, .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.genres { margin: 0 0 8px; }
.chips { margin-top: 10px; }
.chip { font-size: 12px; padding: 3px 9px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); }
a.chip:hover { border-color: var(--muted); }
.chip-active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.crumbs { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
.crumbs a:hover { color: var(--text); }

/* сетка карточек */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--grid-min), 1fr)); gap: 18px 14px; }
.row { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(var(--grid-min), 1fr); gap: 14px;
  overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 6px; }
.row .card { scroll-snap-align: start; }
.card { display: block; }
.card:hover .poster { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,.5); }
.poster { display: block; width: 100%; aspect-ratio: var(--poster-ratio); object-fit: cover; border-radius: var(--radius);
  background: var(--panel); transition: transform .15s, box-shadow .15s; }
.poster-empty { display: flex; align-items: flex-end; padding: 10px; font-weight: 600; font-size: 13px;
  background: var(--empty-poster); color: var(--empty-poster-text); overflow: hidden; }
.poster-empty span { display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.card-name { margin-top: 8px; font-weight: 600; font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }

.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 28px; color: var(--muted); }
.pager a { color: var(--text); background: var(--panel); border: 1px solid var(--line); padding: 8px 14px; border-radius: var(--radius-sm); }

/* страница сериала: на компьютере плеер слева, справа заголовок и серии; на телефоне — заголовок, плеер, серии */
.title-page { display: grid; grid-template-columns: minmax(280px, 400px) 1fr; grid-template-areas: "watch head" "watch info";
  grid-template-rows: auto 1fr; column-gap: 28px; align-items: start; }
.info-head { grid-area: head; }
.watch { grid-area: watch; position: sticky; top: 72px; }
.info { grid-area: info; }
.title-page > * { min-width: 0; }
.player { width: 100%; aspect-ratio: 9 / 16; max-height: calc(100vh - 130px); background: #000; border-radius: calc(var(--radius) + 2px); display: block; }
.player-empty { display: flex; align-items: center; justify-content: center; text-align: center; padding: 20px; color: var(--muted); background: var(--panel); }
.now { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; color: var(--muted); font-size: 13px; }
.now a { color: var(--accent); padding: 8px 0; }
.lead a { color: var(--accent); }
.btn { display: inline-block; color: var(--text); background: var(--panel); border: 1px solid var(--line); padding: 10px 16px; border-radius: var(--radius-sm); }
.info-head { display: flex; gap: 16px; align-items: flex-start; }
.poster-small { width: 110px; flex: none; }
.info-head > div { min-width: 0; }
.meta { color: var(--muted); font-size: 13px; }
.lead { color: var(--muted); }
.desc { white-space: pre-line; color: var(--text-soft); }
.actors { color: var(--muted); font-size: 13px; }
.eps { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }
.ep { text-align: center; padding: 8px 0; border-radius: var(--radius-sm); background: var(--panel); border: 1px solid var(--line); font-size: 13px; }
.ep:hover { border-color: var(--muted); }
.ep-current { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 700; }
.ep-trailer { color: var(--muted); }
.related { margin-top: 36px; }

/* служебные страницы */
.page-text { max-width: 760px; color: var(--text-soft); }
.page-text a { color: var(--accent); }

/* подвал */
.foot { max-width: var(--max); margin: 0 auto; padding: 20px 16px 32px; color: var(--muted); font-size: 13px;
  border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 8px 20px; justify-content: space-between; }
.foot nav { display: flex; flex-wrap: wrap; gap: 0 16px; }
.foot nav a { padding: 6px 0; }
.foot a:hover { color: var(--text); }

@media (max-width: 760px) {
  /* шапка в одну строку: логотип + поиск */
  .top { gap: 12px; padding: 8px 12px; }
  .logo { font-size: 17px; flex: none; }
  .search { max-width: none; margin: 0; }
  .search input { padding: 7px 10px; }
  main { padding: 14px 12px 40px; }
  h1 { font-size: 20px; margin-bottom: 12px; }
  /* жанры — одной прокручиваемой строкой, кнопки под палец */
  .genres { flex-wrap: nowrap; overflow-x: auto; margin: 0 -12px 8px; padding: 2px 12px 6px; scrollbar-width: none; }
  .genres::-webkit-scrollbar { display: none; }
  .genres .chip, a.chip { flex: none; padding: 8px 12px; font-size: 13px; }
  .crumbs { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .grid { gap: 16px 10px; }
  /* сериал: заголовок → плеер → серии → описание */
  .title-page { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "watch" "info"; grid-template-rows: auto; }
  .info-head { margin-bottom: 14px; gap: 12px; }
  .info-head h1 { margin: 0 0 6px; }
  .poster-small { width: 72px; }
  .info-head .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-right: -12px; }
  .info-head .chips::-webkit-scrollbar { display: none; }
  .watch { position: static; }
  .player { width: min(100%, calc(70vh * 9 / 16)); max-height: none; margin: 0 auto; }
  .now { font-size: 14px; }
  .now a { padding: 10px 0; }
  .ep { padding: 11px 0; font-size: 14px; }
  .eps { grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); }
  .row { grid-auto-columns: 42%; }
}
.page-text ul { padding-left: 20px; }
.page-text li { margin: 4px 0; }

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

/* кнопка ленты на главной */
.feed-cta { display: flex; align-items: center; gap: 12px; margin: 4px 0 16px; padding: 12px 16px; max-width: 420px;
  background: var(--accent); color: var(--accent-text); border-radius: calc(var(--radius) + 4px); }
.feed-cta b { display: block; font-size: 16px; }
.feed-cta small { display: block; font-size: 13px; opacity: .85; }
.feed-cta-icon { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 50%;
  background: rgba(255,255,255,.2); font-size: 16px; padding-left: 3px; }
.feed-cta:active { transform: scale(.98); }

/* лента: каждый слайд — экран, листание вверх-вниз с прилипанием */
body.feed-mode { overflow: hidden; background: #000; }
body.feed-mode main { max-width: none; padding: 0; }
.feed { position: fixed; inset: 0; overflow-y: auto; scroll-snap-type: y mandatory; overscroll-behavior: contain;
  background: #000; scrollbar-width: none; }
.feed::-webkit-scrollbar { display: none; }
.slide { position: relative; height: 100%; /* ровно высота окна ленты, без «выглядывающего» соседа */ scroll-snap-align: start; scroll-snap-stop: always;
  display: flex; justify-content: center; align-items: center; overflow: hidden; }
.slide video { height: 100%; width: 100%; max-width: calc(100dvh * 9 / 16); object-fit: cover; background: #000; }
.slide-ui { position: absolute; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: calc(100dvh * 9 / 16);
  padding: 60px 16px calc(20px + env(safe-area-inset-bottom)); display: flex; align-items: flex-end; gap: 12px;
  background: linear-gradient(transparent, rgba(0,0,0,.75)); color: #fff; pointer-events: none; }
.slide-ui a, .slide-ui button { pointer-events: auto; }
.slide-info { flex: 1; min-width: 0; }
.slide-title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  font-weight: 700; font-size: 17px; text-shadow: 0 1px 3px rgba(0,0,0,.6); }
.slide-ep { font-size: 13px; opacity: .85; margin-top: 4px; }
.slide-btn { flex: none; padding: 11px 14px; border-radius: 999px; background: var(--accent); color: var(--accent-text);
  font-weight: 600; font-size: 14px; white-space: nowrap; }
.slide-progress { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--accent); width: 0; }
.slide-center { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.slide-center span { padding: 10px 16px; border-radius: 999px; background: rgba(0,0,0,.55); color: #fff; font-size: 14px; }
.slide-play { position: absolute; inset: 0; margin: auto; width: 72px; height: 72px; border-radius: 50%; border: 0;
  background: rgba(0,0,0,.45); color: #fff; font-size: 28px; padding-left: 6px; cursor: pointer; }
.feed-btn { position: fixed; z-index: 10; border: 0; cursor: pointer; color: #fff; background: rgba(0,0,0,.45);
  border-radius: 999px; backdrop-filter: blur(6px); }
.feed-close { position: fixed; z-index: 10; top: calc(12px + env(safe-area-inset-top)); right: 12px; width: 40px; height: 40px;
  display: grid; place-items: center; border-radius: 50%; background: rgba(0,0,0,.45); color: #fff; font-size: 26px; line-height: 1; }
.feed-unmute { top: calc(12px + env(safe-area-inset-top)); left: 12px; padding: 10px 14px; font-size: 14px; }
.feed-hint { position: fixed; z-index: 9; left: 50%; bottom: calc(110px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  padding: 8px 14px; border-radius: 999px; background: rgba(0,0,0,.55); color: #fff; font-size: 13px; white-space: nowrap; margin-bottom: 110px;
  animation: feed-hint 2.4s ease-in-out 3; pointer-events: none; }
@keyframes feed-hint { 0%, 100% { transform: translate(-50%, 0); } 50% { transform: translate(-50%, -10px); } }
@media (min-width: 761px) {
  .slide video { border-radius: 12px; height: calc(100% - 32px); }
}

/* лайк в ленте — справа, над подписью */
.slide-like { position: absolute; z-index: 2; right: max(12px, calc(50% - 50dvh * 9 / 16 + 12px)); bottom: calc(110px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; gap: 2px; border: 0; background: none; color: #fff; cursor: pointer;
  text-shadow: 0 1px 4px rgba(0,0,0,.6); }
.slide-like span { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; background: rgba(0,0,0,.4); font-size: 28px; line-height: 1; }
.slide-like small { font-size: 12px; }
.slide-like.on span { color: var(--accent); animation: like-pop .3s ease-out; }
@keyframes like-pop { 0% { transform: scale(.7); } 60% { transform: scale(1.2); } 100% { transform: scale(1); } }

/* лайк на странице сериала */
.like-btn { display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text); font: inherit; font-size: 14px; cursor: pointer; }
.like-btn span { font-size: 18px; line-height: 1; }
.like-btn.on { border-color: var(--accent); }
.like-btn.on span { color: var(--accent); }

/* персональные ряды на главной */
.personal[hidden] { display: none; }
.personal-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.personal-reset { border: 0; background: none; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; padding: 8px 0; }

/* просмотренные серии (обе раскладки) */
.ep-watched { position: relative; color: var(--muted); }
.ep-watched::after { content: "✓"; position: absolute; top: 1px; right: 4px; font-size: 10px; color: var(--accent); }
.ep.ep-current.ep-watched { color: var(--accent-text); }
.ep.ep-current.ep-watched::after { color: var(--accent-text); }

/* ---------- вид «история» (layout.title = 'story') ---------- */
.story { max-width: 760px; margin: 0 auto; }
.story-hero { position: relative; isolation: isolate; text-align: center; padding: 28px 16px 20px; margin: 0 -16px 8px; overflow: hidden; }
.story-hero::before { content: ""; position: absolute; inset: -40px; z-index: -2; background: var(--story-bg, none) center / cover;
  filter: blur(36px) saturate(1.3); opacity: .55; transform: scale(1.1); }
.story-hero::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(transparent 30%, var(--bg) 92%); }
.story-poster { width: 168px; margin: 0 auto 14px; box-shadow: 0 14px 32px rgba(0,0,0,.28); }
.story-hero h1 { margin: 0 0 6px; }
.story-hero .chips { justify-content: center; }
.story-actions { display: flex; gap: 10px; justify-content: center; margin-top: 16px; }
.story-play { display: inline-flex; align-items: center; justify-content: center; gap: 8px; flex: 1; max-width: 360px; min-height: 50px;
  padding: 12px 22px; border-radius: 999px; background: var(--accent); color: var(--accent-text); font-size: 16px; }
.story-play b { font-weight: 600; }
.story-play.is-off { background: var(--panel); color: var(--muted); }
.story-like { margin: 0; width: 50px; height: 50px; justify-content: center; padding: 0; flex: none; }
.story-like span { font-size: 22px; }
.story-progress { max-width: 360px; margin: 14px auto 0; text-align: left; }
.story-bar { height: 5px; border-radius: 5px; background: var(--line); overflow: hidden; }
.story-bar i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 5px; }
.story-progress small { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; }
.story-lead { text-align: center; }
.story-tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 0 10px; padding-bottom: 2px; }
.story-tabs::-webkit-scrollbar { display: none; }
.story-tabs button { flex: none; border: 1px solid var(--line); background: var(--panel); color: var(--text-soft); font: inherit; font-size: 13px;
  padding: 7px 14px; border-radius: 999px; cursor: pointer; }
.story-tabs button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.story-grid { grid-template-columns: repeat(5, 1fr); }
.story-grid .ep[hidden] { display: none; }
.title-intro { color: var(--text-soft); margin: 0 0 10px; }
.story-desc.clamped { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.story-more { border: 0; background: none; padding: 6px 0; color: var(--accent); font: inherit; cursor: pointer; }
.story .related .row { grid-auto-columns: minmax(140px, 1fr); }

/* полноэкранный плеер истории — поверх страницы, на основе стилей ленты */
.story-player { z-index: 8; }
body.story-open .feed-close, body.story-open .feed-unmute { z-index: 11; }
.story-player-like { position: fixed; z-index: 11; }
.story-hint { position: absolute; left: 0; right: 0; bottom: calc(96px + env(safe-area-inset-bottom)); text-align: center; color: rgba(255,255,255,.8);
  font-size: 12px; pointer-events: none; text-shadow: 0 1px 3px rgba(0,0,0,.6); }

@media (max-width: 760px) {
  .story-hero { margin: 0 -12px 8px; padding: 22px 12px 18px; }
  .story-poster { width: 150px; }
}
@media (min-width: 761px) {
  .story-hero { margin: 0 0 8px; border-radius: 24px; }
  .story-grid { grid-template-columns: repeat(10, 1fr); }
}

/* карточка выбора в ленте: «Продолжить» или «Другие сериалы» */
.slide-choice { background: #000; }
.slide-choice::before { content: ""; position: absolute; inset: -40px; background: var(--choice-bg, none) center / cover;
  filter: blur(28px) brightness(.45); transform: scale(1.1); }
.choice-card { position: relative; width: min(88%, 340px); padding: 26px 22px; border-radius: 22px; text-align: center; color: #fff;
  background: rgba(20, 20, 24, .55); backdrop-filter: blur(10px); box-shadow: 0 20px 40px rgba(0,0,0,.4); }
.choice-seen { margin: 0 0 6px; font-size: 13px; opacity: .8; }
.choice-title { margin: 0 0 20px; font-size: 20px; line-height: 1.3; }
.choice-btn { display: block; width: 100%; min-height: 50px; margin-top: 10px; border-radius: 999px; font: inherit; font-size: 16px;
  font-weight: 600; cursor: pointer; border: 1px solid rgba(255,255,255,.35); background: transparent; color: #fff; }
.choice-continue { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.choice-btn:disabled { opacity: .6; }

/* классическая страница: кнопка полноэкранного режима «Смотреть подряд» под плеером */
.watch-row { display: flex; width: 100%; max-width: none; min-height: 48px; margin-top: 10px; font-size: 15px; }
.watch-row span { font-size: 18px; }
.watch-frame { position: relative; }
.watch-expand { position: absolute; top: 10px; right: 10px; z-index: 2; flex: none; min-height: 0; width: 42px; height: 42px; padding: 0;
  border-radius: 50%; background: rgba(0,0,0,.5); color: #fff; font-size: 20px; backdrop-filter: blur(6px); }

/* окошко выбора поверх полноэкранного плеера сериала */
.story-choice { position: fixed; inset: 0; z-index: 12; display: grid; place-items: center; background: rgba(0,0,0,.55); backdrop-filter: blur(6px); }
a.choice-btn { display: flex; align-items: center; justify-content: center; text-decoration: none; }

/* текст о сайте внизу главной */
.seo-text { max-width: 820px; margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--line); color: var(--text-soft); font-size: 14px; }
.seo-text h2 { margin-top: 0; }
