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

/* Ensure [hidden] always wins over display:flex/block rules */
[hidden] { display: none !important; }

/* ── CSS custom properties (light / day theme) ─────────────── */
:root {
  --header-bg:    #ffffff;
  --header-border:#e2e5ec;
  --header-h:     58px;

  --body-bg:      #f0f2f5;

  --text-primary:  #1a1d2e;
  --text-secondary:#6b7280;

  --btn-bg:        #f3f4f6;
  --btn-border:    #d1d5db;
  --btn-text:      #374151;
  --btn-hover-bg:  #e5e7eb;

  --btn-on-bg:     #dbeafe;
  --btn-on-border: #3b82f6;
  --btn-on-text:   #1d4ed8;

  --btn-inc-on-bg:     #fee2e2;
  --btn-inc-on-border: #ef4444;
  --btn-inc-on-text:   #b91c1c;

  --chip-bg:      #ffffffcc;
  --chip-border:  #d1d5db;
  --chip-text:    #374151;

  --legend-bg:    #ffffffee;
  --legend-border:#d1d5db;
  --legend-text:  #374151;

  --panel-bg:     #ffffff;
  --panel-border: #e2e5ec;
  --panel-sub:    #6b7280;

  --detail-border:#f3f4f6;
  --detail-dt:    #9ca3af;
  --detail-dd:    #111827;

  --status-on:    #16a34a;
  --status-off:   #dc2626;

  --feed-bg:      #f3f4f6;
  --feed-border:  #e2e5ec;

  --spinner-track:#e2e5ec;
  --spinner-head: #2563eb;

  --shadow-sm:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md:    0 4px 12px rgba(0,0,0,.10);

  --radius-sm:    6px;
  --radius-md:    10px;
  --radius-lg:    14px;

  --transition:   0.2s ease;
}

/* ── Night theme overrides ─────────────────────────────────── */
body.night {
  --header-bg:    #161b27;
  --header-border:#21273a;

  --body-bg:      #0d1117;

  --text-primary:  #f3f4f6;
  --text-secondary:#9ca3af;

  --btn-bg:        #1e2435;
  --btn-border:    #2d3550;
  --btn-text:      #d1d5db;
  --btn-hover-bg:  #252c40;

  --btn-on-bg:     #1e3a5f;
  --btn-on-border: #2563eb;
  --btn-on-text:   #93c5fd;

  --btn-inc-on-bg:     #3b1a1a;
  --btn-inc-on-border: #c8102e;
  --btn-inc-on-text:   #fca5a5;

  --chip-bg:       #161b27cc;
  --chip-border:   #21273a;
  --chip-text:     #d1d5db;

  --legend-bg:     #161b27ee;
  --legend-border: #21273a;
  --legend-text:   #d1d5db;

  --panel-bg:      #161b27;
  --panel-border:  #21273a;
  --panel-sub:     #6b7280;

  --detail-border: #1e2435;
  --detail-dt:     #6b7280;
  --detail-dd:     #e5e7eb;

  --feed-bg:       #1e2435;
  --feed-border:   #21273a;

  --spinner-track: #21273a;
  --spinner-head:  #3b82f6;

  --shadow-sm:     0 1px 3px rgba(0,0,0,.4);
  --shadow-md:     0 4px 16px rgba(0,0,0,.5);
}

/* ── Body & layout scaffold ────────────────────────────────── */
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--body-bg);
  color: var(--text-primary);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: background var(--transition), color var(--transition);
}

/* ── Header ────────────────────────────────────────────────── */
#app-header {
  height: var(--header-h);
  background: var(--header-bg);
  border-bottom: 1px solid var(--header-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  z-index: 1001; /* must beat Leaflet controls (z-index 1000) so dropdown is visible */
  position: relative;
  transition: background var(--transition), border-color var(--transition);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 11px;
}

.brand-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #c8102e 0%, #ff5252 100%);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(200,16,46,.35);
}

/* Visually hidden SEO text inside h1 — read by Google, invisible to users */
.brand-sr-text {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

.brand-words h1 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text-primary);
  line-height: 1.2;
  transition: color var(--transition);
}

.brand-words p {
  font-size: 11px;
  color: var(--text-secondary);
  transition: color var(--transition);
}

/* ── Header controls ───────────────────────────────────────── */
.header-controls {
  display: flex;
  align-items: center;
  gap: 7px;
}

