/* ============================================================================
   UNIFIED THEME SYSTEM - Edit colors, fonts, and UI elements here
   ============================================================================
   
   This is the single source of truth for all UI styling. Changes here
   cascade throughout the entire application.
   
   To customize:
   1. Modify color values below
   2. All CSS, JavaScript, and Python files reference these variables
   3. Reload the page to see changes
*/

:root {
  /* ========== PRIMARY BRAND COLORS ========== */
  --color-primary: #198225;
  --color-primary-dark: #105C1D;
  --color-primary-light: #B6B944;
  --color-secondary: #B6B944;
  --color-secondary-hover: #9FA030;
  
  /* ========== BACKWARD COMPATIBILITY ALIASES ========== */
  --primary: var(--color-primary);
  --primary-dark: var(--color-primary-dark);
  --primary-light: var(--color-primary-light);
  --secondary: var(--color-secondary);
  --secondary-hover: var(--color-secondary-hover);
  
  /* ========== MARKER/ICON COLORS ========== */
  --color-campsite: #198225;
  --color-campsite-icon-size: 14px;
  
  --color-station: #131313;
  --color-station-icon-size: 14px;
  
  --color-supermarket: #B6B944;
  --color-supermarket-icon-size: 11px;
  
  --color-bakery: #FAD200;
  --color-bakery-icon-size: 11px;
  
  --color-pub: #FF3331;
  --color-pub-icon-size: 11px;
  
  --color-restaurant: #FF752E;
  --color-restaurant-icon-size: 11px;
  
  --color-tourist-info: #0101FF;
  --color-tourist-info-icon-size: 11px;
  
  /* ========== REGION BOUNDARY COLORS ========== */
  --color-region-outline: #B6B944;
  --color-region-outline-hover: #198225;
  --color-region-outline-persistent: var(--color-primary-light);
  --region-outline-weight: 0.6;
  --region-outline-weight-hover: 1.8;
  --region-outline-opacity: 0;
  --region-outline-opacity-hover: 1.0;
  --region-fill-color: transparent;
  --region-fill-opacity: 0;
  --region-fill-opacity-hover: 0.05;
  --region-persistent-weight: 1.0;
  --region-persistent-opacity: 0.2;
  
  /* ========== RAIL/TRAJECTORY COLORS ========== */
  --rail-stroke-color: #131313;
  --rail-stroke-weight: 1.2;
  --rail-stroke-opacity: 0.6;
  --rail-interactive-color: #FF752E;
  --rail-interactive-weight: 8;
  --rail-interactive-opacity: 0;
  
  /* ========== MAP VISUAL EFFECTS ========== */
  --map-filter-hue-rotate: -30deg;
  --map-filter-saturate: 1.05;
  --map-filter-brightness: 1.02;
  --map-filter-contrast: 1.005;
  --map-vintage-filter: hue-rotate(var(--map-filter-hue-rotate)) saturate(var(--map-filter-saturate)) brightness(var(--map-filter-brightness)) contrast(var(--map-filter-contrast));
  
  /* ========== TEXT COLORS ========== */
  --text-dark: #131313;
  --text-light: #ffffff;
  --text-muted: #777;
  --text-secondary: #556;
  --text-heading: #198225;
  
  /* ========== BACKGROUND & SURFACE COLORS ========== */
  --bg-light: #f9fcf7;
  --bg-hover: #e8f1dd;
  --bg-white: #ffffff;
  --bg-light-overlay: rgba(255, 255, 255, 0.95);
  
  /* ========== BORDER COLORS ========== */
  --border-light: #e8e8e8;
  --border-lighter: #ddecd8;
  --border-input: #d6e8ce;
  --border-error: #FF3331;
  --border-warning: #FAD200;
  --border-success: var(--color-secondary);
  
  /* ========== SHADOW DEFINITIONS ========== */
  --shadow-sm: 0 1px 2px rgba(79, 115, 2, 0.04);
  --shadow-md: 0 2px 6px rgba(79, 115, 2, 0.15);
  --shadow-lg: 0 4px 12px rgba(79, 115, 2, 0.25);
  --shadow-xl: 0 14px 40px rgba(12, 36, 8, 0.06);
  
  /* ========== FOCUS & INTERACTIVE COLORS ========== */
  --focus-color: #0101FF;
  --focus-shadow: rgba(10, 124, 255, 0.25);
  --focus-outline: 3px solid;
  
  /* ========== STATUS/FEEDBACK COLORS ========== */
  --color-error: #FF3331;
  --color-warning: #FAD200;
  --color-success: var(--color-secondary);
  --color-info: #0101FF;
  
  /* ========== TRANSITIONS & ANIMATIONS ========== */
  --transition-fast: all 0.15s ease;
  --transition-normal: all 0.2s ease;
  --transition-slow: all 0.3s ease;
  --transition-smooth: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  
  /* ========== FONT FAMILY ========== */
  --font-primary: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-system: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  
  /* ========== SIZING & SPACING ========== */
  --size-touch-target: 44px;
  --size-min-width: 200px;
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 12px;
  --spacing-lg: 16px;
  --spacing-xl: 20px;
  --spacing-2xl: 24px;
  
  /* ========== BORDER RADIUS ========== */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  
  /* ========== ZINDEX STACK ========== */
  --z-dropdown: 100;
  --z-sticky: 500;
  --z-fixed: 1000;
  --z-modal: 1100;
  --z-popover: 1200;
  --z-tooltip: 1300;
  --z-notification: 2000;
  
  /* ========== POPUP SPECIFIC STYLES ========== */
  --popup-content-max-width: 420px;
  --popup-title-font-size: 16px;
  --popup-title-font-weight: 700;
  --popup-section-title-font-size: 13px;
  --popup-section-title-font-weight: 700;
  --popup-entry-font-size: 13px;
  --popup-entry-padding: 10px 12px;
  --popup-entry-gap: 4px;
  --popup-entry-max-height: 160px;
  
  --popup-section-border-width: 2px;
  --popup-entry-border-left-width: 3px;
  --popup-entry-border-width: 1px;
  
  --popup-section-border-color: var(--color-primary);
  --popup-entry-border-color: var(--border-light);
  --popup-entry-border-left-color: var(--color-primary);
  --popup-entry-hover-background: var(--bg-hover);
  
  /* ========== POPUP SECTION SPACING ========== */
  --popup-section-margin-top: 8px;
  --popup-section-margin-bottom: 0px;
  --popup-section-first-margin-top: 0px;
  --popup-subtitle-margin-top: 4px;
  --popup-subtitle-margin-bottom: 6px;
  --popup-info-block-margin-top: 12px;
  --popup-info-block-padding-top: 12px;
  --popup-info-block-border-top: 3px solid var(--color-primary);
  --popup-buttons-gap: 8px;
  --popup-buttons-margin-bottom: 8px;
  --popup-info-item-margin-top: 8px;
  
  /* ========== POPUP CONTAINER ========== */
  --popup-content-padding: 16px;
  --popup-content-max-width: 380px;
  --popup-content-max-height: 400px;
  --popup-border-radius: 8px;
  
  /* ========== POPUP TITLE ========== */
  --popup-title-font-size: 16px;
  --popup-title-font-weight: 700;
  --popup-title-color: var(--text-dark);
  --popup-title-margin-bottom: 14px;
  --popup-title-padding-bottom: 12px;
  --popup-title-border-width: 2px;
  --popup-title-border-color: var(--color-primary);
  
  /* ========== POPUP SUBTITLE ========== */
  --popup-subtitle-font-size: 11px;
  --popup-subtitle-font-weight: 700;
  --popup-subtitle-color: var(--color-primary);
  --popup-subtitle-text-transform: uppercase;
  --popup-subtitle-letter-spacing: 0.6px;
  
  /* ========== POPUP LIST ========== */
  --popup-list-gap: 6px;
  --popup-list-item-padding: 10px 12px;
  --popup-list-item-border-radius: 6px;
  --popup-list-item-font-size: 12px;
  --popup-list-item-border: 1px solid var(--border-light);
  --popup-list-item-border-left: 3px solid var(--color-primary);
  --popup-list-item-background: var(--bg-light);
  --popup-list-item-color: var(--text-dark);
  --popup-list-item-box-shadow: 0 1px 3px rgba(79,115,2,0.08);
  
  /* ========== POPUP LIST HOVER ========== */
  --popup-list-item-hover-background: var(--bg-hover);
  --popup-list-item-hover-box-shadow: 0 2px 6px rgba(79,115,2,0.15);
  
  /* ========== POPUP BUTTONS ========== */
  --popup-button-padding: 9px 12px;
  --popup-button-font-size: 11px;
  --popup-button-font-weight: 600;
  --popup-button-border-radius: 5px;
  --popup-button-min-height: 36px;
  --popup-button-gap: 6px;
  --popup-button-primary-background: #B6B944;
  --popup-button-primary-color: #fff;
  --popup-button-primary-shadow: 0 2px 4px rgba(79, 115, 2, 0.2);
  --popup-button-primary-hover-shadow: 0 4px 12px rgba(79, 115, 2, 0.3);
  --popup-button-secondary-background: #198225;
  --popup-button-secondary-color: #fff;
  --popup-button-secondary-shadow: 0 2px 4px rgba(45, 157, 126, 0.15);
  --popup-button-secondary-hover-shadow: 0 4px 12px rgba(45, 157, 126, 0.3);
  
  /* ========== POPUP DISTANCE/METADATA ========== */
  --popup-distance-color: var(--text-muted);
  --popup-distance-font-size: 11px;
  --popup-distance-font-weight: 600;
  --popup-entry-hover-border-color: var(--color-primary);
  
  --popup-shadow: 0 6px 20px rgba(79, 115, 2, 0.15);
  --popup-shadow-secondary: 0 2px 4px rgba(0, 0, 0, 0.06);
  --popup-shadow-combined: 0 6px 20px rgba(79, 115, 2, 0.15), 0 2px 4px rgba(0, 0, 0, 0.06);
  
  --popup-scrollbar-gradient-start: #B6B944;
  --popup-scrollbar-gradient-end: #198225;
  
  /* ========== POPUP LIST STYLES ========== */
  --relation-list-border-radius: 0;
  --relation-list-flex-direction: column;
  --relation-entry-border-radius: 6px;
}

