/* HomeFlix — ngôn ngữ thiết kế iOS 26 (Liquid Glass) dùng chung cho iPhone và TV */

:root {
    /* Vùng an toàn: iPhone có Dynamic Island và thanh Home. Test ghi đè các biến này. */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);

    --glass-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.06));
    --glass-bg-solid: rgba(28, 28, 30, 0.94);
    --glass-border-light: rgba(255, 255, 255, 0.22);
    --glass-blur: blur(24px) saturate(180%);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.18);
    --pill: 999px;
    --tap: 44px;
}

.glass {
    background: var(--glass-bg);
    -webkit-backdrop-filter: var(--glass-blur);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border-light);
    box-shadow: var(--glass-shadow);
    border-radius: var(--pill);
}

/* Trình duyệt không hỗ trợ backdrop-filter: lùi về nền mờ đặc */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .glass {
        background: var(--glass-bg-solid);
    }
}

body, input, button, textarea, select {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Be Vietnam Pro", sans-serif;
}

/* TV: chữ từ 20px, viền tiêu điểm trắng 4px (thắng các viền vàng cũ) */
body.device-tv {
    font-size: 20px;
    --focus-ring: #fff; /* các luật viền tiêu điểm cũ dùng biến này (trước là vàng) */
}

body.device-tv :focus-visible {
    outline: 4px solid #fff !important;
    outline-offset: 2px;
}

/* --- Tab bar nổi (iPhone) --- */
.float-tabbar,
.manual-url-link {
    display: none;
}

body.device-mobile .float-tabbar {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(var(--safe-bottom) + 8px);
    height: 64px;
    padding: 0 max(16px, var(--safe-left)) 0 max(16px, var(--safe-right));
    gap: 12px;
    justify-content: center;
    z-index: 900;
    pointer-events: none;
}

body.device-mobile .float-tabbar > * {
    pointer-events: auto;
}

body.device-mobile.player-active .float-tabbar {
    display: none;
}

body.device-mobile #appTabsNav {
    display: none;
}

.fab-capsule {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px;
    height: 64px;
}

.fab-tab {
    min-width: var(--tap);
    min-height: var(--tap);
    height: 52px;
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border: 0;
    border-radius: var(--pill);
    background: transparent;
    color: var(--text-dim);
    font-size: 11px;
    font-weight: 600;
}

.fab-tab.active {
    color: #fff;
    background: rgba(255, 255, 255, 0.18);
}

.fab-search {
    width: 64px;
    height: 64px;
    min-width: var(--tap);
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}

/* Nội dung chừa chỗ cho tab bar và thanh Home */
body.device-mobile .container {
    padding-bottom: calc(var(--safe-bottom) + 8px + 64px + 16px);
}

body.device-mobile .manual-url-link {
    display: inline-flex;
    align-items: center;
    min-height: var(--tap);
    padding: 0 16px;
    margin-bottom: 8px;
    border: 1px solid var(--glass-border-light);
    border-radius: var(--pill);
    background: transparent;
    color: var(--text-dim);
    font-size: 14px;
}

/* --- Hero: poster phủ nền, chữ đè lên --- */
.hero[hidden],
.hero-dots[hidden] {
    display: none !important;
}

.hero {
    position: relative;
    width: 100%;
    height: 56vh;
    min-height: 340px;
    overflow: hidden;
    border-radius: 28px;
    background: #111;
}

.hero-track {
    display: flex;
    height: 100%;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
}

.hero-track::-webkit-scrollbar {
    display: none;
}

.hero-slide {
    position: relative;
    flex: 0 0 100%;
    height: 100%;
    scroll-snap-align: start;
}

.hero-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hero-gradient {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(8, 8, 8, 0.96) 0%, rgba(8, 8, 8, 0.6) 38%, rgba(8, 8, 8, 0) 72%);
}

