/* LEMMIQ V2.12.1 — PWA/mobile chat composer visibility hotfix.
   The previous V2.10.11 100dvh-92px height collided with fixed bottom nav. */
@media (max-width: 900px) {
  /* Fallback if JavaScript is delayed/disabled. JS refines this height from live geometry. */
  #view-chats .chat-layout.open-chat {
    height: calc(100dvh - 176px - env(safe-area-inset-bottom, 0px)) !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }
  #view-chats .chat-layout.open-chat .chat-pane {
    display: block;
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }
  /* Flex column handles the optional AI suggestion, reply preview and composer
     without implicitly allocating extra CSS grid rows. */
  #activeChat:not(.hidden),
  #activeGroup:not(.hidden),
  #activeQThread:not(.hidden) {
    display: flex !important;
    flex-direction: column !important;
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }
  #activeChat .chat-head,
  #activeGroup .chat-head,
  #activeQThread .chat-head {
    flex: 0 0 auto;
    min-width: 0;
  }
  #activeChat .messages,
  #activeGroup .messages,
  #activeQThread .messages {
    flex: 1 1 0;
    min-height: 0 !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
  #activeChat .assist-bar,
  #activeGroup .assist-bar {
    position: static !important;
    flex: 0 0 auto;
    margin: 4px 7px !important;
    padding: 6px 8px !important;
    min-height: 0;
  }
  #activeChat .suggestion,
  #activeChat .reply-preview,
  #activeGroup .suggestion,
  #activeQThread .q-thread-foot {
    flex: 0 0 auto;
    max-height: min(26dvh, 180px);
    overflow-y: auto;
  }
  #activeChat .composer,
  #activeGroup .composer {
    flex: 0 0 auto;
    position: relative;
    z-index: 3;
    width: 100%;
    min-width: 0;
    margin: 0 !important;
    background: var(--panel, #171b33);
    border-top: 1px solid var(--line, rgba(255,255,255,.12));
    padding-bottom: max(8px, env(safe-area-inset-bottom, 0px)) !important;
  }
  #activeChat .composer textarea,
  #activeGroup .composer textarea {
    min-width: 0 !important;
    max-width: 100%;
    font-size: 16px; /* Avoid iOS input auto-zoom. */
  }
  /* Make excessively long chat action rows horizontally scroll rather than growing the header. */
  #activeChat .chat-person,
  #activeGroup .chat-person {min-width: 0; flex: 1 1 auto;}
  #activeChat .chat-head-actions,
  #activeGroup .chat-head-actions {
    min-width: 0;
    max-width: 58%;
    flex: 0 1 auto;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  #activeChat .chat-head-actions::-webkit-scrollbar,
  #activeGroup .chat-head-actions::-webkit-scrollbar {display: none;}
  #activeChat .chat-head-actions button,
  #activeGroup .chat-head-actions button {flex: 0 0 auto;}
}
@media (max-width: 430px) {
  #activeChat .assist-bar > span,
  #activeGroup .assist-bar > span {display: none;}
  #activeChat .assist-bar button,
  #activeGroup .assist-bar button {min-height: 36px;}
}
