/* Scoped to .mp-modal only — does not affect theme/Bootstrap .btn-close on other modals. */

.mp-modal {
	--mp-offset-top: 1.25rem;
	position: fixed;
	inset: 0;
	z-index: 1040;
	display: flex;
	justify-content: center;
	padding: var(--mp-offset-top, 1.25rem) 1.25rem 2rem;
	isolation: isolate;
}

.mp-modal--align-top {
	align-items: flex-start;
}

.mp-modal--align-center {
	align-items: center;
}

.mp-modal[hidden] {
	display: none !important;
}

.mp-modal.is-open {
	display: flex;
	z-index: 1060;
}

.mp-modal__overlay {
	position: absolute;
	inset: 0;
	z-index: 0;
	background: rgba(0, 0, 0, 0.55);
}

.mp-modal__shell {
	position: relative;
	z-index: 1;
	display: flex;
	flex-direction: column;
	align-items: stretch;
	width: min(1040px, 100%);
	max-height: min(90vh, 720px);
	overflow: hidden;
}

.mp-layout-split .mp-modal__shell {
	height: min(90vh, 720px);
	min-height: min(90vh, 720px);
	max-height: min(90vh, 720px);
}

.mp-modal .mp-modal__header {
	display: flex;
	justify-content: flex-end;
	align-items: stretch;
	align-self: flex-end;
	margin: 0;
	padding: 0;
	background: #fff;
	border: 0;
	width: auto;
	flex: 0 0 auto;
	position: relative;
	z-index: 2;
}

.mp-modal .mp-modal__header button.mp-modal__close {
	box-sizing: border-box;
	background: #fff !important;
	background-color: #fff !important;
	background-image: none !important;
	filter: none;
	margin: 0 0 0 auto;
	border-radius: 0;
	opacity: 1;
	border: 0 !important;
	border-width: 0 !important;
	outline: none;
	width: auto;
	max-width: none;
	min-width: 0;
	height: auto;
	font-family: inherit;
	font-size: 18px;
	line-height: 1.2;
	padding: 10px 30px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	color: #000 !important;
	cursor: pointer;
	appearance: none;
	box-shadow: none !important;
	font-weight: 400;
	-webkit-tap-highlight-color: transparent;
	flex: 0 0 auto;
	text-transform: none;
	letter-spacing: normal;
}

.mp-modal .mp-modal__header button.mp-modal__close::before,
.mp-modal .mp-modal__header button.mp-modal__close::after {
	content: none !important;
	display: none !important;
	background: none !important;
}

.mp-modal .mp-modal__header button.mp-modal__close:hover,
.mp-modal .mp-modal__header button.mp-modal__close:focus,
.mp-modal .mp-modal__header button.mp-modal__close:active {
	background: #fff !important;
	background-color: #fff !important;
	background-image: none !important;
	color: #000 !important;
	opacity: 1;
	border: 0 !important;
	outline: none;
	box-shadow: none !important;
}

.mp-modal .mp-modal__header button.mp-modal__close:focus:not(:focus-visible) {
	outline: none;
	box-shadow: none !important;
	border: 0 !important;
}

.mp-modal .mp-modal__header button.mp-modal__close:focus-visible {
	background: #fff !important;
	background-color: #fff !important;
	outline: 2px solid #000;
	outline-offset: 2px;
	box-shadow: none !important;
	border: 0 !important;
}

.mp-modal__close-icon {
	width: 1em;
	height: 1em;
	flex-shrink: 0;
	display: block;
	pointer-events: none;
}

.mp-modal__dialog {
	position: relative;
	width: 100%;
	flex: 1 1 auto;
	min-height: 0;
	overflow: hidden;
	background: #fff;
	border-radius: 0;
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
	padding: 0;
}

.mp-layout-full .mp-modal__dialog {
	overflow: auto;
}

.mp-modal__dialog:focus {
	outline: none;
}

.mp-modal__title {
	margin: 0;
	padding: 0;
	font-size: 1.35rem;
}

.mp-modal__body {
	display: flex;
	flex-wrap: wrap;
	gap: 0;
}