/* Chữ nằm dưới dải Dynamic Island và trên đáy hero */
.hero-content {
    position: absolute;
    left: max(16px, var(--safe-left));
    right: max(16px, var(--safe-right));
    top: 24px;
    bottom: 40px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 8px;
}

.hero-badge {
    align-self: flex-start;
    padding: 4px 12px;
    border-radius: var(--pill);
    background: rgba(229, 9, 20, 0.85);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.hero-title {
    font-size: 30px;
    line-height: 1.15;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.hero-meta {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dim);
}

.hero-desc {
    font-size: 14px;
    line-height: 1.45;
    color: rgba(255, 255, 255, 0.85);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.hero-desc:empty {
    display: none;
}

.hero-actions {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.hero-btn-play,
.hero-btn-save {
    min-height: var(--tap);
    padding: 0 28px;
    border: 0;
    border-radius: var(--pill);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
}

.hero-btn-play {
    background: #fff;
    color: #000;
}

.hero-btn-save {
    color: #fff;
    border: 1px solid var(--glass-border-light);
}

.hero-dots {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 14px;
    display: flex;
    justify-content: center;
    gap: 6px;
    pointer-events: none;
}

.hero-dot {
    width: 6px;
    height: 6px;
    border-radius: var(--pill);
    background: rgba(255, 255, 255, 0.4);
    transition: width 0.2s, background 0.2s;
}

.hero-dot.active {
    width: 18px;
    background: #fff;
}

/* iPhone: hero kéo tràn dưới thanh trạng thái, logo nổi trên đó */
body.device-mobile .hero {
    /* chừa chỗ cho thanh lọc (112px) và khoảng cách 2rem nằm trên tab bar nổi ở màn hình đầu */
    height: calc(100svh - var(--safe-bottom) - 8px - 64px - 12px - 112px - 2rem);
    margin: -1rem -1rem 0;
    width: auto;
    border-radius: 0;
}

body.device-mobile .hero-content {
    top: calc(var(--safe-top) + 60px);
}

body.device-mobile .sticky-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: auto;
    background: linear-gradient(rgba(8, 8, 8, 0.7), rgba(8, 8, 8, 0));
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    padding-top: calc(var(--safe-top) + 8px);
    padding-bottom: 8px;
    border: 0;
    pointer-events: none;
}

body.device-mobile .sticky-header header {
    border: 0;
    padding: 0 16px;
}

body.device-mobile .search-bar {
    display: none;
}

body.device-mobile .tab-content:not(#search-tab),
body.device-mobile #movieDetailContainer {
    padding-top: calc(var(--safe-top) + 56px);
}

/* TV: hero ngang, chữ bên trái */
body.device-tv .hero-content {
    left: 48px;
    right: auto;
    width: 45%;
    top: 24px;
    bottom: 56px;
}

body.device-tv .hero-title {
    font-size: 44px;
}

body.device-tv .hero-desc,
body.device-tv .hero-meta {
    font-size: 20px;
}

/* --- Thanh lọc: loại phim + chip, dính khi cuộn trên iPhone --- */
#filterBar {
    position: relative;
    z-index: 60;
    padding: 8px 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Lớp kính nằm ở phần tử giả để tờ chọn (position: fixed) không bị kẹt trong backdrop-filter */
#filterBar::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: rgba(8, 8, 8, 0.72);
    -webkit-backdrop-filter: var(--glass-blur);
    backdrop-filter: var(--glass-blur);
}

#filterBar .type-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    gap: 8px;
}

#filterBar .type-row::-webkit-scrollbar {
    display: none;
}

#filterBar .grid-tab-btn {
    flex: 0 0 auto;
    min-height: var(--tap);
    padding: 0 18px;
    border-radius: var(--pill);
    border: 1px solid var(--glass-border-light);
    font-size: 15px;
    font-weight: 600;
}

#filterBar .grid-tab-btn.active {
    color: #fff;
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
}

#filterBar .chip-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

