/* ═══════════════════════════════════════════════════
   BetterRoads — Main Styles (Light Theme)
   ═══════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Syne:wght@700;800&family=DM+Sans:wght@300;400;500;600&display=swap');

:root {
  --bg:      #f8f9fb;
  --bg2:     #ffffff;
  --bg3:     #f1f3f7;
  --border:  #e2e6ed;
  --border2: #d0d5de;
  --text:    #0f1117;
  --muted:   #6b7280;
  --muted2:  #9ca3af;
  --road:    #ef4444;
  --mark:    #3b82f6;
  --trash:   #f59e0b;
  --green:   #22c55e;
  --orange:  #f97316;
  --card:    #ffffff;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; font-family: 'DM Sans', sans-serif; background: var(--bg); color: var(--text); }

/* ── Map ── */
#map { position: fixed; top: calc(var(--announce-h, 0px) + 90px); left: 0; right: 0; bottom: 0; z-index: 0; }
.leaflet-container { background: #e8eaed !important; }

/* ── Announce Bar ── */
#announce-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  background: var(--orange);
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  padding: 5px 32px 5px 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  z-index: 1100;
  line-height: 1.4;
}
#announce-bar a { color: #fff; text-decoration: underline; }
#announce-bar a:hover { opacity: 0.85; }
.announce-sep { opacity: 0.55; }
#announce-close {
  position: absolute;
  right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: #fff;
  font-size: 13px; cursor: pointer; opacity: 0.8; padding: 2px 4px;
  line-height: 1;
}
#announce-close:hover { opacity: 1; }

