/* StreamHub Design System - Cinema-grade Netflix/YouTube Style */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    --primary: #E50914;
    /* Netflix Red */
    --accent: #B20710;
    --bg-dark: #0a0a0a;
    /* Deeper cinema black */
    --bg-card: #121212;
    --glass: rgba(20, 20, 20, 0.8);
    /* Darker, less glassy */
    --glass-border: rgba(255, 255, 255, 0.1);
    --text: #ffffff;
    --text-muted: #9ca3af;

    /* StreamHub Gradients */
    --gradient-red: linear-gradient(135deg, #E50914 0%, #B20710 100%);
    --gradient-cinema: linear-gradient(135deg, #0f0f0f 0%, #0a0a0a 100%);
    --gradient-card: linear-gradient(145deg, #1a1a1a 0%, #0f0f0f 100%);
    --gradient-hero: linear-gradient(180deg, transparent 0%, rgba(10, 10, 10, 0.8) 50%, #0a0a0a 100%);

    /* StreamHub Shadows */
    --shadow-card: 0 8px 32px -8px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px -10px rgba(229, 9, 20, 0.4);
    --shadow-elevated: 0 20px 60px -15px rgba(0, 0, 0, 0.7);
}

/* ===== GLOBAL SCROLLBAR ===== */
html {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) var(--bg-dark);
    scroll-snap-type: y mandatory;
    scroll-behavior: smooth;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
}

/* ===== STREAMHUB UTILITY CLASSES ===== */

/* Gradient Text Effect */
.text-gradient {
    background: var(--gradient-red);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

/* Glass Card Effect */
.glass-card {
    background: rgba(18, 18, 18, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulseGlow {

    0%,
    100% {
        opacity: 0.4;
    }

    50% {
        opacity: 0.8;
    }
}

.animate-fade-in {
    animation: fadeIn 0.5s ease-out forwards;
}

.animate-slide-up {
    animation: slideUp 0.6s ease-out forwards;
}

.animate-pulse-glow {
    animation: pulseGlow 2s ease-in-out infinite;
}

/* ===== STREAMHUB NAVBAR ===== */
.streamhub-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    height: 64px;
    background: transparent;
    transition: background 0.3s ease, transform 0.3s ease-in-out;
}

.streamhub-nav.scrolled {
    background: rgba(10, 10, 10, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

/* Antigravity-style: Hide navbar on scroll down */
.streamhub-nav.nav-hidden {
    transform: translateY(-100%);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

/* Removed .nav-logo styles as icon was removed */

.nav-title {
    font-size: 2rem;
    font-weight: 700;
    color: white;
    letter-spacing: -1px;
    display: flex;
    align-items: center;
    gap: 0;
}

.nav-title span {
    color: #94a3b8;
    /* Blue-grey for "KK" */
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    position: relative;
    padding: 0.5rem 1rem;
    border-radius: 50px;
    transition: all 0.3s ease;
    background: transparent;
}

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

.nav-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 0;
}

.nav-icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    transform: none;
    box-shadow: none;
}

.nav-icon-btn svg {
    width: 20px;
    height: 20px;
}

.notification-dot {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    animation: pulseGlow 2s ease-in-out infinite;
}

/* ===== STREAMHUB HERO SECTION ===== */
.hero-section {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 100px 1.5rem 2rem;
    position: relative;
    overflow: hidden;
    scroll-snap-align: start;
    scroll-snap-stop: always;
}

/* Animated Background Orbs */
.hero-section::before {
    content: '';
    position: absolute;
    top: 20%;
    left: -200px;
    width: 400px;
    height: 400px;
    background: rgba(229, 9, 20, 0.15);
    border-radius: 50%;
    filter: blur(120px);
    animation: pulseGlow 3s ease-in-out infinite;
    pointer-events: none;
}

.hero-section::after {
    content: '';
    position: absolute;
    bottom: 20%;
    right: -200px;
    width: 400px;
    height: 400px;
    background: rgba(229, 9, 20, 0.1);
    border-radius: 50%;
    filter: blur(120px);
    animation: pulseGlow 3s ease-in-out infinite 1s;
    pointer-events: none;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 50px;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.hero-badge svg {
    width: 16px;
    height: 16px;
    color: var(--primary);
}

.hero-heading {
    font-family: 'Inter', sans-serif;
    font-size: clamp(2.5rem, 8vw, 4.5rem);
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -2px;
    margin-bottom: 1.5rem;
}

.hero-heading .text-muted-line {
    color: var(--text-muted);
}

.hero-description {
    font-size: 1.1rem;
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto 2rem;
    line-height: 1.6;
}

/* URL Input Card */
.url-input-card {
    display: flex;
    flex-direction: row;
    gap: 12px;
    padding: 12px;
    width: 100%;
    max-width: 700px;
    box-shadow: var(--shadow-elevated);
    position: relative;
    z-index: 10;
}

.url-input-wrapper {
    flex: 1;
    position: relative;
}

/* Limit the generic SVG selector to only the direct child (the link icon) */
.url-input-wrapper>svg {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--text-muted);
    pointer-events: none;
}

.url-input {
    width: 100%;
    padding: 1rem 48px 1rem 48px;
    /* Added right padding for clear button */
    background: rgba(30, 30, 30, 0.5);
    border: none;
    border-radius: 12px;
    color: white;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
}

.clear-url-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: none;
    /* Hidden by default */
    align-items: center;
    justify-content: center;
    z-index: 20;
    pointer-events: auto;
    transition: background-color 0.2s ease;
    margin: 0;
    /* Prevent browser defaults */
}

.clear-url-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    /* Match notification icon */
    color: white;
    transform: translateY(-50%) !important;
    /* Prevent movement from generic button:hover */
    box-shadow: none !important;
    /* Remove generic shadow */
}

.url-input:focus {
    outline: none;
    box-shadow: 0 0 0 1px var(--primary);
}

.url-input::placeholder {
    color: rgba(156, 163, 175, 0.6);
}

.play-btn-gradient {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 1rem 2rem;
    background: var(--gradient-red);
    border: none;
    border-radius: 12px;
    color: white;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: var(--shadow-glow);
    transition: all 0.3s ease;
}

.play-btn-gradient:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 50px -10px rgba(229, 9, 20, 0.5);
}

.play-btn-gradient:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.play-btn-gradient svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* Demo Quick Links */


/* Force Transcode Checkbox */
.transcode-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.transcode-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

/* ===== IMPROVED TRANSCODE TOGGLE ===== */
.transcode-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 1.25rem;
    padding: 12px 20px;
    background: rgba(30, 30, 30, 0.6);
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}

.transcode-toggle:hover {
    background: rgba(40, 40, 40, 0.8);
}

.transcode-toggle input[type="checkbox"] {
    display: none;
}

.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    background: rgba(80, 80, 80, 0.5);
    border-radius: 24px;
    transition: all 0.3s ease;
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: all 0.3s ease;
}

.transcode-toggle input:checked+.toggle-switch {
    background: var(--primary);
    box-shadow: 0 0 20px rgba(229, 9, 20, 0.4);
}

.transcode-toggle input:checked+.toggle-switch::after {
    transform: translateX(20px);
    background: white;
}

.toggle-label {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
}

.toggle-label svg {
    width: 16px;
    height: 16px;
}

.transcode-toggle:hover .toggle-label {
    color: white;
}

/* ===== TOGGLES ROW (Force Transcode + Save to Cloud) ===== */
.toggles-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 1.25rem;
    flex-wrap: wrap;
}

.toggles-row .transcode-toggle {
    margin: 0;
}

/* Cloud Upload Warning */
.cloud-warning {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 0.75rem;
    font-size: 0.8rem;
    color: rgba(245, 158, 11, 0.85);
    text-align: center;
}

.cloud-warning svg {
    flex-shrink: 0;
    color: rgba(245, 158, 11, 0.85);
}

/* ===== FEATURED SECTION (Cinema Welcome) ===== */
.featured-section {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 100px 1.5rem 3rem;
    position: relative;
    overflow: hidden;
    scroll-snap-align: start;
    background:
        linear-gradient(180deg,
            rgba(10, 10, 10, 0.3) 0%,
            rgba(10, 10, 10, 0.6) 30%,
            rgba(10, 10, 10, 0.95) 100%),
        radial-gradient(ellipse at center top,
            rgba(229, 9, 20, 0.15) 0%,
            transparent 60%),
        linear-gradient(135deg,
            #0a0a0a 0%,
            #1a1a1a 25%,
            #0d0d0d 50%,
            #1a1a1a 75%,
            #0a0a0a 100%);
    background-size: 100% 100%, 100% 100%, 400% 400%;
    animation: cinemaGradient 15s ease infinite;
}

@keyframes cinemaGradient {

    0%,
    100% {
        background-position: 0% 50%, 0% 0%, 0% 50%;
    }

    50% {
        background-position: 0% 50%, 0% 0%, 100% 50%;
    }
}

/* Cinema Spotlight Effects */
.featured-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    height: 60%;
    background: radial-gradient(ellipse 80% 50% at 50% 0%,
            rgba(229, 9, 20, 0.08) 0%,
            transparent 70%);
    pointer-events: none;
}

.featured-section::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 200px;
    background: linear-gradient(to top, var(--bg-dark) 0%, transparent 100%);
    pointer-events: none;
}

/* Featured Content */
.featured-content {
    position: relative;
    z-index: 1;
    max-width: 900px;
}

.featured-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(229, 9, 20, 0.15);
    border: 1px solid rgba(229, 9, 20, 0.3);
    border-radius: 50px;
    font-size: 0.85rem;
    color: var(--primary);
    margin-bottom: 2rem;
    animation: pulseGlow 3s ease-in-out infinite;
}

.featured-heading {
    font-family: 'Inter', sans-serif;
    font-size: clamp(2.5rem, 8vw, 5rem);
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -2px;
    margin-bottom: 1rem;
}

