/* ============================================================================
   franklin-page.css — Scrollable page layout for the Franklin line page
   ============================================================================ */

/* Override shared layout: make body scrollable instead of full-screen fixed */
html, body {
  height: auto !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
}
body {
  display: block !important;
  background: #f8f8f8 !important;
}

/* Hide elements from the old full-screen layout */
.story-header,
.home-footer,
.left-panel,
.train-direction-toggle,
.legend-box,
.basemap-toggle,
.north-arrow,
.story-panel,
.dev-tools-panel { display: none !important; }

/* ============================================================================
   HEADER
   ============================================================================ */
.page-header {
  position: sticky;
  top: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 32px;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  pointer-events: auto; /* override legacy full-screen `header { pointer-events:none }` in style.css */
}
.page-header * { pointer-events: auto; }

.page-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgb(128, 39, 108) 17%,
    rgb(128, 39, 108) 20%,
    transparent 100%);
}

.page-header .header-logos {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 32px;
}

.page-header .hntb-logo { height: 26px; }
.page-header .mbta-logo { height: 30px; }

.page-header .logo-separator {
  color: #ccc;
  font-size: 20px;
  font-weight: 300;
}

.page-header .header-title-block {
  display: flex;
  flex-direction: column;
  padding-left: 4px;
}

.page-header .header-title {
  font-size: 17px;
  font-weight: 700;
  color: rgb(128, 39, 108);
  font-family: 'DM Sans', sans-serif;
}

.page-header .header-subtitle {
  font-size: 10px;
  font-weight: 400;
  color: #999;
  font-family: 'DM Sans', sans-serif;
}

.page-header .header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-header .back-button {
  display: inline-block;
  padding: 7px 16px;
  background: rgb(128, 39, 108);
  color: white !important;
  border: none;
  border-radius: 4px;
  text-decoration: none;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}
.page-header .back-button:hover {
  background: rgb(108, 29, 88);
  color: white !important;
}

/* ============================================================================
   MAIN CONTENT
   ============================================================================ */
.page-main {
  max-width: 90%;
  margin: 0 auto;
  padding: 28px 32px 0;
}

/* ============================================================================
   SECTION TABS — horizontal tab bar with underline indicator
   ============================================================================ */
.section-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid #e0e0e0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  position: relative;
}
.section-tabs::-webkit-scrollbar { display: none; }

/* Scroll fade indicators */
.section-tabs-wrap {
  position: relative;
}
.section-tabs-wrap::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 48px;
  height: 100%;
  background: linear-gradient(90deg, transparent, #f8f8f8);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 1;
}
.section-tabs-wrap.has-overflow::after { opacity: 1; }
.section-tabs-wrap.scrolled-end::after { opacity: 0; }

.section-tabs .tab-btn {
  padding: 12px 20px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: #888;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -2px;
  position: relative;
}

