/* NOMI · mobile-only messenger composer · 2026-10-20.
   Touchscreen tablets use the same keyboard-safe editor; desktops stay unchanged. */
@media (max-width: 800px), (pointer: coarse) and (max-width: 1280px) {
  /* The conversation already has a participant header. Save the limited
     phone viewport for actual messages, especially above the keyboard. */
  body.nomi-chat-fixed-layout #nomiMessenger.nomi-mobile-thread-open > h2,
  body.nomi-chat-fixed-layout #nomiMessenger.nomi-mobile-thread-open > #nomiChatCustomizer {
    display: none !important;
  }

  #nomiMessenger #nomiSendForm.nomi-mobile-composer {
    display: grid !important;
    grid-template-columns: 34px minmax(0, 1fr) 34px;
    align-items: end !important;
    gap: 4px !important;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding: 3px 3px max(3px, env(safe-area-inset-bottom)) !important;
    border: 1px solid rgba(171, 116, 217, .55);
    border-radius: 13px;
    background: #20112f;
    box-shadow: 0 -3px 16px rgba(15, 7, 30, .20);
  }

  #nomiMessenger #nomiSendForm.nomi-mobile-composer .nomi-mobile-compose-editor {
    min-width: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
    border: 2px solid #ba8be5;
    border-radius: 12px;
    background: #190d2a;
    transition: border-color 140ms ease;
  }
  #nomiMessenger #nomiSendForm.nomi-mobile-composer .nomi-mobile-compose-editor:focus-within {
    border-color: #e0b9ff;
  }
  #nomiMessenger #nomiSendForm.nomi-mobile-composer #nomiMessageText {
    box-sizing: border-box !important;
    display: block;
    flex: 0 0 auto !important;
    width: 100% !important;
    min-width: 0 !important;
    min-height: 38px !important;
    max-height: 98px !important;
    height: 38px !important;
    margin: 0 !important;
    padding: 6px 9px 1px !important;
    border: 0 !important;
    border-radius: 0 !important;
    outline: none;
    background: transparent !important;
    color: #fff !important;
    font-size: 16px !important;
    font-weight: 400 !important;
    line-height: 1.38 !important;
    letter-spacing: normal;
    resize: none !important;
    overflow-y: hidden;
    overflow-x: hidden;
    overflow-wrap: anywhere;
    -webkit-text-size-adjust: 100%;
  }
  #nomiMessenger #nomiMessageText::placeholder {
    color: #bfb2cd;
    opacity: 1;
  }
  #nomiMessenger #nomiSendForm.nomi-mobile-composer .nomi-mobile-compose-tools {
    box-sizing: border-box;
    display: flex;
    gap: 7px;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 27px;
    padding: 0 6px 2px;
  }
  #nomiMessenger #nomiSendForm.nomi-mobile-composer #nomiEmojiToggle,
  #nomiMessenger #nomiSendForm.nomi-mobile-composer #nomiVoiceToggle {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    flex: 0 0 28px !important;
    width: 28px !important;
    min-width: 28px !important;
    height: 28px !important;
    min-height: 28px !important;
    padding: 0 !important;
    border-radius: 10px !important;
    font-size: 20px !important;
    background: #36214e;
  }
  #nomiMessenger #nomiSendForm.nomi-mobile-composer #nomiAttachToggle,
  #nomiMessenger #nomiSendForm.nomi-mobile-composer #nomiSendButton {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    flex: 0 0 34px !important;
    width: 34px !important;
    min-width: 34px !important;
    height: 40px !important;
    min-height: 40px !important;
    margin: 0 0 1px !important;
    padding: 0 !important;
    border-radius: 14px !important;
    font-size: 20px !important;
    touch-action: manipulation;
  }
  #nomiMessenger #nomiSendForm.nomi-mobile-composer #nomiAttachToggle {
    color: #f3d9ff;
    background: #382250;
    border: 1px solid #795597;
    font-size: 24px !important;
    font-weight: 300;
  }
  #nomiMessenger #nomiSendForm.nomi-mobile-composer #nomiSendButton {
    color: #fff;
    background: linear-gradient(135deg,#9148ca,#b23bcd);
    box-shadow: 0 3px 12px rgba(117, 41, 170, .28);
  }
  #nomiMessenger #nomiSendForm.nomi-mobile-composer button:focus-visible {
    outline: 2px solid #eed0ff;
    outline-offset: 2px;
  }
  /* Important: the picker is a flex child of the thread.
     flex-shrink previously collapsed its rows into a thin strip. Keep a
     real scrollable height above the composer instead of hiding emojis. */
  body.nomi-chat-fixed-layout #nomiMessenger.nomi-mobile-thread-open #nomiThread #nomiEmojiPanel:not([hidden]) {
    display: block !important;
    box-sizing: border-box;
    flex: 0 0 auto !important;
    height: min(225px, 34dvh) !important;
    min-height: min(140px, 24dvh) !important;
    max-height: min(225px, 34dvh) !important;
    width: 100%;
    min-width: 0;
    margin: 4px 0 2px !important;
    overflow-x: hidden;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    padding: 7px 8px 9px;
    border: 1px solid #8457a6;
    border-radius: 14px;
    background: #261637;
    scrollbar-width: thin;
  }
  body.nomi-chat-fixed-layout #nomiMessenger #nomiEmojiPanel .nomi-emoji-tabs {
    position: sticky;
    top: -7px;
    z-index: 2;
    display: flex;
    gap: 5px;
    width: 100%;
    min-height: 39px;
    padding: 4px 0 7px;
    overflow-x: auto;
    overflow-y: hidden;
    background: #261637;
    scrollbar-width: none;
  }
  body.nomi-chat-fixed-layout #nomiMessenger #nomiEmojiPanel .nomi-emoji-tabs button {
    flex: 0 0 auto;
    min-height: 30px;
    white-space: nowrap;
  }
  body.nomi-chat-fixed-layout #nomiMessenger #nomiEmojiPanel .nomi-emoji-grid {
    display: grid !important;
    width: 100%;
    min-width: 0;
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)) !important;
    grid-auto-rows: 43px;
    align-items: center;
    gap: 5px;
    padding-block: 3px 8px;
  }
  body.nomi-chat-fixed-layout #nomiMessenger #nomiEmojiPanel .nomi-emoji-grid button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 40px !important;
    height: 40px;
    padding: 3px !important;
    font-size: 25px !important;
    line-height: 1;
    touch-action: manipulation;
  }
  body.nomi-chat-fixed-layout #nomiMessenger #nomiReplyPreview:not([hidden]),
  body.nomi-chat-fixed-layout #nomiMessenger #nomiAttachPreview:not([hidden]) {
    flex: 0 0 auto;
    max-height: 100px;
    overflow-y: auto;
  }
}
@media (max-width: 350px) {
  #nomiMessenger #nomiSendForm.nomi-mobile-composer {
    grid-template-columns: 32px minmax(0, 1fr) 32px;
    gap: 5px !important;
    padding-inline: 3px !important;
  }
  #nomiMessenger #nomiSendForm.nomi-mobile-composer #nomiAttachToggle,
  #nomiMessenger #nomiSendForm.nomi-mobile-composer #nomiSendButton {
    width: 32px !important;
    min-width: 32px !important;
    height: 40px !important;
    min-height: 40px !important;
  }
}

