/* Player styles — shared across all series */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root {
  --bg: #0d0f14;
  --surface: #151821;
  --surface2: #1c202c;
  --accent: #e8a33d;
  --accent-hover: #f2b45a;
  --text: #eef0f4;
  --text2: #8b91a0;
  --border: #262b38;
  --ok: #34b273;
}
html, body { width: 100%; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font: 14px/1.4 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; }
body { display: flex; flex-direction: column; }
button, .btn-icon { font-family: inherit; }
svg { display: block; }

/* Header */
.header { height: 64px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 12px; flex-shrink: 0; gap: 8px; }
.header-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.header-poster { width: 84px; height: 47px; object-fit: cover; border-radius: 8px; flex-shrink: 0; }
.header-title { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 1px; }
.header-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; font-size: 0.95rem; }
.header-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 0.78rem; color: var(--text2); }
.header-actions { display: flex; gap: 4px; }
.btn-fallback { display: flex; align-items: center; gap: 6px; height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface2); color: var(--text2); font: inherit; font-size: 0.78rem; font-weight: 600; cursor: pointer; }
.btn-fallback svg { width: 16px; height: 16px; }
.btn-fallback:hover { color: var(--text); border-color: var(--text2); }
.btn-fallback.on { color: var(--accent); border-color: var(--accent); background: rgba(232,163,61,0.1); }
.btn-fallback.on span::after { content: " ✕"; font-weight: 400; }
.btn-icon { width: 40px; height: 40px; border-radius: 10px; border: none; background: transparent; color: var(--text2); font-size: 1.1rem; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.btn-icon svg { width: 20px; height: 20px; }
.btn-icon:hover { background: var(--surface2); color: var(--text); }
.btn-icon:active { background: var(--surface2); transform: scale(0.94); }

/* Video + custom player UI */
.video-section { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.video-container { flex: 1; background: #000; display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative; }
.video-container.cursor-hidden { cursor: none; }
.video-container video, .video-container iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: none; }
#video { object-fit: contain; }
.hidden { display: none !important; }
.player-hint { position: absolute; bottom: 76px; left: 50%; transform: translateX(-50%); background: rgba(13,15,20,0.92); border: 1px solid var(--border); color: var(--text); padding: 10px 16px; border-radius: 10px; font-size: 0.85rem; opacity: 0; transition: opacity 0.3s; pointer-events: none; max-width: 90%; text-align: center; z-index: 30; }
.player-hint.visible { opacity: 1; }

/* Всплывающая подсказка горячих клавиш (громкость, перемотка, скорость) */
.vui-toast { position: absolute; left: 18px; bottom: 90px; background: rgba(13,15,20,0.88); border: 1px solid var(--border); color: #fff; padding: 7px 14px; border-radius: 9px; font-size: 0.78rem; font-weight: 600; font-variant-numeric: tabular-nums; opacity: 0; transition: opacity 0.15s; pointer-events: none; z-index: 22; }
.vui-toast.show { opacity: 1; }
.fallback-btn.on { color: var(--accent); background: rgba(232,163,61,0.12); }

/* Спиннер загрузки серии */
.vui-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 19; opacity: 0; pointer-events: none; transition: opacity 0.25s; background: rgba(5,7,10,0.4); }
.vui-loading.show { opacity: 1; }
.vui-loading::after { content: ""; width: 56px; height: 56px; border-radius: 50%; border: 3px solid rgba(232,163,61,0.28); border-top-color: var(--accent); animation: vui-spin 0.85s linear infinite; }
@keyframes vui-spin { to { transform: rotate(360deg); } }

/* ---- Custom video UI (vui) ---- */
.vui { position: absolute; inset: 0; z-index: 20; display: flex; flex-direction: column; justify-content: flex-end; opacity: 1; transition: opacity 0.25s; padding: 0 14px 8px; background: linear-gradient(transparent 55%, rgba(5,7,10,0.55) 85%); }
.vui.hidden-ui { opacity: 0; cursor: none; pointer-events: none; }
.vui-progress { position: relative; padding: 8px 0; cursor: pointer; }
.vui-track { height: 4px; background: rgba(255,255,255,0.18); border-radius: 3px; overflow: visible; position: relative; }
.vui-buffer { position: absolute; inset: 0; width: 0%; background: rgba(255,255,255,0.28); border-radius: 3px; }
.vui-fill { position: absolute; inset: 0; width: 0%; background: var(--accent); border-radius: 3px; }
.vui-thumb { position: absolute; top: 50%; left: 0%; width: 13px; height: 13px; background: var(--accent); border-radius: 50%; transform: translate(-50%, -50%) scale(0); transition: transform 0.15s; box-shadow: 0 1px 6px rgba(0,0,0,0.6); }
.vui-progress:hover .vui-thumb, .vui-progress.scrubbing .vui-thumb { transform: translate(-50%, -50%) scale(1); }
.vui-progress:hover .vui-track { height: 5px; }
.vui-controls { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.vui-btn { width: 38px; height: 38px; border-radius: 10px; border: none; background: transparent; color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font: inherit; font-weight: 600; font-size: 0.82rem; }
.vui-btn:hover { background: rgba(255,255,255,0.12); }
.vui-btn:active { transform: scale(0.9); }
.vui-btn svg { width: 21px; height: 21px; }
.vui-btn .ic-pause { display: none; }
.vui-btn .ic-muted { display: none; }
.vui.playing .ic-play { display: none; }
.vui.playing .ic-pause { display: block; }
.vui.muted .ic-vol { display: none; }
.vui.muted .ic-muted { display: block; }
.vui-time { color: #fff; font-size: 0.78rem; font-weight: 500; opacity: 0.92; font-variant-numeric: tabular-nums; margin-left: 4px; white-space: nowrap; }
.vui-spacer { flex: 1; }
#vuiVol { width: 74px; height: 4px; -webkit-appearance: none; appearance: none; background: rgba(255,255,255,0.25); border-radius: 3px; outline: none; cursor: pointer; }
#vuiVol::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; border-radius: 50%; background: #fff; }
#vuiVol::-moz-range-thumb { width: 12px; height: 12px; border: none; border-radius: 50%; background: #fff; }
.vui #vuiRate { width: 40px; }
/* На тач-девайсах громкость системная — прячем весь десктоп-набор */
@media (pointer: coarse) {
  .vui-desktop { display: none !important; }
}
/* Двойной тап-сонар: подсказка зоны */
.vui #vuiRate:active { transform: scale(0.9); }
/* центр-кнопка поверх всего при паузе */
.vui-center { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 21; pointer-events: none; }
.vui-center-btn { width: 76px; height: 76px; border-radius: 50%; border: none; background: rgba(13,15,20,0.68); color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; pointer-events: auto; opacity: 0; transform: scale(0.85); transition: opacity 0.2s, transform 0.2s; box-shadow: 0 4px 24px rgba(0,0,0,0.5); }
.vui-center-btn svg { width: 34px; height: 34px; }
.vui-center-btn:hover { background: rgba(232,163,61,0.9); color: #000; }
.vui.center-gone .vui-center { display: none; }
.vui.paused-center .vui-center-btn { opacity: 1; transform: scale(1); }
.vui-center.gone { display: none; }

/* Episode bar */
.episode-bar { height: 60px; background: var(--surface); border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 12px; flex-shrink: 0; }
.episode-title { font-size: 0.875rem; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.episode-nav { display: flex; gap: 8px; flex-shrink: 0; }
.btn-nav { display: flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface2); color: var(--text); font-size: 0.8rem; cursor: pointer; }
.btn-nav svg { width: 14px; height: 14px; }
.btn-nav:hover { border-color: var(--accent); color: var(--accent); }
.btn-nav:active { transform: scale(0.95); }

/* Кнопка описания — мягкий акцент, выделяется среди обычных кнопок */
#infoExpand { border-color: rgba(232,163,61,0.4); background: rgba(232,163,61,0.09); color: var(--accent); }
#infoExpand:hover { border-color: var(--accent); background: rgba(232,163,61,0.16); color: var(--accent-hover); }

/* Overlay + side panel */
.overlay { position: fixed; inset: 0; background: rgba(5,7,10,0.65); z-index: 100; opacity: 0; visibility: hidden; transition: opacity 0.25s, visibility 0.25s; }
.overlay.active, .overlay.always { opacity: 1; visibility: visible; }
.panel { position: fixed; top: 0; right: 0; bottom: 0; width: 85%; max-width: 360px; background: var(--surface); border-left: 1px solid var(--border); z-index: 101; transform: translateX(0); transition: transform 0.28s cubic-bezier(0.4,0,0.2,1); display: flex; flex-direction: column; }
.panel.closed { transform: translateX(100%); }
.panel-header { padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.panel-toggle { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; flex-shrink: 0; }
.panel-toggle input { display: none; }
.tgl-track { width: 36px; height: 20px; background: var(--border); border-radius: 12px; position: relative; transition: background 0.2s; flex-shrink: 0; }
.tgl-thumb { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; background: #fff; border-radius: 50%; transition: transform 0.2s; }
.panel-toggle input:checked + .tgl-track { background: var(--ok); }
.panel-toggle input:checked + .tgl-track .tgl-thumb { transform: translateX(16px); }
.tgl-label { font-size: 0.8rem; color: var(--text2); }
.panel-toggle input:checked ~ .tgl-label { color: var(--text); }
.panel-title { font-weight: 600; }
.panel-content { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 8px; scrollbar-width: thin; scrollbar-color: var(--surface2) transparent; }
.panel-content::-webkit-scrollbar { width: 4px; }
.panel-content::-webkit-scrollbar-thumb { background: var(--surface2); border-radius: 2px; }

/* Episode list */
.episode-item { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 10px; cursor: pointer; margin-bottom: 2px; border: 1px solid transparent; }
.episode-item:hover { background: var(--surface2); }
.episode-item:active { background: var(--surface2); }
.episode-item.active { background: var(--surface2); border-color: var(--accent); }
.episode-item.active .ep-num { background: var(--accent); color: #000; }
.episode-item.watched { opacity: 0.62; }
.episode-item.watched .ep-num { background: var(--ok); color: #fff; }
.ep-num { width: 36px; height: 36px; border-radius: 9px; background: var(--surface2); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 0.85rem; flex-shrink: 0; position: relative; }
.ep-icon { position: absolute; top: -4px; right: -4px; font-size: 0.7rem; background: var(--ok); border-radius: 50%; width: 16px; height: 16px; display: flex; align-items: center; justify-content: center; }
.ep-info { flex: 1; min-width: 0; }
.ep-name { font-weight: 500; font-size: 0.875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ep-time { font-size: 0.75rem; color: var(--text2); margin-top: 3px; }
.progress-track { height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; margin-top: 6px; }
.progress-fill { height: 100%; background: var(--accent); transition: width 0.5s linear; }
.episode-item.active .progress-fill { background: var(--accent-hover); }

/* Continue modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(5,7,10,0.8); z-index: 200; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal-overlay.active { display: flex; }
.modal { background: var(--surface2); border: 1px solid var(--border); border-radius: 16px; padding: 24px; width: 100%; max-width: 340px; }
.modal-title { font-weight: 600; font-size: 1rem; margin-bottom: 18px; text-align: center; }
.modal-buttons { display: flex; flex-direction: column; gap: 10px; }
.modal-btn { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 13px 20px; border-radius: 11px; border: none; font-weight: 600; font-size: 0.9rem; cursor: pointer; }
.modal-btn svg { width: 16px; height: 16px; }
.modal-btn:active { transform: scale(0.97); }
.modal-btn-primary { background: var(--accent); color: #000; }
.modal-btn-primary:hover { background: var(--accent-hover); }
.modal-btn-secondary { background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.modal-btn-secondary:hover { border-color: var(--text2); }

/* End-of-episode overlay */
.end-overlay { position: fixed; inset: 0; background: rgba(5,7,10,0.85); z-index: 300; display: none; align-items: center; justify-content: center; padding: 20px; }
.end-overlay.active { display: flex; }
.end-box { background: var(--surface2); border: 1px solid var(--border); border-radius: 16px; padding: 26px 24px; width: 100%; max-width: 380px; text-align: center; }
.end-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 6px; }
.end-next-title { font-size: 0.85rem; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 4px; }
.end-timer { font-size: 0.8rem; color: var(--accent); margin-bottom: 18px; }
.end-buttons { display: flex; flex-direction: column; gap: 10px; }
.end-btn { padding: 13px 20px; border-radius: 11px; border: none; font-weight: 600; font-size: 0.9rem; cursor: pointer; }
.end-btn:active { transform: scale(0.97); }
.end-btn-primary { background: var(--accent); color: #000; }
.end-btn-primary:hover { background: var(--accent-hover); }
.end-btn-secondary { background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.end-btn-secondary:hover { border-color: var(--text2); }

/* Кнопка описания в шапке */
.info-expand { display: flex; align-items: center; gap: 6px; flex-shrink: 0; border: 1px solid var(--border); background: var(--surface2); color: var(--text); font: inherit; font-size: 0.78rem; font-weight: 600; padding: 7px 13px; border-radius: 18px; cursor: pointer; transition: border-color 0.2s, color 0.2s; }
.info-expand:hover { border-color: var(--accent); color: var(--accent); }
.info-expand svg { width: 14px; height: 14px; transition: transform 0.25s; }

/* Description sheet — модальная панель описания (Kinopoisk-style) */
.sheet-overlay { position: fixed; inset: 0; background: rgba(5,7,10,0.68); z-index: 150; opacity: 0; visibility: hidden; transition: opacity 0.25s, visibility 0.25s; }
.sheet-overlay.active { opacity: 1; visibility: visible; }
.sheet { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 30px); width: min(760px, calc(100vw - 24px)); max-height: calc(100vh - 56px); background: var(--surface2); border: 1px solid var(--border); border-radius: 18px; box-shadow: 0 30px 80px rgba(0,0,0,0.55); z-index: 151; opacity: 0; visibility: hidden; pointer-events: none; display: flex; flex-direction: column; transition: opacity 0.28s, transform 0.28s cubic-bezier(0.4,0,0.2,1), visibility 0.28s; }
.sheet.open { opacity: 1; visibility: visible; pointer-events: auto; transform: translate(-50%, 0); }
.sheet-scroll { overflow-y: auto; overscroll-behavior: contain; padding: 0 36px 30px; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.sheet-scroll::-webkit-scrollbar { width: 4px; }
.sheet-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.sheet-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; margin: 0 -36px; padding: 20px 38px 14px; background: linear-gradient(var(--surface2) 78%, rgba(28,32,44,0)); }
.sheet-heading { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em; color: var(--text2); }
.sheet-close { width: 36px; height: 36px; flex-shrink: 0; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text2); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.sheet-close svg { width: 16px; height: 16px; }
.sheet-close:hover { color: var(--text); border-color: var(--text2); }
.sheet-grid { display: grid; grid-template-columns: 230px 1fr; gap: 34px; align-items: start; }
.sheet-side img { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 12px; border: 1px solid var(--border); }
@media (max-width: 700px) { .header { height: 56px; } .header-poster { display: none; } .info-expand span { display: none; } .info-expand { padding: 8px; } .sheet-grid { grid-template-columns: 1fr; } .sheet-side { display: none; } .sheet-scroll { padding: 0 22px 26px; } .sheet-head { margin: 0 -22px; padding: 18px 24px 12px; } .sheet { bottom: 0; width: 100%; border-radius: 18px 18px 0 0; border-bottom: none; box-shadow: none; max-height: min(86vh, 860px); } }

/* Типографика описания */
.info-desc p { margin: 0 0 14px; font-size: 0.92rem; line-height: 1.75; color: #c7ccd8; max-width: 62ch; }
.info-desc strong { color: var(--text); font-weight: 600; }
.info-desc em { color: var(--accent-hover); font-style: normal; }
.info-desc h2 { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em; color: var(--accent); margin: 28px 0 12px; max-width: 62ch; }
.info-desc ul { list-style: none; margin: 0; padding: 0; }
.info-desc li { position: relative; padding-left: 20px; margin-bottom: 8px; font-size: 0.88rem; line-height: 1.55; color: #c7ccd8; max-width: 56ch; }
.info-desc li::before { content: ""; position: absolute; left: 2px; top: 0.55em; width: 7px; height: 7px; border-radius: 2px; background: var(--accent); opacity: 0.85; transform: rotate(45deg); }

/* Hidden SEO content */
.seo-content { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

@media (max-width: 400px) { .panel { width: 90%; } .btn-nav span { display: none; } .btn-nav { padding: 8px 10px; } }
@media (orientation: landscape) and (max-height: 500px) { .panel { width: 280px; } .header, .episode-bar { height: 48px; } }

/* Десктоп: список серий — постоянная правая панель, оверлей не нужен */
@media (min-width: 1024px) {
  .overlay { display: none !important; }
  .panel { width: 320px; }
  .panel.closed { transform: translateX(100%); }
  body:has(.panel:not(.closed)) { padding-right: 320px; }
}