.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: var(--spacing-lg) var(--spacing-xl);
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.8) 0%, transparent 100%);
    z-index: 1000;
    pointer-events: none;
}

.back-btn {
    pointer-events: auto;
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: 0.7rem 1.5rem;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-full);
    color: var(--color-text-primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all var(--transition-smooth);
    box-shadow: var(--shadow-sm);
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--color-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.watch-container {
    max-width: 1600px;
    margin: var(--spacing-2xl) auto;
    padding: 0 var(--spacing-xl);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xl);
    align-items: center;
}

.player-section {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

.player-toolbar {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    flex-wrap: wrap;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    box-shadow: var(--shadow-sm);
}

.control-group { display: flex; align-items: center; gap: var(--spacing-md); }

.sd-toggle {
    display: flex;
    background: var(--color-bg-elevated);
    border: var(--border-subtle);
    border-radius: var(--radius-full);
    padding: 4px;
    position: relative;
    cursor: pointer;
}

.sd-option {
    padding: 0.6rem 1.5rem;
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--color-text-muted);
    z-index: 2;
    transition: color var(--transition-base);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sd-option.active { color: var(--color-text-primary); }

.sd-bg {
    position: absolute;
    top: 4px; left: 4px; bottom: 4px;
    width: calc(50% - 4px);
    background: var(--color-primary);
    border-radius: var(--radius-full);
    transition: transform var(--transition-smooth);
    box-shadow: 0 4px 12px var(--color-primary-glow);
    z-index: 1;
}

.sd-toggle[data-state="dub"] .sd-bg { transform: translateX(100%); }

.source-select {
    appearance: none;
    background-color: var(--color-bg-elevated);
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1.2rem center;
    border: var(--border-subtle);
    color: var(--color-text-primary);
    padding: 0.7rem 2.8rem 0.7rem 1.2rem;
    border-radius: var(--radius-full);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    min-width: 160px;
    transition: all var(--transition-base);
}

.source-select:hover { border-color: var(--color-primary); background-color: var(--color-bg-card); }
.source-select:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-glow); }

.video-container {
    aspect-ratio: 16/9;
    width: 100%;
    background: var(--color-bg-base);
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-lg), 0 0 0 1px var(--glass-border);
    position: relative;
    transition: box-shadow var(--transition-smooth);
}

.video-container:hover { box-shadow: var(--shadow-lg), 0 0 0 1px var(--color-primary), var(--shadow-glow); }

#player { width: 100%; height: 100%; object-fit: contain; }

.loading-overlay {
    position: absolute;
    inset: 0;
    background: var(--color-bg-base);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 20;
    gap: var(--spacing-lg);
}

.spinner {
    width: 48px; height: 48px;
    border: 3px solid rgba(255,255,255,0.1);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-overlay p { color: var(--color-text-secondary); font-size: 0.95rem; font-weight: 500; }

.episode-controls {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--spacing-lg);
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-sm);
}

.episode-info h1 { font-size: 1.75rem; font-weight: 800; margin: 0 0 var(--spacing-xs); }
.episode-info p { color: var(--color-primary); font-weight: 600; font-size: 1rem; text-transform: uppercase; letter-spacing: 0.05em; }

.navigation-buttons { display: flex; gap: var(--spacing-md); }

.nav-btn {
    display: flex; align-items: center; gap: var(--spacing-sm);
    background: var(--color-bg-elevated); border: var(--border-subtle);
    color: var(--color-text-primary); padding: 0.75rem 1.5rem;
    border-radius: var(--radius-full); font-weight: 600; font-size: 0.9rem;
    cursor: pointer; transition: all var(--transition-base);
}