/* ── Header ── */
#header {
  position: fixed;
  top: var(--announce-h, 0px); left: 0; right: 0;
  height: 90px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 0;
  gap: 0;
  z-index: 1000;
  overflow: visible;
}
.logo-text { font-family: 'Syne', sans-serif; font-weight: 800; font-size: 18px; letter-spacing: -0.5px; color: var(--text); }
.header-spacer { flex: 1; }
.header-btn {
  padding: 6px 12px;
  border-radius: 18px;
  border: 1px solid var(--border2);
  background: var(--bg3);
  color: var(--muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all 0.15s;
}
.header-btn:hover { color: var(--text); border-color: var(--muted); }

.btn-report {
  padding: 8px 16px;
  border-radius: 20px;
  border: none;
  background: linear-gradient(135deg, #ef4444, #f97316);
  color: white;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 2px 10px #ef444430;
  flex-shrink: 0;
  transition: all 0.15s;
}
.btn-report:hover { transform: translateY(-1px); box-shadow: 0 4px 14px #ef444445; }

/* ── Filter Bar ── */
#filter-bar {
  display: none;
  position: fixed;
  top: calc(var(--announce-h, 0px) + 50px); left: 0; right: 0;
  height: 40px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 10px;
  gap: 6px;
  overflow-x: auto;
  z-index: 500;
  -webkit-overflow-scrolling: touch;
}
#filter-bar::-webkit-scrollbar { display: none; }
.filter-chip {
  display: flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 14px;
  border: 1px solid var(--border); background: transparent;
  color: var(--muted); font-family: 'DM Sans', sans-serif;
  font-size: 11px; white-space: nowrap; cursor: pointer;
  transition: all 0.15s; flex-shrink: 0;
}
.filter-chip.active { background: var(--bg3); border-color: var(--border2); color: var(--text); font-weight: 600; }
.filter-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.filter-count { background: var(--bg3); border-radius: 8px; padding: 0 5px; font-size: 10px; color: var(--muted); }
.filter-chip.active .filter-count { background: var(--border2); color: var(--muted2); }

/* ── Search Row ── */
#search-row {
  position: fixed;
  top: calc(var(--announce-h, 0px) + 90px); left: 0; right: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 52px;
  z-index: 900;
}
.search-side-btn {
  width: 40px; height: 40px;
  background: rgba(255,255,255,0.97);
  border: 1px solid var(--border2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 18px; flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  transition: all 0.15s;
}
.search-side-btn:hover { background: var(--bg3); transform: scale(1.05); }

/* Override btn-report when used as side button */
button.search-side-btn.btn-report {
  background: linear-gradient(135deg, #ef4444, #f97316);
  border: none;
  color: white;
  font-size: 22px;
  font-weight: 700;
  box-shadow: 0 2px 10px #ef444430;
}
button.search-side-btn.btn-report:hover { transform: scale(1.05); }

/* ── Search Bar ── */
#search-wrap {
  flex: 1;
  position: relative;
  min-width: 0;
}
#search-bar {
  display: flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,0.97);
  border: 1px solid var(--border2);
  border-radius: 24px;
  padding: 7px 10px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
#search-input {
  flex: 1; background: transparent; border: none;
  color: var(--text); font-family: 'DM Sans', sans-serif;
  font-size: 13px; outline: none; min-width: 0;
}
#search-input::placeholder { color: var(--muted); }
#search-clear { background: none; border: none; color: var(--muted); font-size: 15px; cursor: pointer; display: none; padding: 0; line-height: 1; }
#search-clear.show { display: block; }
#search-results {
  display: none;
  background: rgba(255,255,255,0.98);
  border: 1px solid var(--border2);
  border-top: none;
  border-radius: 0 0 16px 16px;
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(0,0,0,0.1);
  margin: 0 4px;
}
#search-results.show { display: block; }
.result-item {
  padding: 9px 14px;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.result-item:last-child { border-bottom: none; }
.result-item:hover { background: var(--bg3); }
.result-icon { font-size: 13px; flex-shrink: 0; margin-top: 1px; }
.result-main { font-size: 12px; color: var(--text); line-height: 1.3; }
.result-sub { font-size: 10px; color: var(--muted); margin-top: 1px; }

/* ── Nearby Badge ── */
#nearby-badge {
  position: fixed;
  top: 140px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 899;
  display: none;
  background: rgba(255,255,255,0.95);
  border: 1px solid var(--border2);
  border-radius: 16px;
  padding: 4px 12px;
  font-size: 11px;
  color: var(--muted2);
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
#nearby-badge.show { display: block; }

/* ── Layer Picker ── */
#layer-picker {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  padding: 16px 16px 32px;
  z-index: 2000;
  animation: slideUp 0.25s ease;
  max-height: 80vh;
  overflow-y: auto;
}
#layer-picker.show { display: block; }
.layer-section-title {
  font-family: 'Syne', sans-serif;
  font-weight: 700; font-size: 14px;
  margin-bottom: 12px;
  color: var(--text);
}
.layer-options {
  display: flex; gap: 12px; justify-content: center;
  margin-bottom: 4px;
}
.layer-option {
  display: flex; flex-direction: column;
  align-items: center; gap: 6px;
  cursor: pointer; flex: 1; max-width: 90px;
}
.layer-thumb {
  width: 70px; height: 70px;
  border-radius: 12px; border: 2px solid var(--border2);
  background: var(--bg3);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; transition: all 0.15s;
}
.layer-option.active .layer-thumb { border-color: var(--road); box-shadow: 0 0 10px #ef444430; }
.layer-name { font-size: 12px; color: var(--muted); font-weight: 500; }
.layer-option.active .layer-name { color: var(--road); font-weight: 700; }

.layer-divider { height: 1px; background: var(--border); margin: 14px 0; }

/* Filters inside layer picker */
.picker-filters {
  display: flex; flex-direction: column; gap: 6px;
  margin-bottom: 4px;
}
.picker-filter {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--muted); font-family: 'DM Sans', sans-serif;
  font-size: 13px; cursor: pointer; transition: all 0.15s;
  text-align: left;
}
.picker-filter:hover { border-color: var(--border2); color: var(--text); }
.picker-filter.active { border-color: var(--border2); color: var(--text); font-weight: 600; background: white; }
.pf-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.pf-count {
  margin-left: auto;
  background: var(--bg3); border-radius: 10px;
  padding: 1px 8px; font-size: 11px; color: var(--muted);
}
.picker-filter.active .pf-count { background: var(--border); color: var(--text); }

.layer-close {
  margin-top: 14px; width: 100%; padding: 11px;
  background: var(--bg3); border: 1px solid var(--border2);
  border-radius: 10px; color: var(--muted);
  font-family: 'DM Sans', sans-serif; font-size: 13px; cursor: pointer;
  transition: all 0.15s;
}
.layer-close:hover { color: var(--text); }

/* ── Search Results Dropdown ── */
#search-results {
  display: none;
  position: absolute;
  top: 100%; left: 0; right: 0;
  background: rgba(255,255,255,0.98);
  border: 1px solid var(--border2);
  border-top: none;
  border-radius: 0 0 16px 16px;
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(0,0,0,0.12);
  z-index: 901;
}
#search-results.show { display: block; }
.result-item {
  padding: 9px 14px; cursor: pointer;
  display: flex; align-items: flex-start; gap: 8px;
  border-bottom: 1px solid var(--border); transition: background 0.1s;
}
.result-item:last-child { border-bottom: none; }
.result-item:hover { background: var(--bg3); }
.result-icon { font-size: 13px; flex-shrink: 0; margin-top: 1px; }
.result-main { font-size: 12px; color: var(--text); line-height: 1.3; }
.result-sub { font-size: 10px; color: var(--muted); margin-top: 1px; }

