:root {
  --fg: #111;
  --muted: #6b6258;

  /* Warm neutrals (no pure white in header/tabs) */
  --app-bg: #fbf7f1;        /* tortilla */
  --header-surface: #f2ece2; /* slightly darker/cooler than app bg */
  --content-surface: #fffdf7; /* map/list surface + selected tab */

  --border: rgba(17, 17, 17, 0.14);
  --border-strong: rgba(17, 17, 17, 0.18);

  --shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  --header-h: 56px;
  --radius: 12px;
  --tap: 44px;
  --font: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;

  /* existing */
  --map-gap: 10px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font);
  background: var(--app-bg);
  color: var(--fg);
}

.app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* Header (two-row, warm, sticky) */
.app-header {
  padding: 10px 10px 0;
  border-bottom: 1px solid var(--border);
  background: var(--header-surface);
  position: sticky;
  top: 0;
  z-index: 1000;
}

/* rows */
.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.header-row--top {
  position: relative;
  padding-bottom: 8px;
}

.header-row--top .icon-btn {
  margin-left: auto; /* pushes it to the right in a flex row */
}

.header-row--top::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 0;
  height: 2px; /* thicker, intentional */
  background: rgba(17, 17, 17, 0.12);
  border-radius: 1px;
}

.header-row--bottom {
  align-items: flex-end;
  padding-top: 10px; /* space between divider and tabs */
}

.app-title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-weight: 800;
  font-size: 17px;
  line-height: 1.2;
  letter-spacing: 0.3px;
  white-space: nowrap;
  pointer-events: none; /* prevents accidental overlap taps */
}

/* Tabs (folder tabs) */
.tabs {
  display: inline-flex;
  gap: 6px;
  align-items: flex-end;
  padding: 0;
  margin: 0;
}

/* folder-tab shape: rounded top only, flat bottom */
.tab {
  height: 38px;
  min-width: 84px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  border-radius: 12px 12px 0 0;
  background: var(--header-surface);
  color: var(--fg);
  font-weight: 800;
  font-size: 14px;
}

/* active tab looks “in front” + matches content surface */
.tab.is-active {
  background: var(--content-surface);
  border-color: var(--border-strong);
  border-bottom-color: var(--content-surface); /* hides the header bottom rule under it */
  position: relative;
  z-index: 2;
}

/* affordance */
.tab:active {
  transform: translateY(0.5px);
}
.tab:focus-visible {
  outline: 2px solid rgba(17, 17, 17, 0.25);
  outline-offset: 2px;
}

/* Filters action (icon + label, rectangular, not pill) */
.filters-btn {
  height: 38px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--content-surface); /* was --header-surface */
  color: var(--fg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 800;
  font-size: 14px;
  white-space: nowrap;
}

.filters-btn svg {
  width: 18px;
  height: 18px;
}

.filters-btn:active {
  background: rgba(17, 17, 17, 0.06);
}

.filters-btn:focus-visible {
  outline: 2px solid rgba(17, 17, 17, 0.25);
  outline-offset: 2px;
}

/* Right-side actions */
.header-actions {
  display: inline-flex;
  gap: 6px;
  justify-self: end;
}

/* Icon buttons */
.icon-btn {
  width: var(--tap);
  height: var(--tap);
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--content-surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

/* Optical centering: heart */
.fav-btn svg {
  transform: translate(3px, 0) scale(1.8);
}

/* Optical centering: close X */
.vendor-close svg {
  transform: translate(2px, 0) scale(1.5);
}

.icon-btn:active {
  background: rgba(17, 17, 17, 0.06);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

/* Main content */
.app-main {
  flex: 1;
  min-height: 0; /* important for flex children overflow */
  position: relative;
}

.view {
  height: 100%;
  width: 100%;
}

/* Make hidden views *actually* not render (defensive, fixes Firefox oddities) */
.view[hidden] {
  display: none !important;
}

/* =========================
   MAP VIEW — SAFE LAYOUT
   ========================= */

#view-map {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: var(--map-gap);
}

#view-list {
  padding: var(--map-gap);
  background: var(--shell-bg);
}