#filterBar .filter-bar {
    width: auto; /* luật .device-mobile .filter-bar cũ ép 100% làm số phim rớt xuống hàng riêng */
    margin-left: 0;
    flex-wrap: wrap;
    gap: 8px;
}

#filterBar .filter-btn,
#filterBar .filter-clear-btn {
    min-height: var(--tap);
    padding: 0 16px;
    border-radius: var(--pill);
    font-size: 14px;
}

#filterBar .filter-btn.active {
    color: #fff;
    background: var(--accent-color);
    border-color: var(--accent-color);
}

.result-count {
    margin-left: auto;
    font-size: 13px;
    color: var(--text-dim);
}

.filter-menu {
    -webkit-backdrop-filter: var(--glass-blur);
    backdrop-filter: var(--glass-blur);
    background: rgba(28, 28, 30, 0.88);
}

.filter-option {
    min-height: var(--tap);
}

body.device-mobile #filterBar {
    position: sticky;
    top: calc(var(--safe-top) + 44px);
    margin: 0 -1rem;
    padding: 8px 1rem;
}

/* iPhone: tờ chọn dạng viên thuốc nổi phía trên tab bar */
body.device-mobile .filter-menu {
    position: fixed;
    left: 12px;
    right: 12px;
    top: auto;
    bottom: calc(var(--safe-bottom) + 8px + 64px + 12px);
    min-width: 0;
    max-height: 55vh;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
    padding: 16px;
    border-radius: 28px;
    z-index: 950;
}

body.device-mobile .filter-option {
    padding: 0 16px;
    border-radius: var(--pill);
    border: 1px solid var(--glass-border-light);
}

body.device-mobile .grid-tab-content {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

body.device-mobile .grid-tab-content .movie-title {
    font-size: 12px;
}

body.device-mobile .grid-tab-content .movie-meta {
    font-size: 11px;
}

/* TV: kết quả là một hàng cuộn ngang */
body.device-tv .grid-tab-content {
    display: grid;
    grid-auto-flow: column;
    grid-template-columns: none;
    grid-auto-columns: 220px;
    overflow-x: auto;
    padding: 12px 8px 28px;
}

body.device-tv .grid-load-more {
    grid-column: auto;
}

/* --- Tủ phim: Tiếp tục xem + Đã lưu --- */
.library-section[hidden],
.library-empty[hidden] {
    display: none !important;
}

.library-section {
    margin-bottom: 24px;
}

.library-title {
    font-size: 20px;
    font-weight: 800;
    margin-bottom: 12px;
}

.library-empty {
    text-align: center;
    color: var(--text-dim);
    padding: 3rem 0;
    font-size: 1.1rem;
}

.continue-row {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 4px;
}

.continue-row::-webkit-scrollbar {
    display: none;
}

.continue-card {
    flex: 0 0 140px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.continue-poster {
    width: 100%;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    border-radius: 16px;
    background: #1a1a1c;
}

.continue-title {
    font-size: 13px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.continue-ep {
    font-size: 12px;
    color: var(--text-dim);
}

.continue-progress {
    height: 4px;
    border-radius: var(--pill);
    background: rgba(255, 255, 255, 0.2);
    overflow: hidden;
}

.continue-progress-fill {
    height: 100%;
    background: var(--accent-color);
}

/* --- Nút Phát: trạng thái đang tải --- */
.hero-btn-play.is-loading {
    opacity: 0.6;
    position: relative;
}

.hero-btn-play.is-loading::after {
    content: "";
    width: 14px;
    height: 14px;
    margin-left: 8px;
    display: inline-block;
    vertical-align: -2px;
    border: 2px solid rgba(0, 0, 0, 0.3);
    border-top-color: #000;
    border-radius: 50%;
    animation: hf-spin 0.8s linear infinite;
}

@keyframes hf-spin {
    to { transform: rotate(360deg); }
}

/* --- Trang chi tiết iPhone: nút Phát cố định trong tầm ngón cái, trên tab bar --- */
body.device-mobile .detail-actions {
    position: fixed;
    left: max(16px, var(--safe-left));
    right: max(16px, var(--safe-right));
    bottom: calc(var(--safe-bottom) + 8px + 64px + 12px);
    z-index: 850;
    display: flex;
    gap: 12px;
    padding: 8px;
    border-radius: var(--pill);
    background: var(--glass-bg);
    -webkit-backdrop-filter: var(--glass-blur);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border-light);
    box-shadow: var(--glass-shadow);
}

body.device-mobile .detail-actions .detail-action-play {
    flex: 1;
    min-height: var(--tap);
    border-radius: var(--pill);
}

body.device-mobile .detail-actions .detail-action-side {
    min-height: var(--tap);
    border-radius: var(--pill);
}

body.device-mobile #movieDetailContainer {
    padding-bottom: calc(var(--safe-bottom) + 8px + 64px + 12px + 64px);
}

/* --- Khung trình phát: tôn trọng vùng an toàn khi xoay ngang (Dynamic Island, thanh Home) --- */
body.player-active #playerHeader {
    padding: max(8px, var(--safe-top)) max(16px, var(--safe-right)) 8px max(16px, var(--safe-left)) !important;
}

