/* BM3 Android WebView: contain all Better Messages vertical scroll surfaces. */
html.hb-bm-wv-guard,
html.hb-bm-wv-guard body {
    overscroll-behavior-y: none !important;
}
html.hb-bm-wv-guard body {
    /* Native SwipeRefreshLayout often checks whether the WebView itself can
       scroll upward. Two harmless document pixels let JS park it at 1px. */
    min-height: calc(100vh + 2px) !important;
}
html.hb-bm-wv-guard .bm-wrap,
html.hb-bm-wv-guard .bm-wrap-main,
html.hb-bm-wv-guard .bm-single-thread-wrap,
html.hb-bm-wv-guard .bm-thread-col,
html.hb-bm-wv-guard .bm-msg-list-wrap,
html.hb-bm-wv-guard .bm-threads-list-widget,
html.hb-bm-wv-guard .bm-list-wrap,
html.hb-bm-wv-guard .bm-list-wrap .bm-list,
html.hb-bm-wv-guard .bm-msg-list,
html.hb-bm-wv-guard [data-overlayscrollbars-viewport] {
    overscroll-behavior-y: contain !important;
}
html.hb-bm-wv-guard .bm-list-wrap .bm-list,
html.hb-bm-wv-guard .bm-msg-list,
html.hb-bm-wv-guard [data-overlayscrollbars-viewport] {
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y pinch-zoom;
}

/* BM3 desktop + BuddyX/BuddyPress width containment.
 * Scoped to the BuddyPress Messages screen only so Activity, Groups, Members
 * and other BuddyPress layouts are not changed. Mobile keeps its native layout.
 */
@media (min-width: 769px) {
    body.bp-messages #buddypress .bp-wrap,
    body.bp-messages #buddypress #item-body,
    body.bp-messages #buddypress .bm-wrap-main {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
    }
}

/* Better Messages 3.0.8 compatibility (Android/WebView only).
 * 3.0.8 adds html.bm-page-held body { position:fixed; inset:0 } while its
 * mobile takeover is open. That removes the tiny document scroll range used
 * by the proven 1.3.6 WebView guard and makes the native refresh container
 * behave as if the WebView were permanently at its upper edge.
 * Restore the pre-3.0.8 page geometry only while our Android guard is active.
 * Keep overflow:hidden because that already existed in BM 3.0.4 mobile mode.
 */
html.hb-bm-wv-guard.bm-page-held body {
    position: relative !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
}
