:root {
  --bg: #ffffff;
  --fg: #1d2421;
  --muted: #5e6a64;
  --line: #d9dfdb;
  --accent: #e2531c;
  --st: #8a3b12;
  --dt: #d9822b;
  --dr: #b59a6a;
  --rd: #8b8f93;
  --miss: #7b3fe4;
  --no: #d0182f;
  --route: #e2531c;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1f1d;
    --fg: #e8ece9;
    --muted: #9aa59f;
    --line: #333a36;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg);
  font: 14px/1.35 system-ui, -apple-system, "Segoe UI", sans-serif; }
#map { position: absolute; inset: 0; }

#panel {
  position: absolute; z-index: 1000; top: 10px; left: 10px; width: 360px;
  max-height: calc(100% - 20px); overflow: auto;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 4px 18px rgba(0,0,0,.18); padding: 10px 12px;
}
#panel header { display: flex; align-items: center; justify-content: space-between; }
#panel h1 { font-size: 16px; margin: 0; }
#collapse { border: 0; background: none; color: var(--fg); font-size: 16px; cursor: pointer; }
#panel.collapsed > :not(header) { display: none; }
#panel.collapsed #collapse { transform: rotate(180deg); }

.hint { color: var(--muted); font-size: 12.5px; margin: 6px 0 8px; }
.row { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; margin: 6px 0; }
label { font-size: 12.5px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
label.check { color: var(--fg); }
select, button, input[type=file] { font: inherit; font-size: 13px; color: var(--fg); }
select, button { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; }
button { cursor: pointer; }
button:hover { border-color: var(--accent); }
.buttons button { flex: 1 1 auto; }

.hidden { display: none !important; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 10px; margin: 10px 0 6px; }
.stat b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 11.5px; color: var(--muted); }
.stats .wide { grid-column: 1 / -1; font-size: 12.5px; }
.stats .warn { color: var(--no); }
.bar { display: flex; height: 10px; border-radius: 3px; overflow: hidden; margin-top: 3px; }
.bar i { display: block; height: 100%; }

#profile { width: 100%; height: 150px; display: block; cursor: crosshair; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 11px; color: var(--muted); margin-top: 4px; }
.legend i, .netlegend i { display: inline-block; width: 12px; height: 8px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }
.netlegend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; margin: 8px 0; }
.netlegend i.dash { background: repeating-linear-gradient(90deg, var(--c) 0 4px, transparent 4px 7px); height: 4px; }
details summary { cursor: pointer; font-weight: 600; margin-top: 8px; }
.small { font-size: 11.5px; color: var(--muted); }
.small table { border-collapse: collapse; margin-top: 6px; }
.small td { padding: 1px 8px 1px 0; }

.toast {
  position: absolute; z-index: 1100; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: rgba(20,24,22,.9); color: #fff; padding: 8px 14px; border-radius: 8px; font-size: 13px;
}
.wp-icon {
  width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 3px solid var(--route);
  box-shadow: 0 1px 4px rgba(0,0,0,.4);
}
.wp-icon.first { border-color: #1a8f3a; }
.wp-icon.last { border-color: #222; }
.hover-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--route); border: 2px solid #fff; }
.leaflet-tooltip.trail-tip { font-size: 12px; }

@media (max-width: 640px) {
  #panel { left: 0; right: 0; top: auto; bottom: 0; width: auto; max-height: 55%;
    border-radius: 12px 12px 0 0; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .stats { grid-template-columns: repeat(3, 1fr); }
}