/* ========== APPLIED TO COMMON ELEMENTS ========== */

* {
  box-sizing: border-box;
}

body {
  font-family: var(--font-primary);
  color: var(--text-dark);
  background: var(--bg-light);
}

/* ========== SCROLLBAR STYLING ========== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(79, 115, 2, 0.05);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--color-primary);
  border-radius: 4px;
  border: 2px solid rgba(79, 115, 2, 0.1);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-primary-dark);
}

/* Firefox scrollbar */
* {
  scrollbar-color: var(--color-primary) rgba(79, 115, 2, 0.05);
  scrollbar-width: thin;
}

/* ========== BUTTON BASE STYLES ========== */
button,
input[type="button"],
input[type="submit"] {
  background: var(--color-primary);
  color: var(--text-light);
  border: none;
  border-radius: var(--radius-lg);
  padding: var(--spacing-md) var(--spacing-lg);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition-fast);
  box-shadow: var(--shadow-md);
  min-height: var(--size-touch-target);
  display: flex;
  align-items: center;
  justify-content: center;
}

button:hover {
  background: var(--color-primary-dark);
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
  box-shadow: var(--shadow-md);
}

button:focus-visible {
  outline: var(--focus-outline) var(--focus-color);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--focus-shadow);
}

/* ========== INPUT BASE STYLES ========== */
input[type="text"],
input[type="search"],
input[type="email"],
input[type="password"],
select,
textarea {
  padding: var(--spacing-md) var(--spacing-lg);
  border: 2px solid var(--border-input);
  border-radius: var(--radius-lg);
  font-family: var(--font-primary);
  font-size: 14px;
  color: var(--text-dark);
  background: var(--bg-white);
  transition: var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

input[type="text"]:hover,
input[type="search"]:hover,
select:hover,
textarea:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
}

