:root {
  /* Oil 6 palette — lospec.com/palette-list/oil-6 (GrafxKid)
     #272744  #494d7e  #8b6d9c  #c69fa5  #f2d3ab  #fbf5ef
     A navy→cream monoramp: navy surfaces, indigo borders, mauve muted text,
     dusty-rose highlights, warm-sand accent, cream foreground. */
  --bg: #21213b;           /* a hair below the darkest swatch for depth */
  --panel: #272744;        /* darkest swatch — cards, sidebar, modals */
  --panel-2: #34345e;      /* raised surface between the two darks */
  --border: #494d7e;       /* indigo — separators, input borders */
  --text: #fbf5ef;         /* cream — primary foreground */
  --muted: #ad94bd;        /* mauve (lightened) — secondary text */
  --rose: #c69fa5;         /* dusty rose — likes / soft highlights */
  --accent: #f2d3ab;       /* warm sand — primary accent */
  --accent-hover: #f8e3c5;
  --ink: #272744;          /* navy text that sits on sand/cream surfaces */
  --danger: #b76a72;       /* rose-red derived from the palette */
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  /* Lock the page itself — it's a full-screen map. Overlays/sheets scroll
     internally; without this the page could scroll on mobile and reveal an
     open spot sheet behind a modal. */
  overflow: hidden;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

#map {
  position: absolute;
  inset: 0;
}

/* Dim/desaturate the base tiles slightly for a moodier urbex feel */
.leaflet-tile-pane { filter: saturate(0.9) brightness(0.95); }

/* ----- Search ----- */
#search-box {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1100;
  width: min(520px, calc(100% - 24px));
}

/* Search bar on the left (flex:1) + filter/locate tool buttons on the right. */
#search-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
#search-main {
  flex: 1;
  min-width: 0;
}
#map-tools {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.map-tool-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  color: var(--text);
  background: rgba(39, 39, 68, 0.92);
  border: 1px solid var(--border);
  backdrop-filter: blur(6px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}
.map-tool-btn:hover { background: var(--panel-2); color: var(--accent); }

#search-form {
  display: flex;
  gap: 6px;
  background: rgba(39, 39, 68, 0.92);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 5px 5px 14px;
  backdrop-filter: blur(6px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}

#search-input {
  flex: 1;
  background: transparent;
  border: none;
  padding: 6px 0;
  font-size: 14px;
}
#search-input:focus { outline: none; }

#search-btn {
  background: var(--accent);
  color: var(--ink);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 14px;
}
#search-btn:hover { background: var(--accent-hover); }
#search-btn:disabled { opacity: 0.6; }

#search-results {
  list-style: none;
  margin: 6px 0 0;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  max-height: 260px;
  overflow-y: auto;
}
#search-results li {
  padding: 9px 11px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.35;
  cursor: pointer;
  color: var(--text);
}
#search-results li:hover { background: var(--panel-2); }
#search-results li.empty {
  color: var(--muted);
  cursor: default;
  text-align: center;
}
#search-results li.empty:hover { background: transparent; }

#hint {
  position: absolute;
  bottom: 48px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: rgba(39, 39, 68, 0.85);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  pointer-events: none;
  backdrop-filter: blur(4px);
}

/* Zoom + layer switcher live in the bottom-right corner (set in app.js). */

/* ----- Filter panel ----- */
#filter-panel {
  position: absolute;
  right: 12px;         /* drops below the account chip, near the filter button */
  left: auto;
  top: 64px;
  z-index: 1100;
  width: 224px;
  max-height: calc(100% - 120px);
  overflow-y: auto;
  background: rgba(39, 39, 68, 0.95);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
  padding: 12px 14px;
}
.filter-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.filter-head h3 { margin: 0; font-size: 15px; }
#filter-reset {
  font-size: 12px;
  padding: 3px 8px;
}
.filter-group { margin-bottom: 12px; }
.filter-group:last-child { margin-bottom: 0; }
.filter-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 5px;
}
.filter-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 2px;
  font-size: 13px;
  cursor: pointer;
}
.filter-item input { accent-color: var(--accent); cursor: pointer; }