.ctrl-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  color: var(--btn-text);
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition), border-color var(--transition),
              color var(--transition), box-shadow var(--transition);
}

.ctrl-btn:hover {
  background: var(--btn-hover-bg);
}

.ctrl-btn.active {
  background: var(--btn-on-bg);
  border-color: var(--btn-on-border);
  color: var(--btn-on-text);
}

.ctrl-btn.inc-active {
  background: var(--btn-inc-on-bg);
  border-color: var(--btn-inc-on-border);
  color: var(--btn-inc-on-text);
}

.btn-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.btn-icon {
  font-size: 13px;
  line-height: 1;
}

.cam-badge {
  font-weight: 700;
}

.divider {
  width: 1px;
  height: 22px;
  background: var(--btn-border);
  margin: 0 3px;
  transition: background var(--transition);
}

/* ── Search box ────────────────────────────────────────────── */
.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  margin-right: 10px;
}

.search-icon {
  position: absolute;
  left: 9px;
  font-size: 13px;
  pointer-events: none;
  opacity: 0.5;
  z-index: 1;
}

.search-input {
  width: 210px;
  height: 32px;
  padding: 0 10px 0 30px;
  border: 1px solid var(--btn-border);
  border-radius: var(--radius-sm);
  background: var(--btn-bg);
  color: var(--text-primary);
  font-size: 12.5px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition), background var(--transition),
              box-shadow var(--transition), width var(--transition);
  -webkit-appearance: none;
}

.search-input::placeholder { color: var(--text-secondary); }

.search-input:focus {
  border-color: var(--btn-on-border);
  box-shadow: 0 0 0 2px rgba(59,130,246,.18);
  width: 260px;
}

/* Cancel button that browsers inject */
.search-input::-webkit-search-cancel-button { opacity: 0.5; cursor: pointer; }

.search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  width: 320px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: 9999;
  list-style: none;
  padding: 4px 0;
  max-height: 280px;
  overflow-y: auto;
}

.search-result-item {
  display: flex;
  flex-direction: column;
  padding: 8px 13px;
  cursor: pointer;
  transition: background var(--transition);
  border-bottom: 1px solid var(--detail-border);
}

.search-result-item:last-child { border-bottom: none; }

.search-result-item:hover,
.search-result-item[aria-selected="true"] {
  background: var(--btn-hover-bg);
}

.sri-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sri-sub {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.search-result-empty {
  padding: 12px 13px;
  font-size: 12.5px;
  color: var(--text-secondary);
  text-align: center;
}

/* ── Map wrapper ───────────────────────────────────────────── */
#map-wrap {
  flex: 1;
  min-height: 0; /* lets flexbox shrink this below its content height */
  position: relative;
  overflow: hidden;
}

/* Map sits to the left of the always-visible side panel */
#map {
  width: calc(100% - 375px);
  height: 100%; /* fill #map-wrap which flexbox sizes correctly */
}

@media (max-width: 700px) {
  #map { width: 100%; }
}

/* ── Loading overlay ───────────────────────────────────────── */
#loading {
  position: absolute;
  inset: 0;
  background: var(--body-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 300;
  gap: 14px;
  transition: background var(--transition);
}

#loading p {
  font-size: 13px;
  color: var(--text-secondary);
}

.spinner {
  width: 38px;
  height: 38px;
  border: 3px solid var(--spinner-track);
  border-top-color: var(--spinner-head);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Stats bar ─────────────────────────────────────────────── */
.stats-bar {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 7px;
  z-index: 1000;
  pointer-events: none;
}

.chip {
  background: var(--chip-bg);
  border: 1px solid var(--chip-border);
  border-radius: 20px;
  padding: 5px 13px;
  font-size: 12px;
  color: var(--chip-text);
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  transition: background var(--transition), border-color var(--transition);
}

.chip strong {
  color: var(--text-primary);
  font-weight: 700;
}

/* ── Legend ────────────────────────────────────────────────── */
.legend {
  position: fixed;
  bottom: 24px;
  left: 14px;
  background: var(--legend-bg);
  border: 1px solid var(--legend-border);
  border-radius: var(--radius-md);
  padding: 13px 15px;
  z-index: 9999;
  min-width: 148px;
  box-shadow: var(--shadow-md);
  transition: background var(--transition), border-color var(--transition);
  pointer-events: none;
}

.legend-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-secondary);
  margin-bottom: 9px;
}

