/* Parking Spotter styles. Colours are tokens at the top; dark mode swaps them. */
:root {
  --bg: #f4f5f2; --surface: #ffffff; --surface-2: #eef0ec; --ink: #16201d; --mute: #5b6661; --line: #dde1dc;
  --brand: #0f766e; --brand-ink: #ffffff; --brand-soft: #d7efec;
  --free: #15803d; --paid: #1f2937; --carpark: #1d4ed8; --warn: #b45309; --danger: #b91c1c;
  --radius: 14px; --shadow: 0 1px 2px rgba(16, 24, 20, .06), 0 4px 16px rgba(16, 24, 20, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1412; --surface: #161e1b; --surface-2: #1f2925; --ink: #eef3f0; --mute: #9aa8a2; --line: #2b3632;
    --brand: #2dd4bf; --brand-ink: #062b27; --brand-soft: #123a35;
    --free: #4ade80; --paid: #e5e7eb; --carpark: #93b4ff; --warn: #fbbf24; --danger: #f87171;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1412; --surface: #161e1b; --surface-2: #1f2925; --ink: #eef3f0; --mute: #9aa8a2; --line: #2b3632;
  --brand: #2dd4bf; --brand-ink: #062b27; --brand-soft: #123a35;
  --free: #4ade80; --paid: #e5e7eb; --carpark: #93b4ff; --warn: #fbbf24; --danger: #f87171;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4); color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Layout: map on top with the list below on phones; list beside the map on wide screens */
.app { display: flex; flex-direction: column-reverse; }
.panel { padding: 14px 16px calc(24px + env(safe-area-inset-bottom, 0px)); }
.map-wrap { position: sticky; top: 0; z-index: 5; height: 40vh; min-height: 240px; }
#map { position: absolute; inset: 0; z-index: 0; background: var(--surface-2); }
@media (min-width: 900px) {
  .app { flex-direction: row; height: 100vh; }
  .panel { width: 440px; flex: none; overflow-y: auto; padding: 20px 20px 32px; }
  .map-wrap { position: relative; flex: 1; height: auto; }
}

/* Header */
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.logo { width: 40px; height: 40px; border-radius: 11px; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-weight: 800; font-size: 22px; flex: none; }
.brand h1 { font-size: 20px; line-height: 1.1; margin: 0; letter-spacing: -.01em; }
.brand p { margin: 2px 0 0; color: var(--mute); font-size: 14px; }

/* Search */
.where { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); }
.search { position: relative; display: flex; gap: 8px; }
.search-icon { position: absolute; left: 12px; top: 50%; width: 20px; height: 20px; transform: translateY(-50%); fill: var(--mute); pointer-events: none; }
.search input { flex: 1; min-width: 0; height: 46px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface-2); padding: 0 12px 0 40px; font-size: 16px; }
.search input:focus { border-color: var(--brand); outline: none; background: var(--surface); }
.icon-btn { width: 46px; height: 46px; flex: none; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); display: grid; place-items: center; }
.icon-btn svg { width: 22px; height: 22px; fill: var(--brand); }
.icon-btn:hover { border-color: var(--brand); }
.hits { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 4px; }
.hits:empty { display: none; }
.hits button { width: 100%; text-align: left; background: none; border: 0; border-radius: 10px; padding: 8px 10px; }
.hits button:hover, .hits button:focus-visible { background: var(--brand-soft); }
.hits small { display: block; color: var(--mute); font-size: 13px; }
.hits .msg { padding: 6px 10px; color: var(--mute); font-size: 14px; }
.hits .msg.error { color: var(--danger); }
.dest-line { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin: 12px 2px 8px; font-size: 15px; }
.dest-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.link-btn { background: none; border: 0; color: var(--brand); font-weight: 600; font-size: 14px; padding: 4px; white-space: nowrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-size: 14px; min-height: 34px; }
.chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.chip.saved::before { content: "★ "; color: var(--warn); }
.chip[aria-pressed="true"].saved::before { color: inherit; }
.hint { margin: 10px 2px 0; color: var(--mute); font-size: 13px; }

/* Controls */
.controls { margin-top: 14px; display: grid; gap: 12px; }
.control-label { display: block; font-size: 12px; font-weight: 700; color: var(--mute); margin: 0 0 6px 2px; text-transform: uppercase; letter-spacing: .05em; }
.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { flex: 1; border: 0; background: none; border-radius: 9px; padding: 8px 4px; font-size: 14px; font-weight: 500; min-height: 38px; white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--surface); box-shadow: var(--shadow); font-weight: 700; color: var(--brand); }
.stay-custom { display: flex; gap: 8px; margin-top: 8px; }
.stay-custom[hidden] { display: none; }
.stay-custom label { flex: 1; display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--mute); }
.stay-custom input { flex: 1; width: 0; min-width: 0; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); padding: 6px 10px; min-height: 44px; font-size: 16px; }
.arrive-row { display: flex; gap: 8px; flex-wrap: wrap; }
.arrive-row .seg { flex: 1 1 160px; }
#arriveAt { flex: 1 1 200px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); padding: 6px 10px; min-height: 44px; min-width: 0; }
.toggles { display: flex; gap: 16px; flex-wrap: wrap; }
.toggle { display: flex; align-items: center; gap: 8px; font-size: 15px; cursor: pointer; }
.toggle input { width: 20px; height: 20px; accent-color: var(--brand); margin: 0; }

