:root {
	color-scheme: dark;
	--bg: #0d1014;
	--top: #151a21;
	--panel: #1a2028;
	--panel-soft: #202833;
	--canvas: #05090a;
	--border: #34404e;
	--border-soft: #27313c;
	--text: #edf3f7;
	--muted: #a8b3bf;
	--dim: #73808d;
	--accent: #56ff7a;
	--accent-soft: rgba(86, 255, 122, 0.16);
	--danger: #ff7373;
	--warning: #f3b64b;
	--mono: Consolas, "Courier New", monospace;
	--ui: "Segoe UI", Arial, sans-serif;
}

* {
	box-sizing: border-box;
}

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font-family: var(--ui);
}

button,
input,
select,
textarea {
	font: inherit;
}

button,
.fileButton,
.donateButton {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 36px;
	border: 1px solid var(--border);
	background: #26303a;
	color: var(--text);
	cursor: pointer;
	padding: 7px 12px;
	line-height: 1;
	white-space: nowrap;
}

button:hover,
.fileButton:hover,
.donateButton:hover {
	border-color: var(--accent);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.donateButton:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}

h1,
h2,
p {
	margin: 0;
}

h1 {
	font-size: 23px;
	font-weight: 700;
	letter-spacing: 0;
}

h2 {
	font-size: 15px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0;
}

p,
li {
	color: var(--muted);
}

.topbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 24px;
	min-height: 74px;
	padding: 14px 18px;
	border-bottom: 1px solid var(--border);
	background: var(--top);
}

.topbar button,
.topbar .fileButton,
.topbar .donateButton,
.topbar select {
	height: 40px;
	min-height: 40px;
}

.brandBlock,
.brandLine,
.topNav,
.topbarActions,
.stageActions,
.zoomControls,
.panelHead,
.iconActions {
	display: flex;
	align-items: center;
	gap: 10px;
}

.brandBlock {
	min-width: 390px;
	gap: 12px;
}

.brandLogo {
	display: block;
	width: auto;
	height: 32px;
	object-fit: contain;
}

.brandBlock p {
	margin-top: 2px;
	font-size: 13px;
}

.appVersion,
.panelBadge,
.modeBadge {
	border: 1px solid var(--border);
	background: #202833;
	color: var(--muted);
	font-family: var(--mono);
	font-size: 12px;
	font-weight: 700;
}

.appVersion {
	padding: 2px 7px;
}

.modeBadge {
	min-height: 36px;
	display: inline-flex;
	align-items: center;
	padding: 7px 10px;
	color: var(--accent);
}

.panelBadge {
	display: inline-grid;
	min-width: 30px;
	height: 23px;
	place-items: center;
}

.navButton.isActive {
	border-color: var(--accent);
	background: var(--accent-soft);
	color: var(--accent);
}

.wizardSelect {
	width: 230px;
	min-height: 36px;
	border-color: var(--border);
	background: #26303a;
	color: var(--text);
	font-weight: 700;
}

.fileButton input {
	display: none;
}

.donateButton {
	border: 0;
	background: transparent;
	padding: 0;
	text-decoration: none;
}

.donateButton:hover {
	box-shadow: 0 0 0 1px var(--accent);
}

.donateImage {
	display: block;
	width: auto;
	height: 38px;
}

.pagePanel {
	display: none;
}

.pagePanel.isActive {
	display: block;
}

.workspace.pagePanel.isActive {
	display: grid;
}

.workspace {
	grid-template-columns: 300px minmax(560px, 1fr) 420px;
	gap: 14px;
	height: calc(100vh - 74px);
	padding: 14px;
}

.panel,
.stagePanel {
	min-height: 0;
	border: 1px solid var(--border);
	background: var(--panel);
}

.setupPanel,
.inspectorPanel {
	display: flex;
	flex-direction: column;
	gap: 14px;
	overflow: auto;
	padding: 14px;
}

.setupPanel {
	gap: 10px;
	padding: 10px;
}

.setupPanel .formStack,
.inspector,
.wizardFields {
	gap: 6px;
	margin-top: 8px;
}

.setupPanel label:not(.checkRow),
.inspector label:not(.checkRow),
.wizardFields label:not(.checkRow) {
	grid-template-columns: 96px minmax(0, 1fr);
	align-items: center;
	gap: 8px;
	min-height: 30px;
	line-height: 1.1;
}

