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

:root {
  --cream: #F8F9FB;
  --stone: #E5E7EB;
  --warm-gray: #6B7280;
  --charcoal: #111827;
  --text: #1F2937;
  --green: #10B981;
  --green-bg: #D1FAE5;
  --red: #EF4444;
  --red-bg: #FEE2E2;
  --amber: #F59E0B;
  --amber-bg: #FEF3C7;
  --white: #FFFFFF;
  --green-dark: #246842;
  --border-muted: #d5d0ca;
  --sidebar: 340px;
  --header: 0px;
}

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--cream);
  color: var(--text);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}
/* Allow text selection in inputs and text content */
input, textarea, .station-name, .station-address, .popup-body {
  -webkit-user-select: text;
  user-select: text;
}

/* ─── LAYOUT ─── */
.app-body { display: flex; flex: 1; overflow: hidden; position: relative; }

/* ─── SIDEBAR (transparent overlay on desktop, bottom sheet on mobile) ─── */
aside {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: calc(var(--sidebar) + 40px);
  background: transparent;
  border-right: none;
  display: flex;
  flex-direction: column;
  padding: 20px;
  gap: 12px;
  z-index: 800;
  pointer-events: none;
}
aside > * {
  pointer-events: auto;
}

/* ─── SIDEBAR CARDS ─── */
.sidebar-card {
  background: var(--white);
  border: 1px solid var(--stone);
  border-radius: 12px;
  overflow: hidden;
}
.sidebar-card-intro {
  flex-shrink: 0;
  padding: 20px;
}
.sidebar-card-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ─── INTRO LOGO ─── */
.intro-logo {
  font-family: 'Fraunces', serif;
  font-size: 32px;
  font-weight: 600;
  color: var(--charcoal);
  margin-bottom: 8px;
  line-height: 1.1;
}

/* Scrollable settings wrapper */
.settings-scroll {
  overflow-y: auto;
  overflow-x: hidden;
  flex-shrink: 1;
  min-height: 0;
}
.settings-scroll::-webkit-scrollbar { width: 3px; }
.settings-scroll::-webkit-scrollbar-thumb { background: var(--stone); border-radius: 3px; }

/* ─── INTRO TAGLINE ─── */
.intro-tagline {
  margin-bottom: 0;
  padding-bottom: 0;
}
.intro-title {
  font-family: 'Fraunces', serif;
  font-size: 16px;
  font-weight: 600;
  color: var(--charcoal);
  line-height: 1.3;
  margin-bottom: 4px;
}
.intro-title em {
  font-style: italic;
  color: var(--green);
}
.intro-desc {
  font-size: 12px;
  color: var(--warm-gray);
  line-height: 1.5;
}
.intro-desc strong {
  color: var(--text);
  font-weight: 600;
}

/* ─── SETTINGS PANEL ─── */
.settings-panel {
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--stone);
}

/* Settings header with collapse */
.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.settings-header .settings-label {
  margin-bottom: 0;
}
.settings-label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--warm-gray);
  margin-bottom: 10px;
}
.settings-collapse-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1.5px solid var(--stone);
  border-radius: 8px;
  cursor: pointer;
  color: var(--warm-gray);
  transition: all 0.15s;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.settings-collapse-btn:hover { background: var(--cream); color: var(--text); }
.settings-collapse-btn.collapsed svg {
  transform: rotate(180deg);
}

/* Settings body (collapsible) */
.settings-body {
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.2s ease;
  max-height: 600px;
  opacity: 1;
}
.settings-body.collapsed {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}

/* Settings collapsed summary */
.settings-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0 2px;
  font-size: 12px;
  color: var(--text);
  gap: 8px;
}
.settings-summary span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.summary-edit-btn {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--green);
  background: none;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  padding: 2px 4px;
}
.summary-edit-btn:hover { text-decoration: underline; }

.setting-row {
  margin-bottom: 10px;
}
.setting-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
  display: block;
}

/* Fuel Type Toggle */
.fuel-toggle {
  display: flex;
  gap: 0;
  border: 1.5px solid var(--stone);
  border-radius: 8px;
  overflow: hidden;
}
.fuel-btn {
  flex: 1;
  padding: 6px 10px;
  background: var(--cream);
  border: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--warm-gray);
  cursor: pointer;
  transition: all 0.15s;
}
.fuel-btn + .fuel-btn { border-left: 1.5px solid var(--stone); }
.fuel-btn.active {
  background: var(--charcoal);
  color: #fff;
}
.fuel-btn:hover:not(.active) { background: var(--stone); }

