:root {
	--bg: #04070f;
	--glass: rgba(9, 18, 30, 0.78);
	--glass-strong: rgba(9, 18, 30, 0.9);
	--panel-border: rgba(77, 208, 225, 0.08);
	--accent: #48d7f0;
	--accent-soft: rgba(72, 215, 240, 0.18);
	--text: #f1f7ff;
	--muted: #7fa2c3;
	--muted-strong: #96b6d4;
	--danger: #ff7b7b;
	--card-shadow: 0 20px 55px rgba(1, 10, 20, 0.65);
	--radius: 18px;
	font-smooth: always;
}

* {
	box-sizing: border-box;
}

html,
body {
	height: 100%;
	margin: 0;
	font-family: "Inter", "Neue Haas Grotesk", "Segoe UI", Roboto, sans-serif;
	background: radial-gradient(120% 120% at 10% 10%, rgba(72, 215, 240, 0.12), transparent 60%), var(--bg);
	color: var(--text);
	-webkit-font-smoothing: antialiased;
}

#map {
	position: fixed;
	inset: 0;
	z-index: 1;
	/* Remove heavy image manipulation so tile content (roads/paths) renders as intended */
	filter: none;
}

.leaflet-container {
	background: #02060c;
}

.leaflet-control-attribution {
	background: rgba(2, 8, 14, 0.7) !important;
	color: var(--muted) !important;
	font-size: 11px !important;
	border-radius: 8px !important;
	padding: 2px 8px !important;
}

#hud {
	position: fixed;
	top: 16px;
	left: 16px;
	display: flex;
	flex-direction: column;
	gap: 18px;
	width: min(360px, calc(100% - 32px));
	max-height: calc(100vh - 32px);
	overflow-y: auto;
	pointer-events: none;
	z-index: 1200;
}

#hud .card,
#hud details {
	pointer-events: auto;
	background: var(--glass);
	border: 1px solid var(--panel-border);
	border-radius: var(--radius);
	padding: 18px;
	backdrop-filter: blur(18px) saturate(140%);
	box-shadow: var(--card-shadow);
}

#hud details summary {
	cursor: pointer;
	font-size: 13px;
	color: var(--muted);
}

.card-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 14px;
}

.header-right {
	display: flex;
	align-items: center;
	gap: 8px;
}

.collapse-btn {
	display: none;
	width: 28px;
	height: 28px;
	border: 1px solid rgba(255, 255, 255, 0.15);
	background: rgba(255, 255, 255, 0.05);
	color: var(--muted-strong);
	border-radius: 8px;
	font-size: 18px;
	line-height: 1;
	padding: 0;
	cursor: pointer;
	transition: all 0.2s ease;
	flex-shrink: 0;
}

.collapse-btn:hover {
	background: rgba(255, 255, 255, 0.1);
	border-color: rgba(255, 255, 255, 0.25);
	transform: translateY(-1px);
}

.card.controls.collapsed .card-body {
	display: none;
}

.card.controls.collapsed .card-head {
	margin-bottom: 0;
}

.card.results.collapsed .route-detail,
.card.results.collapsed .results-list {
	display: none;
}

.card.results.collapsed .card-head {
	margin-bottom: 0;
}

.logo {
	font-size: 18px;
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.status-badge {
	font-size: 12px;
	color: var(--accent);
	background: rgba(72, 215, 240, 0.18);
	border: 1px solid rgba(72, 215, 240, 0.25);
	padding: 4px 10px;
	border-radius: 999px;
}

.status-badge.is-idle {
	color: var(--muted-strong);
	background: rgba(255, 255, 255, 0.05);
	border-color: rgba(255, 255, 255, 0.08);
}

.status-badge.is-alert {
	color: #ff9fa0;
	background: rgba(255, 99, 132, 0.12);
	border-color: rgba(255, 99, 132, 0.25);
}

.status-badge.is-success {
	color: #7ef9c5;
	background: rgba(62, 201, 181, 0.16);
	border-color: rgba(62, 201, 181, 0.28);
}

.card-body {
	display: flex;
	flex-direction: column;
	gap: 16px;
}

.field label {
	display: flex;
	align-items: center;
	justify-content: space-between;
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: var(--muted-strong);
	margin-bottom: 8px;
}

.distance-label {
	font-size: 14px;
	font-weight: 600;
	color: var(--accent);
	text-transform: none;
	letter-spacing: 0;
}

input[type="range"] {
	width: 100%;
	accent-color: var(--accent);
}

input[type="range"]::-webkit-slider-thumb {
	-webkit-appearance: none;
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: var(--accent);
	box-shadow: 0 0 12px rgba(72, 215, 240, 0.6);
}

input[type="range"]::-moz-range-thumb {
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: var(--accent);
	box-shadow: 0 0 12px rgba(72, 215, 240, 0.6);
}

.control-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
}