input[type="text"]:focus,
input[type="search"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(79, 115, 2, 0.1), var(--shadow-md);
}

/* ========== LINKS ========== */
a {
  color: var(--color-primary);
  text-decoration: none;
  transition: var(--transition-fast);
  cursor: pointer;
}

a:hover {
  color: var(--color-primary-dark);
  text-decoration: underline;
}

a:focus-visible {
  outline: var(--focus-outline) var(--focus-color);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ========== HEADINGS ========== */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-heading);
  font-weight: 700;
  margin-top: 1.5em;
  margin-bottom: 0.5em;
}

h1 { font-size: 24px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
h4 { font-size: 14px; }

/* ========== UNIFIED POPUP STYLING ========== */
.popup-content,
.leaflet-popup-content {
  max-width: var(--popup-content-max-width);
  padding: var(--spacing-lg);
  font-family: var(--font-system);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-dark);
  scrollbar-width: thin;
  scrollbar-color: var(--popup-scrollbar-gradient-start) var(--bg-light);
}

.popup-content::-webkit-scrollbar,
.leaflet-popup-content::-webkit-scrollbar {
  width: 8px;
  height: 8px;
  background: var(--bg-light);
  border-radius: 4px;
}

.popup-content::-webkit-scrollbar-thumb,
.leaflet-popup-content::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--popup-scrollbar-gradient-start) 0%, var(--popup-scrollbar-gradient-end) 100%);
  border-radius: 4px;
  box-shadow: inset 0 0 2px rgba(79, 115, 2, 0.3);
}

.popup-content::-webkit-scrollbar-thumb:hover,
.leaflet-popup-content::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, var(--popup-scrollbar-gradient-end) 0%, #1f2d00 100%);
}

