/* V35.18 — MOBILE EMOJI / KEYBOARD SURFACE FINAL — TARGETED ONLY
 * Base: V35.17/FIXED22. No menu/message markup/navigation changes.
 */
@media (max-width:767px){
  /* One bottom composer surface: input row first, emoji layer second. */
  #chatMainContainer.mobile-active .chat-input-zone.v3518-emoji-surface,
  #chatMainContainer.mobile-active .chat-input-zone.v3518-keyboard-surface,
  body.mobile-chat-focus .chat-input-zone.v3518-emoji-surface,
  body.mobile-chat-focus .chat-input-zone.v3518-keyboard-surface{
    position:fixed !important;
    left:0 !important;
    right:0 !important;
    bottom:0 !important;
    width:100% !important;
    margin:0 !important;
    padding:0 !important;
    min-height:0 !important;
    max-height:none !important;
    height:auto !important;
    display:flex !important;
    flex-direction:column !important;
    justify-content:flex-end !important;
    align-items:stretch !important;
    overflow:visible !important;
    z-index:2146 !important;
    box-sizing:border-box !important;
    background:var(--bg-main,#111b21) !important;
  }

  /* Existing WhatsApp composer row — ALWAYS ABOVE the emoji layer. */
  .chat-input-zone.v3518-emoji-surface > .zalo-input-area,
  .chat-input-zone.v3518-keyboard-surface > .zalo-input-area{
    order:1 !important;
    position:relative !important;
    flex:0 0 auto !important;
    display:flex !important;
    visibility:visible !important;
    opacity:1 !important;
    width:100% !important;
    min-height:54px !important;
    z-index:2150 !important;
    box-sizing:border-box !important;
  }

  /* Emoji is a separate, bounded surface below the input row.
     35dvh / 280px matches the compact WhatsApp-like proportion and leaves
     enough conversation visible on small iPhone screens. */
  .chat-input-zone.v3518-emoji-surface > #emojiPanel.v3518-emoji-open{
    order:2 !important;
    position:relative !important;
    flex:0 0 min(35dvh,280px) !important;
    width:100% !important;
    height:min(35dvh,280px) !important;
    max-height:min(35dvh,280px) !important;
    min-height:220px !important;
    margin:0 !important;
    padding:0 !important;
    display:flex !important;
    flex-direction:column !important;
    overflow:hidden !important;
    visibility:visible !important;
    opacity:1 !important;
    transform:none !important;
    z-index:2147 !important;
    box-sizing:border-box !important;
    border-radius:18px 18px 0 0 !important;
    background:#111b21 !important;
    box-shadow:0 -6px 22px rgba(0,0,0,.20) !important;
  }

  .chat-input-zone.v3518-emoji-surface > #emojiPanel.v3518-emoji-open .zalo-popup-tabs{
    order:1 !important;
    flex:0 0 40px !important;
    height:40px !important;
    min-height:40px !important;
    padding:2px 10px !important;
    box-sizing:border-box !important;
  }

  .chat-input-zone.v3518-emoji-surface > #emojiPanel.v3518-emoji-open .emoji-content-tab{
    order:2 !important;
    flex:1 1 auto !important;
    min-height:0 !important;
    overflow:auto !important;
    -webkit-overflow-scrolling:touch !important;
    scrollbar-width:none !important;
  }
  .chat-input-zone.v3518-emoji-surface > #emojiPanel.v3518-emoji-open .emoji-content-tab::-webkit-scrollbar{display:none !important;}

  .chat-input-zone.v3518-emoji-surface > #emojiPanel.v3518-emoji-open .emoji-grid{
    grid-template-columns:repeat(8,minmax(0,1fr)) !important;
    gap:0 !important;
    padding:4px 6px 6px !important;
    max-height:none !important;
    overflow:visible !important;
  }
  .chat-input-zone.v3518-emoji-surface > #emojiPanel.v3518-emoji-open .emoji-cell{
    height:38px !important;
    min-height:38px !important;
    font-size:24px !important;
    line-height:38px !important;
    display:flex !important;
    align-items:center !important;
    justify-content:center !important;
    border-radius:8px !important;
  }

  /* Remove only the unused old footer/category strip under the emoji grid. */
  .chat-input-zone.v3518-emoji-surface > #emojiPanel.v3518-emoji-open .zalo-popup-footer{
    display:none !important;
  }

  /* Keyboard state: no emoji layer, only the same composer row above native keyboard. */
  .chat-input-zone.v3518-keyboard-surface > #emojiPanel{
    display:none !important;
  }

  .chat-input-zone.v3518-keyboard-surface{
    bottom:var(--v3518-keyboard-offset,0px) !important;
  }

  /* Preserve the existing message renderer. This is only a scroll-viewport
     inset so the last rendered message is not hidden behind the fixed composer. */
  #chatMainContainer.mobile-active #chatWindow.v3518-composer-inset,
  body.mobile-chat-focus #chatWindow.v3518-composer-inset{
    padding-bottom:var(--v3518-composer-inset,0px) !important;
    box-sizing:border-box !important;
  }

  :root[data-theme="light"] .chat-input-zone.v3518-emoji-surface > #emojiPanel.v3518-emoji-open,
  body[data-theme="light"] .chat-input-zone.v3518-emoji-surface > #emojiPanel.v3518-emoji-open{
    background:#f0f2f5 !important;
  }
}
