/* Тема «Pastel Minimal» (Sakura): плоско, светло, один розовый акцент. Без градиентов, теней, рейтингов и значков. */

:root {
  color-scheme: light;
  --bg: #fff8fb;          /* фон страницы */
  --card: #ffffff;        /* поверхности: поиск, чипы, кнопки */
  --line: #f4dce6;        /* все границы и разделители */
  --text: #43303c;        /* основной текст */
  --muted: #a58b98;       /* второстепенный текст */
  --pink: #f08ab4;        /* акцент: главная кнопка, выбранный чип, активный файл */
  --pink-hover: #e9739f;  /* наведение, значки play */
  --pink-soft: #fde6ef;   /* заливка героя */
  --hero-text: #7e6671;
  --r: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
button, select, a, input { -webkit-tap-highlight-color: transparent; }
button, select { touch-action: manipulation; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
h1, h2 { letter-spacing: -.02em; }
code { padding: 1px 6px; border-radius: 6px; background: var(--pink-soft); color: var(--text); font-size: .92em; }
a { color: var(--pink-hover); }

/* ---------- кнопки, списки, поля ---------- */
button, select {
  font: inherit; color: var(--text);
  background: var(--card); border: 1px solid var(--line); border-radius: 99px;
  padding: 9px 18px; cursor: pointer;
  transition: color .2s, border-color .2s, background .2s;
}
button:hover { color: var(--pink-hover); border-color: var(--pink); }
/* выпадающие списки: свой тонкий шеврон вместо системного (он липнет к краю и тёмный), та же высота и шрифт, что у подписи рядом */
select {
  -webkit-appearance: none; appearance: none;
  height: 36px; padding: 0 34px 0 16px; font-size: 13px; line-height: 34px; text-overflow: ellipsis;
  background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23a58b98' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 15px center / 10px 6px;
}
select:hover { border-color: var(--pink); }
select:focus-visible { border-color: var(--pink); }
button:focus-visible, select:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--pink); outline-offset: 2px; }
button.primary { padding: 13px 26px; background: var(--pink); border-color: var(--pink); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--pink-hover); border-color: var(--pink-hover); color: #fff; }
button.round { width: 40px; height: 40px; padding: 0; border-radius: 50%; font-size: 22px; line-height: 1; display: grid; place-items: center; }
button.link { padding: 0; border: 0; background: none; border-radius: 0; color: var(--muted); }
button.link:hover { color: var(--text); background: none; }
input[type=range] { accent-color: var(--pink); }

/* ---------- шапка ---------- */
.top { position: sticky; top: 0; z-index: 20; background: rgba(255, 248, 251, .92); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1180px; height: 64px; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; gap: 28px; }
a.brand { display: flex; align-items: center; flex: none; text-decoration: none; }
.logo { display: block; height: 34px; width: auto; }

.search { position: relative; flex: 1; max-width: 560px; }
.search input {
  width: 100%; height: 42px; padding: 0 48px 0 20px;
  border: 1px solid var(--line); border-radius: 99px; background: var(--card);
  font: inherit; font-size: 14px; color: var(--text); outline: none;
  transition: border-color .2s;
}
.search input:focus { border-color: var(--pink); }
.search input::placeholder { color: var(--muted); }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; width: 14px; height: 14px; margin: 0 4px 0 0; cursor: pointer; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'%3E%3Cpath d='M3 3l8 8M11 3l-8 8' fill='none' stroke='%23a58b98' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat; }
.search input::-webkit-search-cancel-button:hover { opacity: .7; }
.search-btn { position: absolute; right: 5px; top: 5px; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--muted); display: grid; place-items: center; }
.search-btn:hover { color: var(--pink-hover); border: 0; }

