:root {
  --cream: #FFFBEB;
  --charcoal: #111827;
  --tomato: #DC2626;
  --saffron: #F59E0B;
  --white: #FFFFFF;
  --muted: #6B7280;
  --font-body: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-head: Poppins, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }
body {
  display: flex;
  flex-direction: column;
  background: var(--cream);
  color: var(--charcoal);
  font-family: var(--font-body);
  line-height: 1.5;
}

.header {
  background: var(--charcoal);
  color: var(--white);
  padding: 16px 24px;
}
.header h1 {
  margin: 0;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1.5rem;
}
.header p { margin: 4px 0 0; color: #E5E7EB; font-size: 0.95rem; }

/* Desktop: map left (~60%), panel right (~40%) */
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 60fr 40fr;
  min-height: 0;
}

.map-wrap { position: relative; min-height: 0; }
#map { position: absolute; inset: 0; }

.panel { padding: 24px; overflow-y: auto; }
.panel h2 {
  margin: 0 0 8px;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 1.25rem;
}

.status {
  margin: 0;
  padding: 12px 16px;
  background: var(--white);
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(17, 24, 39, 0.12);
  color: var(--muted);
}
.status.is-set { color: var(--charcoal); }
.status.is-warn { color: var(--tomato); }
.area-note { margin: 0; color: var(--muted); font-size: 0.95rem; }
#nearby:not(:empty) { margin-top: 8px; }

/* F3: radius selector */
.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;
}
.radius { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 16px 0 12px; padding: 0; border: 0; }
.radius-title { font: 600 1rem var(--font-head); }
.radius label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.radius input { accent-color: var(--tomato); }
.radius-label { margin-right: 6px; font-weight: 500; }
#radius-value, #filter-cuisine {
  padding: 6px 8px;
  border: 1px solid var(--muted);
  border-radius: 6px;
  background: var(--white);
  color: var(--charcoal);
  font: 0.95rem var(--font-body);
}

/* F9: cuisine and price filters */
.filter-price { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 8px 0; padding: 0; border: 0; }
.filter-price legend { margin-bottom: 4px; padding: 0; font-weight: 500; }
.filter-price label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.filter-price input { accent-color: var(--tomato); }
.filters .mark-btn:disabled { cursor: default; }
.filter-fav { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; cursor: pointer; }
.filter-fav input { accent-color: var(--tomato); }

/* F10: use my location */
.locate-note { margin: 4px 0 0; color: var(--muted); font-size: 0.8rem; }

/* Pin marker */
.pin { background: none; border: 0; }
.pin-dot {
  display: block;
  width: 28px;
  height: 28px;
  background: var(--tomato);
  border: 3px solid var(--white);
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}
.pin-dot.bounce { animation: bounce 0.5s ease-out; }

@keyframes bounce {
  0%   { transform: translateY(-24px) rotate(-45deg); }
  60%  { transform: translateY(4px) rotate(-45deg); }
  100% { transform: translateY(0) rotate(-45deg); }
}

:focus-visible { outline: 3px solid var(--saffron); outline-offset: 2px; }

