.map-editor {
	grid-template-columns: minmax(0, 1fr);
	grid-template-rows: auto auto minmax(0, 1fr) auto;
}

.map-editor .editor-top-bar {
	grid-row: 1;
	gap: 8px 14px;
	max-height: 32dvh;
	padding: 10px 14px;
}

.editor-tools-open { display: none; }
.editor-page .editor-tool-choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.editor-history button { min-width: 44px; }
.editor-top-bar .editor-page-button { font-size: 14px; padding: 6px 8px; }

.editor-level-name {
	max-width: 180px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.map-editor .editor-top-bar button,
.editor-selection-bar button,
.editor-page button {
	min-height: 44px;
}

.editor-selection-bar {
	grid-row: 2;
	justify-self: center;
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	padding: 10px;
}

.map-editor .editor-status-line {
	grid-row: 4;
	max-height: 50px;
	padding-bottom: max(8px, env(safe-area-inset-bottom));
}

.editor-page {
	width: min(660px, 100%);
	max-height: calc(100dvh - 32px);
	overflow: hidden;
	display: flex;
	flex-direction: column;
	padding: 20px;
}

.editor-page-content { min-height: 0; overflow: auto; overscroll-behavior: contain; scrollbar-gutter: stable; padding: 4px; }

.editor-page > .screen-heading {
	flex: none;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	margin-bottom: 20px;
}

.editor-page .editor-page-body {
	width: auto;
	min-width: 0;
	padding: 0;
	border: 0;
	overflow: visible;
}

.editor-page .editor-page-body > h3:first-child {
	display: none;
}

.editor-page .editor-materials,
.editor-page .picker-row,
.editor-page-choices {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
	gap: 14px;
}

.editor-page .editor-materials .swatch,
.editor-page .picker-choice {
	width: 100%;
	height: 76px;
}

.editor-page .picker-choice img {
	object-fit: contain;
	image-rendering: auto;
}

.editor-page .picker-choice-flags {
	grid-column: span 2;
}

.editor-page .editor-field input:not([type="checkbox"]),
.editor-page .editor-field textarea,
.editor-page .editor-field select {
	min-height: 44px;
	max-width: 100%;
}

.editor-page .editor-field textarea {
	min-height: 100px;
}

.editor-page-done {
	flex: none;
	display: block;
	margin: 24px 0 0 auto;
}

@media (max-width: 640px), (pointer: coarse) and (max-height: 600px) {
	.map-editor .editor-top-bar {
		flex-wrap: wrap;
		overflow: visible;
		max-height: none;
		padding: 8px;
	}

	.map-editor .editor-top-group {
		flex-wrap: wrap;
		min-width: 0;
	}

	.map-editor .editor-drawing-tools { display: none; }
	.map-editor .editor-tools-open { display: inline-flex; }
	.map-editor .editor-top-group.right { width: 100%; justify-content: space-between; }

	.map-editor .editor-top-bar .tab {
		font-size: 14px;
	}

	.editor-level-name {
		display: none;
	}

	.editor-page {
		padding: 16px;
		max-height: calc(100dvh - 20px);
	}

	.editor-selection-bar {
		gap: 6px;
		padding: 8px;
	}
}

.maps { gap: 12px; }
.maps > :is(.screen-heading, .maps-tabs, .maps-search, .maps-pages, .maps-notice, .maps-body) { width: min(1000px, 100%); flex: none; }
.maps > .screen-heading { flex-wrap: wrap; gap: 12px; }
.maps > .screen-heading h1 { margin-right: auto; }
.maps-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.maps-tabs button { min-height: 44px; }
.maps-search { padding: 12px; min-height: 44px; }
.maps-pages { display: flex; align-items: center; justify-content: center; gap: 14px; }
.maps-pages button { min-width: 44px; min-height: 44px; }
.maps-notice { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.maps-notice:empty { display: none; }
.maps-body { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; padding-bottom: 16px; }
.map-card { min-width: 0; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.map-card .level-name { font: 800 18px/1.25 var(--font); text-transform: none; white-space: normal; overflow-wrap: anywhere; }
.map-card .level-preview { width: 100%; height: 140px; object-fit: contain; }
.map-card .buttons { margin-top: auto; gap: 12px; }
.map-card :is(button, select) { min-width: 44px; min-height: 44px; }
.map-supply { align-items: center; text-align: center; }
.map-empty { grid-column: 1 / -1; padding: 20px; }
@media (max-width: 600px) {
 .maps-body { grid-template-columns: minmax(0, 1fr); }
 .maps-tabs button { font-size: 14px; padding: 8px 10px; }
}

.editor-tools-open { flex-direction: column; font-size: 14px; line-height: 1.1; }
.editor-tools-open small { font: 600 11px/1.1 var(--font); }
.editor-shape-search { width: 100%; min-height: 44px; margin-bottom: 12px; }
.editor-shape-row { flex-wrap: wrap; }
.editor-shape-name { overflow-wrap: anywhere; }

.editor-page.editor-shape-library { --shape-row-height: 104px; --shape-columns: 1; width: min(1120px, calc(100vw - 16px)); max-height: calc(100dvh - 24px); padding: 12px; gap: 8px; rotate: 0deg; }
.editor-shape-library button { min-width: 44px; }
.editor-shape-library > .screen-heading { margin: 0; gap: 16px; }
.editor-shape-library > .screen-heading h2 { font-size: 28px; }
.editor-shape-library .editor-shape-add { padding: 8px; font: 800 14px var(--font); text-transform: none; white-space: nowrap; }
.editor-shape-search-field { position: relative; min-width: 0; flex: 1; }
.editor-shape-library .editor-shape-search { width: 100%; min-width: 0; margin: 0; padding: 8px 48px 8px 12px; border: var(--line); border-radius: 8px; background: var(--paper-bright); font-size: 16px; }
.editor-shape-search::-webkit-search-cancel-button { display: none; }
.editor-shape-library .editor-search-clear { position: absolute; right: 0; top: 50%; translate: 0 -50%; width: 44px; height: 44px; padding: 12px; border: 0; border-radius: 0; --face: transparent; --shade: transparent; --edge: 0px; }
.editor-search-clear::after { display: none; }
.editor-shape-library .editor-page-content { overflow: hidden; scrollbar-gutter: auto; padding: 0; }
.editor-shape-library .editor-page-body { display: grid; grid-template-columns: repeat(var(--shape-columns), minmax(0, 1fr)); gap: 0 20px; }
.editor-shape-library .editor-shape-row { display: grid; grid-template-columns: 128px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) 44px; align-items: center; gap: 4px 10px; height: var(--shape-row-height); padding: 8px 0; border-bottom: 1px dashed var(--ink-soft); }
.editor-shape-library .editor-shape-preview-button { position: relative; grid-row: 1 / 3; width: 128px; height: 80px; padding: 0; overflow: hidden; }
.editor-shape-preview-button .level-preview, .editor-shape-image .level-preview { display: block; width: 100%; height: 100%; object-fit: contain; }
.editor-shape-preview-button > svg { position: absolute; right: 0; bottom: 0; width: 24px; height: 24px; padding: 3px; border-radius: 5px 0 0; background: var(--paper-bright); }
.editor-shape-preview-button, .editor-shape-image { border: 1px solid #b5a384; border-radius: 6px; background-color: #eadbb8; background-image: linear-gradient(#70513c14 1px, transparent 1px), linear-gradient(90deg, #70513c14 1px, transparent 1px); background-size: 12px 12px; }
.editor-page.editor-shape-inspection { width: min(660px, calc(100vw - 24px)); padding: 12px; gap: 12px; rotate: 0deg; }
.editor-shape-inspection > .screen-heading { min-width: 0; margin: 0; justify-content: start; gap: 12px; }
.editor-shape-inspection h2 { margin: 0; font-size: 23px; overflow-wrap: anywhere; }
.editor-shape-image { width: 100%; height: min(400px, 50dvh); min-height: 0; }
.editor-shape-inspection button { flex: none; min-width: 44px; min-height: 44px; }
.editor-shape-maintenance { flex: none; margin: 0; justify-content: space-between; }
.editor-shape-maintenance button { display: flex; align-items: center; gap: 8px; width: auto; padding: 8px 12px; font: 800 14px var(--font); text-transform: none; }
.editor-shape-maintenance svg { flex: none; }
.editor-shape-library .editor-shape-name { font-size: 14px; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.editor-shape-library .buttons { grid-column: 2; margin: 0; flex-wrap: nowrap; gap: 6px; }
.editor-shape-library .buttons button { padding: 6px 10px; }
.editor-shape-row .buttons > .primary { font: 900 14px var(--font); text-transform: none; border-radius: 8px; }
.editor-shape-pages { display: flex; flex: none; align-items: center; justify-content: space-between; gap: 8px; }
.editor-shape-pages .collection-pages { gap: 0; border: 1px solid var(--ink-soft); border-radius: 10px; }
.editor-shape-pages .collection-pages button { --face: transparent; --shade: transparent; --edge: 0px; border: 0; border-radius: 8px; }
.editor-shape-pages .collection-pages button:hover:not(:disabled) { --face: var(--paper-bright); }
.editor-shape-pages .collection-pages > span { background: transparent; border-radius: 0; padding: 6px; font-size: 13px; white-space: nowrap; }
.editor-shape-count { display: flex; flex-direction: column; gap: 2px; text-align: right; }
.editor-shape-count small { font-size: 11px; white-space: nowrap; }
@media (min-width: 700px) {
 .editor-page.editor-shape-library { --shape-columns: 2; }
}
@media (min-width: 1100px) {
 .editor-page.editor-shape-library { --shape-columns: 3; }
}
@media (max-width: 639px) {
 .editor-shape-library > .screen-heading { display: grid; grid-template-columns: minmax(0, 1fr) auto 44px; gap: 8px; }
 .editor-shape-search-field { grid-column: 1 / -1; grid-row: 2; width: 100%; }
 .editor-shape-library > .screen-heading > .editor-shape-add { grid-column: 2; grid-row: 1; }
 .editor-shape-library > .screen-heading > .bingo-close { grid-column: 3; grid-row: 1; }
}
