/* Shared */
html { height: 100%; }

/* =========================
   Page: Map (index/admin)
   ========================= */
body.page-map {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #050816;
  color: #e5e7eb;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Use the same header/menu look on album as on map */
.page-map header,
.page-album header {
  padding: 16px 24px;
  background: #0f172a;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.page-map h1,
.page-album h1 { margin: 0; font-size: 1.4rem; }

.page-map .controls,
.page-album .controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.page-map .field,
.page-album .field { display: flex; flex-direction: column; gap: 4px; }

.page-map label,
.page-album label { font-size: 0.8rem; opacity: 0.85; }

/* Ensure shared header stays identical across pages */
.page-map header .field,
.page-album header .field {
  align-items: flex-start;
}

.page-map header label,
.page-album header label {
  text-align: left;
  width: 100%;
}

.page-map input[type="datetime-local"],
.page-map select,
.page-album input[type="datetime-local"],
.page-album select {
  background: #020617;
  border-radius: 999px;
  border: 1px solid #1f2937;
  color: #e5e7eb;
  padding: 6px 10px;
  font-size: 0.9rem;
}

.page-map button,
.page-album button {
  border-radius: 999px;
  border: none;
  padding: 8px 16px;
  font-size: 0.9rem;
  cursor: pointer;
  user-select: none;
}

.page-album .btn-primary { background: #2563eb; color: white; font-weight: 500; }
.page-album .btn-primary:hover { background: #1d4ed8; }

.page-album .btn-secondary {
  background: #111827;
  color: #e5e7eb;
  border: 1px solid #1f2937;
  padding: 6px 10px;
}
.page-album .btn-secondary:hover { background: #1f2937; }

.page-album .btn-ghost {
  background: transparent;
  color: #e5e7eb;
  border: 1px solid #1f2937;
  padding: 6px 10px;
}
.page-album .btn-ghost:hover { background: #111827; }

.page-album .range-buttons { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.page-album .inline-row { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }

@media (max-width: 900px) {
  .page-album header { flex-direction: column; align-items: flex-start; }
}

.page-map header {
  padding: 16px 24px;
  background: #0f172a;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.page-map h1 { margin: 0; font-size: 1.4rem; }

.page-map .controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.page-map .field { display: flex; flex-direction: column; gap: 4px; }
.page-map label { font-size: 0.8rem; opacity: 0.85; }

.page-map input[type="datetime-local"],
.page-map select {
  background: #020617;
  border-radius: 999px;
  border: 1px solid #1f2937;
  color: #e5e7eb;
  padding: 6px 10px;
  font-size: 0.9rem;
}

.page-map button {
  border-radius: 999px;
  border: none;
  padding: 8px 16px;
  font-size: 0.9rem;
  cursor: pointer;
  user-select: none;
}

.page-map .btn-primary { background: #2563eb; color: white; font-weight: 500; }
.page-map .btn-primary:hover { background: #1d4ed8; }
.page-map .btn-primary.active { filter: brightness(0.95); }



.page-map .btn-secondary {
  background: #111827;
  color: #e5e7eb;
  border: 1px solid #1f2937;
  padding: 6px 10px;
}
.page-map .btn-secondary:hover { background: #1f2937; }
.page-map .btn-secondary.active { background: #2563eb; border-color: #2563eb; }

/* Track edit: rectangle tool buttons should clearly indicate active state */
.page-map #trackEditSourceRectBtn.active {
  background: #f59e0b;
  border-color: #f59e0b;
  color: #111827;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.25);
}
.page-map #trackEditSourceRectBtn.active:hover { background: #d97706; border-color: #d97706; }

.page-map #trackEditDeleteRectBtn.active {
  background: #ef4444;
  border-color: #ef4444;
  color: #ffffff;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.25);
}
.page-map #trackEditDeleteRectBtn.active:hover { background: #dc2626; border-color: #dc2626; }

.page-map .btn-ghost {
  background: transparent;
  color: #e5e7eb;
  border: 1px solid #1f2937;
  padding: 6px 10px;
}
.page-map .btn-ghost:hover { background: #111827; }

.page-map .range-buttons {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
}

/* Index: orange hint line shown in nearby (Umkreis) mode */
/* Index: persistent hint shown under the menu in nearby (Umkreis) mode */
.page-map #nearbyHintBar {
  flex-shrink: 0;
  display: none;
  padding: 8px 24px;
  font-size: 0.85rem;
  border-left: 4px solid #f59e0b;
  background: #f59e0b;
  color: #111827;
  font-weight: 600;
}

.page-map .inline-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.page-map #messageBar {
  flex-shrink: 0;
  display: none;
  padding: 8px 24px;
  font-size: 0.85rem;
  background: #111827;
  color: #e5e7eb;
}
.page-map #messageBar.info { border-left: 4px solid #3b82f6; }
.page-map #messageBar.warning { border-left: 4px solid #f59e0b; background: #f59e0b; color: #111827; }
.page-map #messageBar.error { border-left: 4px solid #ef4444; }

.page-map #map { flex: 1 1 auto; width: 100%; }

/* =========================
   Page: Perimeter / Nearby (peri.php)
   ========================= */
body.page-peri {
  /* keep the same base look as page-map but ensure map fills the viewport */
  overflow: hidden;
}

body.page-peri #map {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
}

/* During replay we must allow the preview bar to take space above the map */
body.page-peri.replay-active #map,
body.page-peri.replay-active.map-fullscreen #map {
  height: auto !important;
}

body.page-peri #messageBar {
  position: fixed;
  left: 12px;
  right: 12px;
  top: calc(env(safe-area-inset-top, 0px) + 58px);
  z-index: 2200;
  border-radius: 12px;
}

body.page-peri .peri-topbar {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  z-index: 2300;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 12px 10px 12px;
  display: grid;
  grid-template-columns: repeat(3, auto);
  justify-content: center;
  align-content: start;
  gap: 8px;
  pointer-events: none; /* buttons still clickable */
}

body.page-peri .peri-topbar .peri-mode-select {
  pointer-events: auto;
  padding: 10px 14px;
}
 
 body.page-peri .peri-topbar .peri-reload-btn {
   pointer-events: auto;
 }

body.page-peri .peri-topbar .peri-replay-today-btn,
body.page-peri .peri-topbar .peri-replay-yesterday-btn,
body.page-peri .peri-topbar .peri-replay-stop-btn {
  pointer-events: auto;
}

@media (max-width: 480px) {
  body.page-peri .peri-topbar {
    gap: 6px;
    padding: calc(env(safe-area-inset-top, 0px) + 8px) 10px 8px 10px;
  }
  body.page-peri .peri-topbar .peri-mode-select {
    padding: 10px 12px;
    font-size: 0.9rem;
  }
}

@media (max-width: 900px) {
  .page-map header { flex-direction: column; align-items: flex-start; }
}

/* Foto-Thumbnails als Marker */
.page-map .picture-thumb-icon { background: transparent; border: none; }
.page-map .picture-thumb-icon .thumb-wrap {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid #f59e0b;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.25);
  background: rgba(0, 0, 0, 0.15);
}

/* Foto-Cluster: rundes Preview + Anzahl */
.page-map .picture-cluster-icon { background: transparent; border: none; }
.page-map .picture-cluster-icon .cluster-wrap {
  width: 46px;
  height: 46px;
  border-radius: 999px;
  overflow: hidden;
  border: 2px solid #f59e0b;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.25);
  background: transparent;
  position: relative;
}
.page-map .picture-cluster-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  image-orientation: from-image;
}
.page-map .picture-cluster-icon .cluster-count {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
  background: transparent;
  border: none;
  padding: 0;
  color: #f59e0b;
  text-shadow:
    0 1px 2px rgba(0, 0, 0, 0.85),
    0 0 6px rgba(0, 0, 0, 0.65);
}

/* Picture edit: selected/moved marker gets a yellow frame */
.page-map .picture-thumb-icon.is-edit-selected .thumb-wrap {
  border-color: #f59e0b;
  border-width: 3px;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.45), 0 8px 18px rgba(0, 0, 0, 0.35);
}

/* Picture edit: any dirty (moved) marker stays yellow until saved */
.page-map .picture-thumb-icon.is-edit-dirty .thumb-wrap {
  border-color: #f59e0b;
  border-width: 3px;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.45), 0 8px 18px rgba(0, 0, 0, 0.35);
}
.page-map .picture-thumb-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  image-orientation: from-image;
}

/* Lightbox / Bild-Overlay */
.page-map #imageOverlay {
  position: fixed;
  inset: 0;
  z-index: 5000;
  background: rgba(0, 0, 0, 0.82);
  display: none;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.page-map #imageOverlay.active { display: flex; }

/* Leaflet popup: set range from picture timestamp */
.leaflet-popup-content .popup-time-setter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 6px 0 8px 0;
  font-size: 0.85rem;
}

.leaflet-popup-content .popup-time-setter button {
  border-radius: 999px;
  border: 1px solid #1f2937;
  background: #111827;
  color: #e5e7eb;
  padding: 4px 10px;
  font-size: 0.85rem;
  cursor: pointer;
}

.leaflet-popup-content .popup-time-setter button:hover {
  background: #1f2937;
}

/* Leaflet: TrackSources legend (bottom-right) */
.track-legend {
  background: #111827;
  color: #e5e7eb;
  border: 1px solid #1f2937;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.85rem;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  display: none; /* legend removed */
}

/* Leaflet: End-of-track marker (green) */
.end-track-icon {
  background: transparent;
  border: none;
}

.end-track-icon__dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: #22c55e;
  border: 2px solid rgba(0, 0, 0, 0.55);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.25);
}