.mp-layout-split .mp-modal__dialog {
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

.mp-layout-split .mp-modal__body {
	flex: 1 1 auto;
	min-height: 0;
	flex-wrap: nowrap;
	align-items: stretch;
	overflow: hidden;
}

.mp-layout-split .mp-modal__col--text {
	flex: 0 0 40%;
	max-width: 40%;
	min-width: 0;
	min-height: 0;
	overflow: hidden;
}

.mp-layout-split .mp-modal__col--form {
	flex: 0 0 60%;
	max-width: 60%;
	min-width: 0;
	min-height: 0;
	align-self: stretch;
	overflow-x: hidden;
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
}

.mp-layout-full .mp-modal__col--full {
	flex: 1 1 100%;
}

/* Scroll the modal layer when content is taller than the viewport (mobile + overflow detection). */
.mp-modal.is-open.mp-modal--page-scroll {
	position: fixed;
	inset: 0;
	width: 100%;
	height: 100%;
	max-height: 100vh;
	max-height: 100dvh;
	display: block;
	overflow-x: hidden;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	overscroll-behavior: contain;
	touch-action: pan-y;
	padding-bottom: 2rem;
}

.mp-modal.is-open.mp-modal--page-scroll .mp-modal__overlay {
	position: fixed;
	inset: 0;
	z-index: 0;
}

.mp-modal.is-open.mp-modal--page-scroll .mp-modal__shell {
	position: relative;
	z-index: 1;
	margin-left: auto;
	margin-right: auto;
	max-height: none;
	height: auto;
	min-height: 0;
	overflow: visible;
}

.mp-modal.is-open.mp-modal--page-scroll .mp-modal__dialog {
	flex: none;
	min-height: auto;
	max-height: none;
	height: auto;
	overflow: visible;
}

.mp-modal--page-scroll.mp-layout-split .mp-modal__shell {
	height: auto;
	min-height: 0;
	max-height: none;
}

.mp-modal--page-scroll.mp-layout-split .mp-modal__dialog {
	overflow: visible;
	display: flex;
	flex-direction: column;
	flex: none;
	min-height: auto;
	height: auto;
}

.mp-modal--page-scroll.mp-layout-full .mp-modal__dialog {
	overflow: visible;
	display: block;
	flex: none;
	min-height: auto;
	height: auto;
}

@media (min-width: 783px) {
	.mp-modal--page-scroll.mp-layout-split .mp-modal__body {
		flex: none;
		min-height: auto;
		height: auto;
		overflow: visible;
		flex-wrap: nowrap;
		align-items: stretch;
	}

	.mp-modal--page-scroll.mp-layout-split .mp-modal__col--text {
		flex: 0 0 40%;
		max-width: 40%;
		min-height: auto;
		height: auto;
		max-height: none;
		overflow: visible;
	}

	.mp-modal--page-scroll.mp-layout-split .mp-modal__col--form {
		flex: 0 0 60%;
		max-width: 60%;
		min-height: auto;
		height: auto;
		max-height: none;
		overflow: visible;
	}
}

@media (max-width: 782px) {
	.mp-modal.is-open {
		position: fixed;
		inset: 0;
		width: 100%;
		height: 100%;
		max-height: 100vh;
		max-height: 100dvh;
		display: block;
		overflow-x: hidden;
		overflow-y: auto;
		-webkit-overflow-scrolling: touch;
		overscroll-behavior: contain;
		touch-action: pan-y;
		padding-bottom: 2rem;
	}

	.mp-modal.is-open .mp-modal__overlay {
		position: fixed;
		inset: 0;
		z-index: 0;
	}

	.mp-modal.is-open .mp-modal__shell {
		position: relative;
		z-index: 1;
		margin-left: auto;
		margin-right: auto;
		max-height: none !important;
		height: auto !important;
		min-height: 0 !important;
		overflow: visible;
	}

	.mp-layout-split .mp-modal.is-open .mp-modal__shell {
		height: auto !important;
		min-height: 0 !important;
		max-height: none !important;
	}

	.mp-layout-split .mp-modal.is-open .mp-modal__dialog {
		overflow: visible;
		display: flex;
		flex-direction: column;
		flex: none;
		min-height: auto;
		max-height: none;
		height: auto;
	}

	.mp-layout-full .mp-modal.is-open .mp-modal__dialog {
		overflow: visible;
		display: block;
		flex: none;
		min-height: auto;
		max-height: none;
		height: auto;
	}

	/* Stack split columns on small viewports only. */
	.mp-modal.mp-layout-split .mp-modal__body,
	.mp-modal.mp-layout-split.is-open .mp-modal__body,
	.mp-modal.mp-layout-split.mp-modal--page-scroll .mp-modal__body {
		display: flex;
		flex-direction: column;
		flex-wrap: nowrap;
		flex: none;
		min-height: auto;
		height: auto;
		overflow: visible;
		align-items: stretch;
	}

	.mp-modal.mp-layout-split .mp-modal__col--text,
	.mp-modal.mp-layout-split .mp-modal__col--form,
	.mp-modal.mp-layout-split.is-open .mp-modal__col--text,
	.mp-modal.mp-layout-split.is-open .mp-modal__col--form,
	.mp-modal.mp-layout-split.mp-modal--page-scroll .mp-modal__col--text,
	.mp-modal.mp-layout-split.mp-modal--page-scroll .mp-modal__col--form {
		flex: 0 0 auto;
		flex-basis: auto;
		max-width: 100%;
		width: 100%;
		min-width: 0;
		min-height: auto;
		height: auto;
		max-height: none;
		overflow: visible;
	}
}

@media (max-height: 640px) and (min-width: 783px) {
	/* Short desktop/laptop windows: allow page scroll, keep side-by-side columns. */
	.mp-modal.is-open.mp-modal--page-scroll {
		overflow-y: auto;
	}
}

body.mp-modal-open:not(.modal-open) {
	overflow: hidden;
}

body.modal-open .mp-modal[hidden] {
	display: none !important;
}