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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "DM Sans", Helvetica, Arial, sans-serif;
}

/* ── App layout ──────────────────────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: row;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#map-container {
  flex: 1 1 auto;
  position: relative;
  min-width: 0;
  min-height: 0;
}

#map {
  width: 100%;
  height: 100%;
}

/* ── Side panel ──────────────────────────────────────────────────────────── */
#side-panel {
  flex: 0 0 0;
  width: 0;
  overflow: hidden;
  background: #fff;
  box-shadow: -4px 0 24px rgba(0,0,0,0.12);
  transition: flex-basis 0.35s ease, width 0.35s ease;
  position: relative;
  z-index: 10;
}

#side-panel.open,
#side-panel.list-mode {
  flex-basis: 380px;
  width: 380px;
}

/* list-mode: show route list, hide detail content */
#side-panel.list-mode #panel-close,
#side-panel.list-mode #panel-content { display: none; }

/* open (detail): hide route list */
#side-panel.open #panel-route-list { display: none; }

/* ── Route list ──────────────────────────────────────────────────────────── */
#panel-route-list {
  flex: 1 1 auto;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.route-list-header {
  padding: 20px 20px 14px;
  border-bottom: 1px solid #f0f0f0;
  flex-shrink: 0;
}

.route-list-title {
  font-size: 15px;
  font-weight: 800;
  color: #111;
  margin-bottom: 2px;
}

.route-list-sub {
  font-size: 11px;
  color: #9ca3af;
  font-weight: 500;
}

.route-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 20px;
  background: none;
  border: none;
  border-bottom: 1px solid #f3f4f6;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s;
  font-family: "DM Sans", Helvetica, Arial, sans-serif;
}

.route-list-item:hover {
  background: #fdf2f3;
}

.route-list-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.route-list-info {
  flex: 1 1 auto;
  min-width: 0;
}

.route-list-name {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #111827;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.route-list-meta {
  display: block;
  font-size: 11px;
  color: #9ca3af;
  font-weight: 500;
  margin-top: 1px;
}

.route-list-arrow {
  color: #e5e7eb;
  font-size: 20px;
  flex-shrink: 0;
  transition: color 0.12s;
}

.route-list-item:hover .route-list-arrow {
  color: #fa4351;
}

#panel-inner {
  width: 380px;
  height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

#panel-close {
  position: sticky;
  top: 0;
  align-self: flex-end;
  margin: 12px 12px 0 0;
  padding: 0;
  background: #fff4f5;
  border: none;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  cursor: pointer;
  font-size: 13px;
  color: #fa4351;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
  z-index: 1;
}

#panel-close:hover {
  background: #fa4351;
  color: #fff;
}

/* ── Panel route content ─────────────────────────────────────────────────── */
#panel-content {
  flex: 1 1 auto;
}

.panel-route-header {
  padding: 16px 20px 14px;
  color: #fff;
  margin-top: -30px; /* slide behind the close button */
  padding-top: 46px;
}

.panel-route-title {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.2;
  margin: 6px 0 4px;
}

.panel-route-body {
  padding: 14px 20px 18px;
}

.panel-route-body .route-meta-row {
  margin-bottom: 10px;
}

.panel-route-body .route-highlight {
  margin-bottom: 14px;
}

/* ── Panel gallery ───────────────────────────────────────────────────────── */
.panel-gallery {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 0 20px 18px;
}

.gallery-thumb {
  position: relative;
  border: none;
  padding: 0;
  margin: 0;
  background: #f3f4f6;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  aspect-ratio: 4 / 3;
  display: block;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.gallery-thumb:hover {
  transform: scale(1.03);
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
}

.gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gallery-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 4px 8px 5px;
  background: linear-gradient(transparent, rgba(0,0,0,0.55));
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  text-align: center;
  line-height: 1.3;
}

/* ── Lightbox ────────────────────────────────────────────────────────────── */
#lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2000;
  align-items: center;
  justify-content: center;
}

#lightbox.open {
  display: flex;
}

#lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.82);
}

#lightbox-card {
  position: relative;
  max-width: min(92vw, 900px);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

#lightbox-img {
  max-width: 100%;
  max-height: 80vh;
  border-radius: 10px;
  display: block;
  object-fit: contain;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}

#lightbox-caption {
  color: rgba(255,255,255,0.85);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