/* Location Input */
.location-input-wrap {
  display: flex;
  gap: 6px;
}
.input-clear-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}
.input-clear-wrap .setting-input {
  width: 100%;
  padding-right: 28px;
}
.setting-input {
  flex: 1;
  background: var(--cream);
  border: 1.5px solid var(--stone);
  border-radius: 8px;
  padding: 7px 10px;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
  min-width: 0;
}
.setting-input::placeholder { color: var(--warm-gray); }
.setting-input:focus { background: var(--white); border-color: var(--charcoal); }
@media (max-width: 700px) { .setting-input { font-size: 16px; } }

/* Autocomplete dropdown */
.autocomplete-wrap {
  position: relative;
}
.autocomplete-list {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  z-index: 1200;
  background: var(--white);
  border: 1.5px solid var(--stone);
  border-top: none;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 6px 16px rgba(0,0,0,0.1);
  max-height: 200px;
  overflow-y: auto;
}
.autocomplete-list.visible { display: block; }
.autocomplete-item {
  padding: 8px 10px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  border-bottom: 1px solid var(--cream);
  line-height: 1.35;
  transition: background 0.08s;
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover,
.autocomplete-item.active {
  background: var(--cream);
}
.autocomplete-item .ac-main {
  font-weight: 500;
}
.autocomplete-item .ac-sub {
  color: var(--warm-gray);
  font-size: 13px;
}

.clear-input-btn {
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--warm-gray);
  padding: 0;
  border-radius: 50%;
  transition: color 0.15s;
  z-index: 2;
  -webkit-tap-highlight-color: transparent;
}
.clear-input-btn:hover { color: var(--charcoal); }

.gps-btn {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cream);
  border: 1.5px solid var(--stone);
  border-radius: 8px;
  cursor: pointer;
  color: var(--warm-gray);
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.gps-btn:hover { background: var(--stone); color: var(--charcoal); }
.gps-btn.active { color: var(--green); border-color: var(--green); background: var(--green-bg); }

/* Stepper Inputs */
.stepper-wrap {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1.5px solid var(--stone);
  border-radius: 8px;
  overflow: hidden;
  background: var(--cream);
}
.stepper-btn {
  width: 38px;
  height: 38px;
  background: transparent;
  border: none;
  font-size: 18px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.stepper-btn:hover { background: var(--stone); }
.stepper-btn:active { background: var(--border-muted); }
.stepper-input {
  width: 48px;
  text-align: center;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  outline: none;
  -moz-appearance: textfield;
}
.stepper-input::-webkit-inner-spin-button,
.stepper-input::-webkit-outer-spin-button { -webkit-appearance: none; }
.stepper-unit {
  font-size: 13px;
  color: var(--warm-gray);
  white-space: nowrap;
  margin-right: 4px;
}

/* Side-by-side setting pair (Consumption + Tank) */
.setting-row-pair {
  display: flex;
  gap: 10px;
}
.setting-row-pair .setting-row {
  flex: 1;
  min-width: 0;
  margin-bottom: 10px;
}
.setting-row-pair .stepper-btn {
  width: 28px;
  height: 28px;
  font-size: 16px;
}
.setting-row-pair .stepper-input {
  width: 36px;
  font-size: 12px;
}
.setting-row-pair .stepper-unit {
  font-size: 10px;
}

/* Fuel Gauge Slider */
.fuel-gauge-wrap { margin-top: 2px; }
.fuel-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 4px;
  outline: none;
  background: linear-gradient(90deg, var(--red) 0%, var(--amber) 40%, var(--green) 100%);
  cursor: pointer;
}
.fuel-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--charcoal);
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  cursor: pointer;
}
.fuel-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--charcoal);
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  cursor: pointer;
}
.fuel-gauge-labels {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--warm-gray);
  margin-top: 2px;
  font-weight: 500;
}
.fuel-level-display {
  font-weight: 600;
  color: var(--text);
}

/* Action Bar (sticky CTA area, never scrolled away) */
.action-bar {
  padding: 6px 14px 8px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--stone);
  background: var(--white);
}

/* Fill Button */
.fill-btn {
  width: 100%;
  padding: 10px 16px;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.15s, transform 0.1s;
}
.fill-btn:hover { background: var(--green-dark); }
.fill-btn:active { transform: scale(0.98); }
.fill-btn:disabled { background: var(--warm-gray); cursor: not-allowed; }
.fill-btn.loading {
  pointer-events: none;
  opacity: 0.7;
}

/* Optional label hint */
.label-optional {
  font-weight: 400;
  color: var(--warm-gray);
  font-size: 10px;
  text-transform: none;
  letter-spacing: 0;
  margin-left: 4px;
}

