.mobile-sheet-handle { display: none; }

/* Reserve the native scrollbar before any owner locks scrolling. */
html { scrollbar-gutter: stable; }
/* Team Space scrolls inside its fixed app, never in the root document. */
html:has(.ts-app) { scrollbar-gutter: auto; }
html.mobile-sheet-open,
html.mobile-sheet-open body {
    overflow: hidden !important;
    overscroll-behavior: none;
}
.mobile-sheet-overlay,
.mobile-sheet-surface,
.mobile-sheet-backdrop {
    animation: none !important;
    transition: none !important;
}
.mobile-sheet-overlay.mobile-sheet-overlay {
    z-index: var(--sheet-layer) !important;
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    opacity: 1;
}
.mobile-sheet-surface.mobile-sheet-surface {
    z-index: var(--sheet-layer) !important;
    opacity: 1;
}
.mobile-sheet-overlay > .mobile-sheet-surface { position: relative; }
.mobile-sheet-backdrop {
    visibility: hidden !important;
    pointer-events: none !important;
}
.mobile-sheet-shade,
.mobile-sheet-frame-shade {
    position: fixed;
    inset: 0;
    background: rgb(0 0 0 / 38%);
    touch-action: none;
}
.mobile-sheet-frame-shade { z-index: 10049; }
.mobile-sheet-closing { pointer-events: none !important; }

@media (max-width: 767px) {
    body.mobile-sheet-open,
    body.mobile-sheet-child-open { overflow: hidden !important; }
    :is(.mobile-sheet-open, .mobile-sheet-child-open) :is(.app-bottom-nav, .club-feed-bottom-nav) {
        visibility: hidden !important;
    }
    body.mobile-sheet-child-open .aformat-site-shell-viewport {
        z-index: 10050;
    }
    .mobile-sheet-overlay {
        z-index: var(--sheet-layer) !important;
        inset: var(--sheet-top, 0px) 0 auto !important;
        width: 100% !important;
        height: var(--sheet-height, 100dvh) !important;
        padding: 0 !important;
        overflow: hidden !important;
        align-items: flex-end !important;
    }
    .mobile-sheet-panel {
        z-index: var(--sheet-layer) !important;
        box-sizing: border-box !important;
        position: fixed !important;
        top: auto !important;
        right: 0 !important;
        bottom: var(--sheet-bottom, 0px) !important;
        left: 0 !important;
        width: 100% !important;
        max-width: none !important;
        min-width: 0 !important;
        min-height: 0 !important;
        height: auto !important;
        max-height: calc(var(--sheet-height, 100dvh) - max(8px, env(safe-area-inset-top))) !important;
        margin: 0 !important;
        padding-top: calc(var(--sheet-padding-top, 0px) + 28px) !important;
        padding-bottom: max(var(--sheet-padding-bottom, 0px), env(safe-area-inset-bottom)) !important;
        border-radius: 24px 24px 0 0 !important;
        border-bottom: 0 !important;
        overflow-y: auto !important;
        overscroll-behavior: contain;
        scroll-padding-block: 36px 24px;
        transform: translateY(var(--sheet-drag, 0px));
        animation: none !important;
        transition: none !important;
    }
    /* Explicit state specificity beats existing centered/zoomed modal rules.
       Transform remains animatable by the Web Animations API. */
    .mobile-sheet-panel.mobile-sheet-panel { transform: translateY(var(--sheet-drag, 0px)); }
    .mobile-sheet-overlay > .mobile-sheet-panel {
        position: relative !important;
        bottom: auto !important;
        flex-shrink: 0;
    }
    .mobile-sheet-panel:is(.match-modal, .media-lightbox__dialog, .ts-image-viewer) {
        height: calc(var(--sheet-height, 100dvh) - max(8px, env(safe-area-inset-top))) !important;
    }
    .mobile-sheet-handle {
        position: absolute;
        z-index: 5;
        top: 0;
        inset-inline: 56px;
        display: grid;
        height: 28px;
        place-items: center;
        touch-action: none;
        cursor: grab;
    }
    .mobile-sheet-handle:active { cursor: grabbing; }
    .mobile-sheet-handle > span {
        width: 38px;
        height: 4px;
        border-radius: 4px;
        background: #94a3b8;
    }
    .mobile-sheet-panel :is(button[aria-label^="Закрыть"], .modal-close, .video-modal-close) {
        min-width: 44px;
        min-height: 44px;
    }
}
