:root {
	--ink: #1c2126;
	--muted: #667079;
	--line: #e4e7ea;
	--soft: #f4f5f6;
	--panel: #fff;
	--accent: #ff9828;
	--accent-ink: #a85600;
	--danger: #b42318;
	--radius: 8px;
	--panel-w: 320px;
	--profile-h: 150px;
	/* Leaflet konci na 1000 */
	--z-float: 1100;
	--z-toast: 1200;
	--z-drop: 1300;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
	margin: 0;
	height: 100dvh;
	display: flex;
	color: var(--ink);
	background: var(--panel);
	font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
	-webkit-font-smoothing: antialiased;
}

h1, h2, p, ul, dl, dd { margin: 0; padding: 0; }
ul { list-style: none; }
button, input { font: inherit; color: inherit; }

.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

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

/* --- panel --- */
#panel {
	flex: 0 0 var(--panel-w);
	display: flex;
	flex-direction: column;
	gap: 16px;
	padding: 16px;
	padding-left: max(16px, env(safe-area-inset-left));
	overflow-y: auto;
	border-right: 1px solid var(--line);
}

.brand { display: flex; align-items: baseline; gap: 8px; }
.brand-name { font-size: 22px; font-weight: 700; }
.brand-by { color: var(--accent-ink); font-weight: 600; }

.row { display: flex; gap: 8px; }
.row > .btn { flex: 1; }

