/* ── Reset & base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sidebar-w: 300px;
  --radius-lg: 12px;
  --radius:     8px;
  --radius-sm:  6px;
  --t: .15s ease;
}

/* ── Dark theme (default) ──────────────────────────────── */
:root, [data-theme="dark"] {
  --bg-base:     #0b1119;
  --bg-surface:  #0e1621;
  --bg-elevated: #162030;
  --bg-input:    #111928;
  --border:      rgba(255,255,255,.07);
  --border-md:   rgba(255,255,255,.13);
  --border-str:  rgba(255,255,255,.26);

  --text-primary:   #dce9f7;
  --text-secondary: #8daac7;
  --text-muted:     #506070;

  --accent:        #4d8cf5;
  --accent-hover:  #3a7cec;
  --accent-subtle: rgba(77,140,245,.13);

  --from-color: #34d399;
  --to-color:   #fbbf24;
  --danger:     #f87171;

  --shadow:    0 4px 24px rgba(0,0,0,.5);
  --shadow-lg: 0 12px 48px rgba(0,0,0,.6);

  --info-bg:        #162030;
  --info-surface:   rgba(255,255,255,.06);
  --info-surface-h: rgba(255,255,255,.10);
  --info-text:      #dce9f7;
  --info-secondary: #8daac7;
  --info-muted:     #506070;
  --info-border:    rgba(255,255,255,.08);

  --overlay-bg:           rgba(11,17,25,.92);
  --overlay-subtle:       rgba(255,255,255,.10);
  --overlay-subtle-hover: rgba(255,255,255,.18);
}

/* ── Light theme ───────────────────────────────────────── */
[data-theme="light"] {
  --bg-base:     #f0f4f8;
  --bg-surface:  #ffffff;
  --bg-elevated: #f8fafc;
  --bg-input:    #f1f5f9;
  --border:      rgba(0,0,0,.07);
  --border-md:   rgba(0,0,0,.13);
  --border-str:  rgba(0,0,0,.22);

  --text-primary:   #0f172a;
  --text-secondary: #475569;
  --text-muted:     #94a3b8;

  --accent:        #1d4ed8;
  --accent-hover:  #1e40af;
  --accent-subtle: rgba(29,78,216,.09);

  --from-color: #16a34a;
  --to-color:   #d97706;
  --danger:     #dc2626;

  --shadow:    0 4px 24px rgba(0,0,0,.10);
  --shadow-lg: 0 12px 48px rgba(0,0,0,.15);

  --info-bg:        #ffffff;
  --info-surface:   #f1f5f9;
  --info-surface-h: #e2e8f0;
  --info-text:      #0f172a;
  --info-secondary: #475569;
  --info-muted:     #94a3b8;
  --info-border:    #e2e8f0;

  --overlay-bg:           rgba(255,255,255,.92);
  --overlay-subtle:       rgba(0,0,0,.07);
  --overlay-subtle-hover: rgba(0,0,0,.13);
}

html {
  color-scheme: dark light;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg-base);
  color: var(--text-primary);
}

/* ── App layout ───────────────────────────────────────── */
#app {
  display: flex;
  height: 100vh;
  height: 100dvh; /* excluye barra del navegador en iOS Safari */
  overflow: hidden;
}

/* ── Sidebar ──────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--border);
}

/* ── Header ───────────────────────────────────────────── */
#sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 13px 13px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 8px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.header-icon {
  font-size: 28px;
  line-height: 1;
  flex-shrink: 0;
}

.header-text { min-width: 0; }

#sidebar-header h1 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#sidebar-header p {
  font-size: 10px;
  color: var(--text-secondary);
  margin-top: 2px;
  letter-spacing: .04em;
}

#sidebar-header-btns {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

#theme-toggle, #sidebar-close {
  background: var(--bg-elevated);
  border: 1px solid var(--border-md);
  color: var(--text-secondary);
  width: 32px; height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px;
  transition: all var(--t);
  flex-shrink: 0;
}
#theme-toggle:hover {
  background: var(--accent-subtle);
  color: var(--accent);
  border-color: rgba(77,140,245,.4);
}

