:root {
  /* House style (as Planning Map): one brand colour for both bars. */
  --brand: #0b5cad;
  --brand-dark: #084785;
  --on-brand: #ffffff;
  --on-brand-muted: #a9c6e8;
  --bg: #f6f8fb;
  --card: #ffffff;
  --fg: #1a1a1a;
  --muted: #5b636e;
  --line: #dde3ea;
  --free: #15803d;
  --limited: #0d9488;
  --paid: #d97706;
  --maybe: #65a30d;
  --warn: #c42b2b;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); }
body { display: grid; grid-template-rows: auto 1fr auto; grid-template-columns: minmax(0, 1fr); height: 100dvh; overflow: hidden; }
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; }

/* Top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--brand); color: var(--on-brand);
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.25); z-index: 1100;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand h1 { font-size: 19px; font-weight: 700; letter-spacing: .3px; margin: 0; }
.top-actions { display: flex; align-items: center; }
.icon-btn {
  background: none; border: 0; color: var(--on-brand); padding: 8px 10px; border-radius: 8px;
  display: flex; align-items: center;
}
.icon-btn:hover { background: rgba(255,255,255,.12); }

/* Views */
.views { position: relative; min-height: 0; }
.view { position: absolute; inset: 0; }
#map { position: absolute; inset: 0; }

/* Bottom tab bar */
.tabbar {
  display: flex; background: var(--brand); border-top: 1px solid var(--brand-dark);
  padding-bottom: env(safe-area-inset-bottom); z-index: 1100;
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: none; border: 0; color: var(--on-brand-muted); padding: 7px 0 6px; font-size: 11px; font-weight: 600;
}
.tab svg .fillable { fill: none; }
.tab.active { color: var(--on-brand); }
.tab.active svg .fillable { fill: currentColor; fill-opacity: .28; }

/* Results panel */
.panel {
  position: absolute; left: 12px; bottom: 24px; z-index: 1000; width: min(400px, calc(100% - 24px));
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,.14); font-size: .85rem;
  max-height: calc(100% - 110px); display: flex; flex-direction: column;
}
.panel-head {
  display: flex; align-items: center; gap: 8px; width: 100%; margin: 0 0 6px; padding: 0;
  background: none; border: 0; color: inherit; text-align: left; font-size: inherit;
}
#status { flex: 1; font-weight: 600; }
.panel-head .chev { flex: none; color: var(--muted); transition: transform .15s; }
.panel.collapsed .panel-body { display: none; }
.panel.collapsed .panel-head { margin-bottom: 0; }
.panel.collapsed .chev { transform: rotate(180deg); }
.panel-body { overflow-y: auto; min-height: 0; overscroll-behavior: contain; }

.row { display: flex; align-items: center; gap: 8px; margin: 0 0 7px; flex-wrap: wrap; }
.row-label { width: 42px; color: var(--muted); font-weight: 600; font-size: .78rem; }
.chips { display: flex; gap: 4px; flex-wrap: wrap; }
.chips button, .chip-solo {
  border: 1px solid var(--line); background: var(--bg); color: var(--fg); border-radius: 14px;
  padding: 4px 9px; font-size: .8rem; font-weight: 600;
}
.chips button[aria-checked="true"], .chip-solo.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.when {
  border: 1px solid var(--line); border-radius: 8px; padding: 3px 6px; font: inherit; font-size: .8rem;
  background: var(--bg); color: var(--fg); min-width: 0;
}
#when-date { flex: 1 1 120px; max-width: 150px; }
#when-time { flex: 0 1 92px; }
/* Stay pills share one line; the Arrive row never wraps */
.chips.stay { flex-wrap: nowrap; width: 100%; gap: 3px; }
.chips.stay button { flex: 1 1 0; min-width: 0; padding: 4px 0; text-align: center; white-space: nowrap; }
.row.arrive { flex-wrap: nowrap; gap: 6px; }
.row.arrive .row-label { width: auto; flex: none; }
.row.arrive .chip-solo { flex: none; }
.row.arrive #when-date { flex: 1 1 0; width: 0; max-width: 150px; }
.row.arrive #when-time { flex: 1 1 0; width: 0; max-width: 100px; }

