.overlay {
	position: fixed;
	inset: 0;

	z-index: 10;
	background: var(--surface);
	color: var(--ink);
	display: flex;
	flex-direction: column;
	overscroll-behavior: contain;
	touch-action: none;
	outline: none;
}
.overlay__bar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	min-height: 60px;
	padding: 0 8px;
	border-bottom: 1px solid #ece7df;
}
.overlay__title {
	font-family: var(--font-heading);
	font-size: 18px;
	font-weight: 700;
	text-align: center;
	min-width: 0;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.overlay__title small {
	display: block;
	font-size: 13px;
	font-weight: 400;
	color: var(--muted);
	overflow: hidden;
	text-overflow: ellipsis;
}
.overlay__body {
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 14px;
	padding: 16px 20px;
	min-height: 0;
}
.overlay__pad {
	position: relative;
	flex: 1;
	min-height: 160px;
	background: var(--bg);
	border: 1.5px solid var(--line);
	border-radius: var(--radius-lg);
	overflow: hidden;
}
.overlay__pad canvas {
	display: block;
	width: 100%;
	height: 100%;
	touch-action: none;
}
.overlay__baseline {
	position: absolute;
	left: 24px;
	right: 24px;
	bottom: 44px;
	border-top: 1px dashed #b8b0a4;
	pointer-events: none;
}
.overlay__caption {
	position: absolute;
	left: 24px;
	bottom: 18px;
	font-size: 12px;
	color: var(--faint);
	pointer-events: none;
}
.overlay__foot {
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 0 20px 24px;
}

/* Landscape: canvas beside the buttons so the stroke area gets the full width. */
.overlay.is-landscape .overlay__body {
	flex-direction: row;
	padding: 12px 20px 16px;
}
.overlay.is-landscape .overlay__pad {
	flex: 1 1 auto;
}
.overlay.is-landscape .overlay__foot {
	flex: 0 0 170px;
	flex-direction: column;
	justify-content: flex-end;
	padding: 0 0 0 4px;
}
.overlay.is-landscape .overlay__foot .hint {
	display: none;
}
.overlay.is-landscape .overlay__rotate {
	display: none;
}
.overlay.is-rotated .overlay__rotate {
	display: flex;
}

/* Forced landscape while the phone stays in portrait lock: rotate the whole overlay by CSS. */
.overlay.is-rotated {
	width: 100dvh;
	height: 100dvw;
	transform-origin: top left;
	transform: rotate(90deg) translateY(-100%);
}

.overlay__bar {
	padding-left: max(8px, env(safe-area-inset-left));
	padding-right: max(8px, env(safe-area-inset-right));
}
.overlay__body {
	padding-left: max(16px, env(safe-area-inset-left));
	padding-right: max(16px, env(safe-area-inset-right));
	padding-bottom: max(16px, env(safe-area-inset-bottom));
}

/* Full-screen picker for long name and site lists */
.overlay--picker {
	touch-action: auto;
}
.picker__body {
	gap: 8px;
	padding: 12px 16px 0;
}
.picker__search {
	flex: 0 0 auto;
	/* never below 16px: iOS zooms the page in when a focused field has smaller text */
	font-size: 16px;
	min-height: 48px;
}
.picker__status {
	flex: 0 0 auto;
	font-size: 13px;
	color: var(--muted);
}
.picker__list {
	flex: 1;
	min-height: 0;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	overscroll-behavior: contain;
	display: flex;
	flex-direction: column;
	padding-bottom: env(safe-area-inset-bottom, 0px);
}
.picker__row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	width: 100%;
	/* 48px stays above the 44pt Apple asks for, so gloves still hit the right row */
	min-height: 48px;
	padding: 7px 4px;
	text-align: left;
	font: inherit;
	font-size: 16px;
	color: var(--ink);
	background: none;
	border: 0;
	border-bottom: 1px solid var(--line);
}
.picker__row.is-on {
	color: var(--accent);
	font-weight: 600;
}
.picker__text {
	min-width: 0;
}
.picker__name {
	display: block;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
}
.picker__text small {
	display: block;
	margin-top: 1px;
	font-size: 13px;
	font-weight: 400;
	color: var(--muted);
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
}

/* Desktop (mouse): the full-screen views stay as wide as the app. Phones keep the whole
   screen, the landscape signature needs it. margin auto centres a fixed box. */
@media (min-width: 600px) and (pointer: fine) {
	.overlay {
		max-width: var(--app-width);
		margin: 0 auto;
		box-shadow:
			0 0 0 1px var(--line),
			0 12px 40px rgba(31, 28, 24, 0.12);
	}
}