/* ========== POPUP TITLE ========== */
.popup-title {
  font-weight: var(--popup-title-font-weight);
  font-size: var(--popup-title-font-size);
  color: var(--text-dark);
  margin-bottom: var(--spacing-md);
  padding-bottom: var(--spacing-md);
  border-bottom: var(--popup-section-border-width) solid var(--popup-section-border-color);
  line-height: 1.3;
}

/* Rail popup titles (Trajecten) use bright green underline */
.popup-title.rail-popup {
  border-bottom-color: #198225;
}

/* ========== POPUP SECTION TITLES =========== */
.relation-section-title,
.popup-section-title {
  font-weight: var(--popup-section-title-font-weight);
  color: var(--text-dark);
  font-size: var(--popup-section-title-font-size);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: var(--spacing-md);
  padding-bottom: var(--spacing-md);
  border-bottom: var(--popup-section-border-width) solid var(--popup-section-border-color);
  margin-top: 0;
}

/* make relation heading look like a real popup title */
.relation-section-title,
.popup-title {
  font-size: var(--popup-title-font-size);
  font-weight: var(--popup-title-font-weight);
  color: var(--color-primary);
  margin-bottom: var(--spacing-sm);
  padding-bottom: var(--spacing-xs);
  border-bottom: 2px solid var(--color-primary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

/* ========== PROMINENT RELATION ENTRY STYLE ========== */
.relation-entry,
.popup-entry {
  margin-top: var(--popup-entry-gap);
  margin-bottom: var(--popup-entry-gap);
  padding: var(--popup-entry-padding);
  background: #f7fff3;
  border-left: 4px solid var(--color-primary);
  border-radius: var(--relation-entry-border-radius);
  line-height: 1.4;
  cursor: pointer;
  text-decoration: none;
  color: var(--text-dark) !important;
  font-size: var(--popup-entry-font-size);
  border: var(--popup-entry-border-width) solid var(--popup-entry-border-color);
  box-shadow: var(--shadow-sm);
  transition: var(--transition-fast);
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
}

.relation-entry:hover,
.popup-entry:hover,
.relation-entry:focus,
.popup-entry:focus {
  background: #e8f7de;
  border-color: var(--color-primary);
  border-left-color: var(--color-primary);
  box-shadow: var(--shadow-md);
}

.relation-entry.active {
  background: #deefd7;
  border-color: var(--color-primary);
  border-left-color: var(--color-primary);
}

.relation-entry .popup-distance,
.popup-entry .popup-distance {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
  justify-self: end;
  align-self: center;
}

.relation-entry span:first-child {
  display: inline-block;
  word-break: break-word;
  overflow-wrap: break-word;
  align-self: center;
}

/* ========== POPUP ENTRIES (Relations, Routes, etc.) ========== */
.relation-entry,
.popup-entry {
  margin-top: var(--popup-entry-gap);
  margin-bottom: var(--popup-entry-gap);
  padding: var(--popup-entry-padding);
  background: var(--bg-light);
  border-left: var(--popup-entry-border-left-width) solid var(--popup-entry-border-left-color);
  border-radius: var(--relation-entry-border-radius);
  line-height: 1.4;
  cursor: pointer;
  text-decoration: none;
  color: var(--text-dark) !important;
  font-size: var(--popup-entry-font-size);
  border: var(--popup-entry-border-width) solid var(--popup-entry-border-color);
  box-shadow: var(--shadow-sm);
  transition: var(--transition-fast);
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto;
  align-items: start;
  gap: 6px;
}

.relation-entry:hover,
.popup-entry:hover {
  background: var(--popup-entry-hover-background);
  border-color: var(--popup-entry-hover-border-color);
  border-left-color: var(--popup-entry-hover-border-color);
  text-decoration: none;
  box-shadow: var(--shadow-md);
}

.relation-entry:first-of-type {
  margin-top: 0;
}

.relation-entry:last-of-type {
  margin-bottom: 0;
}

/* ========== RELATION LIST CONTAINER ========== */
.relation-list {
  max-height: var(--popup-entry-max-height);
  overflow-y: auto;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: var(--relation-list-flex-direction);
  gap: var(--popup-entry-gap);
  scrollbar-width: thin;
  scrollbar-color: var(--popup-scrollbar-gradient-start) var(--bg-light);
}

.relation-list::-webkit-scrollbar {
  width: 8px;
  background: var(--bg-light);
  border-radius: 4px;
}

.relation-list::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--popup-scrollbar-gradient-start) 0%, var(--popup-scrollbar-gradient-end) 100%);
  border-radius: 4px;
  box-shadow: inset 0 0 2px rgba(79, 115, 2, 0.3);
}

.relation-list::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, var(--popup-scrollbar-gradient-end) 0%, #1f2d00 100%);
}