/* QA 2026-11-01: one-line compact composer, larger visible Send target. Retain original buttons & listeners. */
@media (max-width:800px), (pointer:coarse) and (max-width:1280px) {
  #nomiMessenger #nomiSendForm.nomi-mobile-composer {
    grid-template-columns:42px minmax(0,1fr) 44px !important;
    gap:6px !important;
    align-items:center !important;
    padding:4px !important;
  }
  #nomiMessenger #nomiSendForm.nomi-mobile-composer .nomi-mobile-compose-editor {
    display:block;
    position:relative;
    min-height:44px;
    border-width:1.5px;
    border-radius:14px;
    overflow:hidden;
  }
  #nomiMessenger #nomiSendForm.nomi-mobile-composer #nomiMessageText {
    min-height:44px !important;
    padding:9px 70px 6px 10px !important;
    line-height:1.3 !important;
  }
  #nomiMessenger #nomiSendForm.nomi-mobile-composer .nomi-mobile-compose-tools {
    position:absolute;
    top:5px;
    right:5px;
    width:auto;
    height:34px;
    min-height:0;
    gap:2px;
    padding:0;
    justify-content:flex-end;
    background:transparent;
  }
  #nomiMessenger #nomiSendForm.nomi-mobile-composer #nomiEmojiToggle,
  #nomiMessenger #nomiSendForm.nomi-mobile-composer #nomiVoiceToggle {
    width:30px !important;
    min-width:30px !important;
    height:32px !important;
    min-height:32px !important;
    padding:0 !important;
    font-size:19px !important;
    border-radius:9px !important;
    background:transparent;
    box-shadow:none;
  }
  #nomiMessenger #nomiSendForm.nomi-mobile-composer #nomiAttachToggle,
  #nomiMessenger #nomiSendForm.nomi-mobile-composer #nomiSendButton {
    min-height:44px !important;
    height:44px !important;
    margin:0 !important;
    border-radius:12px !important;
    flex-shrink:0;
  }
  #nomiMessenger #nomiSendForm.nomi-mobile-composer #nomiAttachToggle {
    width:42px !important;
    min-width:42px !important;
  }
  #nomiMessenger #nomiSendForm.nomi-mobile-composer #nomiSendButton {
    display:inline-flex !important;
    width:44px !important;
    min-width:44px !important;
    justify-content:center;
    font-size:25px !important;
    background:linear-gradient(120deg,#8431db,#bd1fff);
    border:1px solid #dc64ff;
    box-shadow:0 0 10px #a42cef88;
  }
}
@media(max-width:350px) {
  #nomiMessenger #nomiSendForm.nomi-mobile-composer {
    grid-template-columns:38px minmax(0,1fr) 42px !important;
    gap:4px !important;
  }
  #nomiMessenger #nomiSendForm.nomi-mobile-composer #nomiAttachToggle {
    width:38px !important;
    min-width:38px !important;
  }
  #nomiMessenger #nomiSendForm.nomi-mobile-composer #nomiSendButton {
    width:42px !important;
    min-width:42px !important;
  }
}
