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

:root {
  --bg:      #f4f6f9;
  --sb:      #ffffff;
  --border:  #dde1e7;
  --tp:      #1a1f2e;
  --ts:      #6b7280;
  --accent:  #2563eb;
  --accent-bg: rgba(37,99,235,0.08);
  --card:    #f8fafc;
  --hover:   #f1f4f8;
  --shadow:  0 2px 8px rgba(0,0,0,.10);
}

html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--tp); overflow: hidden; }

#app { display: flex; height: 100vh; }
#map { flex: 1; position: relative; }

/* ── Sidebar ── */
#sidebar {
  width: 290px; min-width: 290px;
  background: var(--sb);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow-y: auto; overflow-x: hidden;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
  z-index: 999;
  box-shadow: 2px 0 12px rgba(0,0,0,.07);
}
#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── Tour Switch (Floating top-center) ── */
#tour-switch-wrap {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  pointer-events: auto;
}
.tour-switch {
  display: flex;
  background: white;
  border-radius: 20px;
  padding: 3px;
  position: relative;
  border: 1px solid var(--border);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  min-width: 220px;
}
.tour-switch input { display: none; }
.tour-switch label {
  flex: 1;
  text-align: center;
  padding: 8px 0;
  font-size: 13px;
  font-weight: 700;
  color: #6b7280;
  cursor: pointer;
  z-index: 2;
  transition: color 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.tour-switch input:checked + label {
  color: #1e3a8a;
}
.tour-switch-slider {
  position: absolute;
  top: 3px; bottom: 3px;
  left: 3px; width: calc(50% - 3px);
  background: #f1f4f8;
  border-radius: 17px;
  z-index: 1;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid #e2e8f0;
}
#tour2:checked ~ .tour-switch-slider {
  transform: translateX(100%);
}

.sb-header {
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
  color: white;
}
.sb-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.sb-header-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}
#info-btn {
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 50%;
  color: white;
  font-size: 16px;
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
#info-btn:hover { background: rgba(255,255,255,.28); }

/* ── Modal ── */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 2000;
  padding: 20px;
}
.modal-overlay.hidden { display: none; }
.modal-content {
  background: white;
  width: 100%; max-width: 400px;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  display: flex; flex-direction: column;
  max-height: 80vh;
}
.modal-header {
  padding: 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 16px; font-weight: 700; color: var(--tp); }
.modal-header .close-btn {
  background: none; border: none; font-size: 18px; color: var(--ts); cursor: pointer;
}
.modal-body { padding: 16px; overflow-y: auto; }
.info-section { margin-bottom: 16px; }
.info-title { font-size: 14px; font-weight: 700; color: #b91c1c; margin-bottom: 8px; }
.info-desc { font-size: 13px; color: var(--ts); margin-bottom: 12px; line-height: 1.4; }
.missing-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
  gap: 6px;
}
.missing-item {
  background: #fee2e2; color: #b91c1c;
  padding: 4px; text-align: center; border-radius: 4px;
  font-size: 11px; font-weight: 600; font-family: monospace;
}

/* ── Metropolitan Gauge ── */
#metro-gauge-wrap {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  background: white;
  border-radius: 22px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: -2px 0 12px rgba(0,0,0,0.15);
  z-index: 1000;
  border: 1px solid var(--border);
}
.metro-gauge-container {
  position: relative;
  width: 100%;
  height: 240px;
}
#metro-gauge {
  width: 100%;
  height: 100%;
  background: #f1f3f5;
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column-reverse; /* Bottom to top */
  border: 1px solid #e9ecef;
}
.gauge-seg {
  width: 100%;
  transition: height 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.metro-gauge-markers {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  pointer-events: none;
}
.metro-gauge-markers .marker {
  position: absolute;
  left: -4px;
  right: -4px;
  border-top: 1px solid rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
}
.metro-gauge-markers .marker span {
  position: absolute;
  left: -18px;
  font-size: 10px;
  font-weight: 700;
  color: var(--ts);
}
.marker.m-25 { bottom: 25%; }
.marker.m-50 { bottom: 50%; border-top: 2px solid rgba(0,0,0,0.3); }
.marker.m-75 { bottom: 75%; }

.metro-gauge-footer {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  position: relative;
  width: 100%;
}
.metro-gauge-icon {
  font-size: 16px;
}
.metro-gauge-total {
  font-size: 11px;
  font-weight: 800;
  color: var(--tp);
}
#metro-legend-toggle {
  background: none; border: none; font-size: 14px; color: var(--ts); cursor: pointer;
  padding: 4px; border-radius: 4px;
}
#metro-legend-toggle:hover { background: var(--hover); }