.section-tabs .tab-btn:hover { color: #555; }

.section-tabs .tab-btn.active {
  color: rgb(128, 39, 108);
  border-bottom-color: rgb(128, 39, 108);
  font-weight: 600;
}

/* ============================================================================
   SECTION CONTENT — single visible section at a time
   ============================================================================ */
.section-body {
  padding: 24px 0 28px;
  min-height: 100px;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.section-body.fade-out {
  opacity: 0;
  transform: translateY(6px);
}

.section-body.fade-in {
  opacity: 1;
  transform: translateY(0);
}

.section-body h2 {
  font-family: 'DM Sans', sans-serif;
  font-size: 22px;
  font-weight: 600;
  color: rgb(128, 39, 108);
  margin: 0 0 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid rgba(128, 39, 108, 0.2);
}

.section-body p {
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  line-height: 1.72;
  color: #3a3a3a;
  margin: 0 0 14px;
}

.section-body p:last-child { margin-bottom: 0; }

/* Map-content sync: clickable place references */
.place-link {
  color: rgb(128, 39, 108);
  cursor: pointer;
  border-bottom: 1px dotted rgba(128, 39, 108, 0.4);
  transition: border-color 0.15s;
}
.place-link:hover {
  border-bottom-color: rgb(128, 39, 108);
}

/* ============================================================================
   STATION DETAIL CARD — shows on diagram hover
   ============================================================================ */
.station-detail-card {
  background: white;
  border-radius: 8px;
  padding: 16px 18px;
  box-shadow: 0 1px 8px rgba(0,0,0,0.08);
  margin-top: 14px;
  min-height: 80px;
  border-left: 3px solid rgb(128, 39, 108);
  transition: opacity 0.15s;
}

.station-detail-card:empty {
  opacity: 0.3;
  border-left-color: #ddd;
}

.station-detail-card:empty::before {
  content: 'Hover a station on the diagram above to see details';
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  color: #aaa;
  font-style: italic;
}

/* Crossing detail card — same pattern */
.crossing-detail-card {
  background: white;
  border-radius: 8px;
  padding: 16px 18px;
  box-shadow: 0 1px 8px rgba(0,0,0,0.08);
  margin-top: 14px;
  min-height: 60px;
  border-left: 3px solid rgb(128, 39, 108);
  transition: opacity 0.15s;
}

.crossing-detail-card:empty {
  opacity: 0.3;
  border-left-color: #ddd;
}

.crossing-detail-card:empty::before {
  content: 'Hover a crossing on the diagram above to see details';
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  color: #aaa;
  font-style: italic;
}

.station-card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}

.station-card-name {
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  font-weight: 600;
  color: #222;
}

.station-card-zone {
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  font-weight: 600;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.station-card-stats {
  display: flex;
  gap: 16px;
  margin-bottom: 10px;
}

.station-card-stats .stat {
  display: flex;
  flex-direction: column;
}

.station-card-stats .stat-val {
  font-family: 'DM Mono', monospace;
  font-size: 14px;
  font-weight: 500;
  color: rgb(128, 39, 108);
}

.station-card-stats .stat-lbl {
  font-family: 'DM Sans', sans-serif;
  font-size: 10px;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.station-card-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tag {
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 3px;
  background: #f0f0f0;
  color: #666;
}

.tag-ada { background: #e8f5e9; color: #2e7d32; }
.tag-no-ada { background: #fff3e0; color: #e65100; }
.tag-parking { background: #e3f2fd; color: #1565c0; }

/* ============================================================================
   CROSSING POPUP — clean card design
   ============================================================================ */
.xing-popup-wrap .leaflet-popup-content-wrapper {
  border-radius: 10px;
  padding: 0;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}
.xing-popup-wrap .leaflet-popup-content {
  margin: 0;
  width: auto !important;
}
.xing-popup-wrap .leaflet-popup-tip {
  box-shadow: none;
}

.xing-card {
  font-family: 'DM Sans', sans-serif;
  padding: 14px 16px 12px;
  min-width: 220px;
}

.xing-name {
  font-size: 16px;
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 2px;
}

.xing-loc {
  font-size: 11px;
  color: #999;
  margin-bottom: 10px;
  letter-spacing: 0.01em;
}

.xing-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 12px;
}

.xing-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

.spd-green  { background: #e8f5e9; color: #2e7d32; }
.spd-amber  { background: #fff3e0; color: #e65100; }
.spd-red    { background: #ffebee; color: #c62828; }
.xing-gates { background: #e3f2fd; color: #1565c0; }
.xing-bells { background: #f3e5f5; color: #7b1fa2; }
.xing-quiet { background: #e0f2f1; color: #00695c; }

/* ============================================================================
   TRACK CONDITION — popup card + section summary
   ============================================================================ */
.cond-card {
  font-family: 'DM Sans', sans-serif;
  padding: 12px 14px;
  min-width: 180px;
}
.cond-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.cond-sev {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #fff;
  padding: 3px 7px;
  border-radius: 4px;
  white-space: nowrap;
}
.cond-type {
  font-size: 14px;
  font-weight: 700;
  color: #1a1a1a;
}
.cond-stats { display: flex; flex-direction: column; gap: 4px; }
.cond-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: 12px;
}
.cond-label { color: #999; }
.cond-val { color: #333; font-weight: 600; }

.cond-summary {
  margin-top: 18px;
  padding: 16px 18px;
  background: #fafafa;
  border: 1px solid #eee;
  border-radius: 10px;
}
.cond-total {
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 12px;
}
.cond-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-bottom: 14px;
}
.cond-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  color: #555;
}
.cond-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1.5px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.15);
  flex-shrink: 0;
}
.cond-legend-lbl { font-weight: 600; }
.cond-legend-ct {
  font-weight: 700;
  color: #1a1a1a;
  background: #eee;
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 11px;
}
.cond-types {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.cond-type-chip {
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  color: #555;
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 4px;
  padding: 3px 8px;
}
.cond-type-chip b { color: #1a1a1a; }

/* Track condition filter (segmented control in map popout) */
.cond-filter-seg {
  display: flex;
  border: 1px solid rgb(128, 39, 108);
  border-radius: 5px;
  overflow: hidden;
}
.cond-filter-seg button {
  flex: 1;
  border: none;
  background: white;
  color: rgb(128, 39, 108);
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  cursor: pointer;
}
.cond-filter-seg button + button { border-left: 1px solid rgb(128, 39, 108); }
.cond-filter-seg button.active { background: rgb(128, 39, 108); color: white; }

.xing-stats {
  border-top: 1px solid #f0f0f0;
  padding-top: 8px;
}

.xing-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 0;
  font-size: 13px;
}

.xing-label { color: #777; }
.xing-val { font-weight: 600; color: #333; }

.xing-acc {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #f0f0f0;
  font-size: 12px;
  color: #c62828;
  font-weight: 500;
}

.xing-acc-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #c62828;
  margin-right: 4px;
  vertical-align: middle;
}

.xing-clear {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #f0f0f0;
  font-size: 12px;
  color: #66bb6a;
  font-weight: 500;
}

/* ============================================================================
   SPEED POPOUT — floating control on the map when speed mode is active
   ============================================================================ */
.speed-popout {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.14);
  padding: 12px 16px;
  font-family: 'DM Sans', sans-serif;
  min-width: 160px;
}

.station-analysis-icon { background: none !important; border: none !important; }

.speed-popout-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #888;
  margin-bottom: 8px;
}

.speed-popout .speed-type-select {
  width: 100%;
  padding: 5px 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: white;
  color: #444;
  cursor: pointer;
  margin-bottom: 10px;
}

.speed-popout-legend {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sp-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #555;
}

.sp-swatch {
  width: 22px;
  height: 4px;
  border-radius: 2px;
  flex-shrink: 0;
}

.speed-popout-divider {
  height: 1px;
  background: #e0e0e0;
  margin: 10px 0;
}

/* Hide the inline speed legend in the layers panel */
.speed-legend { display: none !important; }

/* ============================================================================
   LINE DIAGRAM — schematic strip showing stations/crossings along the line
   ============================================================================ */
.line-diagram {
  position: relative;
  padding: 30px 20px 110px;
  margin: 18px 0 12px;
  overflow: visible;
}

/* Extra top padding when branch row is above */
.line-diagram.has-branch {
  padding-top: 80px;
}

.line-diagram-track {
  position: relative;
  height: 4px;
  background: rgb(128, 39, 108);
  border-radius: 2px;
}

/* Branch label — below the branch track */
.diagram-track-label {
  position: absolute;
  left: 0;
  bottom: -16px;
  font-family: 'DM Sans', sans-serif;
  font-size: 10px;
  font-weight: 600;
  color: rgb(128, 39, 108);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  pointer-events: none;
  white-space: nowrap;
}

/* Foxboro branch: horizontal track ABOVE main */
.line-diagram-branch-row {
  position: relative;
  margin-bottom: 38px;
  height: 4px;
  background: rgb(160, 93, 145);
  border-radius: 2px;
}

/* Branch station labels go ABOVE (rotate negative) */
.line-diagram-branch-row .diagram-label {
  top: auto;
  bottom: 18px;
  transform: rotate(-45deg);
  transform-origin: bottom left;
}

/* Branch crossing labels also go above */
.line-diagram-branch-row .diagram-xing .diagram-label {
  top: auto;
  bottom: 28px;
  transform: rotate(-45deg);
  transform-origin: bottom left;
}

/* Branch MP ticks point upward */
.line-diagram-branch-row .diagram-mp {
  top: auto;
  bottom: -16px;
}
.line-diagram-branch-row .diagram-mp::after {
  top: auto;
  bottom: 16px;
}

/* Vertical connector between branch (above) and main (below) */
.branch-connector {
  position: absolute;
  z-index: 0;
}

.branch-connector svg {
  display: block;
}

/* Milepost tick marks — ABOVE the track line */
.diagram-mp {
  position: absolute;
  top: -22px;
  font-family: 'DM Mono', monospace;
  font-size: 9px;
  font-weight: 500;
  color: #aaa;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 1;
}
.diagram-mp::after {
  content: '';
  position: absolute;
  top: 12px;
  left: 50%;
  width: 1px;
  height: 12px;
  background: #ccc;
}

.diagram-stop {
  position: absolute;
  top: -6px;
  width: 16px;
  height: 16px;
  margin-left: -8px;
  border-radius: 50%;
  background: rgb(128, 39, 108);
  border: 2.5px solid white;
  box-shadow: 0 0 0 1px rgba(128, 39, 108, 0.6);
  cursor: pointer;
  z-index: 2;
  transition: transform 0.12s;
}

.diagram-stop:hover, .diagram-stop.active {
  transform: scale(1.4);
  box-shadow: 0 0 0 2px rgb(128, 39, 108);
}

.diagram-stop.terminal {
  width: 20px;
  height: 20px;
  margin-left: -10px;
  top: -8px;
}

.diagram-label {
  position: absolute;
  top: 18px;
  left: 0;
  font-family: 'DM Sans', sans-serif;
  font-size: 10px;
  font-weight: 600;
  color: #555;
  white-space: nowrap;
  transform: rotate(45deg);
  transform-origin: top left;
  pointer-events: none;
}

/* Dynamic stagger using CSS custom property --stagger */
.diagram-stop.staggered .diagram-label { top: calc(18px + var(--stagger)); }
.diagram-stop.staggered::after {
  content: ''; position: absolute;
  top: 16px; left: 50%; width: 1px;
  height: var(--stagger);
  background: rgba(128, 39, 108, 0.18);
}
.diagram-xing.staggered .diagram-label { top: calc(18px + var(--stagger)); }
.diagram-xing.staggered::after {
  content: ''; position: absolute;
  top: 24px; left: 50%; width: 1px;
  height: var(--stagger);
  background: rgba(128, 39, 108, 0.18);
}

/* Label flipped above the track */
.diagram-xing.label-above .diagram-label {
  top: auto;
  bottom: 28px;
  transform: rotate(-45deg);
  transform-origin: bottom left;
}
.diagram-xing.label-above.staggered .diagram-label {
  bottom: calc(28px + var(--stagger));
}
.diagram-xing.label-above.staggered::after {
  top: auto;
  bottom: 24px;
}

.diagram-xing {
  position: absolute;
  top: -12px;
  width: 24px;
  height: 24px;
  margin-left: -12px;
  cursor: pointer;
  z-index: 2;
  transition: transform 0.12s;
}

.diagram-xing:hover { transform: scale(1.3); }

.diagram-xing img {
  width: 100%;
  height: 100%;
}

/* Tooltip for diagram items */
.diagram-tooltip {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255,255,255,0.97);
  border-radius: 6px;
  padding: 10px 14px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.15);
  font-family: 'DM Sans', sans-serif;
  z-index: 10;
  pointer-events: none;
  white-space: nowrap;
  display: none;
}

.diagram-stop:hover .diagram-tooltip,
.diagram-stop.active .diagram-tooltip { display: block; }

/* ============================================================================
   MAP WRAPPER — contained box with rounded corners
   ============================================================================ */
.map-wrapper {
  position: relative;
  width: 100%;
  height: 78vh;
  min-height: 520px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 16px rgba(0,0,0,0.10);
  background: #e8e8e8;
}

/* Override shared #map absolute positioning for the contained layout */
.map-wrapper #map {
  position: absolute !important;
  top: 0; left: 0;
  width: 100% !important;
  height: 100% !important;
  z-index: 1;
}

.map-buffer { height: 48px; }

/* ============================================================================
   LAYERS PANEL — collapsible control inside the map
   ============================================================================ */
.layers-panel {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.14);
  font-family: 'DM Sans', sans-serif;
  overflow: hidden;
  transition: box-shadow 0.2s;
}

.layers-panel:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.18); }

/* Collapsed = icon only */
.layers-panel.collapsed { cursor: pointer; }
.layers-panel.collapsed .layers-body { display: none; }

.layers-toggle-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 9px 14px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: #555;
  white-space: nowrap;
}

.layers-toggle-btn .layers-icon {
  font-size: 16px;
  line-height: 1;
}

.layers-panel.collapsed .layers-toggle-btn .layers-label { display: none; }
.layers-panel.collapsed .layers-toggle-btn { padding: 10px 12px; }

/* Expanded body */
.layers-body {
  padding: 0 14px 14px;
}

.layers-group {
  padding: 10px 0;
  border-top: 1px solid #eaeaea;
}
.layers-group:first-child { border-top: none; padding-top: 4px; }

.layers-group-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #999;
  margin: 0 0 8px;
}

