/* ==========================================================================
   Elli Distance Finder — Design System & Styles
   Premium dark theme with Elli's magenta/pink brand accents
   ========================================================================== */

/* --- Design Tokens --- */
:root {
  /* Colors */
  --bg-primary: #0c0e14;
  --bg-secondary: #141821;
  --bg-card: rgba(22, 27, 38, 0.85);
  --bg-card-hover: rgba(30, 37, 52, 0.95);
  --bg-glass: rgba(255, 255, 255, 0.04);
  --bg-glass-border: rgba(255, 255, 255, 0.08);

  --accent: #e84393;
  --accent-light: #fd79a8;
  --accent-glow: rgba(232, 67, 147, 0.25);
  --accent-soft: rgba(232, 67, 147, 0.12);

  --text-primary: #f0f2f5;
  --text-secondary: #8b95a5;
  --text-muted: #5a6375;
  --text-accent: #fd79a8;

  --green: #00b894;
  --green-soft: rgba(0, 184, 148, 0.15);
  --yellow: #fdcb6e;
  --yellow-soft: rgba(253, 203, 110, 0.15);
  --red: #e17055;
  --red-soft: rgba(225, 112, 85, 0.15);
  --blue: #74b9ff;
  --blue-soft: rgba(116, 185, 255, 0.15);

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Radii */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px var(--accent-glow);

  /* Typography */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Transitions */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --duration: 0.25s;

  /* Layout */
  --header-height: 72px;
  --panel-width: 440px;
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* ==========================================================================
   Header
   ========================================================================== */
#app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-lg);
  background: rgba(12, 14, 20, 0.88);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--bg-glass-border);
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.logo-mark {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.logo-icon {
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: var(--accent-soft);
  border-radius: var(--radius-md);
  border: 1px solid rgba(232, 67, 147, 0.2);
}

.logo-text h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--text-primary), var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tagline {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 1px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
}

/* Institution Selector */
.institution-selector {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.institution-selector label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.institution-selector select,
#sort-select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--bg-glass);
  border: 1px solid var(--bg-glass-border);
  color: var(--text-primary);
  padding: 8px 36px 8px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
  transition: all var(--duration) var(--ease);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b95a5' d='M6 8.825L1.175 4 2.238 2.938 6 6.7 9.763 2.937 10.825 4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.institution-selector select:hover,
#sort-select:hover {
  border-color: var(--accent);
  background-color: rgba(255, 255, 255, 0.06);
}

.institution-selector select:focus,
#sort-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.institution-selector select option,
#sort-select option {
  background: #1a1f2e;
  color: #f0f2f5;
  padding: 8px;
}

/* Transport Mode Toggle */
.transport-toggle {
  display: flex;
  background: var(--bg-glass);
  border: 1px solid var(--bg-glass-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.transport-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  position: relative;
}

.transport-btn:not(:last-child)::after {
  content: '';
  position: absolute;
  right: 0;
  top: 25%;
  height: 50%;
  width: 1px;
  background: var(--bg-glass-border);
}

.transport-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.transport-btn.active {
  color: var(--accent-light);
  background: var(--accent-soft);
}

.transport-icon {
  font-size: 1rem;
  line-height: 1;
}

/* ==========================================================================
   Main Layout
   ========================================================================== */
#app-main {
  display: flex;
  height: 100vh;
  padding-top: var(--header-height);
}

/* --- Property Panel (Left) --- */
#property-panel {
  width: var(--panel-width);
  min-width: var(--panel-width);
  height: calc(100vh - var(--header-height));
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border-right: 1px solid var(--bg-glass-border);
  z-index: 100;
}

.panel-controls {
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  border-bottom: 1px solid var(--bg-glass-border);
  background: var(--bg-secondary);
}

/* Search Box */
.search-box {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  background: var(--bg-glass);
  border: 1px solid var(--bg-glass-border);
  border-radius: var(--radius-sm);
  padding: 0 var(--space-md);
  transition: all var(--duration) var(--ease);
}

.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-icon {
  font-size: 0.9rem;
  opacity: 0.5;
}

.search-box input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.85rem;
  padding: 10px 0;
  outline: none;
}

.search-box input::placeholder {
  color: var(--text-muted);
}

/* Filter Section & Drawer (Desktop Layout) */
.drawer-overlay {
  display: none;
}

.mobile-controls-header, .drawer-header {
  display: none;
}

.mobile-search-campus-row {
  display: contents;
}

