.map > p {
    width: 80%;
    margin: auto;
}

.map-instructions {
    display: flex;
    justify-content: space-around;
    margin: auto;
}

.map-container {
    min-height: 500px;
    width: 70%;
    margin: 2em auto;
    border: 2px solid var(--primary-color);
    border-radius: 1em;
    overflow: hidden;
}

.map-element {
    width: 100%;
    height: 500px;
}

.map-controls {
    margin: auto;
    justify-items: center;
    width: 65%;
}

.search-container {
    background-color: rgba(249, 187, 1, 0.12);
    border: 2px solid rgba(0, 23, 39, 0.25);
    border-radius: 14px;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 1em;
    width: 100%;
    padding: 1em;
}

html.theme-dark .search-container {
    background-color: rgba(0, 23, 39, 0.75);
    border-color: #F9BB01;
}

.search-input-group {
    position: relative !important;
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 240px !important;
    min-width: 200px !important;
}

/* ── Autocomplete Search Suggestions Dropdown (Scrollable 3 at a time) ── */
.search-suggestions {
    display: none;
    position: absolute !important;
    top: calc(100% + 4px) !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-height: 138px !important; /* Shows exactly 3 items (3 x 46px) at a time */
    overflow-y: auto !important;
    overflow-x: hidden !important;
    background: #ffffff !important;
    border: 1.5px solid rgba(0, 23, 39, 0.2) !important;
    border-radius: 8px !important;
    box-shadow: 0 6px 20px rgba(0, 23, 39, 0.18) !important;
    z-index: 1050 !important;
    box-sizing: border-box !important;
    padding: 0 !important;
    margin: 0 !important;
    scrollbar-width: thin !important;
    scrollbar-color: #F9BB01 rgba(0, 23, 39, 0.08) !important;
}

.search-suggestions.visible {
    display: flex !important;
    flex-direction: column !important;
}

.search-container button.search-suggestion,
.search-suggestion {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    height: 46px !important;
    min-height: 46px !important;
    max-height: 46px !important;
    padding: 0 0.85rem !important;
    background: transparent !important;
    border: none !important;
    border-bottom: 1px solid rgba(0, 23, 39, 0.08) !important;
    text-align: left !important;
    cursor: pointer !important;
    color: #001727 !important;
    font-size: 0.9rem !important;
    font-family: inherit !important;
    box-sizing: border-box !important;
    flex-shrink: 0 !important;
    border-radius: 0 !important;
    margin: 0 !important;
    transition: background 0.15s ease, color 0.15s ease !important;
}

.search-container button.search-suggestion:last-child,
.search-suggestion:last-child {
    border-bottom: none !important;
}

.search-container button.search-suggestion:hover,
.search-container button.search-suggestion:focus,
.search-container button.search-suggestion.active,
.search-suggestion:hover,
.search-suggestion:focus,
.search-suggestion.active {
    background: rgba(249, 187, 1, 0.2) !important;
    color: #001727 !important;
    outline: none !important;
}

.search-suggestion .suggestion-label {
    font-weight: 600 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    flex: 1 1 auto !important;
    text-align: left !important;
    color: inherit !important;
}

.search-suggestion .suggestion-label strong {
    color: #b45309 !important;
    text-decoration: underline !important;
}

.search-suggestion .suggestion-subtitle {
    font-size: 0.75rem !important;
    color: #64748b !important;
    margin-left: 0.5rem !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
}

/* Dark Mode Autocomplete Suggestions */
html.theme-dark .search-suggestions,
body.a11y-high-contrast .search-suggestions {
    background: var(--panel-bg-color, #012136) !important;
    border-color: #F9BB01 !important;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.6) !important;
    scrollbar-color: #F9BB01 rgba(0, 23, 39, 0.5) !important;
}

html.theme-dark .search-container button.search-suggestion,
html.theme-dark .search-suggestion,
body.a11y-high-contrast .search-container button.search-suggestion,
body.a11y-high-contrast .search-suggestion {
    color: #fff7d6 !important;
    border-bottom-color: rgba(249, 187, 1, 0.15) !important;
}

html.theme-dark .search-container button.search-suggestion:hover,
html.theme-dark .search-container button.search-suggestion:focus,
html.theme-dark .search-container button.search-suggestion.active,
html.theme-dark .search-suggestion:hover,
html.theme-dark .search-suggestion:focus,
html.theme-dark .search-suggestion.active,
body.a11y-high-contrast .search-container button.search-suggestion:hover,
body.a11y-high-contrast .search-container button.search-suggestion.active,
body.a11y-high-contrast .search-suggestion:hover,
body.a11y-high-contrast .search-suggestion.active {
    background: rgba(249, 187, 1, 0.25) !important;
    color: #F9BB01 !important;
}

html.theme-dark .search-suggestion .suggestion-label strong,
body.a11y-high-contrast .search-suggestion .suggestion-label strong {
    color: #F9BB01 !important;
}

html.theme-dark .search-suggestion .suggestion-subtitle,
body.a11y-high-contrast .search-suggestion .suggestion-subtitle {
    color: #94a3b8 !important;
}

fieldset {
    justify-content: center;
}

legend {
    font-weight: bold;
    color: var(--primary-color);
}

#combined-search-btn {
    width: 48px !important;
    min-width: 48px !important;
    max-width: 48px !important;
    height: 48px !important;
    min-height: 48px !important;
    max-height: 48px !important;
    aspect-ratio: 1 / 1 !important;
    padding: 0 !important;
    border-radius: 12px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    box-sizing: border-box !important;
    background-color: var(--primary-color, #F9BB01) !important;
    color: #001727 !important;
    border: 2px solid var(--primary-color, #F9BB01) !important;
    cursor: pointer !important;
    transition: transform 180ms ease, background-color 180ms ease, box-shadow 180ms ease !important;
}

#combined-search-btn:hover {
    transform: translateY(-2px) !important;
    background-color: #ffd64f !important;
    box-shadow: 0 0 12px rgba(249, 187, 1, 0.45) !important;
}

#combined-search-btn span,
#combined-search-btn .btn-icon {
    font-size: 1.4rem !important;
    line-height: 1 !important;
    margin: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* The switch - the box around the slider */
.changing-places-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  width: auto;
  height: auto;
  border: 0;
  cursor: pointer;
}