/* ── Right Map Controls ── */
#map-controls {
  position: fixed;
  right: 12px;
  top: calc(var(--announce-h, 0px) + 150px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 800;
}
.map-ctrl-btn {
  width: 46px; height: 46px;
  background: rgba(255,255,255,0.95);
  border: 1px solid var(--border2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 20px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.15);
  transition: all 0.15s;
  position: relative; z-index: 850;
}
.map-ctrl-btn:hover { background: var(--bg3); transform: scale(1.05); }
.map-ctrl-btn:active { transform: scale(0.95); }
.map-ctrl-btn.active { background: #fff0ee; border-color: var(--road); box-shadow: 0 0 10px #ef444430; }

/* Leaflet zoom control — same round style, right below map controls */
.leaflet-top.leaflet-right {
  top: 270px !important;
  right: 12px !important;
  top: calc(var(--announce-h, 0px) + 160px) !important;
}
.leaflet-control-zoom {
  border: 1px solid var(--border2) !important;
  box-shadow: 0 2px 10px rgba(0,0,0,0.15) !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 0 !important;
  margin: 0 !important;
  border-radius: 10px !important;
  overflow: hidden !important;
  z-index: 850 !important;
}
.leaflet-control-zoom-in,
.leaflet-control-zoom-out {
  width: 46px !important;
  height: 46px !important;
  border-radius: 0 !important;
  border: none !important;
  border-bottom: 1px solid var(--border2) !important;
  background: rgba(255,255,255,0.95) !important;
  color: var(--text) !important;
  font-size: 20px !important;
  font-weight: 400 !important;
  line-height: 46px !important;
  text-align: center !important;
  text-decoration: none !important;
  display: block !important;
  box-shadow: none !important;
  transition: background 0.15s !important;
  margin-bottom: 0 !important;
}
.leaflet-control-zoom-out {
  border-bottom: none !important;
}
.leaflet-control-zoom-in:hover,
.leaflet-control-zoom-out:hover {
  background: var(--bg3) !important;
}

@media (min-width: 768px) {
  #map-controls { right: 20px; top: 155px; gap: 12px; }
  .map-ctrl-btn { width: 54px; height: 54px; font-size: 24px; }
  .leaflet-top.leaflet-right { top: 295px !important; right: 20px !important; }
  .leaflet-control-zoom-in,
  .leaflet-control-zoom-out { width: 54px !important; height: 54px !important; line-height: 52px !important; }
}

/* ═══════════════════════════════════════
   DESKTOP FILTER PANEL (left side)
   Shown only on screens ≥ 960px
═══════════════════════════════════════ */
#filter-panel {
  display: none; /* hidden by default, shown on desktop */
  position: fixed;
  left: 12px;
  top: 145px;
  width: 200px;
  background: rgba(255,255,255,0.97);
  border: 1px solid var(--border2);
  border-radius: 14px;
  padding: 12px 10px;
  z-index: 800;
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
}
.fp-title {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 600;
  padding: 0 6px;
  margin-bottom: 8px;
}
.fp-list { display: flex; flex-direction: column; gap: 2px; }
.fp-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 8px;
  border-radius: 9px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
  width: 100%;
}
.fp-item:hover { background: var(--bg3); color: var(--text); }
.fp-item.active { background: var(--bg3); color: var(--text); font-weight: 600; }
.fp-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.fp-label { flex: 1; line-height: 1.3; }
.fp-count {
  font-size: 11px;
  color: var(--muted);
  background: var(--bg3);
  border-radius: 10px;
  padding: 1px 7px;
  flex-shrink: 0;
}
.fp-item.active .fp-count { background: var(--border2); color: var(--text); }

