:root {
  --free: #1b9e77;
  --pay: #2c6fbb;
  --shared: #8a4fbf;
  --permit: #e0531f;
  --unknown: #8a8f98;
  --moto: #f2c200;
  --moto-edge: #7a6000;
  --zone: #1f3a5f;
  --ink: #17212b;
  --muted: #5b6672;
  --panel: #ffffff;
  --line: #e3e7ec;
  --accent: #1f3a5f;
  --shadow: 0 2px 10px rgba(15, 30, 50, .18);
  --radius: 14px;
  color-scheme: light;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #eef0f2; color: var(--ink); }
#map { position: fixed; inset: 0; }

/* ---------- top bar ---------- */
.top {
  position: fixed; left: 0; right: 0; top: 0; z-index: 2;
  padding: calc(env(safe-area-inset-top) + 10px) 12px 0;
  pointer-events: none;
}
.top > * { pointer-events: auto; }
.search-wrap { position: relative; max-width: 560px; margin: 0 auto; }
.search {
  display: flex;
  background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.search input {
  flex: 1; min-width: 0; border: 0; padding: 13px 14px; font-size: 16px; /* 16px stops iOS zooming */
  background: transparent; color: var(--ink); outline: none;
}
.search input::placeholder { color: #8b95a0; text-transform: none; }
.search button {
  border: 0; background: var(--accent); color: #fff; width: 52px; cursor: pointer;
  display: grid; place-items: center;
}
.search button:active { filter: brightness(1.2); }

.bar {
  display: flex; gap: 8px; align-items: center; max-width: 560px; margin: 8px auto 0;
  overflow-x: auto; scrollbar-width: none;
}
.bar::-webkit-scrollbar { display: none; }
.bar > * { flex-shrink: 0; }
.clock, .legend {
  background: rgba(255,255,255,.94); border-radius: 999px; box-shadow: var(--shadow);
  font-size: 13px; white-space: nowrap;
}
.clock { padding: 6px 11px; font-weight: 600; }
.legend { display: flex; gap: 6px; list-style: none; margin: 0; padding: 6px 9px; font-size: 12px; }
.legend li { display: flex; align-items: center; }
.legend i { width: 11px; height: 11px; border-radius: 3px; background: var(--c); display: inline-block; }
.legend button {
  display: flex; align-items: center; gap: 4px; border: 0; background: none; padding: 0;
  font: inherit; color: inherit; cursor: pointer;
}
.legend button.off { color: var(--muted); text-decoration: line-through; }
.legend button.off i { background: none; box-shadow: inset 0 0 0 1.5px var(--c); }
.legend [data-cat="moto"] i { box-shadow: inset 0 0 0 1px var(--moto-edge); }
.legend [data-cat="moto"].off i { box-shadow: inset 0 0 0 1.5px var(--moto-edge); }

/* ---------- bottom sheet ---------- */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 3;
  max-width: 560px; margin: 0 auto; max-height: 70vh; overflow-y: auto;
  background: var(--panel); border-radius: 18px 18px 0 0; box-shadow: 0 -4px 20px rgba(15,30,50,.2);
  padding: 18px 18px calc(env(safe-area-inset-bottom) + 18px);
  animation: up .18s ease-out;
}
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.close {
  position: absolute; top: 10px; right: 10px; width: 36px; height: 36px; border-radius: 50%;
  border: 0; background: #f0f2f5; color: var(--ink); display: grid; place-items: center; cursor: pointer;
}
.sheet h2 { margin: 0 44px 2px 0; font-size: 18px; }
.sheet .sub { color: var(--muted); font-size: 14px; margin-bottom: 12px; }
.status {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px; border-radius: 12px;
  background: color-mix(in srgb, var(--c) 12%, white); border: 1px solid color-mix(in srgb, var(--c) 35%, white);
  margin-bottom: 14px;
}
.status i { flex: none; width: 14px; height: 14px; border-radius: 4px; background: var(--c); margin-top: 3px; }
.status b { display: block; font-size: 16px; }
.status span { font-size: 14px; color: var(--muted); }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; margin: 0 0 14px; font-size: 15px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.pbp { display: inline-flex; align-items: center; gap: 8px; }
.pbp code { font-size: 16px; font-weight: 700; letter-spacing: .5px; }
.btn {
  border: 1px solid var(--line); background: #f7f8fa; color: var(--ink); border-radius: 10px;
  padding: 6px 10px; font-size: 14px; cursor: pointer; text-decoration: none; display: inline-block;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.warn {
  font-size: 13px; background: #fff6e0; border: 1px solid #f1d38a; border-radius: 10px; padding: 8px 10px;
  margin-bottom: 12px;
}
.fine { font-size: 12px; color: var(--muted); margin: 0; }

/* ---------- misc ---------- */
.toast {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 150px); transform: translateX(-50%);
  z-index: 4; background: var(--ink); color: #fff; padding: 9px 14px; border-radius: 10px; font-size: 14px;
  box-shadow: var(--shadow); max-width: calc(100% - 32px);
}
.loading {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 24px); transform: translateX(-50%);
  z-index: 2; background: var(--panel); padding: 10px 16px; border-radius: 999px; box-shadow: var(--shadow);
  font-size: 14px;
}
.loading[hidden], .toast[hidden], .sheet[hidden] { display: none; }
.maplibregl-ctrl-bottom-right { margin-bottom: env(safe-area-inset-bottom); }
.maplibregl-ctrl-group button { width: 40px; height: 40px; }
.muted { color: var(--muted); font-size: 13px; }
.prices { border-collapse: collapse; font-variant-numeric: tabular-nums; }
.prices td { padding: 1px 0; }
.prices td + td { padding-left: 14px; text-align: right; font-weight: 600; }

/* ---------- stay planner ---------- */
.pill {
  border: 0; border-radius: 999px; box-shadow: var(--shadow); font: inherit; font-size: 13px;
  white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
}
.pill.chip { background: var(--accent); color: #fff; padding: 0; overflow: hidden; }
.pill.chip button { border: 0; background: none; color: inherit; font: inherit; font-weight: 600; padding: 6px 10px; cursor: pointer; }
.pill.chip button + button { border-left: 1px solid rgba(255,255,255,.3); padding: 6px 10px; }
.pill[hidden], .clock[hidden] { display: none; }
.plan-fab {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 2;
  bottom: calc(env(safe-area-inset-bottom) + 40px);
  display: inline-flex; align-items: center; gap: 9px; white-space: nowrap;
  border: 0; border-radius: 999px; background: var(--accent); color: #fff; cursor: pointer;
  font: inherit; font-size: 16px; font-weight: 700; padding: 14px 24px;
  box-shadow: 0 6px 18px rgba(15, 30, 50, .35), 0 0 0 3px rgba(255, 255, 255, .9);
}
.plan-fab:active { transform: translateX(-50%) scale(.97); }
.plan-fab[hidden] { display: none; }

.plan-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.plan-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 600; }
.plan-form .full { grid-column: 1 / -1; }
.plan-form .row { display: flex; gap: 8px; }
.plan-form input, .plan-form select {
  font: inherit; font-size: 16px; color: var(--ink); padding: 9px 10px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; min-width: 0; width: 100%;
}
.plan-form .row input { flex: 1; }
.plan-form .row .btn { white-space: nowrap; }
.btn.big { padding: 12px 14px; font-size: 16px; font-weight: 600; }
.btn:disabled { opacity: .6; }

.plan-summary { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 12px;
  background: #e8f5f0; border: 1px solid #b7e0d2; margin-bottom: 10px; }
.plan-summary b { font-size: 17px; }
.plan-summary span { font-size: 13px; color: var(--muted); }
.plan-summary.none { background: #fff6e0; border-color: #f1d38a; }
.options { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.option {
  width: 100%; display: grid; grid-template-columns: 62px 1fr auto; gap: 10px; align-items: center; text-align: left;
  border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 9px 10px; font: inherit; color: inherit; cursor: pointer;
}
.option:active { background: #f3f5f8; }
.option .price { font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums; }
.option .price.best { color: #137a5c; }
.option .what { display: flex; flex-direction: column; min-width: 0; font-size: 14px; }
.option .what small { color: var(--muted); font-size: 12.5px; }
.option .dist { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.plan-box { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 12px; margin-bottom: 14px; }
.plan-box span { font-size: 13.5px; color: var(--muted); }
.plan-box.ok { background: #e8f5f0; border: 1px solid #b7e0d2; }
.plan-box.no { background: #f4f5f7; border: 1px solid #dde1e6; }
.back { border: 0; background: none; color: var(--accent); font: inherit; font-size: 14px; font-weight: 600; padding: 0 0 8px; cursor: pointer; }
.sheet[data-view="results"] { max-height: 55vh; }

/* ---------- map layers ---------- */
.switches { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.switch {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border: 1px solid var(--line);
  border-radius: 12px; cursor: pointer;
}
.switch input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; margin: 0; }
.switch span { display: flex; flex-direction: column; gap: 1px; }
.switch b { display: flex; align-items: center; gap: 6px; font-size: 15px; }
.switch small { font-size: 13px; color: var(--muted); }
.swatch { width: 12px; height: 12px; border-radius: 3px; background: var(--c); display: inline-block; }

/* ---------- my permit zone ---------- */
.pill.ghost { background: rgba(255,255,255,.94); color: var(--ink); padding: 6px 11px; font-weight: 600; }
.pill.ghost.on { background: #e8f5f0; color: #137a5c; box-shadow: var(--shadow), inset 0 0 0 1.5px #1b9e77; }
.zones { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin: 4px 0 14px; }
.zone {
  font: inherit; font-size: 16px; font-weight: 700; padding: 11px 0; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: #f7f8fa; color: var(--ink);
}
.zone.none { grid-column: 1 / -1; font-size: 15px; }
.zone.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- search suggestions ---------- */
.suggest {
  list-style: none; margin: 0; padding: 4px; background: var(--panel); border-radius: var(--radius);
  box-shadow: 0 6px 22px rgba(15, 30, 50, .25); max-height: 60vh; overflow-y: auto;
}
#q-suggest { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 5; }
.suggest.inline { margin-top: 4px; border: 1px solid var(--line); box-shadow: 0 4px 14px rgba(15, 30, 50, .15); }
.suggest[hidden] { display: none; }
.suggest li { display: flex; gap: 10px; align-items: center; padding: 9px 10px; border-radius: 10px; cursor: pointer; }
.suggest li.on, .suggest li:hover { background: #f0f3f7; }
.suggest .ico { flex: none; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: #eef1f5; color: var(--accent); }
.suggest .ico.venue { background: #fdf0e8; color: #c2461a; }
.suggest .ico.postcode { background: #e8f5f0; color: #137a5c; }
.suggest .txt { display: flex; flex-direction: column; min-width: 0; }
.suggest .txt b { font-size: 15px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suggest .txt small { font-size: 12.5px; color: var(--muted); font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
