.hme-wrapper {
	position: relative;
	width: 100%;
	height: var(--hme-height, clamp(440px, 74dvh, 780px));
	min-height: 360px;
	background: radial-gradient(circle at 50% 45%, #0c1930 0%, #050a14 75%, #020409 100%);
	border-radius: 12px;
	overflow: hidden;
	box-shadow: 0 12px 36px rgba(2, 8, 23, 0.28);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	color: #f1f5f9;
	box-sizing: border-box;
	margin: 16px 0;
	-webkit-tap-highlight-color: transparent;
}

.hme-wrapper.is-fullscreen-page {
	margin: 0;
	border-radius: 0;
	height: 100vh;
	height: 100dvh;
	box-shadow: none;
}

/* Fullscreen covers the whole wrapper (map + filter panel + quickbar) */
.hme-wrapper:fullscreen,
.hme-wrapper.is-fullscreen {
	width: 100%;
	height: 100%;
	height: 100dvh;
	min-height: 0;
	margin: 0;
	border-radius: 0;
	box-shadow: none;
}

.hme-wrapper:-webkit-full-screen {
	width: 100%;
	height: 100%;
	margin: 0;
	border-radius: 0;
}

/* Fallback when the Fullscreen API is unavailable (iPhone Safari, sandboxed iframes) */
.hme-wrapper.is-pseudo-fullscreen {
	position: fixed;
	inset: 0;
	z-index: 2147483000;
	width: 100vw;
	height: 100vh;
	height: 100dvh;
	max-width: none;
	margin: 0;
	border-radius: 0;
	padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}

html.hme-noscroll,
html.hme-noscroll body {
	overflow: hidden !important;
}

.hme-wrapper *,
.hme-wrapper *::before,
.hme-wrapper *::after {
	box-sizing: border-box;
}

.hme-wrapper button,
.hme-wrapper input {
	touch-action: manipulation;
	font-family: inherit;
}

.hme-map-canvas {
	width: 100%;
	height: 100%;
}

/* Loading overlay */
.hme-loading {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	padding: 16px;
	text-align: center;
	background: rgba(5, 10, 20, 0.78);
	backdrop-filter: blur(4px);
	color: #e2e8f0;
	font-size: 14px;
	font-weight: 500;
	z-index: 20;
	transition: opacity 0.25s ease;
}

.hme-loading.is-hidden {
	opacity: 0;
	pointer-events: none;
}

.hme-spinner {
	width: 18px;
	height: 18px;
	border: 2.5px solid rgba(56, 189, 248, 0.28);
	border-top-color: #38bdf8;
	border-radius: 50%;
	animation: hme-spin 0.8s linear infinite;
	flex-shrink: 0;
}

@keyframes hme-spin {
	to { transform: rotate(360deg); }
}

/* Control panel */
.hme-panel {
	position: absolute;
	top: 12px;
	left: 12px;
	width: 316px;
	max-width: calc(100% - 62px);
	max-height: calc(100% - 74px);
	display: flex;
	flex-direction: column;
	background: rgba(11, 18, 32, 0.86);
	backdrop-filter: blur(12px);
	-webkit-backdrop-filter: blur(12px);
	border: 1px solid rgba(148, 163, 184, 0.22);
	border-radius: 10px;
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
	z-index: 10;
	overflow: hidden;
}

.hme-panel.is-collapsed {
	width: auto;
	max-width: calc(100% - 62px);
}

.hme-panel.is-collapsed .hme-panel-body {
	display: none;
}

.hme-panel-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding: 9px 11px;
	background: rgba(15, 23, 42, 0.72);
	border-bottom: 1px solid rgba(148, 163, 184, 0.16);
}

.hme-panel.is-collapsed .hme-panel-header {
	border-bottom: none;
}

.hme-panel-title {
	display: flex;
	align-items: center;
	gap: 7px;
	font-size: 13.5px;
	font-weight: 700;
	color: #f8fafc;
	letter-spacing: 0.01em;
	margin: 0;
	line-height: 1.2;
	white-space: nowrap;
}

