:root {
    --bg-color: #0a0a0a;
    --bg-secondary: #141414;
    --bg-card: #1a1a1a;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --accent-color: #e50914;
    /* Netflix-ish red, or maybe a nice purple/blue? Let's go with a vibrant purple/blue gradient */
    --accent-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --accent-solid: #764ba2;
    --card-hover-transform: scale(1.05);
    --transition-speed: 0.3s;
    --font-family: 'Outfit', sans-serif;
    --grid-gap: 1.5rem;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

.app-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* Header */
.main-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(10, 10, 10, 0.95);
    backdrop-filter: blur(10px);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.05em;
}

.logo .accent {
    color: var(--accent-solid);
}

/* Search */
.search-container {
    flex: 1;
    max-width: 600px;
    /* Increased width */
    margin: 0 2rem;
}

.search-wrapper {
    position: relative;
    background: var(--bg-secondary);
    border-radius: 50px;
    border: 1px solid #333;
    transition: all var(--transition-speed);
    display: flex;
    align-items: center;
}

.search-wrapper:focus-within {
    border-color: var(--accent-solid);
    background: #222;
    box-shadow: 0 0 20px rgba(118, 75, 162, 0.3);
    /* Add glow */
    transform: scale(1.02);
    /* Slight zoom */
}

.search-icon {
    position: absolute;
    left: 1.2rem;
    color: var(--text-secondary);
    pointer-events: none;
}

#search-input {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding: 1rem 3rem 1rem 3.5rem;
    /* Increased padding */
    font-size: 1.1rem;
    /* Larger font */
    font-family: var(--font-family);
    outline: none;
}

.search-clear {
    position: absolute;
    right: 1rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.2rem;
    border-radius: 50%;
    transition: background 0.2s, color 0.2s;
}

.search-clear:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

/* Badge */
.badge {
    background: rgba(118, 75, 162, 0.2);
    color: #b983ff;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.badge-dot {
    width: 8px;
    height: 8px;
    background-color: #b983ff;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 10px #b983ff;
}

.hidden {
    display: none !important;
}

/* Hero Section */
.hero {
    height: 60vh;
    border-radius: 20px;
    overflow: hidden;
    position: relative;
    margin-bottom: 3rem;
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: flex-end;
}

.hero-overlay {
    background: linear-gradient(to top, var(--bg-color) 0%, rgba(10, 10, 10, 0.8) 50%, rgba(10, 10, 10, 0) 100%);
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

.hero-content {
    position: relative;
    z-index: 10;
    padding: 3rem;
    max-width: 800px;
}

.hero-title {
    font-size: 3.5rem;
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 1rem;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.hero-meta {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
    color: #ddd;
}

.hero-desc {
    font-size: 1.1rem;
    color: #ccc;
    margin-bottom: 2rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    border: none;
    padding: 0.8rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 50px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(118, 75, 162, 0.4);
}

/* Media Sections */
.media-section {
    margin-bottom: 3rem;
}

.subsection {
    margin-bottom: 2rem;
}

.subsection-title {
    font-size: 1.2rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    padding-left: 0.5rem;
    border-left: 3px solid var(--accent-solid);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.section-title {
    font-size: 1.5rem;
    font-weight: 600;
}

.section-tabs {
    display: flex;
    gap: 0.5rem;
    background: var(--bg-secondary);
    padding: 0.3rem;
    border-radius: 50px;
}

.tab {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.4rem 1rem;
    border-radius: 20px;
    cursor: pointer;
    font-family: var(--font-family);
    font-weight: 500;
    transition: all 0.2s;
}

.tab.active {
    background: #333;
    color: white;
}

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--grid-gap);
}

/* Cards */
.media-card {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg-card);
    transition: transform var(--transition-speed), box-shadow var(--transition-speed);
    cursor: pointer;
    aspect-ratio: 2/3;
}

.media-card:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    z-index: 10;
}

.card-poster {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 1rem;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9), transparent);
    opacity: 0;
    transition: opacity 0.2s;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.media-card:hover .card-overlay {
    opacity: 1;
}