.featured-heading .static-text {
    display: block;
    background: linear-gradient(135deg, #ffffff 0%, rgba(255, 255, 255, 0.9) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Typing Animation Container */
.typing-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80px;
    font-size: clamp(1.5rem, 5vw, 3rem);
    font-weight: 600;
    color: var(--text-muted);
}

.typing-text {
    display: inline-block;
    position: relative;
}

.typing-cursor {
    display: inline-block;
    width: 3px;
    height: 1em;
    background: var(--primary);
    margin-left: 4px;
    animation: cursorBlink 1s step-end infinite;
    vertical-align: text-bottom;
}

@keyframes cursorBlink {

    0%,
    50% {
        opacity: 1;
    }

    51%,
    100% {
        opacity: 0;
    }
}

.featured-description {
    font-size: 1.1rem;
    color: var(--text-muted);
    max-width: 600px;
    margin: 1.5rem auto 2.5rem;
    line-height: 1.6;
}

/* Featured CTA Buttons */
.featured-cta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
}

.cta-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 1rem 2rem;
    background: var(--gradient-red);
    border: none;
    border-radius: 50px;
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-glow);
    transition: all 0.3s ease;
}

.cta-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 0 60px -10px rgba(229, 9, 20, 0.6);
}

.cta-secondary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 1rem 2rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50px;
    color: white;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.cta-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.cta-primary svg,
.cta-secondary svg {
    width: 20px;
    height: 20px;
}

/* ===== THEATER SECTION (Below Video Player) ===== */
.theater-section {
    position: relative;
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 4rem 1.5rem;
    overflow: hidden;
    scroll-snap-align: start;
    scroll-snap-stop: always;
}