.hme-globe-badge {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 22px;
	height: 22px;
	border-radius: 6px;
	background: linear-gradient(135deg, #0ea5e9, #2563eb);
	color: #fff;
	font-size: 12px;
	flex-shrink: 0;
}

.hme-header-actions {
	display: flex;
	align-items: center;
	gap: 4px;
}

.hme-icon-btn {
	appearance: none;
	border: 1px solid rgba(148, 163, 184, 0.24);
	background: rgba(30, 41, 59, 0.75);
	color: #cbd5e1;
	border-radius: 6px;
	padding: 5px 8px;
	font-size: 11.5px;
	font-weight: 600;
	cursor: pointer;
	line-height: 1.2;
	white-space: nowrap;
	transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.hme-icon-btn:hover {
	background: rgba(56, 189, 248, 0.22);
	border-color: rgba(56, 189, 248, 0.55);
	color: #ffffff;
}

.hme-panel-body {
	padding: 10px 12px 12px;
	overflow-y: auto;
	overscroll-behavior: contain;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

/* Search box */
.hme-search-wrap {
	position: relative;
}

.hme-search-input {
	width: 100%;
	padding: 8px 30px 8px 10px;
	border-radius: 7px;
	border: 1px solid rgba(148, 163, 184, 0.28);
	background: rgba(15, 23, 42, 0.9);
	color: #f8fafc;
	font-size: 13px;
	outline: none;
	transition: border-color 0.15s ease;
}

.hme-search-input::placeholder {
	color: #94a3b8;
}

.hme-search-input:focus {
	border-color: #38bdf8;
}

.hme-search-clear {
	position: absolute;
	right: 6px;
	top: 50%;
	transform: translateY(-50%);
	background: none;
	border: none;
	color: #94a3b8;
	cursor: pointer;
	font-size: 16px;
	line-height: 1;
	padding: 4px 6px;
	display: none;
}

.hme-search-clear.is-visible {
	display: block;
}

.hme-search-results {
	position: absolute;
	left: 0;
	right: 0;
	top: calc(100% + 4px);
	max-height: 185px;
	overflow-y: auto;
	background: #0f172a;
	border: 1px solid rgba(148, 163, 184, 0.3);
	border-radius: 8px;
	box-shadow: 0 12px 24px rgba(0, 0, 0, 0.55);
	z-index: 30;
	display: none;
}

.hme-search-results.is-open {
	display: block;
}

.hme-search-item {
	width: 100%;
	text-align: left;
	background: transparent;
	border: none;
	border-bottom: 1px solid rgba(148, 163, 184, 0.12);
	padding: 8px 10px;
	color: #e2e8f0;
	font-size: 12.5px;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
}

.hme-search-item:last-child {
	border-bottom: none;
}

.hme-search-item:hover {
	background: rgba(56, 189, 248, 0.16);
}

.hme-search-tag {
	font-size: 10.5px;
	padding: 2px 6px;
	border-radius: 999px;
	background: rgba(148, 163, 184, 0.18);
	color: #cbd5e1;
	white-space: nowrap;
}

/* Section labels */
.hme-section-label {
	font-size: 11px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: #94a3b8;
	margin: 0 0 5px;
	display: flex;
	align-items: center;
	justify-content: space-between;
}

/* Line toggles */
.hme-line-list {
	display: flex;
	flex-direction: column;
	gap: 5px;
}

.hme-line-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 6px;
	padding: 6px 8px;
	border-radius: 7px;
	background: rgba(30, 41, 59, 0.55);
	border: 1px solid rgba(148, 163, 184, 0.14);
	transition: background 0.15s ease, border-color 0.15s ease;
}

.hme-line-row:hover,
.hme-line-row.is-active {
	background: rgba(30, 41, 59, 0.9);
	border-color: rgba(56, 189, 248, 0.45);
}

.hme-line-check {
	display: flex;
	align-items: center;
	margin: 0;
	cursor: pointer;
	flex-shrink: 0;
}

.hme-line-check input[type="checkbox"] {
	margin: 0;
	width: 15px;
	height: 15px;
	accent-color: #38bdf8;
	cursor: pointer;
}

.hme-line-focus-btn {
	appearance: none;
	background: transparent;
	border: none;
	padding: 2px 0;
	display: flex;
	align-items: center;
	gap: 7px;
	flex: 1;
	min-width: 0;
	cursor: pointer;
	font-size: 12.5px;
	font-weight: 600;
	color: #f1f5f9;
	text-align: left;
}

.hme-color-dot {
	width: 10px;
	height: 10px;
	border-radius: 50%;
	flex-shrink: 0;
	box-shadow: 0 0 8px currentColor;
}

.hme-line-label {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.hme-line-meta {
	font-size: 10.5px;
	color: #94a3b8;
	flex-shrink: 0;
}

.hme-fly-btn {
	appearance: none;
	border: 1px solid rgba(148, 163, 184, 0.24);
	background: rgba(15, 23, 42, 0.8);
	color: #93c5fd;
	border-radius: 5px;
	padding: 4px 7px;
	font-size: 10.5px;
	font-weight: 600;
	cursor: pointer;
	flex-shrink: 0;
}

.hme-fly-btn:hover {
	background: rgba(37, 99, 235, 0.35);
	color: #ffffff;
	border-color: #60a5fa;
}

/* Layer pills & mode buttons */
.hme-pill-group {
	display: flex;
	flex-wrap: wrap;
	gap: 5px;
}

.hme-pill {
	appearance: none;
	border: 1px solid rgba(148, 163, 184, 0.25);
	background: rgba(15, 23, 42, 0.7);
	color: #cbd5e1;
	border-radius: 999px;
	padding: 5px 10px;
	font-size: 11.5px;
	font-weight: 600;
	cursor: pointer;
	transition: all 0.15s ease;
}

.hme-pill.is-active {
	background: rgba(14, 165, 233, 0.24);
	border-color: #38bdf8;
	color: #ffffff;
}

.hme-pill:hover {
	border-color: #7dd3fc;
}

/* Bottom quick-select bar for 1-tap zooming to lines on Desktop & Mobile */
.hme-quickbar {
	position: absolute;
	left: 50%;
	bottom: max(12px, env(safe-area-inset-bottom));
	transform: translateX(-50%);
	max-width: calc(100% - 24px);
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 6px 8px;
	background: rgba(11, 18, 32, 0.86);
	backdrop-filter: blur(12px);
	-webkit-backdrop-filter: blur(12px);
	border: 1px solid rgba(148, 163, 184, 0.24);
	border-radius: 999px;
	box-shadow: 0 10px 28px rgba(0, 0, 0, 0.48);
	z-index: 9;
	overflow-x: auto;
	scrollbar-width: none;
	-webkit-overflow-scrolling: touch;
}

.hme-quickbar::-webkit-scrollbar {
	display: none;
}

.hme-quick-pill {
	appearance: none;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	border: 1px solid rgba(148, 163, 184, 0.24);
	background: rgba(30, 41, 59, 0.75);
	color: #e2e8f0;
	border-radius: 999px;
	padding: 6px 11px;
	font-size: 12px;
	font-weight: 600;
	white-space: nowrap;
	cursor: pointer;
	flex-shrink: 0;
	transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.hme-quick-pill:hover {
	background: rgba(51, 65, 85, 0.9);
	border-color: rgba(148, 163, 184, 0.5);
}

.hme-quick-pill.is-active {
	background: rgba(14, 165, 233, 0.28);
	border-color: #38bdf8;
	color: #ffffff;
}

.hme-quick-pill.is-locating {
	border-color: #38bdf8;
	color: #7dd3fc;
}

.hme-quick-pill svg {
	flex-shrink: 0;
}

/* Toast notification */
.hme-toast {
	position: absolute;
	top: 14px;
	left: 50%;
	transform: translateX(-50%) translateY(-8px);
	max-width: min(360px, calc(100% - 32px));
	background: rgba(15, 23, 42, 0.94);
	border: 1px solid rgba(248, 113, 113, 0.45);
	color: #fecaca;
	padding: 8px 14px;
	border-radius: 8px;
	font-size: 12.5px;
	font-weight: 500;
	text-align: center;
	box-shadow: 0 10px 25px rgba(0, 0, 0, 0.45);
	z-index: 25;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.2s ease, transform 0.2s ease;
}

.hme-toast.is-visible {
	opacity: 1;
	transform: translateX(-50%) translateY(0);
}

.hme-popup-action-btn {
	appearance: none;
	border: 1px solid rgba(56, 189, 248, 0.55);
	background: rgba(14, 165, 233, 0.22);
	color: #e0f2fe;
	border-radius: 6px;
	padding: 5px 10px;
	font-size: 11.5px;
	font-weight: 600;
	cursor: pointer;
	width: 100%;
	margin-top: 6px;
	transition: background 0.15s ease;
}

.hme-popup-action-btn:hover {
	background: rgba(14, 165, 233, 0.38);
	color: #ffffff;
}

/* Bottom-left status tip on large screens */
.hme-statusbar {
	position: absolute;
	left: 12px;
	bottom: 58px;
	background: rgba(11, 18, 32, 0.74);
	backdrop-filter: blur(8px);
	border: 1px solid rgba(148, 163, 184, 0.18);
	border-radius: 6px;
	padding: 4px 8px;
	font-size: 11px;
	color: #cbd5e1;
	z-index: 5;
	pointer-events: none;
}

/* MapLibre Popup styling */
.hme-wrapper .maplibregl-popup-content {
	background: rgba(11, 18, 32, 0.94);
	color: #f1f5f9;
	border: 1px solid rgba(148, 163, 184, 0.28);
	border-radius: 10px;
	padding: 12px 14px;
	box-shadow: 0 12px 30px rgba(0, 0, 0, 0.55);
	max-width: min(290px, calc(100vw - 32px));
	font-size: 12.5px;
	line-height: 1.45;
}

.hme-wrapper .maplibregl-popup-tip {
	border-top-color: rgba(11, 18, 32, 0.94);
	border-bottom-color: rgba(11, 18, 32, 0.94);
}

.hme-wrapper .maplibregl-popup-close-button {
	color: #94a3b8;
	font-size: 18px;
	padding: 2px 7px;
}

.hme-wrapper .maplibregl-popup-close-button:hover {
	color: #ffffff;
	background: transparent;
}

.hme-popup-badge {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: 11px;
	font-weight: 700;
	padding: 2px 8px;
	border-radius: 999px;
	background: rgba(30, 41, 59, 0.9);
	margin-bottom: 6px;
}

.hme-popup-title {
	font-size: 14px;
	font-weight: 700;
	color: #ffffff;
	margin: 0 0 4px;
}

.hme-popup-meta {
	font-size: 11.5px;
	color: #94a3b8;
	margin-bottom: 6px;
}

.hme-popup-desc {
	font-size: 12px;
	color: #e2e8f0;
	background: rgba(30, 41, 59, 0.6);
	padding: 6px 8px;
	border-radius: 6px;
	margin-bottom: 8px;
	white-space: pre-line;
}

.hme-popup-links {
	display: flex;
	gap: 10px;
	flex-wrap: wrap;
	border-top: 1px solid rgba(148, 163, 184, 0.16);
	padding-top: 7px;
	margin-top: 4px;
}

.hme-popup-link {
	color: #38bdf8;
	text-decoration: none;
	font-size: 11.5px;
	font-weight: 600;
}

.hme-popup-link:hover {
	text-decoration: underline;
}

/* Tablet & Mobile responsiveness */
@media (max-width: 768px) {
	.hme-wrapper {
		height: var(--hme-height, clamp(420px, 78dvh, 680px));
		border-radius: 10px;
	}

	.hme-wrapper.is-fullscreen-page {
		height: 100vh;
		height: 100dvh;
		border-radius: 0;
	}

	.hme-panel {
		top: 8px;
		left: 8px;
		width: min(320px, calc(100% - 54px));
		max-width: calc(100% - 54px);
		max-height: calc(100% - 76px);
	}

	.hme-panel.is-collapsed {
		width: auto;
	}

	.hme-panel-header {
		padding: 7px 9px;
	}

	.hme-panel-title {
		font-size: 12.5px;
	}

	.hme-quickbar {
		left: 8px;
		right: 8px;
		transform: none;
		max-width: none;
		bottom: max(8px, env(safe-area-inset-bottom));
		border-radius: 12px;
		padding: 6px;
	}

	.hme-quick-pill {
		padding: 7px 11px;
		font-size: 12px;
	}

	.hme-statusbar {
		display: none;
	}

	.hme-wrapper .maplibregl-ctrl-bottom-right {
		bottom: 56px;
	}
}