/* Locked (Supporter-only) filter rows: muted, with a star, click pitches the
   upsell. pointer-events:none on the box routes the click to the row handler. */
.filter-item.locked { opacity: 0.7; cursor: pointer; }
.filter-item.locked input { pointer-events: none; }
.filter-item .filter-lock { margin-left: auto; color: var(--accent); font-size: 12px; }
.filter-label .perk-badge {
  font-size: 10px;
  letter-spacing: 0.02em;
  color: var(--accent);
  text-transform: none;
}

/* Pins that don't match the active filters recede but stay clickable. */
.pin-dimmed {
  opacity: 0.35;
  filter: grayscale(0.85);
  transition: opacity 0.15s, filter 0.15s;
}

/* ----- Custom markers ----- */
.urbex-pin {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid rgba(0, 0, 0, 0.35);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  font-size: 14px;
}
.urbex-pin span { transform: rotate(45deg); }
.condition-intact     { background: #4c9a5b; }
.condition-sealed_off { background: #4a78c0; }
.condition-demolished { background: #8a8f99; }
.urbex-pin.is-pending { opacity: 0.55; border-style: dashed; }
/* Per-user "explored" checkmark, sits on the marker's top-right corner */
.explored-check {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #4c9a5b;
  color: #07140a;
  font-size: 10px;
  font-weight: 700;
  line-height: 15px;
  text-align: center;
  border: 1.5px solid var(--bg);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

.signin-link, .signin-link2 { color: var(--accent); cursor: pointer; }

/* Private-spot lock badge (top-left corner of the marker) */
.private-lock {
  position: absolute;
  top: -6px;
  left: -6px;
  font-size: 11px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.7));
}
.supporter-star { color: var(--accent); }

/* ----- Modal ----- */
.hidden { display: none !important; }

#modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.55);
  display: grid;
  place-items: center;
  padding: 16px;
}

#pin-form {
  width: min(460px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

#pin-form h2 {
  margin: 0;
  font-size: 19px;
  letter-spacing: 0.3px;
}

#pin-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

#pin-form .row {
  display: flex;
  gap: 12px;
}
#pin-form .row label { flex: 1; }

input, textarea, select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 9px 10px;
  font-size: 14px;
  font-family: inherit;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
}
textarea { resize: vertical; }

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

button {
  border: none;
  border-radius: 8px;
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
#save-btn { background: var(--accent); color: var(--ink); }
#save-btn:hover { background: var(--accent-hover); }
button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
button.ghost:hover { color: var(--text); }
button:disabled { opacity: 0.5; cursor: default; }

/* ----- Thumbnails (popup + edit form) ----- */
.thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.thumbs .thumb-wrap { position: relative; }
.thumbs img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: pointer;
}
.thumbs .del-photo {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  padding: 0;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  font-size: 12px;
  line-height: 20px;
  text-align: center;
}

/* ----- Account chip (top-right) ----- */
#account {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1100;
  display: flex;
  align-items: center;
  gap: 8px;
}
#account .chip {
  display: flex;
  align-items: center;
  gap: 9px;
  background: rgba(39, 39, 68, 0.92);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 14px;
  backdrop-filter: blur(6px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  font-size: 13px;
}
#account .chip img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
#account .chip-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
}
#account .chip-name {
  font-weight: 600;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#account .chip .avatar-fallback {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--ink);
  font-weight: 700;
}
#account .role-tag {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}
#account button {
  padding: 7px 13px;
  font-size: 13px;
  border-radius: 999px;
}
#account button.signin { background: var(--accent); color: var(--ink); }
#account button.icon-btn {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
}

/* ----- Sidebar ----- */
#sidebar {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 1500;
  width: min(380px, 100%);
  height: 100%;
  background: var(--panel);
  border-left: 1px solid var(--border);
  box-shadow: -10px 0 40px rgba(0, 0, 0, 0.5);
  overflow-y: auto;
  overscroll-behavior: contain;
  transform: translateX(0);
  transition: transform 0.22s ease;
}
#sidebar.hidden {
  display: block !important;
  transform: translateX(105%);
  pointer-events: none;
}
#sidebar-close {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 2;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.4);
  color: var(--text);
  font-size: 20px;
  line-height: 32px;
}
#sidebar-content { padding: 0 0 24px; }