.filter-drawer, .drawer-scroll-content {
  display: contents; /* Flatten for flex ordering on desktop */
}

.institution-selector { order: 1; }
.desktop-section-divider { order: 2; }
.desktop-locations-label { order: 3; }
.search-box { order: 4; }
.filter-section { order: 5; }
.results-summary { order: 6; }

.mobile-filter-toggle {
  display: none;
}

.filter-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

/* Sort Controls */
.sort-controls {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.sort-controls label {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

#sort-select {
  flex: 1;
  padding: 6px 32px 6px 10px;
  font-size: 0.8rem;
}

/* Results Summary */
.results-summary {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
  padding: 2px 0;
}

.results-summary .highlight {
  color: var(--accent-light);
  font-weight: 600;
}

/* --- Property List --- */
.property-list {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding: var(--space-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
}

/* Loading State */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  padding: var(--space-2xl);
  color: var(--text-muted);
}

.loading-state.hidden {
  display: none;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--bg-glass-border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* --- Property Card --- */
.property-card {
  background: var(--bg-card);
  border: 1px solid var(--bg-glass-border);
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-md) var(--space-md) calc(var(--space-md) + 4px);
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.property-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: var(--card-accent, var(--text-muted));
  border-radius: 3px 0 0 3px;
  transition: width var(--duration) var(--ease);
}

@media (hover: hover) {
  .property-card:hover {
    background: var(--bg-card-hover);
    border-color: rgba(255, 255, 255, 0.12);
    transform: translateX(2px);
    box-shadow: var(--shadow-sm);
  }

  .property-card:hover::before {
    width: 4px;
  }
}

.property-card.active {
  border-color: var(--accent);
  background: var(--bg-card-hover);
  box-shadow: var(--shadow-glow);
}

.property-card.active::before {
  width: 4px;
  background: var(--accent);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-sm);
  margin-bottom: var(--space-xs);
}

.card-header > div:first-child {
  min-width: 0;
  flex: 1;
}

.card-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.card-area {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
}

/* Distance Badge */
.distance-badge {
  display: flex;
  align-items: baseline;
  gap: 3px;
  flex-shrink: 0;
}

.distance-value {
  font-size: 1.15rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.distance-unit {
  font-size: 0.72rem;
  font-weight: 500;
  opacity: 0.6;
}

/* Distance color coding */
.distance-badge.close .distance-value {
  color: var(--green);
}
.distance-badge.medium .distance-value {
  color: var(--yellow);
}
.distance-badge.far .distance-value {
  color: var(--red);
}

.property-card.close { --card-accent: var(--green); }
.property-card.medium { --card-accent: var(--yellow); }
.property-card.far { --card-accent: var(--red); }

/* Card Details (types + rent) */
.card-details {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  margin-top: var(--space-xs);
}

.type-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.type-tag {
  display: inline-block;
  padding: 2px 8px;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
}

.rent-text {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent-light);
  white-space: nowrap;
}

/* Card Amenities (icon row) */
.card-amenities {
  display: flex;
  gap: 6px;
  margin-top: var(--space-xs);
}

.amenity-icon {
  font-size: 0.75rem;
  opacity: 0.6;
  cursor: default;
  transition: opacity var(--duration) var(--ease);
}

.amenity-icon:hover {
  opacity: 1;
}

/* Card Footer (time estimates) */
.card-footer {
  display: flex;
  gap: var(--space-md);
  margin-top: var(--space-sm);
  padding-top: var(--space-sm);
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.time-estimate {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.time-estimate .time-icon {
  font-size: 0.8rem;
  opacity: 0.7;
}

.time-estimate.active-mode {
  color: var(--accent-light);
  font-weight: 500;
}

/* Link to Elli */
.card-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-decoration: none;
  margin-top: var(--space-sm);
  transition: color var(--duration) var(--ease);
}

.card-link:hover {
  color: var(--accent-light);
}

/* ==========================================================================
   Map Panel
   ========================================================================== */
#map-panel {
  flex: 1;
  position: relative;
}

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

/* Dark map tiles override */
.leaflet-tile-pane {
  filter: brightness(0.82) contrast(1.1) saturate(0.85);
}

/* Map overlay stats */
.map-overlay {
  position: absolute;
  bottom: var(--space-lg);
  left: var(--space-lg);
  z-index: 500;
  display: flex;
  gap: var(--space-md);
  background: rgba(12, 14, 20, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--bg-glass-border);
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-lg);
}