.suggest { position: absolute; left: 0; right: 0; top: calc(100% + 8px); margin: 0; padding: 6px; list-style: none; max-height: 380px; overflow: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); z-index: 30; }
.suggest .group { padding: 10px 12px 4px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.suggest [role=option] { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; padding: 9px 12px; border-radius: 10px; cursor: pointer; font-size: 14px; }
.suggest [role=option]:hover, .suggest [role=option][aria-selected=true] { background: var(--pink-soft); }
.suggest .t { font-weight: 500; overflow-wrap: anywhere; }
.suggest .m { flex: none; font-size: 12px; color: var(--muted); white-space: nowrap; }

.msg { width: calc(100% - 40px); max-width: 1140px; margin: 16px auto 0; padding: 12px 18px; border-radius: var(--r); background: var(--pink-soft); border: 1px solid var(--line); color: var(--text); }
.msg.info { background: var(--card); }

/* ---------- главная: герой и каталог ---------- */
.library { width: 100%; max-width: 1180px; margin: 0 auto; padding: 28px 20px 0; }
.hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 48px; padding: 56px; border-radius: 24px; background: var(--pink-soft); }
.hero[hidden] { display: none; }
.hero-art { display: block; width: 196px; height: auto; aspect-ratio: 2 / 3; object-fit: cover; border-radius: var(--r); background: #f8c8dc; }
.hero h2 { max-width: 14em; margin: 0 0 16px; font-size: clamp(34px, 5vw, 58px); line-height: 1.05; font-weight: 700; letter-spacing: -.03em; }
.hero-desc { max-width: 560px; margin: 0 0 10px; color: var(--hero-text); font-size: 17px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.hero-meta { margin: 0 0 28px; color: var(--hero-text); font-size: 13px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.hero-actions button:not(.primary) { padding: 13px 26px; }

.catalog { margin-top: 56px; }
.hero[hidden] + .catalog { margin-top: 12px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.section-head h2 { margin: 0; font-size: 22px; font-weight: 700; }
.sort { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; line-height: 1; }
.sort select { min-width: 150px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 7px 16px; font-size: 13px; color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--pink); border-color: var(--pink); color: #fff; }
.chip[aria-pressed="true"]:hover { background: var(--pink-hover); border-color: var(--pink-hover); color: #fff; }

.lib-status { margin: 18px 0 0; min-height: 21px; color: var(--muted); font-size: 13px; }
.lib-status button.link { text-decoration: underline; }

.grid { list-style: none; margin: 20px 0 0; padding: 0 0 56px; display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 22px; }
.grid[aria-busy="true"] { opacity: .6; transition: opacity .2s .15s; }
.card { position: relative; }
.art { position: relative; transition: transform .2s; }
.card:hover .art, .card:focus-within .art { transform: translateY(-4px); }
.poster {
  display: block; width: 100%; padding: 0; overflow: hidden; border: 0; border-radius: var(--r);
  aspect-ratio: 2 / 3; background: var(--tile, #f8c8dc);
}
.poster:hover { border: 0; }
.poster img { display: block; width: 100%; height: 100%; object-fit: cover; }
.poster-letter { display: grid; place-items: center; width: 100%; height: 100%; font-size: 72px; font-weight: 700; color: rgba(255, 255, 255, .7); }
.card-play {
  position: absolute; right: 8px; bottom: 8px; width: 36px; height: 36px; padding: 0 0 0 3px; border: 0; border-radius: 50%;
  display: grid; place-items: center; font-size: 14px; background: #fff; color: var(--pink-hover); opacity: 0;
  transition: opacity .2s;
}
.card-play:hover { border: 0; color: var(--pink-hover); }
.card:hover .card-play, .card:focus-within .card-play { opacity: 1; }
@media (hover: none) { .card-play { opacity: 1; } }
.label { display: block; width: 100%; margin-top: 10px; padding: 0; border: 0; border-radius: 0; background: none; text-align: left; }
.label:hover { color: var(--text); }
.card-title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 14px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
mark { padding: 0; background: none; color: var(--pink-hover); font-weight: 700; }
.card-meta { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); }
.label:hover .card-title { color: var(--pink-hover); }

/* ---------- страницы каталога ---------- */
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; padding: 0 0 64px; }
.pager button { min-width: 40px; height: 40px; padding: 0 14px; font-size: 14px; }
.pager button[aria-current="page"], .pager button[aria-current="page"]:hover { background: var(--pink); border-color: var(--pink); color: #fff; cursor: default; }
.pager button:disabled { opacity: .45; cursor: default; }
.pager button:disabled:hover { color: var(--text); border-color: var(--line); }
.pager .gap { color: var(--muted); padding: 0 4px; }

/* ---------- карточка фильма (модальное окно) ---------- */
.film { position: relative; width: min(900px, calc(100vw - 24px)); max-height: calc(100vh - 32px); padding: 22px; border: 0; border-radius: 22px; background: var(--bg); color: var(--text); overflow: auto; }
.film[open] { animation: fade .2s; }
.film::backdrop { background: rgba(67, 48, 60, .4); }
.film[open]::backdrop { animation: fade .2s; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
#film-close { position: sticky; top: 0; z-index: 3; margin: -6px -6px -34px auto; background: var(--bg); }
.film-body { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 28px; }
.film-cover { width: 100%; height: auto; aspect-ratio: 2 / 3; object-fit: cover; border-radius: var(--r); background: var(--pink-soft); }
.film-info { padding-right: 44px; }
.film-info h2 { margin: 0; font-size: 30px; line-height: 1.15; font-weight: 700; }
.film-sub, .film-genres { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.film-desc { margin: 18px 0; line-height: 1.6; }
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 20px; margin: 0 0 22px; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.film-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- экран просмотра ---------- */
.layout { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 32px; padding: 24px 20px 48px; align-items: start; }
.layout.with-side { grid-template-columns: minmax(0, 1fr) 300px; }

.player { position: relative; min-width: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.player:fullscreen { display: flex; flex-direction: column; border: 0; border-radius: 0; background: #000; }
.player:fullscreen .stage { flex: 1; aspect-ratio: auto; max-height: none; }
.crumbs { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 18px; border-bottom: 1px solid var(--line); font-size: 14px; }
.player:fullscreen .crumbs { display: none; }

.stage { touch-action: manipulation; position: relative; background: #000; aspect-ratio: 16 / 9; max-height: 72vh; width: 100%; cursor: pointer; user-select: none; -webkit-user-select: none; }
.stage.idle { cursor: none; }
.mount, .mount > * { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.mount video, .mount avbridge-video { background: #000; }

.overlay { cursor: default; position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 24px; background: var(--pink-soft); z-index: 2; }
.overlay.clear { display: none; }
.overlay-inner { width: 100%; max-width: 520px; }
.overlay h1, .overlay p { overflow-wrap: anywhere; }
.overlay h1 { margin: 0 0 8px; font-size: 22px; line-height: 1.3; }
.overlay p { margin: 0 0 16px; color: var(--hero-text); }

.spinner { width: 34px; height: 34px; margin: 0 auto 14px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--pink); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* панель: сверху дорожка перемотки на всю ширину, под ней компактный ряд кнопок */
.controls { position: relative; display: flex; align-items: center; flex-wrap: wrap; gap: 4px 6px; padding: 4px 14px 8px; background: rgba(255, 255, 255, .88); border-top: 1px solid var(--line); }
.player:fullscreen .controls { background: rgba(255, 255, 255, .92); }
button.icon { display: grid; place-items: center; width: 30px; height: 30px; min-width: 30px; padding: 0; }
button.icon svg { display: block; width: 16px; height: 16px; }
button.icon[aria-expanded="true"] { color: var(--pink-hover); border-color: var(--pink); }
.time { margin: 0 auto 0 4px; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; white-space: nowrap; }
.seek { position: relative; order: -1; flex: 1 0 100%; height: 24px; min-width: 0; }
.seek canvas { position: absolute; left: 0; right: 0; top: 50%; z-index: 0; width: 100%; height: 6px; margin-top: -3px; border-radius: 3px; background: var(--line); }
.seek-fill { position: absolute; left: 0; top: 50%; z-index: 1; width: 0; height: 6px; margin-top: -3px; border-radius: 3px; background: var(--pink); pointer-events: none; }
.seek:hover canvas, .seek:hover .seek-fill { height: 8px; margin-top: -4px; }
.seek-tip { position: absolute; bottom: 30px; z-index: 3; transform: translateX(-50%); padding: 2px 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; pointer-events: none; }
.seek input { position: absolute; z-index: 2; inset: 0; width: 100%; height: 100%; margin: 0; background: transparent; -webkit-appearance: none; appearance: none; cursor: pointer; }
.seek input::-webkit-slider-runnable-track { background: transparent; height: 24px; }
.seek input::-moz-range-track { background: transparent; height: 24px; }
.seek input::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; margin-top: 5px; border-radius: 50%; background: var(--pink); border: 2px solid #fff; }
.seek input::-moz-range-thumb { width: 10px; height: 10px; border: 2px solid #fff; border-radius: 50%; background: var(--pink); }
#c-vol { width: 72px; }
#c-audio, #c-subs, #c-speed { max-width: 130px; height: 30px; padding: 0 26px 0 12px; font-size: 12px; line-height: 28px; background-position: right 10px center; background-size: 9px 5px; }
#c-audio, #c-subs { max-width: 210px; text-overflow: ellipsis; } /* у озвучек и субтитров из раздач названия длинные */
button.icon:disabled { opacity: .4; cursor: default; }
button.icon:disabled:hover { color: var(--text); border-color: var(--line); }

/* список серий (когда в раздаче больше одного видео) */
.episodes { padding: 10px 18px 12px; border-top: 1px solid var(--line); }
.ep-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 8px; }
.ep-head h2 { margin: 0; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.ep-now { min-width: 0; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.ep-groups { display: flex; flex-direction: column; gap: 10px; }
.ep-group h3 { margin: 0 0 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.ep-list { display: flex; flex-wrap: wrap; gap: 6px; max-height: 172px; overflow: auto; padding: 2px; }
.ep { min-width: 38px; height: 28px; padding: 0 10px; font-size: 12px; font-variant-numeric: tabular-nums; }
.ep.text { padding: 0 14px; }
.ep.active, .ep.active:hover { background: var(--pink); border-color: var(--pink); color: #fff; }
details.ep-extras > summary { cursor: pointer; list-style: none; font-size: 12px; font-weight: 600; color: var(--muted); }
details.ep-extras > summary::before { content: '▸ '; }
details.ep-extras[open] > summary::before { content: '▾ '; }
details.ep-extras .ep-group { margin-top: 8px; }

.now { padding: 14px 18px 16px; border-top: 1px solid var(--line); }
.now-name { font-weight: 600; overflow-wrap: anywhere; }
.badges { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 12px; color: var(--muted); }
.now-desc { margin: 6px 0 0; color: var(--hero-text); font-size: 14px; max-width: 70ch; }
.now-desc:empty { display: none; }
.credit { margin: 8px 0 0; color: var(--muted); font-size: 12px; }

.side { min-width: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 6px 18px 18px; }
.side h2 { margin: 16px 0 10px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.hint { margin: 0; color: var(--muted); font-size: 13px; }

.files { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 46vh; overflow: auto; }
.file { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 14px; border-radius: 14px; text-align: left; font-size: 13px; }
.file .name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.file .size { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.file .tag { font-size: 11px; color: var(--muted); white-space: nowrap; }
.file.other { opacity: .5; cursor: default; }
.file.other:hover { color: var(--text); border-color: var(--line); }
.file.active, .file.active:hover { background: var(--pink); border-color: var(--pink); color: #fff; }
.file.active .tag, .file.active .size { color: #fff; }

.stats { margin: 0; display: grid; gap: 8px; font-size: 14px; }
.stats > div { display: flex; justify-content: space-between; gap: 12px; }
.stats dt { color: var(--muted); }
.stats dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

/* ---------- подвал ---------- */
.foot { margin-top: auto; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.foot-in { max-width: 1180px; margin: 0 auto; padding: 22px 20px; display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; }

/* ---------- узкие экраны ---------- */
@media (max-width: 960px) {
  .layout.with-side { grid-template-columns: minmax(0, 1fr); }
  .layout { gap: 20px; }
  .hero { padding: 40px 28px; }
  .foot-in { gap: 8px; }
}
/* ---------- плеер: центр экрана ---------- */
.buffer-spin { position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; pointer-events: none; }
.buffer-spin .spinner { width: 58px; height: 58px; margin: 0; border-width: 5px; background: rgba(255, 255, 255, .88); }
/* субтитры поверх картинки: тёмная плашка, чтобы читалось на любом кадре; клики проходят сквозь них к экрану плеера */
.subs { position: absolute; left: 6%; right: 6%; bottom: 6%; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; pointer-events: none; }
.subs[hidden] { display: none; }
/* слой для ASS: те же границы, что у плеера; позиции и размеры считает ass.js */
.subs-ass { position: absolute; inset: 0; z-index: 1; overflow: hidden; pointer-events: none; }
.subs div { max-width: 100%; padding: 2px 10px; border-radius: 4px; background: rgba(0, 0, 0, .74); color: #fff; font-size: clamp(14px, 2.3vw, 26px); line-height: 1.35; white-space: pre-line; overflow-wrap: anywhere; }
.player:fullscreen .subs { bottom: 9%; }
.player:fullscreen .subs div { font-size: clamp(18px, 2.7vw, 40px); }
.flash { position: absolute; left: 50%; top: 50%; z-index: 3; width: 76px; height: 76px; margin: -38px 0 0 -38px; border-radius: 50%; display: grid; place-items: center; background: rgba(67, 48, 60, .55); color: #fff; opacity: 0; pointer-events: none; }
.flash svg { width: 34px; height: 34px; }
.flash.show { animation: flash .55s ease-out; }
@keyframes flash { from { opacity: .95; transform: scale(.8); } to { opacity: 0; transform: scale(1.25); } }
.seekflash { position: absolute; top: 50%; z-index: 3; padding: 12px 20px; border-radius: 99px; background: rgba(67, 48, 60, .55); color: #fff; font-weight: 600; opacity: 0; pointer-events: none; transform: translateY(-50%); }
.seekflash.left { left: 9%; }
.seekflash.right { right: 9%; }
.seekflash.show { animation: seekflash .65s ease-out; }
@keyframes seekflash { 0% { opacity: .95; } 70% { opacity: .95; } 100% { opacity: 0; } }
.toast { position: absolute; left: 14px; bottom: 14px; z-index: 4; display: flex; align-items: center; gap: 14px; max-width: calc(100% - 28px); padding: 8px 16px; border: 1px solid var(--line); border-radius: 99px; background: rgba(255, 255, 255, .94); font-size: 13px; cursor: default; }
.toast .link { color: var(--pink-hover); font-weight: 600; text-decoration: none; }
.help { position: absolute; left: 50%; top: 50%; z-index: 6; width: min(420px, calc(100% - 28px)); transform: translate(-50%, -50%); padding: 18px 20px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255, 255, 255, .97); cursor: default; font-size: 13px; }
.help h3 { margin: 0 0 10px; font-size: 14px; }
.help dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.help dt { font-weight: 600; white-space: nowrap; }
.help dd { margin: 0; color: var(--muted); }
kbd { display: inline-block; min-width: 22px; padding: 0 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); font: inherit; font-size: 12px; text-align: center; }

/* ---------- статистика для гиков ---------- */
.nerd { position: absolute; right: 12px; bottom: calc(100% + 10px); z-index: 7; width: 380px; max-width: calc(100vw - 48px); max-height: min(70vh, 560px); overflow: auto; padding: 14px 16px 16px; border: 1px solid var(--line); border-radius: 16px; background: #fff; font-variant-numeric: tabular-nums; cursor: default; }
.nerd-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.nerd-head h3 { margin: 0; font-size: 14px; }
.nerd-always { display: flex; align-items: center; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); cursor: pointer; }
.nerd-always input { accent-color: var(--pink); width: 16px; height: 16px; margin: 0; }
.nerd-speed { display: flex; align-items: baseline; gap: 8px; }
.nerd-speed b { font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
.nerd-speed span { color: var(--muted); font-size: 12px; }
.nerd canvas.spark { display: block; width: 100%; height: 64px; margin: 6px 0 12px; border-radius: 10px; background: var(--bg); }
.nerd-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 18px; margin: 0 0 12px; }
.nerd-grid div { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; }
.nerd-grid dt { color: var(--muted); }
.nerd-grid dd { margin: 0; font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.nerd h4 { margin: 12px 0 8px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.srv { display: grid; grid-template-columns: 78px minmax(0, 1fr) minmax(0, auto); align-items: center; gap: 4px 10px; margin: 0 0 8px; font-size: 12px; }
.srv-name { display: flex; align-items: center; gap: 6px; min-width: 0; font-weight: 600; }
.srv-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.srv-dot { flex: none; width: 8px; height: 8px; border-radius: 2px; background: var(--pink); }
.srv-track { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.srv-fill { height: 100%; border-radius: 4px; background: var(--pink); transition: width .4s; }
.srv.paused .srv-fill { background: var(--muted); }
.srv-num { color: var(--muted); text-align: right; }
.nerdbar { padding: 12px 18px 14px; border-top: 1px solid var(--line); background: var(--card); font-variant-numeric: tabular-nums; }
.nerdbar canvas { display: block; width: 100%; height: 40px; }
.nerdbar .nums { display: flex; flex-wrap: wrap; gap: 4px 20px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.nerdbar .nums b { color: var(--text); font-weight: 600; }
.nerdbar .key { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 8px; font-size: 11px; color: var(--muted); }
.nerdbar .key i { display: inline-block; width: 10px; height: 10px; margin-right: 6px; border-radius: 3px; vertical-align: -1px; }
.nerdbar .key i.key-ghost { box-sizing: border-box; border: 1.5px dashed var(--pink-hover); background: none; }
.nb-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 10px; min-height: 20px; margin-bottom: 8px; }
.nb-glyph { flex: none; width: 14px; text-align: center; font-family: ui-monospace, Menlo, Consolas, monospace; color: var(--pink-hover); }
.nb-main { font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.nb-sub { font-size: 12px; color: var(--muted); }
.nb-head[data-tone="warn"] .nb-glyph, .nb-head[data-tone="warn"] .nb-main { color: #d9627a; }
.nb-head[data-tone="idle"] .nb-glyph, .nb-head[data-tone="idle"] .nb-main { color: var(--muted); }
.nb-head[data-tone="ok"] .nb-glyph { color: #4fa97a; }
.nb-srvs { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.nb-srvs:empty { display: none; }
.nb-srv i { display: inline-block; width: 10px; height: 10px; margin-right: 6px; border-radius: 3px; vertical-align: -1px; }
.nb-srv b { margin-left: 6px; color: var(--text); font-weight: 600; }
.nb-srv.down > span { text-decoration: line-through; text-decoration-thickness: 1px; }
.nb-srv.down b { color: var(--muted); }
.nerd-log { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; font-size: 12px; }
.nerd-log time { margin-right: 4px; color: var(--muted); font-variant-numeric: tabular-nums; }
.nerd-log li.fail { color: #d9627a; }
.nerd-log li.ok { color: #4fa97a; }
.nerd-log li.none { color: var(--muted); }
.player:fullscreen .nerdbar { background: #fff; }

/* «пробуем другой вариант»: цепочки серверов и раздач поверх видео */
.trail { position: absolute; left: 14px; top: 14px; z-index: 5; width: min(580px, calc(100% - 28px)); padding: 12px 14px 14px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255, 255, 255, .96); font-size: 13px; cursor: default; }
.trail[hidden] { display: none; }
.trail-head { display: flex; align-items: center; gap: 10px; }
.trail-title { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.trail-dots { display: inline-flex; flex: none; gap: 3px; }
.trail-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--pink); animation: trail-dot 1.2s steps(1) infinite; }
.trail-dots i:nth-child(2) { animation-delay: .2s; }
.trail-dots i:nth-child(3) { animation-delay: .4s; }
@keyframes trail-dot { 0% { opacity: .2; } 25% { opacity: 1; } 60%, 100% { opacity: .2; } }
.trail[data-phase="recovered"] .trail-dots i { animation: none; background: var(--pink-hover); }
.trail[data-phase="failed"] .trail-dots i { animation: none; background: var(--muted); }
.trail-x { width: 22px; height: 22px; padding: 0; border: 0; background: none; color: var(--muted); font-size: 18px; line-height: 1; border-radius: 50%; }
.trail-x:hover { color: var(--text); border: 0; }
.trail-retry { padding: 4px 14px; font-size: 12px; background: var(--pink); border-color: var(--pink); color: #fff; font-weight: 600; }
.trail-retry:hover { background: var(--pink-hover); border-color: var(--pink-hover); color: #fff; }
.trail-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.trail-label { flex: none; width: 58px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.trail-chain { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0; padding: 0; list-style: none; }
.tarrow { color: var(--muted); }
.tchip { position: relative; overflow: hidden; display: inline-flex; align-items: baseline; gap: 6px; padding: 4px 11px; border: 1px solid var(--line); border-radius: 99px; background: #fff; white-space: nowrap; }
.tchip small { color: var(--muted); font-size: 11px; }
.tmark { font-size: 11px; }
.tchip.pending { border-style: dashed; color: var(--muted); }
.tchip.trying { border-color: var(--pink); background: var(--pink-soft); }
.tchip.trying::after { content: ''; position: absolute; top: 0; bottom: 0; left: 0; width: 28%; background: rgba(240, 138, 180, .3); animation: trail-sweep 1.2s steps(14) infinite; }
@keyframes trail-sweep { from { transform: translateX(-100%); } to { transform: translateX(360%); } }
.tchip.failed { background: var(--pink-soft); color: var(--muted); }
.tchip.failed b { text-decoration: line-through; text-decoration-thickness: 1px; }
.tchip.ok { background: var(--pink); border-color: var(--pink); color: #fff; }
.tchip.ok small { color: #fff; }
.tchip.enter { animation: trail-in .3s ease-out both; }
@keyframes trail-in { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .trail-dots i, .tchip.trying::after, .tchip.enter { animation: none; } }

/* ---------- телефон и планшет: в самом конце, чтобы переопределять правила выше ---------- */
@media (max-width: 600px) {
  .top { position: sticky; }
  .top-in { gap: 12px; padding: 0 14px; height: 58px; }
  .logo { height: 28px; }
  .search { position: static; }
  .search input { height: 40px; font-size: 16px; } /* 16 px: iOS не приближает страницу при вводе */
  .search-btn { top: 50%; transform: translateY(-50%); }
  .search-btn { right: calc(14px + 5px); }
  /* подсказки на всю ширину экрана, а не только под узким полем */
  .suggest { position: absolute; left: 14px; right: 14px; top: calc(100% + 6px); max-height: 60vh; }
  .library { padding: 16px 14px 0; }
  .hero { grid-template-columns: minmax(0, 1fr); padding: 28px 22px 26px; border-radius: 20px; gap: 0; }
  .hero-art { display: none; }
  .hero h2 { margin-bottom: 12px; }
  .hero-desc { font-size: 15px; }
  .hero-meta { margin-bottom: 22px; }
  .hero-actions button { flex: 1 1 auto; padding: 12px 18px; }
  .catalog { margin-top: 32px; }
  .section-head { flex-wrap: nowrap; }
  .section-head h2 { font-size: 20px; }
  .sort select { min-width: 0; font-size: 16px; height: 38px; }
  .chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -14px; padding: 2px 14px 8px; scrollbar-width: none; } /* жанры — лентой, которую можно листать пальцем */
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 12px; margin-top: 14px; }
  .card-play { width: 34px; height: 34px; right: 6px; bottom: 6px; font-size: 12px; }
  .card-title { font-size: 13px; }
  .pager { padding-bottom: 40px; }

  .film { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); padding: 14px 16px 18px; border-radius: 18px; }
  .film-body { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .film-cover { width: 46%; max-width: 190px; margin: 4px auto 0; }
  .film-info { padding-right: 0; }
  .film-info h2 { font-size: 24px; }
  .facts { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .facts dd { margin: 0 0 10px; }
  .film-actions { position: sticky; bottom: -18px; padding: 10px 0 18px; margin-bottom: -18px; background: var(--bg); }
  .film-actions button { flex: 1 1 100%; }

  .crumbs { padding: 8px 14px; }
  .layout { padding: 12px 14px 32px; gap: 16px; }
  .msg { width: calc(100% - 28px); }
  .now { padding: 12px 14px 14px; }
  .episodes { padding: 10px 14px 12px; }
  .side { padding: 4px 14px 16px; }
  .stats { font-size: 13px; }

  /* панель плеера: сверху перемотка, потом крупные кнопки и время, в конце — три списка в ряд */
  .controls { gap: 6px 4px; padding: 6px 12px 12px; }
  .seek { height: 30px; }
  .seek input::-webkit-slider-runnable-track { height: 30px; }
  .seek input::-webkit-slider-thumb { width: 18px; height: 18px; margin-top: 6px; }
  button.icon { width: 36px; height: 36px; min-width: 36px; }
  button.icon svg { width: 18px; height: 18px; }
  #c-play { width: 42px; height: 42px; min-width: 42px; }
  #c-vol, #c-pip { display: none; }
  .time { order: 0; margin: 0 auto 0 4px; font-size: 12px; }
  /* первый ряд — кнопки и время, второй — списки: база 100 px больше остатка первого ряда, поэтому списки всегда переходят на новую строку */
  #c-audio, #c-subs, #c-speed { order: 9; flex: 1 1 100px; min-width: 0; max-width: none; height: 38px; margin-top: 2px; padding: 0 28px 0 12px; font-size: 16px; line-height: 36px; background-position: right 12px center; }
  #c-audio[hidden], #c-subs[hidden] { display: none; }
  #c-speed { flex: 0 0 78px; }
  .stage { max-height: none; }

  /* окно статистики — нижний лист: у верхнего края плеера оно обрезалось */
  .nerd { position: fixed; left: 8px; right: 8px; bottom: 8px; width: auto; max-width: none; max-height: 72vh; max-height: 72dvh; z-index: 60; padding: 14px 14px 16px; border-radius: 18px; }
  .nerdbar { padding: 12px 14px 14px; }
  .nerdbar .key { display: none; }
  .nb-main { font-size: 14px; }

  .trail { left: 8px; top: 8px; width: calc(100% - 16px); padding: 10px 12px 12px; }
  .trail-label { width: 50px; }
  .toast { left: 8px; bottom: 8px; max-width: calc(100% - 16px); }
  .help { width: calc(100% - 16px); }

  .foot-in { padding: 18px 14px calc(18px + env(safe-area-inset-bottom)); flex-direction: column; }
}
@media (max-width: 360px) {
  #c-back, #c-fwd { display: none; } /* на самых узких экранах первый ряд панели не вместил бы все кнопки; ±5 с остаются на двойном касании экрана */
  .hero h2 { font-size: 30px; }
  .grid { gap: 16px 10px; }
}
@media (max-width: 960px) and (min-width: 601px) {
  .hero { grid-template-columns: minmax(0, 1fr) auto; gap: 32px; padding: 40px 32px; }
  .hero-art { width: 150px; }
}
