/* v1503: the modal frame owns clipping; the header can never paint square corners. */
.modal .dialog {
  display: flex !important;
  flex-direction: column;
  overflow: hidden !important;
  border-radius: 28px !important;
  background-clip: padding-box;
  isolation: isolate;
  transform: translateZ(0);
  contain: paint;
}

.modal .dialog-head {
  flex: 0 0 auto;
  border-radius: 27px 27px 0 0;
  overflow: hidden !important;
  background-clip: padding-box;
}

.modal .dialog > .form {
  min-height: 0;
  overscroll-behavior: contain;
}

/* Keep the lead form unobstructed and focus-safe while any homepage modal is open. */
body:has(.modal.open) .nl-chat-widget {
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

@media (max-height: 820px), (max-width: 960px) {
  .modal .dialog {
    max-height: calc(100dvh - 28px) !important;
  }

  .modal .dialog > .form {
    overflow-y: auto;
  }
}

@media (max-width: 620px) {
  .modal {
    padding: 8px !important;
  }

  .modal .dialog {
    width: 100% !important;
    max-height: calc(100dvh - 16px) !important;
    border-radius: 20px !important;
  }

  .modal .dialog-head {
    border-radius: 19px 19px 0 0;
  }
}
