/* Browse-only mobile shell; desktop and other pages keep their existing layout. */
.browse-mobile-nav,
.browse-mobile-guest-menu,
.browse-mobile-screen {
    display: none;
}

@media (max-width: 650px) {
    html:has(body:is(.browse-page, .channel-page)) {
        min-height: 100%;
        -webkit-text-size-adjust: 100%;
        text-size-adjust: 100%;
        transform: none;
        filter: none;
        perspective: none;
        contain: none;
        scroll-padding-block: 88px 110px;
    }

    body:is(.browse-page, .channel-page) {
        --aux-ui-scale: 1;
        --browse-nav-top: max(0px, calc(env(safe-area-inset-top) - 12px));
        --browse-nav-bottom: max(16px, env(safe-area-inset-bottom));
        --browse-dock-space: calc(94px + var(--browse-nav-bottom));
        min-height: 100vh;
        min-height: 100dvh;
        padding-bottom: var(--browse-dock-space);
        background-attachment: scroll;
        transform: none;
        filter: none;
        perspective: none;
        contain: none;
    }

    :is(.browse-page, .channel-page) .navbar {
        height: calc(68px + var(--browse-nav-top));
        flex: 0 0 auto;
        gap: 12px;
        padding: var(--browse-nav-top) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
    }

    :is(.browse-page, .channel-page) .nav-logo { flex: 0 0 auto; }
    :is(.browse-page, .channel-page) .nav-logo img { width: 62px; height: auto; }

    :is(.browse-page, .channel-page) .nav-search,
    :is(.browse-page, .channel-page) .nav-search.expanded {
        position: relative;
        top: auto;
        left: auto;
        flex: 1 1 0;
        width: auto;
        min-width: 0;
        max-width: none;
        height: 40px;
        transform: none;
        transition: none;
    }

    :is(.browse-page, .channel-page) .nav-search input {
        height: 40px !important;
        padding-inline: 10px !important;
        font-size: 16px !important;
    }

    :is(.browse-page, .channel-page) .nav-auth,
    :is(.browse-page, .channel-page) .navbar .btn-go-live,
    :is(.browse-page, .channel-page) .navbar .nav-profile-link,
    :is(.browse-page, .channel-page) #nav-dropdown-trigger,
    :is(.browse-page, .channel-page) .aux-kofi-nav-mask { display: none !important; }

    :is(.browse-page, .channel-page) .nav-auth-logged-in { flex: 0 0 40px; gap: 0; }
    :is(.browse-page, .channel-page) .nav-notif-button { width: 40px; height: 44px; padding: 8px; }
    :is(.browse-page, .channel-page) .nav-notif-icon { width: 24px; height: 24px; }
    :is(.browse-page, .channel-page) .sidebar { display: none; }

    :is(.browse-page, .channel-page) .main-content,
    :is(.browse-page, .channel-page) .main-content.expanded { width: 100%; min-width: 0; margin: 0; }

    :is(.browse-page, .channel-page) .content-area {
        width: 100%;
        min-height: 0;
        margin: 0;
        padding: 22px max(20px, env(safe-area-inset-right)) 24px max(20px, env(safe-area-inset-left));
        border-radius: 0;
        background: transparent;
    }

    :is(.browse-page, .channel-page) .browse-top-section { display: block; }
    :is(.browse-page, .channel-page) .featured-column { display: none; }
    :is(.browse-page, .channel-page) .trending-column { width: 100%; margin-bottom: 18px; }
    :is(.browse-page, .channel-page) .section-title { margin-bottom: 12px; font-size: 22px; line-height: 1.2; letter-spacing: 0; }
    :is(.browse-page, .channel-page) .browse-desktop-label { display: none; }

    :is(.browse-page, .channel-page) .trending-player-card {
        width: 100%;
        height: auto;
        min-height: 90px;
        aspect-ratio: 3.4 / 1;
        margin: 0;
        border-radius: 7px;
    }

    :is(.browse-page, .channel-page) .live-indicator-dot { top: 10px; right: 10px; width: 8px; height: 8px; }
    :is(.browse-page, .channel-page) .recent-streams-section,
    :is(.browse-page, .channel-page) .top-categories-section { margin-bottom: 20px; }
    /* The carousel writes inline display values after its data loads. */
    :is(.browse-page, .channel-page) .slider-arrow { display: none !important; }

    :is(.browse-page, .channel-page) :is(.streams-row, .category-grid, .favorites-grid) {
        gap: 14px;
        margin: 0;
        padding: 0 0 5px;
        overscroll-behavior-x: contain;
        scroll-snap-type: x proximity;
    }

    :is(.browse-page, .channel-page) :is(.stream-card, .category-item, .placeholder-category-card) {
        flex: 0 0 calc((100% - 14px) / 2);
        min-width: 0;
        max-width: calc((100% - 14px) / 2);
        margin: 0;
        scroll-snap-align: start;
    }

    :is(.browse-page, .channel-page) .stream-thumbnail { aspect-ratio: 16 / 9; border-radius: 7px; }
    :is(.browse-page, .channel-page) .stream-info { margin-top: 7px; padding: 0 2px; }
    :is(.browse-page, .channel-page) .stream-title { font-size: 12px; }
    :is(.browse-page, .channel-page) .stream-metadata { gap: 5px; font-size: 10px; }
    :is(.browse-page, .channel-page) .stream-metadata > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    :is(.browse-page, .channel-page) .stream-viewer-count { flex-shrink: 0; }
    :is(.browse-page, .channel-page) :is(.category-card, .placeholder-category-card) { width: 100%; height: auto; aspect-ratio: 2 / 3; }
    :is(.browse-page, .channel-page) .category-title { max-width: 100%; font-size: 12px; }
    :is(.browse-page, .channel-page) .category-card-bg { background-position: 0 -1000px, center, center !important; opacity: 1; }
    :is(.browse-page, .channel-page) .favourite-categories-section:has(#favorites-container:empty) { display: none; }

    :is(.browse-page, .channel-page) > footer { display: none !important; }

    :is(.browse-page, .channel-page) .browse-mobile-nav {
        position: fixed;
        left: max(10px, env(safe-area-inset-left));
        right: max(10px, env(safe-area-inset-right));
        bottom: var(--browse-nav-bottom);
        z-index: 1001;
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        min-height: 74px;
        padding: 7px 5px;
        border: 1px solid rgba(255, 255, 255, .1);
        border-radius: 18px;
        background: #202020;
        box-shadow: 0 14px 38px rgba(0, 0, 0, .42);
        backdrop-filter: blur(18px);
        -webkit-backdrop-filter: blur(18px);
    }

    .browse-mobile-nav-item {
        display: flex;
        min-width: 0;
        min-height: 56px;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 5px;
        padding: 3px 2px;
        border: 0;
        border-radius: 12px;
        background: transparent;
        color: #9b2d2d;
        font: 700 11px 'Montserrat', sans-serif;
        text-decoration: none;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .browse-mobile-nav-item :is(svg, img) { width: 27px; height: 27px; flex-shrink: 0; }
    .browse-mobile-nav-item svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
    .browse-mobile-nav-item img { object-fit: cover; border: 1px solid rgba(255, 255, 255, .15); border-radius: 5px; }
    .browse-mobile-live-dot { width: 20px; height: 20px; margin-block: 3.5px; border-radius: 50%; background: #9b2d2d; }
    .browse-mobile-nav-item:focus-visible { outline: 2px solid #c2c2c2; outline-offset: -2px; }
    .browse-mobile-nav-item:is(:active, :focus, [aria-current="page"]) { background: transparent; }

    .browse-mobile-screen[hidden] { display: none !important; }
    .browse-mobile-screen:not([hidden]) { display: block; flex: 1; width: 100%; min-height: calc(100dvh - 68px - var(--browse-dock-space)); background: #202020; padding-bottom: 20px; }
    .browse-mobile-page-heading { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid rgba(255,255,255,.08); }
    .browse-mobile-page-heading h1 { margin: 0; font-size: 22px; }
    .browse-mobile-page-heading h1:focus { outline: none; }
    .browse-mobile-page-heading button svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
    .browse-mobile-page-heading button { width: 44px; height: 44px; padding: 0; border: 0; font-size: 28px; color: #c2c2c2; background: transparent; cursor: pointer; }
    .browse-mobile-page-content { padding: 14px max(20px, env(safe-area-inset-right)) 20px max(20px, env(safe-area-inset-left)); }
    :is(.browse-page, .channel-page) .browse-mobile-screen #nav-user-dropdown,
    :is(.browse-page, .channel-page) .browse-mobile-screen .browse-mobile-guest-menu {
        position: static !important;
        display: flex !important;
        flex-direction: column;
        width: 100% !important;
        min-height: 0;
        max-height: none;
        margin: 0;
        padding: 0 !important;
        border: 0 !important;
        border-radius: 0 !important;
        background: transparent !important;
        box-shadow: none !important;
        backdrop-filter: none;
    }
    :is(.browse-page, .channel-page) .browse-mobile-screen :is(.dropdown-item, .browse-mobile-guest-menu a) { min-height: 44px; padding: 12px; font-size: 14px; text-decoration: none; color: #c2c2c2; border-radius: 8px; background: #181818; }
    :is(.browse-page, .channel-page) .browse-mobile-screen #nav-user-dropdown a[href="/about"],
    :is(.browse-page, .channel-page) .browse-mobile-screen #aux-footer-visibility-toggle { display: none; }
    .browse-mobile-page-links { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; margin-top: 18px; padding-top: 18px; border-top: 1px solid rgba(255,255,255,.08); }
    .browse-mobile-page-links :is(a,button) { display: flex; align-items: center; justify-content: center; min-width: 0; min-height: 44px; padding: 10px; border: 1px solid #9b2d2d; border-radius: 8px; background: #181818; color: #c2c2c2; text-align: center; text-decoration: none; font: 600 12px 'Montserrat',sans-serif; overflow-wrap: anywhere; cursor: pointer; }
    .browse-mobile-screen :is(a,button):focus-visible { outline: 2px solid #9b2d2d; outline-offset: 2px; }
    :is(.browse-page, .channel-page) .browse-mobile-screen .btn-logout { background: #9b2d2d !important; }
    .browse-mobile-copyright { margin: 18px 0 0; font-size: 11px; text-align: center; color: #888; }
    :is(.browse-page, .channel-page) #browse-mobile-notification-list #notificationListContainer {
        position: static !important; display: flex; width: 100%; max-height: none; margin: 0; border-radius: 0; box-shadow: none; background: transparent; overflow: visible;
    }
    :is(.browse-page, .channel-page)[data-browse-mobile-tab="notifications"] .notification-list-header { display: none; }
    :is(.browse-page, .channel-page) #notificationListContainer {
        top: calc(68px + var(--browse-nav-top)) !important;
        right: max(10px, env(safe-area-inset-right)) !important;
        max-height: calc(100dvh - var(--browse-dock-space) - 88px);
    }
    :is(.browse-page, .channel-page) .aux-advent-slot:not([hidden]) { height: 88px; }
    :is(.browse-page, .channel-page) .aux-advent-pouch { top: 8px; right: 20px; width: 64px; height: 76px; }
}