.theater-background {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        linear-gradient(180deg,
            var(--bg-dark) 0%,
            rgba(10, 10, 10, 0.7) 20%,
            rgba(20, 15, 15, 0.8) 50%,
            rgba(10, 10, 10, 0.9) 80%,
            var(--bg-dark) 100%),
        radial-gradient(ellipse 120% 60% at 50% 30%,
            rgba(139, 69, 19, 0.25) 0%,
            rgba(60, 30, 10, 0.15) 40%,
            transparent 70%),
        linear-gradient(135deg,
            #1a0a0a 0%,
            #2a1515 30%,
            #1a0a0a 60%,
            #2a1515 100%);
    z-index: 0;
}

/* Theater Spotlights */
.theater-section::before {
    content: '';
    position: absolute;
    top: -50%;
    left: 20%;
    width: 30%;
    height: 150%;
    background: linear-gradient(to bottom,
            transparent 0%,
            rgba(255, 200, 100, 0.03) 40%,
            rgba(255, 200, 100, 0.02) 60%,
            transparent 100%);
    transform: skewX(-15deg);
    pointer-events: none;
    z-index: 1;
}

.theater-section::after {
    content: '';
    position: absolute;
    top: -50%;
    right: 20%;
    width: 30%;
    height: 150%;
    background: linear-gradient(to bottom,
            transparent 0%,
            rgba(255, 200, 100, 0.03) 40%,
            rgba(255, 200, 100, 0.02) 60%,
            transparent 100%);
    transform: skewX(15deg);
    pointer-events: none;
    z-index: 1;
}

.theater-content {
    position: relative;
    z-index: 2;
    max-width: 1200px;
    width: 100%;
    padding: 0 2rem;
}

.theater-heading {
    font-family: 'Inter', sans-serif;
    font-size: clamp(46px, 10vw, 107px);
    font-weight: 700;
    line-height: 1.05;
    letter-spacing: -2px;
    margin-bottom: 2rem;
    color: white;
    min-height: 2.2em;
}

/* Multi-line typing animation styles */
.typing-line {
    display: block;
    min-height: 1.1em;
    background: linear-gradient(135deg, #ffffff 0%, rgba(255, 255, 255, 0.9) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.typing-line.accent {
    color: var(--primary);
    background: linear-gradient(135deg, var(--primary) 0%, #ff4d4d 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Cursor Attached to Typing Line */
.typing-line.active-typing::after {
    content: '';
    display: inline-block;
    width: 3px;
    height: 0.9em;
    background: var(--primary);
    margin-left: 6px;
    animation: cursorBlink 1s step-end infinite;
    vertical-align: baseline;

    /* Reset text clip properties to ensure cursor is visible */
    -webkit-text-fill-color: initial;
    -webkit-background-clip: border-box;
    background-clip: border-box;
}

.theater-description {
    font-size: clamp(1rem, 2vw, 1.25rem);
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.6;
}

/* ===== CACHED VIDEOS SECTION ===== */
.cached-videos-section {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 4rem 1.5rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    scroll-snap-align: start;
    scroll-snap-stop: always;
}

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

.section-title {
    font-family: 'Inter', sans-serif;
    font-size: 1.5rem;
    font-weight: 600;
    color: white;
    display: flex;
    align-items: center;
    gap: 12px;
}

.section-title svg {
    width: 24px;
    height: 24px;
    color: var(--primary);
}

.section-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Centered Header for Library Section */
.section-header-centered {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    margin-bottom: 3rem;
    gap: 0.75rem;
}

.section-title-large {
    font-family: 'Inter', sans-serif;
    font-size: clamp(2rem, 4vw, 3rem);
    font-weight: 700;
    color: white;
    display: flex;
    align-items: center;
    gap: 16px;
    letter-spacing: -0.5px;
}

.section-title-large svg {
    width: 32px;
    height: 32px;
    color: var(--primary);
    fill: var(--primary);
}

.section-subtitle-muted {
    color: var(--text-muted);
    font-size: 1rem;
    margin: 0;
}

.cached-videos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.cached-video-card {
    position: relative;
    background: rgba(30, 30, 30, 0.6);
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.cached-video-card:hover {
    transform: translateY(-5px);
    border-color: rgba(229, 9, 20, 0.3);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.video-thumbnail {
    position: relative;
    aspect-ratio: 16/9;
    background: linear-gradient(135deg, #1a1a1a 0%, #2a2a2a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-thumbnail svg {
    width: 48px;
    height: 48px;
    color: var(--text-muted);
    opacity: 0.5;
}

.video-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-duration {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.8);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    color: white;
    font-weight: 500;
}

.cached-video-card .card-content {
    padding: 16px;
}

.cached-video-card .card-title {
    font-size: 1rem;
    font-weight: 600;
    color: white;
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cached-video-card .card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.cached-video-card .card-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Play Overlay */
.play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.cached-video-card:hover .play-overlay {
    opacity: 1;
}

.play-circle {
    width: 56px;
    height: 56px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(229, 9, 20, 0.4);
    transform: scale(0.8);
    transition: transform 0.3s ease;
}

.cached-video-card:hover .play-circle {
    transform: scale(1);
}

.play-circle svg {
    width: 24px;
    height: 24px;
    color: white;
    margin-left: 3px;
}

/* Empty State */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
    opacity: 0.3;
}

.empty-state h3 {
    font-size: 1.25rem;
    color: white;
    margin-bottom: 0.5rem;
}

/* ===== BROWSE OVERLAY SEARCH BAR ===== */
.browse-search-container {
    padding: 20px 24px;
    background: rgba(20, 20, 20, 0.95);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: sticky;
    top: 0;
    z-index: 10;
}

.browse-search-wrapper {
    position: relative;
    max-width: 500px;
    margin: 0 auto;
}

.browse-search-wrapper svg {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--text-muted);
    pointer-events: none;
}

.browse-search-input {
    width: 100%;
    padding: 14px 16px 14px 60px !important;
    background: rgba(40, 40, 40, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: white;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.browse-search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(229, 9, 20, 0.1);
}

.browse-search-input::placeholder {
    color: rgba(156, 163, 175, 0.6);
}

/* Filter Tags Removed */




.hero-section,
.main-content,
.theater-section,
.cached-videos-section {
    scroll-snap-align: start;
    scroll-snap-stop: always;
}

/* Explore Videos Indicator */
.explore-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-top: 3rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    cursor: pointer;
    transition: color 0.3s ease;
}

.explore-indicator:hover {
    color: white;
}

.explore-indicator svg {
    width: 20px;
    height: 20px;
    animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(5px);
    }
}

/* ===== MAIN CONTENT CONTAINER ===== */
.main-content {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 0;
    /* min-height: 100vh;  <-- Removed to fix mobile spacing. Added back in desktop media query. */
    scroll-snap-align: start;
    scroll-snap-stop: always;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Hide old glass-container header */
.glass-container>header {
    display: none;
}

/* Hide old input-group */
.glass-container>.input-group {
    display: none;
}

/* Hide old settings-row with transcode */
.glass-container>.settings-row {
    display: none;
}

/* Mobile Responsive Navbar */
@media (max-width: 768px) {
    .streamhub-nav {
        padding: 0 1rem;
        height: 56px;
    }

    .nav-links {
        display: none;
    }

    .nav-title {
        font-size: 1.25rem;
    }

    .hero-section {
        min-height: 70vh;
        padding: 80px 1rem 1.5rem;
    }

    .hero-heading {
        letter-spacing: -1px;
    }

    .hero-description {
        font-size: 1rem;
    }

    .url-input-card {
        flex-direction: column;
        padding: 10px;
    }

    .url-input {
        /* Increased right padding (48px) to prevent text overlapping clear button */
        padding: 0.875rem 48px 0.875rem 44px;
    }

    .play-btn-gradient {
        width: 100%;
        justify-content: center;
        padding: 0.875rem;
    }

    .demo-links {
        flex-wrap: wrap;
    }
}

/* 
   ===== Z-INDEX SYSTEM =====
   0-49:    Base Content (Video, Poster, standard UI)
   50-99:   Floating Controls (Mobile Top Controls, Audio Bar)
   100-199: Menus & Dropdowns (Settings, Context Menus)
   2000+:   Full Screen Modals (Library Overlay)
*/

/* ===== MOVIE TITLE (Center of Controls Bar) ===== */
.controls-center {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    min-width: 0;
    /* Allow shrinking */
}

.movie-title {
    font-size: 0.95rem;
    color: #ffffff;
    font-weight: 500;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
    opacity: 0.9;
}

/* Fix Audio Slide-Down Notification Bar */
.audio-fallback-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: #ff9800;
    color: white;
    padding: 10px 15px;
    padding: 10px 15px;
    z-index: 60;
    /* Layer 60: Audio Bar (Above Controls 50, Below Menus 100) */
    transform: translateY(-100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.audio-fallback-bar.show {
    transform: translateY(0);
}

.fallback-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

/* ===== MOBILE TOP CONTROLS (YouTube Style) ===== */
.mobile-top-controls {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: none;
    /* Hidden on desktop, shown via media query */
    justify-content: flex-end;
    align-items: center;
    padding: 12px 16px;
    gap: 8px;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.8) 0%, transparent 100%);
    z-index: 50;
    /* Layer 50: Mobile Controls (Above Content 0-49, Below Menus 100) */
    /* Ensure it's above everything else but below menus */
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

/* Show top controls when user is active or video is paused */
.video-wrapper.user-active .mobile-top-controls,
.video-wrapper.is-paused .mobile-top-controls {
    opacity: 1;
    pointer-events: auto;
}

/* Mobile Top Button Styling - YouTube Style (ICON ONLY, NO BACKGROUND) */
.mobile-top-btn {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
}

.mobile-top-btn:hover {
    transform: none !important;
    box-shadow: none !important;
}

.mobile-top-btn:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.1) !important;
    /* Subtle touch feedback */
    border-radius: 50%;
}

.mobile-top-btn svg {
    width: 22px;
    height: 22px;
    fill: #ffffff !important;
    display: block;
    /* Clean, hard shadow for max visibility */
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.8));
    pointer-events: none;
}

/* ===== MOBILE PORTRAIT YOUTUBE-STYLE OVERRIDES (xsmall-width-mode) ===== */
@media screen and (max-width: 480px) and (orientation: portrait) {
    /* ===== FULL-WIDTH EDGE-TO-EDGE PLAYER (YouTube Style) ===== */

    /* Remove container padding around video player for edge-to-edge */
    .glass-container {
        padding-left: 0;
        padding-right: 0;
    }

    /* Video wrapper - YouTube style: no borders, no radius, full width */
    .video-wrapper {
        border-radius: 0 !important;
        border: none !important;
        box-shadow: none !important;
        margin: 0 !important;
        width: 100vw !important;
        margin-left: calc(-1rem) !important;
        /* Offset container's remaining padding */
    }

    /* Restore padding for non-video elements */
    .glass-container>*:not(.video-wrapper) {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    /* ===== TOP CONTROLS (YouTube Style) ===== */
    .mobile-top-controls {
        padding: 8px 12px;
        gap: 4px;
    }

    .mobile-top-btn {
        width: 32px;
        height: 32px;
    }

    .mobile-top-btn svg {
        width: 18px;
        height: 18px;
    }

    /* ===== SEEK BAR & BOTTOM CONTROLS (YouTube Style) ===== */

    /* YouTube-style seek bar - edge-to-edge */
    .progress-container {
        margin-bottom: 0;
        /* Reduced from 8px to bring it closer to buttons */
        border-radius: 0;
    }

    /* YouTube small-mode bottom controls height: 36px */
    .controls-main {
        height: 36px;
        min-height: 36px;
    }

    /* YouTube small-mode button sizing: 36px */
    .control-btn {
        width: 36px;
        height: 36px;
        padding: 6px;
        font-size: 1.2rem;
    }

    /* Player controls area - edge-to-edge progress bar */
    .player-controls-area {
        padding: 0 0 10px;
        gap: 4px;
    }

    /* Add slight padding only to controls row, not progress bar */
    .controls-main {
        padding: 0 12px;
        height: 36px;
        min-height: 36px;
    }

    /* ===== AUDIO FALLBACK BAR (Compact Mobile) ===== */
    .audio-fallback-bar {
        padding: 8px 12px;
        /* reduced padding */
    }

    .fallback-message {
        font-size: 0.8rem;
        gap: 6px;
    }

    .fallback-message ion-icon {
        font-size: 1.1rem;
    }

    .fix-audio-btn {
        padding: 5px 10px;
        font-size: 0.8rem;
    }

    .close-bar-btn ion-icon {
        font-size: 1.2rem;
    }
}


.fallback-message {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 500;
}

.fallback-message ion-icon {
    font-size: 1.2rem;
}

.fallback-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.fix-audio-btn {
    background: white;
    color: #ff6f00;
    border: none;
    padding: 6px 14px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.fix-audio-btn:hover {
    background: white;
    transform: none;
}

.close-bar-btn {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-bar-btn:hover {
    color: white;
    transform: none;
}

.close-bar-btn ion-icon {
    font-size: 1.3rem;
}

/* Hide title on very small screens? No, user wants it checking center. */
@media (width <=600px) {
    .controls-center {
        /* Show it */
        display: flex;
        justify-content: center;
        overflow: hidden;
    }

    .movie-title {
        /* Smaller font */
        font-size: 0.8rem;

        /* Limit width */
        max-width: 150px;
    }
}

/* ===== TV MODE STYLES (Remove Blur/Glassmorphism) ===== */
body.tv-mode .glass-container {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(20, 20, 20, 0.95);
    box-shadow: none;
}

body.tv-mode .settings-menu {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(20, 20, 20, 0.98);
}

body.tv-mode .center-btn {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(0, 0, 0, 0.7);
}

/* ===== END TV MODE ===== */

/* ===== GLOBAL FOCUS RESET (All Devices) ===== */
/* Remove focus outline on click/touch for ALL interactive elements */
button:focus,
select:focus,
input:focus,
a:focus,
[tabindex]:focus {
    outline: none;
    box-shadow: none;
}

/* Restore focus ring ONLY for keyboard navigation (accessibility) */
button:focus-visible,
select:focus-visible,
input:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ===== END GLOBAL FOCUS RESET ===== */

/* ... existing styles ... */

/* Seek Feedback Overlay */
.seek-feedback {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    /* Default to center if no side class (though we'll always use one) */
    left: 50%;
    transform: translate(-50%, -50%);
    /* This overrides the above transform */

    background: rgba(0, 0, 0, 0.7);
    padding: 15px 25px;
    border-radius: 30px;
    color: white;
    font-size: 1.2rem;
    font-weight: 600;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 10px;
}

.seek-feedback.active {
    opacity: 1;
}

.seek-feedback.seek-left {
    left: 15%;
    right: auto;
    transform: translateY(-50%);
}

.seek-feedback.seek-right {
    right: 15%;
    left: auto;
    transform: translateY(-50%);
}



.control-btn svg {
    width: 24px;
    height: 24px;
}

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

body {
    font-family: 'Inter', 'Outfit', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overscroll-behavior-y: none;
    /* Prevent pull-to-refresh effects */
}

body.no-scroll {
    overflow: hidden !important;
    touch-action: none;
    position: fixed;
    width: 100%;
}


/* Main Container */
.glass-container {
    width: 100%;
    max-width: 1400px;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: none;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 0;
}

header {
    text-align: center;
}

header h1 {
    font-size: 2.5rem;
    background: linear-gradient(135deg, #fff, #94a3b8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 600;
}

header p {
    color: var(--text-muted);
    font-size: 0.9rem;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* Input Section */
.input-group {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

input[type="text"] {
    flex: 1;
    min-width: 200px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    padding: 1rem 1.5rem;
    border-radius: 12px;
    color: white;
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.3s ease;
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.3);
}

button {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border: none;
    padding: 1rem 2rem;
    border-radius: 12px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: transform 0.2s, box-shadow 0.2s;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

button:active {
    transform: translateY(0);
}

/* TV Focus State */
/* TV Focus State - RED Active Color */
.user-focus {
    outline: 2px solid #f00;
    /* Red Outline */
    outline-offset: 2px;
    transform: scale(1.1);
    background-color: rgba(255, 0, 0, 0.2);
    /* Red tint */
}

/* Override for Seek Bar - No external outline, handled by internal parts */
.progress-container.user-focus {
    outline: none;
    background-color: transparent;
    transform: none;
}

/* Video Player */
.video-wrapper {
    position: relative;
    width: 100%;
    max-width: 1200px;
    background: #000;
    aspect-ratio: 16 / 9;
    border-radius: 16px;
    overflow: hidden;
    /* box-shadow: 0 25px 80px rgba(0, 0, 0, 0.6); */
    box-shadow: none !important;
    border: none;
    /* YOUTUBE-STYLE: Allow vertical page scrolling over video player */
    /* Gestures (swipe-to-exit-fullscreen) are handled in JS only when in fullscreen */
    touch-action: pan-y;
}

/* ===== SOCIAL MEDIA EMBED CONTAINER ===== */
.embed-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 10;
    border-radius: 16px;
    overflow: hidden;
}

.embed-container.active {
    display: block !important;
}

.embed-player {
    width: 100%;
    height: 100%;
}

.embed-player iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.embed-badge {
    position: absolute;
    top: 16px;
    left: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    border-radius: 50px;
    z-index: 15;
    font-size: 0.85rem;
    font-weight: 500;
    color: white;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.embed-container:hover .embed-badge {
    opacity: 1;
}

.badge-icon {
    font-size: 1rem;
}

.embed-close-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 15;
    opacity: 0;
    transition: all 0.3s ease;
}

.embed-container:hover .embed-close-btn {
    opacity: 1;
}

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

/* Embed Loading State */
.embed-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 16px;
    color: rgba(255, 255, 255, 0.7);
}

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

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

.embed-error {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #ff6b6b;
    font-size: 1rem;
}

video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    outline: none !important;
    border: none !important;
}

/* Zoom to Fill State (Mobile Pinch Gesture) */
video.video-zoomed {
    object-fit: cover;
}

video:focus,
.video-wrapper:focus {
    outline: none !important;
    border: none !important;
    box-shadow: none !important;
}

/* Custom Player Controls (Bottom Bar) */
.player-controls-area {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, transparent 100%);
    padding: 20px 20px 25px;
    /* Extra bottom padding for breathing room */
    opacity: 0;
    transition: opacity 0.3s;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 20;
    pointer-events: none;
    /* Disable clicks when hidden */
}

/* Show when active OR paused OR hovering controls OR MENU OPEN */
.video-wrapper.user-active .player-controls-area,
.video-wrapper.is-paused .player-controls-area,
.video-wrapper.menu-open .player-controls-area {
    opacity: 1;
    pointer-events: auto;
}

@media (hover: hover) {
    .video-wrapper .player-controls-area:hover {
        opacity: 1;
        pointer-events: auto;
    }
}

/* Hide cursor when inactive and playing */
.video-wrapper:not(.user-active):not(.is-paused) {
    cursor: none;
}

/* Progress Bar - YouTube Style (Proximity Hover) */
/* Progress Bar - YouTube Style (Proximity Hover) */
.progress-container {
    width: auto;
    /* Allow margin to define width */
    margin: 0 12px;
    /* Gap from edges */
    height: 16px;
    /* Increased hit area (YouTube uses ~15-20px) */
    background: transparent;
    /* Invisible hit area */
    cursor: pointer;
    position: relative;
    /* transition: none; Container height shouldn't animate, visual parts should */
    display: flex;
    /* Helps vertical centering if needed, but absolute positioning is safer */
    align-items: center;
    /* Center children vertically */
    touch-action: none;
    /* Prevent scrolling while dragging */
}

/* Visual Background Rail */
/* Visual Background Rail */
.progress-container::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 3px;
    /* Default visual height */
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-50%);
    border-radius: 3px;
    transition: height 0.1s ease, transform 0.1s ease;
    z-index: 0;
}



/* Hover Effect: Expand Visuals */
.progress-container:hover::before,
.progress-container.seek-focused::before {
    height: 5px;
    /* Expand visual rail */
}

/* Filled Progress */
.progress-filled {
    height: 3px;
    /* Default visual height */
    width: 0%;
    background: var(--primary);
    border-radius: 3px;
    position: absolute;
    /* Changed to absolute for precise centering */
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    z-index: 2;
    transition: height 0.1s ease, transform 0.1s ease;
    pointer-events: none;
    /* Let clicks pass through to container */
}

/* Expand Filled on Hover */
.progress-container:hover .progress-filled {
    height: 5px;
}

/* Focus State: Thicker Bar, No Background Rail */
.progress-container.seek-focused .progress-filled {
    height: 8px;
    /* Thicker on focus */
}

/* Buffer Progress */
.progress-buffer {
    height: 3px;
    /* Default visual height */
    width: 0%;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 3px;
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    z-index: 1;
    transition: width 0.2s, height 0.1s ease, transform 0.1s ease;
    pointer-events: none;
}

/* Expand Buffer on Hover or Focus */
.progress-container:hover .progress-buffer,
.progress-container.seek-focused .progress-buffer {
    height: 5px;
}

/* ===== SCRUBBER DOT (YouTube Style) ===== */
.progress-scrubber {
    position: absolute;
    right: 0;
    /* Center dot exactly on the end of the filled bar */
    top: 50%;
    transform: translate(50%, -50%) scale(0);
    /* Hidden by default */
    width: 13px;
    height: 13px;
    background: var(--primary);
    border-radius: 50%;
    z-index: 10;
    transition: transform 0.1s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
}

/* Show scrubber on hover or focus */
.progress-container:hover .progress-scrubber,
.progress-container.seek-focused .progress-scrubber {
    transform: translate(50%, -50%) scale(1);
    /* Restored original scrubber size */
}

/* ===== MOBILE TOUCH DRAGGING STATE ===== */
/* When actively dragging on mobile, show slightly enlarged scrubber */
.progress-container.touch-dragging .progress-scrubber {
    transform: translate(50%, -50%) scale(1.15) !important;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
    transition: none;
}

/* Show scrubber during touch (even without hover) */
.progress-container.touch-active .progress-scrubber {
    transform: translate(50%, -50%) scale(1);
}

/* ===== HOVER TIMESTAMP TOOLTIP ===== */
.progress-tooltip {
    position: absolute;
    bottom: 20px;
    /* Above the progress bar */
    left: 0;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.85);
    color: #ffffff;
    font-size: 0.8rem;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 50;
}