.track-legend__title {
  font-weight: 700;
  margin-bottom: 6px;
}

.track-legend__list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.track-legend__row {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.track-legend__swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1px solid #1f2937;
  flex: 0 0 14px;
}

.track-legend__label {
  opacity: 0.95;
}

/* Revue: zentrierte Bildvorschau (2s) */
/* index.php: show preview above the map (map shifts down) */
body.page-map:not(.page-peri) .replay-preview {
  flex-shrink: 0;
  display: none;
  padding: 10px 24px 0 24px;
  pointer-events: none;
}

body.page-map:not(.page-peri) .replay-preview img {
  width: 100%;
  max-width: min(78vw, 720px);
  max-height: 50vh;
  margin: 0 auto;
  display: block;
  border-radius: 0;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  object-fit: contain;
  background: rgba(0, 0, 0, 0.15);
  image-orientation: from-image;
}

@media (max-width: 700px) {
  body.page-map:not(.page-peri) .replay-preview {
    padding: 0;
  }
  body.page-map:not(.page-peri) .replay-preview img {
    width: 100%;
    max-width: 100%;
    max-height: 50vh;
    margin: 0;
    border-radius: 0;
  }
}

/* peri.php: same as index.php (preview above map) */
body.page-map.page-peri .replay-preview {
  flex-shrink: 0;
  display: none;
  padding: 0;
  pointer-events: none;
  /* fixed peri topbar overlays the top edge; give the preview some space */
  margin-top: calc(env(safe-area-inset-top, 0px) + 70px);
}

