/* Mobile / touch layer, loaded last.
   - no zoom: inputs are 16 px (no iOS focus zoom), double-tap zoom is off via touch-action (pinch zoom stays available), no scale() entrances;
   - hairline borders on every region, bottom sheets for menus and dialogs, safe-area insets, keyboard-aware chat pane, 44 px tap targets, landscape. */
html { touch-action: manipulation; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
.msg, .bub, .conv, .chip, label, summary { touch-action: manipulation; }
.thread, .conv-list, .dr-nav, .i-scroll, .dlg-body, .pop, .search-results, .captions { overscroll-behavior: contain; }
.hd-name, .c-name, .i-name, .dr-profile .nm, .sr-name { overflow-wrap: anywhere; }

@media (max-width: 899px), (pointer: coarse) {
  /* inputs: 16 px keeps iOS Safari from zooming the page on focus */
  input, textarea, select, .input, .cta, .search-field input { font-size: 16px; }
  .btn { height: 44px; } .btn.sm { height: 40px; }
  .menu-item { height: 44px; } .react-opt { width: 44px; height: 44px; } .emo { width: 40px; height: 40px; }
  .dr-item { height: 52px; }
  .hd-pair > button { min-height: 36px; position: relative; } .hd-pair > button::after { content: ""; position: absolute; inset: -4px -2px; }
  .rchip, .vp-speed { position: relative; } .rchip::after, .vp-speed::after { content: ""; position: absolute; inset: -10px -4px; }
  .lbtn { min-height: 24px; }
  .ibtn:active:not(:disabled) { transform: scale(.97); }
  .onb-icon, .onb-switch, .onb-lang { height: 44px; } .onb-icon { width: 44px; }
  .onb-seg-i, .onb-link, .onb-back { height: 44px; }
  .onb-inline { padding: 12px 6px; margin: -12px -6px; }
  .check { min-height: 44px; align-items: center; }
  .chip::after { content: ""; position: absolute; inset: -4px 0; } .hd-main { min-height: 44px; }
  .vp-play { width: 44px; height: 44px; } .emo { width: 44px; height: 44px; }
  .lbtn::after { inset: -12px -8px; } .vp-speed::after { inset: -12px -8px; }
  .switch::after { } .switch { position: relative; } .switch::before { content: ""; position: absolute; inset: -10px -4px; }
  .seg > button { position: relative; } .seg > button::after { content: ""; position: absolute; inset: -4px 0; }
  .i-act { height: 44px; } .t-act { padding: 11px 8px 13px; margin: -12px -8px; }   /* hit area 44px, label optically level with the message */
  .seg > button { height: 36px; } .btn.sm { height: 44px; }

  /* entrances slide / fade, never zoom in */
  @keyframes pop-in { from { opacity: 0; transform: translateY(6px); } }
  @keyframes msg-mine { from { opacity: 0; transform: translateY(12px); } }
  @keyframes rpop { 0% { opacity: 0; transform: translateY(4px); } 100% { opacity: 1; transform: none; } }
  @keyframes icon-in { from { opacity: 0; } }
  .msbtn .ms-send, .msbtn.has-text .ms-mic, .cbar.recording .msbtn .ms-mic { transform: none; }
  .onb-done { transform: translateY(10px); } .onb-done.on { transform: none; }
  .lm-dot { transform: none; }
}

@media (max-width: 899px) {
  /* hairlines: strip under the head, list rows inset past the avatar, sheets and cards outlined */
  .rail { border-right: 0; box-shadow: none; border-bottom: 1px solid var(--sep); }
  .sb-head { border-bottom: 0; padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
  .rail { padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
  .conv-list { padding: 0 max(4px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(4px, env(safe-area-inset-left)); }
  .conv::after { content: ""; position: absolute; left: 76px; right: 10px; bottom: 0; border-bottom: 1px solid var(--line); }
  .conv.active::after, .conv:last-child::after { display: none; }
  .i-head { border-bottom: 1px solid var(--sep); }

  /* chat pane tracks the visible viewport (on-screen keyboard), see nav.js */
  .chat-pane { top: var(--vvt, 0px); bottom: auto; height: var(--vvh, 100dvh); }
  .chat-card { height: 100%; padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
  .composer-wrap { padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  .chat-head { padding-left: max(4px, env(safe-area-inset-left)); padding-right: max(8px, env(safe-area-inset-right)); }

  /* menus and dialogs: bottom sheets with a handle */
  .sheet-scrim { position: fixed; inset: 0; z-index: 309; background: var(--scrim); animation: fade-in 200ms both; }
  .pop.sheet { left: 0; right: 0; top: auto; bottom: 0; width: 100%; min-width: 0; max-width: none; border-radius: 16px 16px 0 0; padding: 22px 8px calc(10px + env(safe-area-inset-bottom)); max-height: min(70dvh, 560px); overflow-y: auto; box-shadow: 0 0 0 1px var(--line); animation: sheet-in 240ms var(--ease) both; }
  .pop.sheet::before, dialog.dlg::before { content: ""; position: absolute; top: 8px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: 2px; background: var(--field-line); }
  .pop.sheet .react-bar { justify-content: space-around; }
  .pop.sheet.emoji-pop .emoji-grid { grid-template-columns: repeat(7, 1fr); justify-items: center; } .pop.sheet .emo { width: 100%; max-width: 44px; }
  dialog.dlg { position: fixed; margin: auto 0 0; width: 100%; max-width: none; border-radius: 16px 16px 0 0; border-bottom: 0; max-height: calc(100dvh - 24px - env(safe-area-inset-top)); padding-bottom: env(safe-area-inset-bottom); }
  dialog.dlg.small { width: 100%; }
  dialog.dlg[open] { animation: sheet-in 240ms var(--ease) both; }
  dialog.dlg .dlg-head { padding-top: 22px; }
  dialog.settings-dlg { height: calc(100dvh - 48px - env(safe-area-inset-top)); }
  .dlg-foot { padding-bottom: 16px; }
  @keyframes sheet-in { from { opacity: 0; transform: translateY(24px); } }
  .call-card { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
}

/* landscape phones: one-row chat header, tighter paddings */
@media (max-width: 899px) and (max-height: 500px) {
  .chat-head { grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "l p a"; min-height: 52px; padding-top: calc(4px + env(safe-area-inset-top)); padding-bottom: 4px; gap: 8px; }
  .hd-pair { margin-bottom: 0; }
  .thread-inner { padding-top: 6px; }
  .composer-wrap { padding-top: 6px; padding-bottom: calc(6px + env(safe-area-inset-bottom)); }
  .sb-head { padding-top: calc(6px + env(safe-area-inset-top)); padding-bottom: 6px; }
  .onb-main { padding-top: 0; }
}
@media (max-width: 899px), (pointer: coarse) { .dr-item .kbd { display: none; } }   /* keyboard hints make no sense on phones */
@media (max-width: 899px) { .chip .n.soft { background: transparent; color: var(--t3); } }