#lightbox-nav {
  display: flex;
  gap: 16px;
}

#lb-prev, #lb-next {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  font-size: 28px;
  line-height: 1;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

#lb-prev:hover, #lb-next:hover {
  background: rgba(255,255,255,0.28);
}

#lb-close {
  position: absolute;
  top: -14px;
  right: -14px;
  background: #fa4351;
  border: none;
  color: #fff;
  font-size: 13px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

#lb-close:hover {
  background: #e0303e;
}

/* ── Panel layer toggles ─────────────────────────────────────────────────── */
#panel-layers {
  border-top: 1px solid #f0f0f0;
  padding: 14px 20px 20px;
  flex-shrink: 0;
}

.panel-layers-header {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fa4351;
  margin-bottom: 10px;
}

.panel-layer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  cursor: pointer;
  font-size: 13px;
  color: #2d3748;
  font-weight: 500;
}

.panel-layer-row:hover {
  color: #1a202c;
}

.panel-layer-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  flex-shrink: 0;
}

/* ── Colour swatch (shared by layer toggles) ─────────────────────────────── */
.layer-swatch {
  display: inline-block;
  width: 32px;
  height: 10px;
  border-radius: 4px;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.18);
}

/* ── Popups ──────────────────────────────────────────────────────────────── */
.leaflet-popup-content-wrapper {
  border-radius: 12px !important;
  box-shadow: 0 8px 30px rgba(0,0,0,0.18) !important;
  padding: 0 !important;
  overflow: hidden;
  min-width: 240px;
  max-width: 300px;
}

.leaflet-popup-content {
  margin: 0 !important;
  line-height: 1.5;
}

.leaflet-popup-tip-container {
  margin-top: -1px;
}

.popup-header {
  padding: 12px 16px 10px;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  line-height: 1.3;
}

.popup-body {
  padding: 10px 16px 14px;
  font-size: 12.5px;
  color: #374151;
  background: #fff;
}

.popup-body p {
  margin: 4px 0;
  display: flex;
  gap: 6px;
}

.popup-body .label {
  font-weight: 600;
  color: #6b7280;
  min-width: 68px;
  flex-shrink: 0;
}

.popup-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  margin-top: 6px;
  margin-right: 4px;
}