.metro-legend {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  align-items: center;
  transition: all 0.3s;
}
.metro-legend.hidden {
  display: none;
}
.ml-item-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.ml-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.1);
}
.ml-count {
  font-size: 9px;
  font-weight: 700;
  color: var(--ts);
}

#se-info-btn {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--ts);
  font-size: 14px;
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  margin-bottom: 8px;
  transition: all 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
#se-info-btn:hover { background: #eff6ff; color: #2563eb; border-color: #bfdbfe; }

.se-modal-content {
  max-width: 650px;
}
.se-intro {
  font-size: 13px;
  color: var(--ts);
  margin-bottom: 16px;
  font-style: italic;
  line-height: 1.4;
  padding-bottom: 12px;
  border-bottom: 1px solid #f1f5f9;
}
.se-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.se-item {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 40px;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid #f1f5f9;
}
.se-name { font-size: 12px; font-weight: 700; color: var(--tp); }
.se-commune { font-size: 12px; color: var(--ts); }
.se-tendency {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
  text-align: center;
}
.se-ref {
  text-align: right;
}
.se-ref a {
  font-size: 11px;
  color: #3b82f6;
  text-decoration: none;
  font-weight: 700;
}
.se-ref a:hover { text-decoration: underline; }

/* Colors for tendencies */
.tendency-droite { background: #dbeafe; color: #1e40af; }
.tendency-centre { background: #ffedd5; color: #9a3412; }
.tendency-gauche { background: #fce7f3; color: #9d174d; }
.tendency-divers { background: #f1f5f9; color: #475569; }

#sidebar-close {
  display: none;   /* shown only on mobile via media query */
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 6px;
  color: white;
  font-size: 14px;
  line-height: 1;
  padding: 5px 8px;
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 2px;
}
#sidebar-close:hover { background: rgba(255,255,255,.28); }
.sb-title { font-size: 18px; font-weight: 800; letter-spacing: -0.3px; }
.sb-title sup { font-size: 11px; }
.sb-sub   { font-size: 12px; opacity: 0.8; margin-top: 2px; }
.sb-badge {
  display: inline-flex; align-items: center; gap: 5px;
  margin-top: 10px; padding: 3px 10px;
  background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.35);
  border-radius: 20px; font-size: 11px; color: white;
}
.sb-badge::before { content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #4ade80; }
.zoom-label {
  display: inline-flex; align-items: center; gap: 5px;
  margin-top: 5px; padding: 2px 10px;
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.25);
  border-radius: 20px; font-size: 10px; color: rgba(255,255,255,.85); letter-spacing: 0.3px;
}

.sb-meta {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px; padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.meta-card { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.meta-card .val { font-size: 17px; font-weight: 700; color: var(--tp); }
.meta-card .lbl { font-size: 10px; color: var(--ts); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px; }

/* ── Section ── */
.sb-section { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.sb-section-title {
  font-size: 10px; font-weight: 700; color: var(--ts);
  text-transform: uppercase; letter-spacing: 0.9px;
  margin-bottom: 8px;
  display: flex; align-items: center; justify-content: space-between;
}
.link-btn { background: none; border: none; color: var(--accent); font-size: 11px; cursor: pointer; padding: 1px 4px; border-radius: 3px; }
.link-btn:hover { background: var(--accent-bg); }

/* ── Search ── */
.search-row { display: flex; gap: 6px; }
.search-row input {
  flex: 1; padding: 7px 10px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 13px; background: var(--card); color: var(--tp);
  outline: none; transition: border-color 0.15s;
}
.search-row input:focus { border-color: var(--accent); }
.search-row button {
  padding: 7px 12px; background: var(--accent); color: white;
  border: none; border-radius: 8px; cursor: pointer; font-size: 14px;
  transition: background 0.15s;
}
.search-row button:hover { background: #1d4ed8; }
.search-error { font-size: 11px; color: #dc2626; margin-top: 5px; min-height: 14px; }

/* ── Arrondissement grid ── */
#arrdt-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px;
}
.arrdt-btn {
  padding: 5px 4px; background: var(--card); border: 1px solid var(--border);
  border-radius: 6px; cursor: pointer; text-align: center;
  font-size: 12px; font-weight: 600; color: var(--ts);
  transition: all 0.15s;
}
.arrdt-btn:hover { border-color: var(--accent); color: var(--accent); }
.arrdt-btn.active { background: var(--accent); border-color: var(--accent); color: white; }

/* ── Layer toggles ── */
.layer-btn {
  width: 100%; display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; margin-bottom: 4px;
  border-radius: 8px; border: 1px solid transparent;
  background: transparent; color: var(--tp);
  cursor: pointer; text-align: left;
  transition: background 0.15s, border-color 0.15s;
}
.layer-btn:hover { background: var(--hover); }
.layer-btn.active { background: var(--accent-bg); border-color: rgba(37,99,235,.2); }
.layer-icon { width: 30px; height: 30px; border-radius: 7px; display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; background: var(--card); border: 1px solid var(--border); }
.layer-text { flex: 1; }
.layer-text strong { display: block; font-size: 12px; font-weight: 600; }
.layer-text small  { display: block; font-size: 10px; color: var(--ts); margin-top: 1px; }
.layer-check { width: 17px; height: 17px; border-radius: 4px; border: 1.5px solid var(--border); flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 10px; color: transparent; transition: all 0.15s; }
.layer-btn.active .layer-check { background: var(--accent); border-color: var(--accent); color: white; }

/* ── Legend ── */
.legend-item { display: flex; align-items: center; gap: 7px; margin-bottom: 5px; font-size: 12px; }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.legend-item .lname { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.legend-item .lpct { font-size: 11px; color: var(--ts); font-weight: 600; }

/* ── Detail panel ── */
#detail-panel { display: none; }
#detail-panel.open { display: block; }
.close-btn { background: none; border: none; color: var(--ts); cursor: pointer; font-size: 12px; padding: 2px 5px; border-radius: 4px; }
.close-btn:hover { background: var(--hover); color: var(--tp); }

.detail-bv-num  { font-size: 10px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 2px; }
.detail-bv-name { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.detail-bv-meta { font-size: 11px; color: var(--ts); margin-bottom: 10px; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 8px; }
.stat-box { background: var(--card); border: 1px solid var(--border); border-radius: 7px; padding: 7px 10px; }
.stat-box.hl { background: rgba(37,99,235,.06); border-color: rgba(37,99,235,.25); }
.stat-box .v { font-size: 19px; font-weight: 800; }
.stat-box .l { font-size: 10px; color: var(--ts); text-transform: uppercase; letter-spacing: 0.4px; margin-top: 1px; }

.part-bar { display: flex; height: 8px; border-radius: 5px; overflow: hidden; margin-bottom: 5px; background: #e5e7eb; }
.part-bar-seg { height: 100%; transition: width 0.5s cubic-bezier(.4,0,.2,1); }
.part-bar-legend { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.pbl-item { display: flex; align-items: center; gap: 4px; font-size: 10px; color: var(--ts); }
.pbl-dot { width: 8px; height: 8px; border-radius: 2px; }

.tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.tab-btn { flex: 1; padding: 5px; font-size: 12px; border-radius: 6px; cursor: pointer; text-align: center; background: var(--card); border: 1px solid var(--border); color: var(--ts); transition: all 0.15s; }
.tab-btn.active { background: var(--accent); border-color: var(--accent); color: white; font-weight: 600; }
.tab-btn:hover:not(.active) { background: var(--hover); color: var(--tp); }

.rr { margin-bottom: 7px; }
.rr-top { display: flex; align-items: center; gap: 5px; margin-bottom: 3px; }
.rr-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.rr-name { flex: 1; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rr-pct { font-size: 12px; font-weight: 700; width: 38px; text-align: right; flex-shrink: 0; }
.rr-bar { height: 3px; margin-left: 14px; border-radius: 2px; background: var(--hover); overflow: hidden; }
.rr-bar-fill { height: 100%; border-radius: 2px; transition: width 0.5s cubic-bezier(.4,0,.2,1); }
.rr-votes { font-size: 10px; color: var(--ts); text-align: right; margin-top: 1px; }

/* ── Map markers ── */
.bv-icon { background: none !important; border: none !important; overflow: visible !important; }
.bv-marker-wrap {
  position: absolute;
  pointer-events: none;
}
.bv-marker {
  display: flex; flex-direction: column; align-items: center;
  position: relative;
  transform: translate(-50%, -50%);
  cursor: pointer;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,.35));
  transition: filter 0.2s;
  pointer-events: auto;
}
.bv-pies {
  display: flex; flex-direction: row; gap: 3px;
}
.bv-marker-label {
  margin-top: 3px;
  padding: 2px 8px;
  background: white;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 700;
  color: #1e293b;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 1px 4px rgba(0,0,0,.28);
  line-height: 1.5;
}
.bv-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #1e40af;
  color: white;
  font-size: 9px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  z-index: 10;
  pointer-events: none;
  line-height: 1;
}
.bv-marker:hover { filter: drop-shadow(0 2px 8px rgba(0,0,0,.55)) brightness(1.05); }
.bv-marker.selected { filter: drop-shadow(0 0 0 2.5px rgba(37,99,235,1)) drop-shadow(0 2px 10px rgba(0,0,0,.5)); }
.bv-marker svg { display: block; overflow: visible; }

/* Layer visibility */
#map:not(.show-participation) .participation-pie { display: none; }
#map:not(.show-ville)         .ville-pie          { display: none; }
#map:not(.show-secteur)       .secteur-pie         { display: none; }

/* Dimmed bureaux (arrdt filter) */
.bv-icon.dimmed { opacity: 0.15; pointer-events: none; }

/* Leader line from original to displaced position */
.leader-line {
  position: absolute;
  pointer-events: none;
  z-index: 400;
}

/* ── Leaflet tooltip ── */
.leaflet-tooltip.bv-tip {
  background: rgba(255,255,255,.97);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--tp);
  font-size: 12px;
  padding: 7px 11px;
  pointer-events: none;
  box-shadow: var(--shadow);
}
.leaflet-tooltip.bv-tip::before { border-top-color: var(--border); }
.bv-tip .tip-num  { font-size: 10px; color: var(--ts); margin-bottom: 2px; }
.bv-tip .tip-name { font-weight: 700; margin-bottom: 5px; color: var(--tp); }
.bv-tip .tip-row  { display: flex; align-items: center; gap: 6px; margin-top: 3px; }
.bv-tip .tip-dot  { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.bv-tip .tip-cand { flex: 1; color: var(--tp); }
.bv-tip .tip-pct  { font-weight: 700; color: var(--accent); }

/* ── Leaflet UI ── */
.leaflet-control-zoom a { background: white !important; color: var(--tp) !important; border-color: var(--border) !important; box-shadow: var(--shadow) !important; }
.leaflet-control-zoom a:hover { background: var(--hover) !important; }
.leaflet-control-attribution { background: rgba(255,255,255,.8) !important; color: var(--ts) !important; font-size: 9px !important; }
.leaflet-control-attribution a { color: var(--ts) !important; }

/* ── Loader ── */
#loader {
  position: fixed; inset: 0; background: white;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  z-index: 10000; gap: 14px; transition: opacity 0.5s;
}
#loader.hidden { opacity: 0; pointer-events: none; }
.loader-spinner { width: 38px; height: 38px; border: 3px solid #e5e7eb; border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loader-text { font-size: 13px; color: var(--ts); }

/* ─── DENSITY CONTROL ─────────────────────────────────────── */
#density-ctrl {
  position: absolute;
  top: 80px;
  right: 10px;
  z-index: 1000;
  font-family: inherit;
}
#density-toggle-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 13px;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
  color: #1e293b;
  transition: all 0.15s;
  white-space: nowrap;
}
#density-toggle-btn:hover { background: #f8fafc; }
#density-toggle-btn.active { background: #1e40af; color: white; border-color: #1e40af; }

#density-panel {
  margin-top: 6px;
  background: white;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 18px rgba(0,0,0,.14);
  overflow: hidden;
  width: 268px;
}
#density-panel.hidden { display: none; }

/* ── flex row: slider column on left, main content on right ── */
.dm-body { display: flex; align-items: stretch; }

.dm-contrast-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 4px;
  border-right: 1px solid #e2e8f0;
  background: #f8fafc;
  width: 36px;
  flex-shrink: 0;
}
.dm-contrast-lbl {
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  line-height: 1;
  user-select: none;
}
.dm-contrast-val {
  font-size: 10px;
  color: #64748b;
  font-weight: 600;
  margin-top: 2px;
}
/* Container that reserves vertical space for the rotated slider */
.dm-contrast-track {
  flex: 1;
  position: relative;
  width: 20px;
  min-height: 80px;
}
.dm-contrast-slider {
  position: absolute;
  /* width becomes height after -90° rotation */
  width: 130px;
  height: 20px;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) rotate(-90deg);
  cursor: pointer;
  accent-color: #1e40af;
  margin: 0;
  padding: 0;
}

.dm-main { flex: 1; min-width: 0; }

.dm-tabs {
  display: flex;
  border-bottom: 1px solid #e2e8f0;
}
.dm-tab {
  flex: 1; padding: 8px 0;
  font-size: 11px; font-weight: 600;
  border: none; background: none;
  cursor: pointer; color: #64748b;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}
.dm-tab:hover { background: #f8fafc; color: #1e293b; }
.dm-tab.active { color: #1e40af; border-bottom-color: #1e40af; }

#density-list {
  max-height: 320px;
  overflow-y: auto;
  padding: 6px;
}
#density-list::-webkit-scrollbar { width: 4px; }
#density-list::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 2px; }

.dc-btn {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: none;
  cursor: pointer;
  font-size: 11px; text-align: left;
  color: #1e293b;
  transition: all 0.12s;
  margin-bottom: 2px;
}
.dc-btn:hover { background: #f1f5f9; }
.dc-btn.active { background: #eff6ff; border-color: #bfdbfe; font-weight: 600; }
.dc-swatch {
  width: 12px; height: 12px;
  border-radius: 3px; flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.1);
}
.dc-sect-header {
  font-size: 10px; font-weight: 700;
  color: #94a3b8; text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 8px 3px;
}
.dc-info {
  padding: 12px 10px;
  font-size: 11px; color: #64748b; line-height: 1.5;
}

/* ─────────────────────────────────────────────
   RESPONSIVE — mobile / narrow screens (≤768px)
   ───────────────────────────────────────────── */

/* Hamburger toggle button on the map — hidden on desktop */
#sidebar-toggle {
  display: none;
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 1001;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
  font-size: 18px;
  padding: 6px 10px;
  cursor: pointer;
  color: #1e293b;
  line-height: 1;
}
#sidebar-toggle:hover { background: #f8fafc; }

/* Dim overlay behind the open sidebar */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 998;
}

@media (max-width: 768px) {
  /* Sidebar slides off-screen to the left by default */
  #sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 999;
    /* keep declared width */
  }

  /* When open: slide in */
  #app.sidebar-open #sidebar {
    transform: translateX(0);
    box-shadow: 4px 0 28px rgba(0,0,0,.25);
  }

  /* Show overlay when sidebar is open */
  #app.sidebar-open #sidebar-overlay {
    display: block;
  }

  /* Show hamburger and close buttons */
  #sidebar-toggle { display: block; }
  #sidebar-close  { display: block; }
}
