/* Bowserbird. Phone first: one column of rounded cards, wider screens get a centred column.
   Colours live in variables so dark mode only has to swap them. */
:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e5e9f2;
  --soft: #eef1f8;
  --brand: #3352e6;       /* "bower blue": satin bowerbirds collect blue things */
  --brand-deep: #1b2a7a;
  --brand-ink: #ffffff;
  --accent: #ffc533;      /* fuel-drop yellow */
  --cheap: #16a34a;
  --dear: #dc2626;
  --warn-bg: #fff4e0;
  --warn-ink: #8a4b00;
  --shadow: 0 1px 2px #0f172a0d, 0 4px 16px #0f172a0f;
  --radius: 20px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1020;
    --card: #141a2e;
    --ink: #e8ecf6;
    --muted: #97a3ba;
    --line: #263049;
    --soft: #1c2440;
    --brand: #6f88ff;
    --brand-deep: #c9d3ff;
    --cheap: #34d27a;
    --dear: #ff6b6b;
    --warn-bg: #3a2a10;
    --warn-ink: #ffcf87;
    --shadow: 0 1px 2px #0006, 0 4px 18px #0005;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Plus Jakarta Sans', -apple-system, system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
main { max-width: 680px; margin: 0 auto; padding: 0 12px; display: grid; gap: 12px; }
a { color: var(--brand); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
select, input, textarea, button { font-family: inherit; color: inherit; }

/* ---- App bar ---- */
.app-bar {
  position: sticky; top: 0; z-index: 1100; /* above the map's zoom buttons */
  display: flex; align-items: center; gap: 8px;
  max-width: 680px; margin: 0 auto;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; text-decoration: none; color: var(--ink); }
.brand img { border-radius: 10px; }
.brand span { font-weight: 800; font-size: 1.2rem; letter-spacing: -0.02em; }
.fuel-chip select, dialog select {
  appearance: none; -webkit-appearance: none;
  font-size: 0.95rem; font-weight: 600; padding: 8px 32px 8px 14px;
  border: 1px solid var(--line); border-radius: 999px; background-color: var(--card);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%2364748b' stroke-width='1.6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 11px;
}
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; flex-shrink: 0;
  border: 1px solid var(--line); border-radius: 50%; background: var(--card); color: var(--ink); cursor: pointer;
}
.icon-btn.solid { background: var(--brand); color: var(--brand-ink); border: none; border-radius: 14px; width: 44px; height: 44px; }
#find-me.busy { opacity: 0.5; }