/* ========== POPUP SUB-COMPONENTS ========== */
.popup-subtitle {
  font-size: 11px;
  color: var(--color-primary);
  margin-top: 12px;
  margin-bottom: var(--spacing-sm);
}

.popup-header {
  font-weight: 700;
  font-size: 13px;
  color: var(--text-dark);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: var(--spacing-md);
  padding-bottom: var(--spacing-md);
  border-bottom: 2px solid var(--color-primary);
  margin-top: 0;
}

.popup-header strong {
  font-weight: 700;
}

.popup-info-item {
  font-size: 12px;
  padding: var(--spacing-sm);
  border-radius: var(--radius-md);
  transition: var(--transition-fast);
}

.popup-info-item:hover {
  background: var(--bg-hover);
  color: var(--color-primary);
}

.relation-entry .popup-distance {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
  justify-self: end;
  align-self: center;
}

.relation-entry span:first-child {
  display: inline-block;
  word-break: break-word;
  overflow-wrap: break-word;
  align-self: center;
}

.relation-entry,
.popup-entry {
  align-items: center;
}

.no-relations {
  color: var(--text-muted);
  font-style: italic;
  font-size: var(--popup-entry-font-size);
}

/* ========== LEAFLET POPUP WRAPPER ========== */
.leaflet-popup-content-wrapper {
  border-radius: var(--radius-lg);
  box-shadow: var(--popup-shadow-combined);
  padding: 0 !important;
}

.leaflet-popup-content {
  margin: 0 !important;
  padding: var(--spacing-lg) !important;
}

.leaflet-popup-tip {
  background: var(--text-light) !important;
}

/* ========== ACCESSIBILITY FOCUS STATES ========== */
.popup-content:focus,
.relation-entry:focus {
  outline: var(--focus-outline) var(--focus-color);
  outline-offset: 2px;
}

/* ========== POPUP & MARKER INTERACTIONS ==================== */
.leaflet-marker { outline: none !important; background: none !important; border: none !important; cursor: pointer; }
.leaflet-marker:focus { outline: none !important; }
.leaflet-marker:active { outline: none !important; }
.leaflet-interactive { outline: none !important; }
.leaflet-interactive:focus { outline: none !important; }

.leaflet-marker-icon { 
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); 
    outline: none !important; 
    border: none !important; 
    box-shadow: none !important; 
    background: none !important; 
    cursor: pointer;
}

.leaflet-marker-icon:focus { outline: none !important; border: none !important; box-shadow: none !important; }
.leaflet-marker-icon:active { outline: none !important; border: none !important; box-shadow: none !important; }

/* Clicked marker animation */
.leaflet-marker-icon.marker-clicked { 
    filter: drop-shadow(0 8px 16px rgba(79, 115, 2, 0.35)) drop-shadow(0 4px 8px rgba(79, 115, 2, 0.25)); 
    animation: none !important;
    transform: none !important;
    z-index: 1200 !important;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes markerClickPulse {
    0% { transform: scale(1) translateY(0); filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1)); }
    50% { transform: scale(1.25) translateY(-8px); filter: drop-shadow(0 8px 16px rgba(79, 115, 2, 0.4)); }
    100% { transform: scale(1.08) translateY(-3px); filter: drop-shadow(0 6px 12px rgba(79, 115, 2, 0.3)); }
}

.leaflet-marker-icon { 
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1); 
    outline: none !important; 
    border: none !important; 
    box-shadow: none !important; 
    background: none !important; 
    cursor: pointer;
    will-change: transform, filter;
    transform-origin: center center;
    pointer-events: auto !important;
}

.leaflet-marker-icon:focus { outline: none !important; border: none !important; box-shadow: none !important; }
.leaflet-marker-icon:active { outline: none !important; border: none !important; box-shadow: none !important; }

.marker-icon-wrapper { 
    width: 20px; 
    height: 20px; 
    display: flex !important; 
    align-items: center; 
    justify-content: center; 
    background: transparent; 
    border-radius: 50%; 
    box-shadow: none; 
    border: none; 
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1); 
    position: relative; 
    outline: none !important; 
    cursor: pointer; 
    visibility: visible !important; 
    opacity: 1 !important; 
    will-change: transform, background, box-shadow;
    transform-origin: center center;
    pointer-events: none;
}

.marker-icon-wrapper:not(.animated) { 
    animation: fadeInScale 0.25s ease-out forwards; 
}

.marker-icon-wrapper.animated { 
    opacity: 1 !important;
    transform: scale(1) !important;
}

.leaflet-marker-icon.marker-inactive { 
    opacity: 0.35; 
    filter: grayscale(0.9); 
}

.leaflet-marker-icon.marker-inactive:hover { 
    opacity: 0.5; 
    filter: grayscale(0.7);
}

