/* Geometry only: preserve each existing popup's appearance, actions and effects. */
:root{--popup-viewport-height:100dvh;--popup-viewport-width:100vw;--popup-viewport-top:0px;--popup-viewport-left:0px;--popup-viewport-bottom:0px}
html body dialog:is(.aa-dialog,.payment-dialog,.deposit-guide-dialog,.ftx-purchaseModal,.media-viewer){
 box-sizing:border-box;min-width:0;min-height:0;
 max-width:calc(var(--popup-viewport-width) - 24px)!important;
 max-height:calc(var(--popup-viewport-height) - 24px)!important;
 inset-block-start:var(--popup-viewport-top);inset-block-end:var(--popup-viewport-bottom);
 overscroll-behavior:contain;
}
html body dialog:is(.aa-dialog,.payment-dialog,.deposit-guide-dialog,.ftx-purchaseModal){overflow:auto}
html body dialog:is(.aa-dialog,.payment-dialog,.deposit-guide-dialog,.ftx-purchaseModal) fieldset{min-inline-size:0}
html body dialog:is(.aa-dialog,.payment-dialog,.deposit-guide-dialog,.ftx-purchaseModal) :is(input,select,textarea){max-width:100%;box-sizing:border-box}
html body .payment-dialog .payment-dialog-scroll{max-height:none;overflow:visible}
html body .media-viewer-content:not(:fullscreen){min-height:0;overflow:auto}
html body .media-viewer-content:not(:fullscreen) .media-viewer-stage :is(img,video){height:auto;max-height:max(80px,calc(var(--popup-viewport-height) - 156px));object-fit:contain}
html body .media-viewer header{flex-wrap:wrap}
/* SweetAlert order review, close review, cancellation and PnL detail. */
html body .swal2-container{top:var(--popup-viewport-top);bottom:var(--popup-viewport-bottom);height:auto;overflow-y:auto}
html body .swal2-popup{
 box-sizing:border-box;min-width:0;min-height:0;
 max-width:calc(var(--popup-viewport-width) - 24px)!important;
 max-height:calc(var(--popup-viewport-height) - 24px)!important;overflow:auto;
}
html body .swal2-html-container{min-width:0;overflow-wrap:anywhere}
html body .swal2-actions{flex-wrap:wrap}
/* The leverage modal keeps its current structure and keyboard handler. */
html body #ftxPage #ftxLevModal{top:var(--popup-viewport-top)!important;bottom:var(--popup-viewport-bottom)!important;height:auto!important}
html body #ftxPage #ftxLevModal .ftx-modalBox{box-sizing:border-box;min-height:0;max-width:calc(var(--popup-viewport-width) - 32px)!important;max-height:calc(var(--popup-viewport-height) - 32px)!important;overflow:auto}
html body #ftxPage[data-app-terminal] .app-order-sheet.is-open{max-height:calc(var(--popup-viewport-height) - 16px)!important}
/* Keep the chat composer reachable while the keyboard or browser chrome resizes. */
html body #chat-widget-root .member-chat-dialog{box-sizing:border-box;min-height:0;max-width:calc(var(--popup-viewport-width) - 24px)!important;max-height:calc(var(--popup-viewport-height) - 100px)!important;bottom:calc(var(--popup-viewport-bottom) + 80px)!important}
html body #chat-widget-root .member-chat-title{flex-shrink:0}
@media(max-width:600px){html body #chat-widget-root .member-chat-dialog{max-height:calc(var(--popup-viewport-height) - 24px)!important;bottom:calc(var(--popup-viewport-bottom) + 12px)!important}}
/* Anchored panels use the space below their real opening position. */
html body :is([data-header-panel],#member-notice-panel),html body #ftxPage #ftxSymMenu{box-sizing:border-box;max-width:calc(var(--popup-viewport-width) - 24px)!important;max-height:var(--popup-panel-space,calc(var(--popup-viewport-height) - 100px))!important;overflow-y:auto!important;overscroll-behavior:contain}