/* Show tooltip on hover */
.progress-container:hover .progress-tooltip {
    opacity: 1;
}

/* Controls Layout */
.controls-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.controls-left,
.controls-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Buttons & Selects */
.control-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 8px;
    /* Slightly larger hit area */
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, color 0.2s;
    width: auto;
    height: auto;
    box-shadow: none;
    position: relative;
    /* For menu positioning */
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: none;
}

/* Custom Icon Images */
.control-icon-img {
    width: 24px;
    height: 24px;
    object-fit: contain;
    filter: invert(1);
    /* Make black icons white if they are black. Adjust if needed */
}

/* Custom Control Wrapper (for relative menu positioning) */
.custom-control-wrapper {
    position: relative;
    display: inline-block;
}

/* Settings Menu (Glassmorphism) */
.settings-menu {
    position: absolute;
    bottom: 95px;
    /* Fixed above controls and seek bar */
    right: 20px;
    /* Fixed right align */
    width: 280px;
    /* Wider default */
    max-height: 300px;
    overflow-y: auto;
    background: #181818;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    padding: 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    z-index: 100;
    display: none;
    /* Hidden by default */
    transform-origin: bottom right;
    animation: menuFadeIn 0.2s ease;
    overscroll-behavior: contain;
    /* Prevent background scroll when menu ends */
}



/* ===== MOBILE BOTTOM SHEET MENU (YouTube Style) ===== */
@media screen and (max-width: 768px) {
    .settings-menu {
        position: fixed;
        bottom: 12px;
        left: 8px;
        right: 8px;
        width: auto;
        box-sizing: border-box;
        max-height: 70vh;
        border-radius: 12px;
        background: #212121;
        border: none;
        box-shadow: 0 -2px 20px rgba(0, 0, 0, 0.5);
        z-index: 9000;
        padding-bottom: env(safe-area-inset-bottom, 12px);
        transform: translateY(calc(100% + 20px));
        opacity: 0;
        pointer-events: none;
        transition: transform 0.3s cubic-bezier(0.2, 0, 0, 1), opacity 0.2s ease;
        overflow-y: auto;
    }

    .settings-menu.active {
        transform: translateY(0) !important;
        opacity: 1 !important;
        pointer-events: auto !important;
        display: block !important;
    }
}

.settings-menu.active {
    display: block;
}

/* Landscape Mobile Fix (Menu Overflow & Play Button) */
/* Combine max-width check OR pointer check to catch high-res phones */
@media screen and (max-width: 900px) and (orientation: landscape),
screen and (pointer: coarse) and (orientation: landscape) {


    /* Enable Center Play Button only in Mobile Landscape */
    .center-controls {
        display: flex !important;
        opacity: 0;
        transition: opacity 0.3s;
    }

    /* Force visibility when active OR paused */
    .video-wrapper.user-active .center-controls,
    .video-wrapper.is-paused .center-controls {
        opacity: 1 !important;
        pointer-events: auto !important;
        z-index: 50;
        /* Ensure it stays on top */
    }

    .settings-menu,
    .settings-menu.settings-panel {
        max-height: calc(100vh - 80px) !important;
        /* Ensure it fits in viewport */
        overflow-y: auto !important;
        /* Enable scrolling */
        bottom: 70px;
        width: 260px !important;
        right: 20px !important;
        left: auto !important;
        transform: none !important;
        border-radius: 12px;
        display: none;
    }

    .settings-menu.active {
        display: flex;
        /* Flex only when active */
        flex-direction: column;
    }

    /* Fix Header Visibility */
    .menu-header,
    .section-header {
        flex-shrink: 0;
        /* Never shrink or scroll */
        padding: 10px 15px;
        background: rgba(0, 0, 0, 0.5);
        /* contrast */
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    /* Scroll ONLY the content, not the header */
    .settings-section-panel,
    .settings-main {
        overflow-y: auto;
        flex-grow: 1;
        max-height: 60vh;
        /* Allow generous scrolling within limits */
        padding-bottom: 10px;
    }

    /* Specific fix for Speed Options Grid/List */
    .speed-preset-options {
        padding: 5px 0;
    }
}

/* ===== SETTINGS PANEL (Wider, Multi-Section) ===== */
.settings-menu.settings-panel {
    width: 280px;
    max-height: 400px;
}

.settings-sections {
    padding: 10px;
}

.settings-section {
    margin-bottom: 15px;
}

.settings-section:last-child {
    margin-bottom: 5px;
}

.section-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    padding-bottom: 5px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Netflix-Style Settings Menu */
.settings-main {
    display: none;
    /* Hidden by default, shown via .active */
}

.settings-main.active {
    display: block;
}

/* =========================================
   Ambient Mode (OLED Burn-in Protection) 
   ========================================= */
.video-container.ambient-mode::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    /* Dim the screen heavily */
    z-index: 5;
    /* Above video, below controls (which will be hidden anyway) */
    pointer-events: none;
    transition: background 1s ease;
    /* Fade in slowly */
}

.settings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

/* Hide Tick Mark in Main Settings as requested (target any checkmark) */
#settingsMain ion-icon[name="checkmark"],
#settingsMain .speed-check ion-icon {
    display: none !important;
}

/* Let the CSS ::before handle the checkmarks for all submenus to avoid double ticks */
.speed-check ion-icon,
.menu-item ion-icon[name="checkmark"] {
    display: none !important;
}

/* Except for speed-preset-items which rely heavily on speed-check structure */
.speed-preset-item.active .speed-check ion-icon {
    display: block !important;
}

/* Suppress the ::after pseudo-element checkmark for speed-preset-items
   (they use ion-icon via .speed-check instead, prevents double tick) */
.speed-preset-item.active::after {
    display: none !important;
}

.settings-row:hover {
    background: rgba(255, 255, 255, 0.05);
}

.row-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.row-left ion-icon {
    font-size: 1.2rem;
    color: var(--text-muted);
}

.row-left span {
    font-size: 0.9rem;
    color: inherit;
    /* Inherit color from parent (.menu-item.active has red) */
}

/* =========================================
   TV Remote Navigation (Focus Styles) 
   ========================================= */
/* YouTube Style Focus: Solid white outline or background */
.control-btn.user-focus,
.back-btn.user-focus {
    /* For buttons: A slight background tint and scale */
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    /* Make square buttons look good, or keep current */
    outline: none;
    transform: scale(1.1);
}

