/* Keep the open-chat menu above the message surface and its scroll layer. */
#chatView .chat-header {
    position: sticky !important;
    z-index: 3000 !important;
    overflow: visible !important;
}

#chatView .chat-header .chat-menu {
    position: relative !important;
    z-index: 3001 !important;
    overflow: visible !important;
}

#chatView .chat-header .chat-menu .menu-btn {
    position: relative !important;
    z-index: 3002 !important;
}

#chatView .chat-header .chat-menu .chat-menu-dropdown {
    position: absolute !important;
    top: calc(100% + 8px) !important;
    right: 0 !important;
    z-index: 3003 !important;
    visibility: visible;
}

/* Chat-history menus flip toward the side with enough visible room. */
#chatHistoryList .chat-menu-dropdown.show,
#chatsListGrid .chat-menu-dropdown.show {
    top: calc(100% - 4px) !important;
    bottom: auto !important;
    max-height: var(--chat-menu-available-height, calc(100vh - 24px)) !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
}

#chatHistoryList .chat-menu-dropdown.show.opens-up,
#chatsListGrid .chat-menu-dropdown.show.opens-up {
    top: auto !important;
    bottom: calc(100% + 4px) !important;
}