body.page-map.page-peri .replay-preview img {
  width: 100%;
  max-width: 100%;
  max-height: 50vh;
  margin: 0;
  display: block;
  border-radius: 0;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  object-fit: contain;
  background: rgba(0, 0, 0, 0.15);
  image-orientation: from-image;
}

@media (max-width: 700px) {
  body.page-map.page-peri .replay-preview {
    padding: 0;
    margin-top: calc(env(safe-area-inset-top, 0px) + 70px);
  }
  body.page-map.page-peri .replay-preview img {
    width: 100vw;
    max-width: 100vw;
    max-height: 50vh;
    margin: 0;
    border-radius: 0;
  }
}

.page-map #imageOverlay .overlay-inner {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.page-map #imageOverlay img {
  max-width: 96vw;
  max-height: 92vh;
  border-radius: 14px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  transform-origin: center center;
  cursor: zoom-out;
  user-select: none;
  -webkit-user-drag: none;
  object-fit: contain;
  image-orientation: from-image;
}

.page-map #imageOverlay .zoom-btn {
  position: fixed;
  right: 16px;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(18, 24, 40, 0.85);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
}
.page-map #imageOverlay .zoom-in { top: 16px; }
.page-map #imageOverlay .zoom-out { top: 68px; }

.page-map #imageOverlay .close-hint {
  position: fixed;
  left: 16px;
  bottom: 16px;
  color: rgba(255, 255, 255, 0.85);
  font-size: 14px;
  background: rgba(0, 0, 0, 0.35);
  padding: 8px 10px;
  border-radius: 12px;
}

/* Prev/Next + Slideshow oben mittig */
.page-map #imageOverlay .top-center {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  align-items: center;
  z-index: 5003;
}