/* Time Filter */
.time-filter {
  padding: 8px 14px;
  border-bottom: 1px solid var(--stone);
}
.time-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--stone);
  outline: none;
  margin-top: 4px;
  cursor: pointer;
}
.time-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--charcoal);
  cursor: pointer;
}
.time-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--charcoal);
  cursor: pointer;
  border: none;
}

/* Data freshness (footer below station list) */
.data-freshness {
  display: block;
  padding: 8px 14px 10px;
  font-size: 13px;
  color: var(--warm-gray);
  text-align: center;
  flex-shrink: 0;
  border-top: 1px solid var(--stone);
}
.data-freshness .stale { color: var(--red); }

/* ─── RESULTS HEADER ─── */
.results-header {
  padding: 8px 14px 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  border-bottom: 1px solid var(--stone);
  gap: 6px;
}
.results-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.list-count {
  font-size: 12px;
  color: var(--warm-gray);
  font-weight: 500;
  white-space: nowrap;
}
.sort-toggle { display: flex; gap: 2px; flex-shrink: 0; }
.sort-btn {
  background: none;
  border: 1px solid transparent;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  color: var(--warm-gray);
  cursor: pointer;
  transition: all 0.12s;
  user-select: none;
}
.sort-btn:hover:not(.active) { background: #EDEAE5; }
.sort-btn.active {
  background: var(--stone);
  color: var(--text);
  border-color: var(--border-muted);
}

/* ─── STATION LIST ─── */
.station-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 5px 16px;
  min-height: 0;
}
.station-list::-webkit-scrollbar { width: 3px; }
.station-list::-webkit-scrollbar-thumb { background: var(--stone); border-radius: 3px; }

.station-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 9px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.1s;
  margin-bottom: 1px;
}
.station-item:hover { background: var(--cream); }
.station-item.active { background: var(--cream); border-color: var(--stone); }

.station-rank {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 2px;
  color: #fff;
}

.station-info { flex: 1; min-width: 0; }
.station-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.station-address {
  font-size: 13px;
  color: var(--warm-gray);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.station-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.station-tag {
  font-size: 13px;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 500;
  white-space: nowrap;
}
.station-tag.effective {
  background: var(--green-bg);
  color: var(--green);
  font-weight: 700;
}
.station-tag.posted {
  background: #f0ede8;
  color: var(--warm-gray);
}
.station-tag.distance {
  color: var(--warm-gray);
  padding-left: 0;
}
.station-tag.savings {
  background: var(--green-bg);
  color: var(--green);
}
.station-tag.savings.negative {
  background: var(--red-bg);
  color: var(--red);
}
.station-tag.unreachable {
  background: var(--red-bg);
  color: var(--red);
  font-weight: 600;
}

.station-prices {
  text-align: right;
  flex-shrink: 0;
}
.station-effective-price {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  font-family: 'DM Sans', system-ui, sans-serif;
}
.station-posted-price {
  font-size: 13px;
  color: var(--warm-gray);
  margin-top: 1px;
}

/* Price freshness tag */
.price-freshness {
  font-size: 12px;
  font-weight: 500;
  margin-top: 1px;
}
.price-freshness.fresh { color: var(--green); }
.price-freshness.aging { color: var(--amber); }
.price-freshness.stale { color: var(--red); }

.empty-state {
  padding: 36px 14px;
  text-align: center;
  color: var(--warm-gray);
  font-size: 14px;
  line-height: 1.6;
}

/* ─── LOADING SKELETON ─── */
.loading-skeleton {
  padding: 32px 14px;
  text-align: center;
}
.skeleton-pulse {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  margin: 0 auto 12px;
  background: var(--stone);
  animation: skeletonPulse 1.5s ease-in-out infinite;
}
.skeleton-text {
  font-size: 13px;
  color: var(--warm-gray);
  animation: skeletonPulse 1.5s ease-in-out infinite;
}
@keyframes skeletonPulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* ─── MAP ─── */
#map { flex: 1; width: 100%; z-index: 100; }

/* Map Legend */
.map-legend {
  position: absolute;
  bottom: 28px;
  left: calc(var(--sidebar) + 50px);
  z-index: 500;
  background: rgba(255,255,255,0.95);
  border: 1px solid var(--stone);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.legend-title {
  font-weight: 700;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--warm-gray);
  margin-bottom: 4px;
}
.legend-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 1px 0;
  color: var(--text);
}
.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Route close button */
.route-close-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 500;
  background: white;
  border: 1px solid var(--stone);
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  font-size: 14px;
  color: var(--text);
}