body.player-active #playerHeader .btn-overlay-back {
    min-height: var(--tap);
    min-width: var(--tap);
}

body.player-active #episodesDrawerEl {
    width: auto;
    margin: 0 max(16px, var(--safe-right)) max(16px, var(--safe-bottom)) max(16px, var(--safe-left));
}

.airplay-remote-overlay {
    padding: max(2rem, var(--safe-top)) max(2rem, var(--safe-right)) max(2rem, var(--safe-bottom)) max(2rem, var(--safe-left));
}

.airplay-disconnect-btn {
    top: max(1rem, var(--safe-top));
    right: max(1rem, var(--safe-right));
    min-height: var(--tap);
    padding: 0 1rem;
}

/* TV: chữ điều khiển từ 20px, vùng chạm lớn hơn */
body.device-tv #filterBar .grid-tab-btn,
body.device-tv #filterBar .filter-btn,
body.device-tv #filterBar .filter-clear-btn,
body.device-tv .result-count,
body.device-tv .hero-btn-play,
body.device-tv .hero-btn-save {
    font-size: 20px;
}

body.device-tv .hero-badge {
    font-size: 20px;
    padding: 6px 16px;
}

body.device-tv #filterBar .grid-tab-btn,
body.device-tv #filterBar .filter-btn,
body.device-tv #filterBar .filter-clear-btn,
body.device-tv .hero-btn-play,
body.device-tv .hero-btn-save {
    min-height: 56px;
}

/* Lớp tìm kiếm toàn màn hình: chữ và nút nằm dưới dải Dynamic Island, nội dung chừa chỗ tab bar */
body.device-mobile .search-overlay {
    padding-top: calc(var(--safe-top) + 1rem);
    padding-bottom: calc(var(--safe-bottom) + 8px + 64px + 16px);
}

/* --- Cast: bên nhận (TV, máy tính) --- */
.cast-label[hidden],
.cast-dialog[hidden],
.cast-panel[hidden] {
    display: none !important;
}

.cast-settings-btn {
    min-width: var(--tap);
    min-height: var(--tap);
    border: 1px solid var(--glass-border-light);
    border-radius: var(--pill);
    background: transparent;
    color: var(--text-dim);
    font-size: 20px;
    cursor: pointer;
}

body.device-mobile .cast-settings-btn {
    display: none;
}

.cast-label {
    position: fixed;
    top: calc(var(--safe-top) + 16px);
    right: max(16px, var(--safe-right));
    z-index: 960;
    padding: 8px 20px;
    font-size: 16px;
    font-weight: 600;
}