/* ── Locate button (en el mapa, sobre layer-toggle) ───── */
#locate-btn {
  position: absolute;
  bottom: 76px; right: 10px;
  z-index: 900;
  background: var(--overlay-bg);
  border: 1px solid var(--border-md);
  color: var(--text-secondary);
  width: 36px; height: 36px;
  border-radius: 8px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  box-shadow: var(--shadow);
  transition: border-color var(--t), color var(--t);
}
#locate-btn:hover { border-color: var(--border-str); color: var(--accent); }
#sidebar-close { display: none; }
#sidebar-close:hover {
  background: rgba(248,113,113,.1);
  color: var(--danger);
  border-color: rgba(248,113,113,.4);
}

/* ── Tabs ─────────────────────────────────────────────── */
#tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.tab {
  flex: 1;
  padding: 11px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  letter-spacing: .06em;
  text-transform: uppercase;
  transition: color var(--t), border-color var(--t);
}
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab:hover:not(.active) { color: var(--text-secondary); }

.tab-content { display: none; flex: 1; flex-direction: column; overflow: hidden; }
.tab-content.active { display: flex; }

/* ── Search ───────────────────────────────────────────── */
#search-wrap {
  position: relative;
  padding: 12px 12px 8px;
  flex-shrink: 0;
}

#search {
  width: 100%;
  padding: 9px 32px 9px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-md);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: border-color var(--t), box-shadow var(--t);
}
#search::placeholder { color: var(--text-muted); }
#search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

#search-clear {
  position: absolute;
  right: 20px; top: 50%; transform: translateY(-50%);
  background: none; border: none;
  color: var(--text-muted); font-size: 16px; cursor: pointer; line-height: 1;
  display: none;
  transition: color var(--t);
}
#search-clear:hover { color: var(--text-primary); }
#search-clear.visible { display: block; }

/* ── Filters ──────────────────────────────────────────── */
#filters {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 0 12px 10px;
  flex-shrink: 0;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px 3px 8px;
  border-radius: 20px;
  border: 1px solid var(--border-md);
  background: transparent;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t);
  white-space: nowrap;
  letter-spacing: .02em;
}
/* Colored dot indicator for each category */
.filter-chip::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--chip-color, transparent);
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity var(--t);
}
.filter-chip[data-filter="all"] { padding: 3px 10px; }
.filter-chip[data-filter="all"]::before { display: none; }

.filter-chip:hover {
  border-color: var(--chip-color, var(--accent));
  color: var(--text-primary);
  background: rgba(255,255,255,.04);
}
.filter-chip:hover::before { opacity: 1; }

.filter-chip.active {
  border-color: var(--chip-color, var(--accent));
  color: var(--text-primary);
  background: rgba(255,255,255,.06);
  font-weight: 700;
}
.filter-chip.active::before { opacity: 1; }

.filter-chip[data-filter="all"].active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ── Building list ────────────────────────────────────── */
#building-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  padding-bottom: 8px;
}

.building-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  cursor: pointer;
  border-left: 3px solid transparent;
  border-top: 1px solid var(--border);
  transition: background var(--t), border-color var(--t);
}
.building-item:first-child { border-top: none; }
.building-item:hover {
  background: var(--bg-elevated);
  border-left-color: var(--item-color, var(--border-str));
}
.building-item.active {
  background: var(--bg-elevated);
  border-left-color: var(--item-color, var(--accent));
}

.building-icon {
  font-size: 14px;
  width: 30px; height: 30px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.06);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background var(--t), border-color var(--t);
}
.building-item:hover .building-icon,
.building-item.active .building-icon {
  background: rgba(255,255,255,.1);
  border-color: var(--item-color, var(--border-md));
}

.building-item-text { min-width: 0; }
.building-item-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.building-item-sub {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 1px;
}

/* ── Encabezado de categoría en la lista ──────────────────── */
.cat-header {
  position: sticky; top: 0; z-index: 1;
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em;
  padding: 11px 14px 4px;
}

/* ── Etiquetas de edificio sobre el mapa (según el zoom) ───── */
.leaflet-tooltip.building-label {
  background: none; border: none; box-shadow: none; padding: 0;
  color: #fff;
  font: 600 11px/1.1 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  text-shadow: 0 0 3px #000, 0 0 3px #000, 0 1px 4px #000;
  white-space: nowrap; pointer-events: none;
}
.leaflet-tooltip.building-label::before { display: none; }   /* sin flecha */
.building-label.minor { display: none; }
#map.labels-all .building-label.minor { display: block; }
#map.labels-off .building-label { display: none; }

.list-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
}

/* ── Sidebar footer ───────────────────────────────────── */
#sidebar-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  padding: 8px 12px;
}
#disclaimer {
  font-size: 10px;
  color: var(--text-primary);
  font-weight: 600;
  line-height: 1.4;
  margin: 0 0 6px;
}

