/* EchoMe shared native-dialog viewport positioning */

/* Apply only to modal dialogs, not non-modal page dialogs. */
dialog:modal {
  position: fixed !important;
  inset: 0 !important;
  margin: auto !important;

  box-sizing: border-box !important;

  max-width: calc(100vw - 32px) !important;
  max-height: calc(100dvh - 32px) !important;

  overflow-x: hidden;
  overflow-y: auto;

  overscroll-behavior: contain;
}

/* Keep media within the available viewport. */
dialog:modal img,
dialog:modal video {
  max-width: 100%;
}

/* Respect smaller screens. */
@media (max-width: 480px) {
  dialog:modal {
    max-width: calc(100vw - 20px) !important;
    max-height: calc(100dvh - 20px) !important;
  }
}