.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 38px;
	padding: 0 12px;
	border: 1px solid var(--line);
	border-radius: var(--radius);
	background: var(--panel);
	font-weight: 600;
	text-align: center;
	cursor: pointer;
	user-select: none;
}
.btn:hover { background: var(--soft); }
.btn:disabled { color: #a3abb2; background: var(--panel); cursor: default; }
.btn[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: #fff; }
.btn-primary { border-color: var(--accent); background: var(--accent); color: var(--ink); }
.btn-primary:hover { border-color: #f58a12; background: #f58a12; }
.btn-primary:disabled { border-color: var(--line); background: var(--soft); }

.field { display: flex; flex-direction: column; gap: 4px; }
.label, legend, section h2 { color: var(--muted); font-size: 12px; font-weight: 600; }
.field input {
	min-height: 38px;
	padding: 0 10px;
	border: 1px solid var(--line);
	border-radius: var(--radius);
	background: var(--panel);
}

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; padding: 12px 0; border-block: 1px solid var(--line); }
.stats dt { color: var(--muted); font-size: 12px; }
.stats dd { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.25; }

section { display: flex; flex-direction: column; gap: 8px; }

.surface-bar { display: flex; height: 8px; overflow: hidden; border-radius: 4px; background: var(--soft); }
.surface-bar i { display: block; height: 100%; }
.surface-list { display: flex; flex-direction: column; gap: 2px; }
.surface-list li { display: flex; align-items: center; gap: 8px; }
.surface-list i { flex: none; width: 10px; height: 10px; border-radius: 3px; }
.surface-list span:last-child { margin-left: auto; font-variant-numeric: tabular-nums; }
.status { min-height: 20px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
legend { padding: 0; margin-bottom: 8px; }
.modes { display: grid; grid-template-columns: repeat(4, 1fr); overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); }
.mode { position: relative; display: block; cursor: pointer; }
.mode + .mode { border-left: 1px solid var(--line); }
.mode input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.mode span { display: flex; align-items: center; justify-content: center; min-height: 38px; font-size: 13px; font-weight: 600; }
.mode:hover span { background: var(--soft); }
.mode input:checked + span { background: var(--accent); }
.mode input:focus-visible + span { outline: 2px solid var(--accent-ink); outline-offset: -2px; }
.mode-hint { margin-top: 6px; color: var(--muted); font-size: 12px; }

.tools { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.hints { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12px; text-wrap: pretty; }
.hints b { color: var(--ink); font-weight: 600; }

#download { position: sticky; bottom: 0; flex: none; min-height: 44px; margin-top: auto; }

/* --- mapa --- */
#stage { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; }
#map { flex: 1; min-height: 0; background: #e8ebed; }
#map.crosshair, #map.crosshair .leaflet-grab, #map.crosshair .leaflet-interactive { cursor: crosshair; }
body.busy #map, body.busy #map .leaflet-grab { cursor: progress; }

.profile { position: relative; flex: 0 0 var(--profile-h); border-top: 1px solid var(--line); background: var(--panel); }
#profile { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }

.search { position: absolute; top: 12px; left: 12px; z-index: var(--z-float); width: min(280px, calc(100% - 200px)); }
.search input {
	width: 100%;
	min-height: 38px;
	padding: 0 12px;
	border: 1px solid var(--line);
	border-radius: var(--radius);
	background: var(--panel);
	box-shadow: 0 1px 3px rgba(0, 0, 0, .15);
}
.search ul { margin-top: 4px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: 0 1px 3px rgba(0, 0, 0, .15); }
.search button { display: block; width: 100%; padding: 8px 12px; border: 0; background: none; text-align: left; cursor: pointer; }
.search button:hover { background: var(--soft); }
.search small { display: block; color: var(--muted); font-size: 12px; }

.bases {
	position: absolute;
	top: 12px;
	right: 12px;
	z-index: var(--z-float);
	display: flex;
	overflow: hidden;
	border: 1px solid var(--line);
	border-radius: var(--radius);
	background: var(--panel);
	box-shadow: 0 1px 3px rgba(0, 0, 0, .15);
}
.bases button { min-height: 36px; padding: 0 10px; border: 0; background: none; font-weight: 600; cursor: pointer; }
.bases button + button { border-left: 1px solid var(--line); }
.bases button:hover { background: var(--soft); }
.bases button[aria-pressed="true"] { background: var(--ink); color: #fff; }

.leaflet-top.leaflet-right { top: 56px; }

/* decentni popisek zdroje mapy jako na webu MCC */
.leaflet-container .leaflet-control-attribution { padding: 0 6px; border-top-left-radius: 6px; background: rgba(255, 255, 255, .55); color: #8b9197; font-size: 10px; line-height: 1.5; }
.leaflet-container .leaflet-control-attribution a { color: #8b9197; text-decoration: none; }
.leaflet-container .leaflet-control-attribution a:hover { color: var(--ink); text-decoration: underline; }

.start {
	position: absolute;
	inset: 0 0 var(--profile-h);
	z-index: var(--z-float);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	pointer-events: none;
}
.start[hidden] { display: none; }
.start-card {
	display: flex;
	flex-direction: column;
	gap: 12px;
	width: min(400px, 100%);
	padding: 24px;
	border-radius: 12px;
	background: var(--panel);
	box-shadow: 0 4px 16px rgba(0, 0, 0, .18);
	pointer-events: auto;
}
.start-card h1 { font-size: 22px; line-height: 1.2; text-wrap: balance; }
.start-card p { text-wrap: pretty; }
.start-alt { color: var(--muted); font-size: 13px; text-align: center; }

.section {
	position: absolute;
	left: 50%;
	bottom: calc(var(--profile-h) + 12px);
	z-index: var(--z-float);
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 8px 12px;
	width: max-content;
	max-width: calc(100% - 32px);
	padding: 8px 12px;
	border-radius: 10px;
	background: var(--panel);
	box-shadow: 0 2px 10px rgba(0, 0, 0, .22);
	transform: translateX(-50%);
}
.section[hidden] { display: none; }
#section-info { font-weight: 600; font-variant-numeric: tabular-nums; }
.section-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.section-actions .btn[hidden] { display: none; }

.toast {
	position: fixed;
	left: 50%;
	bottom: calc(var(--profile-h) + 24px + env(safe-area-inset-bottom));
	z-index: var(--z-toast);
	max-width: min(520px, calc(100% - 32px));
	padding: 10px 14px;
	border-radius: var(--radius);
	background: var(--ink);
	color: #fff;
	transform: translateX(-50%);
	text-wrap: pretty;
}
.toast[hidden] { display: none; }

.drop {
	position: fixed;
	inset: 0;
	z-index: var(--z-drop);
	display: flex;
	align-items: center;
	justify-content: center;
	border: 4px dashed var(--accent);
	background: rgba(255, 255, 255, .85);
	font-size: 24px;
	font-weight: 700;
	pointer-events: none;
}
.drop[hidden] { display: none; }

dialog { width: min(400px, calc(100% - 32px)); padding: 20px; border: 0; border-radius: 12px; color: var(--ink); box-shadow: 0 8px 28px rgba(0, 0, 0, .28); }
dialog::backdrop { background: rgba(0, 0, 0, .35); }
dialog h2 { margin-bottom: 8px; font-size: 18px; }
dialog p { margin-bottom: 16px; text-wrap: pretty; overflow-wrap: anywhere; }

/* --- body na mape --- */
.anchor { border: 2px solid var(--ink); border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 1.5px #fff; }
.anchor.auto { border-width: 1.5px; background: #fff; }
#map.far .anchor.auto { display: none; }
.anchor.start, .anchor.finish {
	display: flex;
	align-items: center;
	justify-content: center;
	border-width: 0;
	color: #fff;
	font-size: 12px;
	font-weight: 700;
	line-height: 1;
}
.anchor.start { background: #15803d; }
.anchor.finish { background: #b42318; }
.ghost { border: 2px solid var(--ink); border-radius: 50%; background: #fff; box-shadow: 0 0 0 1.5px #fff; cursor: grab; }
.arrow { display: flex; align-items: center; justify-content: center; pointer-events: none; }
.arrow span { display: block; width: 0; height: 0; border-inline: 5px solid transparent; border-bottom: 8px solid #fff; filter: drop-shadow(0 0 1px rgba(0, 0, 0, .9)); }
.wpt { border: 1.5px solid #fff; border-radius: 3px; background: var(--ink); transform: rotate(45deg); }
.spot { border: 2px solid #fff; border-radius: 50%; background: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .4); }

.leaflet-popup-content { margin: 10px 12px; font: 13px/1.4 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; }
.popup { display: flex; flex-direction: column; gap: 6px; min-width: 170px; }
.popup b { font-variant-numeric: tabular-nums; }
.popup .btn { min-height: 34px; }

@media (max-width: 800px) {
	:root { --profile-h: 110px; }
	body { flex-direction: column; height: auto; }
	#stage { order: -1; flex: none; height: 72dvh; }
	#panel { flex: none; border-right: 0; border-top: 1px solid var(--line); padding-bottom: max(16px, env(safe-area-inset-bottom)); }
	.bases { top: 58px; left: 12px; right: auto; }
	.bases button { padding: 0 8px; }
	.search { left: 12px; right: 12px; width: auto; }
	.leaflet-top.leaflet-right { top: 58px; }
	.section { bottom: calc(var(--profile-h) + 8px); }
	.toast { bottom: 16px; }
}
