:root {
  --bg: #f6f5f3;
  --card: #ffffff;
  --ink: #1b1a19;
  --muted: #6b6864;
  --line: #e2dfdb;
  --accent: #b5442e;
  --accent-ink: #ffffff;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161514;
    --card: #201e1d;
    --ink: #ece9e6;
    --muted: #9a948e;
    --line: #322f2d;
    --accent: #e0674c;
    --accent-ink: #1b1a19;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.wrap { max-width: 720px; margin: 0 auto; padding: 16px; }

.head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 4px 0 14px; }
h1 { font-size: 1.25rem; font-weight: 600; margin: 0; }
h2 { font-size: 0.95rem; font-weight: 600; margin: 0 0 12px; }
.sub { color: var(--muted); font-size: 0.82rem; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
}

#map { height: 340px; border-radius: 10px; z-index: 0; }
.note, .hint { color: var(--muted); font-size: 0.78rem; margin: 10px 0 0; }

/* Detail line, under the map rather than over it: a popup would cover exactly
   the streets you selected the event to look at. */
.detail {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px;
  margin-top: 10px; padding: 10px 12px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  font-size: 0.82rem;
}
.detail .d-mag { font-weight: 600; font-variant-numeric: tabular-nums; }
.detail .d-place { font-weight: 500; }
.detail .d-meta { color: var(--muted); font-variant-numeric: tabular-nums; }
.detail .d-close {
  margin-left: auto; min-height: 32px; padding: 0 12px;
  font: inherit; font-size: 0.78rem; color: var(--muted);
  background: transparent; border: 1px solid var(--line); border-radius: 8px;
  cursor: pointer;
}
.detail .d-close:hover { color: var(--ink); }

.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.row label { font-size: 0.9rem; }
.row input {
  width: 96px; padding: 9px 10px; font: inherit; text-align: right;
  color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 9px;
}

button.primary {
  width: 100%; min-height: 44px; margin-top: 12px;
  font: inherit; font-weight: 600;
  color: var(--accent-ink); background: var(--accent);
  border: 0; border-radius: 10px; cursor: pointer;
}
button.primary:disabled { opacity: 0.55; cursor: default; }
.status { font-size: 0.82rem; margin: 10px 0 0; min-height: 1.2em; }
.status.err { color: var(--accent); }

.events { list-style: none; margin: 0; padding: 0; }
.events li {
  display: flex; align-items: baseline; gap: 10px;
  padding: 9px 8px; margin: 0 -8px;
  min-height: 44px;                        /* touch target */
  border-bottom: 1px solid var(--line); font-size: 0.88rem;
  border-radius: 8px; cursor: pointer;
}
.events li[data-id]:hover { background: var(--bg); }
.events li.sel { background: var(--bg); box-shadow: inset 2px 0 0 var(--accent); }
.events li:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.events li:last-child { border-bottom: 0; }
.events .mag { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 3.1em; }
.events .when { color: var(--muted); margin-left: auto; white-space: nowrap; font-size: 0.8rem; }
.events .empty { color: var(--muted); justify-content: center; }

@media (max-width: 460px) {
  .wrap { padding: 12px; }
  #map { height: 260px; }
  .row { flex-direction: column; align-items: stretch; }
  .row input { width: 100%; text-align: left; }
  .detail .d-close { margin-left: 0; width: 100%; }
}