.nav-btn:hover:not(:disabled) { background: var(--color-primary); border-color: var(--color-primary); transform: translateY(-2px); box-shadow: var(--shadow-glow); }
.nav-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.episode-carousel-compact {
    width: 100%;
    max-width: 1600px;
    margin-top: var(--spacing-lg);
    padding: 0;
    background: transparent;
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.carousel-header {
    margin-bottom: var(--spacing-lg);
    padding: 0 var(--spacing-xl);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.carousel-header h2 {
    font-size: 1.6rem;
    font-weight: 900;
    color: var(--color-text-primary);
    letter-spacing: -0.04em;
    border-left: 4px solid var(--color-primary);
    padding-left: var(--spacing-md);
}

.carousel-nav {
    display: flex;
    gap: var(--spacing-xs);
}

.carousel-arrow-mini {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--color-bg-elevated);
    border: var(--border-subtle);
    border-radius: var(--radius-full);
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.carousel-arrow-mini:hover {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: var(--color-text-primary);
    box-shadow: var(--shadow-sm);
}

.carousel-arrow-mini[style*="opacity: 0.3"] {
    background: var(--color-bg-elevated);
    color: var(--color-text-muted);
    border-color: var(--border-subtle);
    box-shadow: none;
}

.episode-carousel-compact-list {
    display: flex;
    gap: var(--spacing-md);
    padding: var(--spacing-sm) var(--spacing-xl);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    mask-image: linear-gradient(to right, transparent, black var(--spacing-md), black calc(100% - var(--spacing-md)), transparent);
}

.episode-carousel-compact-list::-webkit-scrollbar { display: none; }

.carousel-item {
    flex: 0 0 200px;
    height: 112px;

    background: var(--color-bg-card);
    border: 2px solid var(--border-subtle);
    border-radius: var(--radius-md);
    overflow: hidden;
    position: relative;
    transition: all var(--transition-base);
    text-decoration: none;
    display: flex;
    flex-direction: column;

    scroll-snap-align: start;
    box-shadow: var(--shadow-sm);
}

.carousel-item:hover {
    border-color: var(--color-primary);
    transform: scale(1.02);
    box-shadow: var(--shadow-md), var(--shadow-glow);
}

.carousel-item.active-ep-carousel {
    border-color: var(--color-primary);
    background: rgba(139, 92, 246, 0.15);
    box-shadow: 0 0 0 2px var(--color-primary), var(--shadow-md);
    transform: scale(1.02);
}

.carousel-item.active-ep-carousel::after {
    content: 'WATCHING';
    position: absolute;
    top: 0;
    right: 0;
    background: var(--color-primary);
    color: var(--color-text-primary);
    padding: 2px 8px;
    font-size: 0.7rem;
    font-weight: 800;
    border-bottom-left-radius: var(--radius-sm);
    letter-spacing: 0.05em;
    z-index: 10;
}

.carousel-item-img-container {
    height: 70px;
    background: var(--color-bg-elevated);
    overflow: hidden;
    position: relative;
}

.carousel-item-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-smooth);
    opacity: 0.8;
}

.carousel-item:hover .carousel-item-img {
    transform: scale(1.1);
    opacity: 1;
}

.carousel-item-info {
    flex: 1;
    padding: var(--spacing-xs) var(--spacing-sm);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    background: var(--color-bg-elevated);
}

.carousel-item-info p {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text-primary);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0;
    line-height: 1.2;
}

.carousel-item-info p::before {
    content: attr(data-episode-number);
    color: var(--color-primary);
    font-weight: 800;
    margin-right: var(--spacing-xs);
    opacity: 0.7;
}

.carousel-item.no-thumbnail {
    flex: 0 0 160px;
    height: 90px;
    background: var(--color-bg-elevated);
    border: 2px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: row;
}

.carousel-item.no-thumbnail .carousel-item-info {
    padding: var(--spacing-sm);
    background: transparent;
    justify-content: center;
}

.carousel-item.no-thumbnail .carousel-item-info p {
    color: var(--color-text-secondary);
    font-size: 1.05rem;
    font-weight: 700;
    text-align: center;
}

.carousel-item.no-thumbnail:hover {
    background: rgba(139, 92, 246, 0.12);
    border-color: var(--color-primary);
}

.carousel-item.no-thumbnail.active-ep-carousel .carousel-item-info p {
    color: var(--color-primary);
}

.anime-details, .anime-extra-content {
    max-width: 1600px;
    margin: var(--spacing-2xl) auto;
}

.details-container {
    display: flex;
    flex-direction: row;
    gap: var(--spacing-xl);
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-xl);
    box-shadow: var(--shadow-md);
}

.details-cover {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--spacing-md);
    flex-shrink: 0;
}

.details-cover h1 {
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--color-text-primary);
    line-height: 1.2;
    margin: 0 0 var(--spacing-md) 0;
    text-align: left;
}

.cover-image { width: 220px; border-radius: var(--radius-md); box-shadow: var(--shadow-lg); }