.page-map #imageOverlay .nav-btn,
.page-map #imageOverlay .play-btn {
  width: 48px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(18, 24, 40, 0.85);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
}
.page-map #imageOverlay .play-btn { width: 56px; font-size: 18px; }
.page-map #imageOverlay .nav-btn:disabled { opacity: 0.35; cursor: default; }

.page-map #imageOverlay .meta {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.92);
  font-size: 14px;
  background: rgba(0, 0, 0, 0.35);
  padding: 8px 10px;
  border-radius: 12px;
  z-index: 5003;
  max-width: 92vw;
  text-align: center;
  pointer-events: none;
}

.page-map #imageOverlay .comment {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.92);
  font-size: 18px;
  background: rgba(0, 0, 0, 0.45);
  padding: 10px 12px;
  border-radius: 12px;
  z-index: 5003;
  white-space: pre-wrap;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100vw;
  box-sizing: border-box;
}

.page-map #imageOverlay .comment-text {
  flex: 1 1 auto;
  white-space: pre-wrap;
}

.page-map #imageOverlay .comment-actions {
  display: flex;
  flex-shrink: 0;
  gap: 6px;
}

.page-map #imageOverlay .comment-actions button {
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(15, 23, 42, 0.8);
  color: #e5e7eb;
  padding: 4px 8px;
  font-size: 13px;
  cursor: pointer;
}

.page-map #imageOverlay .comment-actions button:hover {
  background: rgba(37, 99, 235, 0.9);
  border-color: rgba(37, 99, 235, 1);
}

@media (max-width: 768px) {
  .page-map #map { height: calc(100vh - 110px); }

  /* peri.php uses a fixed topbar and (during replay) a preview bar above the map */
  body.page-peri #map { height: auto !important; }

  .page-map #imageOverlay .zoom-btn { width: 38px; height: 38px; font-size: 18px; }

  .page-map #imageOverlay .nav-btn,
  .page-map #imageOverlay .play-btn {
    width: 40px;
    height: 38px;
    font-size: 18px;
  }

  .page-map #imageOverlay .meta { font-size: 13px; top: 64px; }

  .page-map #imageOverlay .comment {
    position: fixed;
    bottom: 62px;
    left: 50%;
    width: 90%;
    font-size: 15px;
  }

  .page-map #imageOverlay .close-hint { font-size: 12px; bottom: 10px; }
}

.page-map .titlebar, .page-album .titlebar { display: flex; align-items: center; gap: 12px; }
.page-map .icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid #1f2937;
  background: #020617;
  color: #e5e7eb;
  cursor: pointer;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.2);
}

.page-album .icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid #1f2937;
  background: #020617;
  color: #e5e7eb;
  cursor: pointer;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.2);
}

body.page-map.menu-collapsed header { padding: 10px 14px; }
body.page-map.menu-collapsed header form.controls { display: none; }
body.page-album.menu-collapsed header { padding: 10px 14px; }
body.page-album.menu-collapsed header form.controls { display: none; }

/* Album should use the same header layout, but hide map-only controls */
body.page-album .field-nearby,
body.page-album .field-autozoom,
body.page-album .field-follow,
body.page-album .field-showpictures {
  display: none;
}

.page-map .map-fs-btn {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 1200;
  width: 48px;
  height: 48px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(18, 24, 40, 0.85);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
}

.page-map .time-context-menu {
  position: absolute;
  z-index: 2000;
  min-width: 180px;
  background: #020617;
  border-radius: 10px;
  border: 1px solid #1f2937;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  font-size: 0.85rem;
  color: #e5e7eb;
}

.page-map .time-context-menu__header {
  padding: 6px 10px;
  border-bottom: 1px solid #1f2937;
  background: #0f172a;
  font-weight: 500;
}

.page-map .time-context-menu button {
  display: block;
  width: 100%;
  padding: 6px 10px;
  background: transparent;
  border: none;
  text-align: left;
  cursor: pointer;
  color: inherit;
}
.page-map .time-context-menu button:hover { background: #111827; }

/* Track edit submenu (orange bar under header) */
.page-map .track-edit-submenu {
  position: absolute;
  z-index: 2500;
  width: auto;
  background: transparent;
  color: #111827;
  padding: 0;
  top: 12px;
  left: 60px;
  pointer-events: none;
}

.page-map .track-edit-submenu__inner {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  background: #f59e0b;
  padding: 8px 10px;
  border-radius: 8px;
  pointer-events: auto;
}

/* Ensure the floating submenu is anchored to the map */
.page-map #map {
  position: relative;
}