/* Advanced filter */
#fp-advanced-btn { transition: all 0.15s; }
#fp-advanced-btn.active { background: var(--text); color: white; border-color: var(--text); }
#fml-adv-btn { transition: all 0.15s; }
.fp-adv-lbl {
  font-size: 9px; font-weight: 700; letter-spacing: 0.8px;
  text-transform: uppercase; color: var(--muted);
  margin-bottom: 6px;
}
.fp-sub-row { display: flex; flex-wrap: wrap; gap: 4px; }
.fp-sub-chip {
  padding: 2px 8px; border-radius: 20px; font-size: 10px; font-weight: 500;
  border: 1px solid var(--border2); background: transparent;
  color: var(--muted2); cursor: pointer;
  font-family: 'DM Sans', sans-serif; transition: all 0.12s;
}
.fp-sub-chip.active { font-weight: 600; }
.fp-star-btn {
  width: 26px; height: 26px; border-radius: 6px;
  border: 1px solid var(--border2); background: transparent;
  font-size: 12px; cursor: pointer; transition: all 0.12s;
}
.fp-star-btn.active { background: #fef3c7; border-color: #f59e0b; }
.fp-cat-block { margin-bottom: 2px; }
.fp-cat-header {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 8px 8px; border-radius: 9px;
  border: none; background: transparent;
  color: var(--muted); font-family: 'DM Sans', sans-serif;
  font-size: 13px; cursor: pointer; transition: all 0.15s; text-align: left;
}
.fp-cat-header:hover { background: var(--bg3); color: var(--text); }
.fp-cat-header.open { color: var(--text); font-weight: 600; }
.fp-cat-header.cat-selected { background: var(--bg3); color: var(--text); font-weight: 700; }
.fp-cat-header.cat-selected .fp-dot { box-shadow: 0 0 0 2px white, 0 0 0 3px currentColor; }
.fp-cat-header.cat-partial { color: var(--text); font-weight: 600; }
.fp-cat-arrow { font-size: 10px; margin-left: auto; color: var(--muted); transition: transform 0.15s; }
.fp-cat-arrow.open { transform: rotate(90deg); }

/* ═══════════════════════════════════════
   MOBILE FILTER BUTTON (<960px)
═══════════════════════════════════════ */
#filter-mobile-wrap {
  display: none;
  position: fixed;
  left: 10px;
  top: calc(var(--announce-h, 0px) + 145px);
  z-index: 1100;
}
#filter-mobile-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  background: rgba(255,255,255,0.97);
  border: 1px solid var(--border2);
  border-radius: 20px;
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  transition: all 0.15s;
  white-space: nowrap;
}
#filter-mobile-btn:hover { background: var(--bg3); }
#filter-mobile-list {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 220px;
  background: white;
  border: 1px solid var(--border2);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  animation: dropDown 0.18s ease;
}
#filter-mobile-list.show { display: block; }
@keyframes dropDown { from { opacity:0; transform:translateY(-6px); } to { opacity:1; transform:translateY(0); } }
.fml-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 14px;
  border: none;
  background: transparent;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  width: 100%;
  text-align: left;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}
