:root {
  --bg: #ffffff;
  --surface: #fafaf9;
  --surface-hover: #f4f4f5;
  --border: #ececec;
  --border-strong: #d4d4d8;
  --text: #18181b;
  --text-soft: #3f3f46;
  --muted: #71717a;
  --muted-soft: #a1a1aa;
  --accent: #e85d27;
  --accent-hover: #d14e1c;
  --accent-soft: #fde7dc;
  --pin-default: #3f3f46;
  --pin-favorite: #eab308;
  --map-bg: #eef0ee;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
  --sidebar-w: 340px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

body.theme-dark {
  --bg: #0a0a0a;
  --surface: #141414;
  --surface-hover: #1f1f1f;
  --border: #27272a;
  --border-strong: #3f3f46;
  --text: #fafafa;
  --text-soft: #e4e4e7;
  --muted: #a1a1aa;
  --muted-soft: #71717a;
  --accent: #f07a47;
  --accent-hover: #e85d27;
  --accent-soft: rgba(240, 122, 71, 0.18);
  --pin-default: #d4d4d8;
  --pin-favorite: #fbbf24;
  --map-bg: #1a1a1a;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: 'cv11', 'ss01';
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

button {
  font-family: inherit;
  color: inherit;
}

/* ---------- Sidebar ---------- */
.sidebar {
  flex: 0 0 var(--sidebar-w);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow: hidden;
  padding: 20px 18px 0;
  gap: 16px;
  transition: margin-left 0.35s var(--ease);
  z-index: 500;
}

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

/* Brand */
.brand {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.brand-text h1 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 0;
  line-height: 1.2;
}
.brand .tagline {
  margin: 3px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  letter-spacing: -0.005em;
}

/* Icon button */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: var(--radius-sm);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.12s ease;
  padding: 0;
}
.icon-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface-hover);
}

.sidebar-expand {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 600;
  width: 36px;
  height: 36px;
  background: var(--bg);
  box-shadow: var(--shadow);
}
body:not(.sidebar-collapsed) .sidebar-expand { display: none; }

/* ---------- Search ---------- */
.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: 12px;
  color: var(--muted);
  pointer-events: none;
}
#search {
  width: 100%;
  padding: 10px 50px 10px 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  font-size: 14px;
  color: var(--text);
  font-family: inherit;
  transition: all 0.15s ease;
  outline: none;
}
#search::placeholder { color: var(--muted-soft); }
#search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.kbd {
  position: absolute;
  right: 10px;
  padding: 2px 6px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: 4px;
  pointer-events: none;
}

/* ---------- Header actions ---------- */
.header-actions { display: flex; gap: 6px; }
#theme-toggle .icon-sun { display: none; }
#theme-toggle .icon-moon { display: block; }
body.theme-dark #theme-toggle .icon-sun { display: block; }
body.theme-dark #theme-toggle .icon-moon { display: none; }

/* ---------- Quick actions ---------- */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}
.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 8px 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-soft);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s ease;
  white-space: nowrap;
}
.action-btn:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}
.action-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.action-btn.active svg { color: #fff; }
.action-btn svg { color: var(--muted); transition: color 0.12s; }
.action-btn:hover svg { color: var(--text); }

/* ---------- Filters ---------- */
.filter-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 8px;
  display: block;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.chip {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s var(--ease);
  user-select: none;
  color: var(--text-soft);
  font-family: inherit;
}
.chip:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}
.chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  transform: scale(1.02);
}
.chip.active:hover { background: var(--accent-hover); }

/* ---------- List ---------- */
.list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 4px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

.count-badge {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 6px;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 10.5px;
  color: var(--text-soft);
  letter-spacing: 0;
  text-transform: none;
  font-weight: 500;
}

