:root {
	--gap: 16px;
	--panel: rgba(255, 255, 255, .95);
	--line: #d7deea;
	--text: #0f172a;
	--muted: #64748b;
	--accent: #2563eb;
	--accent-soft: #eff6ff;
	--danger: #dc2626;
	--ok: #15803d;
	--shadow: 0 12px 36px rgba(15, 23, 42, .18);
	--toolbar-h: 64px;
	--sidebar-w: 360px;
	--radius: 18px
}

* {
	box-sizing: border-box
}

html,
body {
	width: 100%;
	height: 100%;
	margin: 0;
	font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
	color: var(--text);
	overflow: hidden;
	background: #dbe5f1
}

.app {
	position: relative;
	width: 100%;
	height: 100%
}

#map {
	position: absolute;
	inset: 0;
	z-index: 1
}

.leaflet-control-zoom {
	display: none !important
}

.leaflet-container {
	background: #dce6f3
}

.leaflet-container.is-picking-label,
.leaflet-container.is-picking-label * {
	cursor: crosshair !important
}

.leaflet-container.inspect-mode,
.leaflet-container.inspect-mode * {
	cursor: default !important
}

.topbar {
	position: absolute;
	top: var(--gap);
	left: var(--gap);
	right: var(--gap);
	min-height: var(--toolbar-h);
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 10px 14px;
	background: var(--panel);
	border: 1px solid rgba(255, 255, 255, .72);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	backdrop-filter: blur(12px);
	z-index: 1000
}

.brand {
	display: flex;
	align-items: center;
	gap: 12px;
	min-width: 0
}

.brand-badge {
	width: 42px;
	height: 42px;
	border-radius: 12px;
	background: linear-gradient(135deg, #2563eb, #1e40af);
	color: #fff;
	display: grid;
	place-items: center
}

.brand-title {
	font-size: 16px;
	font-weight: 800
}

.brand-subtitle {
	font-size: 12px;
	color: var(--muted)
}

.topbar-actions {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-wrap: wrap;
	justify-content: flex-end
}

.tool-btn,
.btn,
.icon-btn,
.mini-btn,
.list-item {
	border: 1px solid var(--line);
	background: #fff;
	color: var(--text);
	border-radius: 12px;
	transition: .18s ease;
	box-shadow: 0 1px 0 rgba(255, 255, 255, .8) inset
}

.tool-btn {
	width: 46px;
	height: 46px;
	display: grid;
	place-items: center;
	font-size: 17px;
	cursor: pointer
}

.tool-btn.active {
	background: var(--accent-soft);
	color: var(--accent);
	border-color: #bfdbfe
}

.btn {
	height: 42px;
	padding: 0 14px;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	font-size: 14px;
	font-weight: 700;
	cursor: pointer
}

.btn.primary {
	background: var(--accent);
	color: #fff;
	border-color: var(--accent)
}

.btn.success {
	background: var(--ok);
	color: #fff;
	border-color: var(--ok)
}

.btn.danger {
	color: var(--danger);
	border-color: #fecaca;
	background: #fff
}

.icon-btn {
	width: 42px;
	height: 42px;
	display: grid;
	place-items: center;
	cursor: pointer
}

.sidebar {
	position: absolute;
	top: calc(var(--gap) + var(--toolbar-h) + var(--gap));
	right: var(--gap);
	width: min(var(--sidebar-w), calc(100vw - 32px));
	max-height: calc(100vh - 112px);
	background: var(--panel);
	border: 1px solid rgba(255, 255, 255, .75);
	border-radius: 22px;
	box-shadow: var(--shadow);
	backdrop-filter: blur(12px);
	z-index: 1000;
	display: flex;
	flex-direction: column;
	overflow: hidden
}

.sidebar.is-hidden {
	display: none
}

.sidebar-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 16px 18px 12px;
	border-bottom: 1px solid #e8edf4
}

.sidebar-title {
	font-size: 17px;
	font-weight: 800
}

