:root {
  --cream: #fdf8f0;
  --cream-deep: #f5e8c7;
  --chocolate: #3f2a1d;
  --chocolate-soft: #5c4030;
  --coral: #c73e1d;
  --gold: #e89c3d;
  --white: #ffffff;
  --line: #e8d9c2;
  --shadow: 0 12px 40px rgba(63, 42, 29, 0.18);
  --radius: 20px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --topbar-h: 64px;
  --sheet-peek: 42vh;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: Inter, system-ui, -apple-system, sans-serif;
  color: var(--chocolate);
  background: var(--cream);
  -webkit-font-smoothing: antialiased;
}

#app {
  position: relative;
  height: 100%;
  overflow: hidden;
}

.topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: linear-gradient(180deg, rgba(253, 248, 240, 0.96) 0%, rgba(253, 248, 240, 0.88) 70%, transparent 100%);
  pointer-events: none;
}

.topbar > * {
  pointer-events: auto;
}

.btn-locate-main {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: none;
  border-radius: 999px;
  padding: 10px 16px 10px 12px;
  background: linear-gradient(135deg, var(--coral), #a83218);
  color: white;
  font-weight: 600;
  font-size: 0.88rem;
  box-shadow: 0 8px 22px rgba(199, 62, 29, 0.35);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  text-align: left;
  max-width: min(78vw, 280px);
}

.btn-locate-main .locate-label {
  display: flex;
  flex-direction: column;
  gap: 1px;
  line-height: 1.15;
}

.btn-locate-main .locate-label strong {
  font-size: 0.92rem;
  font-weight: 700;
}

.btn-locate-main .locate-label em {
  font-style: normal;
  font-size: 0.68rem;
  font-weight: 500;
  opacity: 0.92;
}

.btn-home {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 11px 14px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  color: var(--chocolate);
  font-weight: 600;
  font-size: 0.82rem;
  text-decoration: none;
  box-shadow: 0 4px 14px rgba(63, 42, 29, 0.1);
}

.btn-locate {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  border-radius: 999px;
  padding: 11px 14px;
  background: linear-gradient(135deg, var(--coral), #a83218);
  color: white;
  font-weight: 600;
  font-size: 0.88rem;
  box-shadow: 0 8px 22px rgba(199, 62, 29, 0.35);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.gmap-frame {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: calc(100% - var(--sheet-peek));
  border: 0;
  background: #e8dfd0;
}

#map.map-dimmed {
  visibility: hidden;
}

@media (min-width: 900px) {
  .gmap-frame {
    right: 400px;
    height: 100%;
  }
}

.btn-locate:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 26px rgba(199, 62, 29, 0.42);
}

.btn-locate:active {
  transform: translateY(0);
}

.btn-locate.loading {
  opacity: 0.75;
  pointer-events: none;
}

.btn-locate.loading span::after {
  content: "…";
}

#map {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: #e8dfd0;
}

/* Leaflet chrome */
.leaflet-control-attribution {
  font-size: 10px !important;
  background: rgba(255, 255, 255, 0.75) !important;
  margin-bottom: calc(var(--sheet-peek) + 8px) !important;
}

.leaflet-control-zoom {
  border: none !important;
  box-shadow: 0 6px 18px rgba(63, 42, 29, 0.15) !important;
  margin-top: 78px !important;
  margin-right: 12px !important;
}

.leaflet-control-zoom a {
  color: var(--chocolate) !important;
  width: 34px !important;
  height: 34px !important;
  line-height: 34px !important;
  border-bottom-color: var(--line) !important;
}

.pin-wrap {
  background: transparent;
  border: none;
}

/* Ice-cream map marker */
.pin {
  width: 36px;
  height: 42px;
  display: grid;
  place-items: center;
  position: relative;
  filter: drop-shadow(0 4px 8px rgba(63, 42, 29, 0.35));
}