.fml-item:last-child { border-bottom: none; }
.fml-item:hover { background: var(--bg3); color: var(--text); }
.fml-item.active { color: var(--text); font-weight: 700; background: #eef2ff; border-left: 3px solid #1e40af; padding-left: 11px; }
.fml-item.active[data-f="road"] { background: #fff1f1; border-left-color: #ef4444; }
.fml-item.active[data-f="markings"] { background: #eff6ff; border-left-color: #3b82f6; }
.fml-item.active[data-f="trash"] { background: #fffbeb; border-left-color: #f59e0b; }
.fml-item.active[data-f="all"] { background: #f1f5f9; border-left-color: #94a3b8; }
.fml-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.fml-count {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
  background: var(--bg3);
  border-radius: 10px;
  padding: 2px 8px;
}
.fml-item.active .fml-count { background: var(--border2); color: var(--text); }

/* Mobile advanced bottom sheet */
.fml-adv-header {
  display: flex; align-items: stretch;
  width: 100%; border: none; background: transparent;
}
/* Left: fixed width so all arrows align at same position */
.fml-cat-check {
  display: inline-flex; align-items: center; gap: 10px;
  width: 185px; flex-shrink: 0;
  padding: 12px 8px 12px 14px;
  border: none; background: transparent;
  font-family: 'DM Sans', sans-serif; font-size: 13px; font-weight: 500;
  color: var(--muted2); cursor: pointer; text-align: left;
  transition: background 0.12s;
  box-sizing: border-box;
}
.fml-cat-check:hover { background: var(--bg3); }
.fml-cat-check.checked { color: var(--text); font-weight: 700; background: var(--bg3); }
.fml-cat-check.checked .fml-dot { box-shadow: 0 0 0 2px white, 0 0 0 3.5px currentColor; }
.fml-cat-label { white-space: nowrap; }
/* Right: arrow takes all remaining space, arrow icon on the left of that space */
.fml-cat-toggle {
  flex: 0 0 64px; width: 64px;
  border: none; border-left: 1px solid var(--border);
  background: transparent; cursor: pointer;
  font-size: 14px; color: var(--muted);
  display: flex; align-items: center; justify-content: center; gap: 5px;
  padding: 0;
  transition: all 0.15s;
}
.fml-cat-toggle:hover { background: var(--bg3); color: var(--text); }
.fml-cat-toggle.open { color: var(--text); }
.fml-cat-toggle.open::before { content: '▾'; font-size: 14px; }
.fml-cat-toggle:not(.open)::before { content: '▸'; font-size: 20px; }
.fml-adv-badge {
  font-size: 10px; font-weight: 600; border-radius: 10px;
  padding: 1px 7px; margin-left: 4px; flex-shrink: 0;
}
#fml-adv-panel {
  width: calc(100vw - 80px);
  max-width: 320px;
}
.fml-adv-cat { width: 100%; }
.fml-adv-cat > div[id^="fml-adv-body"] { width: 100%; box-sizing: border-box; }

/* ═══════════════════════════════════════
   RESPONSIVE BREAKPOINT — 960px
═══════════════════════════════════════ */
@media (min-width: 960px) {
  /* Show desktop filter panel */
  #filter-panel { display: block; }
  /* Hide mobile filter button */
  #filter-mobile-wrap { display: none; }
  /* Hide old filter chips bar content (bar stays for spacing) */
  #filter-bar .filter-chip { display: none; }
}

@media (max-width: 959px) {
  /* Hide desktop filter panel */
  #filter-panel { display: none; }
  /* Show mobile filter button */
  #filter-mobile-wrap { display: block; }
  /* Hide old filter chips on mobile too */
  #filter-bar .filter-chip { display: none; }
}

/* ── Legend ── */
#legend {
  position: fixed;
  bottom: 40px; right: 12px;
  background: rgba(255,255,255,0.92);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  z-index: 800;
  font-size: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.legend-title { color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; font-size: 9px; margin-bottom: 5px; }
.legend-row { display: flex; align-items: center; gap: 5px; margin-bottom: 3px; color: var(--muted2); }
.legend-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }

/* ── Pin Placement Mode — app style ── */
#pin-mode {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1500;
  pointer-events: none;
}
#pin-mode.show { display: block; }

/* Top bar — coords + cancel/next — sits BELOW header+filterbar */
#pin-topbar {
  position: absolute;
  top: calc(var(--announce-h, 0px) + 90px); left: 0; right: 0;
  height: 44px;
  background: white;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 12px;
  pointer-events: all;
  z-index: 1600;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
#pin-cancel-top {
  width: 36px; height: 36px;
  background: none; border: none;
  color: var(--muted2); font-size: 20px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
#pin-coords {
  flex: 1;
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
}
#pin-coords span { color: var(--muted); font-size: 11px; margin-right: 3px; }
#pin-next {
  background: none; border: none;
  color: #f97316;
  font-family: 'Syne', sans-serif;
  font-weight: 700; font-size: 15px;
  cursor: pointer; flex-shrink: 0;
  padding: 4px 8px;
  pointer-events: all;
}

/* Center pin — offset down to account for header+filter+topbar */
#pin-crosshair {
  position: absolute;
  top: calc(50% + 67px); left: 50%;
  transform: translate(-50%, -100%);
  pointer-events: none;
  transition: transform 0.12s;
  z-index: 1600;
}
#pin-crosshair.moving {
  transform: translate(-50%, -115%) scale(1.1);
}

/* Shadow blob under pin */
#pin-shadow {
  position: absolute;
  top: calc(50% + 67px); left: 50%;
  transform: translate(-50%, -2px);
  width: 20px; height: 8px;
  background: rgba(0,0,0,0.25);
  border-radius: 50%;
  pointer-events: none;
  transition: all 0.12s;
  z-index: 1599;
  filter: blur(3px);
}
#pin-crosshair.moving ~ #pin-shadow {
  width: 14px; height: 5px; opacity: 0.4;
  transform: translate(-50%, 4px);
}

/* Address label — above pin */
#pin-address {
  position: absolute;
  top: calc(50% + 67px - 96px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255,255,255,0.96);
  border: 1px solid var(--border2);
  border-radius: 16px;
  padding: 5px 14px;
  font-size: 12px; color: var(--text);
  white-space: nowrap;
  max-width: calc(100% - 80px);
  overflow: hidden; text-overflow: ellipsis;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  z-index: 1600;
  text-align: center;
}

