* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --sidebar-width: 340px;
  --accent: #2c7a4b;
  --bg: #ffffff;
  --bg-alt: #f4f6f5;
  --text: #1f2933;
  --text-muted: #616e7c;
  --border: #e0e4e8;
}

html, body {
  height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
}

#app {
  display: flex;
  height: 100%;
}

#map {
  flex: 1;
  height: 100%;
  z-index: 1;
}

/* ---------- Sidebar ---------- */

#sidebar {
  width: var(--sidebar-width);
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-right: 1px solid var(--border);
  z-index: 2;
  transition: margin-left 0.25s ease;
}

#sidebar.collapsed {
  margin-left: calc(-1 * var(--sidebar-width));
}

#sidebar-header {
  padding: 16px 16px 12px;
  background: var(--accent);
  color: #fff;
}

#sidebar-header h1 {
  font-size: 1.3rem;
}

#sidebar-header .subtitle {
  font-size: 0.8rem;
  opacity: 0.9;
  margin-top: 4px;
}

#controls {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

#search {
  width: 100%;
  padding: 8px 10px;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 10px;
}

#search:focus {
  outline: 2px solid var(--accent);
  border-color: transparent;
}

#drive-filter {
  margin-bottom: 10px;
  font-size: 0.85rem;
}

#drive-filter label {
  display: block;
  margin-bottom: 4px;
  color: var(--text-muted);
}

#drive-range {
  width: 100%;
  accent-color: var(--accent);
}

#category-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cat-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: var(--bg-alt);
  font-size: 0.78rem;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s;
}

.cat-chip.active {
  border-color: var(--chip-color);
  background: var(--chip-bg);
  font-weight: 600;
}

.cat-chip .count {
  color: var(--text-muted);
  font-weight: normal;
  font-size: 0.72rem;
}

#results-count {
  padding: 8px 16px;
  font-size: 0.78rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

/* ---------- Place list ---------- */

#place-list {
  flex: 1;
  overflow-y: auto;
  list-style: none;
}

.place-item {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}

.place-item:hover,
.place-item.highlight {
  background: var(--bg-alt);
}

.place-item .place-name {
  font-weight: 600;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.place-item .place-meta {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-top: 2px;
}

#sidebar-footer {
  padding: 8px 16px;
  font-size: 0.7rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

#sidebar-footer a {
  color: var(--text-muted);
}

/* ---------- Sidebar toggle ---------- */

#sidebar-toggle {
  position: absolute;
  top: 10px;
  left: calc(var(--sidebar-width) + 10px);
  z-index: 1000;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 6px;
  background: var(--bg);
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.3);
  font-size: 1.1rem;
  cursor: pointer;
  transition: left 0.25s ease;
}

#sidebar.collapsed ~ #sidebar-toggle {
  left: 10px;
}

/* ---------- Map markers & popups ---------- */

.marker-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.marker-icon span {
  transform: rotate(45deg);
  font-size: 15px;
  line-height: 1;
}

.home-marker {
  font-size: 26px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.leaflet-popup-content-wrapper {
  border-radius: 10px;
}

.leaflet-popup-content {
  margin: 14px 16px;
  min-width: 240px;
  max-width: 280px;
}

.popup-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 2px;
}

.popup-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 6px 0;
}

.badge {
  font-size: 0.68rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.badge.cat {
  color: #fff;
  border: none;
}

.popup-desc {
  font-size: 0.82rem;
  line-height: 1.45;
  margin: 6px 0;
}

.popup-detail {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin: 3px 0;
  line-height: 1.4;
}

.popup-links {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.popup-links a {
  flex: 1;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
}

.popup-links a.secondary,
.popup-links button.secondary {
  background: var(--bg-alt);
  color: var(--text);
  border: 1px solid var(--border);
}

.popup-links button {
  flex: 1;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}

/* ---------- Mobile ---------- */

@media (max-width: 700px) {
  :root {
    --sidebar-width: 85vw;
  }

  #sidebar {
    position: absolute;
    left: 0;
    top: 0;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.2);
  }
}