.sb-hero {
  width: 100%;
  height: 200px;
  object-fit: cover;
  background: var(--panel-2);
  display: block;
}
.sb-hero-empty {
  height: 90px;
  background: linear-gradient(135deg, #34345e, #272744);
}
.sb-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.sb-body h2 { margin: 0; font-size: 21px; line-height: 1.2; }
.sb-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sb-desc { font-size: 14px; line-height: 1.5; color: var(--text); white-space: pre-wrap; margin: 0; }
.sb-desc.muted { color: var(--muted); font-style: italic; }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink);
}
.badge.pending { background: #d9a441; color: var(--ink); }
.badge.cat { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); }

.sb-gallery { display: flex; flex-wrap: wrap; gap: 6px; }
.sb-gallery img {
  width: 80px; height: 80px; object-fit: cover;
  border-radius: 8px; border: 1px solid var(--border); cursor: pointer;
}

.sb-section { border-top: 1px solid var(--border); padding-top: 12px; }

.like-row { display: flex; align-items: center; gap: 10px; }
.like-btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 999px; padding: 8px 15px;
}
.like-btn.liked { background: #3a2b40; border-color: var(--rose); color: #f0d4d8; }
.like-btn:disabled { cursor: default; }
.like-count { color: var(--muted); font-size: 13px; }
.explored-btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 999px; padding: 8px 15px;
}
.explored-btn.done { background: #234029; border-color: #4c9a5b; color: #c8f0d2; }
.explored-btn:disabled { cursor: default; }
.deletion-banner { font-size: 13px; color: #f0c9c4; }
.deletion-banner em { color: var(--text); font-style: italic; }

.sb-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.sb-actions button { padding: 8px 14px; font-size: 13px; }
.btn-secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); }
.btn-approve { background: #4c9a5b; color: #07140a; }
.btn-danger { background: var(--danger); color: #fff; }

/* Navigate (Google Maps) — Supporter perk button in the sidebar. */
.btn-nav {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 10px 14px; font-size: 14px; font-weight: 600;
  border-radius: 10px; cursor: pointer; text-decoration: none;
  background: var(--accent); color: var(--ink); border: none;
}
.btn-nav:hover { background: var(--accent-hover); }
.btn-nav.locked {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
}

/* Comments */
.comment-list { display: flex; flex-direction: column; gap: 12px; margin: 10px 0; }
.comment { display: flex; gap: 9px; }
.comment .c-avatar {
  width: 30px; height: 30px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
  background: var(--accent); color: var(--ink); display: grid; place-items: center; font-weight: 700; font-size: 13px;
}
.comment .c-main { flex: 1; min-width: 0; }
.comment .c-name { font-size: 13px; font-weight: 600; }
.comment .c-time { font-size: 11px; color: var(--muted); margin-left: 6px; font-weight: 400; }
.comment .c-body { font-size: 13px; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; }
.comment .c-del { background: none; color: var(--muted); padding: 0 4px; font-size: 12px; }
.comment .c-del:hover { color: var(--danger); }
.comment .c-report { background: none; color: var(--muted); padding: 0 4px; font-size: 12px; }
.comment .c-report:hover { color: var(--danger); }
.comment-empty { color: var(--muted); font-size: 13px; }

#comment-form { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
#comment-form textarea { width: 100%; }
.comment-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.attach-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 12px; font-size: 13px; cursor: pointer;
}
.attach-btn:hover { border-color: var(--accent); }
.c-gallery { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.c-gallery img {
  width: 64px; height: 64px; object-fit: cover;
  border-radius: 6px; border: 1px solid var(--border); cursor: pointer;
}
.hint-text { color: var(--muted); font-weight: 400; font-size: 11px; }

/* Checkbox rows (anonymous toggles) */
.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex-direction: row !important;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}
.checkbox-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin-top: 1px;
  accent-color: var(--accent);
  flex-shrink: 0;
}
.checkbox-row.small { font-size: 12px; color: var(--muted); align-items: center; }
.comment-actions-left { display: flex; align-items: center; gap: 10px; }
.sb-author { font-size: 12px; color: var(--muted); margin-top: -4px; }
.anon-tag { font-size: 11px; }
.signin-nudge { color: var(--muted); font-size: 13px; }
.signin-nudge a { color: var(--accent); cursor: pointer; }