.sidebar-body {
	padding: 14px;
	overflow: auto;
	display: flex;
	flex-direction: column;
	gap: 14px
}

.panel {
	display: none;
	flex-direction: column;
	gap: 12px;
	border: 1px solid #e6ebf2;
	background: #fbfdff;
	border-radius: 18px;
	padding: 14px
}

.panel.active {
	display: flex
}

.panel h3 {
	margin: 0;
	font-size: 14px;
	font-weight: 800
}

.field {
	display: flex;
	flex-direction: column;
	gap: 6px
}

.field label {
	font-size: 12px;
	font-weight: 700;
	color: #334155
}

.input,
.textarea,
.select {
	width: 100%;
	border: 1px solid #d9e1ec;
	background: #fff;
	border-radius: 12px;
	padding: 11px 12px;
	font: inherit;
	color: inherit;
	outline: none
}

.textarea {
	min-height: 88px;
	resize: vertical
}

.row {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 10px
}

.compact-row {
	display: flex;
	gap: 8px;
	flex-wrap: wrap
}

.range-wrap {
	display: flex;
	align-items: center;
	gap: 10px
}

.range-wrap input[type=range] {
	flex: 1
}

.value-box,
.empty-state {
	min-height: 36px;
	padding: 8px 12px;
	border: 1px solid #dbe4ef;
	border-radius: 12px;
	background: #fff;
	font-size: 12px;
	color: #334155
}

.search-input-wrap {
	position: relative
}

.search-input-wrap i {
	position: absolute;
	left: 12px;
	top: 50%;
	transform: translateY(-50%);
	color: #64748b;
	font-size: 14px
}

.search-input-wrap .input {
	padding-left: 36px
}

.result-list,
.object-list {
	display: flex;
	flex-direction: column;
	gap: 10px;
	max-height: 320px;
	overflow: auto
}

.list-item {
	padding: 12px;
	display: flex;
	flex-direction: column;
	gap: 8px;
	cursor: pointer;
	text-align: left
}

.list-item.active {
	background: #eff6ff;
	border-color: #bfdbfe
}

.list-title {
	font-size: 14px;
	font-weight: 800
}

.list-meta {
	font-size: 12px;
	color: var(--muted)
}

.mini-btn {
	height: 32px;
	padding: 0 10px;
	font-size: 12px;
	font-weight: 700;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	cursor: pointer
}

.help-fab {
	position: absolute;
	left: 24px;
	bottom: 24px;
	width: 54px;
	height: 54px;
	border-radius: 999px;
	background: #fff;
	border: 1px solid rgba(255, 255, 255, .85);
	box-shadow: var(--shadow);
	display: grid;
	place-items: center;
	z-index: 1000;
	font-size: 20px;
	cursor: pointer
}

.tooltip {
	position: absolute;
	max-width: 280px;
	padding: 10px 12px;
	border-radius: 12px;
	background: rgba(15, 23, 42, .92);
	color: #fff;
	font-size: 12px;
	line-height: 1.45;
	box-shadow: 0 10px 20px rgba(15, 23, 42, .18);
	pointer-events: none;
	opacity: 0;
	transition: opacity .15s ease;
	z-index: 1200
}

.map-label {
	display: inline-flex;
	overflow: hidden;
	align-items: center;
	justify-content: center;
	border: 1px solid rgba(15, 23, 42, .12);
	box-shadow: 0 4px 12px rgba(15, 23, 42, .12);
	font-weight: 700;
	white-space: nowrap;
	transform: translate(-50%, -50%);
	line-height: 1;
	text-align: center;
}

.map-label.transparent {
	background: transparent;
	border-color: transparent;
	box-shadow: none
}

.leaflet-div-icon {
	background: transparent;
	border: none
}

.inline-check {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	font-size: 12px;
	font-weight: 700;
	color: #334155;
	background: #fff;
	border: 1px solid #dbe4ef;
	border-radius: 12px;
	padding: 10px 12px;
	user-select: none
}

