:root {
  --ink: #16222C;
  --mist: #EEF2F5;
  --line: #D3DCE3;
  --blue: #1F5FD6;
  --stop: #B3261E;
  --raw: #C8372D;
  --clean: #12805C;
  --muted: #5B6B78;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--mist);
}
#map { position: fixed; inset: 0; z-index: 0; }

.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  max-height: 70vh; overflow-y: auto;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  background: #fff;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -6px 24px rgba(22, 34, 44, .18);
}
@media (min-width: 720px) {
  .sheet { left: 16px; right: auto; bottom: 16px; width: 380px; border-radius: 16px; padding-bottom: 16px; }
}

.modes { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--mist); border-radius: 12px; padding: 4px; gap: 4px; }
.modes input { position: absolute; opacity: 0; pointer-events: none; }
.modes span { display: block; text-align: center; padding: 10px 0; border-radius: 9px; font-weight: 600; font-size: 15px; cursor: pointer; color: var(--muted); }
.modes input:checked + span { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(22, 34, 44, .2); }
.modes input:focus-visible + span { outline: 3px solid var(--blue); outline-offset: 1px; }
.modes.locked { opacity: .5; pointer-events: none; }

.action {
  display: block; width: 100%; margin: 14px 0 8px; padding: 18px;
  font: inherit; font-size: 18px; font-weight: 700; color: #fff;
  border: 0; border-radius: 14px; cursor: pointer;
}
.action.start { background: var(--blue); }
.action.stop { background: var(--stop); }
.action:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.action:disabled { opacity: .6; }

.status { margin: 0 0 12px; color: var(--muted); font-size: 14px; min-height: 1.3em; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 0 0 12px; }
.stats div { background: var(--mist); border-radius: 10px; padding: 8px; }
.stats dt { font-size: 11px; color: var(--muted); line-height: 1.2; min-height: 2.4em; }
.stats dd { margin: 0; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }

.dists { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 12px; }
.dists div { border-radius: 10px; padding: 8px; border: 1px solid var(--line); }
.dists div:first-child { border-left: 4px solid var(--raw); }
.dists div:last-child { border-left: 4px solid var(--clean); }
.dists dt { font-size: 11px; color: var(--muted); }
.dists dd { margin: 0; font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }

.layers { display: flex; gap: 16px; margin-bottom: 8px; font-size: 14px; }
.layers label { display: flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 18px; height: 4px; border-radius: 2px; }
.sw.raw { background: var(--raw); }
.sw.clean { background: var(--clean); }

.history { border-top: 1px solid var(--line); padding-top: 10px; font-size: 14px; }
.history summary { cursor: pointer; font-weight: 600; }
.history ul { list-style: none; margin: 8px 0 0; padding: 0; }
.history li { margin: 0; }
.history li.empty { color: var(--muted); }
.history button {
  width: 100%; text-align: left; font: inherit; background: none; border: 0;
  border-bottom: 1px solid var(--line); padding: 10px 2px; cursor: pointer; color: var(--ink);
}
.history button:focus-visible { outline: 3px solid var(--blue); }
.history small { display: block; color: var(--muted); }