.menu-item.user-focus,
.speed-preset-item.user-focus,
.settings-row.user-focus {
    /* For menu items: White outline highlight (distinct from .active red tint) */
    background: rgba(255, 255, 255, 0.15) !important;
    outline: 2px solid rgba(255, 255, 255, 0.8) !important;
    outline-offset: -2px !important;
    transform: none !important;
}

/* Special Seek Focus - Match YouTube hover expand */
.progress-container.seek-focused {
    cursor: default;
}

.progress-container.seek-focused .progress-scrubber {
    opacity: 1;
    transform: translate(50%, -50%) scale(1);
    /* Ensure it stays scale(1) even when focused, like hover */
}

/* ========================================= */

.row-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.row-right span {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.row-right ion-icon {
    font-size: 1rem;
    color: var(--text-muted);
}

/* Settings Section Panels (Hidden by default) */
.settings-section-panel {
    display: none;
    padding: 0 15px 15px;
}

.settings-section-panel.active {
    display: block;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: center;
    /* Center the title */
    position: relative;
    /* Enable absolute positioning for back button */
    gap: 10px;
    padding: 10px 50px;
    /* Side padding to make room for back button */
    margin-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.section-header span {
    font-size: 0.95rem;
    font-weight: 600;
    color: #fff;
}

.back-btn {
    position: absolute;
    /* Position absolutely to left */
    left: 10px;
    right: auto;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    outline: none;
    box-shadow: none;
    color: #fff;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: auto;
}

.back-btn:hover {
    background: transparent;
    transform: translateY(-50%);
    box-shadow: none;
}

.back-btn ion-icon {
    font-size: 1.2rem;
}

/* Fix Audio Footer (Always Visible) */
.fix-audio-footer {
    padding: 0 15px 15px;
}

.fix-audio-separator {
    height: 1px;
    background: rgba(255, 255, 255, 0.15);
    margin-bottom: 12px;
}

.fix-audio-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.fix-audio-settings-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px 15px;
    background: rgba(255, 255, 255, 0.05);
    border: none;
    outline: none;
    box-shadow: none;
    border-radius: 6px;
    color: #fff;
    font-size: 0.9rem;
    cursor: pointer;
}

.fix-audio-settings-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    transform: none;
    box-shadow: none;
}

.fix-audio-settings-btn ion-icon {
    font-size: 1.1rem;
}

.fix-audio-hint {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: center;
}

/* Playback Speed Options Grid */
.speed-options {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
}

/* YouTube-Style Speed Slider */
.speed-slider-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 5px;
}

.speed-slider-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 5px;
}

.speed-slider-value {
    font-size: 1.1rem;
    font-weight: 500;
    color: #fff;
    margin-bottom: 10px;
}

.speed-slider {
    width: 100%;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    cursor: pointer;
}

.speed-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    cursor: pointer;
}

.speed-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

/* Speed Preset Options List */
.speed-preset-options {
    display: flex;
    flex-direction: column;
}

.speed-preset-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 15px;
    cursor: pointer;
    font-size: 0.9rem;
    color: #fff;
}

.speed-preset-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.speed-preset-item.active {
    background: rgba(229, 9, 20, 0.2);
    color: var(--primary);
    border-radius: 4px;
    font-weight: 600;
}

.speed-check {
    width: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.speed-check ion-icon {
    font-size: 1rem;
    color: #fff;
}

.speed-item {
    padding: 8px 4px;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-muted);
    border: none;
    outline: none;
    box-shadow: none;
}

.speed-item:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    box-shadow: none;
    transform: none;
}

.speed-item.active {
    background: rgba(229, 9, 20, 0.2);
    color: var(--primary);
    font-weight: 600;
}

/* Setting Rows (Label + Select) */
.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.setting-row:last-child {
    margin-bottom: 0;
}

.setting-row label {
    font-size: 0.85rem;
    color: #fff;
    flex-shrink: 0;
}

.setting-select {
    width: 130px;
    padding: 6px 10px;
    font-size: 0.8rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    color: #fff;
    cursor: pointer;
    transition: all 0.15s ease;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='white' viewBox='0 0 16 16'%3E%3Cpath d='m4.5 6 3.5 4 3.5-4h-7z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 25px;
}

.setting-select:hover {
    background-color: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.25);
}

.setting-select:focus {
    outline: none;
    border-color: var(--primary);
}

.setting-select option {
    background: #1a1a1a;
    color: #fff;
}

@keyframes menuFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.menu-header {
    padding: 10px 15px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
}

.menu-options {
    padding: 5px 0;
}

.menu-item {
    padding: 10px 15px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.menu-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.menu-item.active {
    /* No background tint - only tick + red text indicate selection */
    background: transparent;
    color: var(--primary);
    font-weight: 600;
}

/* Ensure the left side text occupies available space to push checkmark right */
.menu-item .row-left,
.menu-item span:not(.speed-check) {
    flex: 1;
    text-align: left;
}

/* Specific Fix for "CC: Off" which sometimes gets unlarged */
.menu-item[data-value="-1"],
.menu-item[data-value="off"] {
    font-size: 0.95rem !important;
    font-weight: 600 !important;
}

.menu-item.active::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    min-width: 20px;
    margin-left: 12px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'%3E%3Cpath fill='none' stroke='%23e50914' stroke-linecap='round' stroke-linejoin='round' stroke-width='44' d='M416 128L192 384l-96-96'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

/* Hide pseudo checkmark in Main Settings or if we already have a speed-check */
#settingsMain .menu-item.active::after {
    display: none !important;
}

/* If a menu-item uses .row-left, ensure the ::after doesn't break flex */
.menu-item.active .row-left {
    display: flex;
    align-items: center;
}

/* Buffering Spinner */
.buffering-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 1s ease-in-out infinite;
    z-index: 20;
    display: none;
    /* Hidden by default */
    pointer-events: none;
}

.buffering-spinner.active {
    display: block;
}

@keyframes spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

.control-btn:hover {
    color: var(--primary);
    transform: scale(1.1);
    background: transparent;
    box-shadow: none;
}

.control-select {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #f8fafc;
    padding: 5px 10px;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    outline: none;
    transition: all 0.2s;
}

/* Remove focus ring on click/touch, keep for keyboard */
.control-select:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.2);
}

.control-select:focus-visible {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(229, 9, 20, 0.3);
}

.control-btn:focus {
    outline: none;
    box-shadow: none;
}

.control-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.control-select:hover {
    background: rgba(0, 0, 0, 0.8);
    border-color: var(--primary);
}

.control-select option {
    background: #0f172a;
    color: white;
}

/* Volume Slider */
.volume-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* YouTube-Style Center Controls */
.center-controls {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    display: none;
    /* Hidden by default on PC */
    align-items: center;
    justify-content: center;
    z-index: 15;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
}

/* Momentary Feedback Class (Still works for feedback) */
.center-controls.show-feedback {
    display: flex;
    /* Show momentarily for feedback */
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    transform: translate(-50%, -50%) scale(1);
    transition: opacity 0.1s, transform 0.1s;
}

/* REMOVED default .user-active trigger for Desktop */
/* .video-wrapper.user-active .center-controls ... { } */

/* YouTube-Style Center Play/Pause Button (68px like YouTube) */
.center-btn {
    background: rgba(0, 0, 0, 0.5);
    border: none;
    border-radius: 50%;
    width: 68px;
    height: 68px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s ease, background 0.1s ease;
    backdrop-filter: none !important;
    box-shadow: none !important;
    padding: 0;
}

.center-btn:hover {
    background: rgba(0, 0, 0, 0.7);
}

.center-btn svg {
    width: 32px;
    /* YouTube uses ~32px icon inside */
    height: 32px;
    fill: white;
    display: block;
}

/* Fix visual centering for Play icon */
.center-btn svg.center-icon-play {
    margin-left: 3px;
    /* Slight nudge for optical centering */
}

#volumeSlider {
    width: 0;
    overflow: hidden;
    transition: width 0.3s;
    appearance: none;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    cursor: pointer;
}

.volume-container:hover #volumeSlider {
    width: 80px;
}

#volumeSlider::-webkit-slider-thumb {
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
}

.time-display {
    font-size: 0.85rem;
    color: #cbd5e1;
    margin-left: 8px;
    letter-spacing: 0.3px;
    /* min-width prevents layout shift when digit widths vary (replaces tabular-nums which caused compression) */
    min-width: 9ch;
    display: inline-block;
    white-space: nowrap;
}

/* 2x Speed Overlay */
.speed-overlay {
    position: absolute;
    top: 5%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    color: white;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 50;
    /* Ensure above controls overlay (z-index ~20) and mobile menus (~2000) */
    display: flex;
    align-items: center;
    gap: 6px;
}

.speed-overlay.visible {
    opacity: 1;
}

.speed-overlay svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}

/* ===== VOLUME OSD (YouTube-style) ===== */
.volume-osd {
    position: absolute;
    top: 12%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(6px);
    color: white;
    padding: 10px 20px;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.25s ease;
    z-index: 50;
    /* Same tier as .speed-overlay, below modals */
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 180px;
}

.volume-osd.visible {
    opacity: 1;
}

.volume-osd-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.volume-osd-bar-wrap {
    flex: 1;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    overflow: hidden;
}

.volume-osd-bar-fill {
    height: 100%;
    background: white;
    border-radius: 2px;
    transition: width 0.1s ease;
}

.volume-osd-pct {
    font-size: 0.85rem;
    min-width: 36px;
    text-align: right;
    opacity: 0.85;
}

/* Status */
#statusMessage {
    text-align: center;
    font-size: 0.9rem;
    min-height: 1.2rem;
    color: var(--text-muted);
}