/* Hint */
#pin-hint {
  position: absolute;
  bottom: 32px; left: 50%;
  transform: translateX(-50%);
  background: rgba(255,255,255,0.85);
  border: 1px solid var(--border2);
  border-radius: 16px;
  padding: 6px 16px;
  font-size: 11px; color: var(--muted2);
  white-space: nowrap;
  pointer-events: none;
  z-index: 1600;
}

/* ── Side Panel ── */
#panel {
  position: fixed;
  right: -100%;
  top: 0; bottom: 0;
  width: 100%;
  max-width: 340px;
  background: var(--bg2);
  border-left: 1px solid var(--border);
  z-index: 1200;
  display: flex;
  flex-direction: column;
  transition: right 0.25s ease;
}
#panel.open { right: 0; }
.panel-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-shrink: 0;
  padding-top: 56px;
}
.panel-close-btn {
  width: 26px; height: 26px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.panel-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.panel-scroll::-webkit-scrollbar { width: 3px; }
.panel-scroll::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }
.panel-sec { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.panel-lbl { font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 7px; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 7px; text-align: center; }
.stat-cell { background: var(--bg3); border-radius: 7px; padding: 8px 4px; }
.stat-val { font-size: 17px; font-weight: 700; }
.stat-lbl { font-size: 9px; color: var(--muted); margin-top: 2px; }
.vote-row { display: flex; flex-direction: column; gap: 6px; }
.vote-btn {
  width: 100%; padding: 8px 12px;
  border-radius: 8px; border: 1px solid;
  display: flex; justify-content: space-between; align-items: center;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif; font-size: 12px; font-weight: 500;
  transition: opacity 0.15s;
}
.vote-btn:hover { opacity: 0.85; }
.tag-row { display: flex; flex-wrap: wrap; gap: 4px; }
.tag-pill {
  background: var(--bg3); border: 1px solid var(--border2);
  border-radius: 10px; padding: 2px 8px;
  font-size: 10px; color: var(--muted2);
}
.comment-box { background: var(--bg3); border-radius: 7px; padding: 8px; margin-bottom: 5px; }
.comment-top { display: flex; justify-content: space-between; margin-bottom: 3px; }
.comment-user { font-size: 10px; color: var(--mark); font-weight: 600; }
.comment-time { font-size: 9px; color: var(--muted); }
.comment-txt { font-size: 11px; color: var(--muted2); line-height: 1.5; }
.comment-in {
  width: 100%;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px;
  color: var(--text); font-family: 'DM Sans', sans-serif; font-size: 12px;
  outline: none; box-sizing: border-box;
}
.comment-in:focus { border-color: var(--border2); }


/* ── Report Form ── */
#report-sheet {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 2000;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(4px);
}
#report-sheet.show { display: flex; }
#report-card {
  width: 100%;
  max-width: 500px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.28s ease;
}
@keyframes slideUp { from { transform: translateY(100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.report-progress { height: 3px; background: var(--border); flex-shrink: 0; border-radius: 3px 3px 0 0; }
.report-progress-fill { height: 100%; background: linear-gradient(90deg, #ef4444, #f97316); transition: width 0.3s; border-radius: 3px 3px 0 0; }
.report-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  flex-shrink: 0;
}
.report-title { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 15px; }
.report-step { font-size: 11px; color: var(--muted); margin-top: 2px; }
.report-body { padding: 16px; overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }
.report-body::-webkit-scrollbar { width: 3px; }
.report-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex; gap: 8px;
  flex-shrink: 0;
}
.form-lbl { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.7px; margin-bottom: 8px; display: block; }
.cat-card {
  width: 100%; padding: 11px 12px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 10px;
  display: flex; align-items: center; gap: 10px;
  cursor: pointer; transition: all 0.15s;
  margin-bottom: 7px;
  color: var(--muted); font-family: 'DM Sans', sans-serif; font-size: 13px;
  text-align: left;
}
.cat-card:hover { border-color: var(--border2); color: var(--text); }
.cat-card.sel { color: var(--text); font-weight: 600; }
.cat-icon { font-size: 19px; flex-shrink: 0; }
.tags-wrap { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.tag-btn {
  padding: 4px 9px; border-radius: 14px;
  border: 1px solid var(--border); background: var(--bg3);
  color: var(--muted); font-family: 'DM Sans', sans-serif; font-size: 11px;
  cursor: pointer; transition: all 0.15s;
}
.tag-btn:hover { border-color: var(--border2); color: var(--muted2); }
.tag-btn.sel { color: white; border-color: transparent; }
.stars-row { display: flex; gap: 6px; margin: 4px 0 10px; }
.star { font-size: 24px; cursor: pointer; opacity: 0.25; transition: opacity 0.1s, transform 0.1s; }
.star.lit { opacity: 1; }
.star:hover { transform: scale(1.15); }
.rating-hint { font-size: 10px; color: var(--muted); margin-bottom: 10px; margin-top: -6px; }
.desc-area {
  width: 100%; height: 78px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 8px; padding: 9px;
  color: var(--text); font-family: 'DM Sans', sans-serif; font-size: 13px;
  resize: none; outline: none; margin-bottom: 3px;
}
.desc-area:focus { border-color: var(--border2); }
.desc-counter { font-size: 10px; color: var(--muted); text-align: right; margin-bottom: 14px; }
.photo-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 7px; margin-bottom: 14px; }
.photo-slot {
  aspect-ratio: 1; border-radius: 8px;
  border: 1px dashed var(--border2); background: var(--bg3);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer; gap: 3px; position: relative; overflow: hidden;
}
.photo-slot:hover { border-color: var(--muted); }
.photo-slot-icon { font-size: 20px; color: var(--muted); }
.photo-slot-txt { font-size: 9px; color: var(--muted); }
.photo-slot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.photo-slot input { display: none; }
.link-in {
  width: 100%; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px;
  color: var(--text); font-family: 'DM Sans', sans-serif; font-size: 12px; outline: none;
}
.link-in:focus { border-color: var(--border2); }
.review-card { background: var(--bg3); border-radius: 9px; padding: 10px 12px; margin-bottom: 8px; }
.review-k { font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 5px; }
.review-v { font-size: 12px; color: var(--text); font-weight: 500; }

/* ── Auth Modal ── */
#auth-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.8);
  z-index: 3000;
  align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}
#auth-overlay.show { display: flex; }
#auth-card {
  width: calc(100% - 24px);
  max-width: 340px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  animation: popIn 0.2s ease;
}
@keyframes popIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
.auth-title { font-family: 'Syne', sans-serif; font-weight: 800; font-size: 20px; margin-bottom: 3px; }
.auth-sub { font-size: 12px; color: var(--muted); margin-bottom: 16px; }
.social-btn {
  width: 100%; padding: 10px 12px;
  border-radius: 10px; border: 1px solid var(--border2);
  background: var(--bg3); color: var(--text);
  font-family: 'DM Sans', sans-serif; font-size: 13px; font-weight: 500;
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 9px;
  margin-bottom: 8px; transition: all 0.15s;
}
.social-btn:hover { background: var(--border); }
.social-btn img { width: 17px; height: 17px; }
.divider {
  display: flex; align-items: center; gap: 8px;
  margin: 12px 0; color: var(--muted); font-size: 10px;
}
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.field { margin-bottom: 10px; }
.field-lbl { font-size: 10px; color: var(--muted); margin-bottom: 4px; display: block; }
.field-in {
  width: 100%; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px;
  color: var(--text); font-family: 'DM Sans', sans-serif; font-size: 12px; outline: none;
}
.field-in:focus { border-color: var(--border2); }
.auth-submit {
  width: 100%; padding: 10px;
  background: linear-gradient(135deg, #ef4444, #f97316);
  border: none; border-radius: 10px;
  color: white; font-family: 'DM Sans', sans-serif; font-size: 13px; font-weight: 700;
  cursor: pointer; margin-top: 4px;
}
.auth-switch { font-size: 11px; color: var(--muted); text-align: center; margin-top: 12px; }
.auth-switch a { color: var(--mark); cursor: pointer; }

.guide-imgs {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 4px;
  margin-bottom: 10px;
  border-radius: 8px;
  overflow: hidden;
}
.guide-imgs img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  display: block;
  border-radius: 3px;
}

/* ── Help Button ── */
#btn-help {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 18px;
  color: var(--muted);
}
#btn-help:hover { color: var(--text); }