/* Soft Card Map framing */
.map-card {
  flex: 1;
  background: var(--content-surface);
  border: 1px solid rgba(17, 17, 17, 0.10);
  border-radius: 12px;
  overflow: hidden;
}

/* Leaflet container */
#map {
  height: 100%;
  width: 100%;
}

/* Map view overlays (Locate + toast) */
.locate-btn {
  position: absolute;
  top: calc(var(--map-gap) + 10px + env(safe-area-inset-top));
  right: calc(var(--map-gap) + 10px + env(safe-area-inset-right));
  z-index: 1000; /* above tiles; below overlays */
}

.locate-btn:disabled {
  opacity: 0.6;
}

.map-toast {
  position: absolute;
  top: calc(var(--map-gap) + 10px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: rgba(17, 17, 17, 0.92);
  color: #fff;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
  max-width: calc(100% - 24px);
  text-align: center;
}

.map-toast.is-visible {
  opacity: 1;
}

/* =========================
   LIST VIEW
   ========================= */

.list {
  height: 100%;
  overflow: auto;
  padding: 0 0 90px;
  background: transparent;
}

/* Wider cards + smaller gaps */
.list-item {
  padding: 0;
  margin: 8px 6px; /* closer to edges + less vertical gap */
  background: transparent;
  border: 0;
}

/* Selected list item highlight (THICK border + darker shade, no underline) */
.list-item.is-selected .vendor-card {
  border: 4px solid rgba(17, 17, 17, 0.75);
  background: #efe2cf; /* darker tortilla tint */
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.18);
}

.list-item.is-selected .vendor-name {
  text-decoration: none;
}

.list-item .vendor-card {
  padding: 12px;
}

/* List vendor layout: left rail (fav) + content (name/tags + desc) */
.vendor-row {
  display: grid;
  grid-template-columns: var(--tap) 1fr;
  gap: 10px;
  align-items: stretch;
}

.vendor-row .fav-btn {
  align-self: center; /* visually centered across name+desc */
}

.vendor-content {
  min-width: 0;
}

/* Name + chips on one line feel, wrap allowed */
.vendor-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

/* Map card: content column has a topline (title/tags + close) */
.vendor-topline {
  display: flex;
  align-items: center;
  gap: 10px;
}

.vendor-topline .vendor-title {
  flex: 1;
  min-width: 0;
}

/* Ensure close stays far right */
.vendor-topline .vendor-close {
  flex: 0 0 auto;
}

/* List top row aligns like map card (no close button) */
.list-item .vendor-top {
  align-items: center;
}

.list-item .vendor-desc {
  margin-top: 6px;
}

.list-item-desc {
  margin: 6px 0 8px;
  color: #333;
  font-size: 14px;
}

.muted {
  color: var(--muted);
}

/* =========================
   VENDOR CARD (shared language: Map overlay + List cards)
   ========================= */

.vendor-card {
  background: #fff;
  border: 1px solid rgba(17, 17, 17, 0.14);
  border-radius: 14px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.10);
}

/* Top row: [fav] [name + tags] [close] */
.vendor-top {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

/* Name + tags live together and can wrap */
.vendor-title {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.vendor-name {
  font-weight: 900;
  font-size: 17px; /* + ~2pt feel */
  line-height: 1.15;
}

.vendor-desc {
  margin-top: 4px; /* tighter: fixes map-card “big gap” */
  font-size: 14px;
  color: #333;
  line-height: 1.3;
  white-space: normal; /* never truncate */
}

.vendor-tags {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-chip {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 8px;
  background: #fafafa;
  font-weight: 700;
  font-size: 12px;
  line-height: 1.1;
  color: var(--fg);
}

#card.vendor-card--map .vendor-top {
  align-items: center;
}

/* Map overlay positioning (floating, inset, safe-area friendly) */
#card.vendor-card--map {
  position: fixed;
  left: calc(var(--map-gap) + env(safe-area-inset-left));
  right: calc(var(--map-gap) + env(safe-area-inset-right));
  bottom: calc(var(--map-gap) + env(safe-area-inset-bottom));
  padding: 12px;
  display: none;
  z-index: 1100;
  max-height: 70vh;
  overflow: auto;
}

/* Map card close button: always top-right */
#card.vendor-card--map {
  position: fixed;
}