#privacy-link {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  padding: 4px 2px;
  transition: color var(--t);
  letter-spacing: .01em;
}
#privacy-link:hover { color: var(--accent); }

/* ── Nav bar (bottom, estilo Waze) ───────────────────── */
#nav-bar {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--info-bg);
  border: 1px solid var(--info-border);
  border-radius: 40px;
  padding: 10px 16px 10px 20px;
  box-shadow: 0 4px 20px rgba(0,0,0,.35);
  transition: opacity var(--t);
  white-space: nowrap;
}
#nav-bar.hidden { display: none; }

.nav-stats { display: flex; align-items: center; gap: 10px; }
.nav-stat   { display: flex; align-items: baseline; gap: 4px; }
.nav-val    { font-size: 22px; font-weight: 700; color: var(--text-primary); }
.nav-lbl    { font-size: 12px; color: var(--text-secondary); }
.nav-divider { width: 1px; height: 28px; background: var(--info-border); }

#nav-cancel {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--overlay-subtle);
  color: var(--text-secondary);
  font-size: 16px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--t), color var(--t);
}
#nav-cancel:hover { background: #ef4444; color: #fff; }

/* ── Route panel ──────────────────────────────────────── */
#route-panel {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}

.route-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-md);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.route-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
}

.route-swap-row {
  position: relative;
  display: flex;
  align-items: center;
  margin: 0 14px;
}
.route-swap-line {
  flex: 1;
  height: 1px;
  background: var(--border);
}
.route-swap {
  position: absolute;
  right: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-md);
  color: var(--text-secondary);
  width: 28px; height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  transition: all var(--t);
  flex-shrink: 0;
}
.route-swap:hover {
  background: var(--accent-subtle);
  color: var(--accent);
  border-color: rgba(77,140,245,.4);
}

.route-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.route-dot.from { background: var(--from-color); box-shadow: 0 0 0 3px rgba(52,211,153,.15); }
.route-dot.to   { background: var(--to-color);   box-shadow: 0 0 0 3px rgba(251,191,36,.15); }

.route-field { flex: 1; min-width: 0; }
.route-field label {
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .09em;
  font-weight: 700;
}
.route-name {
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.route-name.placeholder { color: var(--text-muted); font-weight: 400; font-style: italic; }

.route-clear {
  background: none; border: none;
  color: var(--text-muted); font-size: 16px; cursor: pointer;
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  transition: color var(--t), background var(--t);
  flex-shrink: 0;
}
.route-clear:hover { color: var(--danger); background: rgba(248,113,113,.1); }

#route-summary {
  background: var(--bg-elevated);
  border: 1px solid var(--border-md);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: none;
}
#route-summary.visible { display: block; }

.route-stat { display: flex; justify-content: space-between; align-items: center; }
.route-stat + .route-stat {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.route-stat-label {
  font-size: 10px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 600;
}
.route-stat-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

#route-hint {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.6;
  text-align: center;
  padding: 4px 0 2px;
}
#route-hint.hidden { display: none; }

#route-mode-btn {
  padding: 11px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--t), transform var(--t);
  letter-spacing: .01em;
}
#route-mode-btn:hover { background: var(--accent-hover); }
#route-mode-btn:active { transform: scale(.98); }
#route-mode-btn.active { background: var(--danger); }

/* ── Map wrap ─────────────────────────────────────────── */
#map-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
}
#map { width: 100%; height: 100%; }

/* ── Info panel (floating) ────────────────────────────── */
#info-panel {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  width: min(460px, calc(100% - 32px));
  background: var(--info-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 20px 20px 16px;
  z-index: 900;
  transition: opacity .2s ease, transform .2s ease;
}
#info-panel.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(10px);
}

#info-close {
  position: absolute;
  top: 14px; right: 14px;
  background: var(--info-surface);
  border: none;
  font-size: 15px;
  width: 28px; height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--info-secondary);
  transition: background var(--t), color var(--t);
}
#info-close:hover { background: var(--info-surface-h); color: var(--info-text); }

#info-category {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 3px 10px;
  border-radius: 20px;
  margin-bottom: 8px;
}

#info-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--info-text);
  margin-bottom: 12px;
  padding-right: 36px;
  line-height: 1.25;
  letter-spacing: -.02em;
}