/* ========== POPUP CONTENT ==================== */
.popup-content { 
    max-width: var(--popup-content-max-width); 
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    padding: var(--popup-content-padding);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--color-primary) var(--bg-light);
}

.popup-content::-webkit-scrollbar {
    width: 8px;
}

.popup-content::-webkit-scrollbar-track {
    background: var(--bg-light);
    border-radius: 4px;
}

.popup-content::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    border-radius: 4px;
    transition: background 0.2s ease;
    box-shadow: inset 0 0 2px rgba(79,115,2,0.3);
}

.popup-content::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, var(--color-primary-dark) 0%, #1f2d00 100%);
}

.leaflet-popup-content { 
    overflow-y: auto; 
    overflow-x: hidden; 
    scrollbar-width: thin; 
    scrollbar-color: var(--color-primary) var(--bg-light); 
    max-height: var(--popup-content-max-height);
}

.leaflet-popup-content::-webkit-scrollbar { 
    width: 8px; 
}

.leaflet-popup-content::-webkit-scrollbar-track { 
    background: var(--bg-light); 
    border-radius: 4px;
}

.leaflet-popup-content::-webkit-scrollbar-thumb { 
    background: linear-gradient(180deg, var(--color-primary) 0%, var(--color-primary-dark) 100%); 
    border-radius: 4px; 
    transition: background 0.2s ease;
    box-shadow: inset 0 0 2px rgba(79,115,2,0.3);
}

.leaflet-popup-content::-webkit-scrollbar-thumb:hover { 
    background: linear-gradient(180deg, var(--color-primary-dark) 0%, #1f2d00 100%);
}

/* ========== POPUP TYPOGRAPHY ==================== */
.popup-title { 
    font-weight: var(--popup-title-font-weight); 
    font-size: var(--popup-title-font-size); 
    color: var(--popup-title-color); 
    margin-bottom: var(--popup-title-margin-bottom); 
    padding-bottom: var(--popup-title-padding-bottom); 
    border-bottom: var(--popup-title-border-width) solid var(--popup-title-border-color); 
    line-height: 1.3;
}

.popup-title a { 
    font-weight: 700; 
    font-size: 15px; 
    color: var(--text-dark) !important; 
    text-decoration: none !important;
    transition: color 0.2s ease;
}

.popup-title a:hover { 
    color: var(--color-secondary) !important; 
}

.popup-title a:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
    border-radius: 2px;
}

.popup-stars { 
    color: var(--color-primary); 
    font-size: 12px; 
    margin-left: 8px; 
    white-space: nowrap; 
    flex-shrink: 0; 
}

/* ========== POPUP SECTIONS & SUBTITLES ==================== */
.popup-section {
    margin-top: var(--popup-section-margin-top);
    margin-bottom: var(--popup-section-margin-bottom);
    padding-top: 0;
    padding-bottom: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.popup-section:first-of-type { margin-top: var(--popup-section-first-margin-top); }
.popup-section:last-of-type { margin-bottom: 0; }

.popup-subtitle {
    font-weight: var(--popup-subtitle-font-weight);
    margin-bottom: var(--popup-subtitle-margin-bottom);
    color: var(--popup-subtitle-color);
    font-size: var(--popup-subtitle-font-size);
    text-transform: var(--popup-subtitle-text-transform);
    letter-spacing: var(--popup-subtitle-letter-spacing);
    padding-left: 0;
    margin-top: var(--popup-subtitle-margin-top);
}

.relation-section-title {
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--color-primary);
    font-size: 16px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding-left: 0;
    padding-bottom: 4px;
    border-bottom: 2px solid var(--color-primary);
    margin-top: 0;
    display: block;
}

/* ========== POPUP LISTS ==================== */
.popup-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--popup-list-gap);
}

.popup-list li { 
    margin: 0; 
    padding: 0; 
}

.popup-list li:last-child { 
    margin-bottom: 0; 
}

.popup-list a { 
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: center;
    padding: var(--popup-list-item-padding); 
    border-radius: var(--popup-list-item-border-radius); 
    background: var(--popup-list-item-background); 
    text-decoration: none; 
    color: var(--popup-list-item-color) !important; 
    font-size: var(--popup-list-item-font-size); 
    border: var(--popup-list-item-border);
    border-left: var(--popup-list-item-border-left);
    line-height: 1.3;
    cursor: pointer;
    box-shadow: var(--popup-list-item-box-shadow); 
    transition: var(--transition-fast);
}

.popup-list a:hover { 
    background: var(--popup-list-item-hover-background); 
    border-color: var(--color-primary);
    border-left-color: var(--color-primary);
    text-decoration: none; 
    box-shadow: var(--popup-list-item-hover-box-shadow);
}

