:root {
  --bg: #f7f4ec;
  --ink: #2b2b28;
  --rust: #b4541f;
  --panel: #ffffff;
  --line: #e0dad0;
  --muted: #6f6a60;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

.topbar {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
}

.topbar h1 {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
}

.filters {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.filters select {
  margin-left: 0.35rem;
  padding: 0.2rem 0.4rem;
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg);
}

.count { font-variant-numeric: tabular-nums; }

/* Map is the main character: full-bleed canvas with the list floating over it. */
main {
  position: relative;
  height: calc(100% - 3.5rem);
}

#map {
  position: absolute;
  inset: 0;
  height: 100%;
}

#list {
  position: absolute;
  top: 1rem;
  right: 1rem;
  bottom: 1rem;
  width: 21rem;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.14);
  z-index: 500; /* above Leaflet panes */
}

#list .shop:last-child { border-bottom: none; }

/* Sticky panel head with count + collapse toggle. */
.panel-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  border-radius: 10px 10px 0 0;
}

.panel-head .count {
  font-size: 0.8rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

#list-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
  line-height: 1;
}

#list-toggle:hover { border-color: var(--rust); color: var(--rust); }

.chevron {
  font-size: 1.1rem;
  /* Expanded: chevron points right (collapse toward edge). */
  transform: rotate(0deg);
  transition: transform 0.15s ease;
}

/* Collapsed: panel shrinks to just the head pill; chevron flips to "reopen". */
#list.collapsed {
  bottom: auto;
  width: auto;
}

#list.collapsed #list-items { display: none; }
#list.collapsed .panel-head { border-bottom: none; border-radius: 10px; }
#list.collapsed .chevron { transform: rotate(180deg); }

.shop {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.shop:hover { background: var(--bg); }

.shop h2 {
  margin: 0 0 0.15rem;
  font-size: 0.95rem;
}

.shop .kind {
  display: inline-block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--rust);
}

.shop .meta { font-size: 0.8rem; color: var(--muted); }

.shop .edit {
  float: right;
  margin-left: 0.5rem;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.95rem;
}
.shop .edit:hover { color: var(--rust); }

.popup-title { font-weight: 600; }
.popup-meta { color: var(--muted); font-size: 0.82rem; }

.more-hint {
  cursor: default;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}
.more-hint:hover { background: none; }

/* Locate control button — matches Leaflet's control chrome. */
.locate-btn {
  width: 34px;
  height: 34px;
  border: 2px solid rgba(0, 0, 0, 0.2);
  background: #fff;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  color: var(--ink);
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.4);
}
.locate-btn:hover { background: var(--bg); color: var(--rust); }

/* Transient status toast (geolocation feedback). */
#toast {
  position: absolute;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%) translateY(1rem);
  z-index: 600;
  max-width: 80%;
  padding: 0.5rem 0.85rem;
  background: var(--ink);
  color: #fff;
  font-size: 0.85rem;
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 720px) {
  /* Bottom sheet over a full-bleed map. */
  #list {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-height: 45%;
    border: none;
    border-top: 1px solid var(--line);
    border-radius: 12px 12px 0 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.14);
  }
  .panel-head { border-radius: 12px 12px 0 0; }
  /* Keep the sheet pinned to the bottom edge when collapsed. */
  #list.collapsed { bottom: 0; width: auto; }
}