#info-fields {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--info-border);
}
#info-fields:empty { display: none; }

.info-field {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
  color: var(--info-secondary);
}
.info-field-label {
  font-size: 10px;
  color: var(--info-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  min-width: 62px;
  flex-shrink: 0;
}
.info-field a { color: var(--accent); text-decoration: none; }
.info-field a:hover { text-decoration: underline; }

#info-actions { display: flex; flex-direction: column; gap: 7px; }

.action-btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: .01em;
  transition: filter var(--t), transform var(--t);
}
.action-btn:active { transform: scale(.98); }

.directions-btn {
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.directions-btn:hover { filter: brightness(1.08); }

.from-btn {
  background: transparent;
  color: var(--info-secondary);
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--info-border);
  padding: 9px;
}
.from-btn:hover { background: var(--info-surface); color: var(--info-text); filter: none; }

/* ── Route mode badge ─────────────────────────────────── */
#route-mode-badge {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--overlay-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 500;
  padding: 9px 18px;
  border-radius: 24px;
  border: 1px solid var(--border-md);
  box-shadow: var(--shadow);
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 14px;
  white-space: nowrap;
}
#route-mode-badge.hidden { display: none; }

#cancel-route-mode {
  background: var(--overlay-subtle);
  border: 1px solid var(--border-str);
  color: var(--text-primary);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  cursor: pointer;
  transition: background var(--t);
}
#cancel-route-mode:hover { background: var(--overlay-subtle-hover); }

/* ── Mobile menu button ───────────────────────────────── */
#menu-btn {
  display: none;
  position: absolute;
  top: 12px; left: 12px;
  z-index: 970;
  background: var(--overlay-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text-primary);
  border: 1px solid var(--border-md);
  border-radius: var(--radius);
  width: 40px; height: 40px;
  font-size: 17px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
}

/* ── Sidebar overlay ──────────────────────────────────── */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 950;
}
#sidebar-overlay.visible { display: block; }

/* ── Layer toggle ─────────────────────────────────────── */
#layer-toggle {
  position: absolute;
  bottom: 32px; right: 10px;
  z-index: 900;
  background: var(--overlay-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text-primary);
  border: 1px solid var(--border-md);
  border-radius: var(--radius);
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: border-color var(--t);
  letter-spacing: .03em;
}
#layer-toggle:hover { border-color: var(--border-str); }

/* Elevar botones cuando el nav bar está activo (desktop) */
#map-wrap.nav-active #layer-toggle { bottom: 90px; }
#map-wrap.nav-active #locate-btn   { bottom: 134px; }

/* El SVG del circlePane cubre todo el mapa; debe pasar eventos al overlayPane
   excepto en los paths de circles interactivos */
.leaflet-circle-pane svg { pointer-events: none; }
.leaflet-circle-pane svg .leaflet-interactive { pointer-events: visiblePainted; }

/* ── Selection pin ────────────────────────────────────── */
.selection-pin {
  width: 34px; height: 34px;
  background: var(--info-bg);
  border: 2.5px solid;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  box-shadow: 0 2px 10px rgba(0,0,0,.45);
  user-select: none;
  pointer-events: none;
}

/* ── User sheep marker ────────────────────────────────── */
.user-location-marker {
  width: 44px; height: 44px;
  position: relative;
  display: flex; align-items: center; justify-content: center;
}

/* Halo de pulso exterior */
.user-location-marker::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(59, 130, 246, 0.2);
  animation: location-pulse 2s ease-out infinite;
}

/* Círculo base azul */
.user-location-marker::after {
  content: '';
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: rgba(59, 130, 246, 0.18);
  border: 2px solid rgba(59, 130, 246, 0.6);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12),
              0 2px 8px rgba(0, 0, 0, 0.25);
}

.user-sheep {
  font-size: 22px;
  line-height: 1;
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,.4));
  animation: sheep-bounce .7s ease-in-out infinite alternate;
}

@keyframes sheep-bounce {
  from { transform: translateY(0); }
  to   { transform: translateY(-2px); }
}

@keyframes location-pulse {
  0%   { transform: scale(0.8); opacity: 0.8; }
  70%  { transform: scale(1.4); opacity: 0; }
  100% { transform: scale(1.4); opacity: 0; }
}

/* ── Scrollbars ───────────────────────────────────────── */
* { scrollbar-width: thin; scrollbar-color: var(--bg-elevated) transparent; }
#building-list::-webkit-scrollbar { width: 3px; }
#building-list::-webkit-scrollbar-track { background: transparent; }
#building-list::-webkit-scrollbar-thumb { background: var(--bg-elevated); border-radius: 2px; }