.cast-dialog {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 980;
    width: min(90vw, 520px);
    padding: 28px;
    border-radius: 28px;
    text-align: center;
    background: rgba(28, 28, 30, 0.9);
}

.cast-dialog p {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 20px;
}

.cast-dialog-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.cast-btn {
    min-height: 56px;
    min-width: 120px;
    padding: 0 24px;
    border: 1px solid var(--glass-border-light);
    border-radius: var(--pill);
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 20px;
    font-weight: 700;
    cursor: pointer;
}

.cast-btn-primary {
    background: #fff;
    color: #000;
}

.cast-panel {
    position: fixed;
    top: calc(var(--safe-top) + 72px);
    right: max(16px, var(--safe-right));
    z-index: 970;
    padding: 20px 24px;
    border-radius: 24px;
    background: rgba(28, 28, 30, 0.92);
}

.cast-switch {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 20px;
    cursor: pointer;
}

.cast-switch input {
    width: 28px;
    height: 28px;
}

/* --- Cast: bên điều khiển (iPhone) --- */
.cast-sheet[hidden],
.cast-scrim[hidden],
.cast-toast[hidden],
.cast-dot[hidden],
.cast-empty[hidden] {
    display: none !important;
}

body:not(.device-mobile) .cast-top-btn {
    display: none;
}

.cast-top-btn {
    position: relative;
    min-width: var(--tap);
    min-height: var(--tap);
    padding: 0;
    border: 1px solid var(--glass-border-light);
    border-radius: var(--pill);
    background: rgba(8, 8, 8, 0.35);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
}

.cast-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #30d158;
    box-shadow: 0 0 0 2px rgba(8, 8, 8, 0.8);
}

body.device-mobile .sticky-header header {
    align-items: center;
}

.cast-scrim {
    position: fixed;
    inset: 0;
    z-index: 940;
    background: rgba(0, 0, 0, 0.35);
}

.cast-sheet {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(var(--safe-bottom) + 8px + 64px + 12px);
    max-height: calc(100svh - var(--safe-top) - var(--safe-bottom) - 64px - 8px - 12px - 24px);
    overflow-y: auto;
    z-index: 950;
    padding: 20px 16px 16px;
    border-radius: 28px;
    background: rgba(28, 28, 30, 0.9);
}

.cast-sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.cast-sheet-head h2 {
    font-size: 20px;
    font-weight: 800;
}

.cast-sheet-close {
    min-width: var(--tap);
    min-height: var(--tap);
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 16px;
}

.cast-device-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cast-device {
    min-height: 56px;
    padding: 0 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid var(--glass-border-light);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    text-align: left;
}

.cast-device-status {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-dim);
}

.cast-empty {
    text-align: center;
    padding: 16px 8px;
    color: var(--text-dim);
}

.cast-empty p:first-child {
    color: #fff;
    font-weight: 700;
    margin-bottom: 6px;
}

.cast-hint {
    font-size: 14px;
}

.cast-toast {
    position: fixed;
    left: 50%;
    top: calc(var(--safe-top) + 64px);
    transform: translateX(-50%);
    z-index: 990;
    padding: 10px 20px;
    font-size: 15px;
    font-weight: 600;
    background: rgba(28, 28, 30, 0.92);
    max-width: calc(100vw - 32px);
}

/* --- Cast: thanh nhỏ và bảng điều khiển (iPhone) --- */
.cast-mini[hidden],
.cast-remote[hidden] {
    display: none !important;
}

.cast-mini {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(var(--safe-bottom) + 8px + 64px + 8px);
    z-index: 899;
    min-height: 56px;
    padding: 8px 18px 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-radius: 28px;
    color: #fff;
    text-align: left;
    overflow: hidden;
}