@media (max-width: 600px) {
    body {
        padding: 0;
        align-items: flex-start;
    }

    .glass-container {
        padding: 1rem;
        width: 100%;
        max-width: 100%;
        border-radius: 0;
        margin: 0;
        min-height: 100vh;
        /* FIX: Remove backdrop-filter on mobile as it breaks position:fixed for menus */
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        transform: none !important;
        perspective: none !important;
    }

    header h1 {
        font-size: 1.8rem;
    }

    header p {
        font-size: 0.8rem;
    }

    /* Input controls */
    .input-group {
        flex-direction: column;
        gap: 0.8rem;
    }

    input[type="text"] {
        width: 100%;
        font-size: 16px;
        /* Prevents zoom on iOS */
        padding: 0.9rem 1rem;
    }

    button {
        width: 100%;
        padding: 0.9rem 1.5rem;
        font-size: 1rem;
    }

    /* Settings row */
    .settings-row {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 10px !important;
    }





    .control-select {
        font-size: 0.8rem;
        padding: 6px 8px;
        min-height: 36px;
        /* Touch-friendly */
    }

    /* Time display - smaller on mobile */
    .time-display {
        font-size: 0.75rem;
    }

    /* Center play button - YouTube mobile size (48px) */
    .center-btn {
        width: 48px;
        height: 48px;
    }

    .center-btn svg {
        width: 24px;
        height: 24px;
    }

    /* Progress bar - YouTube mobile style (slimmer) */
    .progress-container {
        height: 16px;
        /* Maintain hit area */
        margin-bottom: 4px;
    }

    /* Mobile: Always thin unless dragging */
    .progress-container::before {
        height: 3px;
    }

    .progress-filled,
    .progress-buffer {
        height: 3px;
    }

    /* Expand only on active touch/drag (not just hover since mobile hover is tricky) */
    .progress-container:active::before,
    .progress-container.touch-dragging::before {
        height: 5px;
    }

    .progress-container:active .progress-filled,
    .progress-container.touch-dragging .progress-filled,
    .progress-container:active .progress-buffer,
    .progress-container.touch-dragging .progress-buffer {
        height: 5px;
    }

    /* Volume slider - hide on mobile (use device volume) */
    .volume-container {
        display: none;
    }

    /* Controls layout - YouTube mobile style (closer to bottom edge) */
    .player-controls-area {
        padding: 8px 12px 8px;
        gap: 6px;
    }

    .controls-main {
        flex-wrap: nowrap;
        gap: 8px;
        justify-content: space-between;
        align-items: center;
    }

    .controls-left {
        gap: 4px;
        flex-shrink: 0;
        flex: 0;
    }

    /* 
     * Mobile: Hide audio/subtitle/settings BUTTONS from bottom bar
     * But keep the wrapper/menus visible so menus triggered from top bar still work
     */
    /* 
     * Mobile: Hide audio/subtitle/settings BUTTONS from bottom bar 
     * ONLY when NOT in fullscreen (Portrait Mode)
     */
    .video-wrapper:not(:fullscreen):not(:-webkit-full-screen) .controls-right .custom-control-wrapper>.control-btn {
        display: none !important;
    }

    /* Keep the wrapper positioned but minimal */
    .controls-right .custom-control-wrapper {
        position: static;
        width: 0;
        overflow: visible;
        /* Allow menus to overflow */
    }

    .controls-right {
        gap: 4px;
        flex-shrink: 0;
        flex-wrap: nowrap;
        justify-content: flex-end;
    }

    /* 
     * Show mobile top controls bar on mobile 
     * ONLY when NOT in fullscreen
     */
    .video-wrapper:not(:fullscreen):not(:-webkit-full-screen) .mobile-top-controls {
        display: flex;
    }

    /* Adjust icon sizes for mobile */
    .control-icon-img {
        width: 22px;
        height: 22px;
    }

    .control-btn {
        padding: 8px;
        /* Good touch target */
    }

    /* 
     * ============================================
     * YOUTUBE-STYLE BOTTOM SHEET MENUS FOR MOBILE
     * ============================================
     * Floating card style - detached from edges
     * ONLY applies when NOT in fullscreen
     */
    .video-wrapper:not(:fullscreen):not(:-webkit-full-screen) .settings-menu {
        position: fixed !important;
        top: auto !important;
        bottom: 12px !important;
        left: 8px !important;
        right: 8px !important;
        width: auto !important;
        max-height: 70vh !important;
        min-height: auto;
        background: #212121 !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        border-radius: 12px !important;
        padding: 0 0 env(safe-area-inset-bottom, 12px) 0 !important;
        overflow-y: auto !important;
        z-index: 9000 !important;
        margin: 0 !important;
        box-shadow: 0 -2px 20px rgba(0, 0, 0, 0.5) !important;
        transform: translateY(calc(100% + 20px));
        transition: transform 0.3s cubic-bezier(0.2, 0, 0, 1), opacity 0.2s ease !important;
        opacity: 0;
        pointer-events: none;
    }

    /* Show animation for bottom sheet */
    .video-wrapper:not(:fullscreen):not(:-webkit-full-screen) .settings-menu.active {
        transform: translateY(0) !important;
        opacity: 1 !important;
        pointer-events: auto !important;
        display: block !important;
    }

    /* Handle indicator - now inside the card */
    /* Handle indicator - REMOVED */
    .video-wrapper:not(:fullscreen):not(:-webkit-full-screen) .settings-menu::before {
        display: none !important;
    }

    /* Menu items - compact for mobile */
    .menu-item {
        padding: 12px 16px !important;
        font-size: 0.95rem !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 0 !important;
        border-bottom: none;
        text-align: left !important;
    }

    /* Text label takes full available width, pushes checkmark to right */
    .menu-item>span:not(.speed-check),
    .menu-item>.row-left {
        flex: 1 !important;
        text-align: left !important;
    }

    .menu-item:last-child {
        border-bottom: none;
    }

    .menu-item:hover,
    .menu-item:active {
        background: rgba(255, 255, 255, 0.08) !important;
    }

    .menu-item.active {
        background: transparent !important;
        color: var(--primary) !important;
    }

    /* Fix Mobile Header Alignment - Center Title */
    .video-wrapper:not(:fullscreen):not(:-webkit-full-screen) .section-header,
    .settings-menu .section-header {
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        position: relative !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
        padding: 14px 60px !important;
        margin-bottom: 8px !important;
    }

    /* Position back button absolutely to left - VISIBLE */
    .video-wrapper:not(:fullscreen):not(:-webkit-full-screen) .back-btn,
    .settings-menu .back-btn {
        position: absolute !important;
        left: 16px !important;
        right: auto !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        padding: 8px !important;
        z-index: 10 !important;
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        width: auto !important;
        justify-content: flex-start !important;
    }

    /* Ensure title text is white/clean */
    .video-wrapper:not(:fullscreen):not(:-webkit-full-screen) .section-header span,
    .settings-menu .section-header span {
        font-size: 1rem !important;
        font-weight: 600 !important;
        color: #fff !important;
    }

    /* Bottom sheet overlay - real div managed by JS for click-to-close */
    .mobile-menu-backdrop {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.6);
        z-index: 8999;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s ease;
        visibility: hidden;
    }

    .mobile-menu-backdrop.active {
        opacity: 1;
        pointer-events: auto;
        visibility: visible;
    }

    /* Dropdown selects - more compact on mobile */
    .control-select {
        font-size: 0.75rem;
        padding: 5px 6px;
        min-height: 36px;
        max-width: 120px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Time display - smaller on mobile */
    .time-display {
        font-size: 0.7rem;
        white-space: nowrap;
    }

    /* Mobile subtitle sizing - uses --video-width variable for consistent scaling */
    .custom-subtitle {
        font-size: clamp(0.65rem, calc(var(--video-width, 360px) * 0.038), 1.2rem);
        line-height: 1.3;
        padding: clamp(3px, calc(var(--video-width, 360px) * 0.01), 6px) clamp(6px, calc(var(--video-width, 360px) * 0.025), 12px);
        max-width: 90%;
        bottom: 15px;
    }

    /* When controls visible on mobile */
    .video-wrapper.user-active .custom-subtitle,
    .video-wrapper.is-paused .custom-subtitle {
        bottom: 70px;
    }

    /* Status message */
    #statusMessage {
        font-size: 0.85rem;
    }

    /* Seek feedback - smaller on mobile */
    .seek-feedback {
        font-size: 1rem;
        padding: 10px 18px;
    }

    /* Center controls container */
    .center-controls {
        gap: 20px;
    }

    /* Center play button - HIDDEN in normal mobile view */
    /* Only shows in fullscreen mode (see below) */
    .video-wrapper.user-active .center-controls,
    .video-wrapper.is-paused .center-controls {
        opacity: 0;
        pointer-events: none;
    }

    /* Show center play button when controls are active (Mobile) - Fullscreen View */
    /* Note: Need !important to override base opacity: 0 in fullscreen context */
    .video-wrapper:fullscreen.user-active .center-controls,
    .video-wrapper:fullscreen.is-paused .center-controls {
        opacity: 1 !important;
        pointer-events: auto !important;
        z-index: 25 !important;
        transform: translate(-50%, -50%) scale(1) !important;
    }

    /* WebKit (Safari, iOS) fullscreen */
    .video-wrapper:-webkit-full-screen.user-active .center-controls,
    .video-wrapper:-webkit-full-screen.is-paused .center-controls {
        opacity: 1 !important;
        pointer-events: auto !important;
        z-index: 25 !important;
        transform: translate(-50%, -50%) scale(1) !important;
    }

    /* Mozilla fullscreen */
    .video-wrapper:-moz-full-screen.user-active .center-controls,
    .video-wrapper:-moz-full-screen.is-paused .center-controls {
        opacity: 1 !important;
        pointer-events: auto !important;
        z-index: 25 !important;
        transform: translate(-50%, -50%) scale(1) !important;
    }
}

/* Netflix-Style Custom Subtitle Overlay */
.custom-subtitle {
    position: absolute;
    /* Default: Near bottom when controls are hidden */
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    max-width: 80%;
    text-align: center;
    /* DYNAMIC SIZING: Scales with actual video player width via --video-width JS variable.
       3.5% of the player width, clamped between 0.75rem (tiny player) and 1.8rem (large player). */
    font-size: clamp(0.75rem, calc(var(--video-width, 640px) * 0.035), 1.8rem);
    line-height: 1.4;
    color: #ffffff;
    font-family: 'Outfit', sans-serif;
    text-shadow: 2px 2px 2px rgba(0, 0, 0, 0.9), 0 0 5px rgba(0, 0, 0, 0.7);
    background-color: rgba(0, 0, 0, 0.75);
    padding: clamp(3px, calc(var(--video-width, 640px) * 0.008), 8px) clamp(8px, calc(var(--video-width, 640px) * 0.02), 18px);
    border-radius: 4px;
    z-index: 25;
    pointer-events: none;
    opacity: 0;
    /* Smooth transition for position AND opacity */
    transition: bottom 0.3s ease, opacity 0.15s ease;
}

