/* Portalled forms must be centred in the visible area above the touch keyboard. */
@media screen and (max-width:1180px) and (pointer:coarse) {
  .eco-cash-modal-backdrop, .eco-cash-picker-backdrop, .eco-finance-modal-backdrop,
  .pd-extra-overlay, .m2-overlay, [class*="_popupOverlay_"],
  .fixed.inset-0:has(.pt-tile), .fixed.inset-0:has(.m2-modal) {
    top:var(--keyboard-viewport-top,var(--crm-viewport-top,0px)) !important;
    bottom:auto !important;
    height:var(--keyboard-viewport-height,var(--crm-viewport-height,100dvh)) !important;
    max-height:var(--keyboard-viewport-height,var(--crm-viewport-height,100dvh)) !important;
    box-sizing:border-box;
  }
  .eco-cash-modal, .eco-cash-picker, .eco-finance-modal, .m2-modal, .pt-tile {
    max-height:calc(var(--keyboard-viewport-height,var(--crm-viewport-height,100dvh)) - 24px) !important;
    min-height:0;
  }
  .eco-cash-modal-backdrop, .eco-cash-picker-backdrop { padding:12px !important; }
  .eco-cash-picker { display:flex; flex-direction:column; }
  .eco-cash-picker > input { flex-shrink:0; }
  .eco-cash-picker-list { min-height:0; overflow-y:auto; }
  .eco-finance-modal form, .m2-modal .m2-body, .m2-modal .m2-fields { min-height:0; overflow-y:auto; }
}

/* Native staff dialogs otherwise remain centred behind the software keyboard. */
@media screen and (max-width:1180px) and (pointer:coarse) {
  :root[data-crm-keyboard] .staff-dialog[open],
  :root[data-crm-keyboard] .driver-message-dialog[open] {
    top:calc(var(--keyboard-viewport-top,var(--crm-viewport-top,0px)) + 12px) !important;
    bottom:auto !important;
    margin:0 auto !important;
    max-height:calc(var(--keyboard-viewport-height,var(--crm-viewport-height,100dvh)) - 24px) !important;
    overflow-y:auto;
  }
  :root[data-crm-keyboard] .staff-dialog form {
    max-height:calc(var(--keyboard-viewport-height,var(--crm-viewport-height,100dvh)) - 26px) !important;
  }
}