.legend-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.legend-list li {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12px;
  color: var(--legend-text);
}

.legend-swatch {
  display: inline-block;
  width: 26px;
  height: 5px;
  border-radius: 3px;
  flex-shrink: 0;
}

.legend-hw-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: #f59e0b;
  border: 2px solid #ffffff;
  flex-shrink: 0;
}

.legend-cam-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #38bdf8;
  border: 2px solid #ffffff;
  box-shadow: 0 0 5px #38bdf855;
  flex-shrink: 0;
}

.legend-rule {
  border: none;
  border-top: 1px solid var(--legend-border);
  margin: 8px 0;
  transition: border-color var(--transition);
}

/* ── Highway sensor dot markers ────────────────────────────── */
.hw-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: #f59e0b;
  border: 2px solid #ffffff;
  cursor: pointer;
  box-shadow: 0 0 4px #f59e0b66;
  transition: transform 0.12s ease;
}

.hw-dot:hover { transform: scale(1.5); }


/* ── Camera marker wrapper (dot + status pill) ─────────────── */
.cam-marker-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: max-content;
}

.cam-status-pill {
  background: rgba(255,255,255,0.92);
  border: 1px solid #d1d5db;
  border-radius: 10px;
  padding: 0 5px;
  font-size: 9px;
  font-weight: 700;
  font-family: 'Segoe UI', system-ui, sans-serif;
  white-space: nowrap;
  line-height: 13px;
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
  pointer-events: none;
}

.cam-status-pill.online  { color: #16a34a; }
.cam-status-pill.offline { color: #9ca3af; }

body.night .cam-status-pill {
  background: rgba(22,27,39,0.92);
  border-color: #21273a;
}
body.night .cam-status-pill.online  { color: #4ade80; }
body.night .cam-status-pill.offline { color: #6b7280; }


/* ── Camera dot markers ────────────────────────────────────── */
.cam-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #38bdf8;
  border: 2px solid #ffffff;
  cursor: pointer;
  box-shadow: 0 0 6px #38bdf877;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.cam-dot:hover {
  transform: scale(1.4);
  box-shadow: 0 0 12px #38bdf8bb;
}

.cam-dot.offline {
  background: #9ca3af;
  box-shadow: none;
}

/* ── Side panel ────────────────────────────────────────────── */
.side-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: 375px;
  height: 100%;
  background: var(--panel-bg);
  border-left: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  z-index: 50;
  box-shadow: var(--shadow-md);
  transition: background var(--transition), border-color var(--transition);
}

/* Panel header */
.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 15px 17px;
  border-bottom: 1px solid var(--panel-border);
  flex-shrink: 0;
  transition: border-color var(--transition);
}

.panel-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
  transition: color var(--transition);
}

.panel-sub {
  font-size: 11px;
  color: var(--panel-sub);
  margin-top: 2px;
  word-break: break-all;
}

.close-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 17px;
  line-height: 1;
  padding: 3px 5px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  transition: color var(--transition), background var(--transition);
}

.close-btn:hover {
  color: var(--text-primary);
  background: var(--btn-hover-bg);
}

/* Feed section */
.feed-section {
  padding: 14px;
  border-bottom: 1px solid var(--panel-border);
  flex-shrink: 0;
  transition: border-color var(--transition);
}

.feed-img-wrap {
  position: relative;
  width: 100%;
  height: 195px;
  background: var(--feed-bg);
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--feed-border);
  transition: background var(--transition), border-color var(--transition);
}

.feed-img-wrap img,
.feed-img-wrap video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.feed-overlay-offline {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--feed-bg);
  gap: 6px;
}

.feed-overlay-offline span {
  font-size: 32px;
  opacity: 0.3;
}

.feed-overlay-offline p {
  font-size: 13px;
  color: var(--text-secondary);
}

.feed-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 9px;
}

.feed-live-badge {
  background: #dc2626;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 2px 7px;
  border-radius: 4px;
  flex-shrink: 0;
}

.feed-timestamp {
  flex: 1;
}

.feed-timestamp {
  font-size: 11px;
  color: var(--text-secondary);
}

.refresh-btn {
  background: none;
  border: 1px solid var(--btn-border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 11px;
  font-family: inherit;
  padding: 3px 10px;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition),
              background var(--transition);
}

.refresh-btn:hover {
  color: var(--text-primary);
  border-color: var(--text-secondary);
  background: var(--btn-hover-bg);
}