/* Results */
.summary { margin: 18px 2px 8px; font-size: 14px; color: var(--mute); }
.summary strong { color: var(--ink); }
.results { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.card { background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card.open { border-color: var(--brand); }
.card-main { width: 100%; display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; text-align: left; background: none; border: 0; padding: 12px; }
.badge { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff; background: #1f2937; }
.badge.free { background: #15803d; } .badge.carpark { background: #1d4ed8; }
.card h3 { margin: 0; font-size: 16px; line-height: 1.25; }
.card .meta { color: var(--mute); font-size: 13px; margin-top: 2px; }
.tag { display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 1px 7px; border-radius: 6px; background: var(--brand-soft); color: var(--brand); margin-bottom: 3px; }
.live { font-weight: 600; color: var(--free); } .live.low { color: var(--warn); }
.price { text-align: right; font-weight: 800; font-size: 20px; line-height: 1.1; white-space: nowrap; }
.price small { display: block; font-size: 12px; font-weight: 500; color: var(--mute); }
.price.free { color: var(--free); }
.price.unknown { font-size: 13px; font-weight: 600; color: var(--mute); white-space: normal; max-width: 84px; }
.card-detail { padding: 0 12px 12px 54px; font-size: 14px; }
.card-detail dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0 0 12px; }
.card-detail dt { color: var(--mute); } .card-detail dd { margin: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn { border: 0; border-radius: 10px; padding: 9px 14px; font-weight: 600; font-size: 14px; background: var(--brand); color: var(--brand-ink); text-decoration: none; display: inline-block; }
.btn.ghost { background: none; border: 1.5px solid var(--line); color: var(--ink); }
.actions select { border: 1.5px solid var(--line); border-radius: 10px; padding: 8px; background: var(--surface); font-size: 14px; }
.empty { background: var(--surface); border: 1.5px dashed var(--line); border-radius: var(--radius); padding: 16px; color: var(--mute); font-size: 15px; }
.empty .btn { margin-top: 10px; }
.small-print { margin-top: 24px; font-size: 12px; color: var(--mute); }
.small-print p { margin: 0 0 8px; }
.small-print a, .disclaimer a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.legal-links { font-size: 13px; }
.disclaimer { margin: 12px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border-left: 4px solid var(--warn); font-size: 13px; color: var(--ink); }
.disclaimer strong { color: var(--warn); }

/* Map pins (fixed colours, so they read on the light map tiles in both themes) */
.pin { width: 100%; height: 100%; border-radius: 50%; display: grid; place-items: center; color: #fff; font: 700 12px/1 system-ui, sans-serif; border: 2.5px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .45); background: #1f2937; }
.pin-free { background: #15803d; } .pin-carpark { background: #1d4ed8; }
.pin-sel { border-color: #f59e0b; border-width: 3.5px; font-size: 14px; }
.pin-dest { width: 22px; height: 22px; border-radius: 50%; background: #f59e0b; border: 4px solid #fff; box-shadow: 0 0 0 2px #b45309, 0 2px 6px rgba(0, 0, 0, .4); }
.legend { position: absolute; right: 10px; top: 10px; z-index: 500; background: rgba(255, 255, 255, .94); color: #16201d; border-radius: 10px; padding: 6px 10px; font-size: 12px; display: flex; gap: 10px; box-shadow: 0 1px 4px rgba(0, 0, 0, .2); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: -1px; }
.dot-free { background: #15803d; } .dot-paid { background: #1f2937; } .dot-carpark { background: #1d4ed8; }
.map-error { padding: 16px; color: var(--mute); }
.leaflet-container { font: 13px/1.4 system-ui, sans-serif; }

#toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 1000; }
#toast.on { opacity: 1; }
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }

/* Privacy and terms pages */
.doc { max-width: 720px; margin: 0 auto; padding: 24px 16px 48px; }
.doc .brand { margin-bottom: 8px; }
.doc .brand a { color: inherit; text-decoration: none; display: flex; align-items: center; gap: 12px; }
.doc h2 { font-size: 26px; margin: 24px 0 4px; }
.doc h3 { font-size: 17px; margin: 28px 0 6px; }
.doc p, .doc li { color: var(--ink); }
.doc ul { padding-left: 20px; }
.doc li { margin-bottom: 6px; }
.doc a { color: var(--brand); }
.doc .updated { color: var(--mute); font-size: 14px; margin: 0 0 16px; }
.doc .back { display: inline-block; margin-top: 32px; font-weight: 600; }