/* ── Road Quality Guide Modal ── */
#guide-overlay.show { display: flex !important; }

#guide-modal {
  width: calc(100% - 24px);
  max-width: 480px;
  max-height: 85vh;
  min-height: 300px;
  background: white;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  animation: popIn 0.2s ease;
}

#guide-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

#guide-title {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 16px;
  color: var(--text);
}

#guide-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
}
#guide-body::-webkit-scrollbar { width: 3px; }
#guide-body::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

/* Guide tabs */
.guide-tab {
  flex: 1; padding: 10px 6px; border: none; background: transparent;
  font-family: 'DM Sans', sans-serif; font-size: 12px; font-weight: 500;
  color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent;
  transition: all 0.15s; display: flex; align-items: center; justify-content: center; gap: 5px;
  line-height: 1; height: 40px; vertical-align: middle;
}
.guide-tab:hover { color: var(--text); background: var(--bg2); }
.guide-tab.active { color: var(--text); font-weight: 700; border-bottom-color: var(--text); background: var(--bg2); }


  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.guide-cat-name {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 6px;
}

.guide-desc {
  font-size: 12px;
  color: var(--muted2);
  line-height: 1.6;
  margin-bottom: 6px;
}

.guide-impact {
  font-size: 11px;
  color: #ef4444;
  background: #fef2f2;
  border-radius: 6px;
  padding: 5px 8px;
  line-height: 1.5;
}