/* Detail rows */
.panel-details {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 17px;
  border-bottom: 1px solid var(--detail-border);
  transition: border-color var(--transition);
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-row dt {
  font-size: 12px;
  color: var(--detail-dt);
  font-weight: 400;
  transition: color var(--transition);
}

.detail-row dd {
  font-size: 13px;
  color: var(--detail-dd);
  font-weight: 500;
  text-align: right;
  max-width: 65%;
  transition: color var(--transition);
}

.status-on  { color: var(--status-on)  !important; }
.status-off { color: var(--status-off) !important; }

/* ── Map click hint ────────────────────────────────────────── */
.map-hint {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--legend-bg);
  border: 1px solid var(--legend-border);
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 12px;
  color: var(--text-secondary);
  z-index: 1000;
  pointer-events: none;
  display: none;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  transition: background var(--transition), border-color var(--transition);
}

/* ── Panel mode tag ────────────────────────────────────────── */
.panel-mode-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  border-radius: 4px;
  padding: 2px 7px;
  margin-bottom: 4px;
}

.tag-sv {
  background: #dbeafe;
  color: #1d4ed8;
}

.tag-cam {
  background: #dcfce7;
  color: #15803d;
}

body.night .tag-sv  { background: #1e3a5f; color: #93c5fd; }
body.night .tag-cam { background: #14532d; color: #86efac; }

/* ── Street View section ───────────────────────────────────── */
.sv-section {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.sv-container {
  width: 100%;
  flex: 1;
  min-height: 320px;
}

.sv-no-coverage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 30px;
  text-align: center;
}

.sv-no-coverage span {
  font-size: 40px;
  opacity: 0.25;
}

.sv-no-coverage p {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.sv-no-coverage small {
  font-size: 12px;
  color: var(--text-secondary);
}

.sv-details {
  flex: 0 0 auto;
  border-top: 1px solid var(--panel-border);
}

/* ── Camera section ────────────────────────────────────────── */
.cam-section {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
}

.cam-sv-link {
  padding: 12px 14px;
  border-top: 1px solid var(--panel-border);
  flex-shrink: 0;
}

.sv-link-btn {
  width: 100%;
  background: var(--btn-on-bg);
  border: 1px solid var(--btn-on-border);
  border-radius: var(--radius-sm);
  color: var(--btn-on-text);
  font-size: 12.5px;
  font-family: inherit;
  padding: 8px 14px;
  cursor: pointer;
  transition: opacity 0.15s;
}

.sv-link-btn:hover { opacity: 0.85; }

/* ── Footer ────────────────────────────────────────────────── */
#app-footer {
  height: 28px;
  background: var(--header-bg);
  border-top: 1px solid var(--header-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--text-secondary);
  flex-shrink: 0;
  letter-spacing: 0.1px;
  transition: background var(--transition), border-color var(--transition),
              color var(--transition);
}

/* ── Affiliates bar ────────────────────────────────────────── */
#affiliates-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 18px;
  background: var(--body-bg);
  border-top: 1px solid var(--header-border);
  flex-shrink: 0;
  transition: background var(--transition), border-color var(--transition);
}

.aff-label {
  font-size: 10px;
  color: var(--text-secondary);
  white-space: nowrap;
  margin-right: 4px;
}

.aff-chip {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 4px;
  padding: 2px 8px;
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--transition), background var(--transition),
              border-color var(--transition);
}

.aff-chip:hover {
  color: var(--text-primary);
  background: var(--btn-hover-bg);
  border-color: var(--text-secondary);
}


/* ── Footer links ──────────────────────────────────────────── */
.footer-link {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--transition);
}

.footer-link:hover { color: var(--text-primary); text-decoration: underline; }

.footer-link-btn {
  background: none;
  border: none;
  font-size: inherit;
  font-family: inherit;
  cursor: pointer;
  padding: 0;
}

