/* Мобильные чаты: шапка закреплена, лента + композер под клавиатуру. ПК не затрагивается. */
@media (max-width: 767px) {
    .mck-chat-wallpaper {
        position: fixed;
        z-index: 0;
        pointer-events: none;
        top: var(--mck-vv-top, 0);
        left: var(--mck-vv-left, 0);
        width: var(--mck-vv-width, 100%);
        height: var(--mck-vv-height, 100%);
        background: #f9f9fb;
    }

    html.dark .mck-chat-wallpaper {
        background: #1a1a1e;
    }

    /* ——— ЛК: полноэкранный диалог ——— */
    body.dash-mobile-tab-chat.dash-chat-thread-open #dashMobileChatThread {
        display: flex !important;
        flex-direction: column !important;
        padding-top: env(safe-area-inset-top, 0px);
        overflow: hidden !important;
    }

    /* Не сдвигаем весь экран чата (только композер через JS) */
    body.dash-mobile-tab-chat.dash-chat-thread-open #dashMobileChatThread.mck-keyboard-sync {
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
    }

    body.dash-mobile-tab-chat.dash-chat-thread-open #supportChat.chat-card {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        overflow: hidden !important;
    }

    body.dash-mobile-tab-chat.dash-chat-thread-open #supportChat .chat-header {
        flex: 0 0 auto !important;
        flex-shrink: 0 !important;
        position: relative !important;
        z-index: 12 !important;
        background: #fff !important;
        width: 100% !important;
        box-sizing: border-box;
    }

    body.dash-mobile-tab-chat.dash-chat-thread-open #supportChat .chat-collapse {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
    }

    body.dash-mobile-tab-chat.dash-chat-thread-open #clientChatBox {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        height: auto !important;
        max-height: none !important;
        margin: 0 !important;
        border-radius: 0 !important;
        border-left: none !important;
        border-right: none !important;
        border-top: none !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-y: contain;
        overflow-anchor: auto;
    }

    body.dash-mobile-tab-chat.dash-chat-composer-fixed.dash-chat-thread-open .client-chat-composer-wrap {
        background: #fff;
        border-top: 1px solid #ececf2;
        box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.06);
    }

    /* ——— Админка: диалог с клиентом / гость ——— */
    #chat-tab.admin-chat-mobile-convo #adminChatConvoPanel.mck-keyboard-sync,
    #guest-support-tab.admin-guest-chat-mobile-convo #guestSupportConvoPanel.mck-keyboard-sync {
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        padding-top: max(8px, env(safe-area-inset-top, 0px)) !important;
    }

    #chat-tab.admin-chat-mobile-convo #adminChatConvoPanel,
    #guest-support-tab.admin-guest-chat-mobile-convo #guestSupportConvoPanel {
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
    }

    #chat-tab.admin-chat-mobile-convo #activeChatHeader,
    #guest-support-tab.admin-guest-chat-mobile-convo #guestSupportChatHeader {
        flex: 0 0 auto !important;
        flex-shrink: 0 !important;
        position: relative !important;
        z-index: 12 !important;
        background: #fff !important;
        width: 100% !important;
        box-sizing: border-box;
    }

    html.dark #chat-tab.admin-chat-mobile-convo #activeChatHeader,
    html.dark #guest-support-tab.admin-guest-chat-mobile-convo #guestSupportChatHeader {
        background: #121212 !important;
    }

    #chat-tab.admin-chat-mobile-convo #adminChatBox,
    #guest-support-tab.admin-guest-chat-mobile-convo #guestSupportChatBox {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        height: auto !important;
        max-height: none !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-y: contain;
        overflow-anchor: auto;
        margin-bottom: 0 !important;
    }

    body.admin-chat-composer-fixed #chat-tab.admin-chat-mobile-convo .admin-chat-composer-wrap,
    body.admin-chat-composer-fixed #guest-support-tab.admin-guest-chat-mobile-convo .admin-chat-composer-wrap {
        background: #fff;
        border-top: 1px solid #ececf2;
        box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.06);
    }

    html.dark body.admin-chat-composer-fixed #chat-tab.admin-chat-mobile-convo .admin-chat-composer-wrap,
    html.dark body.admin-chat-composer-fixed #guest-support-tab.admin-guest-chat-mobile-convo .admin-chat-composer-wrap {
        background: #121212;
        border-top-color: #333;
    }

    /* Виджет поддержки на сайте — корень под vv */
    #siteGuestSupportChatRoot.sc-root-fs-mobile.sc-keyboard-open .sc-msgs {
        flex: 1 !important;
        min-height: 0 !important;
        overflow-y: auto !important;
        overflow-anchor: auto;
        background: transparent !important;
    }
}