.custom-subtitle.visible {
    opacity: 1;
}

/* When controls are visible, move subtitle up DYNAMICALLY */
.video-wrapper.user-active .custom-subtitle,
.video-wrapper.is-paused .custom-subtitle {
    /* DESKTOP: Add padding to clearing control gradient */
    bottom: calc(var(--control-area-height, 100px) - 13px);
}

/* MOBILE OVERRIDE: Add gap because mobile controls have 0 top padding */
@media screen and (max-width: 768px) {

    .video-wrapper.user-active .custom-subtitle,
    .video-wrapper.is-paused .custom-subtitle {
        /* Mobile controls are slim (0 padding top), so we MUST add positive margin to clear the seek bar */
        bottom: calc(var(--control-area-height, 60px) + 4px) !important;
    }
}

/* Fullscreen adjustments for custom subtitle */
.video-wrapper:fullscreen .custom-subtitle,
.video-wrapper:-webkit-full-screen .custom-subtitle,
.video-wrapper:-moz-full-screen .custom-subtitle {
    /* In fullscreen, player fills screen so --video-width equals screen width — scale up slightly */
    font-size: clamp(1.1rem, calc(var(--video-width, 1280px) * 0.028), 2.2rem);
    padding: clamp(5px, calc(var(--video-width, 1280px) * 0.006), 10px) clamp(12px, calc(var(--video-width, 1280px) * 0.018), 24px);
    bottom: var(--control-area-height, 100px) !important;
    max-width: 70%;
    line-height: 1.3;
}

/* Legacy override removed to prevent double-gap issue */
/* The dynamic height variable now handles all positioning correctly */

/* =========================================
   YTP SEEK OVERLAY (YouTube-style accumulating seek)
   ========================================= */
.ytp-seek-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 30;
    display: none;
    align-items: center;
    justify-content: center;
}

.ytp-seek-overlay-animation {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.55);
    border-radius: 50px;
    padding: 10px 22px;
    color: #ffffff;
    font-size: clamp(1.1rem, 3vw, 1.6rem);
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    letter-spacing: 0.02em;
    opacity: 0;
    transform: scale(0.88);
    transition: opacity 0.12s ease, transform 0.12s ease;
    white-space: nowrap;
}

.ytp-seek-overlay-animation.show {
    opacity: 1;
    transform: scale(1);
}

.ytp-seek-overlay-animation-forward {
    /* positioned right-of-center */
    position: absolute;
    right: 15%;
    left: auto;
}

.ytp-seek-overlay-animation-back {
    /* positioned left-of-center */
    position: absolute;
    left: 15%;
    right: auto;
}

.ytp-seek-overlay-duration {
    font-size: clamp(1rem, 2.8vw, 1.5rem);
    font-weight: 700;
    color: #ffffff;
    min-width: 3ch;
    text-align: center;
}

.ytp-seek-overlay-arrow-container {
    display: flex;
    align-items: center;
    justify-content: center;
}

.ytp-seek-overlay-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
}

.ytp-seek-overlay-arrow svg {
    width: clamp(20px, 3vw, 32px);
    height: clamp(20px, 3vw, 32px);
    fill: #ffffff;
}

/* Burst ripple effect */
.ytp-seek-burst {
    position: absolute;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    transform: scale(0);
    opacity: 0;
    pointer-events: none;
    top: 50%;
    margin-top: -45px;
    margin-left: -45px;
}

.ytp-seek-burst.active {
    animation: seek-burst 0.5s ease-out forwards;
}

@keyframes seek-burst {
    0% {
        transform: scale(0);
        opacity: 0.6;
    }

    100% {
        transform: scale(2.5);
        opacity: 0;
    }
}

/* Hide native subtitles when using custom overlay */
video::cue {
    visibility: hidden;
    opacity: 0;
}

/* Controls Row */
.controls-row {
    display: flex;
    gap: 0.5rem;
    flex: 1;
}

.track-select {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    padding: 1rem 1rem;
    border-radius: 12px;
    color: white;
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.track-select:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.3);
}

.track-select:focus-visible {
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.3);
}

/* FORCE Back Button Positioning Globally */
.section-header .back-btn {
    position: absolute !important;
    left: 10px !important;
    right: auto !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    width: auto !important;
    z-index: 100 !important;
}

/* Movie Title in Controls */
.movie-title {
    color: #e5e5e5;
    font-size: 0.95rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
    /* Limit width */
    text-align: center;
    opacity: 0.9;
    background: transparent;
    pointer-events: none;
    /* Let clicks pass through */
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Hide on very small screens */
@media (max-width: 500px) {
    .movie-title {
        display: none;
    }
}

/* Movie Poster Image */
.movie-poster-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    position: absolute;
    top: 0;
    left: 0;
}

/* --- NEW MOVIE CARD DESIGN (Netflix Style) --- */

.movies-grid {
    display: grid;
    /* Responsive Grid: Cards roughly 250px-300px wide */
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px 16px;
    /* Row gap 20px, Col gap 16px */
    padding: 10px;
}

.movie-card {
    background: transparent;
    border-radius: 4px;
    /* Minimal rounding */
    cursor: pointer;
    transition: transform 0.2s ease;
    /* Very subtle pop only */
    position: relative;
    overflow: visible;
    /* Allow content to flow */
    /* REMOVED: Box shadows and aggressive scales */
}

.movie-card:hover {
    transform: scale(1.02);
    /* Very slight scale feedback */
    z-index: 2;
}

.movie-poster-placeholder {
    width: 100%;
    aspect-ratio: 16 / 9;
    /* Force 1920x1080 ratio */
    background-color: #202020;
    /* Dark grey placeholder */
    border-radius: 4px;
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Delete Button - Top Right of Poster */
.movie-card .delete-action-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    /* Hidden by default */
    transition: opacity 0.2s ease, background 0.2s;
    z-index: 5;
    padding: 4px;
}

.movie-card:hover .delete-action-btn {
    opacity: 1;
    /* Show on hover */
}

.movie-card .delete-action-btn:hover {
    background: #e50914;
    /* Netflix Red */
}

/* Play Icon Overlay - Center (Optional/Subtle) */
.play-overlay-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
    color: white;
}

.play-overlay-icon svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
    margin-left: 2px;
    /* Visual center */
}

.movie-card:hover .play-overlay-icon {
    opacity: 1;
}

/* Info Below Poster */
.movie-info-below {
    margin-top: 8px;
    padding: 0 2px;
}

.movie-title-text {
    font-size: 0.95rem;
    font-weight: 500;
    color: #e5e5e5;
    margin-bottom: 4px;
    line-height: 1.2;
    /* Truncate to 1 line? Or wrap? User said "always visible". wrapping is safer */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.movie-meta-text {
    font-size: 0.8rem;
    color: #808080;
    /* Grey text */
    font-weight: 400;
}




/* Hide mobile portrait download button by default (desktop/landscape) */
.mobile-portrait-only {
    display: none !important;
}

/* ===== MOBILE PORTRAIT YOUTUBE-STYLE OVERRIDES (xsmall-width-mode) ===== */
@media screen and (max-width: 480px) and (orientation: portrait) {

    /* Show mobile portrait download button in controls ONLY when .active class is present */
    /* This allows JS to control visibility - without .active, button stays hidden */
    .mobile-portrait-only.active {
        display: flex !important;
    }

    /* Hide the old download buttons in mobile portrait */
    #downloadBtn,
    #mobileDownloadBtn {
        display: none !important;
    }

    /* ===== FULL-WIDTH EDGE-TO-EDGE PLAYER (YouTube Style) ===== */

    /* Remove container padding around video player for edge-to-edge */
    .glass-container {
        padding-left: 0;
        padding-right: 0;
    }

    /* Video wrapper - YouTube style: no borders, no radius, full width */
    .video-wrapper {
        border-radius: 0 !important;
        border: none !important;
        box-shadow: none !important;
        margin: 0 !important;
        width: 100vw !important;
    }

    /* Restore padding for non-video elements */
    .glass-container>*:not(.video-wrapper) {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    /* ===== TOP CONTROLS (YouTube Style) ===== */
    .mobile-top-controls {
        padding: 8px 12px;
        gap: 4px;
    }

    .mobile-top-btn {
        width: 32px;
        height: 32px;
    }

    .mobile-top-btn svg {
        width: 18px;
        height: 18px;
    }

    /* ===== SEEK BAR & BOTTOM CONTROLS (YouTube Style) ===== */

    /* YouTube-style seek bar - edge-to-edge */
    .progress-container {
        margin-bottom: 8px;
        /* Width is already 100% */
    }

    /* YouTube small-mode bottom controls height: 36px */
    .controls-main {
        height: 36px;
        min-height: 36px;
    }

    /* YouTube small-mode button sizing: 36px */
    .control-btn {
        width: 36px;
        height: 36px;
        padding: 6px;
        font-size: 1.2rem;
    }

    /* Player controls area - edge-to-edge progress bar */
    .player-controls-area {
        padding: 0 0 10px;
        gap: 4px;
    }

    /* Add slight padding only to controls row, not progress bar */
    .controls-main {
        padding: 0 12px;
        height: 36px;
        min-height: 36px;
    }
}

/* --- Custom Tooltip for Video Title --- */
.movie-title {
    position: relative;
    /* Anchor for tooltip */
    /* Ensure it truncates */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 400px;
    /* Adjust as needed */
    display: inline-block;
    cursor: help;
    /* Indicate hoverable */
}

/* Tooltip Body */
.movie-title[data-full-title]:hover::after {
    content: attr(data-full-title);
    position: absolute;
    bottom: 120%;
    /* Show ABOVE the title */
    left: 50%;
    transform: translateX(-50%);

    background: rgba(20, 20, 20, 0.95);
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    text-align: center;

    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);

    white-space: normal;
    /* Allow wrapping for very long titles */
    min-width: 200px;
    max-width: 600px;
    /* Limit width */
    z-index: 10000;

    /* Animation */
    opacity: 0;
    animation: tooltipFadeIn 0.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    pointer-events: none;
    /* Don't block mouse */
}

