:root {
  --bg: #f4f6f8;
  --bar: #ffffff;
  --ink: #1c2733;
  --muted: #6b7a89;
  --line: #e2e8ee;
  --accent: #0a7d4d;       /* Québec green */
  --accent-ink: #ffffff;
  --shadow: 0 2px 10px rgba(20, 40, 60, .10);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

/* ---- Top bar ---- */
#bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: var(--bar);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
  z-index: 1000;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: #e0322d;
  box-shadow: 0 0 0 4px rgba(224, 50, 45, .18);
  animation: pulse 2s infinite;
}
@keyframes pulse { 50% { box-shadow: 0 0 0 7px rgba(224, 50, 45, 0); } }
h1 { font-size: 18px; margin: 0; font-weight: 700; letter-spacing: -.2px; }
h1 .sub { color: var(--accent); font-weight: 700; }

.controls { display: flex; gap: 8px; align-items: center; flex: 1; min-width: 280px; }
#search {
  flex: 1; min-width: 140px;
  padding: 8px 12px; font-size: 14px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink);
}
#search:focus, #region:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
#region {
  padding: 8px 10px; font-size: 14px; max-width: 230px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); cursor: pointer;
}
#lang {
  padding: 8px 12px; font-weight: 700; font-size: 13px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); cursor: pointer;
}
#lang:hover { border-color: var(--accent); color: var(--accent); }
.meta { color: var(--muted); font-size: 13px; white-space: nowrap; }
.meta #count { font-weight: 700; color: var(--ink); }

/* ---- Map ---- */
#map { flex: 1; width: 100%; }

/* ---- Camera popup ---- */
.leaflet-popup-content { margin: 10px 12px; }
.cam-pop { width: 340px; max-width: 78vw; }
.cam-pop h3 { margin: 0 0 8px; font-size: 14px; line-height: 1.35; font-weight: 600; }
.cam-pop .vidwrap {
  position: relative; width: 100%; aspect-ratio: 352 / 240;
  background: #0d1217 center / 22px no-repeat;
  border-radius: 8px; overflow: hidden; cursor: zoom-in;
}
.cam-pop video { width: 100%; height: 100%; display: block; object-fit: cover; background: #0d1217; }
.cam-pop .zoombtn {
  position: absolute; bottom: 6px; right: 6px;
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  background: rgba(13, 18, 23, .66); color: #fff; border-radius: 6px; font-size: 15px;
  pointer-events: none; transition: background .15s;
}
.cam-pop .vidwrap:hover .zoombtn { background: var(--accent); }

/* ---- Lightbox / enlarged camera ---- */
.lb {
  position: fixed; inset: 0; z-index: 5000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(10, 15, 20, .86); backdrop-filter: blur(2px);
}
.lb-inner { position: relative; width: min(94vw, 1000px); }
.lb video {
  width: 100%; aspect-ratio: 352 / 240; display: block;
  background: #0d1217; border-radius: 12px; box-shadow: 0 14px 50px rgba(0, 0, 0, .55);
  object-fit: contain;
}
.lb-title { margin-top: 12px; color: #fff; font-size: 15px; line-height: 1.4; text-align: center; }
.lb-close {
  position: absolute; top: -16px; right: -16px;
  width: 40px; height: 40px; border: none; border-radius: 50%;
  background: #fff; color: var(--ink); font-size: 24px; line-height: 1; cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .4);
}
.lb-close:hover { background: var(--accent); color: #fff; }
@media (max-width: 640px) {
  .lb-close { top: -14px; right: 4px; }
}
.cam-pop .tags { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.cam-pop .tag {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: #eef3f7; color: var(--muted); border: 1px solid var(--line);
}
.cam-pop .tag.route { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 700; }
.cam-pop .err { color: #c0392b; font-size: 12px; padding: 8px; text-align: center; }

/* cluster bubbles in Québec green */
.marker-cluster-small  { background: rgba(10,125,77,.25); }
.marker-cluster-small div  { background: rgba(10,125,77,.75); color:#fff; }
.marker-cluster-medium { background: rgba(10,125,77,.30); }
.marker-cluster-medium div { background: rgba(10,125,77,.80); color:#fff; }
.marker-cluster-large  { background: rgba(10,125,77,.35); }
.marker-cluster-large div  { background: rgba(10,125,77,.85); color:#fff; }

/* ---- misc ---- */
.empty {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: #fff; padding: 14px 20px; border-radius: 10px; box-shadow: var(--shadow);
  color: var(--muted); z-index: 900; font-size: 14px;
}
.hidden { display: none; }
#credit {
  padding: 7px 16px; font-size: 12px; color: var(--muted);
  background: var(--bar); border-top: 1px solid var(--line); text-align: center;
}
#credit a { color: var(--accent); text-decoration: none; }
#credit a:hover { text-decoration: underline; }

@media (max-width: 640px) {
  #bar { gap: 8px; padding: 8px 10px; }
  h1 { font-size: 16px; }
  .controls { order: 3; flex-basis: 100%; }
  .meta { order: 2; }
}