.sort-toggle {
  display: inline-flex;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
}
.sort-btn {
  background: none;
  border: 0;
  padding: 4px 9px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.12s;
}
.sort-btn.active {
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.list {
  flex: 1 1 0;
  min-height: 80px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 4px 8px 0;
  margin: 0 -4px 0 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.list::-webkit-scrollbar { width: 6px; }
.list::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
.list::-webkit-scrollbar-track { background: transparent; }

.list-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s, transform 0.12s;
  border: 1px solid transparent;
}
.list-item:hover,
.list-item.hover {
  background: var(--bg);
  border-color: var(--border);
}

.list-item-main {
  min-width: 0;
  flex: 1;
}
.list-item-name {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 6px;
}
.list-item-featured {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 3px;
  font-size: 9px;
  font-weight: 700;
  flex: 0 0 auto;
}
.list-item-meta {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 1px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.list-item-meta .dot {
  width: 3px;
  height: 3px;
  background: var(--muted-soft);
  border-radius: 50%;
}
.open-pill {
  color: #16a34a;
  font-weight: 500;
}
.closed-pill {
  color: #dc2626;
  font-weight: 500;
}

.fav-btn {
  background: none;
  border: 0;
  padding: 2px;
  cursor: pointer;
  color: var(--muted-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color 0.12s, transform 0.12s;
  flex: 0 0 auto;
}
.fav-btn:hover { color: var(--accent); transform: scale(1.15); }
.fav-btn.active { color: var(--accent); }
.fav-btn.active svg { fill: var(--accent); }

.list-empty {
  padding: 24px 10px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ---------- More from me ---------- */
.also-by {
  padding-top: 12px;
  border-top: 1px solid var(--border);
  flex: 0 0 auto;
}
.link-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}
.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 999px;
  color: var(--text-soft);
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.15s var(--ease);
  white-space: nowrap;
}
.link-btn:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
  color: var(--text);
}
.link-btn svg { color: var(--muted); flex: 0 0 auto; transition: color 0.12s; }
.link-btn:hover svg { color: var(--text-soft); }
.link-btn-donate svg { color: var(--accent); }
.link-btn-donate:hover { border-color: var(--accent); color: var(--accent); }
.link-btn-donate:hover svg { color: var(--accent); }

/* ---------- Credits / footer ---------- */
.credits {
  flex: 0 0 auto;
  margin: 0 -18px;
  padding: 10px 18px;
  background: var(--surface);
  font-size: 11px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.credits a { color: var(--muted); text-decoration: underline; }

.link {
  background: none;
  border: 0;
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
}
.link:hover { text-decoration: underline; }

/* ---------- Map ---------- */
#map {
  flex: 1;
  height: 100vh;
  background: var(--map-bg);
}
.leaflet-container { font-family: inherit; }
.leaflet-control-attribution {
  font-size: 10px !important;
  background: rgba(255,255,255,0.85) !important;
  padding: 2px 6px !important;
  border-radius: 4px !important;
}
body.theme-dark .leaflet-control-attribution {
  background: rgba(20,20,20,0.85) !important;
  color: var(--muted) !important;
}
body.theme-dark .leaflet-control-attribution a { color: var(--text-soft) !important; }

.leaflet-bar a,
.leaflet-bar a:hover {
  background: var(--bg);
  color: var(--text);
  border-color: var(--border);
}
body.theme-dark .leaflet-bar a { border-color: var(--border-strong); }

/* ---------- Pin markers ---------- */
.pin-wrap {
  background: none !important;
  border: 0 !important;
}
.pin {
  color: var(--pin-default);
  filter: drop-shadow(0 1.5px 2px rgba(0,0,0,0.35));
  transition: transform 0.18s var(--ease);
  display: block;
}
.pin.featured { color: var(--accent); }
.pin.favorite { color: var(--pin-favorite); }
.pin-wrap:hover .pin,
.pin-wrap.hover .pin { transform: scale(1.2) translateY(-2px); }
.pin-core { fill: var(--bg); }

/* Cluster restyle */
.marker-cluster {
  background: rgba(232, 93, 39, 0.15) !important;
  border: 2px solid var(--accent);
}
.marker-cluster div {
  background: var(--accent) !important;
  color: #fff !important;
  font-weight: 600 !important;
  font-family: inherit !important;
  font-size: 12px !important;
}

/* ---------- Popup ---------- */
.leaflet-popup-content-wrapper {
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 0;
}
.leaflet-popup-content {
  margin: 0;
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.5;
  min-width: 200px;
}
.leaflet-popup-tip { box-shadow: var(--shadow-sm); }

.popup-featured {
  display: inline-block;
  margin-bottom: 6px;
  padding: 2px 7px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.popup-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.popup-name {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.005em;
  color: var(--text);
  line-height: 1.3;
}
.popup-fav {
  background: none;
  border: 0;
  padding: 2px;
  cursor: pointer;
  color: var(--muted-soft);
  transition: color 0.12s, transform 0.12s;
  flex: 0 0 auto;
}
.popup-fav:hover { color: var(--accent); transform: scale(1.15); }
.popup-fav.active { color: var(--accent); }
.popup-fav.active svg { fill: var(--accent); }
.popup-meta {
  color: var(--muted);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.popup-meta .dot {
  width: 3px; height: 3px; background: var(--muted-soft); border-radius: 50%;
}
.popup-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.popup-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  color: var(--text);
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all 0.12s;
}
.popup-link:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}
.popup-link.primary {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}
.popup-link.primary:hover {
  background: var(--text-soft);
  border-color: var(--text-soft);
}

/* ---------- Loader ---------- */
.loader {
  position: fixed;
  top: 16px;
  left: calc(var(--sidebar-w) + 16px);
  padding: 9px 14px 9px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 1000;
  font-size: 12.5px;
  color: var(--text-soft);
  transition: left 0.35s var(--ease);
}
body.sidebar-collapsed .loader { left: 16px; }
.loader.hidden { display: none; }
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Animations ---------- */
@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.list-item { animation: fade-in 0.2s var(--ease) both; }

/* ---------- Mobile ---------- */
@media (max-width: 720px) {
  body { flex-direction: column; }
  .sidebar {
    flex: 0 0 auto;
    width: 100%;
    max-height: 58vh;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding: 14px 14px 0;
  }
  body.sidebar-collapsed .sidebar {
    margin-left: 0;
    margin-top: calc(-58vh);
  }
  #map { flex: 1; height: auto; min-height: 42vh; }
  .loader { left: 12px !important; top: auto; bottom: 12px; }
  .sidebar-expand { top: 10px; left: 10px; }
}