.card-title {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.3rem;
    line-height: 1.2;
}

.card-meta {
    font-size: 0.8rem;
    color: #ccc;
    display: flex;
    justify-content: space-between;
}

.rating {
    color: #ffd700;
}

/* Loading Skeleton */
.loading-skeleton {
    background: #1a1a1a;
    aspect-ratio: 2/3;
    border-radius: 12px;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.6;
    }
}

/* Footer */
.main-footer {
    text-align: center;
    padding: 3rem 0;
    color: var(--text-secondary);
    border-top: 1px solid #222;
    margin-top: 3rem;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
}

::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
}

.card-actions {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    right: 0.5rem;
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.media-card:hover .card-actions {
    opacity: 1;
}

.btn-icon-small {
    background: rgba(0, 0, 0, 0.6);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(4px);
    pointer-events: auto;
}

.btn-icon-small:hover {
    background: var(--accent-solid);
    transform: scale(1.1);
}

.fav-btn {
    /* Removed absolute positioning as it's now in flex container */
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: white;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s;
    z-index: 20;
}

.media-card:hover .fav-btn {
    opacity: 1;
}

.fav-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.fav-btn.active {
    color: var(--accent-solid);
    background: rgba(255, 255, 255, 0.1);
}

.card-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.card-genres {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 70%;
}

.card-runtime {
    font-variant-numeric: tabular-nums;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.modal-content {
    background: var(--bg-card);
    border-radius: 1rem;
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.close-modal {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.close-modal:hover {
    background: var(--accent-solid);
}

.modal-layout {
    display: flex;
    gap: 2rem;
    padding: 2rem;
}

.modal-poster-container {
    flex-shrink: 0;
    width: 300px;
}

.modal-poster {
    width: 100%;
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.modal-info {
    flex-grow: 1;
}

.modal-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    line-height: 1.1;
}

.modal-meta {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    color: var(--text-secondary);
}

.modal-rating {
    color: #fbbf24;
}

.modal-genres {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.modal-section {
    margin-bottom: 1.5rem;
}

.modal-section h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.modal-desc {
    line-height: 1.6;
    color: var(--text-secondary);
}

.modal-cast {
    color: var(--text-secondary);
}

.modal-actions {
    margin-top: 2rem;
}

@media (max-width: 768px) {
    .modal-layout {
        flex-direction: column;
        padding: 1.5rem;
    }

    .modal-poster-container {
        width: 100%;
        max-width: 250px;
        margin: 0 auto;
    }

    .modal-title {
        font-size: 1.75rem;
        text-align: center;
    }

    .modal-meta {
        justify-content: center;
        font-size: 1rem;
    }

    .modal-genres {
        justify-content: center;
    }
}

.fav-btn svg {
    pointer-events: none;
}

/* Load More */
.load-more-container {
    display: flex;
    justify-content: center;
    margin-top: 2rem;
    padding-bottom: 2rem;
}

.btn-secondary {
    padding: 0.8rem 2rem;
    font-size: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.4);
}

/* View More Link */
.view-more {
    color: var(--accent-solid);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.2s;
}

.view-more:hover {
    color: #9b6bcc;
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 768px) {
    .hero-title {
        font-size: 2rem;
    }

    .media-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 1rem;
    }

    .hero-content h1 {
        font-size: 2rem;
    }

    /* Mobile Header Adjustments */
    .search-container {
        display: block;
        margin: 0 0.5rem;
        flex: 1;
        width: auto;
    }

    .search-wrapper {
        height: 40px;
    }

    #search-input {
        padding: 0.5rem 2.5rem 0.5rem 2.5rem;
        font-size: 1rem;
    }

    .search-icon {
        left: 0.8rem;
        width: 18px;
        height: 18px;
        top: 50%;
        transform: translateY(-50%);
    }

    .logo {
        font-size: 1.5rem;
    }

    #app-badge {
        display: none !important;
    }
}

/* Chatbot Styles */
#chat-fab {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background: var(--accent-gradient);
    border-radius: 50%;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 9999;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s;
    border: none;
    color: white;
}