/* Toggle row */
.layer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
}

.layer-row label {
  font-size: 13px;
  color: #444;
  cursor: pointer;
  user-select: none;
}

/* Custom toggle switch */
.toggle-switch {
  position: relative;
  width: 34px;
  height: 18px;
  -webkit-appearance: none;
  appearance: none;
  background: #ccc;
  border-radius: 9px;
  outline: none;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}
.toggle-switch:checked { background: rgb(128, 39, 108); }
.toggle-switch::before {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.toggle-switch:checked::before { transform: translateX(16px); }

/* Basemap thumbnails */
.basemap-row {
  display: flex;
  gap: 6px;
  padding: 4px 0;
}

.basemap-thumb {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  border: 2px solid transparent;
  cursor: pointer;
  background-size: cover;
  background-position: center;
  transition: border-color 0.15s;
  flex-shrink: 0;
}
.basemap-thumb:hover { border-color: #bbb; }
.basemap-thumb.active { border-color: rgb(128, 39, 108); }

/* Destination segmented control */
.dest-segment {
  display: flex;
  border: 1.5px solid rgb(128, 39, 108);
  border-radius: 5px;
  overflow: hidden;
  margin: 4px 0;
}

.dest-segment button {
  flex: 1;
  padding: 5px 0;
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  background: white;
  color: rgb(128, 39, 108);
  transition: background 0.15s, color 0.15s;
}

.dest-segment button + button { border-left: 1.5px solid rgb(128, 39, 108); }
.dest-segment button.active { background: rgb(128, 39, 108); color: white; }

/* Line display radio options */
.display-radios {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 4px 0;
}

.display-radio {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
}

.display-radio input[type="radio"] {
  accent-color: rgb(128, 39, 108);
  margin: 0;
  cursor: pointer;
}

.display-radio span {
  font-size: 13px;
  color: #444;
}

/* Track count legend within layers panel */
.track-legend {
  display: none;
  flex-direction: column;
  gap: 3px;
  padding: 6px 0 0 22px;
}

.track-legend.visible { display: flex; }

.track-legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  color: #666;
}

.track-legend-swatch {
  width: 20px;
  height: 3px;
  border-radius: 1px;
  flex-shrink: 0;
}

/* Direction filter inside layers panel */
.direction-segment {
  display: flex;
  border: 1px solid #ccc;
  border-radius: 4px;
  overflow: hidden;
  margin: 4px 0;
}

.direction-segment button {
  flex: 1;
  padding: 4px 0;
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  background: white;
  color: #666;
  transition: background 0.12s, color 0.12s;
}

.direction-segment button + button { border-left: 1px solid #ccc; }
.direction-segment button.active { background: rgb(128, 39, 108); color: white; }

/* ============================================================================
   FOOTER
   ============================================================================ */
.page-footer {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 32px;
  background: white;
}

.page-footer::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg,
    transparent 0%,
    transparent 80%,
    rgb(128, 39, 108) 100%);
}

.page-footer .footer-left,
.page-footer .footer-right {
  display: flex;
  gap: 8px;
  align-items: center;
}

.page-footer .footer-link {
  color: #666;
  font-size: 13px;
  font-family: 'DM Sans', sans-serif;
  text-decoration: none;
}

.page-footer .footer-link:hover { color: rgb(128, 39, 108); }
.page-footer .footer-separator { color: #ccc; }

.page-footer .footer-right {
  color: #666;
  font-size: 13px;
  font-family: 'DM Sans', sans-serif;
}

/* ============================================================================
   LEAFLET OVERRIDES for contained map
   ============================================================================ */
.map-wrapper .leaflet-top.leaflet-left {
  top: auto !important;
  bottom: 12px !important;
}

.map-wrapper .leaflet-control-zoom {
  margin-left: 12px !important;
  margin-bottom: 0 !important;
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */
@media (max-width: 900px) {
  .page-header { padding: 10px 16px; }
  .page-main { padding: 20px 16px 0; }
  .page-footer { padding: 14px 16px; }
  .section-tabs .tab-btn { padding: 10px 14px; font-size: 13px; }
  .map-wrapper { height: 55vh; min-height: 340px; border-radius: 8px; }
}