/* Little Arrow pointing down */
.movie-title[data-full-title]:hover::before {
    content: '';
    position: absolute;
    bottom: 110%;
    /* Just below the tooltip */
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px;
    border-style: solid;
    border-color: rgba(20, 20, 20, 0.95) transparent transparent transparent;
    z-index: 10000;
    opacity: 0;
    animation: tooltipFadeIn 0.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* FIX: Mobile Landscape Menu Overflow (Applied at end to override defaults) */
@media screen and (max-width: 900px) and (orientation: landscape),
screen and (pointer: coarse) and (orientation: landscape) {

    .settings-menu,
    .settings-menu.settings-panel {
        /* FIX: Use parent-relative height (100%) instead of viewport-relative (100vh)
           The menu is positioned inside .video-wrapper, so 100% refers to the player height.
           This ensures the menu never exceeds the player bounds regardless of viewport size. */
        max-height: calc(100% - 85px) !important;
        overflow-y: auto !important;

        /* Positioning */
        bottom: 75px !important;
        right: 20px !important;
        left: auto !important;
        width: 260px !important;

        /* Reset transform/animations that might cause issues */
        transform: none !important;
        display: none;
    }

    .settings-menu.active {
        display: flex !important;
        flex-direction: column !important;
    }

    /* Ensure inner panels don't force height */
    .settings-section-panel,
    .settings-main {
        overflow-y: auto !important;
        flex-grow: 1 !important;
        max-height: none !important;
        /* Let parent control height */
        padding-bottom: 20px;
    }
}

/* FIX: Compact Mobile Menu Styling & Remove Black Layer on Headers */
@media screen and (max-width: 900px) and (orientation: landscape),
screen and (pointer: coarse) and (orientation: landscape) {

    /* Remove the dark background from section headers */
    .menu-header,
    .section-header {
        background: transparent !important;
        padding: 8px 12px !important;
        margin-bottom: 5px !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
    }

    .section-header span {
        font-size: 0.85rem !important;
    }

    /* More compact menu width */
    .settings-menu,
    .settings-menu.settings-panel {
        width: 220px !important;
        font-size: 0.8rem !important;
    }

    /* Compact menu items */
    .settings-row,
    .menu-item {
        padding: 6px 10px !important;
        min-height: auto !important;
    }

    .settings-row span,
    .menu-item span {
        font-size: 0.8rem !important;
    }

    /* Compact speed options */
    .speed-preset-options {
        padding: 3px 0 !important;
    }

    .speed-preset-option {
        padding: 5px 10px !important;
        font-size: 0.8rem !important;
    }

    /* Compact subtitle/audio track items */
    .track-item,
    .subtitle-item,
    .audio-item {
        padding: 5px 10px !important;
        font-size: 0.8rem !important;
    }

    /* Reduce icon sizes in menu */
    .settings-row i,
    .menu-item i {
        font-size: 0.9rem !important;
    }

    /* Compact fix-audio section at bottom */
    .settings-footer,
    .fix-audio-section {
        padding: 5px 10px !important;
    }

    .fix-audio-btn {
        padding: 5px 10px !important;
        font-size: 0.75rem !important;
    }
}

/* Antigravity Fix: Restore Mobile Browse Button */
@media (max-width: 768px) {
    .mobile-only-btn {
        display: flex !important;
    }
}

/* =========================================
   DESKTOP SPECIFIC RESTORATION
   ========================================= */
@media (min-width: 769px) {
    .main-content {
        min-height: 100vh;
    }
}

/* =========================================
   MOBILE LAYOUT OPTIMIZATION (Industry Grade)
   ========================================= */
@media (max-width: 768px) {

    /* 1. Disable Scroll Snap for natural scrolling */
    html,
    body {
        scroll-snap-type: none !important;
        height: auto !important;
        overflow-y: auto !important;
    }

    /* 2. Auto-height sections to eliminate whitespace */
    .hero-section,
    #videoSection,
    .main-content,
    .featured-section,
    section {
        min-height: auto !important;
        height: auto !important;
        padding-top: 60px !important;
        /* Reduced from 80 */
        padding-bottom: 20px !important;
        scroll-snap-align: none !important;
    }

    /* Specific fix for Video Section to stop centering void */
    #videoSection,
    .main-content {
        justify-content: flex-start !important;
    }

    /* STOP Glass Container from growing/centering */
    .glass-container {
        flex: 0 !important;
        min-height: auto !important;
        justify-content: flex-start !important;
        margin-top: 0 !important;
    }

    /* Ensure Hero has enough space but not forced 100vh */
    .hero-section {
        min-height: 60vh !important;
    }

    /* 3. Typography Scaling (Antigravity Inspired) */
    .hero-heading {
        font-size: 2.5rem !important;
        /* Was 4.5rem */
        letter-spacing: -1px !important;
    }

    .section-title {
        font-size: 1.75rem !important;
    }

    /* 4. Grid Optimization */
    /* Force 1 column for movies on mobile (YouTube Style) */
    .movies-grid,
    .cached-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
        padding: 0 16px !important;
    }

    /* 5. General Spacing */
    .container,
    .browse-search-container,
    .library-container {
        padding-left: 16px !important;
        padding-right: 16px !important;
        width: 100% !important;
    }

    /* Fix Video Player width on mobile */
    .video-wrapper {
        width: 100% !important;
        margin: 0 !important;
        border-radius: 0 !important;
    }

    /* Navbar adjustments */
    .streamhub-nav {
        padding: 0 1rem !important;
        background: rgba(10, 10, 10, 0.95) !important;
        /* Solid background on mobile */
    }

    /* URL Input adjustments */
    .url-input-card {
        padding: 8px !important;
    }

    .url-input {
        font-size: 16px !important;
        /* Prevent zoom on iOS */
    }
}

/* Responsive Navbar Browse Icon */
.mobile-icon {
    display: none;
    align-items: center;
    justify-content: center;
}

@media screen and (max-width: 768px) {
    .browse-link .desktop-text {
        display: none;
    }

    .browse-link .mobile-icon {
        display: flex;
        font-size: 1.5rem;
        /* Larger touch target/visual */
        color: var(--text-muted);
        transition: color 0.3s;
    }

    .browse-link:hover .mobile-icon {
        color: white;
    }

    /* Ensure nav links don't wrap weirdly on small screens */
    .nav-links {
        gap: 1.5rem;
    }
}

/* Antigravity Fix: Strict Menu Item Sizing (Prevents Fullscreen Text Explosion) */
.menu-item,
.menu-item span,
.settings-row,
.settings-row span {
    font-size: 14px !important;
    /* Enforce consistent readable size */
    line-height: normal !important;
}

/* Ensure padding is consistent too, not huge */
.video-wrapper:fullscreen .menu-item,
.video-wrapper:fullscreen .settings-row {
    padding: 10px 14px !important;
    min-height: 44px;
}

/* ===== MOBILE SCROLLING FIXES ===== */
@media screen and (max-width: 900px) {
    html {
        scroll-snap-type: none !important;
        overflow-y: auto !important;
        height: auto !important;
    }

    /* Hide Scrollbars */
    ::-webkit-scrollbar {
        display: none !important;
    }

    html,
    body,
    #library-overlay,
    .library-container {
        scrollbar-width: none !important;
        /* Firefox */
        -ms-overflow-style: none !important;
        /* IE */
    }

    body {
        overscroll-behavior-y: auto !important;
        scroll-snap-type: none !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        /* Antigravity Fix: Prevent horizontal scroll */
        height: auto !important;
        width: 100% !important;
        max-width: 100vw !important;
        position: static !important;
    }

    /* Strict container sizing */
    .library-container,
    .movies-grid,
    .cached-grid {
        width: 100% !important;
        max-width: 100vw !important;
        min-width: 0 !important;
        /* Allow shrinking */
        box-sizing: border-box !important;
        overflow-x: hidden !important;
    }

    /* Edge-to-Edge Fixes */
    .library-container {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    .movies-grid,
    .cached-grid {
        margin: 0 !important;
        padding: 0 !important;
        /* Touch edges */
        gap: 0 !important;
        /* No side gap */
    }

    .movie-card {
        width: 100% !important;
        max-width: 100vw !important;
        min-width: 0 !important;
        /* Critical to prevent grid blowout */
        margin-bottom: 20px !important;
        border-radius: 0 !important;
    }

    .movie-poster-placeholder {
        border-radius: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .hero-section,
    .featured-section,
    .theater-section {
        height: auto !important;
        min-height: 100vh;
        overflow: visible !important;
        scroll-snap-align: none !important;
    }

    .main-content {
        overflow: visible !important;
        height: auto !important;
    }

    .glass-container {
        height: auto !important;
        min-height: auto !important;
        flex: none !important;
    }
}

/* ===== MOBILE BROWSE BTN ===== */
.mobile-only-btn {
    display: none !important;
}

@media screen and (max-width: 900px) {
    .mobile-only-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
    }
}

/* --- Top Right Download Button --- */
.top-right-controls {
    position: absolute;
    top: 15px;
    right: 20px;
    z-index: 25;
    display: flex;
    gap: 10px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    /* Let clicks pass through if invisible */
}

/* Interaction: Show on hover or active state */
.video-wrapper:hover .top-right-controls,
.video-wrapper.is-paused .top-right-controls,
.video-wrapper.user-active .top-right-controls {
    opacity: 1;
    pointer-events: auto;
}

.top-right-controls .control-btn {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.download-pill-btn {
    background: transparent !important;
    border: none !important;
    border-radius: 8px !important;
    padding: 8px 12px;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    box-shadow: none !important;
    filter: none !important;
    /* Ensure no drop-shadows */
    backdrop-filter: none !important;
}

.download-pill-btn:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1) !important;
}

.download-pill-btn .download-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    display: block;
    filter: none !important;
}

.download-pill-btn span {
    line-height: 1.2;
    display: block;
    text-shadow: none !important;
    transform: translateY(1px);
}

.d-none-important {
    display: none !important;
}