/* Hide default HTML checkbox */
.changing-places-toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.changing-places-toggle:has(input:focus-visible) {
  outline: 3px solid var(--primary-color);
  outline-offset: 4px;
}

/* The slider */
.slider {
  position: relative;
  flex: 0 0 60px;
  width: 60px;
  height: 34px;
  cursor: pointer;
  background-color: var(--primary-bg-color);
  -webkit-transition: .4s;
  transition: .4s;
  border: solid var(--primary-color) 2px;
  border-radius: 1em;
}

.slider:before {
  position: absolute;
  content: "";
  height: 26px;
  width: 26px;
  left: 4px;
  bottom: 4px;
  background-color: var(--primary-color);
  -webkit-transition: .4s;
  transition: .4s;
  border-radius: 1em;
}

input:checked + .slider {
  background-color: var(--primary-color);
}

input:checked + .slider:before {
  background-color: var(--primary-bg-color);
}

input:checked + .slider:before {
  -webkit-transform: translateX(26px);
  -ms-transform: translateX(26px);
  transform: translateX(26px);
}

.cp-toggle-label {
  color: var(--primary-color);
  font-weight: bold;
  white-space: nowrap;
}

.location-btn {
    width: 6em;
}

.instruction-card {
    background-color: #ffffff;
    border: 1.5px solid rgba(0, 23, 39, 0.15);
    border-radius: 1em;
    padding: 1em;
    width: 25%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1em;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    color: var(--body-text-color);
}

html.theme-dark .instruction-card {
    background-color: var(--panel-bg-color, #012136);
    border: 2px solid rgba(249, 187, 1, 0.4);
    color: #fff7d6;
    box-shadow: none;
}

.instruction-card p {
    margin: 0;
    font-size: 1em;
}

.instruction-card p:nth-of-type(1) {
    font-size: 2em;
}

.instruction-card div {
    display: flex;
    flex-direction: column;
}

.legend-items {
    width: 85% !important;
    max-width: 1000px;
    margin: 1.5rem auto;
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)) !important;
    gap: 1.25rem;
    align-items: stretch !important;
    justify-items: stretch !important;
}   

.legend-items > div,
.legend-item-card {
    background-color: #ffffff;
    border: 1.5px solid rgba(0, 23, 39, 0.15);
    padding: 1.25rem 1.5rem;
    border-radius: 1rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    width: 100% !important;
    min-height: 7rem;
    box-sizing: border-box;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
    color: var(--body-text-color);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.legend-items > div:hover,
.legend-item-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.1);
}

html.theme-dark .legend-items > div,
html.theme-dark .legend-item-card {
    background-color: var(--panel-bg-color, #012136);
    border: 2px solid rgba(249, 187, 1, 0.35);
    color: #fff7d6;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}

.legend-shape-wrap {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
}

.legend-shape-icon {
    display: block;
    width: 44px;
    height: 44px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.25));
}

.legend-text-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    text-align: left;
}