/* ─── LEAFLET POPUP ─── */
.leaflet-popup-content-wrapper {
  border-radius: 12px !important;
  box-shadow: 0 6px 28px rgba(0,0,0,0.13) !important;
  padding: 0 !important;
  border: 1px solid var(--stone) !important;
  overflow: visible;
  font-family: 'DM Sans', sans-serif !important;
}
.leaflet-popup-content { margin: 0 !important; width: auto !important; min-width: 220px; max-width: 300px; overflow: visible; }
.leaflet-popup-tip { background: var(--white) !important; }
.leaflet-popup-close-button {
  top: 18px !important;
  right: 10px !important;
  width: 20px !important;
  height: 20px !important;
  font-size: 16px !important;
  line-height: 20px !important;
  color: var(--warm-gray) !important;
  text-align: center;
  padding: 0 !important;
}
.leaflet-popup-close-button:hover { color: var(--charcoal) !important; }

.popup-bar { height: 12px; border-radius: 12px 12px 0 0; }
.popup-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
}
.popup-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.popup-name {
  font-family: 'Fraunces', serif;
  font-size: 16px;
  font-weight: 600;
  color: var(--charcoal);
  line-height: 20px;
}
.popup-brand {
  font-size: 14px;
  color: var(--warm-gray);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
  line-height: 16px;
}
.popup-address {
  font-size: 12px;
  color: var(--warm-gray);
  line-height: 16px;
}
.popup-price-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.popup-prices {
  display: flex;
  gap: 12px;
}
.popup-price-block {
  flex: 1;
}
.popup-price-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--warm-gray);
  font-weight: 600;
}
.popup-price-value {
  font-size: 20px;
  font-weight: 700;
}
.popup-price-value.effective { color: var(--green); }
.popup-price-value.posted { color: var(--text); }

/* Info tooltip (i) */
.info-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1.5px solid var(--warm-gray);
  background: none;
  color: var(--warm-gray);
  font-size: 8px;
  font-weight: 700;
  font-style: normal;
  font-family: 'DM Sans', sans-serif;
  cursor: help;
  position: relative;
  vertical-align: middle;
  margin-left: 2px;
  line-height: 1;
  font-family: Georgia, serif;
}
.info-tip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--charcoal);
  color: #fff;
  font-size: 13px;
  font-weight: 400;
  font-style: normal;
  font-family: 'DM Sans', sans-serif;
  letter-spacing: 0;
  text-transform: none;
  line-height: 1.4;
  padding: 8px 10px;
  border-radius: 6px;
  width: 200px;
  white-space: normal;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 1300;
}
.info-tip:hover::after,
.info-tip:focus::after {
  opacity: 1;
}

.popup-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.popup-stat {
  font-size: 13px;
  background: var(--cream);
  padding: 3px 8px;
  border-radius: 20px;
  color: var(--text);
  font-weight: 500;
}
.popup-stat.price-freshness {
  font-size: 11px;
}
.popup-stat.price-freshness.fresh { background: var(--green-bg); color: var(--green); }
.popup-stat.price-freshness.aging { background: var(--amber-bg); color: var(--amber); }
.popup-stat.price-freshness.stale { background: var(--red-bg); color: var(--red); }

.popup-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.popup-nav-btns {
  display: flex;
  gap: 5px;
  border-top: 1px solid #E5E7EB;
  padding-top: 13px;
}
.popup-maps-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex: 1;
  padding: 7px;
  background: transparent;
  color: var(--charcoal);
  border: 1px solid #E5E7EB;
  border-radius: 12px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.popup-maps-btn:hover { background: var(--stone); border-color: var(--warm-gray); }

.popup-tcs-link {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #0078A8;
  text-decoration: none;
  transition: color 0.15s;
}
.popup-tcs-link:hover { color: #005f85; }

.popup-dest-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  padding: 8px 12px;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  transition: opacity 0.15s;
}
.popup-dest-btn:hover { opacity: 0.85; }

/* ─── PRICE CLUSTERS (TCS-style: price tag + count badge) ─── */
.cluster-tag {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: 8px;
  background: var(--tag-color, #6B7280);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  font-family: 'DM Sans', sans-serif;
  white-space: nowrap;
  box-shadow: 0 1px 4px rgba(0,0,0,0.22);
  border: 1.5px solid white;
  cursor: pointer;
  margin-bottom: 4px;
}
/* arrow pointing down */
.cluster-tag::after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 50%;
  transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--tag-color, #6B7280);
}
/* station count badge — top-right corner */
.cluster-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--charcoal, #3C3530);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid white;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
  line-height: 1;
}