.popup-list a:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(79,115,2,0.2);
}

.popup-distance { 
    color: var(--popup-distance-color); 
    font-size: var(--popup-distance-font-size); 
    font-weight: var(--popup-distance-font-weight); 
    white-space: nowrap;
    text-align: right;
}

/* ========== POPUP BUTTONS ==================== */
.popup-info-block { 
    margin-top: 12px; 
    padding-top: 12px; 
    margin-bottom: 0; 
    border-top: 3px solid var(--color-primary);
}

.popup-buttons { 
    display: flex; 
    gap: 8px; 
    margin-bottom: 8px; 
    margin-top: 0;
    flex-direction: column; 
    align-items: stretch;
    justify-content: flex-start;
    width: 100%;
}

.popup-buttons a { 
    display: flex;
    width: 100%;
    text-decoration: none;
}

.popup-buttons a:hover { 
    text-decoration: none;
}

.popup-buttons a:active {
    text-decoration: none;
}

.popup-buttons a:focus {
    outline: none;
}

button.popup-cta { 
    padding: var(--popup-button-padding); 
    cursor: pointer;
    text-decoration: none;
    color: var(--popup-button-primary-color) !important;
    font-size: var(--popup-button-font-size);
    background: var(--popup-button-primary-background);
    border: none;
    border-radius: var(--popup-button-border-radius);
    box-shadow: var(--popup-button-primary-shadow);
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    font-weight: var(--popup-button-font-weight);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    white-space: normal;
    word-break: break-word;
    line-height: 1.3;
    gap: var(--popup-button-gap);
    flex-wrap: wrap;
    min-height: var(--popup-button-min-height);
    transform: scale(1);
}

button.popup-cta.secondary { 
    background: var(--popup-button-secondary-background);
    color: var(--popup-button-secondary-color) !important;
    box-shadow: var(--popup-button-secondary-shadow);
}

button.popup-cta:hover { 
    transform: scale(1.02) translateY(-2px);
    box-shadow: var(--popup-button-primary-hover-shadow);
}

button.popup-cta:active {
    transform: scale(0.98) translateY(0px);
}

button.popup-cta:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(79,115,2,0.3);
}

button.popup-cta.secondary:hover { 
    transform: scale(1.02) translateY(-2px);
    box-shadow: var(--popup-button-secondary-hover-shadow);
}

button.popup-cta.secondary:active {
    transform: scale(0.98) translateY(0px);
}

.popup-buttons {
    display: flex;
    gap: 8px;
    margin: 0 0 8px 0;
    width: 100%;
    flex-direction: column;
}

.popup-buttons a {
    width: 100%;
    min-height: 36px;
}

/* ========== POPUP INFO ITEMS ==================== */
.popup-info-item { 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    margin-bottom: 0;
    margin-top: 8px;
    font-size: 12px; 
    color: var(--text-dark); 
    line-height: 1.3; 
    padding: 10px 12px;
    background: var(--bg-light);
    border-radius: 6px;
    border: 1px solid var(--border-light);
    box-shadow: 0 1px 3px rgba(79,115,2,0.08);
    transition: var(--transition-fast);
}

.popup-info-item:first-of-type { 
    margin-top: 0;
}

.popup-info-item:last-child { 
    margin-bottom: 0; 
}

.popup-info-item:hover {
    background: var(--bg-hover);
    border-color: var(--color-primary);
    box-shadow: 0 2px 6px rgba(79,115,2,0.12);
}

.popup-info-item a { 
    color: #2d9d7e !important; 
    text-decoration: none; 
    font-weight: 500;
    transition: color 0.2s ease;
}

.popup-info-item a:hover { 
    text-decoration: underline; 
    color: var(--color-primary) !important;
}

.popup-info-item a:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* ========== RELATION ENTRIES (Rails/Routes) ==================== */
.relation-entry {
    margin-top: 4px;
    margin-bottom: 4px;
    padding: 10px 12px;
    line-height: 1.4;
    cursor: pointer;
    text-decoration: none;
    color: var(--text-dark) !important;
    font-size: 13px;
    background: var(--bg-light);
    border-left: 3px solid var(--color-primary);
    border-radius: 6px;
    border: 1px solid var(--border-light);
    box-shadow: 0 1px 3px rgba(79,115,2,0.08);
    transition: var(--transition-fast);
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 6px;
}

.relation-entry:first-of-type { margin-top: 0; }
.relation-entry:last-of-type { margin-bottom: 0; }

.relation-entry:hover {
    background: var(--bg-hover);
    border-color: var(--color-primary);
    border-left-color: var(--color-primary);
    text-decoration: none;
    box-shadow: 0 2px 6px rgba(79,115,2,0.15);
}