.legend-text-wrap p:nth-of-type(1) {
    font-size: 1.2rem;
    font-weight: 800;
    margin: 0;
    color: var(--primary-color, #001727);
    line-height: 1.2;
}

html.theme-dark .legend-text-wrap p:nth-of-type(1) {
    color: #F9BB01;
}

.legend-text-wrap p:nth-of-type(2) {
    font-size: 0.95rem;
    margin: 0;
    line-height: 1.4;
    opacity: 0.9;
}

.legend-text-wrap .equipment-highlight,
.equipment-highlight {
    color: #d97706;
    font-weight: 700;
    opacity: 1 !important;
}

html.theme-dark .legend-text-wrap .equipment-highlight,
html.theme-dark .equipment-highlight,
body.theme-dark .legend-text-wrap .equipment-highlight,
body.theme-dark .equipment-highlight,
body.a11y-high-contrast .legend-text-wrap .equipment-highlight,
body.a11y-high-contrast .equipment-highlight {
    color: #F9BB01 !important;
}

.features {
    font-size: 2em;
    width: 50%;
    margin: auto;
}

/* Mobile Responsiveness for Map */
@media (max-width: 768px) {
    .map-container {
        width: 100% !important;
        margin: 1em 0 !important;
        min-height: 380px !important;
        height: 60vh !important;
    }

    .map-element {
        width: 100% !important;
        height: 100% !important;
        min-height: 380px !important;
    }

    .map-controls {
        width: 100% !important;
        padding: 0 !important;
    }

    .search-container {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) auto !important;
        align-items: center !important;
        padding: 0.75rem !important;
        gap: 0.75rem !important;
    }

    .search-input-group {
        display: flex !important;
        flex-direction: column !important;
        position: relative !important;
        flex: 1 1 auto !important;
        min-width: 0 !important;
        width: 100% !important;
        height: auto !important;
    }

    .map-instructions {
        flex-direction: column !important;
        gap: 1rem !important;
        padding: 0 0.5rem !important;
    }

    .leaflet-popup-content {
        max-width: 260px !important;
        font-size: 0.85rem !important;
    }
}

/* ── Leaflet Popup Unified Theming ── */
.leaflet-popup-content-wrapper {
    background: #ffffff;
    color: #001727;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 23, 39, 0.18);
    border: 1.5px solid rgba(0, 23, 39, 0.15);
    padding: 0;
    overflow: hidden;
}

.leaflet-popup-content {
    margin: 0 !important;
    line-height: 1.45;
    min-width: 220px;
    max-width: 295px;
}

.leaflet-popup-tip {
    background: #ffffff;
    border: 1.5px solid rgba(0, 23, 39, 0.15);
    box-shadow: none;
}

.leaflet-popup-close-button {
    color: #001727 !important;
    padding: 6px 8px !important;
    font-size: 1.2rem !important;
    font-weight: 700 !important;
}

.route-info,
.unified-route-popup {
    padding: 0.85rem 1rem;
    background: transparent !important;
    border: none !important;
    box-sizing: border-box;
    width: 100%;
}

.route-popup-badge {
    display: inline-block;
    background: #f9bb01;
    color: #001727;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 4px;
    margin-bottom: 6px;
}

.route-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 4px;
}

.route-popup-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--primary-color, #001727);
    line-height: 1.3;
}

.route-popup-score {
    margin: 0.3rem 0;
    font-size: 0.88rem;
    color: var(--primary-color, #001727);
}

.route-popup-a11y {
    font-size: 0.8rem;
    margin: 6px 0;
    border-top: 1px solid rgba(0, 23, 39, 0.1);
    padding-top: 5px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    color: #334155;
}

.route-popup-weather {
    margin: 6px 0 4px;
    padding-top: 6px;
    border-top: 1px solid rgba(0, 23, 39, 0.1);
    min-height: 24px;
}

.route-popup-footer {
    margin-top: 8px;
    padding-top: 4px;
}

.route-popup-more-link {
    font-weight: 700;
    color: var(--primary-color, #001727);
    text-decoration: underline;
    font-size: 0.9rem;
    display: inline-block;
}

.route-popup-more-link:hover {
    text-decoration: none;
    opacity: 0.85;
}

/* Dark Mode Leaflet Popup */
html.theme-dark .leaflet-popup-content-wrapper,
body.a11y-high-contrast .leaflet-popup-content-wrapper {
    background: var(--panel-bg-color, #012136) !important;
    color: #fff7d6 !important;
    border-color: #F9BB01 !important;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.6) !important;
}

html.theme-dark .leaflet-popup-tip,
body.a11y-high-contrast .leaflet-popup-tip {
    background: var(--panel-bg-color, #012136) !important;
    border-color: #F9BB01 !important;
}

html.theme-dark .leaflet-popup-close-button,
body.a11y-high-contrast .leaflet-popup-close-button {
    color: #F9BB01 !important;
}

html.theme-dark .route-info,
html.theme-dark .unified-route-popup,
body.a11y-high-contrast .route-info,
body.a11y-high-contrast .unified-route-popup {
    background: transparent !important;
    color: #fff7d6 !important;
}

html.theme-dark .route-popup-title,
body.a11y-high-contrast .route-popup-title {
    color: #F9BB01 !important;
}

html.theme-dark .route-popup-score,
body.a11y-high-contrast .route-popup-score {
    color: #e2e8f0 !important;
}

html.theme-dark .route-popup-a11y,
body.a11y-high-contrast .route-popup-a11y {
    border-top-color: rgba(249, 187, 1, 0.25) !important;
    color: #cbd5e1 !important;
}

html.theme-dark .route-popup-weather,
body.a11y-high-contrast .route-popup-weather {
    border-top-color: rgba(249, 187, 1, 0.25) !important;
    color: #fff7d6 !important;
}

html.theme-dark .route-popup-more-link,
body.a11y-high-contrast .route-popup-more-link {
    color: #F9BB01 !important;
}