:root {
  --bg: #f6f6f3;
  --ink: #1d1d1b;
  --muted: #5f5f58;
  --line: #deded8;
  --card: #ffffff;
  /* Verdict statuses (docs/tiles.md): green free, blue pay, amber limited, red no, grey unknown. */
  --free: #1f9d55;
  --pay: #2563eb;
  --limited: #d98a00;
  --no: #d64545;
  --unknown: #8a8a84;
  --on-status: #ffffff;
  --on-limited: #1d1d1b;
  --accent: #1d4ed8;
  --sheet-h: 0px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161615; --ink: #f1f1ec; --muted: #a8a8a0; --line: #33332f; --card: #1f1f1d;
    --free: #3ccf7a; --pay: #60a5fa; --limited: #f3ad2b; --no: #f06a6a; --unknown: #9a9a93;
    --on-status: #10100f; --on-limited: #10100f; --accent: #7aa2ff;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { display: flex; flex-direction: column; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
a { color: var(--accent); }

/* ---- header ---------------------------------------------------------------------------- */
.bar { padding: 10px 16px 8px; padding-top: max(10px, env(safe-area-inset-top)); border-bottom: 1px solid var(--line);
  background: var(--card); }
.bar h1 { margin: 0; font-size: 18px; letter-spacing: -0.01em; white-space: nowrap; }
.top { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.search { flex: 1; max-width: 360px; }
#q { width: 100%; font: inherit; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--ink); }
.icon-btn { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border: 1px solid var(--line);
  border-radius: 8px; background: var(--bg); color: var(--ink); cursor: pointer; padding: 0; }
.icon-btn svg { width: 20px; height: 20px; }
.controls { display: flex; gap: 6px 10px; flex-wrap: wrap; align-items: center; }
.when { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.stay-group { display: flex; gap: 6px; align-items: center; }
.stay .short { display: none; }
.chip { border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 999px;
  padding: 5px 11px; font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap; }
.chip.on { background: var(--ink); color: var(--card); border-color: var(--ink); }
#when, #stay, #stay-custom { font: inherit; font-size: 13px; padding: 4px 6px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--bg); color: var(--ink); }
.stay, .stay-custom { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; color: var(--muted);
  white-space: nowrap; }
#stay-custom { width: 5.5em; }
.stay-custom[hidden] { display: none; }

.offline { padding: 6px 16px; background: var(--limited); color: var(--on-limited); font-size: 13px; font-weight: 600; }
.offline[hidden] { display: none; }

/* ---- map and panel --------------------------------------------------------------------- */
main { position: relative; flex: 1; display: flex; min-height: 0; }
#map { flex: 1; min-height: 0; }
/* "Find me": icon and text on wide screens, a 44 px icon button on phones. appearance: none and the explicit SVG
   size keep mobile Safari from drawing its own grey button. */
.locate { position: absolute; z-index: 500; right: calc(340px + 12px); top: 12px; display: inline-flex; align-items: center;
  justify-content: center; gap: 6px; min-width: 44px; height: 44px; margin: 0; padding: 0 16px 0 12px; border-radius: 22px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-size: 14px; font-weight: 600;
  line-height: 1; cursor: pointer; box-shadow: 0 1px 5px rgb(0 0 0 / 0.22); -webkit-appearance: none; appearance: none;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.locate svg { display: block; width: 22px; height: 22px; flex: none; color: var(--accent); }
.locate:disabled { cursor: progress; opacity: 0.8; }
.locate-msg { position: absolute; z-index: 500; right: calc(340px + 12px); top: 64px; max-width: min(320px, calc(100% - 24px));
  margin: 0; padding: 8px 12px; border-radius: 10px; background: var(--ink); color: var(--card); font-size: 13px;
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.25); }
.locate-msg:empty { display: none; }

.panel { width: 340px; overflow-y: auto; padding: 12px 16px; border-left: 1px solid var(--line); background: var(--card); }
.handle { display: none; }
.zone { margin: 0 0 6px; font-weight: 600; }
.counts { margin: 0 0 10px; color: var(--muted); font-size: 13px; }
.near { list-style: none; margin: 0 0 12px; padding: 0; }
.near li { border-top: 1px solid var(--line); }
.near .row { display: block; width: 100%; text-align: left; padding: 8px 4px; min-height: 44px; border: 0;
  background: none; color: inherit; font: inherit; cursor: pointer; border-radius: 6px; }
.near .row:hover .head { text-decoration: underline; }
.near .head { font-weight: 600; }
.near .sub { color: var(--muted); font-size: 13px; }
.pill { display: inline-block; min-width: 3.2em; padding: 1px 6px; margin-right: 6px; border-radius: 4px;
  background: var(--c); color: var(--on-status); font-size: 11px; font-weight: 700; text-align: center;
  text-transform: uppercase; letter-spacing: 0.03em; vertical-align: 1px; }
.pill.s-limited { color: var(--on-limited); }
.s-free { --c: var(--free); } .s-pay { --c: var(--pay); } .s-limited { --c: var(--limited); }
.s-no { --c: var(--no); } .s-unknown { --c: var(--unknown); }
.who { font-size: 13px; margin: 0 0 8px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--muted); margin: 0 0 8px;
  padding: 0; list-style: none; }
.sw { display: inline-block; width: 14px; height: 4px; border-radius: 2px; margin-right: 4px; vertical-align: 3px;
  background: var(--c); }
.sw.s-unknown { background: repeating-linear-gradient(90deg, var(--unknown) 0 4px, transparent 4px 7px); }
.layers { display: grid; gap: 4px; font-size: 13px; margin: 0 0 10px; }
.fine { font-size: 12px; color: var(--muted); margin: 0; }
.link { border: 0; background: none; padding: 0; font: inherit; color: var(--accent); text-decoration: underline;
  cursor: pointer; }

/* ---- popups ---------------------------------------------------------------------------- */
.leaflet-popup-content { font-size: 13px; line-height: 1.45; margin: 10px 12px; }
.pop h3 { margin: 0 0 4px; font-size: 15px; }
.pop .verdict { font-weight: 600; margin: 4px 0 2px; }
.pop .sides { margin: 6px 0 0; padding: 0; list-style: none; }
.pop .sides li { margin: 3px 0; }
.pop .stay-answer { margin: 6px 0 0; padding: 6px 8px; border-left: 3px solid var(--c); background: rgb(127 127 127 / 0.08); }
.pop dl { display: grid; grid-template-columns: auto 1fr; gap: 1px 8px; margin: 8px 0 0; }
.pop dt { color: #77776f; } .pop dd { margin: 0; }
.pop .week { border-collapse: collapse; margin: 8px 0 0; font-size: 12px; }
.pop .week caption { text-align: left; color: #77776f; padding-bottom: 2px; }
.pop .week th { text-align: left; font-weight: 600; padding: 1px 10px 1px 0; }
.pop .week td { padding: 1px 0; }
.pop .week td.off { color: #77776f; }
.pop .pay-code { margin: 8px 0 0; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pop .pay-code b { font-size: 15px; letter-spacing: 0.04em; }
.pop .copy, .pop .go { font: inherit; font-size: 12px; padding: 4px 10px; min-height: 32px; border: 1px solid #c8c8c0;
  border-radius: 6px; background: #f6f6f3; color: #1d1d1b; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; }
.pop .directions { display: flex; gap: 6px; margin: 8px 0 0; flex-wrap: wrap; }
.pop .provenance { margin: 8px 0 0; color: #77776f; font-size: 11px; }
.pop.here p { margin: 6px 0 0; }
.pop.here .when { margin: 0; color: #77776f; font-size: 12px; }
.pop.here .zone-line, .pop.here .unmapped { font-weight: 600; }
.pop.here .label { color: #77776f; font-size: 12px; margin: 8px 0 0; }
.pop.here .note { color: #77776f; font-style: italic; }
.pop .here-list { list-style: none; margin: 2px 0 0; padding: 0; }
.pop .here-list li { border-top: 1px solid #e6e6e0; }
.pop .here-list .row { display: block; width: 100%; text-align: left; padding: 6px 2px; min-height: 44px; border: 0;
  background: none; color: inherit; font: inherit; cursor: pointer; border-radius: 6px; }
.pop .here-list .row:hover .head { text-decoration: underline; }
.pop .here-list .head { display: block; font-weight: 600; }
.pop .here-list .sub { display: block; color: #66665f; font-size: 12px; }
.pop.here .go { margin: 6px 0 0; }
/* The tapped spot: a pin whose tip is on the point (iconAnchor in app.js). */
.here-pin { background: none; border: 0; }
.here-pin span { display: block; width: 24px; height: 24px; border-radius: 50% 50% 50% 0; background: #1d1d1b;
  border: 3px solid #fff; transform: rotate(-45deg); box-shadow: 0 1px 4px rgb(0 0 0 / 0.35); }

/* ---- dialogs --------------------------------------------------------------------------- */
dialog { border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink);
  padding: 18px 20px; width: min(460px, calc(100vw - 24px)); max-height: calc(100vh - 48px); }
dialog::backdrop { background: rgb(0 0 0 / 0.4); }
dialog h2 { margin: 0 0 10px; font-size: 18px; }
dialog h3 { margin: 14px 0 4px; font-size: 14px; }
dialog ul { margin: 0; padding-left: 18px; font-size: 14px; }
dialog li { margin: 3px 0; }
dialog fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 0 0 10px; padding: 6px 12px 8px;
  display: flex; flex-wrap: wrap; gap: 4px 16px; }
dialog fieldset label, dialog .check { display: inline-flex; gap: 6px; align-items: center; min-height: 36px; }
dialog .field { display: grid; gap: 4px; margin: 6px 0; font-weight: 600; font-size: 14px; }
dialog .field input { font: inherit; font-weight: 400; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--bg); color: var(--ink); text-transform: uppercase; }
dialog .hint { color: var(--muted); font-size: 13px; }
dialog .warn { padding: 8px 10px; border-radius: 8px; background: rgb(217 138 0 / 0.14); }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.btn { font: inherit; padding: 8px 16px; min-height: 40px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--ink); cursor: pointer; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---- narrow screens: bottom sheet ------------------------------------------------------ */
@media (max-width: 720px) {
  .bar { padding: 8px 12px 6px; padding-top: max(8px, env(safe-area-inset-top)); }
  .top { gap: 8px; margin-bottom: 6px; }
  .bar h1 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .search { max-width: none; }
  .controls { flex-wrap: nowrap; }
  .when { flex: 1; min-width: 0; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  .stay .long { display: none; }
  .stay .short { display: inline; }
  .when::-webkit-scrollbar { display: none; }
  .panel { position: absolute; z-index: 800; left: 0; right: 0; bottom: 0; width: auto; max-height: 34vh;
    padding: 0 16px 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); border-left: 0;
    border-top: 1px solid var(--line); border-radius: 14px 14px 0 0; box-shadow: 0 -4px 16px rgb(0 0 0 / 0.15);
    overflow-y: hidden; transition: max-height 0.2s ease; touch-action: pan-y; }
  .panel.open { max-height: 78vh; overflow-y: auto; }
  .panel.dragging { transition: none; }
  .handle { display: grid; place-items: center; width: 100%; height: 44px; margin: 0; padding: 0; border: 0;
    background: none; cursor: grab; touch-action: none; }
  .grabber { width: 40px; height: 5px; border-radius: 3px; background: var(--line); }
  .panel:not(.open) .near li:nth-child(n+2), .panel:not(.open) .more { display: none; }
  .leaflet-bottom { bottom: var(--sheet-h); }
  .locate { top: 10px; right: 10px; width: 44px; padding: 0; border-radius: 50%; }
  .locate .label { display: none; }
  .locate-msg { top: 62px; right: 10px; left: 10px; max-width: none; }
}
@media (max-width: 720px), (pointer: coarse) {
  .chip, #when, #stay, #stay-custom, .icon-btn, #q, .btn { min-height: 44px; }
  .icon-btn { width: 44px; }
  .layers label, .who .link, .fine .link { display: inline-flex; align-items: center; min-height: 44px; }
  .pop .copy, .pop .go { min-height: 44px; padding: 4px 14px; }
}