.overlay-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.stat-value {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
}

/* Custom Leaflet popups */
.leaflet-popup-content-wrapper {
  background: var(--bg-secondary) !important;
  color: var(--text-primary) !important;
  border-radius: var(--radius-md) !important;
  border: 1px solid var(--bg-glass-border) !important;
  box-shadow: var(--shadow-lg) !important;
  font-family: var(--font) !important;
}

.leaflet-popup-content {
  margin: var(--space-md) !important;
  font-size: 0.85rem !important;
  line-height: 1.5 !important;
}

.leaflet-popup-tip {
  background: var(--bg-secondary) !important;
  border: 1px solid var(--bg-glass-border) !important;
  box-shadow: none !important;
}

.leaflet-popup-close-button {
  color: var(--text-muted) !important;
}

.leaflet-popup-close-button:hover {
  color: var(--accent-light) !important;
}

/* Popup content styling */
.popup-name {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.popup-address {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.popup-distance {
  font-size: 0.82rem;
  color: var(--accent-light);
  font-weight: 500;
}

/* Campus marker popup */
.popup-campus {
  text-align: center;
}

.popup-campus .popup-name {
  color: var(--accent-light);
}

/* ==========================================================================
   Section Divider & Label (in panel-controls)
   ========================================================================== */
.section-divider {
  height: 1px;
  background: var(--bg-glass-border);
  margin: var(--space-xs) 0;
}

.section-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ==========================================================================
   Route Info Bar (property detail panel)
   ========================================================================== */
.route-info-bar {
  position: fixed;
  bottom: -150%;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  max-width: 600px;
  z-index: 9999;
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: rgba(12, 14, 20, 0.94);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--accent);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-glow);
  transition: bottom 0.4s var(--ease);
}

.route-info-bar.visible {
  bottom: var(--space-lg);
}

.route-info-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  min-width: 0;
}

.route-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}

.route-name-area {
  display: flex;
  align-items: baseline;
  gap: var(--space-sm);
  min-width: 0;
}

.route-property-name {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-primary);
  white-space: nowrap;
}

.route-property-area {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.route-stats {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.85rem;
  flex-shrink: 0;
}

.route-stat {
  font-weight: 500;
  color: var(--text-secondary);
}

.route-stat-highlight {
  color: var(--accent-light);
  font-weight: 700;
  font-size: 0.95rem;
}

.route-divider {
  color: var(--text-muted);
}

/* Detail row: apartments + amenities */
.route-details-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding-top: var(--space-xs);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  flex-wrap: wrap;
}

.route-apartments {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
  min-width: 0;
}

.route-nearby {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
  min-width: 0;
  width: 100%;
  margin-top: var(--space-xs);
  padding-top: var(--space-xs);
  border-top: 1px dashed rgba(255, 255, 255, 0.06);
}

.route-apt-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
}

.route-apt-chip .apt-rent {
  color: var(--accent-light);
  font-weight: 600;
}

.route-amenities {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.route-amenities .amenity-icon {
  font-size: 0.85rem;
  opacity: 0.6;
  cursor: default;
}

.route-amenities .amenity-icon:hover {
  opacity: 1;
}

/* Link to Elli */
.route-elli-link {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
  transition: color var(--duration) var(--ease);
  align-self: flex-start;
}

.route-elli-link:hover {
  color: var(--accent-light);
}

.route-close-btn {
  background: none;
  border: 1px solid var(--bg-glass-border);
  color: var(--text-secondary);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all var(--duration) var(--ease);
  flex-shrink: 0;
  margin-top: 2px;
  position: relative;
  z-index: 10001;
}

.route-close-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-light);
}

/* ==========================================================================
   Custom Map Markers
   ========================================================================== */
.custom-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  transition: all var(--duration) var(--ease);
  font-size: 14px;
  color: var(--bg-primary);
  font-weight: 700;
  font-family: var(--font);
}

.custom-marker:hover {
  transform: scale(1.3);
  box-shadow: 0 4px 16px rgba(232, 67, 147, 0.5);
}

.custom-marker.close {
  background: var(--green);
}

.custom-marker.medium {
  background: var(--yellow);
  color: #333;
}

.custom-marker.far {
  background: var(--red);
}

.custom-marker.active {
  transform: scale(1.4);
  box-shadow: 0 0 20px var(--accent-glow);
  background: var(--accent);
  z-index: 1000 !important;
}