/* ── Leaflet zoom control ─────────────────────────────── */
.leaflet-control-zoom {
  border: 1px solid var(--border-md) !important;
  border-radius: var(--radius) !important;
  overflow: hidden;
  box-shadow: var(--shadow) !important;
}
.leaflet-control-zoom a {
  background: var(--overlay-bg) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text-primary) !important;
  border-bottom: 1px solid var(--border) !important;
  width: 34px !important;
  height: 34px !important;
  line-height: 34px !important;
  font-size: 16px !important;
  transition: background var(--t), color var(--t);
}
.leaflet-control-zoom a:last-child { border-bottom: none !important; }
.leaflet-control-zoom a:hover {
  background: var(--accent-subtle) !important;
  color: var(--accent) !important;
}
.leaflet-control-zoom a.leaflet-disabled {
  color: var(--text-muted) !important;
  cursor: default;
}

/* ── Privacy modal ────────────────────────────────────── */
#privacy-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
#privacy-modal.hidden { display: none; }

#privacy-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

#privacy-dialog {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border-md);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: min(480px, 100%);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#privacy-header {
  padding: 24px 24px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  text-align: center;
}
.privacy-icon { font-size: 32px; margin-bottom: 8px; }
#privacy-header h2 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.01em;
}
#privacy-header p {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 3px;
}

#privacy-body {
  padding: 16px 24px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.privacy-disclaimer {
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--overlay-subtle);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  padding: 8px 10px;
  margin: 0 0 12px;
  line-height: 1.5;
}

.privacy-intro {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.privacy-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}
.privacy-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
}
.privacy-item strong { color: var(--text-primary); }
.privacy-item a { color: var(--accent); text-decoration: none; }
.privacy-item a:hover { text-decoration: underline; }

.privacy-law {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.6;
  text-align: center;
}

#privacy-actions {
  display: flex;
  gap: 8px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
#privacy-reject {
  flex: 1;
  padding: 11px;
  background: transparent;
  border: 1px solid var(--border-md);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--t), color var(--t);
}
#privacy-reject:hover { background: var(--bg-elevated); color: var(--text-primary); }

#privacy-accept {
  flex: 2;
  padding: 11px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: filter var(--t);
}
#privacy-accept:hover { filter: brightness(1.08); }

#privacy-close {
  display: none;
  width: 100%;
  padding: 11px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-md);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--t);
}
#privacy-close:hover { background: var(--border); }

#privacy-modal[data-mode="view"] #privacy-reject,
#privacy-modal[data-mode="view"] #privacy-accept { display: none; }
#privacy-modal[data-mode="view"] #privacy-close  { display: block; }

/* ── Mobile ───────────────────────────────────────────── */
@media (max-width: 640px) {
  #sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 960;
    transform: translateX(-100%);
    transition: transform .25s ease;
    width: min(300px, 88vw);
    min-width: unset;
  }
  #sidebar.open { transform: translateX(0); }

  #menu-btn     { display: flex; }
  #sidebar-close { display: flex; }

  #info-panel {
    bottom: 8px; left: 8px; right: 8px;
    width: auto;
    transform: none;
    border-radius: 16px;
    overflow: hidden;
    padding: 14px 14px max(14px, env(safe-area-inset-bottom));
  }
  #info-panel.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(12px);
  }
  #info-fields { display: none; }
  #info-name   { font-size: 16px; margin: 4px 0 10px; }
  #info-actions {
    flex-direction: row;
    margin-top: 0;
  }
  .directions-btn { flex: 2; }
  .from-btn       { flex: 1; font-size: 12px; padding: 10px 8px; }

  #route-mode-badge {
    top: auto;
    bottom: 16px;
    left: 16px; right: 16px;
    transform: none;
    justify-content: space-between;
  }

  #layer-toggle { bottom: 76px; }
  #locate-btn   { bottom: 120px; }

  /* Elevar botones cuando nav bar está activo (mobile — sobreescribe los de arriba) */
  #map-wrap.nav-active #layer-toggle { bottom: 170px; }
  #map-wrap.nav-active #locate-btn   { bottom: 214px; }

  .action-btn { padding: 13px 8px; font-size: 13px; }
  .tab { padding: 12px; }
  #search { font-size: 16px; }
}