/* Mobile: map on top, results below */
@media (max-width: 800px) {
  body { height: auto; } /* one page scroll, not a small scrolling panel under the map */
  .layout { flex: none; grid-template-columns: 1fr; grid-template-rows: 55vh auto; }
  .panel { padding: 12px 16px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .pin-dot.bounce { animation: none; }
}

/* Food spot pins and popups */
/* The icon box width is estimated in JS, so centre the pill on it (it may overflow both sides evenly) */
.spot { display: flex; align-items: center; justify-content: center; background: none; border: 0; }
.spot-pin {
  display: inline-block;
  min-width: 40px;
  padding: 3px 10px;
  border: 2px solid var(--white);
  border-radius: 999px;
  background: var(--charcoal);
  color: var(--saffron);
  font: 600 0.8rem/1.3 var(--font-head);
  text-align: center;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}
.spot-pin.is-visited { background: var(--saffron); color: var(--charcoal); }
/* F7: outside the radius but within the next larger radius option */
.spot-pin.is-near { opacity: 0.45; box-shadow: none; }
.spot-pin.is-near:hover { opacity: 0.85; }

.spot-popup { font-family: var(--font-body); }
.spot-img { display: block; width: 100%; max-height: 120px; object-fit: cover; border-radius: 8px; margin-bottom: 8px; }
/* Cuisine icon shown when a spot has no dish photo (sized by .spot-img, .spot-card-img, .result-img) */
div.dish-placeholder { display: flex; align-items: center; justify-content: center; background: #F3E9DC; font-size: 2.5rem; line-height: 1; }
.spot-img.dish-placeholder { height: 80px; }
.spot-name { margin: 0 0 4px; font: 600 1rem/1.3 var(--font-head); }
.spot-popup p { margin: 0 0 4px; }
.spot-meta { color: var(--muted); font-size: 0.9rem; }
.spot-dish { font-size: 0.95rem; }
.spot-visit { font-size: 0.9rem; font-weight: 500; }
.spot-link { color: var(--tomato); font-weight: 500; }

/* Footer (banner text + image version) */
.footer {
  padding: 8px 24px;
  background: var(--charcoal);
  color: #E5E7EB;
  font-size: 0.85rem;
}
.footer p { margin: 0; }
/* Hover card on food spots */
.leaflet-tooltip.spot-tooltip {
  width: 250px;
  padding: 0;
  overflow: hidden;
  background: var(--charcoal);
  color: var(--white);
  border: 0;
  border-radius: 14px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  white-space: normal;
}
.leaflet-tooltip-left.spot-tooltip::before  { border-left-color: var(--charcoal); }
.leaflet-tooltip-right.spot-tooltip::before { border-right-color: var(--charcoal); }

.spot-card-img { display: block; width: 100%; height: 110px; object-fit: cover; }
.spot-card-body { padding: 10px 14px 12px; }
.spot-card-body p { margin: 0; }
.spot-card-name { font: 600 1.05rem/1.3 var(--font-head); }
.spot-card-meta { margin-top: 2px; color: #E5E7EB; font-size: 0.85rem; }
.spot-card-visit { margin-top: 6px; color: var(--saffron); font-size: 0.85rem; font-weight: 500; }

/* Click-to-inspect business card (popup at the pin) */
.lookup-card { font-family: var(--font-body); }
.lookup-card p { margin: 0 0 4px; }
.lookup-msg { color: var(--muted); font-size: 0.95rem; }
.lookup-msg.is-warn { color: var(--tomato); }
.lookup-msg.is-loading::before {
  content: "";
  display: inline-block;
  width: 0.8em;
  height: 0.8em;
  margin-right: 8px;
  border: 2px solid var(--saffron);
  border-top-color: transparent;
  border-radius: 50%;
  vertical-align: -1px;
  animation: lookup-spin 0.8s linear infinite;
}
.lookup-row { font-size: 0.9rem; overflow-wrap: anywhere; }
.lookup-links { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.lookup-credit { margin-top: 6px !important; color: var(--muted); font-size: 0.75rem; }

@keyframes lookup-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .lookup-msg.is-loading::before { animation: none; }
}

/* "Mark a business here" fallback (marks, form and buttons) */
.spot-pin.is-user {
  background: var(--white);
  color: var(--charcoal);
  border: 2px dashed var(--tomato);
}
.lookup-prompt { margin: 8px 0 0 !important; }
.lookup-badge { color: var(--muted); font-size: 0.8rem; }
.mark-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.mark-btn {
  padding: 6px 10px;
  border: 1px solid var(--charcoal);
  border-radius: 8px;
  background: var(--white);
  color: var(--charcoal);
  font: 500 0.85rem var(--font-body);
  cursor: pointer;
}
.mark-btn.primary { background: var(--charcoal); color: var(--white); }
.mark-btn.danger { border-color: var(--tomato); color: var(--tomato); }
.mark-field label { display: block; margin: 8px 0 2px; font-size: 0.85rem; font-weight: 500; }
.mark-field input, .mark-field select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--muted);
  border-radius: 6px;
  background: var(--white);
  color: var(--charcoal);
  font: 0.9rem var(--font-body);
}
.mark-sql { width: 100%; height: 90px; margin-top: 6px; font: 0.75rem monospace; }
/* Who added a spot: tags (results list, popups, legend) and community map pins */
.spot-pin.is-community { background: var(--tomato); color: var(--white); }
.tag {
  display: inline-block;
  padding: 1px 8px;
  border: 2px solid transparent;
  border-radius: 999px;
  font: 600 0.72rem/1.4 var(--font-head);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}
.tag-curated   { background: var(--charcoal); color: var(--saffron); }
.tag-community { background: var(--tomato); color: var(--white); }
.tag-mine      { background: var(--white); color: var(--charcoal); border: 2px dashed var(--tomato); }
.spot-popup .tag { margin-bottom: 6px; }

.tag-legend {
  display: flex; flex-direction: column; gap: 4px;
  margin: 10px 0 12px; padding: 0; list-style: none;
  color: var(--muted); font-size: 0.85rem;
}
.tag-legend .tag { margin-right: 6px; }

/* Count button under the pin status: how many spots are in range, and a jump to the list */
.count-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; min-height: 52px; margin-top: 8px; padding: 8px 16px;
  border: 2px solid var(--tomato); border-radius: 12px;
  background: var(--tomato); color: var(--white);
  font: 0.85rem var(--font-body); text-align: left; cursor: pointer;
}
.count-btn[hidden] { display: none; }
.count-btn.is-found { border-color: #15803D; background: #15803D; }
.count-btn strong { display: block; font: 600 1rem/1.3 var(--font-head); }
.count-btn.is-loading { border-color: var(--muted); background: var(--white); color: var(--charcoal); }
.count-btn.is-none { border-color: var(--charcoal); background: var(--white); color: var(--charcoal); }
.count-btn.is-failed { background: var(--white); color: var(--tomato); }

/* Collapsed filters, map layers and notes */
.more { background: var(--white); border-radius: 12px; box-shadow: 0 1px 4px rgba(17, 24, 39, 0.12); }
.more summary { padding: 10px 14px; font: 600 0.95rem var(--font-head); cursor: pointer; }
.more > :not(summary) { margin-left: 14px; margin-right: 14px; }
.more > :last-child { padding-bottom: 12px; }
.more .layer-toggles { padding: 0; box-shadow: none; }

.results-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin: 20px 0 8px; }
.panel .results-head h2 { margin: 0; scroll-margin-top: 12px; }
.map-area { margin-top: 24px; }
@media (prefers-reduced-motion: no-preference) {
  html, .panel { scroll-behavior: smooth; }
}