.pin-bubble {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 18px;
  line-height: 1;
  background: linear-gradient(160deg, #fff 0%, #fdf3e4 100%);
  border: 2.5px solid var(--coral);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.pin-tip {
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 9px solid var(--coral);
  margin-top: -3px;
}

.pin.nearest .pin-bubble {
  width: 40px;
  height: 40px;
  font-size: 20px;
  border-color: var(--gold);
  box-shadow: 0 0 0 5px rgba(232, 156, 61, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.pin.nearest .pin-tip {
  border-top-color: var(--gold);
}

.pin.selected .pin-bubble {
  border-color: var(--chocolate);
  background: linear-gradient(160deg, #fff8ef, #f5e8c7);
}

.pin.selected .pin-tip {
  border-top-color: var(--chocolate);
}

.user-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #2563eb;
  border: 3px solid #fff;
  box-shadow: 0 0 0 8px rgba(37, 99, 235, 0.18), 0 2px 8px rgba(0, 0, 0, 0.25);
}

.status {
  position: absolute;
  top: calc(var(--topbar-h) + 12px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 900;
  max-width: min(92vw, 420px);
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(63, 42, 29, 0.92);
  color: #fff;
  font-size: 0.86rem;
  text-align: center;
  box-shadow: var(--shadow);
}

.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 800;
  height: var(--sheet-peek);
  background: rgba(255, 255, 255, 0.97);
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: 0 -8px 40px rgba(63, 42, 29, 0.16);
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(14px);
  padding-bottom: var(--safe-bottom);
}

.sheet-handle {
  width: 42px;
  height: 4px;
  border-radius: 99px;
  background: #d8c8b0;
  margin: 10px auto 4px;
  flex-shrink: 0;
}

.sheet-head {
  padding: 4px 16px 10px;
  border-bottom: 1px solid rgba(232, 217, 194, 0.7);
  flex-shrink: 0;
}

.sheet-head h2 {
  margin: 0;
  font-family: "Playfair Display", Georgia, serif;
  font-size: 1.2rem;
}

.sheet-head p {
  margin: 2px 0 10px;
  font-size: 0.82rem;
  color: var(--chocolate-soft);
}

.map-audience-note {
  margin: 0 0 12px !important;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(199, 62, 29, 0.08);
  border: 1px solid rgba(199, 62, 29, 0.18);
  font-size: 0.78rem !important;
  line-height: 1.4;
  color: var(--chocolate-soft);
}

.map-audience-note a {
  color: var(--coral);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.search-wrap input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--cream);
  border-radius: 12px;
  padding: 11px 14px;
  font: inherit;
  font-size: 0.92rem;
  color: var(--chocolate);
  outline: none;
}

.search-wrap input:focus {
  border-color: var(--coral);
  box-shadow: 0 0 0 3px rgba(199, 62, 29, 0.12);
}

.search-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
  align-items: stretch;
}

.search-wrap-grow {
  flex: 1 1 160px;
  min-width: 0;
}

.filter-city-only {
  flex: 0 1 160px;
  display: flex;
  align-items: stretch;
}

.filter-city-only select {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 11px 12px;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--chocolate);
  width: 100%;
  height: 100%;
}

.area-line {
  margin-top: 3px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--coral);
  line-height: 1.25;
}

.btn-go-secondary {
  background: transparent;
  color: var(--chocolate);
  border: 1px solid var(--line);
}

.btn-go-secondary:hover {
  background: var(--cream);
}

.popup-card {
  font-family: Inter, system-ui, sans-serif;
  min-width: 160px;
}

.popup-area {
  margin-top: 4px;
  font-size: 12px;
  color: #5c4030;
}

.popup-actions {
  margin-top: 8px;
  font-size: 12px;
}

.popup-actions a {
  color: #c73e1d;
  font-weight: 600;
}

.list {
  overflow: auto;
  padding: 8px 10px 16px;
  -webkit-overflow-scrolling: touch;
  flex: 1;
}

.card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  align-items: center;
  padding: 12px 12px;
  border-radius: 14px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.card:hover,
.card:focus-visible {
  background: var(--cream);
  border-color: var(--line);
  outline: none;
}

.card.active {
  background: linear-gradient(135deg, #fff8ef, #fdf3e4);
  border-color: #efd7b0;
}

.card.nearest-card {
  background: linear-gradient(135deg, #fff8ef, #ffefd6);
  border-color: rgba(232, 156, 61, 0.45);
}

.card-main h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.25;
}

.card-main .meta {
  margin-top: 3px;
  font-size: 0.78rem;
  color: var(--chocolate-soft);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
  color: var(--coral);
}

.badge.gold {
  color: #b45309;
}

.card-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.btn-go {
  border: none;
  border-radius: 10px;
  padding: 8px 12px;
  background: var(--chocolate);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.btn-go:hover {
  background: var(--chocolate-soft);
}

.empty {
  text-align: center;
  padding: 28px 16px;
  color: var(--chocolate-soft);
  font-size: 0.9rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Desktop: side panel */
@media (min-width: 900px) {
  :root {
    --sheet-peek: 100%;
  }

  #map {
    right: 400px;
  }

  .sheet {
    left: auto;
    width: 400px;
    height: 100%;
    border-radius: 0;
    border-top: none;
    border-left: 1px solid var(--line);
  }

  .sheet-handle {
    display: none;
  }

  .leaflet-control-attribution {
    margin-bottom: 8px !important;
  }

  .leaflet-control-zoom {
    margin-top: 78px !important;
  }

  .topbar {
    right: 400px;
  }
}

@media (max-width: 380px) {
  .btn-locate span {
    display: none;
  }

  .btn-locate {
    padding: 12px;
  }
}