.relation-entry:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(79,115,2,0.2);
}

.relation-entry .popup-distance {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
    justify-self: end;
}

/* ========== RELATION LIST ==================== */
.relation-list {
    max-height: 160px;
    overflow-y: auto;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    scrollbar-width: thin;
    scrollbar-color: var(--color-primary) var(--bg-light);
}

.relation-list::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.relation-list::-webkit-scrollbar-track {
    background: var(--bg-light);
    border-radius: 4px;
}

.relation-list::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    border-radius: 4px;
    transition: background 0.2s ease;
    box-shadow: inset 0 0 2px rgba(79,115,2,0.3);
}

.relation-list::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, var(--color-primary-dark) 0%, #1f2d00 100%);
}

.relation-list-wrapper {
    margin-top: 8px;
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
}

/* ========== ICON BUTTONS & CONTROLS ==================== */

/* General icon button styling for smooth transitions */
button[class*="icon"],
.icon-button,
[aria-label] button {
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform: scale(1);
}

button[class*="icon"]:hover,
.icon-button:hover,
[aria-label] button:hover {
    transform: scale(1.1);
}

button[class*="icon"]:active,
.icon-button:active,
[aria-label] button:active {
    transform: scale(0.95);
}

/* Zoom controls and similar Leaflet controls */
.leaflet-control button,
.leaflet-control-zoom-in,
.leaflet-control-zoom-out {
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
    transform: scale(1);
}

.leaflet-control-zoom {
    top: 80px !important;
}

.leaflet-control button:hover,
.leaflet-control-zoom-in:hover,
.leaflet-control-zoom-out:hover {
    transform: scale(1.12);
    background: #f5f5f5 !important;
    color: var(--color-primary) !important;
}

.leaflet-control button:active,
.leaflet-control-zoom-in:active,
.leaflet-control-zoom-out:active {
    transform: scale(0.95);
}

/* Adjust zoom control position based on screen size */
.leaflet-control-zoom {
    top: 25px !important;
}

@media (max-width: 900px) {
    .leaflet-control-zoom {
        top: 20px !important;
    }
}

@media (max-width: 600px) {
    .leaflet-control-zoom {
        top: 10px !important;
    }
}

/* ========== MOBILE RESPONSIVE ==================== */
@media (max-width: 480px) {
    .leaflet-control-zoom {
        top: 10px !important;
    }

    .popup-content { 
        max-width: 280px !important; 
        padding: 8px !important; 
        font-size: 11px;
        line-height: 1.4;
    }

    .leaflet-popup {
        max-height: 60vh !important;
    }

    .leaflet-popup-content {
        max-height: 55vh !important;
    }

    .popup-title { 
        font-size: 11px !important; 
        margin-bottom: 4px; 
        padding-bottom: 2px;
        font-weight: 600;
        line-height: 1.2;
    }

    .popup-section {
        margin-top: 4px;
    }

    .popup-subtitle {
        font-size: 8px;
        margin-bottom: 2px;
        letter-spacing: 0.2px;
    }

    button.popup-cta {
        padding: 4px 6px !important;
        font-size: 9px !important;
        min-width: 60px;
    }

    .popup-buttons {
        gap: 2px;
    }

    .popup-buttons a {
        min-width: 60px;
        flex: 1;
    }

    .popup-info-item {
        padding: 4px 6px !important;
        font-size: 9px !important;
        margin-bottom: 2px !important;
        line-height: 1.2;
    }

    .popup-list a {
        padding: 4px 6px !important;
        font-size: 9px !important;
        line-height: 1.2;
    }

    .popup-distance {
        font-size: 7px !important;
    }

    .relation-list {
        max-height: 60px !important;
    }

    .relation-entry {
        padding: 4px 6px !important;
        font-size: 9px !important;
        margin-bottom: 1px;
        line-height: 1.2;
    }

    .leaflet-popup-content-wrapper {
        border-radius: 4px;
    }

    body {
        font-size: 9px !important;
    }

    .popup-title a {
        font-size: 11px !important;
    }

    .relation-section-title {
        font-size: 8px !important;
        margin-bottom: 4px !important;
    }

    .popup-stars {
        font-size: 10px !important;
    }
}

/* ========== TABLET RESPONSIVE ==================== */
@media (max-width: 768px) and (min-width: 481px) {
    .popup-content { 
        max-width: 360px !important; 
    }

    .popup-title { 
        font-size: 14px !important;
    }

    button.popup-cta {
        padding: 9px 14px !important;
        font-size: 12px !important;
    }

    .popup-info-item {
        font-size: 12px !important;
    }

    .relation-list {
        max-height: 140px !important;
    }
}