#chat-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 25px rgba(118, 75, 162, 0.6);
}

#chat-fab svg {
    width: 32px;
    height: 32px;
    transition: transform 0.3s;
}

#chat-fab.active svg {
    transform: rotate(90deg);
}

/* Chat Panel on Desktop: Right side column, 400px, full height, rounded corners, shadow, z-index, overflow hidden, transform origin, transition, border, pointer events */
#chat-iframe-container {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 400px;
    height: calc(100% - 120px);
    background: var(--bg-card);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    z-index: 9998;
    overflow: hidden;
    transform-origin: bottom right;
    transition: transform 0.3s cubic-bezier(0.165, 0.84, 0.44, 1), opacity 0.3s, visibility 0.3s;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Tablets, Desktop App in Windowed Mode: 50% width, full height, rounded corners, shadow, z-index, overflow hidden, transform origin, transition, border, pointer events */
@media (max-width: 768px) {
    #chat-iframe-container {
        width: 50%;
        right: 20px;
        bottom: 100px;
        height: calc(100% - 120px);
    }
}

/* Native App Banner */
#native-app-banner {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(90deg, #1a1a1a 0%, #2d2d2d 100%);
    border-bottom: 1px solid var(--accent-solid);
    padding: 0.8rem 1.5rem;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    transform: translateY(0);
    transition: transform 0.3s ease-in-out;
}

#native-app-banner.hidden {
    display: none !important;
}

.banner-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
}

.banner-icon {
    font-size: 1.5rem;
    color: var(--accent-solid);
}

.banner-text {
    font-size: 0.95rem;
    color: #e0e0e0;
}

.banner-text strong {
    color: white;
    font-weight: 600;
}

.banner-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn-banner {
    background: var(--accent-gradient);
    color: white;
    padding: 0.5rem 1.2rem;
    border-radius: 20px;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    transition: transform 0.2s;
    white-space: nowrap;
}

.btn-banner:hover {
    transform: scale(1.05);
}

.banner-close {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, background 0.2s;
}

.banner-close:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

@media (max-width: 768px) {
    #native-app-banner {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
        padding: 1rem;
    }

    .banner-content {
        flex-direction: column;
        gap: 0.5rem;
    }

    .banner-actions {
        width: 100%;
        justify-content: center;
    }

    .banner-close {
        position: absolute;
        top: 0.5rem;
        right: 0.5rem;
    }
}


#chat-iframe-container.hidden {
    transform: translateY(100%);
    /* Slide down */
}

#chat-fab {
    bottom: 20px;
    right: 20px;
    z-index: 10000;
}


/* Chat Panel on Mobile (Portrait Mode): Full width, full height, rounded corners, shadow, z-index, overflow hidden, transform origin, transition, border, pointer events */
@media (max-width: 480px) {
    #chat-iframe-container {
        width: calc(100% - 40px);
        right: 20px;
        bottom: 100px;
        height: calc(100% - 120px);
    }

    #chat-fab {
        bottom: 20px;
        right: 20px;
    }
}



/* This was an attempt to make chat work while viewing a movie on your phone.
It failed miserably. We should probably hide the chat toggler in this case until we find a solution 
@media (max-width: 900px) and (orientation: landscape) {
    #chat-iframe-container {
        top: 0;
        bottom: 0;
        right: 0;
        width: 33vw;
        height: 100%;
        border-radius: 0;
        border-left: 1px solid rgba(255, 255, 255, 0.1);
        transform-origin: right center;
    }

    #chat-iframe-container.hidden {
        transform: translateX(100%);
    }
} */

#chat-iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
}


/* Onboarding Modal */
#onboarding-modal-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 20000;
    background: var(--bg-color);
    display: flex;
    justify-content: center;
    align-items: center;
}

#onboarding-modal-container.hidden {
    display: none;
}

#onboarding-iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* ==========================================================================
   Browse redesign: header nav, hero carousel, rows, details sheet
   ========================================================================== */

