html.is-embed {
	height: initial;
	overflow: hidden;
}

.is-embed body {
	height: initial;
	padding-bottom: 30px;
	overflow: hidden;
}

.is-embed #mainSectionWrapper {
	height: initial;
	min-height: initial;
}

.is-embed #mainSectionPadding {
	padding-bottom: 0px;
}

.is-embed #footer {
	display: none;
}

.is-embed .zopim {
	display: none;
}

.is-embed .qsArticle {
	width: initial;
	padding-right: 0px;
}

@media (max-width: 768px) {

	/* spacing */
	.is-embed .qsArticle {
		padding-left: 16px;
		padding-right: 16px;
	}

	/* header stack (logo above title) */
	.is-embed .cpwTable,
	.is-embed .cpwTable tbody,
	.is-embed .cpwTable tr {
		display: flex;
		flex-direction: column;
		width: 100%;
	}

	.is-embed .cpwTable td {
		display: block;
		width: 100% !important;
	}

	.is-embed .cpwTable td:has(.qs-logo) {
		order: 0;
	}

	.is-embed .cpwTable td:has(.pageHeaderWidget) {
		order: 1;
	}

	/* header left alignment */
	.is-embed .cpwTable .imageWidget {
		float: left !important;
	}

	.is-embed .cpwTable .pre-wrap {
		float: left !important;
	}

	/* logo sizing */
	.is-embed .qs-logo {
		display: block;
		margin: 0 0 8px 0;
		text-align: left;
	}

	.is-embed .qs-logo img {
		max-width: 40vw !important;
		max-height: none !important;
		height: auto;
	}

	/* gap between school name and form title */
	.is-embed .qs-school-name {
		display: block;
		text-align: left !important;
		float: none !important;
		margin-top: 8px;
		margin-bottom: 60px;
	}

	/* form title area: title first, actions second (under title) */
	.is-embed .recordHeaderWidget table,
	.is-embed .recordHeaderWidget table tbody,
	.is-embed .recordHeaderWidget table tr {
		display: flex;
		flex-direction: column;
		width: 100%;
	}

	.is-embed .recordHeaderWidget table td {
		display: block;
		width: 100% !important;
	}

	.is-embed .recordHeaderWidget table td.icon {
		display: none;
	}

	.is-embed .recordHeaderWidget table td:has(h1) {
		order: 1;
	}

	.is-embed .recordHeaderWidget table td:has(.buttonPanelWidget) {
		order: 2;
		margin-top: 32px;
		text-align: left;
	}

	/* --- critical override: keep the two action buttons on the same row --- */
	/* revert the inner table/tr/td inside .buttonPanelWidget back to table layout */
	.is-embed .recordHeaderWidget .buttonPanelWidget table,
	.is-embed .recordHeaderWidget .buttonPanelWidget table tr {
		display: table !important;
		width: auto !important;
	}

	.is-embed .recordHeaderWidget .buttonPanelWidget table td {
		display: table-cell !important;
		width: auto !important;
		vertical-align: middle;
	}

	/* keep original button sizing (no full-width on mobile) */
	.is-embed .recordHeaderWidget .buttonPanelWidget .allButtons {
		width: auto !important;
		margin: 0;
	}

	.is-embed .buttonPanelWidget {
		margin-left: 0px !important;
		float: left !important;
	}

	.is-embed .pageHeaderWidget .bottom {
		margin-bottom: 24px !important;
	}

	@media (max-width: 576px) {

		/* stack label and input */
		.is-embed .qpwTable,
		.is-embed .qpwTable tr,
		.is-embed .qpwTable td {
			display: block;
			width: 100% !important;
		}

		/* make input area full width */
		.is-embed .qpwTable .tableValue,
		.is-embed .qpwTable .tableValue textarea {
			width: 100% !important;
			box-sizing: border-box;
			/* ensure padding doesn't overflow */
		}

		/* add spacing below field */
		.is-embed .qpwTable .tableValue {
			margin-bottom: 12px;
		}
	}

	/* Detect if there are 3 columns (buttons) in the row. If so, switch to flex layout to allow wrapping */
	.is-embed .recordHeaderWidget .buttonPanelWidget table tr:has(td:nth-child(3)) {
		display: flex !important;
		flex-wrap: wrap;
		justify-content: flex-end;
		/* Align all buttons (and rows of buttons) to the right */
	}

	/* Force the cell elements to behave like blocks/flex-items instead of table cells */
	.is-embed .recordHeaderWidget .buttonPanelWidget table tr:has(td:nth-child(3)) td {
		display: block !important;
		width: auto !important;
		/* fallback */
		width: fit-content !important;
		/* Ensure they don't take full width */
		flex: 0 1 auto !important;
		/* Allow shrinking but start at auto width */
	}

	/* Target the first button (Copy from Previous) and make it take full width so the next buttons drop down */
	.is-embed .recordHeaderWidget .buttonPanelWidget table tr:has(td:nth-child(3)) td:first-child {
		width: 100% !important;
		flex: 1 0 100% !important;
		text-align: right;
		/* Ensure the button text/element is aligned to the right */
		padding-bottom: 8px;
		/* Add some spacing between the top button and the bottom row */
		padding-left: 0;
		/* Add some spacing between the top button and the bottom row */
	}

	/* Remove padding-right for button columns in 3-button layout on mobile to ensure alignment */
	.is-embed .recordHeaderWidget .buttonPanelWidget table tr:has(td:nth-child(3)) td.col {
		padding-right: 0 !important;
	}
}