.page-map .track-edit-submenu .spacer {
  display: none;
}

.page-map .track-edit-submenu .mode-btn.active {
  background: #2563eb;
  color: #ffffff;
}

.page-map .track-edit-submenu .mode-btn {
  background: #111827;
  color: #e5e7eb;
}

.page-map .track-edit-submenu .mode-btn:hover {
  background: #0b1220;
}

/* Save button should be gray (not black) */
.page-map .track-edit-submenu #trackEditSaveBtn {
  background: #e5e7eb !important;
  color: #111827 !important;
  border: 1px solid #111827 !important;
}

.page-map .track-edit-submenu #trackEditUndoBtn {
  background: #e5e7eb !important;
  color: #111827 !important;
  border: 1px solid #111827 !important;
}

.page-map .track-edit-submenu #trackEditSaveBtn:hover {
  filter: brightness(0.95);
}

.page-map .track-edit-submenu #trackEditUndoBtn:hover {
  filter: brightness(0.95);
}

.page-map .track-edit-submenu .insert-box {
  display: flex;
  align-items: center;
}

.page-map .track-edit-submenu .delete-box {
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-map .track-edit-submenu .source-box {
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-map .track-edit-submenu .source-box input[type="datetime-local"] {
  min-width: 185px;
}

/* Statistics submenu (orange bar content) */
.page-map .stats-submenu__inner {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  min-width: 780px;
  width: 780px;
  max-width: calc(100vw - 90px);
}

.page-map .stats-submenu__inner .stats-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.page-map .stats-submenu__inner .stats-title {
  font-weight: 700;
  color: #111827;
}

.page-map .stats-submenu__inner .stats-close {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(17, 24, 39, 0.35);
  color: #111827;
}

.page-map .stats-submenu__inner .stats-close:hover {
  background: rgba(17, 24, 39, 0.12);
}

.page-map .stats-content {
  color: #111827;
  font-size: 0.9rem;
  line-height: 1.35;
  max-height: 42vh;
  overflow: auto;
  overflow-x: auto;
}

.page-map .stats-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
  white-space: nowrap;
}

.page-map .stats-source {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.page-map .stats-icon {
  width: 22px;
  height: 22px;
  object-fit: contain;
  flex: 0 0 auto;
}

.page-map .stats-table td,
.page-map .stats-table th {
  padding: 4px 6px;
  text-align: left;
  vertical-align: top;
}

.page-map .stats-table th {
  font-weight: 700;
  border-bottom: 1px solid rgba(17, 24, 39, 0.35);
}

.page-map .stats-muted {
  opacity: 0.8;
}

body.page-map.map-fullscreen header,
body.page-map.map-fullscreen #messageBar {
  display: none;
}
body.page-map.map-fullscreen #map { height: 100vh !important; }

@media (max-width: 768px) {
  .page-map header { padding: 12px 14px; gap: 10px; }
  .page-map h1 { font-size: 1.25rem; }
  .page-map .controls { gap: 8px; }
  .page-map .field { gap: 3px; }
  .page-map label { font-size: 0.75rem; }
  .page-map input[type="datetime-local"],
  .page-map select { font-size: 14px; }

  .page-map #trackForm .field-from,
  .page-map #trackForm .field-to {
    flex: 1 1 calc(50% - 4px);
    min-width: 0;
  }
}

.page-map .userbar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-left: auto;
  font-size: 0.9rem;
}
.page-album .userbar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-left: auto;
  font-size: 0.9rem;
}
.page-map .userbar .logout {
  color: inherit;
  text-decoration: underline;
  opacity: 0.85;
}
.page-album .userbar .logout {
  color: inherit;
  text-decoration: underline;
  opacity: 0.85;
}

.page-map .navlinks,
.page-album .navlinks {
  display: flex;
  gap: 10px;
  align-items: center;
}

.page-map .navlinks .nav-link,
.page-album .navlinks .nav-link {
  color: inherit;
  text-decoration: underline;
  opacity: 0.9;
  white-space: nowrap;
}

.page-map .navlinks .nav-link[aria-current="page"],
.page-album .navlinks .nav-link[aria-current="page"] {
  text-decoration: none;
  opacity: 1;
}

