/* Keep admin dialogs inside the viewport and let long content scroll. */
.modal-layer,
.rss-modal-backdrop,
.task-del-modal-backdrop {
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  align-items: flex-start;
  justify-content: safe center;
  max-height: 100dvh;
}

/* React dialogs and later admin panels share the same viewport boundary. */
.modal-layer > [role="dialog"],
.modal-layer > section,
.rss-modal-backdrop > [role="dialog"],
.task-del-modal-backdrop > [role="dialog"] {
  max-width: calc(100vw - 24px);
  max-width: calc(100dvw - 24px);
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px);
  min-width: 0;
  min-height: 0;
  overflow-x: auto;
  overflow-y: auto;
  box-sizing: border-box;
  overscroll-behavior: contain;
}

.modal-layer > .request-modal,
.modal-layer > .action-modal,
.modal-layer > .code-result-modal,
.modal-layer > .planner-modal,
.rss-modal-card,
.task-del-modal-card {
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  box-sizing: border-box;
  margin-block: auto;
}

.modal-layer > .action-modal {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.action-modal .modal-heading {
  min-height: 0;
}

.rss-modal-card {
  display: flex;
  flex-direction: column;
}

.rss-modal-body {
  min-height: 0;
  overscroll-behavior-y: contain;
}

@media (max-width: 600px) {
  .modal-layer,
  .rss-modal-backdrop,
  .task-del-modal-backdrop {
    padding: 12px;
  }

  .modal-layer > .request-modal,
  .modal-layer > .action-modal,
  .modal-layer > .code-result-modal,
  .modal-layer > .planner-modal,
  .rss-modal-card,
  .task-del-modal-card {
    width: 100%;
    max-width: 100%;
  }
}