/* Header */
.main-header {
    display: grid;
    grid-template-columns: auto auto 1fr auto;
    grid-template-areas: "logo nav search actions";
    gap: 1.25rem;
    padding: 1rem 2rem;
    margin: 0 -2rem;
}

.main-header .logo {
    grid-area: logo;
    color: var(--text-primary);
    text-decoration: none;
}

.main-nav {
    grid-area: nav;
    display: flex;
    gap: 0.25rem;
}

.main-nav a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    padding: 0.5rem 0.95rem;
    border-radius: 50px;
    white-space: nowrap;
    transition: color 0.2s, background 0.2s;
}

.main-nav a:hover {
    color: var(--text-primary);
}

.main-nav a.active {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
}

.main-header .search-container {
    grid-area: search;
    justify-self: end;
    width: 100%;
    max-width: 440px;
    margin: 0;
}

.main-header #search-input {
    padding: 0.7rem 2.75rem 0.7rem 3.2rem;
    font-size: 1rem;
}

.main-header .search-wrapper:focus-within {
    transform: none;
}

.main-header .header-actions {
    grid-area: actions;
    gap: 0.25rem;
}

.header-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.55rem 0.8rem;
    border-radius: 50px;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    font: 500 0.95rem var(--font-family);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: color 0.2s, background 0.2s;
}

.header-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.08);
}

.header-btn.active {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.12);
}

.header-btn.spinning svg {
    animation: spin 0.5s ease-in-out;
}

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

.count-badge {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: var(--accent-gradient);
    color: white;
    font-size: 0.72rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Buttons */
.btn-primary {
    font-family: var(--font-family);
}

.btn-glass {
    background: rgba(255, 255, 255, 0.14);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: var(--text-primary);
    padding: 0.8rem 1.6rem;
    border-radius: 50px;
    font: 600 1.05rem var(--font-family);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s, transform 0.2s;
}

.btn-glass:hover {
    background: rgba(255, 255, 255, 0.24);
    transform: translateY(-2px);
}

.btn-glass.active {
    color: #d4b5ff;
}

.btn-round {
    width: 52px;
    height: 52px;
    padding: 0;
    justify-content: center;
}

.btn-small {
    padding: 0.45rem 1rem;
    font-size: 0.9rem;
}

/* Hero carousel */
.hero-carousel {
    position: relative;
    height: min(72vh, 680px);
    min-height: 440px;
    border-radius: 20px;
    overflow: hidden;
    margin: 0.5rem 0 2.5rem;
    background: var(--bg-secondary);
}

.hero-carousel.loading {
    animation: pulse 1.5s infinite;
}

.hero-slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.9s ease;
}

.hero-slide.active {
    opacity: 1;
    pointer-events: auto;
}

.hero-backdrop {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center 20%;
    transform: scale(1.06);
    transition: transform 9s linear;
}

.hero-slide.active .hero-backdrop {
    transform: scale(1);
}

.hero-shade {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(90deg, rgba(10, 10, 10, 0.92) 0%, rgba(10, 10, 10, 0.55) 38%, rgba(10, 10, 10, 0) 70%),
        linear-gradient(0deg, rgba(10, 10, 10, 0.85) 0%, rgba(10, 10, 10, 0) 45%);
}

.hero-carousel .hero-content {
    position: absolute;
    left: 0;
    bottom: 0;
    padding: 3rem 3.5rem;
    max-width: 680px;
    z-index: 2;
}

.hero-kicker {
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.8rem;
    font-weight: 600;
    color: #c9a7ff;
    margin-bottom: 0.75rem;
}

.hero-carousel .hero-title {
    margin-bottom: 1rem;
}

.hero-logo {
    display: block;
    max-width: min(440px, 85%);
    max-height: 170px;
    object-fit: contain;
    object-position: left bottom;
    filter: drop-shadow(0 4px 20px rgba(0, 0, 0, 0.6));
}

.hero-carousel .hero-meta {
    flex-wrap: wrap;
    font-size: 1rem;
    margin-bottom: 1rem;
}