.setupPanel .checkRow {
	min-height: 26px;
	gap: 7px;
}

.setupPanel input,
.setupPanel select,
.inspector input,
.inspector select,
.wizardFields input,
.wizardFields select {
	height: 30px;
	min-height: 30px;
	padding: 5px 7px;
	font-size: 12px;
}

.stagePanel {
	display: grid;
	grid-template-rows: auto minmax(0, 1fr);
}

.stageHeader,
.pageHeader {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	padding: 13px 15px;
	border-bottom: 1px solid var(--border);
	background: #161c24;
}

.pageHeader {
	margin-bottom: 14px;
	border: 1px solid var(--border);
}

.stageHeader p {
	margin-top: 3px;
	font-size: 13px;
}

.zoomControls {
	gap: 4px;
}

.zoomControls button {
	width: 34px;
	min-width: 34px;
	height: 32px;
	min-height: 32px;
	padding: 0;
}

#zoomValue {
	display: inline-grid;
	width: 52px;
	height: 32px;
	place-items: center;
	border: 1px solid var(--border);
	background: #111820;
	color: var(--muted);
	font-family: var(--mono);
	font-size: 11px;
	font-weight: 800;
}

.formStack,
.palette,
.layerList,
.inspector,
.checkGrid,
.guideStack,
.tutorialGrid,
.wizardFields {
	display: grid;
	gap: 9px;
	margin-top: 11px;
}

label {
	display: grid;
	gap: 6px;
	color: var(--muted);
	font-size: 12px;
	font-weight: 650;
}

label.fileButton {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0;
	color: var(--text);
	font-size: inherit;
	font-weight: 700;
	line-height: 1;
}

.checkRow {
	grid-template-columns: 18px 1fr;
	align-items: center;
	gap: 8px;
}

input,
select,
textarea {
	width: 100%;
	min-width: 0;
	border: 1px solid var(--border);
	background: #0f141a;
	color: var(--text);
	padding: 8px 9px;
}

input[type="checkbox"] {
	width: 18px;
	height: 18px;
	padding: 0;
	accent-color: var(--accent);
}

input[type="color"] {
	height: 37px;
	padding: 3px;
}

.palette {
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 6px;
	margin-top: 8px;
}