.results { list-style: none; margin: 4px 0 6px; padding: 0; display: grid; gap: 4px; }
.results li {
  display: flex; gap: 9px; align-items: flex-start; padding: 7px 8px; border-radius: 8px; background: var(--bg);
  cursor: pointer;
}
.results li:hover { background: #edf1f6; }
.results .num {
  flex: none; width: 22px; height: 22px; border-radius: 50%; color: #fff; font-weight: 700; font-size: .78rem;
  display: flex; align-items: center; justify-content: center; margin-top: 1px;
}
.results .main { flex: 1; min-width: 0; }
.results .title { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.results .sub { display: block; color: var(--muted); font-size: .78rem; line-height: 1.35; }
.results .price { flex: none; font-weight: 700; text-align: right; }
.results .walk { display: block; font-weight: 400; color: var(--muted); font-size: .75rem; }
.results .empty { background: none; cursor: default; color: var(--muted); }

.legend { list-style: none; margin: 4px 0 0; padding: 6px 0 0; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: .75rem; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 5px; }
.swatch { display: inline-block; width: 16px; height: 4px; border-radius: 2px; }
.swatch.free, .num.free { background: var(--free); }
.swatch.limited, .num.limited { background: var(--limited); }
.swatch.paid, .num.paid { background: var(--paid); }
.swatch.badge, .num.badge { background: #2563eb; }
.swatch.badgepay, .num.badgepay { background: #7c3aed; }
.swatch.taxi, .num.taxi { background: #db2777; }
.legend:not(.with-badge) .badge-only { display: none; }
.swatch.maybe, .num.maybe { background: repeating-linear-gradient(90deg, var(--maybe) 0 5px, transparent 5px 8px); }
.num.maybe { background: var(--maybe); }

/* Map furniture */
.locate-btn {
  width: 40px; height: 40px; padding: 0; display: flex; align-items: center; justify-content: center;
  background: #fff; color: #333; border: 2px solid rgba(0,0,0,.2); border-radius: 6px;
}
.locate-btn:hover { background: #f4f4f4; }
.locate-btn.locating { color: #1a73e8; }
.locate-btn.locating svg { animation: locate-pulse 1s ease-in-out infinite; }
@keyframes locate-pulse { 50% { opacity: .35; } }

.pin-label {
  background: none; border: 0;
}
.pin-label div {
  width: 24px; height: 24px; border-radius: 50%; border: 2px solid #fff; color: #fff; font-weight: 700;
  font-size: 12px; display: flex; align-items: center; justify-content: center; box-shadow: 0 1px 4px rgba(0,0,0,.4);
}
.cp-icon { background: none; border: 0; }
.cp-icon div {
  display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; transform: translate(-50%, -50%);
  background: #fff; border: 2px solid var(--brand); border-radius: 6px; padding: 0 4px 0 0; font-size: 11px; font-weight: 700;
  color: var(--fg); box-shadow: 0 1px 3px rgba(0,0,0,.3); line-height: 18px;
}
.cp-icon b { background: var(--brand); color: #fff; padding: 0 4px; border-radius: 3px 0 0 3px; }
.cp-icon.free div { border-color: var(--free); } .cp-icon.free b { background: var(--free); }
.cp-icon.paid div { border-color: var(--paid); } .cp-icon.paid b { background: var(--paid); }
.cp-icon.badge div { border-color: #2563eb; } .cp-icon.badge b { background: #2563eb; }
.cp-icon.badgepay div { border-color: #7c3aed; } .cp-icon.badgepay b { background: #7c3aed; }
.cp-icon.unknown div { border-color: #6b7280; } .cp-icon.unknown b { background: #6b7280; }
.cp-icon.no { opacity: .5; }
.cp-icon.no div { border-color: #9ca3af; } .cp-icon.no b { background: #9ca3af; }

/* Popups */
.pop { font-size: .85rem; line-height: 1.4; max-width: min(280px, calc(100vw - 80px)); }
.pop h3 { font-size: .95rem; margin: 0 0 4px; }
.pop .verdict { font-weight: 600; margin: 0 0 6px; }
.pop .verdict.ok { color: var(--free); }
.pop .verdict.pay { color: #b45309; }
.pop .verdict.no { color: var(--warn); }
.pop .sign { margin: 0 0 6px; padding: 5px 7px; background: var(--bg); border-left: 3px solid var(--line); font-size: .8rem; }
.pop .tariff { margin: 0 0 6px; font-size: .78rem; color: var(--muted); white-space: pre-line; max-height: 150px; overflow-y: auto; }
.pop .meta { color: var(--muted); font-size: .78rem; margin: 0 0 4px; }
.pop .src { color: var(--muted); font-size: .75rem; margin: 6px 0 0; }
.pop .nav .pc { font: inherit; font-weight: 700; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; cursor: pointer; }
.leaflet-popup-content { max-height: 60vh; overflow-y: auto; overscroll-behavior: contain; }
.leaflet-container a.leaflet-popup-close-button { width: 36px; height: 36px; font: 26px/34px system-ui, sans-serif; color: #555; }

/* Settings */
.settings { overflow-y: auto; padding: 20px 16px 32px; }
.settings > * { max-width: 560px; margin-left: auto; margin-right: auto; }
.settings h2 { font-size: 26px; margin: 0 auto 16px; }
.settings h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px auto 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 4px 14px; }
.card p { margin: 10px 0; line-height: 1.45; font-size: .92rem; }
.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer;
}
.switch-row:last-child { border-bottom: 0; }
.switch-row > span { display: flex; align-items: center; gap: 9px; }
.switch-row input {
  appearance: none; -webkit-appearance: none; flex: none; width: 44px; height: 26px; border-radius: 13px;
  background: #c9d1da; position: relative; transition: background .15s; cursor: pointer; margin: 0;
}
.switch-row input::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: transform .15s;
}
.switch-row input:checked { background: var(--brand); }
.switch-row input:checked::after { transform: translateX(18px); }
.switch-row input:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.kind-text { display: flex; flex-direction: column; gap: 1px; }
.kind-text b { font-weight: 600; }
.kind-text small { font-size: .8rem; line-height: 1.3; }
.muted { color: var(--muted); }
.small { font-size: .78rem; }

/* Tip jar modal */
.modal {
  position: fixed; inset: 0; z-index: 2000; background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-card {
  background: var(--card); border-radius: 14px; padding: 18px; width: 100%; max-width: 380px;
  display: flex; flex-direction: column; align-items: center; text-align: center;
}
.qr-box { margin: 14px 0 8px; padding: 8px; background: #fff; border-radius: 8px; line-height: 0; }
.qr-box svg { max-width: 100%; height: auto; }
#share-link { border: 0; cursor: pointer; font: inherit; }
.modal-card h2 { font-size: 19px; margin: 6px 0; }
.modal-card p { margin: 0; font-size: 15px; }
.tip-link {
  margin: 16px 0 8px; padding: 11px 22px; border-radius: 8px; background: var(--brand);
  color: #fff; font-weight: 700; text-decoration: none;
}
.close-btn {
  margin-top: 14px; padding: 9px 22px; border-radius: 8px; border: 1px solid var(--line);
  background: none; color: var(--fg); font-weight: 600;
}
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); z-index: 2100;
  background: #1f2937; color: #fff; padding: 8px 14px; border-radius: 8px; font-size: .85rem;
}

@media (max-width: 520px) {
  .panel { left: 8px; right: 8px; width: auto; bottom: 16px; }
}

/* Where the pin is */
.where { flex-wrap: nowrap; }
.where-text { flex: 1; min-width: 0; font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.where .chip-solo { flex: none; }
