/* Surface editor frame (html[data-surface-editor]): top bar, framed page, preview, phone layout and password gate. */
@layer module {
html[data-surface-editor],
.surface-gate {
	--se-ink: rgb(29 30 32);
	--se-muted: rgb(95 99 104);
	--se-line: rgb(227 227 232);
	--se-soft: rgb(244 244 247);
	--se-paper: rgb(255 255 255);
	--se-accent: rgb(103 61 230);
	--se-accent-soft: rgb(239 234 253);
	--se-error: rgb(198 40 40);
	--se-ok: rgb(30 123 69);
	--se-r: 8px;
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
	font-size: 14px;
	line-height: 20px;
	color: var(--se-ink);
	letter-spacing: 0;
	text-transform: none;
}
html[data-surface-editor],
html[data-surface-editor] body {
	margin: 0;
	block-size: 100%;
	overflow: hidden;
	background: var(--se-soft);
}
.surface-gate *,
#se-app * {
	box-sizing: border-box;
}
.surface-gate button,
.surface-gate input,
#se-app button,
#se-app input,
#se-app select {
	font: inherit;
	color: inherit;
}
.surface-gate :focus-visible,
#se-app :focus-visible {
	outline: 2px solid var(--se-accent);
	outline-offset: 2px;
}
#se-app button {
	cursor: pointer;
}
#se-app [hidden] {
	display: none;
}
#se-app button:disabled {
	opacity: 0.4;
	cursor: default;
}

/* ---------- Editor grid ---------- */
#se-app {
	position: fixed;
	inset: 0;
	display: grid;
	grid-template: "bar bar bar" 56px "rail panel stage" 1fr / 72px auto 1fr;
}
.se-bar {
	grid-area: bar;
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	align-items: center;
	gap: 16px;
	padding-block: 0; padding-inline: 16px;
	background: var(--se-paper);
	border-block-end: 1px solid var(--se-line);
}
.se-bar-left,
.se-bar-right {
	display: flex;
	align-items: center;
	gap: 8px;
	min-inline-size: 0;
}
.se-bar-right {
	justify-content: flex-end;
}
.se-site {
	font-weight: 600;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.se-page,
#se-app select,
.se-hex {
	block-size: 36px;
	padding-block: 0; padding-inline: 10px;
	border: 1px solid var(--se-line);
	border-radius: var(--se-r);
	background: var(--se-paper);
}
.se-devices {
	display: flex;
	gap: 2px;
	padding: 2px;
	border-radius: var(--se-r);
	background: var(--se-soft);
}
.se-icon,
.se-btn,
.se-link,
.se-publish {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	block-size: 36px;
	border: 1px solid transparent;
	border-radius: var(--se-r);
	background: transparent;
	white-space: nowrap;
}
.se-icon {
	inline-size: 36px;
	padding: 0;
}
.se-btn {
	padding-block: 0; padding-inline: 12px;
	border-color: var(--se-line);
	background: var(--se-paper);
}
.se-link {
	block-size: auto;
	padding-block: 2px; padding-inline: 4px;
	color: var(--se-accent);
	font-weight: 500;
}
.se-publish {
	padding-block: 0; padding-inline: 20px;
	background: var(--se-accent);
	color: rgb(255 255 255);
	font-weight: 600;
}
.se-devices .se-btn {
	border-color: transparent;
	background: transparent;
}
.se-devices [aria-pressed="true"],
.se-icon[aria-pressed="true"] {
	background: var(--se-paper);
	box-shadow: 0 1px 3px rgb(0 0 0 / 0.12);
	color: var(--se-accent);
}
.se-state {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	margin-block: 0; margin-inline: 8px;
	font-size: 12px;
	line-height: 16px;
}
.se-status {
	color: var(--se-muted);
	white-space: nowrap;
}
#se-app[data-dirty="true"] .se-status {
	color: rgb(166 91 0);
}
}
/* ---------- Stage: the framed page at computer or phone width ---------- */
@layer module {
.se-stage {
	grid-area: stage;
	display: grid;
	place-items: stretch;
	min-inline-size: 0;
	min-block-size: 0;
	overflow: auto;
}
.se-frame {
	inline-size: 100%;
	block-size: 100%;
	border: 0;
	background: rgb(255 255 255);
}
.se-stage[data-device="mobile"] {
	place-items: center;
	padding: 24px;
}
.se-stage[data-device="mobile"] .se-frame {
	inline-size: 390px;
	block-size: min(844px, 100%);
	border-radius: 24px;
	box-shadow:
		0 0 0 10px var(--se-ink),
		0 20px 50px rgb(0 0 0 / 0.25);
}
.se-toast {
	position: fixed;
	inset-inline-start: 50%;
	inset-block-end: 24px;
	z-index: 10;
	display: flex;
	align-items: center;
	gap: 12px;
	max-inline-size: min(560px, calc(100vw - 32px));
	padding-block: 12px; padding-inline: 16px;
	transform: translateX(-50%);
	border-radius: var(--se-r);
	background: var(--se-ink);
	color: rgb(255 255 255);
	box-shadow: 0 8px 30px rgb(0 0 0 / 0.25);
}
.se-toast[hidden],
.se-exit {
	display: none;
}
.se-toast[data-kind="error"] {
	background: var(--se-error);
}
.se-toast[data-kind="saved"] {
	background: var(--se-ok);
}
.se-toast .se-link {
	color: rgb(255 255 255);
	text-decoration: underline;
}

/* Preview: only the page, with a way back. */
#se-app.se-previewing {
	grid-template: "stage" 1fr / 1fr;
}
#se-app.se-previewing :is(.se-bar, .se-rail, .se-panel) {
	display: none;
}
#se-app.se-previewing .se-exit {
	display: inline-flex;
	position: fixed;
	inset-block-start: 16px;
	inset-inline-end: 16px;
	z-index: 10;
	box-shadow: 0 6px 20px rgb(0 0 0 / 0.2);
}