/* ----- Admin panel ----- */
#admin-overlay {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(0, 0, 0, 0.55); display: grid; place-items: center; padding: 16px;
}
#admin-panel {
  width: min(560px, 100%); max-height: 90vh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 18px 20px 20px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.admin-head { display: flex; align-items: center; justify-content: space-between; }
.admin-head h2 { margin: 0; font-size: 19px; }

.admin-tabs { display: flex; gap: 6px; margin: 14px 0 16px; border-bottom: 1px solid var(--border); }
.admin-tab {
  background: none; color: var(--muted); border: none; border-bottom: 2px solid transparent;
  padding: 8px 12px; font-size: 14px; font-weight: 600; border-radius: 0;
}
.admin-tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab-badge {
  display: inline-block; min-width: 18px; padding: 1px 6px; border-radius: 999px;
  background: var(--accent); color: var(--ink); font-size: 11px; font-weight: 700; text-align: center;
}

.admin-user {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid var(--border);
}
.admin-user .u-info { flex: 1; min-width: 0; }
.admin-user .u-name { font-size: 14px; }
.admin-user .u-email { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-user .u-supporter { font-size: 11px; color: var(--accent); margin-top: 2px; }
.admin-user .u-banned { font-size: 11px; color: var(--danger); margin-top: 2px; font-weight: 600; }
.admin-user select { padding: 6px 8px; }

/* Members view: search + pagination so the list scales to many users. */
.members-toolbar { margin-bottom: 12px; }
#member-search { width: 100%; }
.members-pager {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-top: 14px;
}
.members-pager button { padding: 6px 12px; font-size: 13px; }
.member-range { font-size: 12px; color: var(--muted); }

/* Per-row controls stack (supporter toggle above role select). */
.u-controls { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; flex-shrink: 0; }
.supporter-toggle {
  padding: 5px 11px; font-size: 12px; border-radius: 999px;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  white-space: nowrap;
}
.supporter-toggle.on { background: rgba(242, 211, 171, 0.14); border-color: var(--accent); color: var(--accent); }
.supporter-toggle:disabled { opacity: 0.5; cursor: default; }
.ban-toggle {
  padding: 5px 11px; font-size: 12px; border-radius: 999px;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  white-space: nowrap;
}
.ban-toggle.on { background: #3a1414; border-color: var(--danger); color: #f3b2ab; }
.ban-toggle:disabled { opacity: 0.5; cursor: default; }

/* Review queue cards */
.q-h { font-size: 13px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); margin: 16px 0 8px; }
.q-h:first-child { margin-top: 0; }
.q-n { background: var(--panel-2); border-radius: 999px; padding: 1px 8px; font-size: 12px; margin-left: 4px; }
.q-empty { color: var(--muted); font-size: 13px; padding: 4px 0 8px; }
.q-card {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.q-thumb { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; flex-shrink: 0; }
.q-thumb-empty { display: grid; place-items: center; background: var(--panel-2); font-size: 20px; }
.q-info { flex: 1; min-width: 0; }
.q-title { font-size: 14px; font-weight: 600; }
.q-sub { font-size: 12px; color: var(--muted); }
.q-reason { font-size: 12px; color: #f0c9c4; margin-top: 3px; font-style: italic; }
.q-actions { display: flex; flex-direction: column; gap: 5px; flex-shrink: 0; }
.q-actions button { padding: 6px 12px; font-size: 12px; }

/* ----- Supporter benefits sidebar (slides in beside the Ko-fi widget) ----- */
/* The Ko-fi popup is a 328px panel pinned to the bottom-right; this sits just
   to its left and mirrors its open/closed state (.open toggled from app.js). */
/* Ko-fi's floating popup is a 328px panel anchored bottom-left (left: 16px),
   so the benefits panel sits just to its right and shares its bottom edge. */
#kofi-benefits {
  position: fixed; z-index: 10000; left: 360px; bottom: 80px;
  width: min(320px, calc(100vw - 400px)); max-height: min(690px, calc(100vh - 120px));
  overflow-y: auto; overscroll-behavior: contain;
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  padding: 22px 22px 18px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  opacity: 0; visibility: hidden; pointer-events: none;
  transform: translateX(-14px);
  transition: opacity 0.3s ease, transform 0.4s ease, visibility 0s linear 0.4s;
}
#kofi-benefits.open {
  opacity: 1; visibility: visible; pointer-events: auto;
  transform: translateX(0);
  transition: opacity 0.4s ease 0.15s, transform 0.45s ease 0.15s, visibility 0s;
}
/* No room to sit beside the popup on small screens — the popup goes near-full-width. */
@media (max-width: 820px) { #kofi-benefits { display: none; } }

#kofi-benefits h2 { margin: 0 0 4px; font-size: 22px; }
.supporter-price { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.supporter-price .amount { color: var(--accent); font-size: 28px; font-weight: 700; }
.supporter-price .per { color: var(--text); margin-left: 4px; }
.supporter-intro { font-size: 13px; color: var(--muted); line-height: 1.5; margin: 0 0 18px; }
.perks { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.perks li { display: flex; gap: 12px; align-items: flex-start; }
.perk-ic { font-size: 19px; width: 26px; text-align: center; flex-shrink: 0; }
.perks strong { font-size: 14px; }
.perks li span { font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.perks-soon { font-size: 12px; color: var(--muted); font-style: italic; margin: 0 0 18px; }
.supporter-legal { font-size: 11px; color: var(--muted); text-align: center; margin: 12px 0 0; line-height: 1.7; }
.supporter-legal a { color: var(--muted); }

/* ----- Ko-fi tip panel (the popup the floating button opens) -----
   The donation form is hosted by Ko-fi (ko-fi.com, cross-origin) and is
   light-themed — its interior can't be recoloured from our side. What we can
   do is frame the popup so it reads as an intentional card that fits the rest
   of the chrome: rounded corners (the iframe clips its white content to them),
   a themed border + shadow, on a navy backing. */
iframe[id$="kofi-popup-iframe"] {
  border-radius: 14px !important;
  border: 1px solid var(--border) !important;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6) !important;
  background: var(--panel) !important;
}

/* ----- Footer (legal links) ----- */
#footer {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  z-index: 900;
  font-size: 11px;
  background: rgba(39, 39, 68, 0.7);
  padding: 3px 9px;
  border-radius: 8px;
  backdrop-filter: blur(4px);
}
#footer a { color: var(--muted); text-decoration: none; }
#footer a:hover { color: var(--accent); }

/* ----- Toast ----- */
#toast {
  position: fixed; bottom: 60px; left: 50%; transform: translateX(-50%);
  z-index: 3000; background: var(--panel); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 18px; font-size: 13px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  max-width: 90%;
}

@media (max-width: 640px) {
  /* iOS zooms the page when focusing an input smaller than 16px — pin all
     form fields at 16px so tapping a field doesn't jolt the whole map. */
  input, textarea, select, #search-input { font-size: 16px; }

  /* Search: a full-width bar pinned to the very top edge. */
  #search-box {
    top: 8px;
    left: 8px;
    right: 8px;
    width: auto;
    transform: none;
  }

  /* Account chip lands just below the search bar, hugging the right edge and
     wrapping its buttons. No `left` so the empty box never covers — and blocks
     taps on — the zoom controls on the opposite side. */
  #account {
    top: 56px;
    right: 8px;
    max-width: calc(100% - 16px);
    flex-wrap: wrap;
    justify-content: flex-end;
  }
  #account .chip { padding: 5px 10px; }
  #account .chip-name { max-width: 100px; }
  #account button { padding: 8px 12px; }

  /* Filter panel drops below the account chip on the right and widens a little. */
  #filter-panel {
    top: 104px;
    right: 8px;
    left: auto;
    width: min(260px, calc(100% - 16px));
    max-height: calc(100% - 160px);
  }

  /* Detail panel becomes a bottom sheet. */
  #sidebar {
    width: 100%;
    height: 78%;
    top: auto;
    bottom: 0;
    border-left: none;
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
  }
  #sidebar.hidden { transform: translateY(105%); }
  #sidebar-close { width: 36px; height: 36px; line-height: 36px; }

  /* Stack the category/condition selects so neither gets cramped. */
  #pin-form .row { flex-direction: column; gap: 14px; }

  /* Trim modal side padding to reclaim width on small screens. */
  #pin-form, #admin-panel { padding: 18px 16px; }

  /* Keep the drop-a-pin hint clear of the centred footer below it. */
  #hint { bottom: 44px; font-size: 12px; }
}