/* Popup styles (Admin markers) */
.page-map .pic-popup { max-width: 260px; }
.page-map .pic-popup__title { font-size: 0.95rem; font-weight: 600; margin-bottom: 6px; }
.page-map .pic-popup__link { display: block; }
.page-map .pic-popup__img { max-width: 240px; max-height: 170px; display: block; border-radius: 10px; }
.page-map .pic-popup__comment {
  font-size: 0.9rem;
  margin-top: 6px;
  max-width: 240px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
}

/* =========================
   Page: Album
   ========================= */
body.page-album {
  --bg: #0b1020;
  --panel: #0f1730;
  --panel2: #121c39;
  --text: #e9edf7;
  --muted: rgba(233, 237, 247, 0.65);
  --border: rgba(233, 237, 247, 0.12);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --radius: 16px;

  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.page-album * { box-sizing: border-box; }

.page-album .topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 12px 12px;
  background: linear-gradient(180deg, rgba(11, 16, 32, 0.98), rgba(11, 16, 32, 0.86));
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}

.page-album .topbar .titlebar {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.page-album .topbar .controls {
  margin-top: 10px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

body.page-album.menu-collapsed .topbar form.controls { display: none; }

.page-album .topbar .title {
  font-weight: 700;
  font-size: 18px;
  margin-right: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-album .topbar .icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
}

.page-album .topbar .userbar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.9rem;
}

.page-album .topbar .userbar .logout {
  color: inherit;
  text-decoration: underline;
  opacity: 0.85;
}

.page-album .btn {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: none;
  transition: transform 0.08s ease, background 0.2s ease;
  user-select: none;
}

/* Ensure select/dropdown text is readable across browsers */
.page-album select.btn {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 36px;
  background-color: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.page-album select.btn option {
  background: var(--panel);
  color: var(--text);
}
.page-album .btn:active { transform: scale(0.98); }
.page-album .btn.primary {
  background: rgba(70, 130, 255, 0.25);
  border-color: rgba(70, 130, 255, 0.35);
}
.page-album .btn.link {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.page-album .topbar .field {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
}
.page-album .topbar .field label { font-size: 12px; color: var(--muted); }
.page-album .topbar input[type="datetime-local"] {
  background: transparent;
  border: 0;
  color: var(--text);
  font-size: 13px;
  outline: none;
}

.page-album .preset {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.page-album .container {
  padding: 12px;
  max-width: 1100px;
  margin: 0 auto;
}

.page-album .day-header {
  display: flex;
  gap: 10px;
  align-items: baseline;
  margin: 18px 4px 10px;
}
.page-album .day-header .day {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.2px;
}
.page-album .day-header .place {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 70vw;
}

.page-album .grid {
  display: grid;
  gap: 2px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-radius: 14px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.02);
  box-shadow: var(--shadow);
}
@media (min-width: 720px) {
  .page-album .grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 3px; }
}

.page-album .thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
}
.page-album .thumb.album-focus {
  box-shadow: inset 0 0 0 3px rgba(250, 204, 21, 0.95);
}
.page-album .thumb.album-focus::before {
  content: '';
  position: absolute;
  inset: 0;
  box-sizing: border-box;
  border: 3px solid rgba(250, 204, 21, 0.95);
  z-index: 3;
  pointer-events: none;
}
.page-album .thumb img {
  position: relative;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transform: scale(1.02);
}
.page-album .thumb::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.08));
  z-index: 1;
  pointer-events: none;
}

.page-album .status {
  margin: 16px 4px;
  color: var(--muted);
  font-size: 14px;
}

.page-album #imageOverlay {
  position: fixed;
  inset: 0;
  z-index: 5000;
  background: rgba(0, 0, 0, 0.82);
  display: none;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.page-album #imageOverlay.active { display: flex; }

.page-album #imageOverlay .overlay-inner {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.page-album #imageOverlay img {
  max-width: 96vw;
  max-height: 92vh;
  border-radius: 14px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  transform-origin: center center;
  cursor: zoom-out;
  user-select: none;
  -webkit-user-drag: none;
  object-fit: contain;
}

.page-album #imageOverlay .zoom-btn {
  position: fixed;
  right: 16px;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(18, 24, 40, 0.85);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
}
.page-album #imageOverlay .zoom-in { top: 16px; }
.page-album #imageOverlay .zoom-out { top: 68px; }

.page-album #imageOverlay .top-center {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  align-items: center;
  z-index: 5003;
}