.palette button {
	height: 34px;
	min-height: 34px;
	justify-content: flex-start;
	overflow: hidden;
	padding: 5px 7px;
	font-size: 12px;
	font-weight: 700;
	text-align: left;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.canvasShell {
	position: relative;
	display: grid;
	min-height: 0;
	place-items: center;
	padding: 18px;
	overflow: hidden;
	background:
		linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
		linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
		#0b0e12;
	background-size: 32px 32px;
	cursor: grab;
	touch-action: none;
	user-select: none;
}

.canvasShell.isPanning {
	cursor: grabbing;
}

.dialogCanvas {
	position: relative;
	width: min(100%, 1160px);
	aspect-ratio: 16 / 9;
	border: 1px solid var(--border);
	background:
		linear-gradient(90deg, rgba(86, 255, 122, 0.08) 1px, transparent 1px),
		linear-gradient(rgba(86, 255, 122, 0.08) 1px, transparent 1px),
		var(--canvas);
	background-size: calc(100% / 40) calc(100% / 22.5);
	box-shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
	transform: translate(var(--canvas-pan-x, 0px), var(--canvas-pan-y, 0px)) scale(var(--canvas-zoom, 1));
	transform-origin: center center;
	will-change: transform;
	user-select: none;
}

.safezoneFrame {
	position: absolute;
	inset: 4.8% 6%;
	border: 1px dashed rgba(243, 182, 75, 0.52);
	pointer-events: none;
}

.controlLayer {
	position: absolute;
	inset: 0;
}

.controlBox {
	position: absolute;
	display: grid;
	align-items: center;
	min-width: 10px;
	min-height: 10px;
	border: 1px solid rgba(237, 243, 247, 0.42);
	background: rgba(32, 40, 51, 0.78);
	color: var(--text);
	overflow: hidden;
	cursor: move;
}

.controlBox.background {
	border-style: dashed;
	background: rgba(86, 255, 122, 0.1);
}

.controlBox.isSelected {
	border-color: var(--warning);
	box-shadow: 0 0 0 2px rgba(243, 182, 75, 0.28);
}

.controlBox.isLocked {
	cursor: not-allowed;
	opacity: 0.7;
}

.controlBox.hiddenControl {
	opacity: 0.22;
}

.controlBox.hasImagePreview {
	background-position: center;
	background-repeat: no-repeat;
	background-size: contain;
}

.controlBox.hasImagePreview .controlLabel {
	max-width: calc(100% - 8px);
	margin: 4px;
	background: rgba(5, 9, 10, 0.72);
}

.controlLabel {
	display: block;
	overflow: hidden;
	padding: 4px 6px;
	font-size: 12px;
	font-weight: 700;
	line-height: 1.15;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.controlMeta {
	position: absolute;
	right: 4px;
	bottom: 3px;
	color: var(--dim);
	font-family: var(--mono);
	font-size: 10px;
	pointer-events: none;
}

.resizeHandle {
	position: absolute;
	right: -1px;
	bottom: -1px;
	width: 12px;
	height: 12px;
	border: 1px solid #101419;
	background: var(--warning);
	cursor: nwse-resize;
}

.layerItem {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	gap: 8px;
	align-items: center;
	width: 100%;
	min-height: 40px;
	padding: 7px 8px;
	border: 1px solid var(--border-soft);
	background: var(--panel-soft);
	color: var(--text);
	text-align: left;
}

.layerItem.isSelected {
	border-color: var(--accent);
	background: var(--accent-soft);
}

.layerName {
	display: block;
	overflow: hidden;
	font-size: 12px;
	font-weight: 700;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.layerMeta {
	display: block;
	margin-top: 1px;
	color: var(--dim);
	font-size: 10px;
	text-transform: uppercase;
}

.iconActions button {
	display: grid;
	width: 32px;
	min-width: 32px;
	place-items: center;
	padding: 0;
	font-size: 17px;
	line-height: 1;
}

.inspector {
	grid-template-columns: repeat(2, minmax(0, 1fr));
}

.inspector .wide,
.inspector label.wide,
.wizardFields label.wide {
	grid-column: 1 / -1;
}

.inspector label.wide,
.wizardFields label.wide {
	grid-template-columns: 124px minmax(0, 1fr);
}

.imagePreviewControls {
	display: grid;
	gap: 8px;
	padding: 10px;
	border: 1px solid var(--border-soft);
	background: rgba(0, 0, 0, 0.14);
}

.imagePreviewHead {
	display: grid;
	gap: 3px;
}

.imagePreviewHead span {
	color: var(--muted);
	font-size: 11px;
	line-height: 1.3;
}

.imagePreviewBox {
	display: grid;
	min-height: 112px;
	place-items: center;
	border: 1px dashed var(--border);
	background: #0f141a;
	color: var(--muted);
	font-size: 12px;
}

.imagePreviewBox img {
	display: block;
	max-width: 100%;
	max-height: 190px;
	object-fit: contain;
}

.imagePreviewActions {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	gap: 8px;
}

.imagePreviewFile {
	height: 34px;
	min-height: 34px;
}

.inspector.empty,
.empty {
	display: block;
	padding: 10px;
	border: 1px dashed var(--border);
	color: var(--muted);
	background: rgba(0, 0, 0, 0.12);
}

.exportPage,
.guidePage,
.landingPage {
	height: calc(100vh - 74px);
	padding: 14px;
	overflow: auto;
}

.landingShell {
	display: grid;
	gap: 14px;
	max-width: 1180px;
	margin: 0 auto;
}

.landingIntro {
	padding: 18px;
	border: 1px solid var(--border);
	background: #161c24;
}

.landingIntro p {
	max-width: 980px;
	margin-top: 8px;
	line-height: 1.45;
}

.modeChoiceGrid {
	display: grid;
	grid-template-columns: repeat(2, minmax(280px, 1fr));
	gap: 14px;
}

.modeChoice {
	display: grid;
	min-height: 220px;
	align-content: start;
	align-items: start;
	justify-content: stretch;
	gap: 14px;
	padding: 18px;
	border: 1px solid var(--border);
	background: var(--panel);
	text-align: left;
	white-space: normal;
}

.modeChoice:hover,
.modeChoice:focus-visible {
	border-color: var(--accent);
	background: #202833;
}

.modeChoice span {
	font-size: 24px;
	font-weight: 800;
}

.modeChoice small {
	color: var(--muted);
	font-size: 14px;
	line-height: 1.45;
	white-space: normal;
}

.modalOverlay {
	position: fixed;
	z-index: 20;
	display: grid;
	inset: 0;
	place-items: center;
	padding: 18px;
	background: rgba(5, 8, 11, 0.78);
}

.modalOverlay[hidden] {
	display: none;
}

.wizardModal {
	display: grid;
	width: min(760px, 100%);
	max-height: calc(100vh - 36px);
	grid-template-rows: auto minmax(0, 1fr) auto auto;
	border: 1px solid var(--border);
	background: var(--panel);
	box-shadow: 0 28px 80px rgba(0, 0, 0, 0.48);
}

.modalHead,
.modalActions {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 14px;
	padding: 14px;
	border-bottom: 1px solid var(--border-soft);
	background: #161c24;
}

.modalHead p {
	margin-top: 5px;
	font-size: 13px;
	line-height: 1.42;
}

#wizardClose {
	width: 34px;
	min-width: 34px;
	padding: 0;
	font-size: 18px;
	line-height: 1;
}

.wizardFields {
	grid-template-columns: repeat(2, minmax(0, 1fr));
	margin: 0;
	overflow: auto;
	padding: 14px;
}

.wizardFields textarea {
	min-height: 110px;
	resize: vertical;
	font-family: var(--mono);
	font-size: 12px;
	line-height: 1.45;
}

.wizardExplain {
	padding: 12px 14px;
	border-top: 1px solid var(--border-soft);
	color: var(--muted);
	font-size: 13px;
	line-height: 1.45;
}

.wizardExplain strong {
	color: var(--text);
}

.modalActions {
	align-items: center;
	justify-content: flex-end;
	border-top: 1px solid var(--border-soft);
	border-bottom: 0;
}

#configOutput {
	width: 100%;
	min-height: calc(100vh - 170px);
	resize: none;
	font-family: var(--mono);
	font-size: 12px;
	line-height: 1.45;
	white-space: pre;
}

.checkGrid {
	grid-template-columns: repeat(2, minmax(320px, 1fr));
}

.guideStack {
	gap: 14px;
	margin-top: 0;
}

.tutorialGrid {
	grid-template-columns: repeat(2, minmax(320px, 1fr));
	gap: 14px;
	margin-top: 0;
}

.guideIntro,
.tutorialCard,
.checkGrid .panel {
	padding: 16px;
}

.guidePage ol,
.guidePage ul {
	margin: 11px 0 0;
	padding-left: 21px;
}

.guidePage strong {
	color: var(--text);
}

.guidePage code {
	padding: 1px 5px;
	border: 1px solid var(--border-soft);
	background: #0f141a;
	color: var(--accent);
	font-family: var(--mono);
	font-size: 12px;
}

li + li {
	margin-top: 8px;
}

@media (max-width: 1280px) {
	.topbar {
		display: grid;
		grid-template-columns: minmax(330px, 1fr) auto;
		grid-template-areas:
			"brand actions"
			"nav nav";
	}

	.brandBlock {
		grid-area: brand;
	}

	.topbarActions {
		grid-area: actions;
		flex-wrap: wrap;
		justify-content: flex-end;
	}

	.topNav {
		grid-area: nav;
		justify-content: center;
	}

	.workspace {
		grid-template-columns: 280px minmax(520px, 1fr) 390px;
	}
}

@media (max-width: 1080px) {
	.workspace {
		height: auto;
		grid-template-columns: 1fr;
	}

	.stagePanel {
		min-height: 620px;
	}

	.inspectorPanel {
		display: grid;
		grid-template-columns: minmax(300px, 0.8fr) minmax(360px, 1fr);
	}
}

@media (max-width: 760px) {
	.topbar,
	.inspectorPanel,
	.checkGrid,
	.tutorialGrid,
	.wizardFields {
		display: block;
	}

	.brandBlock,
	.topNav,
	.topbarActions {
		margin-top: 10px;
		flex-wrap: wrap;
		min-width: 0;
	}

	.workspace,
	.exportPage,
	.guidePage,
	.landingPage {
		padding: 10px;
	}

	.modeChoiceGrid {
		grid-template-columns: 1fr;
	}

	.stageHeader,
	.pageHeader {
		align-items: flex-start;
		flex-direction: column;
	}

	.setupPanel label:not(.checkRow),
	.inspector label:not(.checkRow),
	.wizardFields label:not(.checkRow),
	.inspector label.wide,
	.wizardFields label.wide {
		grid-template-columns: 1fr;
		align-items: stretch;
	}
}