.vendor-close--map {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  z-index: 2;
}

/* Prevent title/chips from flowing under the close button */
#card.vendor-card--map .vendor-content {
  padding-right: calc(var(--tap) + 12px);
}

#card.vendor-card--map .vendor-topline {
  align-items: flex-start;
}

.vendor-close {
  flex: 0 0 auto;
}

#card h2 {
  margin: 0 0 4px;
  font-size: 16px;
}

#card p {
  margin: 0;
  font-size: 14px;
  color: #444;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* =========================
   FAVORITES (unified Map + List)
   ========================= */

.fav-btn {
  color: var(--muted); /* Off state: neutral */
  transition: transform 120ms ease;
}

.fav-btn svg {
  width: 20px;
  height: 20px;
}

.fav-btn svg path {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linejoin: round;
}

.fav-btn.is-fav {
  color: #C0392B; /* salsa red */
}

.fav-btn.is-fav svg path {
  fill: currentColor;
  stroke: none;
}

@keyframes favPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

.fav-btn.fav-pop {
  animation: favPop 140ms ease-out;
}

/* Overlays */
.overlay[hidden] {
  display: none;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
}

.overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
}

/* Filters: bottom sheet */
.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: #fff;
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 75vh;
  display: flex;
  flex-direction: column;
}

.sheet-header {
  height: 52px;
  padding: 8px 10px 8px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sheet-title {
  font-weight: 800;
}

.sheet-body {
  padding: 14px;
  overflow: auto;
}

/* Filter controls */
.filter-block {
  margin: 0 0 14px;
}

.filter-label {
  font-weight: 800;
  font-size: 13px;
  margin: 0 0 8px;
}

.filter-input {
  width: 100%;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 0 12px;
  font-size: 14px;
}

.filter-hint {
  margin-top: 6px;
  font-size: 12px;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 12px;
  background: #fafafa;
  font-weight: 600;
  font-size: 13px;
}

.filter-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fafafa;
}

.filter-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 6px;
}

/* Buttons */
.primary-btn {
  width: 100%;
  height: 44px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #111;
  color: #fff;
  font-weight: 700;
}

.secondary-btn {
  width: 100%;
  height: 44px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--fg);
  font-weight: 800;
}

/* About screen */
.about {
  position: absolute;
  inset: 0;
  background: #fcfaf6;
  display: flex;
  flex-direction: column;
  z-index: 1;
}

.about-header {
  min-height: var(--header-h);
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: var(--tap) 1fr var(--tap);
  align-items: center;
  padding: 8px 10px;
  position: sticky;
  top: 0;
  background: #fcfaf6;
  z-index: 2;
}

.about-title {
  text-align: center;
  font-weight: 800;
}

.about-body {
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  overflow: auto;
  line-height: 1.55;
  color: #151515;
}

.about-body a {
  color: #1b4d8f;
}

.about-section + .about-section {
  margin-top: 20px;
}

.about-section h2 {
  margin: 0 0 8px;
  font-size: 16px;
  line-height: 1.25;
}

.about-section p {
  margin: 0;
}

.about-section p + p {
  margin-top: 10px;
}

.about-section ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.about-section li + li {
  margin-top: 8px;
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* Reduce tap highlight weirdness on mobile */
button {
  -webkit-tap-highlight-color: transparent;
}

/* Taco marker (Leaflet divIcon with inline SVG) */
.leaflet-div-icon.taco-marker {
  background: transparent;
  border: 0;
}

.taco-marker svg {
  display: block;
  width: 60px;
  height: 60px;
}

/* Selected marker SVG has its own viewBox; let it size by iconSize */
.taco-marker--selected svg {
  width: 72px;
  height: 32px;
}