/* Results list: one card per spot in the radius, closest first */
.results { display: flex; flex-direction: column; gap: 12px; margin: 0; padding: 0; list-style: none; }
.result-card {
  display: flex;
  overflow: hidden;
  background: var(--white);
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(17, 24, 39, 0.12);
  border-left: 4px solid var(--charcoal);
}
.result-card.is-community { border-left-color: var(--tomato); }
.result-card.is-mine { border-left: 4px dashed var(--tomato); }
.result-img { flex: 0 0 96px; width: 96px; object-fit: cover; }
.result-body { flex: 1; min-width: 0; padding: 10px 14px 12px; }
.result-body p { margin: 2px 0 0; }
.result-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 8px; }
.result-who { display: flex; align-items: center; gap: 6px; }
.result-rank {
  display: inline-block;
  min-width: 22px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--charcoal);
  color: var(--saffron);
  font: 600 0.8rem/1.3 var(--font-head);
  text-align: center;
}
.result-dist { color: var(--charcoal); font-size: 0.85rem; font-weight: 500; white-space: nowrap; }
.result-name { margin: 6px 0 0; font: 600 1.05rem/1.3 var(--font-head); overflow-wrap: anywhere; }
.result-meta { color: var(--muted); font-size: 0.9rem; }
.result-row { font-size: 0.9rem; overflow-wrap: anywhere; }
.result-visit { font-size: 0.85rem; font-weight: 500; }
.result-note { color: var(--muted); font-size: 0.85rem; font-style: italic; }
.result-outside { font-size: 0.85rem; font-weight: 500; color: var(--muted); }
.result-empty p { margin: 0; }
.result-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-top: 8px; }
.result-empty { padding: 12px 16px; background: var(--white); border-radius: 12px; color: var(--muted); }

