html, body {
  margin: 0;
  height: 100%;
  font-family: "Segoe UI", system-ui, sans-serif;
}

body {
  display: flex;
  flex-direction: column;
}

#topbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap; /* на узком экране фильтры переносятся под логотип */
  gap: 16px;
  padding: 8px 16px;
  background: #1f2733;
  color: #e8edf3;
  min-height: 44px;
  box-sizing: border-box;
}

#topbar .logo {
  font-weight: 600;
}

#topbar .stats {
  flex: 1;
  opacity: 0.75;
  font-size: 13px;
}

/* Фильтр периода съёмки в топбаре. */
.date-filter {
  display: flex;
  align-items: center;
  gap: 4px;
}

.date-filter input[type="date"] {
  background: #2b3648;
  border: 1px solid #44506a;
  border-radius: 6px;
  color: #e8edf3;
  padding: 4px 6px;
  font-size: 12px;
  color-scheme: dark; /* тёмный нативный календарь-пикер */
}

.date-filter .date-sep {
  color: #8b98ab;
  font-size: 12px;
}

#date-clear {
  background: transparent;
  border: none;
  color: #8b98ab;
  font-size: 16px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

#date-clear:hover {
  color: #e8edf3;
}

#scan-btn {
  background: #3b82f6;
  border: none;
  color: #fff;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

#scan-btn:disabled {
  opacity: 0.5;
  cursor: wait;
}

#map {
  flex: 1;
  min-height: 0;
}

.photo-popup {
  text-align: center;
  max-width: 340px;
}

.photo-popup img {
  max-width: 320px;
  max-height: 240px;
  border-radius: 6px;
  cursor: zoom-in;
}

.photo-popup .meta {
  margin-top: 6px;
  font-size: 12px;
  color: #555;
}

/* Превью кластера по наведению: лента миниатюр в тултипе Leaflet. */
.cluster-thumbs {
  padding: 6px;
  background: rgba(31, 39, 51, 0.92);
  border: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.cluster-thumbs::before {
  display: none; /* убираем стрелку тултипа — лента и так начинается у кластера */
}

.thumbs-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-width: 350px;
}

.thumbs-strip img {
  width: 80px;
  height: 60px;
  object-fit: cover;
  border-radius: 4px;
}

.thumbs-more {
  align-self: center;
  color: #cdd6e1;
  font-size: 12px;
  padding: 0 6px;
}

/* --- Серверные кластеры (мелкий зум) ---------------------------------- */

/* Пузырь с количеством: пастельная терракота, размер по ярусу count. */
.bubble {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(240, 178, 140, 0.92);
  border: 2px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  color: #6b3a1e;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}

.bubble-l {
  font-size: 14px;
}

/* Маркеры-миниатюры: круглое фото с бейджем количества (как в Immich).
   Общий стиль для пузыря с превью, маркера локации и кластера локаций. */
.thumb-bubble,
.photo-marker,
.photo-cluster {
  position: relative;
  border-radius: 50%;
  border: 2px solid #fff;
  background: #1f2733;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  cursor: pointer;
}

/* Специфичность поднята намеренно: в leaflet.css есть правило
   .leaflet-container .leaflet-marker-pane img { width: auto } (0,2,1),
   которое ломало нам ширину — img вылезал за круг и становился овалом. */
.leaflet-container .leaflet-marker-pane .thumb-bubble img,
.leaflet-container .leaflet-marker-pane .photo-marker img,
.leaflet-container .leaflet-marker-pane .photo-cluster img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.thumb-bubble b,
.photo-marker b,
.photo-cluster b {
  position: absolute;
  right: -6px;
  bottom: -6px;
  background: #d97b4f;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 10px;
  border: 1.5px solid #fff;
  white-space: nowrap;
}

/* --- Попап-галерея локации -------------------------------------------- */

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  max-height: 340px;
  overflow-y: auto;
}

.gallery-grid a {
  display: block;
}

.gallery-grid img {
  display: block;
  width: 100%;
  height: 95px;
  object-fit: cover;
  border-radius: 4px;
}

.gallery-more {
  margin-top: 6px;
  width: 100%;
  padding: 6px;
  background: #2b3648;
  border: 1px solid #44506a;
  border-radius: 6px;
  color: #e8edf3;
  font-size: 12px;
  cursor: pointer;
}

.gallery-more:hover {
  background: #35435a;
}

/* Тёмная тема попап-галереи — под стать тултипу-превью. */
.gallery-popup .leaflet-popup-content-wrapper {
  background: #1f2733;
  color: #e8edf3;
  border-radius: 10px;
}

.gallery-popup .leaflet-popup-tip {
  background: #1f2733;
}

.gallery-popup .leaflet-popup-close-button {
  color: #cdd6e1;
}