.inline-check input {
	margin: 0
}

.hint-box {
	font-size: 12px;
	color: var(--muted);
	line-height: 1.45;
	background: #f8fafc;
	border: 1px dashed #cbd5e1;
	border-radius: 12px;
	padding: 10px 12px
}

.list-link a {
	font-size: 11px;
	color: black;
}

/* ── Responsive ─────────────────────────────────────────────────────────────
   768 px  tablet / large phone  — sidebar becomes a bottom sheet,
                                   topbar stays horizontal but compact.
   480 px  phone                 — tighter padding, smaller controls,
                                   constrained textarea / list heights.
   ───────────────────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
	:root {
		--gap: 10px;
		--toolbar-h: 56px
	}

	.help-fab {
		display: none
	}

	.row {
		grid-template-columns: 1fr
	}

	/* Topbar: stays horizontal, shrinks padding, no column flip */
	.topbar {
		flex-direction: row;
		align-items: center;
		padding: 8px 12px;
		gap: 8px;
		border-radius: 14px
	}

	.brand-badge {
		width: 36px;
		height: 36px;
		border-radius: 10px;
		font-size: 15px
	}

	.brand-title {
		font-size: 14px
	}

	.brand-subtitle {
		display: none
	}

	/* Actions strip: single scrollable row, no wrapping */
	.topbar-actions {
		//overflow-x: auto;
		/* flex-wrap: nowrap;*/
		scrollbar-width: none;
		-webkit-overflow-scrolling: touch
	}

	.topbar-actions::-webkit-scrollbar {
		display: none
	}

	/* Prevent buttons from shrinking inside the scroll strip */
	.tool-btn,
	.btn {
		flex-shrink: 0
	}

	/* Sidebar → bottom sheet */
	.sidebar {
		left: var(--gap);
		right: var(--gap);
		bottom: var(--gap);
		/* top: auto;*/
		width: auto;
		max-height: 58vh;
		border-radius: 18px
	}

	/* Drag-handle indicator at top of bottom sheet */
	.sidebar::before {
		content: '';
		display: block;
		width: 36px;
		height: 4px;
		background: rgba(15, 23, 42, .15);
		border-radius: 2px;
		margin: 10px auto 0;
		flex-shrink: 0
	}
}

@media (max-width: 480px) {
	/* Truncate long brand title before it squeezes the action strip */
	.brand-title {
		font-size: 11px;
		/* white-space: nowrap;*/
		overflow: hidden;
		text-overflow: ellipsis;
		max-width: 120px
	}

	.tool-btn {
		width: 40px;
		height: 40px;
		font-size: 14px;
		border-radius: 10px
	}

	.btn {
		height: 40px;
		padding: 0 10px;
		font-size: 13px;
		border-radius: 10px
	}

	.sidebar {
		max-height: 64vh
	}

	.sidebar-body {
		padding: 10px;
		gap: 10px
	}

	.panel {
		padding: 10px;
		gap: 8px;
		border-radius: 14px
	}

	/* Compact textarea so it doesn't eat the whole sheet */
	.textarea {
		min-height: 64px
	}

	/* Shorter scrollable lists so footer buttons stay reachable */
	.result-list,
	.object-list {
		max-height: 180px
	}
}

/* ── Edit-only controls ────────────────────────────────────────────────────
   Hidden by default (view mode). body[data-app-mode="edit"] reveals them.
   Two selectors are required: .tool-btn uses display:grid (icon centering
   via place-items) while .btn uses display:inline-flex. A single
   inline-flex rule would break the grid-based icon alignment on tool buttons.
   ───────────────────────────────────────────────────────────────────────── */
.edit-only {
	display: none !important;
}

body[data-app-mode="edit"] .tool-btn.edit-only {
	display: grid !important;
}

body[data-app-mode="edit"] .btn.edit-only {
	display: inline-flex !important;
}