.toggle {
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: 10px;
	cursor: pointer;
}

.toggle input {
	position: absolute;
	opacity: 0;
	pointer-events: none;
}

.toggle-pill {
	width: 38px;
	height: 20px;
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.12);
	position: relative;
	transition: background 0.2s ease;
}

.toggle-pill::after {
	content: "";
	position: absolute;
	top: 3px;
	left: 3px;
	width: 14px;
	height: 14px;
	border-radius: 50%;
	background: var(--muted);
	transition: transform 0.2s ease, background 0.2s ease;
}

.toggle input:checked + .toggle-pill {
	background: rgba(72, 215, 240, 0.25);
}

.toggle input:checked + .toggle-pill::after {
	transform: translateX(18px);
	background: var(--accent);
}

.toggle-label {
	font-size: 13px;
	color: var(--muted-strong);
}

.actions {
	display: flex;
	gap: 10px;
}

button {
	font-family: inherit;
	border-radius: 12px;
	cursor: pointer;
	transition: transform 0.14s ease, box-shadow 0.2s ease, background 0.2s ease;
}

button.primary {
	flex: 1;
	border: 0;
	background: var(--accent);
	color: #031c23;
	font-weight: 600;
	padding: 12px 16px;
	box-shadow: 0 12px 24px rgba(72, 215, 240, 0.25);
}

button.primary:disabled {
	opacity: 0.4;
	box-shadow: none;
	cursor: not-allowed;
}

button.ghost {
	border: 1px solid rgba(255, 255, 255, 0.08);
	background: rgba(255, 255, 255, 0.02);
	color: var(--muted);
	padding: 12px 16px;
}

button.ghost.small {
	padding: 8px 12px;
	font-size: 12px;
}

button:hover:not(:disabled) {
	transform: translateY(-1px);
}

.status-line {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	font-size: 13px;
	color: var(--muted-strong);
}

.spinner {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 6px 10px;
	border-radius: 999px;
	background: rgba(0, 0, 0, 0.28);
	border: 1px solid rgba(72, 215, 240, 0.15);
}

.spinner.hidden {
	display: none;
}

.spinner-dot {
	width: 12px;
	height: 12px;
	border-radius: 50%;
	border: 3px solid rgba(72, 215, 240, 0.25);
	border-top-color: var(--accent);
	animation: spin 0.8s linear infinite;
}

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

.card.results {
	margin-top: 8px;
}

.summary-tag {
	font-size: 12px;
	color: var(--muted);
	background: rgba(255, 255, 255, 0.04);
	border-radius: 999px;
	padding: 4px 8px;
}

.route-detail {
	margin-bottom: 16px;
	padding: 14px;
	border-radius: 14px;
	background: rgba(255, 255, 255, 0.02);
	border: 1px solid rgba(255, 255, 255, 0.05);
	min-height: 96px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	font-size: 13px;
	color: var(--muted-strong);
}

.route-detail.empty {
	justify-content: center;
	align-items: center;
	color: var(--muted);
	font-style: italic;
}

.detail-meta {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 10px;
}