/* ── Privacy modal ─────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 560px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  transition: background var(--transition), border-color var(--transition);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--panel-border);
  flex-shrink: 0;
}

.modal-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-body {
  overflow-y: auto;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.6;
}

.modal-updated {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.modal-body h3 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.modal-body p, .modal-body ul { margin: 0; }

.modal-body ul {
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.modal-body a {
  color: #2563eb;
  text-decoration: none;
}

.modal-body a:hover { text-decoration: underline; }

body.night .modal-body a { color: #60a5fa; }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 700px) {
  .brand-words p,
  .divider,
  .theme-label { display: none; }

  .ctrl-btn { padding: 6px 9px; font-size: 12px; }

  .side-panel { width: 100%; right: -100%; }

  .stats-bar { top: 10px; gap: 5px; }
  .chip { font-size: 11px; padding: 4px 10px; }

  .legend { bottom: 18px; left: 10px; }

  .traffic-score-wrap { display: none; }
  .footer-socials { display: none; }
}

/* ═══════════════════════════════════════════════════════════════
   NEW FEATURE STYLES
═══════════════════════════════════════════════════════════════ */

/* ── Traffic light loader ───────────────────────────────────── */
.tl-loader {
  display: flex;
  justify-content: center;
  margin-bottom: 18px;
}
.tl-housing {
  background: #111;
  border-radius: 14px;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 4px 24px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.06);
  border: 2px solid #2a2a2a;
}
.tl-light {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  opacity: 0.12;
}
.tl-red   { background: #ef4444; animation: tl-red-glow   1.8s 0s    infinite; }
.tl-amber { background: #f59e0b; animation: tl-amb-glow   1.8s 0.6s  infinite; }
.tl-green { background: #22c55e; animation: tl-grn-glow   1.8s 1.2s  infinite; }

@keyframes tl-red-glow {
  0%,20%  { opacity: 1;    box-shadow: 0 0 18px 4px #ef444499; }
  35%,100%{ opacity: 0.12; box-shadow: none; }
}
@keyframes tl-amb-glow {
  0%,20%  { opacity: 1;    box-shadow: 0 0 18px 4px #f59e0b99; }
  35%,100%{ opacity: 0.12; box-shadow: none; }
}
@keyframes tl-grn-glow {
  0%,20%  { opacity: 1;    box-shadow: 0 0 18px 4px #22c55e99; }
  35%,100%{ opacity: 0.12; box-shadow: none; }
}

/* ── Pulsing live camera dot ────────────────────────────────── */
.cam-dot {
  position: relative; /* needed for ::after */
}
.cam-dot:not(.offline)::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: #38bdf8;
  opacity: 0;
  animation: cam-pulse 3s ease-out infinite;
}
@keyframes cam-pulse {
  0%   { transform: scale(1);   opacity: 0.55; }
  100% { transform: scale(3.2); opacity: 0; }
}

/* ── Traffic score badge ────────────────────────────────────── */
.traffic-score-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: var(--radius-md);
  cursor: default;
  flex-shrink: 0;
  transition: background var(--transition), border-color var(--transition);
}
.ts-badge {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
  transition: background var(--transition);
}
.ts-badge.ts-unknown  { background: #9ca3af; }
.ts-badge.ts-good     { background: #16a34a; box-shadow: 0 0 10px #16a34a55; }
.ts-badge.ts-moderate { background: #d97706; box-shadow: 0 0 10px #d9770655; }
.ts-badge.ts-bad      { background: #dc2626; box-shadow: 0 0 10px #dc262655; }
.ts-label-wrap {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
.ts-top {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}
.ts-status {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

/* ── Night mode: control room aesthetic ─────────────────────── */
body.night {
  --header-bg:     #06090f;
  --header-border: #13192a;
  --body-bg:       #040710;
  --panel-bg:      #06090f;
  --panel-border:  #13192a;
  --btn-bg:        #0d1220;
  --btn-border:    #1a2236;
  --btn-text:      #c9d1e0;
  --btn-hover-bg:  #131b2e;
  --btn-on-bg:     #1f1500;
  --btn-on-border: #d97706;
  --btn-on-text:   #fbbf24;
  --spinner-head:  #f59e0b;
  --chip-bg:       #06090fcc;
  --chip-border:   #13192a;
  --chip-text:     #c9d1e0;
  --legend-bg:     #06090fee;
  --legend-border: #13192a;
}
body.night #app-header {
  box-shadow: 0 1px 0 rgba(245,158,11,.15), 0 2px 16px rgba(0,0,0,.7);
}
body.night .brand-icon {
  background: linear-gradient(135deg, #92400e 0%, #d97706 100%);
  box-shadow: 0 2px 8px rgba(217,119,6,.4);
}
body.night .ts-badge.ts-good     { box-shadow: 0 0 12px #16a34a88; }
body.night .ts-badge.ts-moderate { box-shadow: 0 0 12px #d9770688; }
body.night .ts-badge.ts-bad      { box-shadow: 0 0 12px #dc262688; }

/* Scanline CRT texture */
.scanline-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(0,0,0,.045) 3px,
    rgba(0,0,0,.045) 4px
  );
  pointer-events: none;
  z-index: 8000;
}
body.night .scanline-overlay { display: block; }

/* ── Icon-only compact nav button ───────────────────────────── */
.ctrl-btn.icon-only {
  padding: 6px 8px;
  position: relative;
}

/* ── Share button: "Copied!" flash ─────────────────────────── */
.ctrl-btn.share-copied {
  background: #dcfce7 !important;
  border-color: #16a34a !important;
  color: #15803d !important;
}
body.night .ctrl-btn.share-copied {
  background: #052e16 !important;
  border-color: #16a34a !important;
  color: #4ade80 !important;
}

/* ── Bookmarks dropdown ─────────────────────────────────────── */
.bm-wrap { position: relative; }
.bm-badge {
  position: absolute;
  top: -4px; right: -4px;
  min-width: 16px;
  height: 16px;
  background: #dc2626;
  color: #fff;
  border-radius: 8px;
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  pointer-events: none;
}
.bm-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 240px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: 9999;
  padding: 6px 0;
  max-height: 320px;
  overflow-y: auto;
}
.bm-menu-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  padding: 4px 13px 6px;
}
.bm-empty {
  font-size: 12.5px;
  color: var(--text-secondary);
  padding: 12px 13px;
  text-align: center;
}
.bm-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px 7px 13px;
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  font-size: 12.5px;
  font-family: inherit;
  color: var(--text-primary);
  transition: background var(--transition);
}
.bm-item:hover { background: var(--btn-hover-bg); }
.bm-item-name  { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bm-item-del {
  width: 22px; height: 22px;
  border-radius: 4px;
  border: none;
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
  transition: background var(--transition), color var(--transition);
}
.bm-item-del:hover { background: #fee2e2; color: #dc2626; }
body.night .bm-item-del:hover { background: #3b1a1a; color: #f87171; }
.bm-add-hint {
  font-size: 11px;
  color: var(--text-secondary);
  padding: 6px 13px 4px;
  border-top: 1px solid var(--detail-border);
  margin-top: 4px;
}

/* ── Save location button in panel ──────────────────────────── */
.panel-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.save-loc-btn {
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.save-loc-btn:hover          { color: #f59e0b; border-color: #f59e0b; background: #fef3c7; }
.save-loc-btn.saved          { color: #f59e0b; border-color: #f59e0b; background: #fef3c7; }
body.night .save-loc-btn.saved { background: #1f1500; border-color: #d97706; color: #fbbf24; }

/* ── Toast notifications ────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 72px;
  right: 20px;
  z-index: 9990;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-md);
  font-size: 13px;
  color: var(--text-primary);
  pointer-events: all;
  transform: translateX(120%);
  transition: transform 0.3s cubic-bezier(.34,1.56,.64,1);
  max-width: 300px;
  border-left: 3px solid transparent;
}
.toast.visible            { transform: translateX(0); }
.toast.toast-info         { border-left-color: #3b82f6; }
.toast.toast-warning      { border-left-color: #f59e0b; }
.toast.toast-success      { border-left-color: #22c55e; }
.toast-close {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 14px;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
}

/* ── Embed modal code block ─────────────────────────────────── */
.embed-code-wrap {
  position: relative;
  background: var(--feed-bg);
  border: 1px solid var(--feed-border);
  border-radius: var(--radius-sm);
  padding: 12px 80px 12px 14px;
  margin-top: 10px;
}
.embed-code {
  font-family: 'Consolas', 'SF Mono', monospace;
  font-size: 11.5px;
  color: var(--detail-dd);
  word-break: break-all;
  display: block;
  line-height: 1.5;
}
.embed-copy-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--btn-on-bg);
  border: 1px solid var(--btn-on-border);
  color: var(--btn-on-text);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition);
}
.embed-copy-btn:hover { opacity: 0.85; }

/* ── Footer layout update ───────────────────────────────────── */
#app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.footer-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
}
.footer-socials {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.footer-social {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: all var(--transition);
}
.footer-social:hover { color: var(--text-primary); border-color: var(--text-secondary); }