@media (max-width: 420px) {
  .result-img { flex-basis: 72px; width: 72px; }
}

/* ---------- User-curated spots: layer checkboxes, "Shared" pins, suggestions, add-spot form ---------- */
.layer-toggles {
  display: flex; flex-direction: column; gap: 6px;
  margin: 12px 0 0; padding: 10px 14px;
  background: var(--white); border: 0; border-radius: 12px;
  box-shadow: 0 1px 4px rgba(17, 24, 39, 0.12);
}
.layer-toggles legend {
  float: left; width: 100%; margin-bottom: 4px; padding: 0;
  font: 600 0.95rem var(--font-head);
}
.layer-toggles label { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; cursor: pointer; }
.layer-toggles input { accent-color: var(--tomato); width: 1rem; height: 1rem; }

/* Other users' spots: dotted outline and the word "Shared", so colour is not the only cue */
.spot-pin.is-others {
  background: var(--cream);
  color: var(--charcoal);
  border: 2px dotted var(--charcoal);
}
.tag-others { background: var(--cream); color: var(--charcoal); border: 2px dotted var(--charcoal); }
.result-card.is-others { border-left: 4px dotted var(--charcoal); }
.mark-card .tag { margin-bottom: 6px; }

/* "Is it one of these?" list on the pin card */
.lookup-heading { margin: 0 0 4px !important; font: 600 0.95rem var(--font-head); }
.suggest-list { display: flex; flex-direction: column; gap: 6px; margin: 0 0 8px; padding: 0; list-style: none; }
.suggest-item { display: flex; align-items: center; gap: 6px; font-size: 0.9rem; }
.suggest-item .tag { flex: none; }
.suggest-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.mark-btn.small { padding: 2px 8px; font-size: 0.8rem; }
.mark-btn:disabled { opacity: 0.6; cursor: progress; }

/* Favourite star button, "Surprise me" and the shareable link */
.fav-btn[aria-pressed="true"] { background: var(--saffron); }
.spot-popup .fav-btn, .lookup-card .fav-btn { margin-bottom: 6px; }
.view-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.view-actions .mark-btn:disabled, #clear-pin-btn:disabled { cursor: default; }
.share-url { width: 100%; margin-top: 4px; padding: 6px 8px; font: 0.85rem var(--font-body); }
.share-url[hidden] { display: none; }

/* Add-spot form: name chips and the share checkbox */
.name-offers { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 4px; }
.name-offers-label { color: var(--muted); font-size: 0.8rem; }
.name-chip {
  padding: 1px 8px;
  border: 1px solid var(--muted);
  border-radius: 999px;
  background: var(--cream);
  color: var(--charcoal);
  font: 0.8rem var(--font-body);
  cursor: pointer;
}
.name-chip:hover { border-color: var(--charcoal); }
.mark-check { display: flex; align-items: center; gap: 6px; margin: 10px 0 4px; font-size: 0.85rem; cursor: pointer; }
.mark-check input { accent-color: var(--tomato); }
.lookup-msg[role="alert"]:empty { display: none; }