/* ── Toast ── */
#toast {
  position: fixed; bottom: 20px; left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--bg2); border: 1px solid var(--border2);
  border-radius: 10px; padding: 9px 16px;
  font-size: 12px; color: var(--text);
  z-index: 9999; transition: transform 0.3s ease;
  pointer-events: none; white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
#toast.show { transform: translateX(-50%) translateY(0); }

/* Leaflet cluster */
.marker-cluster-small, .marker-cluster-medium, .marker-cluster-large {
  background: var(--bg3) !important; border: 1px solid var(--border2) !important;
}
.marker-cluster div {
  background: var(--bg2) !important; color: var(--text) !important;
  font-family: 'DM Sans', sans-serif !important; font-weight: 600 !important; font-size: 11px !important;
}

@media (max-width: 400px) {
  #search-wrap { width: calc(100% - 80px); }
  .pin-btn { padding: 11px 20px; font-size: 14px; }
}

/* ── Photo upload status ── */
.photo-done {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(34,197,94,0.7);
  color: white; font-size: 20px; font-weight: 700;
  border-radius: 8px;
}
.photo-uploading {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.4);
  font-size: 20px;
  border-radius: 8px;
}
.photo-error {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(239,68,68,0.7);
  color: white; font-size: 20px;
  border-radius: 8px;
}
/* ── My Reports & Help Overlays ── */
#my-reports-overlay, #help-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 3000;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(4px);
}
#my-reports-overlay.show, #help-overlay.show { display: flex; }
#my-reports-card {
  width: 100%; max-width: 500px;
  background: var(--bg2);
  border-radius: 20px 20px 0 0;
  max-height: 88vh;
  display: flex; flex-direction: column;
  animation: slideUp 0.28s ease;
  overflow: hidden;
}
#help-card {
  width: 100%; max-width: 500px;
  background: var(--bg2);
  border-radius: 20px 20px 0 0;
  animation: slideUp 0.28s ease;
}
.mr-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#my-reports-body {
  overflow-y: auto;
  flex: 1;
  padding: 12px;
  -webkit-overflow-scrolling: touch;
}
.mr-loading { padding: 30px; text-align: center; color: var(--muted); font-size: 13px; }
.mr-empty { padding: 40px 20px; text-align: center; }
.mr-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 10px;
}
.mr-card-top {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 6px;
}
.mr-btn {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border2);
  background: var(--bg2);
  font-family: 'DM Sans', sans-serif;
  font-size: 12px; cursor: pointer;
  transition: all 0.15s;
}
.mr-btn:hover { background: var(--border); }
.mr-btn-delete { color: #ef4444; border-color: #ef444433; }
.mr-btn-delete:hover { background: #fef2f2; }


/* ── Edit Report Overlay ── */
#edit-report-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 3500;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(4px);
}
#edit-report-overlay.show { display: flex; }
#edit-report-card {
  width: 100%; max-width: 500px;
  background: var(--bg2);
  border-radius: 20px 20px 0 0;
  max-height: 92vh;
  display: flex; flex-direction: column;
  animation: slideUp 0.28s ease;
  overflow: hidden;
}
.edit-section {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.edit-lbl {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  margin-bottom: 10px;
  font-weight: 600;
}

/* ── Z-index fixes ── */
#auth-wrap { z-index: 6000; position: relative; }
#user-menu { z-index: 6001 !important; }
#pin-mode { z-index: 500; }

/* ── Settings Overlay ── */
#settings-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 3000;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(4px);
}
#settings-overlay.show { display: flex; }
#settings-card {
  width: 100%; max-width: 500px;
  background: var(--bg2);
  border-radius: 20px 20px 0 0;
  max-height: 88vh;
  display: flex; flex-direction: column;
  animation: slideUp 0.28s ease;
  overflow: hidden;
}

.lv-star-btn {
  font-size: 18px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px;
  opacity: 1;
  transition: opacity 0.15s;
}
.lv-star-btn:hover { opacity: 0.8; }