/* ─── INDIVIDUAL PRICE TAGS ─── */
.price-tag-icon {
  background: none !important;
  border: none !important;
  display: flex !important;
  align-items: flex-end !important;
  justify-content: center !important;
}
.station-price-tag {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: 8px;
  background: var(--tag-color, #6B7280);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  font-family: 'DM Sans', sans-serif;
  white-space: nowrap;
  box-shadow: 0 1px 4px rgba(0,0,0,0.22);
  border: 1.5px solid white;
  cursor: pointer;
  margin-bottom: 4px; /* space for arrow */
}
/* small arrow pointing down to the geo location */
.station-price-tag::after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 50%;
  transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--tag-color, #6B7280);
}

/* ─── LOADING STATE ─── */
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
.fill-btn.loading svg { animation: pulse 1s ease-in-out infinite; }

/* ─── MARKER FADE-IN (triggered on clear → browse transition) ─── */
@keyframes markerFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
#map.markers-entering .leaflet-marker-icon {
  animation: markerFadeIn 0.35s ease-out !important;
}

/* ─── BOTTOM SHEET ─── */
.sheet-handle-bar {
  display: none;
  width: 40px;
  height: 5px;
  background: #D0CAC2;
  border-radius: 3px;
  margin: 0 auto;
  flex-shrink: 0;
}
.sheet-drag-area {
  display: none;
}

/* ─── RESPONSIVE / MOBILE ─── */
@media (max-width: 700px) {
  :root { --sidebar: 100%; }

  /* Lock html to prevent page bounce in PWA standalone mode */
  html {
    position: fixed;
    width: 100%;
    height: 100%;
    overflow: hidden;
  }

  /* Disable tap highlight globally on mobile */
  * { -webkit-tap-highlight-color: transparent; }

  /* Hide intro card on mobile — space is precious */
  .sidebar-card-intro { display: none; }

  /* Main card becomes transparent wrapper on mobile */
  .sidebar-card-main {
    display: contents;
  }

  /* Hide settings collapse on mobile — all settings always visible */
  .settings-header { display: none; }

  .sheet-handle-bar { display: block; }
  .sheet-drag-area {
    display: flex;
    padding: 12px 0 6px;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    cursor: ns-resize;
    touch-action: none;
    user-select: none;
  }

  #map {
    width: 100%;
    height: 100%;
    /* Ensure map fills behind the bottom sheet */
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
  }

  aside {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 45dvh;
    background: #fff;
    border-right: none;
    border-top: none;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -2px 20px rgba(0,0,0,0.15);
    z-index: 900;
    overflow: hidden;
    transition: height 0.3s cubic-bezier(.4,0,.2,1);
    max-height: 90dvh;
    will-change: height;
    touch-action: none;
    padding: 0;
    gap: 0;
    pointer-events: auto;
  }

  .settings-scroll {
    overflow: hidden;
    flex-shrink: 0;
  }

  .station-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    padding-bottom: 80px;
  }

  /* Compact settings on mobile — fit everything without scrolling */
  .settings-panel { padding: 8px 14px 6px; }
  .setting-row { margin-bottom: 6px; }

  /* Larger fuel toggle buttons for touch */
  .fuel-btn { padding: 8px 10px; font-size: 14px; }

  /* Map legend repositioned above sheet */
  .map-legend {
    bottom: auto;
    top: 10px;
    left: 10px;
  }

  /* Zoom controls: positioned dynamically via JS to stay above sheet */
  .leaflet-bottom.leaflet-right {
    transition: bottom 0.32s cubic-bezier(.25,.1,.25,1);
  }

  /* Fill button slightly taller on mobile for better touch */
  .fill-btn { padding: 12px 16px; font-size: 16px; }

  /* Sort buttons slightly bigger for touch */
  .sort-btn { padding: 4px 10px; font-size: 13px; }

  /* Station items slightly more padded for touch */
  .station-item { padding: 12px 10px; gap: 10px; }

  /* Action bar — absolute at bottom, handles safe area */
  .action-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10;
    background: #fff;
    border-top: 1px solid var(--stone);
    padding: 6px 14px 8px;
  }

  /* Route close button larger for mobile */
  .route-close-btn {
    width: 40px;
    height: 40px;
    font-size: 18px;
    top: 12px;
    right: 12px;
  }

  /* Popup adjustments for mobile — wider */
  .leaflet-popup-content { min-width: 260px; max-width: 320px; }
}

@media (max-width: 400px) {
  .setting-row-pair { flex-direction: column; gap: 0; }
  .setting-row-pair .stepper-btn { width: 38px; height: 38px; }
  .setting-row-pair .stepper-input { width: 48px; font-size: 13px; }
  .setting-row-pair .stepper-unit { font-size: 11px; }
}