.hero-carousel .hero-desc {
    margin-bottom: 1.75rem;
    font-size: 1.05rem;
    max-width: 560px;
}

.hero-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
}

.hero-dots {
    position: absolute;
    right: 2.5rem;
    bottom: 2.5rem;
    display: flex;
    gap: 0.5rem;
    z-index: 3;
}

.hero-dot {
    width: 8px;
    height: 8px;
    border-radius: 4px;
    border: none;
    padding: 0;
    background: rgba(255, 255, 255, 0.35);
    cursor: pointer;
    transition: width 0.3s, background 0.3s;
}

.hero-dot.active {
    width: 28px;
    background: white;
}

/* Genre chips (Movies / TV pages) */
.genre-chips {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    scrollbar-width: none;
    margin: -1rem -2rem 2rem;
    padding: 0.25rem 2rem;
}

.genre-chips::-webkit-scrollbar {
    display: none;
}

.chip {
    flex-shrink: 0;
    padding: 0.5rem 1.1rem;
    border-radius: 50px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: var(--bg-secondary);
    color: #ddd;
    text-decoration: none;
    font-size: 0.92rem;
    font-weight: 500;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.chip:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.35);
    color: white;
}

/* Rows */
.media-row {
    margin-bottom: 2rem;
}

.row-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
}

.row-header h2 {
    font-size: 1.35rem;
    font-weight: 600;
}

.view-all {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.92rem;
    font-weight: 500;
    white-space: nowrap;
    transition: color 0.2s;
}

.view-all:hover {
    color: var(--text-primary);
}

.row-scroller {
    position: relative;
    margin: 0 -2rem;
}

.row-track {
    display: flex;
    gap: 0.9rem;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding: 0 2rem;
    padding: 0.75rem 2rem 1rem;
    scrollbar-width: none;
}

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

.row-track>.media-card,
.row-track>.loading-skeleton {
    flex: 0 0 clamp(128px, 13vw, 190px);
    scroll-snap-align: start;
}

.row-arrow {
    position: absolute;
    top: 0.75rem;
    bottom: 1rem;
    width: 3.25rem;
    z-index: 20;
    border: none;
    color: white;
    font-size: 2.75rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
}

.row-arrow.left {
    left: 0;
    background: linear-gradient(to right, rgba(10, 10, 10, 0.95), rgba(10, 10, 10, 0));
}

.row-arrow.right {
    right: 0;
    background: linear-gradient(to left, rgba(10, 10, 10, 0.95), rgba(10, 10, 10, 0));
}

.row-scroller:hover .row-arrow:not(.disabled) {
    opacity: 1;
}

.row-arrow.disabled {
    pointer-events: none;
}

@media (hover: none) {
    .row-arrow {
        display: none;
    }
}

/* Top 10 rows */
.ranked-card {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-end;
    scroll-snap-align: start;
}

.rank-number {
    font-size: clamp(6.5rem, 11vw, 10rem);
    font-weight: 700;
    line-height: 0.78;
    color: var(--bg-color);
    -webkit-text-stroke: 3px rgba(255, 255, 255, 0.55);
    letter-spacing: -0.06em;
    margin-right: -1.1rem;
    user-select: none;
}

.ranked-card .media-card {
    width: clamp(112px, 10.5vw, 160px);
    flex-shrink: 0;
}

/* Cards */
.media-card {
    outline: none;
}

.media-card:focus-visible {
    box-shadow: 0 0 0 3px #b983ff;
}

.card-overlay {
    padding: 0.75rem;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.95) 0%, rgba(0, 0, 0, 0.65) 55%, rgba(0, 0, 0, 0) 100%);
}

.media-card:focus-visible .card-overlay {
    opacity: 1;
}

.card-buttons {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 0.5rem;
}

.card-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.5);
    background: rgba(20, 20, 20, 0.6);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.15s, background 0.15s;
}

.card-btn:hover {
    transform: scale(1.1);
    background: rgba(60, 60, 60, 0.8);
}

.card-btn.card-play {
    background: white;
    color: black;
    border-color: white;
}