.details-content h1 { font-size: 1.5rem; font-weight: 800; margin-bottom: var(--spacing-md); }

.meta-badge {
    background: rgba(139, 92, 246, 0.12);
    color: var(--color-primary);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
    border: 1px solid rgba(139, 92, 246, 0.2);
}

.meta-badge.meta-score { background: var(--color-primary); color: white; }
.details-description { font-size: 1rem; line-height: 1.7; color: var(--color-text-secondary); }

.characters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-xl);
}

.characters-header h2 {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--color-text-primary);
    border-left: 5px solid var(--color-primary);
    padding-left: var(--spacing-md);
}

.expand-btn {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    background: transparent;
    border: none;
    color: var(--color-primary);
    font-weight: 600;
    cursor: pointer;
    font-size: 1rem;
    padding: var(--spacing-xs);
    border-radius: var(--radius-sm);
}

.expand-btn:hover { background: rgba(139, 92, 246, 0.1); }
.expand-btn svg { transition: transform var(--transition-smooth); }
.expand-btn[data-expanded="true"] svg { transform: rotate(180deg); }

.characters-carousel {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-lg);
    align-content: flex-start;
    overflow: hidden;

    height: 208px;
    transition: height 0.55s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0 var(--spacing-sm);

    -ms-overflow-style: none;
    scrollbar-width: none;
}

.characters-carousel::-webkit-scrollbar {
    display: none;
}

.characters-carousel.expanded {

    height: auto;
    max-height: 3200px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;

    -ms-overflow-style: auto;
    scrollbar-width: thin;
}

.characters-carousel.expanded::-webkit-scrollbar {
    width: 6px;
}

.characters-carousel.expanded::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.4);
    border-radius: 3px;
}

.characters-carousel.expanded::-webkit-scrollbar-track {
    background: transparent;
}

.plyr--video { border-radius: var(--radius-xl); }
.plyr__controls { background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.5) 50%, transparent 100%) !important; padding: 1rem 1.5rem 1.5rem !important; }
.plyr--full-ui input[type=range] { color: var(--color-primary); }
.plyr__control:hover { background: rgba(255,255,255,0.12) !important; }
.plyr__menu__container { background: var(--glass-bg) !important; backdrop-filter: blur(16px); border: 1px solid var(--glass-border); box-shadow: var(--shadow-lg) !important; }

@media (min-width: 1024px) {
    .carousel-nav { display: flex; }
    .watch-container { padding-top: 5rem; }

    .details-cover {
        align-items: center;
        text-align: center;
    }
    .details-cover h1 {
        text-align: center;
        margin-bottom: var(--spacing-lg);
    }
}

@media (max-width: 768px) {
    .watch-container { padding: 4.5rem 1rem; }

    .episode-carousel-compact-list {
        padding: var(--spacing-sm) var(--spacing-md);
    }
    .carousel-header {
        padding: 0 var(--spacing-md);
    }
    .carousel-item {
        flex: 0 0 180px;
        height: 100px;
    }
    .carousel-item-img-container { height: 60px; }
    .carousel-item-info p { font-size: 0.95rem; }
    .carousel-item.no-thumbnail {
        flex: 0 0 140px;
        height: 80px;
    }

    .details-container { flex-direction: column; text-align: center; }

    .details-cover {
        align-items: center;
        width: 100%;
    }
    .details-cover h1 {
        font-size: 2rem;
        text-align: center;
    }
    .cover-image { width: 180px; margin: 0 auto; }

    .episode-controls { flex-direction: column; gap: var(--spacing-md); }
    .navigation-buttons { width: 100%; justify-content: center; }
    .nav-btn { flex: 1; justify-content: center; }
}

@media (max-width: 480px) {
    .episode-info h1, .details-content h1 { font-size: 1.5rem; }

    .carousel-item {
        flex: 0 0 150px;
        height: 90px;
    }
    .carousel-item-img-container { height: 50px; }
    .carousel-item-info p { font-size: 0.9rem; }
    .carousel-item.no-thumbnail {
        flex: 0 0 120px;
        height: 70px;
    }

    .details-cover h1 {
        font-size: 1.5rem;
    }

    .nav-btn span { display: none; }

    .character-card {

        flex: 1 1 100%;
    }
}