/* ----- Leaflet controls (zoom + layer switcher) -----
   Themed to match the frosted-navy chrome (.map-tool-btn) and given a uniform
   16px inset from the edges + 16px gap between the two stacked controls, so the
   bottom-right corner spaces like everything else. */
.leaflet-right .leaflet-control { margin-right: 16px; }
.leaflet-bottom .leaflet-control { margin-bottom: 16px; }

.leaflet-bar,
.leaflet-control-layers {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(39, 39, 68, 0.92);
  backdrop-filter: blur(6px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

/* Zoom +/- buttons. The size is set with a selector that also covers Leaflet's
   higher-specificity `.leaflet-touch .leaflet-bar a` rule, so the buttons don't
   resize on hover; hover changes only the colours. */
.leaflet-bar a,
.leaflet-touch .leaflet-bar a {
  width: 36px;
  height: 36px;
  line-height: 36px;
  color: var(--text);
  background: transparent;
  border-bottom: 1px solid var(--border);
  font-size: 18px;
}
.leaflet-bar a:last-child,
.leaflet-touch .leaflet-bar a:last-child { border-bottom: none; }
.leaflet-bar a:hover,
.leaflet-touch .leaflet-bar a:hover { background: var(--panel-2); color: var(--accent); }
.leaflet-bar a.leaflet-disabled,
.leaflet-touch .leaflet-bar a.leaflet-disabled { opacity: 0.4; color: var(--muted); }

/* Layer switcher: the collapsed toggle ships a dark icon — `brightness(0)
   invert(1)` forces it to pure white. Expanded, it becomes a small navy menu. */
.leaflet-control-layers-toggle {
  width: 36px;
  height: 36px;
  background-size: 20px 20px;
  filter: brightness(0) invert(1);
}
.leaflet-control-layers-expanded {
  padding: 10px 13px;
  color: var(--text);
  background: rgba(39, 39, 68, 0.96);
}
.leaflet-control-layers-list { font-size: 13px; }
.leaflet-control-layers label {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 3px 0;
}
.leaflet-control-layers-selector { accent-color: var(--accent); margin: 0; }
.leaflet-control-layers-separator { border-top: 1px solid var(--border); }

/* ----- Popup (legacy, no longer used but kept harmless) ----- */
.leaflet-popup-content-wrapper {
  background: var(--panel);
  color: var(--text);
  border-radius: 12px;
  border: 1px solid var(--border);
}
.leaflet-popup-tip { background: var(--panel); }
.leaflet-popup-content { margin: 12px 14px; min-width: 200px; }
.popup h3 { margin: 0 0 4px; font-size: 16px; }
.popup .meta { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.popup .badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink);
}
.popup p.desc { font-size: 13px; line-height: 1.45; margin: 8px 0; white-space: pre-wrap; }
.popup .popup-actions { display: flex; gap: 8px; margin-top: 8px; }
.popup .popup-actions button { padding: 6px 12px; font-size: 13px; }
.popup .edit-btn { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); }
.popup .delete-btn { background: var(--danger); color: #fff; }
