/**
 * Native pull-to-refresh for groups + channels browse (main-panel layout).
 * Requires html.ulgb-native-pull-refresh-groups-channels (see config).
 *
 * Unlocks the full #groups-main-panel / #channels-main-panel chain with min-height: auto
 * so content stays visible while the document becomes the scroll root.
 *
 * Disabled while channels live viewer is open (body.channels-modal-open).
 * Revert: $ulgbNativePullRefreshGroupsChannelsEnabled = false in config.
 */
@media screen and (max-width: 1024px) {
    html.ulgb-native-pull-refresh-active.ulgb-native-pull-refresh-groups-channels:has(
        body.groups-page:not(.ulgb-no-native-pull-refresh),
        body.channels-page:not(.channels-modal-open):not(.ulgb-no-native-pull-refresh)
    ) {
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        height: auto;
    }

    html.ulgb-native-pull-refresh-active.ulgb-native-pull-refresh-groups-channels
        body.groups-page:not(.ulgb-no-native-pull-refresh),
    html.ulgb-native-pull-refresh-active.ulgb-native-pull-refresh-groups-channels
        body.channels-page:not(.channels-modal-open):not(.ulgb-no-native-pull-refresh) {
        overflow: visible !important;
        min-height: 100%;
    }

    html.ulgb-native-pull-refresh-active.ulgb-native-pull-refresh-groups-channels:has(.navbar-bottom)
        body.groups-page:not(.ulgb-no-native-pull-refresh),
    html.ulgb-native-pull-refresh-active.ulgb-native-pull-refresh-groups-channels:has(.navbar-bottom)
        body.channels-page:not(.channels-modal-open):not(.ulgb-no-native-pull-refresh) {
        padding-bottom: calc(85px + env(safe-area-inset-bottom, 0px));
    }

    html.ulgb-native-pull-refresh-active.ulgb-native-pull-refresh-groups-channels:has(.navbar)
        body.groups-page:not(.ulgb-no-native-pull-refresh),
    html.ulgb-native-pull-refresh-active.ulgb-native-pull-refresh-groups-channels:has(.navbar)
        body.channels-page:not(.channels-modal-open):not(.ulgb-no-native-pull-refresh) {
        padding-top: var(--ulgb-mobile-content-top, 72px);
    }

    /* Full main-panel chain → document flow (min-height: auto prevents zero-height collapse). */
    html.ulgb-native-pull-refresh-active.ulgb-native-pull-refresh-groups-channels
        body.groups-page:not(.ulgb-no-native-pull-refresh) .homepage-wrapper,
    html.ulgb-native-pull-refresh-active.ulgb-native-pull-refresh-groups-channels
        body.groups-page:not(.ulgb-no-native-pull-refresh) .homepage-main-content,
    html.ulgb-native-pull-refresh-active.ulgb-native-pull-refresh-groups-channels
        body.groups-page:not(.ulgb-no-native-pull-refresh) .homepage-main-container,
    html.ulgb-native-pull-refresh-active.ulgb-native-pull-refresh-groups-channels
        body.groups-page:not(.ulgb-no-native-pull-refresh) #groups-desktop-app,
    html.ulgb-native-pull-refresh-active.ulgb-native-pull-refresh-groups-channels
        body.groups-page:not(.ulgb-no-native-pull-refresh) .vc-layout,
    html.ulgb-native-pull-refresh-active.ulgb-native-pull-refresh-groups-channels
        body.groups-page:not(.ulgb-no-native-pull-refresh) #groups-main-panel,
    html.ulgb-native-pull-refresh-active.ulgb-native-pull-refresh-groups-channels
        body.groups-page:not(.ulgb-no-native-pull-refresh) #groups-main-panel .vc-desktop-float-panel,
    html.ulgb-native-pull-refresh-active.ulgb-native-pull-refresh-groups-channels
        body.groups-page:not(.ulgb-no-native-pull-refresh) #groups-main-panel .vc-desktop-float-columns,
    html.ulgb-native-pull-refresh-active.ulgb-native-pull-refresh-groups-channels
        body.groups-page:not(.ulgb-no-native-pull-refresh) #groups-main-panel .groups-main-column,
    html.ulgb-native-pull-refresh-active.ulgb-native-pull-refresh-groups-channels
        body.groups-page:not(.ulgb-no-native-pull-refresh) #groups-main-panel .vc-stage,
    html.ulgb-native-pull-refresh-active.ulgb-native-pull-refresh-groups-channels
        body.groups-page:not(.ulgb-no-native-pull-refresh) #groups-main-panel .vc-video-shell,
    html.ulgb-native-pull-refresh-active.ulgb-native-pull-refresh-groups-channels
        body.groups-page:not(.ulgb-no-native-pull-refresh) #groups-main-panel .vc-video-wrap,
    html.ulgb-native-pull-refresh-active.ulgb-native-pull-refresh-groups-channels
        body.groups-page:not(.ulgb-no-native-pull-refresh) #groups-empty,
    html.ulgb-native-pull-refresh-active.ulgb-native-pull-refresh-groups-channels
        body.groups-page:not(.ulgb-no-native-pull-refresh) #groups-empty .vc-browse-inner,
    html.ulgb-native-pull-refresh-active.ulgb-native-pull-refresh-groups-channels
        body.groups-page:not(.ulgb-no-native-pull-refresh) .groups-center-box,
    html.ulgb-native-pull-refresh-active.ulgb-native-pull-refresh-groups-channels
        body.channels-page:not(.channels-modal-open):not(.ulgb-no-native-pull-refresh) .homepage-wrapper,
    html.ulgb-native-pull-refresh-active.ulgb-native-pull-refresh-groups-channels
        body.channels-page:not(.channels-modal-open):not(.ulgb-no-native-pull-refresh) .homepage-main-content,
    html.ulgb-native-pull-refresh-active.ulgb-native-pull-refresh-groups-channels
        body.channels-page:not(.channels-modal-open):not(.ulgb-no-native-pull-refresh) .homepage-main-container,
    html.ulgb-native-pull-refresh-active.ulgb-native-pull-refresh-groups-channels
        body.channels-page:not(.channels-modal-open):not(.ulgb-no-native-pull-refresh) #channels-desktop-app,
    html.ulgb-native-pull-refresh-active.ulgb-native-pull-refresh-groups-channels
        body.channels-page:not(.channels-modal-open):not(.ulgb-no-native-pull-refresh) .vc-layout,
    html.ulgb-native-pull-refresh-active.ulgb-native-pull-refresh-groups-channels
        body.channels-page:not(.channels-modal-open):not(.ulgb-no-native-pull-refresh) #channels-main-panel,
    html.ulgb-native-pull-refresh-active.ulgb-native-pull-refresh-groups-channels
        body.channels-page:not(.channels-modal-open):not(.ulgb-no-native-pull-refresh) #channels-main-panel .vc-desktop-float-panel,
    html.ulgb-native-pull-refresh-active.ulgb-native-pull-refresh-groups-channels
        body.channels-page:not(.channels-modal-open):not(.ulgb-no-native-pull-refresh) #channels-main-panel .vc-desktop-float-columns,
    html.ulgb-native-pull-refresh-active.ulgb-native-pull-refresh-groups-channels
        body.channels-page:not(.channels-modal-open):not(.ulgb-no-native-pull-refresh) #channels-main-panel .channels-main-column,
    html.ulgb-native-pull-refresh-active.ulgb-native-pull-refresh-groups-channels
        body.channels-page:not(.channels-modal-open):not(.ulgb-no-native-pull-refresh) #channels-main-panel .vc-stage,
    html.ulgb-native-pull-refresh-active.ulgb-native-pull-refresh-groups-channels
        body.channels-page:not(.channels-modal-open):not(.ulgb-no-native-pull-refresh) #channels-main-panel .vc-video-shell,
    html.ulgb-native-pull-refresh-active.ulgb-native-pull-refresh-groups-channels
        body.channels-page:not(.channels-modal-open):not(.ulgb-no-native-pull-refresh) #channels-main-panel .vc-video-wrap,
    html.ulgb-native-pull-refresh-active.ulgb-native-pull-refresh-groups-channels
        body.channels-page:not(.channels-modal-open):not(.ulgb-no-native-pull-refresh) #channels-empty,
    html.ulgb-native-pull-refresh-active.ulgb-native-pull-refresh-groups-channels
        body.channels-page:not(.channels-modal-open):not(.ulgb-no-native-pull-refresh) #channels-empty .vc-browse-inner,
    html.ulgb-native-pull-refresh-active.ulgb-native-pull-refresh-groups-channels
        body.channels-page:not(.channels-modal-open):not(.ulgb-no-native-pull-refresh) .channels-center-box,
    html.ulgb-native-pull-refresh-active.ulgb-native-pull-refresh-groups-channels
        body.channels-page:not(.channels-modal-open):not(.ulgb-no-native-pull-refresh) .channels-mobile-browse-header {
        position: relative !important;
        inset: auto !important;
        top: auto !important;
        bottom: auto !important;
        left: auto !important;
        right: auto !important;
        overflow: visible !important;
        overscroll-behavior: auto !important;
        touch-action: auto !important;
        flex: none !important;
        flex-grow: 0 !important;
        flex-shrink: 0 !important;
        flex-basis: auto !important;
        min-height: auto !important;
        height: auto !important;
        max-height: none !important;
        width: 100% !important;
        box-sizing: border-box;
    }

    html.ulgb-native-pull-refresh-active.ulgb-native-pull-refresh-groups-channels
        body.groups-page:not(.ulgb-no-native-pull-refresh) #groups-main-panel.vc-room-modal,
    html.ulgb-native-pull-refresh-active.ulgb-native-pull-refresh-groups-channels
        body.channels-page:not(.channels-modal-open):not(.ulgb-no-native-pull-refresh) #channels-main-panel.vc-room-modal {
        display: flex !important;
        flex-direction: column !important;
        z-index: 1 !important;
        background: transparent !important;
        padding: 0 !important;
        margin: 0 !important;
        min-height: auto !important;
        height: auto !important;
    }

    html.ulgb-native-pull-refresh-active.ulgb-native-pull-refresh-groups-channels
        body.groups-page:not(.ulgb-no-native-pull-refresh) .groups-cards-grid {
        display: grid !important;
        overflow: visible !important;
        overscroll-behavior: auto !important;
        touch-action: auto !important;
        flex: none !important;
        min-height: auto !important;
        height: auto !important;
        max-height: none !important;
    }

    html.ulgb-native-pull-refresh-active.ulgb-native-pull-refresh-groups-channels
        body.channels-page:not(.channels-modal-open):not(.ulgb-no-native-pull-refresh) .channels-cards-grid {
        overflow: visible !important;
        overscroll-behavior: auto !important;
        touch-action: auto !important;
        flex: none !important;
        min-height: auto !important;
        height: auto !important;
        max-height: none !important;
    }

    html.ulgb-native-pull-refresh-active.ulgb-native-pull-refresh-groups-channels
        body.channels-page:not(.channels-modal-open):not(.ulgb-no-native-pull-refresh) .channels-cards-grid:not(.channels-cards-grid--library) {
        display: flex !important;
        flex-direction: column !important;
    }

    html.ulgb-native-pull-refresh-active.ulgb-native-pull-refresh-groups-channels
        body.channels-page:not(.channels-modal-open):not(.ulgb-no-native-pull-refresh) .channels-cards-grid.channels-cards-grid--library {
        display: grid !important;
    }

    /* Overlays keep contained scroll. */
    html.ulgb-native-pull-refresh-active.ulgb-native-pull-refresh-groups-channels .groups-detail-modal-scroll-wrap,
    html.ulgb-native-pull-refresh-active.ulgb-native-pull-refresh-groups-channels .channels-live-modal-overlay,
    html.ulgb-native-pull-refresh-active.ulgb-native-pull-refresh-groups-channels .channels-setup-overlay {
        overscroll-behavior: contain !important;
    }
}