.campus-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #6c5ce7);
  border: 3px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 4px 20px rgba(108, 92, 231, 0.5);
  font-size: 24px;
  color: white;
  animation: campusPulse 2.5s ease-in-out infinite;
}

@keyframes campusPulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(108, 92, 231, 0.5); }
  50% { box-shadow: 0 4px 30px rgba(108, 92, 231, 0.8), 0 0 40px rgba(232, 67, 147, 0.3); }
}

/* Route polyline pulsing */
.route-animated {
  animation: routePulse 1.5s ease-in-out infinite;
}

/* ==========================================================================
   Responsive — Tablet
   ========================================================================== */
@media (max-width: 1024px) {
  :root {
    --panel-width: 340px;
  }
}

/* ==========================================================================
   Responsive — Mobile
   ========================================================================== */
@media (max-width: 768px) {
  /* Make the app behave like a native mobile app: page scroll */
  body {
    overflow-x: hidden;
    overflow-y: auto;
    height: auto;
    display: flex;
    flex-direction: column;
  }

  /* Header: switch to normal flex item since body is flex column */
  #app-header {
    position: sticky;
    top: 0;
    flex-direction: column;
    align-items: stretch;
    padding: var(--space-sm) var(--space-md);
    gap: var(--space-sm);
    height: auto;
    flex: none;
    z-index: 40;
  }

  .header-left {
    justify-content: center;
  }

  .header-right {
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-sm);
  }

  .logo-icon {
    width: 36px;
    height: 36px;
    font-size: 22px;
  }

  .logo-text h1 {
    font-size: 1rem;
  }

  .tagline {
    font-size: 0.68rem;
  }

  /* Main layout: vertical, fixed map on top, properties below */
  #app-main {
    flex-direction: column;
    flex: 1;
    height: auto;
    min-height: 0;
    overflow: visible;
    padding-top: 0;
    isolation: isolate;
  }

  /* Map: fixed height on the upper portion */
  #map-panel {
    order: -1;
    width: 100%;
    height: max(250px, 35dvh);
    min-height: 250px;
    flex: none;
    position: sticky;
    top: var(--mobile-header-height, 93px);
    z-index: 1000;
    background: var(--bg-primary);
  }

  /* Property panel: fills remaining space, scrollable */
  #property-panel {
    width: 100%;
    min-width: 100%;
    border-right: none;
    display: flex;
    flex-direction: column;
    flex: none;
    height: auto;
    min-height: 0;
    overflow: visible;
    position: relative;
    z-index: 1;
  }

  /* Let the whole panel scroll naturally on mobile */
  .property-list {
    flex: none;
    height: auto;
    min-height: 0;
    overflow: visible;
    max-height: none;
    padding-top: var(--space-sm);
    padding-bottom: calc(var(--space-lg) + 120px);
  }

  body::-webkit-scrollbar,
  #property-panel::-webkit-scrollbar,
  .property-list::-webkit-scrollbar {
    width: 0;
    height: 0;
  }

  /* Compact controls on mobile */
  .panel-controls {
    flex: none;
    position: sticky;
    top: calc(var(--mobile-header-height, 93px) + var(--mobile-map-height, max(250px, 35dvh)));
    z-index: 900;
    padding: var(--space-sm) var(--space-md);
    gap: var(--space-xs);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--bg-glass-border);
  }

  .filter-group label {
    font-size: 0.68rem;
  }

  .desktop-locations-label,
  .desktop-section-divider {
    display: none;
  }

  .mobile-controls-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-xs);
  }

  .mobile-controls-header .section-label {
    margin-bottom: 0;
  }

  .mobile-search-campus-row {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-xs);
  }

  .mobile-search-campus-row .search-box {
    flex: 1 1 auto;
    min-width: 0;
    order: 1;
  }

  .mobile-search-campus-row .institution-selector {
    flex: 0 0 128px;
    min-width: 0;
    order: 2;
  }

  .mobile-search-campus-row .institution-selector select {
    width: 100%;
  }

  .mobile-search-campus-row .institution-selector label {
    display: none;
  }

  /* Mobile Filter Toggle Button */
  .mobile-filter-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 6px 12px;
    background: var(--bg-glass);
    border: 1px solid var(--bg-glass-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--duration) var(--ease);
  }

  .mobile-filter-toggle:hover {
    background: rgba(255, 255, 255, 0.05);
  }

  /* Drawer Overlay */
  .drawer-overlay {
    display: block;
    position: fixed;
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s var(--ease);
  }

  .drawer-overlay.active {
    opacity: 1;
    pointer-events: auto;
  }

  /* Filter Drawer */
  .filter-drawer {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    right: -100%; /* Slide from right */
    width: 85%;
    max-width: 320px;
    height: 100vh;
    height: 100dvh;
    background: var(--bg-secondary);
    z-index: 2000;
    box-shadow: -5px 0 25px rgba(0,0,0,0.5);
    transition: right 0.4s var(--ease);
  }

  .filter-drawer.open {
    right: 0;
  }

  .drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md);
    border-bottom: 1px solid var(--bg-glass-border);
  }

  .drawer-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
  }

  .drawer-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px;
    display: flex;
  }

  .drawer-scroll-content {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    padding: var(--space-md);
    overflow-y: auto;
    flex: 1;
  }

  /* Reset flex orders for mobile since we aren't using flattened display: contents anymore */
  .institution-selector, .desktop-section-divider, .desktop-locations-label, .search-box, .filter-section, .results-summary {
    order: initial;
  }

  .filter-section.mobile-collapsed {
    display: flex; /* Override previous collapsed state, we rely on drawer now */
  }

  .pill-btn {
    padding: 4px 8px;
    font-size: 0.68rem;
  }

  /* Map overlay: stay inside the map panel */
  .map-overlay {
    bottom: var(--space-sm);
    left: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    gap: var(--space-sm);
  }

  .stat-value {
    font-size: 0.9rem;
  }

  .stat-label {
    font-size: 0.6rem;
  }

  /* Route info bar: position at bottom of the screen */
  .route-info-bar {
    position: fixed;
    left: var(--space-sm);
    right: var(--space-sm);
    width: auto;
    max-width: none;
    transform: none;
    bottom: -150%;
    z-index: 9999;
  }

  .route-info-bar.visible {
    bottom: var(--space-sm);
  }

  .route-top-row {
    flex-direction: column;
    gap: var(--space-xs);
  }

  .route-stats {
    align-self: flex-start;
  }

  .route-details-row {
    flex-direction: column;
    gap: var(--space-xs);
  }

  /* Transport toggle inside mobile controls header */
  .mobile-controls-header .transport-toggle {
    margin: 0;
    flex: 1;
    display: flex;
    justify-content: center;
  }

  .transport-label {
    display: none;
  }

  .transport-btn {
    padding: 6px 12px;
  }

  /* Feedback modal responsive */
  .feedback-modal-content {
    width: 98%;
    height: 90vh;
    height: 90dvh;
    max-height: 90vh;
    max-height: 90dvh;
  }

  .feedback-modal-content .modal-header {
    padding: var(--space-md);
  }

  /* Intro modal responsive */
  .modal-content {
    width: 95%;
    padding: var(--space-lg);
  }
}

