html, body, #map { margin: 0; height: 100%; }
body { font: 15px/1.4 system-ui, sans-serif; background: #1d1a16; color: #1d1a16; }

.maplibregl-ctrl button.topo { font: 700 12px system-ui, sans-serif; width: 100%; min-width: 29px; padding: 0 5px; }
.maplibregl-ctrl button.topo.on { background: #1f6feb; color: #fff; }
.maplibregl-ctrl button.topo:disabled { opacity: 0.35; }

#menu {
  position: absolute; z-index: 10; top: 0; left: 0; bottom: 0; width: min(340px, 88vw);
  overflow-y: auto; box-sizing: border-box; padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
  background: #f7f3ea; box-shadow: 0 0 24px #0006;
}
#menu[hidden] { display: none; }
#menu .head { display: flex; align-items: center; justify-content: space-between; }
#menu h2 { margin: 0; font-size: 20px; }
#menu h3 { margin: 18px 0 6px; font-size: 15px; }
#menu p { margin: 4px 0 8px; }
#menu .small { font-size: 12px; color: #6b645a; }
#menu-close { border: 0; background: none; font-size: 20px; padding: 4px 8px; cursor: pointer; }

.btn {
  display: inline-block; padding: 7px 14px; border: 1px solid #1d1a16; border-radius: 8px;
  background: #fff; font: inherit; cursor: pointer;
}
.row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.row input { width: 5em; font: inherit; padding: 4px 6px; }

#gpx-list { list-style: none; margin: 0 0 8px; padding: 0; }
#gpx-list li { display: flex; align-items: center; gap: 6px; padding: 3px 0; }
#gpx-list li span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
#gpx-list li button { border: 0; background: none; cursor: pointer; font-size: 16px; }
#gpx-list li button.rm { color: #c0392b; }
#gpx-list li button.fly { opacity: 0.35; }
#gpx-list li button.fly.on { opacity: 1; }
#gpx-list li button.fly:disabled { opacity: 0.1; cursor: default; }
#gpx-list:empty::before { content: 'None loaded.'; color: #6b645a; }

#profile {
  position: absolute; z-index: 5; left: 0; right: 0; bottom: 0; max-height: 50vh; overflow-y: auto;
  box-sizing: border-box; padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
  background: #f7f3ea; box-shadow: 0 0 16px #0005;
}
#profile[hidden], #profile [hidden] { display: none !important; }
#profile .head { display: flex; align-items: center; gap: 10px; }
#profile-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#profile-at { flex: 1; text-align: right; font-size: 13px; font-variant-numeric: tabular-nums; font-weight: 600; }
#profile .head .btn { padding: 3px 10px; }
#profile-close { border: 0; background: none; font-size: 20px; padding: 2px 6px; cursor: pointer; }
#profile p { margin: 6px 0; }
#profile .small { font-size: 12px; color: #6b645a; }

#profile-sum { display: flex; flex-wrap: wrap; gap: 0 14px; font-size: 13px; font-variant-numeric: tabular-nums; }
#profile-sum b { font-weight: 600; color: #6b645a; margin-right: 4px; }
#profile-ctl { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin: 6px 0 2px; font-size: 12px; }
#profile-ctl .grp, #profile-ys { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 3px 10px; }
#profile-ys .grp { gap: 3px; }
#profile-ys .grp.muted { opacity: 0.5; }
#profile-ctl i { font-style: normal; color: #6b645a; margin-right: 2px; }
#profile-ctl button {
  border: 1px solid var(--c, #1d1a16); border-radius: 10px; padding: 1px 8px; background: #fff; color: var(--c, #1d1a16);
  font: inherit; cursor: pointer;
}
#profile-ctl button.dash { border-style: dashed; }
#profile-ctl button.on { background: var(--c, #1d1a16); color: #fff; }
#profile-ctl button:disabled { opacity: 0.35; cursor: default; }
#profile-smooth { display: inline-flex; align-items: center; gap: 4px; font-variant-numeric: tabular-nums; }
#profile-smooth input { width: min(120px, 30vw); }
#profile-smooth span { min-width: 3.5em; }