.popup-tag.green  { background: #d1fae5; color: #065f46; }
.popup-tag.amber  { background: #fef3c7; color: #92400e; }
.popup-tag.blue   { background: #dbeafe; color: #1e40af; }

/* ── Route info (shared popup + panel) ───────────────────────────────────── */
.route-header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 4px;
}

.route-country {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  opacity: 0.85;
}

.score-badge {
  font-size: 12px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 20px;
  background: rgba(255,255,255,0.25);
  color: #fff;
  letter-spacing: 0.02em;
  line-height: 1.4;
}
.score-high { background: rgba(255,255,255,0.30); }
.score-mid  { background: rgba(255,255,255,0.22); }
.score-low  { background: rgba(0,0,0,0.12); }
.score-base { background: rgba(0,0,0,0.18); }

.route-subtitle {
  font-size: 11px;
  color: rgba(255,255,255,0.80);
}

.route-meta-row {
  display: flex;
  gap: 12px;
  margin-bottom: 7px;
  font-size: 12px;
  color: #374151;
  font-weight: 500;
}

.route-highlight {
  font-size: 12px;
  color: #111827;
  font-weight: 600;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid #f0f0f0;
}

.route-counts {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

.route-count {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #f9fafb;
  border-radius: 7px;
  padding: 6px 4px;
  text-align: center;
}

.count-num {
  font-size: 13px;
  font-weight: 800;
  color: #fa4351;
  line-height: 1.2;
}

.count-lbl {
  font-size: 9.5px;
  color: #9ca3af;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 1px;
}

/* ── Property marker ─────────────────────────────────────────────────────── */
.property-marker {
  background: #7B2D8B;
  color: #fff;
  border-radius: 20px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  border: 2px solid rgba(255,255,255,0.9);
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  line-height: 1;
}

.property-marker:hover {
  background: #6a2278;
  transform: scale(1.05);
}

/* ── POI markers ─────────────────────────────────────────────────────────── */
.poi-marker {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,0.95);
  box-shadow: 0 2px 10px rgba(0,0,0,0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.poi-marker:hover {
  transform: scale(1.15);
}

.poi-marker svg {
  width: 15px;
  height: 15px;
  fill: #fff;
}

/* ── Photo pin markers ───────────────────────────────────────────────────── */
.photo-pin-marker {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--pin-color, #555);
  border: 3px solid #fff;
  box-shadow: 0 2px 12px rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.photo-pin-marker:hover {
  transform: scale(1.18);
  box-shadow: 0 4px 16px rgba(0,0,0,0.45);
}

.photo-pin-marker svg {
  width: 18px;
  height: 18px;
  fill: #fff;
}

/* ── Route hint ──────────────────────────────────────────────────────────── */
.map-hint {
  position: absolute;
  bottom: 36px;
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  border-radius: 999px;
  padding: 10px 20px 10px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #111;
  box-shadow: 0 4px 24px rgba(0,0,0,0.14);
  z-index: 500;
  opacity: 0;
  transition: opacity 0.5s ease;
  pointer-events: none;
  white-space: nowrap;
  border: 1.5px solid #f3f4f6;
}

.map-hint.visible {
  opacity: 1;
}

.map-hint-icon {
  display: inline-block;
  font-size: 16px;
  animation: tap 1.4s ease-in-out infinite;
  transform-origin: bottom center;
}

@keyframes tap {
  0%, 60%, 100% { transform: translateY(0) rotate(0deg); }
  30%            { transform: translateY(4px) rotate(-8deg); }
}

/* ── Attribution ─────────────────────────────────────────────────────────── */
.leaflet-control-attribution {
  font-size: 10px !important;
  background: rgba(255,255,255,0.8) !important;
  border-radius: 4px 0 0 0 !important;
}

/* ── Loading state ───────────────────────────────────────────────────────── */
.map-loader {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(2px);
  z-index: 1200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.map-loader.visible {
  display: flex;
}

.map-loader-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #fff;
  color: #1f2937;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  font-size: 13px;
  font-weight: 600;
}

.map-loader.error .map-loader-card {
  background: #7f1d1d;
  color: #fff;
}

.map-loader-spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #e5e7eb;
  border-top-color: #fa4351;
  animation: spin 0.8s linear infinite;
}

.map-loader.error .map-loader-spinner {
  display: none;
}

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

/* ── Mobile layout ───────────────────────────────────────────────────────── */
/* ── Tab (mobile only) ───────────────────────────────────────────────────── */
#panel-tab {
  display: none;
}

@media (max-width: 768px) {
  #app {
    flex-direction: column;
  }

  #side-panel {
    flex-basis: 44px;
    width: 100%;
    height: 44px;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.10);
    transition: flex-basis 0.35s ease, height 0.35s ease;
  }

  #side-panel.list-mode,
  #side-panel.open {
    flex-basis: 55vh;
    width: 100%;
    height: 55vh;
  }

  #side-panel.open #panel-tab {
    display: none;
  }

  #panel-inner {
    width: 100%;
  }

  #panel-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    height: 44px;
    flex-shrink: 0;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    transition: background 0.15s;
  }

  #panel-tab:hover,
  #panel-tab:active {
    background: #fdf2f3;
  }

  .panel-tab-handle {
    width: 36px;
    height: 4px;
    background: #e5e7eb;
    border-radius: 2px;
  }

  .panel-tab-label {
    font-size: 10px;
    font-weight: 700;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.08em;
  }
}

/* ── Stays by town markers ────────────────────────────────────────────────── */
.stays-pin {
  background: #fa4351;
  color: #fff;
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  font-weight: 700;
  border-radius: 12px;
  padding: 3px 8px;
  white-space: nowrap;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
  border: 2px solid #fff;
  cursor: pointer;
}
.stays-popup {
  font-family: 'DM Sans', sans-serif;
  padding: 4px 2px;
}
.stays-popup strong {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: #111;
  margin-bottom: 4px;
}
.stays-popup span {
  font-size: 12px;
  color: #6b7280;
}
.leaflet-popup-content-wrapper {
  border-radius: 10px !important;
  border: 1.5px solid #fa4351 !important;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12) !important;
  font-family: 'DM Sans', sans-serif;
  padding: 0 !important;
  overflow: hidden;
}
.leaflet-popup-content {
  margin: 12px 16px !important;
  font-family: 'DM Sans', sans-serif;
}