.cast-mini-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.cast-mini-title {
    font-size: 15px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cast-mini-ep {
    font-size: 12px;
    color: var(--text-dim);
}

.cast-mini-state {
    font-size: 18px;
}

.cast-mini-progress {
    position: absolute;
    left: 18px;
    right: 18px;
    bottom: 6px;
    height: 3px;
    border-radius: var(--pill);
    background: rgba(255, 255, 255, 0.2);
    overflow: hidden;
}

.cast-mini-fill {
    display: block;
    height: 100%;
    width: 0;
    background: var(--accent-color);
}

.cast-remote {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(var(--safe-bottom) + 8px + 64px + 12px);
    max-height: calc(100svh - var(--safe-top) - var(--safe-bottom) - 64px - 8px - 12px - 24px);
    overflow-y: auto;
    z-index: 955;
    padding: 20px 16px 16px;
    border-radius: 28px;
    background: rgba(28, 28, 30, 0.92);
}

.cast-remote-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.cast-remote-meta {
    min-width: 0;
}

.cast-remote-title {
    font-size: 18px;
    font-weight: 800;
}

.cast-remote-ep {
    font-size: 14px;
    color: var(--text-dim);
}

.cast-remote-progress {
    height: 6px;
    border-radius: var(--pill);
    background: rgba(255, 255, 255, 0.2);
    overflow: hidden;
}

.cast-remote-fill {
    height: 100%;
    width: 0;
    background: var(--accent-color);
}

.cast-remote-times {
    display: flex;
    justify-content: space-between;
    margin: 6px 0 14px;
    font-size: 12px;
    color: var(--text-dim);
}

.cast-remote-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 14px;
}

.cast-round {
    min-width: var(--tap);
    min-height: var(--tap);
    width: 52px;
    height: 52px;
    border: 1px solid var(--glass-border-light);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
}

.cast-round-main {
    width: 64px;
    height: 64px;
    background: #fff;
    color: #000;
    font-size: 20px;
}

.cast-option {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: var(--tap);
    font-size: 15px;
}

.cast-option input {
    width: 24px;
    height: 24px;
}

.cast-remote-actions {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

.cast-pill {
    flex: 1;
    min-height: var(--tap);
    padding: 0 16px;
    border: 1px solid var(--glass-border-light);
    border-radius: var(--pill);
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
}

.cast-pill-danger {
    color: #ff6961;
}

/* --- Tự qua tập: lớp đếm ngược nằm dưới video, ngoài vùng an toàn --- */
.auto-next {
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: calc(56px + var(--safe-bottom, 0px));
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--pill);
}

.auto-next[hidden] {
    display: none;
}

.auto-next-text {
    flex: 2;
    font-size: 15px;
    font-weight: 700;
    padding-left: 6px;
}

/* --- Bỏ qua mở đầu: góc dưới phải, tầm ngón cái, trên thanh điều khiển video --- */
.skip-intro {
    position: absolute;
    right: calc(12px + var(--safe-right, 0px));
    bottom: calc(56px + var(--safe-bottom, 0px));
    z-index: 5;
    min-height: var(--tap);
    padding: 0 18px;
    border-radius: var(--pill);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
}

.skip-intro[hidden] {
    display: none;
}

/* --- Cài đặt phát (⚙ trong thanh trên của trình phát) --- */
.cast-switch .pref-number {
    width: 88px;
    min-height: var(--tap);
    margin-left: auto;
    padding: 0 10px;
    border: 1px solid var(--glass-border-light);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 18px;
    text-align: center;
}

#playerPrefs .cast-switch + .cast-switch {
    margin-top: 14px;
}

#playerPrefs {
    display: flex;
    flex-direction: column;
}

#playerPrefs[hidden] {
    display: none !important;
}

.player-prefs-btn {
    min-width: var(--tap);
    min-height: var(--tap);
    border: 1px solid var(--glass-border-light);
    border-radius: var(--pill);
    background: transparent;
    color: var(--text-dim);
    font-size: 20px;
    cursor: pointer;
}

.auto-next .cast-pill {
    flex: 0 0 auto;
    min-width: 120px;
}

.auto-next-text {
    flex: 1;
}