/* ==========================================================================
   Animations
   ========================================================================== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.property-card {
  animation: fadeInUp 0.3s var(--ease) both;
}

.property-card:nth-child(1) { animation-delay: 0.02s; }
.property-card:nth-child(2) { animation-delay: 0.04s; }
.property-card:nth-child(3) { animation-delay: 0.06s; }
.property-card:nth-child(4) { animation-delay: 0.08s; }
.property-card:nth-child(5) { animation-delay: 0.10s; }
.property-card:nth-child(6) { animation-delay: 0.12s; }
.property-card:nth-child(7) { animation-delay: 0.14s; }
.property-card:nth-child(8) { animation-delay: 0.16s; }
.property-card:nth-child(9) { animation-delay: 0.18s; }
.property-card:nth-child(10) { animation-delay: 0.20s; }

/* No-results state */
.no-results {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl);
  text-align: center;
  color: var(--text-muted);
  gap: var(--space-sm);
}

.no-results-icon {
  font-size: 2rem;
  opacity: 0.5;
}

/* ==========================================================================
   Language Toggle
   ========================================================================== */
.lang-toggle {
  display: flex;
  background: var(--bg-glass);
  border: 1px solid var(--bg-glass-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.lang-btn, .about-btn {
  padding: 6px 12px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
}

.lang-btn:not(:last-child) {
  border-right: 1px solid var(--bg-glass-border);
}

.lang-btn:hover, .about-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.lang-btn.active {
  color: var(--accent-light);
  background: var(--accent-soft);
}

/* ==========================================================================
   Filter Pills (Radius, Rent, Type)
   ========================================================================== */
.filter-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.filter-group label {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.pill-options {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.pill-btn {
  padding: 5px 10px;
  border: 1px solid var(--bg-glass-border);
  background: var(--bg-glass);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 0.72rem;
  font-weight: 500;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  white-space: nowrap;
}

.pill-btn:hover {
  border-color: var(--accent);
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
}

.pill-btn.active {
  border-color: var(--accent);
  color: var(--accent-light);
  background: var(--accent-soft);
  box-shadow: 0 0 8px var(--accent-glow);
}

/* Range Slider */
input[type=range] {
  -webkit-appearance: none;
  background: transparent;
  cursor: pointer;
}

input[type=range]::-webkit-slider-runnable-track {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  border: 1px solid var(--bg-glass-border);
}

input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  height: 14px;
  width: 14px;
  border-radius: 50%;
  background: var(--accent-light);
  margin-top: -5px;
  box-shadow: 0 0 6px var(--accent-glow);
}

input[type=range]:focus {
  outline: none;
}

/* Dimmed marker for out-of-radius properties */
.custom-marker.out-of-radius {
  opacity: 0.25;
  transform: scale(0.7);
}

/* ==========================================================================
   Leaflet control overrides (for dark theme)
   ========================================================================== */
.leaflet-control-zoom a {
  background-color: var(--bg-secondary) !important;
  color: var(--text-primary) !important;
  border-color: var(--bg-glass-border) !important;
}

.leaflet-control-zoom a:hover {
  background-color: var(--bg-card-hover) !important;
}

.leaflet-control-attribution {
  background: rgba(12, 14, 20, 0.7) !important;
  color: var(--text-muted) !important;
  font-size: 0.6rem !important;
}

.leaflet-control-attribution a {
  color: var(--text-secondary) !important;
}

/* ==========================================================================
   Intro Modal
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(10, 10, 15, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s var(--ease);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--bg-glass-border);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 500px;
  padding: var(--space-xl);
  box-shadow: 0 20px 40px rgba(0,0,0,0.5);
  transform: translateY(20px);
  transition: transform 0.3s var(--ease);
}

.modal-overlay.active .modal-content {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.modal-header h2 {
  font-size: 1.2rem;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.2rem;
  transition: color 0.2s;
}
.modal-close:hover {
  color: var(--text-primary);
}

.modal-section {
  margin-bottom: var(--space-lg);
}

.modal-section h3 {
  font-size: 1rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: var(--space-sm);
}

.modal-section p {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.modal-list {
  list-style: none;
  margin-top: var(--space-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal-list li {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-list li i {
  color: var(--accent-light);
}

.modal-start-btn {
  width: 100%;
  padding: 12px;
  font-size: 0.9rem;
  margin-top: var(--space-sm);
  display: block;
}

/* ==========================================================================
   Feedback Modal
   ========================================================================== */
.feedback-modal-content {
  max-width: 680px;
  width: 95%;
  height: 85vh;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.feedback-modal-content .modal-header {
  padding: var(--space-lg) var(--space-xl);
  margin-bottom: 0;
  flex-shrink: 0;
}

.feedback-modal-body {
  flex: 1;
  overflow: hidden;
  display: flex;
}

.feedback-modal-body iframe {
  flex: 1;
  border: none;
  background: #fff;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Separator between header buttons */
.about-btn + .about-btn {
  border-left: 1px solid var(--bg-glass-border);
}

/* Feedback button with text label */
.feedback-label-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.feedback-label-btn span {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}

/* ==========================================================================
   Bus Schedule Modal & Popup
   ========================================================================== */

.schedule-step {
  display: flex;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
  position: relative;
}

.schedule-step:not(:last-child)::after {
  content: '';
  position: absolute;
  left: 11px;
  top: 28px;
  bottom: -16px;
  width: 2px;
  background: var(--bg-glass-border);
}

.step-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg-glass);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-light);
  font-size: 0.9rem;
  z-index: 1;
}

.step-details {
  flex: 1;
}

.step-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 2px;
}

.step-desc {
  color: var(--text-primary);
  font-weight: 500;
}

.step-sub {
  font-size: 0.75rem;
  margin-top: 2px;
}

.btn-schedule {
  display: inline-block;
  margin-top: var(--space-sm);
  background: var(--accent-soft);
  color: var(--accent-light);
  border: 1px solid rgba(232, 67, 147, 0.2);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  width: 100%;
}

.btn-schedule:hover {
  background: var(--accent);
  color: #fff;
}