@media (hover: hover) and (pointer: fine) {
	#se-app
		:is(.se-icon, .se-rail button, .se-section-open):hover:not(:disabled) {
		background: var(--se-soft);
	}
	.se-publish:hover {
		background: rgb(80 37 209);
	}
}

/* ---------- Phone: bottom tool bar and bottom sheet ---------- */
@media (max-width: 760px) {
	#se-app {
		grid-template: "bar" 56px "stage" 1fr "rail" 60px / 1fr;
	}
	.se-bar {
		grid-template-columns: 1fr auto;
		gap: 8px;
		padding-block: 0; padding-inline: 8px;
	}
	.se-site,
	.se-devices,
	.se-state,
	.se-bar-right .se-btn span {
		display: none;
	}
	.se-bar-right .se-btn {
		inline-size: 36px;
		padding: 0;
		border: 0;
	}
	.se-page {
		max-inline-size: 120px;
	}
	.se-publish {
		padding-block: 0; padding-inline: 14px;
	}
	.se-stage[data-device="mobile"] {
		padding: 0;
	}
	.se-stage[data-device="mobile"] .se-frame {
		inline-size: 100%;
		block-size: 100%;
		border-radius: 0;
		box-shadow: none;
	}
}

/* ---------- Password gate ---------- */
.surface-gate {
	position: fixed;
	inset: 0;
	z-index: 2147483000;
	display: grid;
	place-items: center;
	padding: 16px;
	background: var(--se-soft);
}
.surface-gate-card {
	inline-size: min(380px, 100%);
	display: grid;
	gap: 12px;
	padding: 28px;
	background: var(--se-paper);
	border-radius: 12px;
	box-shadow: 0 10px 40px rgb(0 0 0 / 0.12);
}
.surface-gate-card :is(h1, h2) {
	margin: 0;
	font-size: 22px;
	line-height: 28px;
}
.surface-gate-card p {
	margin: 0;
	color: var(--se-muted);
}
.surface-gate-card a {
	color: var(--se-muted);
	text-align: center;
}
.surface-gate-card label {
	display: grid;
	gap: 6px;
	font-weight: 500;
}
.surface-gate-card input {
	block-size: 44px;
	padding-block: 0; padding-inline: 12px;
	border: 1px solid var(--se-line);
	border-radius: var(--se-r);
}
.surface-gate .surface-primary {
	block-size: 44px;
	border: 0;
	border-radius: var(--se-r);
	background: var(--se-accent);
	color: rgb(255 255 255);
	font-weight: 600;
	cursor: pointer;
}
.surface-gate .surface-error {
	color: var(--se-error);
}
.surface-gate .surface-error:empty {
	display: none;
}
}
