/* --- ПЛЕЕР И ТУЛБАР --- */
.player-section { width: 100%; box-sizing: border-box; margin: 0; padding: 0; transform-origin: top; }
.player-toolbar { display: flex; justify-content: space-between; align-items: center; background: var(--panel-2); border: 1px solid var(--line-strong); border-radius: 12px 12px 0 0; padding: 15px 20px; }
.player-selects { display: flex; gap: 15px; }
.player-select { background: #0f1115; color: #fff; border: 1px solid var(--line); padding: 8px 15px; border-radius: 6px; font-family: 'JetBrains Mono', monospace; font-size: 12px; outline: none; cursor: pointer; min-width: 180px; transition: 0.2s; }
.player-select:hover { border-color: #a1a6b4; }
.player-select:focus { border-color: var(--cyan); }
.theater-btn { background: transparent; border: 1px solid var(--line); color: var(--text-2); padding: 8px 15px; border-radius: 6px; font-family: 'JetBrains Mono', monospace; font-size: 12px; cursor: pointer; transition: 0.2s; display: flex; align-items: center; gap: 6px; }
.theater-btn:hover { color: #fff; border-color: var(--cyan); }

.iframe-wrapper { width: 100%; padding-top: 56.25%; background: #000; border: 1px solid var(--line-strong); border-top: none; border-radius: 0 0 12px 12px; overflow: hidden; position: relative; box-shadow: 0 15px 40px rgba(0,0,0,0.5); }
.iframe-wrapper iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: none; display: block; }

.theater-exit-btn { display: none; position: absolute; top: 20px; right: 20px; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); border: 1px solid var(--line); color: #fff; width: 44px; height: 44px; border-radius: 8px; align-items: center; justify-content: center; cursor: pointer; z-index: 100; transition: 0.2s; }
.theater-exit-btn:hover { background: var(--cyan); color: #000; border-color: var(--cyan); }

.player-skip-btn {
    position: absolute;
    bottom: 70px;
    right: 24px;
    background: rgba(15, 17, 21, 0.9);
    border: 1px solid var(--cyan);
    color: #fff;
    padding: 8px 16px;
    border-radius: 8px;
    font-family: 'Chakra Petch', sans-serif;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    z-index: 999;
    display: none;
    align-items: center;
    gap: 8px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.7), 0 0 12px rgba(63, 224, 208, 0.3);
    transition: transform 0.2s ease, background 0.2s ease;
    backdrop-filter: blur(6px);
}
.player-skip-btn:hover {
    background: var(--cyan);
    color: #000;
    transform: scale(1.05);
}
@media (max-width: 768px) {
    .player-skip-btn { bottom: 50px; font-size: 12px; padding: 6px 12px; }
}

body.theater-mode .a-header { transform: translateY(-100%); }
body.theater-mode .hero-backdrop-wrapper { display: none; }
body.theater-mode .player-section { max-width: 100%; padding: 0; margin-top: 0; }
body.theater-mode .media-body-section { padding: 0; max-width: 100%; gap: 0; }
body.theater-mode .frames-container, body.theater-mode #recommendations-section, body.theater-mode #reviews-section, body.theater-mode #home-continue-section, body.theater-mode #home-schedule-section, body.theater-mode #home-new-section, body.theater-mode #home-collections-section { display: none !important; }
body.theater-mode .iframe-wrapper { border-radius: 0; border: none; height: 100vh; aspect-ratio: auto; }
body.theater-mode .player-toolbar { border-radius: 0; border-left: none; border-right: none; position: absolute; top: 0; left: 0; right: 0; z-index: 50; background: rgba(21,24,30,0.9); opacity: 0; transition: opacity 0.3s; }
body.theater-mode .iframe-wrapper:hover .player-toolbar { opacity: 1; }
body.theater-mode .theater-exit-btn { display: flex; }
body.theater-mode #episode-grid-wrapper { display: none !important; }

/* --- СЕРИИ --- */
.episodes-grid { display: flex; flex-wrap: wrap; gap: 8px; max-height: 200px; overflow-y: auto; padding-right: 10px; }
.ep-btn { position: relative; overflow: hidden; background: var(--panel-2); color: var(--text-1); border: 1px solid var(--line); border-radius: 6px; width: 44px; height: 40px; display: flex; align-items: center; justify-content: center; font-family: 'JetBrains Mono', monospace; font-size: 13px; cursor: pointer; transition: 0.2s; }
.ep-btn:hover { border-color: var(--text-0); color: #fff; }
.ep-btn.active { background: rgba(63,224,208,0.15); border-color: var(--cyan); color: var(--cyan); font-weight: bold; }
.ep-btn.watched { border-color: rgba(39, 174, 96, 0.5); background: rgba(39, 174, 96, 0.08); }
.ep-btn.watched.active { border-color: var(--cyan); background: rgba(63,224,208,0.15); }
.ep-btn:focus-visible { background: rgba(63,224,208,0.4) !important; border-color: var(--cyan); color: #fff; }

.ep-progress-bg { position: absolute; bottom: 0; left: 0; width: 100%; height: 4px; background: rgba(255,255,255,0.05); }
.ep-progress { position: absolute; bottom: 0; left: 0; height: 4px; background: var(--cyan); width: 0%; transition: width 0.3s ease; box-shadow: 0 0 8px rgba(63,224,208,0.5); z-index: 2; }
.ep-progress.watched-prog { background: #27ae60; box-shadow: 0 0 8px rgba(39, 174, 96, 0.5); }
.ep-skip-mark { position: absolute; top: 50%; transform: translateY(-50%); width: 3px; height: 14px; background: #b072ff; border-radius: 2px; box-shadow: 0 0 6px rgba(176,114,255,0.4); opacity: 0.8; }
.ep-skip-op { left: 3px; }
.ep-skip-ed { right: 3px; }

/* --- КАСТОМНЫЕ СЕЛЕКТЫ --- */
.custom-select-wrapper { position: relative; user-select: none; width: 100%; }
.custom-select-trigger { 
    display: flex; align-items: center; justify-content: space-between; 
    background: #0f1115; border: 1px solid var(--line); color: #fff; 
    height: 42px; border-radius: 8px; padding: 0 14px; 
    font-family: 'JetBrains Mono', monospace; font-size: 13px; 
    cursor: pointer; transition: all 0.2s ease; box-sizing: border-box; 
    width: 100%;
}
.custom-select-trigger:hover, .custom-select-wrapper.open .custom-select-trigger { 
    border-color: var(--cyan); 
    box-shadow: 0 0 12px rgba(63, 224, 208, 0.15); 
}
.custom-select-trigger.player-select-trigger { height: 38px; padding: 0 15px; border-radius: 6px; font-size: 12px; min-width: 100%; }
.custom-select-trigger span {
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 8px;
}
.custom-select-icon { transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1); color: var(--text-2); flex-shrink: 0; }
.custom-select-wrapper.open .custom-select-icon { transform: rotate(180deg); color: var(--cyan); }

/* Фиксируем ширину для селектов в плеере, чтобы они не прыгали */
#media-dubbing + .custom-select-wrapper { width: 280px; min-width: 280px; max-width: 280px; flex-shrink: 0; }
#media-player-source + .custom-select-wrapper { width: 200px; min-width: 200px; max-width: 200px; flex-shrink: 0; }

@media (max-width: 768px) {
    #media-dubbing + .custom-select-wrapper,
    #media-player-source + .custom-select-wrapper { width: 100%; }
}

.custom-options { 
    position: absolute; top: calc(100% + 5px); left: 0; 
    width: 100%; box-sizing: border-box;
    background: #14171e; border: 1px solid var(--line-strong); border-radius: 10px; 
    box-shadow: 0 14px 35px rgba(0, 0, 0, 0.85); z-index: 1000; 
    display: none; max-height: 240px; overflow-y: auto; padding: 6px; 
    scrollbar-width: thin; scrollbar-color: var(--cyan) transparent; 
}
.custom-select-wrapper.open .custom-options { display: flex; flex-direction: column; gap: 2px; animation: fadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1); }

.custom-option { 
    padding: 8px 10px; font-family: 'JetBrains Mono', monospace; font-size: 12px; 
    color: #cbd5e1; cursor: pointer; transition: all 0.15s ease; border-radius: 6px; 
    display: flex; align-items: center; gap: 10px; user-select: none;
}
.custom-option:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.custom-option.selected { color: #fff; background: rgba(63, 224, 208, 0.08); font-weight: 600; }

.custom-opt-checkbox {
    width: 16px; height: 16px; border-radius: 4px; border: 1px solid var(--line-strong);
    background: #0b0d11; display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 900; color: transparent; transition: all 0.15s ease; flex-shrink: 0;
}
.custom-opt-checkbox.checked {
    background: var(--cyan); border-color: var(--cyan); color: #000;
}

.custom-opt-checkbox {
    width: 16px; height: 16px; border-radius: 4px; border: 1px solid var(--line-strong);
    background: #0f1115; display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 900; color: transparent; transition: all 0.2s ease; flex-shrink: 0;
}
.custom-opt-checkbox.checked {
    background: var(--cyan); border-color: var(--cyan); color: #000;
}

/* --- ТУЛТИПЫ --- */
.info-tooltip-wrapper { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2); color: var(--text-2); cursor: help; margin-left: 10px; transition: 0.2s; }
.info-tooltip-wrapper:hover { background: var(--cyan); color: #000; border-color: var(--cyan); }
.info-tooltip-text { position: absolute; top: calc(100% + 12px); left: 50%; transform: translateX(-50%) translateY(-10px); background: #15181e; border: 1px solid var(--cyan); padding: 12px 16px; border-radius: 8px; width: 260px; font-family: 'JetBrains Mono', monospace; font-size: 12px; line-height: 1.5; color: #fff; text-align: center; box-shadow: 0 10px 25px rgba(0,0,0,0.8); opacity: 0; visibility: hidden; transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1); z-index: 1000; cursor: auto; }
.info-tooltip-text::before { content: ''; position: absolute; bottom: 100%; left: 0; width: 100%; height: 15px; background: transparent; }
.info-tooltip-text::after { content: ''; position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); border-width: 6px; border-style: solid; border-color: transparent transparent var(--cyan) transparent; }
.info-tooltip-wrapper:hover .info-tooltip-text { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); }

/* --- КОММЕНТАРИИ INVY --- */
.comments-wrapper { display: flex; flex-direction: column; gap: 20px; background: var(--panel-2); border: 1px solid var(--line-strong); border-radius: 12px; padding: 20px; }
.comment-input-area { display: flex; gap: 15px; align-items: flex-start; }
.comment-input-avatar { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; flex-shrink: 0; }
.comment-textarea { flex: 1; background: #0f1115; border: 1px solid var(--line); border-radius: 8px; padding: 12px 15px; color: #fff; font-family: 'JetBrains Mono', monospace; font-size: 13px; min-height: 44px; resize: none; overflow: hidden; outline: none; transition: 0.2s; line-height: 1.5; box-sizing: border-box; }
.comment-textarea:focus { border-color: var(--cyan); box-shadow: 0 0 10px rgba(63, 224, 208, 0.1); }
.comment-submit-btn { background: var(--panel); border: 1px solid var(--line-strong); color: var(--text-2); cursor: pointer; transition: 0.2s; padding: 0; width: 44px; height: 44px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.comment-submit-btn:hover { color: var(--cyan); border-color: var(--cyan); background: rgba(63, 224, 208, 0.05); }

.comments-list { display: flex; flex-direction: column; gap: 15px; }
.comment-item { display: flex; gap: 15px; position: relative; padding-bottom: 15px; border-bottom: 1px solid rgba(255,255,255,0.05); }
.comment-item:last-child { border-bottom: none; padding-bottom: 0; }
.comment-item.is-reply { margin-left: 55px; position: relative; }
.comment-item.is-reply::before { content: ''; position: absolute; left: -34px; top: -15px; bottom: 20px; width: 2px; background: var(--line); border-radius: 2px; }
.comment-item.is-reply::after { content: ''; position: absolute; left: -34px; top: 20px; width: 15px; height: 2px; background: var(--line); border-radius: 2px; }

.c-avatar { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; border: 1px solid var(--line); flex-shrink: 0; }
.c-body { flex: 1; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.c-header { display: flex; align-items: center; gap: 10px; margin-bottom: 2px; flex-wrap: wrap; }
.c-author { font-family: 'Chakra Petch', sans-serif; font-weight: bold; color: #fff; font-size: 15px; }
.c-admin-badge { background: var(--cyan); color: #000; font-size: 9px; padding: 2px 6px; border-radius: 4px; font-weight: bold; font-family: 'JetBrains Mono', monospace; text-transform: uppercase; }
.c-date { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--text-2); }
.c-text { font-family: 'JetBrains Mono', monospace; font-size: 13px; color: #d0d4dc; line-height: 1.5; word-wrap: break-word; }
.c-reply-tag { color: var(--cyan); cursor: pointer; text-decoration: none; font-weight: bold; margin-right: 4px; }
.c-reply-tag:hover { text-decoration: underline; }

.c-actions { display: flex; align-items: center; gap: 15px; margin-top: 4px; }
.c-action-btn { background: transparent; border: none; color: var(--text-2); font-family: 'JetBrains Mono', monospace; font-size: 11px; font-weight: bold; cursor: pointer; display: flex; align-items: center; gap: 4px; padding: 0; transition: 0.2s; }
.c-action-btn:hover { color: #fff; }
.c-action-btn.reply:hover { color: var(--cyan); }
.c-action-btn.delete:hover { color: #ff4444; }

.reply-box { display: none; margin-top: 10px; margin-left: 0; animation: fadeIn 0.2s ease; }
.reply-box.active { display: flex; }
.toggle-replies-btn { width: 100%; background: #0f1115; border: 1px solid var(--line); color: var(--text-2); padding: 8px; border-radius: 6px; font-family: 'JetBrains Mono', monospace; font-size: 11px; font-weight: bold; cursor: pointer; transition: 0.2s; margin-top: 5px; display: flex; align-items: center; justify-content: center; gap: 6px; }
.toggle-replies-btn:hover { background: rgba(255,255,255,0.05); color: #fff; border-color: var(--text-1); }

/* --- СТИЛИЗАЦИЯ PLYR ПОД ТЕМУ INVY CINEMA --- */
:root {
    --plyr-color-main: var(--cyan);
    --plyr-video-control-color-hover: #fff;
}

.iframe-wrapper .plyr {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: 0 0 12px 12px;
    z-index: 5;
}

/* Принудительная тёмная тема для меню настроек Plyr */
.plyr__menu__container {
    background: rgba(21, 24, 30, 0.96) !important;
    backdrop-filter: blur(14px) !important;
    border: 1px solid var(--line-strong, rgba(255, 255, 255, 0.12)) !important;
    border-radius: 8px !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.85), 0 0 15px rgba(63, 224, 208, 0.15) !important;
    color: #e2e8f0 !important;
}

.plyr__menu__container [role="menu"] {
    background: transparent !important;
    color: #e2e8f0 !important;
}

.plyr__menu__container .plyr__control {
    color: #cbd5e1 !important;
    background: transparent !important;
    transition: background 0.15s ease, color 0.15s ease !important;
}

.plyr__menu__container .plyr__control:hover,
.plyr__menu__container .plyr__control[aria-expanded="true"] {
    background: rgba(63, 224, 208, 0.15) !important;
    color: var(--cyan) !important;
}

.plyr__menu__container .plyr__menu__value {
    color: var(--text-2, #a1a6b4) !important;
}

.plyr__menu__container [role="menuitemradio"][aria-checked="true"] {
    background: rgba(63, 224, 208, 0.2) !important;
    color: var(--cyan) !important;
    font-weight: 700 !important;
}

.plyr__menu__container [role="menuitemradio"][aria-checked="true"]::before {
    background: var(--cyan) !important;
}

/* Бейдж качества HD на самой шестерёнке */
.plyr__controls button[data-plyr="settings"] {
    position: relative !important;
}

.plyr__badge-hd {
    display: none;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 3px;
    right: 3px;
    background: #0099ff;
    color: #fff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 8px;
    font-weight: 900;
    line-height: 1;
    padding: 1.5px 3px;
    border-radius: 3px;
    letter-spacing: 0.2px;
    pointer-events: none;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
    z-index: 2;
}

/* Классы режимов масштабирования */
.plyr__video-wrapper video.scale-contain {
    object-fit: contain !important;
}
.plyr__video-wrapper video.scale-cover {
    object-fit: cover !important;
}
.plyr__video-wrapper video.scale-fill {
    object-fit: fill !important;
}

/* Скрытие управления громкостью на мобильных устройствах */
@media (max-width: 768px) {
    .plyr__controls .plyr__volume,
    .plyr__controls button[data-plyr="mute"] {
        display: none !important;
    }
}