@media (max-width: 520px) {
	.detail-meta {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

.detail-meta span {
	display: block;
	font-size: 12px;
	color: var(--muted);
}

.detail-meta strong {
	font-size: 15px;
	color: var(--text);
}

.detail-actions {
	display: flex;
	justify-content: flex-end;
	gap: 10px;
}

.detail-actions button {
	padding: 10px 14px;
	font-size: 13px;
}

.detail-actions button:disabled {
	opacity: 0.4;
	cursor: not-allowed;
}

.results-list {
	display: grid;
	gap: 10px;
	max-height: 300px;
	overflow-y: auto;
	padding-right: 4px;
}

button.route-card {
	font: inherit;
	background: none;
	border: none;
	padding: 0;
}

.route-card {
	border: 1px solid rgba(255, 255, 255, 0.06);
	border-radius: 14px;
	padding: 12px;
	background: rgba(0, 0, 0, 0.22);
	color: var(--text);
	display: grid;
	gap: 8px;
	text-align: left;
	cursor: pointer;
	transition: border 0.2s ease, transform 0.2s ease;
}

.route-card:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}

.route-card:hover {
	/* subtle highlight without shifting layout */
	transform: none;
	border-color: rgba(72, 215, 240, 0.35);
	box-shadow: 0 8px 20px rgba(72, 215, 240, 0.08);
}

.route-card.is-active {
	border-color: rgba(72, 215, 240, 0.5);
	box-shadow: 0 12px 30px rgba(72, 215, 240, 0.18);
}

.route-card {
	will-change: box-shadow;
	-webkit-tap-highlight-color: transparent;
}

.results-list {
	-webkit-overflow-scrolling: touch;
}

.route-card .top-line {
	display: flex;
	align-items: center;
	gap: 8px;
}

.tag {
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	padding: 4px 8px;
	border-radius: 999px;
	background: rgba(72, 215, 240, 0.15);
	color: var(--accent);
}

.tag.loop {
	background: rgba(111, 86, 217, 0.35);
	color: #a998ff;
}

.card-line {
	font-size: 13px;
	color: var(--muted);
}

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

.toast {
	position: fixed;
	top: 24px;
	right: 32px;
	background: var(--glass-strong);
	border: 1px solid rgba(255, 255, 255, 0.08);
	padding: 12px 16px;
	border-radius: 12px;
	box-shadow: 0 14px 32px rgba(0, 0, 0, 0.4);
	z-index: 1400;
	transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.hidden {
	opacity: 0;
	pointer-events: none;
	transform: translateY(-6px);
}

.toast:not(.hidden) {
	opacity: 1;
	transform: translateY(0);
}

.start-pin {
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: var(--accent);
	border: 3px solid rgba(255, 255, 255, 0.85);
	box-shadow: 0 0 22px rgba(72, 215, 240, 0.8);
}

.hidden {
	display: none !important;
}

@media (max-width: 840px) {
	#hud {
		top: 8px;
		left: 8px;
		right: 8px;
		transform: none;
		width: calc(100% - 16px);
		max-height: calc(100vh - 16px);
		gap: 8px;
	}

	#hud .card {
		padding: 10px 12px;
	}

	.collapse-btn {
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.card.results {
		max-height: 40vh;
		overflow: hidden;
	}

	.results-list {
		max-height: 140px;
	}

	.card-head {
		margin-bottom: 8px;
	}

	.card-body {
		gap: 10px;
	}

	.field {
		margin-bottom: 0;
	}

	.actions {
		gap: 8px;
	}

	button.primary,
	button.ghost {
		padding: 10px 14px;
		font-size: 14px;
	}

	.route-detail {
		padding: 10px;
		min-height: 80px;
		margin-bottom: 12px;
	}
}

@media (max-width: 520px) {
	#hud {
		left: 8px;
		right: 8px;
		width: calc(100% - 16px);
		top: 8px;
		bottom: unset;
		transform: none;
		max-height: calc(100vh - 16px);
		gap: 6px;
	}

	#hud .card {
		padding: 8px 10px;
	}

	.card.controls {
		order: 1;
	}

	.card.results {
		order: 2;
	}

	.results-list {
		max-height: 120px;
	}

	.logo {
		font-size: 14px;
	}

	.status-badge {
		font-size: 10px;
		padding: 2px 6px;
	}

	.card-head {
		margin-bottom: 8px;
	}

	.card-body {
		gap: 8px;
	}

	.field label {
		font-size: 11px;
		margin-bottom: 6px;
	}

	.distance-label {
		font-size: 12px;
	}

	button.primary,
		font-size: 14px;
	}

	button.ghost {
		padding: 8px 12px;
		font-size: 13px;
	}

	.status-line {
		font-size: 12px;
	}

	.route-detail {
		padding: 8px;
		min-height: 70px;
		margin-bottom: 10px;
	}

	.route-card {
		padding: 8px 10px;
	}
}

/* Glow routes */
.glow-route {
	stroke-linecap: round;
	stroke-linejoin: round;
	filter: drop-shadow(0 0 8px rgba(72, 215, 240, 0.9)) drop-shadow(0 0 16px rgba(72, 215, 240, 0.6));
	stroke-dasharray: 12 8;
	animation: dash-move 1.6s linear infinite, glow-pulse 2.2s ease-in-out infinite;
}

@keyframes dash-move {
	to {
		stroke-dashoffset: -20;
	}
}

@keyframes glow-pulse {
	0% {
		filter: drop-shadow(0 0 6px rgba(72, 215, 240, 0.6)) drop-shadow(0 0 14px rgba(72, 215, 240, 0.4));
	}
	50% {
		filter: drop-shadow(0 0 14px rgba(72, 215, 240, 1)) drop-shadow(0 0 28px rgba(72, 215, 240, 0.75));
	}
	100% {
		filter: drop-shadow(0 0 6px rgba(72, 215, 240, 0.6)) drop-shadow(0 0 14px rgba(72, 215, 240, 0.4));
	}
}