/* ---- Barometer ---- */
.baro-banner {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 8px;
  padding: 16px 18px; background: #64748b; color: white;
  background-image: linear-gradient(135deg, #ffffff26, #00000014);
  transition: background-color 0.3s;
}
.baro-label { font-size: 0.8rem; font-weight: 600; opacity: 0.9; }
.baro-phase { font-size: 2.3rem; font-weight: 800; line-height: 1.05; letter-spacing: -0.03em; }
.baro-verdict { display: inline-block; margin-top: 6px; padding: 4px 12px; border-radius: 999px; background: #ffffff33; font-weight: 700; font-size: 0.92rem; }
.baro-verdict:empty { display: none; }
.baro-price { text-align: right; font-size: 1.6rem; font-weight: 800; letter-spacing: -0.02em; }
.baro-price .baro-sub { color: inherit; opacity: 0.9; }
.baro-sub { font-size: 0.75rem; color: var(--muted); font-weight: 500; }
.baro-body { padding: 12px 16px 14px; }
.gauge {
  position: relative; display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px;
  margin: 10px 0 4px; font-size: 0.7rem; text-align: center; color: white; font-weight: 700;
}
.gauge[hidden] { display: none; }
.gauge span { padding: 4px 0; border-radius: 6px; }
.gauge span:nth-child(1) { background: #1e8e3e; border-radius: 999px 6px 6px 999px; }
.gauge span:nth-child(2) { background: #e37400; }
.gauge span:nth-child(3) { background: #c5221f; }
.gauge span:nth-child(4) { background: #1a73e8; border-radius: 6px 999px 999px 6px; }
#gauge-marker {
  /* a small triangle above the bar, pointing at today's phase */
  position: absolute; top: -10px; width: 0; height: 0; margin-left: -7px;
  border-left: 7px solid transparent; border-right: 7px solid transparent;
  border-top: 9px solid var(--ink); background: none !important;
}
#baro-advice { margin: 10px 0 8px; font-size: 0.98rem; font-weight: 500; line-height: 1.4; }
#baro-near { margin: 0 0 8px; padding: 10px 12px; border-radius: 12px; background: var(--soft); font-size: 0.85rem; line-height: 1.4; }
#baro-near:empty { display: none; }
#baro-footnote { margin: 6px 0 0; font-style: italic; }
#baro-near .cheaper { color: var(--cheap); }
#baro-near .dearer { color: var(--dear); }
#baro-chart { width: 100%; height: 130px; display: block; margin-top: 4px; }
#baro-chart text { font-size: 10px; fill: var(--muted); font-family: inherit; }
#baro-chart .grid { stroke: var(--line); stroke-width: 1; }

/* ---- Search + map ---- */
.search-row { display: flex; gap: 8px; padding: 12px 12px 6px; }
.search-box {
  flex: 1; display: flex; align-items: center; gap: 8px; padding: 0 14px;
  border-radius: 14px; background: var(--soft); color: var(--muted);
}
#search { flex: 1; min-width: 0; font-size: 16px; padding: 11px 0; border: none; background: none; color: var(--ink); outline: none; }
#place-note { padding: 0 16px; font-size: 0.8rem; color: var(--muted); }
#place-note:empty { display: none; }
#map { scroll-margin-top: 80px; height: 58vh; min-height: 320px; margin: 6px 12px 0; border-radius: 16px; background: var(--soft); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 10px 16px 14px; font-size: 0.78rem; color: var(--muted); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: 0; }
.dot.cheap { background: var(--cheap); }
.dot.dear { background: var(--dear); }
.dot.suspect { background: #8a8f98; }
.dot.stale { background: var(--ink); opacity: 0.35; }

/* ---- Pins ---- */
.pin {
  display: inline-flex; align-items: center; gap: 4px;
  background: #0f172a; color: white; padding: 2px 8px 2px 2px; border-radius: 999px;
  font: 700 12px 'Plus Jakarta Sans', system-ui; white-space: nowrap; transform: translate(-50%, -50%);
  box-shadow: 0 2px 6px #0004;
}
.pin.cheap { background: #16a34a; font-size: 14px; outline: 2px solid white; }
.pin.dear { background: #dc2626; }
.pin.suspect { background: #8a8f98; opacity: 0.85; }
.pin.stale { opacity: 0.55; }
.badge {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  min-width: 20px; height: 20px; padding: 0 3px; border-radius: 10px;
  font: 800 10px system-ui; letter-spacing: -0.3px; border: 1px solid #0002;
}
.cluster {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 42px; height: 42px; padding: 0 7px; border-radius: 21px;
  background: var(--brand); color: white; border: 2px solid white; box-shadow: 0 2px 8px #0005;
  transform: translate(-50%, -50%); line-height: 1.05; font-family: 'Plus Jakarta Sans', system-ui;
}
.cluster b { font-size: 14px; }
.cluster span { font-size: 9px; opacity: 0.9; white-space: nowrap; }

/* ---- Popup ---- */
.leaflet-popup-content-wrapper { border-radius: 16px; background: var(--card); color: var(--ink); box-shadow: 0 8px 30px #0003; }
.leaflet-popup-tip { background: var(--card); }
.leaflet-container { font-family: inherit; }
.popup { font-size: 0.85rem; line-height: 1.45; }
.popup-title { display: flex; align-items: center; gap: 6px; font-size: 1rem; margin-bottom: 4px; }
.popup-price { margin-bottom: 2px; }
.popup-warn { margin: 4px 0; padding: 4px 8px; border-radius: 8px; background: var(--warn-bg); color: var(--warn-ink); font-size: 0.78rem; }
.nav-buttons { display: flex; gap: 6px; margin-top: 10px; }
.popup a.nav {
  flex: 1; text-align: center; padding: 9px 4px; border-radius: 12px;
  background: var(--brand); color: white; text-decoration: none; font-weight: 700;
}
.hours { font-size: 0.75rem; font-weight: 700; }
.hours.open { color: var(--cheap); }
.hours.closed { color: var(--dear); }
.age { font-size: 0.75rem; color: var(--muted); }
.age.stale { color: #b45309; font-weight: 600; }

/* ---- Optional list ---- */
#station-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
#station-list li {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  background: var(--card); border-radius: 16px; box-shadow: var(--shadow); cursor: pointer;
}
#station-list li.cheap { box-shadow: inset 4px 0 0 var(--cheap), var(--shadow); }
#station-list li.dear { box-shadow: inset 4px 0 0 var(--dear), var(--shadow); }
.grow { flex: 1; min-width: 0; }
.station-name { font-weight: 700; }
.station-address { font-size: 0.82rem; color: var(--muted); }
.price { font-size: 1.25rem; font-weight: 800; white-space: nowrap; letter-spacing: -0.02em; }
li.cheap .price { color: var(--cheap); }
li.dear .price { color: var(--dear); }
li.suspect .price { color: #8a8f98; text-decoration: line-through; }

/* ---- Dialogs: bottom sheets on phones, centred cards on bigger screens ---- */
dialog {
  border: none; padding: 8px 18px calc(18px + env(safe-area-inset-bottom));
  width: 100%; max-width: 480px; max-height: 88vh; overflow-y: auto;
  margin: auto auto 0; border-radius: 24px 24px 0 0;
  background: var(--card); color: var(--ink); box-shadow: 0 -8px 40px #0004;
}
@media (min-width: 600px) { dialog { margin: auto; border-radius: 24px; padding-bottom: 18px; } }
dialog[open] { animation: sheet-up 0.22s ease-out; }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }
dialog::backdrop { background: #0f172a66; backdrop-filter: blur(2px); }
.sheet-handle { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 2px auto 10px; }
dialog h2 { margin: 0 0 10px; font-size: 1.25rem; letter-spacing: -0.02em; }
dialog h3 { font-size: 0.95rem; margin: 14px 0 4px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.row small { color: var(--muted); font-weight: 400; }
.range { display: flex; align-items: center; gap: 8px; }
.row input[type=range] { width: 130px; accent-color: var(--brand); }
#radius-value { white-space: nowrap; min-width: 44px; text-align: right; }
input[type=checkbox], input[type=radio] { accent-color: var(--brand); }
/* An iOS-style on/off switch for the list toggle. */
.switch { appearance: none; -webkit-appearance: none; width: 46px; height: 28px; border-radius: 14px; background: var(--line); position: relative; cursor: pointer; transition: background 0.2s; flex-shrink: 0; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: white; box-shadow: 0 1px 3px #0004; transition: transform 0.2s; }
.switch:checked { background: var(--brand); }
.switch:checked::after { transform: translateX(18px); }
.done { margin-top: 14px; width: 100%; padding: 13px; font-size: 1rem; font-weight: 700; border: none; border-radius: 14px; background: var(--brand); color: white; cursor: pointer; }
.pill { padding: 5px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); font-weight: 600; font-size: 0.8rem; }

/* ---- Brand filter ---- */
.brands-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 0 8px; font-weight: 600; }
#brand-filter { max-height: 36vh; overflow-y: auto; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 2px 8px; }
.brand-choice { display: flex; align-items: center; gap: 6px; font-size: 0.82rem; padding: 5px 0; min-width: 0; }
.brand-choice span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Crowd reports ---- */
.crowd { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.crowd-rating { font-weight: 700; }
.crowd-rating span:last-child { font-weight: 400; color: var(--muted); }
.stars { color: #f2a600; letter-spacing: 1px; }
.crowd-price { margin: 4px 0; padding: 6px 9px; border-radius: 10px; background: color-mix(in srgb, var(--brand) 12%, var(--card)); color: var(--brand-deep); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.chip { font-size: 0.72rem; font-weight: 600; padding: 3px 8px; border-radius: 999px; background: color-mix(in srgb, var(--cheap) 14%, var(--card)); color: var(--cheap); }
.crowd-buttons { display: flex; gap: 6px; margin-top: 8px; }
.crowd-btn { flex: 1; padding: 8px 4px; border-radius: 12px; border: 1.5px solid var(--brand); background: transparent; color: var(--brand); font-weight: 700; font-size: 0.8rem; cursor: pointer; }

/* ---- Forms ---- */
.form-station { margin: -4px 0 6px; color: var(--muted); }
.form-note { font-size: 0.75rem; color: var(--muted); }
.form-msg { min-height: 1.2em; font-size: 0.85rem; color: var(--brand); font-weight: 700; }
.form-buttons { display: flex; gap: 8px; }
.form-buttons button { flex: 1; margin-top: 6px; }
.form-cancel { padding: 13px; font-size: 1rem; font-weight: 600; border: 1px solid var(--line); border-radius: 14px; background: var(--card); }
#report-price, #rate-comment, .other-amenity input {
  font-size: 16px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--soft); color: var(--ink);
}
#report-price { width: 120px; }
#rate-comment { width: 100%; font: inherit; font-size: 16px; }
.star-picker { display: flex; flex-direction: row-reverse; justify-content: flex-end; gap: 4px; margin-bottom: 8px; }
.star-picker input { display: none; }
.star-picker label { font-size: 2.1rem; color: var(--line); cursor: pointer; }
.star-picker input:checked ~ label, .star-picker label:hover, .star-picker label:hover ~ label { color: #f2a600; }
.amenity-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 0.85rem; }
.tri { display: flex; gap: 8px; font-size: 0.8rem; }
.other-amenity { display: block; margin-top: 12px; font-size: 0.85rem; font-weight: 700; }
.other-amenity input { display: block; width: 100%; margin-top: 6px; font-weight: 400; }

/* ---- Footer ---- */
footer { max-width: 680px; margin: 0 auto; padding: 20px 16px calc(24px + env(safe-area-inset-bottom)); font-size: 0.76rem; color: var(--muted); line-height: 1.5; }
footer p { margin: 4px 0; }
footer a { color: inherit; }
.footer-brand { display: flex; align-items: center; gap: 6px; font-weight: 700; color: var(--ink); font-size: 0.85rem; margin-bottom: 8px !important; }
.footer-brand img { border-radius: 5px; }
#sample-warning { color: #b45309; }