#profile-chart { position: relative; height: 120px; margin: 4px 0 0; touch-action: none; }
#profile-chart svg { width: 100%; height: 100%; display: block; cursor: crosshair; }
#profile-chart .lines path { fill: none; stroke-width: 2; vector-effect: non-scaling-stroke; }
#profile-chart .breaks line { stroke: #6b645a; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
#profile-chart .cursor { stroke: #c0392b; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
#profile-chart .hi, #profile-chart .lo {
  position: absolute; left: 2px; display: flex; flex-wrap: wrap; gap: 0 8px; font-size: 11px; pointer-events: none;
}
#profile-chart .hi { top: 0; }
#profile-chart .lo { bottom: 0; }
#profile-chart .hi span, #profile-chart .lo span { background: #f7f3eacc; padding: 0 2px; color: #6b645a; }
#profile-x { display: flex; justify-content: space-between; font-size: 11px; color: #6b645a; font-variant-numeric: tabular-nums; }

#profile-table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
#profile-table th, #profile-table td { padding: 2px 6px; text-align: right; }
#profile-table th:first-child, #profile-table td:first-child { text-align: left; }
#profile-table th { color: #6b645a; font-weight: 600; border-bottom: 1px solid #d8d0c0; }
#profile-table tr.total td { font-weight: 700; border-top: 1px solid #d8d0c0; }

.profile-marker { width: 12px; height: 12px; border-radius: 50%; background: #c0392b; border: 2px solid #fff; box-shadow: 0 0 4px #0008; }

#bars {
  position: absolute; z-index: 4; top: 10px; left: 50%; transform: translateX(-50%); max-width: calc(100vw - 110px);
  display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none;
}
#surface, #sun {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px 8px; padding: 4px 10px;
  border-radius: 8px; background: #f7f3eae6; box-shadow: 0 0 8px #0004; font-size: 13px;
  font-variant-numeric: tabular-nums; pointer-events: auto;
}
#surface[hidden], #sun[hidden] { display: none; }
#sun .btn { padding: 2px 8px; }
#sun-time { width: min(200px, 45vw); }
#sun-tv { min-width: 6.5em; }
#sun-info { color: #6b645a; }
#surface input { width: min(160px, 35vw); }
.row input.wide { width: 100%; }

#rv {
  position: relative; display: flex; flex-direction: column; gap: 4px; padding: 6px 30px 6px 10px; border-radius: 8px;
  background: #f7f3eae6; box-shadow: 0 0 8px #0004; font-size: 12px; font-variant-numeric: tabular-nums;
  pointer-events: auto; max-width: min(640px, calc(100vw - 110px));
}
#rv[hidden], #rv [hidden] { display: none !important; }
#rv-points, #rv-ctl { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
#rv .grp { display: inline-flex; align-items: center; gap: 3px; }
#rv i { font-style: normal; color: #6b645a; }
#rv button:not(#rv-close) {
  border: 1px solid var(--c, #1d1a16); border-radius: 10px; padding: 1px 8px; background: #fff; color: var(--c, #1d1a16);
  font: inherit; font-weight: 600; cursor: pointer;
}
#rv button.dash { border-style: dashed; }
#rv button.on { background: var(--c, #1d1a16); color: #fff; }
#rv select { font: inherit; padding: 0 2px; }
#rv-options { align-self: flex-start; max-width: 100%; font-weight: 600; }
#rv-ctl label { display: inline-flex; align-items: center; gap: 4px; }
#rv-ctl input { width: min(110px, 22vw); }
#rv-ctl span { min-width: 3.2em; }
#rv-info { color: #3a332a; }
#rv-close { position: absolute; top: 2px; right: 2px; border: 0; background: none; font-size: 18px; cursor: pointer; }
.rv-marker {
  width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 4px #0008;
  color: #fff; font: 700 11px/26px system-ui, sans-serif; text-align: center; cursor: grab;
}
#surface-hv { min-width: 4em; text-align: right; }