.page-album #imageOverlay .nav-btn,
.page-album #imageOverlay .play-btn {
  width: 48px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(18, 24, 40, 0.85);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
}
.page-album #imageOverlay .play-btn { width: 56px; font-size: 18px; }
.page-album #imageOverlay .nav-btn:disabled { opacity: 0.35; cursor: default; }

.page-album #imageOverlay .meta {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.92);
  font-size: 14px;
  background: rgba(0, 0, 0, 0.35);
  padding: 8px 10px;
  border-radius: 12px;
  z-index: 5003;
  max-width: 92vw;
  text-align: center;
  pointer-events: none;
}

.page-album #imageOverlay .comment {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.92);
  font-size: 18px;
  background: rgba(0, 0, 0, 0.45);
  padding: 10px 12px;
  border-radius: 12px;
  z-index: 5003;
  white-space: pre-wrap;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100vw;
  box-sizing: border-box;
}

.page-album #imageOverlay .comment-text {
  flex: 1 1 auto;
  white-space: pre-wrap;
}

.page-album #imageOverlay .comment-actions {
  display: flex;
  flex-shrink: 0;
  gap: 6px;
}

.page-album #imageOverlay .comment-actions button {
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(15, 23, 42, 0.8);
  color: #e5e7eb;
  padding: 4px 8px;
  font-size: 13px;
  cursor: pointer;
}

.page-album #imageOverlay .comment-actions button:hover {
  background: rgba(37, 99, 235, 0.9);
  border-color: rgba(37, 99, 235, 1);
}

.page-album #imageOverlay .close-hint {
  position: fixed;
  left: 16px;
  bottom: 16px;
  color: rgba(255, 255, 255, 0.85);
  font-size: 14px;
  background: rgba(0, 0, 0, 0.35);
  padding: 8px 10px;
  border-radius: 12px;
}

@media (max-width: 768px) {
  .page-album #imageOverlay .zoom-btn { width: 38px; height: 38px; font-size: 18px; }

  .page-album #imageOverlay .nav-btn,
  .page-album #imageOverlay .play-btn {
    width: 40px;
    height: 38px;
    font-size: 18px;
  }

  .page-album #imageOverlay .meta { font-size: 13px; top: 64px; }

  .page-album #imageOverlay .comment {
    bottom: 62px;
    width: 90%;
    font-size: 15px;
  }

  .page-album #imageOverlay .close-hint { font-size: 12px; bottom: 10px; }
}

/* =========================
   Page: Auth portal
   ========================= */
body.page-auth {
  color-scheme: light dark;
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: #0b0f14;
  color: #e9eef6;
}

.page-auth *,
.page-auth *::before,
.page-auth *::after { box-sizing: border-box; }

.page-auth .wrap { max-width: 560px; margin: 0 auto; padding: 20px; }

.page-auth .card {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.page-auth h1 { font-size: 22px; margin: 0 0 14px; }

.page-auth .grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 860px) { .page-auth .grid { grid-template-columns: 1fr; } }

.page-auth label { display: block; font-size: 13px; opacity: 0.9; margin: 10px 0 6px; }

.page-auth input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.15);
  color: inherit;
  outline: none;
  box-sizing: border-box;
}

.page-auth input:focus {
  border-color: rgba(120, 190, 255, 0.7);
  box-shadow: 0 0 0 3px rgba(120, 190, 255, 0.15);
}

.page-auth button {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 0;
  background: #2e7cf6;
  color: white;
  font-weight: 650;
  cursor: pointer;
  margin-top: 12px;
}
.page-auth button:hover { filter: brightness(1.05); }

.page-auth .hint { font-size: 13px; opacity: 0.85; margin-top: 10px; }

.page-auth .msg {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid transparent;
}

.page-auth .msg.success { background: rgba(40, 170, 90, 0.16); border-color: rgba(40, 170, 90, 0.35); }
.page-auth .msg.error { background: rgba(220, 60, 60, 0.16); border-color: rgba(220, 60, 60, 0.35); }
.page-auth .msg.info { background: rgba(80, 120, 200, 0.14); border-color: rgba(80, 120, 200, 0.28); }

.page-auth a { color: #84b7ff; text-decoration: none; }
.page-auth a:hover { text-decoration: underline; }

.page-auth .topbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; }
.page-auth .pill {
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 13px;
}

.page-auth .row { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.page-auth .row input[type="checkbox"] { width: auto; height: 18px; }
