: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 {
	min-height: 36px;
	border: 1px solid var(--border);
	background: #26303a;
	color: var(--text);
	cursor: pointer;
	padding: 7px 12px;
}

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

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea: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;
}

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

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

.topbarActions,
.stageControls,
.panelHead,
.iconActions {
	display: flex;
	align-items: center;
	gap: 10px;
}

.fileButton input {
	display: none;
}

.workspace {
	display: grid;
	grid-template-columns: 260px minmax(620px, 1fr) 410px;
	gap: 14px;
	height: calc(100vh - 74px);
	padding: 14px;
}

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

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

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

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

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

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

input,
select,
textarea {
	width: 100%;
	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;
}

.toolGrid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 9px;
	margin-top: 11px;
}

.toolButton {
	display: grid;
	grid-template-columns: 28px 1fr;
	align-items: center;
	gap: 7px;
	min-width: 0;
	text-align: left;
}

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

.toolIcon {
	display: grid;
	width: 24px;
	height: 24px;
	place-items: center;
	font-family: var(--mono);
	font-size: 17px;
}

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

.layerList {
	display: grid;
	gap: 8px;
	margin-top: 11px;
}

.layerItem {
	display: grid;
	grid-template-columns: 20px 1fr;
	gap: 9px;
	align-items: center;
	width: 100%;
	min-height: 48px;
	padding: 8px;
	border: 1px solid var(--border-soft);
	background: var(--panel-soft);
	text-align: left;
}

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

.layerGlyph {
	display: grid;
	width: 18px;
	height: 18px;
	place-items: center;
	color: var(--accent);
	font-family: var(--mono);
}

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

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

.canvasShell {
	display: grid;
	min-height: 0;
	place-items: center;
	padding: 18px;
	overflow: auto;
	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;
}

#mfdCanvas {
	display: block;
	width: min(100%, calc(100vh - 154px));
	max-width: 980px;
	aspect-ratio: 1;
	border: 1px solid var(--border);
	background: var(--canvas);
	box-shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
	touch-action: none;
	user-select: none;
}

.canvasBg {
	fill: var(--canvas);
}

.gridMinor {
	stroke: rgba(86, 255, 122, 0.08);
	stroke-width: 1;
}

.gridMajor {
	stroke: rgba(86, 255, 122, 0.2);
	stroke-width: 1.4;
}

.axisLine {
	stroke: rgba(243, 182, 75, 0.36);
	stroke-width: 1.6;
}

.mfdElement {
	cursor: pointer;
	filter: url("#hudGlow");
}

.selectedBounds {
	fill: none;
	stroke: var(--warning);
	stroke-dasharray: 10 8;
	stroke-width: 2;
	pointer-events: none;
}

.handle {
	fill: var(--warning);
	stroke: #101419;
	stroke-width: 2;
	pointer-events: none;
}

.formGrid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 10px;
	margin-top: 11px;
}

.formGrid label:nth-child(2),
.formGrid label:nth-child(6),
.formGrid .cockpitOnly,
.formGrid .hmdOnly {
	grid-column: 1 / -1;
}

.propertiesPanel {
	display: grid;
	gap: 10px;
	margin-top: 11px;
}

.propertiesPanel.empty,
.empty {
	padding: 16px;
	border: 1px dashed var(--border);
	color: var(--muted);
	background: rgba(0, 0, 0, 0.12);
}

.propertyGroup {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 10px;
	padding-bottom: 12px;
	border-bottom: 1px solid var(--border-soft);
}

.propertyGroup label.wide {
	grid-column: 1 / -1;
}

.exportSection {
	display: grid;
	min-height: 360px;
	flex: 1;
	grid-template-rows: auto minmax(0, 1fr);
}

#configOutput {
	min-height: 310px;
	margin-top: 11px;
	resize: none;
	font-family: var(--mono);
	font-size: 12px;
	line-height: 1.45;
	white-space: pre;
}

.hmdOnly {
	display: none;
}

body.isHmd .hmdOnly {
	display: grid;
}

body.isHmd .cockpitOnly {
	display: none;
}

@media (max-width: 1280px) {
	.workspace {
		grid-template-columns: 230px minmax(520px, 1fr) 360px;
	}
}

@media (max-width: 1120px) {
	.topbar {
		height: auto;
		min-height: 74px;
		flex-wrap: wrap;
	}

	.topbarActions {
		flex-wrap: wrap;
	}

	.workspace {
		height: auto;
		grid-template-columns: 1fr;
	}

	.toolsPanel {
		display: grid;
		grid-template-columns: minmax(220px, 280px) 1fr;
	}

	.stagePanel {
		min-height: 680px;
	}

	.inspectorPanel {
		display: grid;
		grid-template-columns: minmax(320px, 0.8fr) minmax(320px, 0.8fr) minmax(420px, 1fr);
		align-items: start;
	}
}

@media (max-width: 760px) {
	.workspace {
		padding: 10px;
	}

	.toolsPanel,
	.inspectorPanel {
		display: flex;
	}

	.formGrid,
	.propertyGroup {
		grid-template-columns: 1fr;
	}

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

	.stagePanel {
		min-height: 560px;
	}

	.canvasShell {
		padding: 10px;
	}
}