.card-btn svg {
    width: 16px;
    height: 16px;
    pointer-events: none;
}

.card-btn.active {
    color: #c9a7ff;
    border-color: #c9a7ff;
}

.card-title {
    font-size: 0.95rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-meta {
    justify-content: flex-start;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.card-genres {
    font-size: 0.72rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.type-badge {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    background: rgba(0, 0, 0, 0.72);
    font-size: 0.62rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-weight: 600;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    z-index: 1;
}

/* Touch screens: no hover overlay, tapping a card opens its details */
@media (hover: none) {
    .card-overlay {
        display: none;
    }

    .media-card:hover {
        transform: none;
    }
}

/* Grid views (View all, genres, search, My List, History) */
.view-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin: 1rem 0 1.75rem;
}

.view-header h1 {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
    margin-right: auto;
}

.filter-pills {
    display: flex;
    gap: 0.25rem;
    background: var(--bg-secondary);
    padding: 0.3rem;
    border-radius: 50px;
    overflow-x: auto;
    scrollbar-width: none;
    max-width: 100%;
}

.pill {
    padding: 0.4rem 1rem;
    border-radius: 50px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    white-space: nowrap;
    transition: color 0.2s, background 0.2s;
}

.pill:hover {
    color: var(--text-primary);
}

.pill.active {
    background: white;
    color: black;
}

.grid-sentinel {
    height: 1px;
}

.empty-state {
    text-align: center;
    padding: 5rem 1rem;
    max-width: 460px;
    margin: 0 auto;
}

.empty-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    color: #b983ff;
}

.empty-icon svg {
    width: 32px;
    height: 32px;
}

.empty-state h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.empty-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

.empty-state-text {
    color: var(--text-secondary);
    padding: 3rem 0;
    text-align: center;
}

/* Details sheet */
body.modal-open {
    overflow: hidden;
}

.modal-content.details-modal {
    max-width: 980px;
    overflow-x: hidden;
}

.modal-content .close-modal {
    z-index: 30;
}

.details-loading .loading-skeleton {
    aspect-ratio: 16 / 9;
    border-radius: 0;
}

.details-hero {
    position: relative;
    aspect-ratio: 16 / 9;
    max-height: 58vh;
    width: 100%;
    background-color: var(--bg-secondary);
    background-size: cover;
    background-position: center 20%;
    display: flex;
    align-items: flex-end;
}

.details-hero-shade {
    position: absolute;
    inset: 0;
    background: linear-gradient(0deg, var(--bg-card) 0%, rgba(26, 26, 26, 0.45) 45%, rgba(26, 26, 26, 0) 75%);
}

.details-hero-content {
    position: relative;
    padding: 2rem 2.5rem 1.5rem;
    width: 100%;
}

.details-logo {
    display: block;
    max-width: min(380px, 70%);
    max-height: 140px;
    object-fit: contain;
    object-position: left bottom;
    margin-bottom: 1.25rem;
    filter: drop-shadow(0 4px 16px rgba(0, 0, 0, 0.6));
}

.details-title {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1.1;
    margin-bottom: 1.25rem;
}

.details-buttons {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.details-hero.playing-trailer {
    max-height: none;
    background: black;
}

.details-hero.playing-trailer iframe {
    width: 100%;
    height: 100%;
    border: 0;
}

.details-body {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
    padding: 0.75rem 2.5rem 2rem;
}

.details-meta {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: center;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.meta-tag {
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 0 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
}

.details-tagline {
    font-style: italic;
    color: #ddd;
    margin-bottom: 0.6rem;
}

.details-overview {
    color: #ddd;
    line-height: 1.7;
}

.details-side p {
    font-size: 0.9rem;
    color: #ccc;
    margin-bottom: 0.75rem;
}

.details-side .label {
    color: #777;
}

.details-genre {
    color: white;
    text-decoration: none;
}

.details-genre:hover {
    text-decoration: underline;
}

.details-recs {
    padding: 0 2.5rem 2.5rem;
}

.details-recs h3 {
    font-size: 1.3rem;
    margin-bottom: 1rem;
}

.recs-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 1rem;
}

/* Toast */
#toast {
    position: fixed;
    left: 50%;
    bottom: 2rem;
    transform: translate(-50%, 20px);
    background: white;
    color: black;
    padding: 0.6rem 1.25rem;
    border-radius: 50px;
    font-weight: 600;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s, transform 0.25s;
    z-index: 20001;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

#toast.visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* Responsive */
@media (max-width: 1280px) {
    .header-btn-label {
        display: none;
    }

    .header-btn .count-badge {
        position: absolute;
        top: 0;
        right: -2px;
        min-width: 17px;
        height: 17px;
        font-size: 0.65rem;
        padding: 0 4px;
    }
}

@media (max-width: 960px) {
    .main-header {
        grid-template-columns: auto 1fr auto;
        grid-template-areas:
            "logo search actions"
            "nav nav nav";
        row-gap: 0.6rem;
        column-gap: 0.75rem;
        padding-top: 0.75rem;
        padding-bottom: 0.75rem;
    }

    .main-header .search-container {
        max-width: none;
    }

    .main-nav {
        background: var(--bg-secondary);
        border-radius: 50px;
        padding: 0.25rem;
    }

    .main-nav a {
        flex: 1;
        text-align: center;
        padding: 0.4rem 0.5rem;
    }

    .main-nav a.active {
        background: rgba(255, 255, 255, 0.1);
        color: var(--text-primary);
    }

    .details-body {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

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

    .main-header {
        margin: 0 -1rem;
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .main-header .header-actions {
        gap: 0;
    }

    .header-btn {
        padding: 0.5rem;
    }

    .main-header #search-input {
        padding: 0.5rem 2.25rem 0.5rem 2.5rem;
    }

    .hero-carousel {
        height: 68vh;
        min-height: 460px;
        border-radius: 16px;
        margin-bottom: 2rem;
    }

    .hero-shade {
        background: linear-gradient(0deg, rgba(10, 10, 10, 0.97) 0%, rgba(10, 10, 10, 0.7) 40%, rgba(10, 10, 10, 0) 75%);
    }

    .hero-carousel .hero-content {
        padding: 1.25rem 1.25rem 2.75rem;
    }

    .hero-carousel .hero-title {
        font-size: 2rem;
    }

    .hero-logo {
        max-height: 110px;
    }

    .hero-carousel .hero-desc {
        -webkit-line-clamp: 2;
        line-clamp: 2;
        font-size: 0.95rem;
        margin-bottom: 1.25rem;
    }

    .hero-buttons .btn-primary,
    .hero-buttons .btn-glass:not(.btn-round) {
        padding: 0.7rem 1.25rem;
        font-size: 1rem;
    }

    .btn-round {
        width: 46px;
        height: 46px;
    }

    .hero-dots {
        left: 0;
        right: 0;
        bottom: 1rem;
        justify-content: center;
    }

    .genre-chips {
        margin: -0.75rem -1rem 1.5rem;
        padding: 0.25rem 1rem;
    }

    .row-scroller {
        margin: 0 -1rem;
    }

    .row-track {
        gap: 0.6rem;
        padding: 0.5rem 1rem 0.75rem;
        scroll-padding: 0 1rem;
    }

    .row-track>.media-card,
    .row-track>.loading-skeleton {
        flex-basis: 31vw;
        max-width: 160px;
    }

    .ranked-card .media-card {
        width: 28vw;
        max-width: 140px;
    }

    .rank-number {
        font-size: 6rem;
        -webkit-text-stroke-width: 2px;
        margin-right: -0.8rem;
    }

    .row-header h2 {
        font-size: 1.15rem;
    }

    .view-header h1 {
        font-size: 1.5rem;
    }

    .modal-overlay {
        padding: 0;
        align-items: flex-end;
    }

    .modal-content.details-modal {
        max-height: 94vh;
        border-radius: 1rem 1rem 0 0;
    }

    .details-hero-content {
        padding: 1.25rem;
    }

    .details-title {
        font-size: 1.75rem;
    }

    .details-logo {
        max-height: 90px;
    }

    .details-body {
        padding: 0.5rem 1.25rem 1.5rem;
    }

    .details-recs {
        padding: 0 1.25rem 2rem;
    }

    .recs-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.6rem;
    }
}


/* ==========================================================================
   Season & episode browser (details sheet and player page)
   ========================================================================== */

.details-episodes {
    padding: 0 2.5rem 2rem;
}

.episodes-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.episodes-header h3 {
    font-size: 1.3rem;
    font-weight: 600;
}

.season-select {
    appearance: none;
    -webkit-appearance: none;
    background: var(--bg-secondary) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") no-repeat right 1rem center;
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 0.55rem 2.5rem 0.55rem 1rem;
    font: 500 0.95rem var(--font-family);
    cursor: pointer;
}

.season-select:focus {
    outline: none;
    border-color: #b983ff;
}

.episode-count {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: -0.5rem 0 0.75rem;
}

.season-single {
    color: var(--text-secondary);
    font-weight: 500;
}

.episode-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.episode {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 1.25rem;
    align-items: start;
    padding: 0.9rem;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s;
    outline: none;
}

.episode:hover,
.episode:focus-visible {
    background: rgba(255, 255, 255, 0.06);
}

.episode.current {
    background: rgba(118, 75, 162, 0.18);
    box-shadow: inset 0 0 0 1px rgba(185, 131, 255, 0.35);
}

.episode.unaired {
    cursor: default;
    opacity: 0.55;
}

.episode.unaired:hover {
    background: none;
}

.episode-thumb {
    position: relative;
    aspect-ratio: 16 / 9;
    border-radius: 6px;
    overflow: hidden;
    background: var(--bg-secondary);
}

.episode-thumb img,
.episode-thumb-empty {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.episode-play {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 42px;
    height: 42px;
    margin: -21px 0 0 -21px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid white;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.episode:hover .episode-play,
.episode:focus-visible .episode-play {
    opacity: 1;
}

.episode-flag {
    position: absolute;
    left: 0.4rem;
    bottom: 0.4rem;
    background: var(--accent-gradient);
    color: white;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
}

.episode-flag.watched {
    background: rgba(0, 0, 0, 0.75);
    color: #ccc;
}

.episode-title-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    margin-bottom: 0.35rem;
}

.episode-title-row h4 {
    font-size: 1.02rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
}

.episode-number {
    color: var(--text-secondary);
    margin-right: 0.15rem;
}

.episode-runtime {
    color: var(--text-secondary);
    font-size: 0.88rem;
    white-space: nowrap;
}

.episode-overview {
    color: #bbb;
    font-size: 0.9rem;
    line-height: 1.55;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 0.35rem;
}

.episode-date {
    color: #777;
    font-size: 0.8rem;
}

.episode-skeleton {
    height: 130px;
    background: var(--bg-secondary);
    animation: pulse 1.5s infinite;
    cursor: default;
}

.episode-empty {
    color: var(--text-secondary);
    padding: 1rem 0;
}

/* Player page bits */
.episode-label {
    margin-top: 0.6rem;
    font-size: 1.1rem;
    font-weight: 500;
    color: #d4b5ff;
}

.btn-next-episode {
    background: var(--accent-gradient) !important;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
}

#episodes-container .episodes {
    margin-top: 1rem;
}

@media (max-width: 768px) {
    .details-episodes {
        padding: 0 1.25rem 1.5rem;
    }

    .episode {
        grid-template-columns: 130px 1fr;
        gap: 0.8rem;
        padding: 0.6rem;
    }

    .episode-title-row {
        flex-direction: column;
        gap: 0.1rem;
    }

    .episode-title-row h4 {
        font-size: 0.95rem;
    }

    .episode-overview {
        -webkit-line-clamp: 2;
        line-clamp: 2;
        font-size: 0.85rem;
    }

    .episode-play {
        opacity: 1;
        width: 34px;
        height: 34px;
        margin: -17px 0 0 -17px;
    }
}
