/* CSS Variables matching your website */
:root {
    --primary-color: #252525;
    --text-color: #333333;
    --background-card: rgba(255, 255, 255, 0.25);
    --theme-rail: #8B4513;      /* Retro brown for railways */
    --theme-vintage: #D2691E;   /* Vintage orange */
    --transition-standard: all 0.3s ease;
}

html {
    margin: 0;
    padding: 0;
    height: 100%;
    height: -webkit-fill-available;
}

body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    min-height: -webkit-fill-available;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    background: #f6f2e7;
    overflow-x: hidden;
    position: relative;
}

/* Static route heading on iconic route pages */
.route-page-title {
    font-family: 'Source Serif 4', serif;
    font-size: 22px;
    font-weight: 400;
    margin: 0 0 4px 0;
    color: #333;
}

.map-overlay.dark-theme .route-page-title {
    color: #f5f5f5;
}

@media (prefers-color-scheme: dark) {
    body {
        background: #1d1f20;
    }
}

#map {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100lvh;
    height: 100dvh;
}

.map-overlay {
    position: absolute;
    top: max(20px, env(safe-area-inset-top, 0px));
    left: max(20px, env(safe-area-inset-left, 0px));
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(10px) saturate(200%);
    -webkit-backdrop-filter: blur(10px) saturate(200%);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 1.5rem;
    max-width: 350px;
    max-height: calc(100dvh - 60px);
    box-sizing: border-box;
    overflow: hidden;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-color);
    box-shadow:
        0 8px 32px rgba(31, 38, 135, 0.2),
        inset 0 2px 10px rgba(255, 255, 255, 0.3);
    transition: var(--transition-standard);
}

.map-overlay-content {
    padding: 2rem;
    max-height: calc(100dvh - 60px);
    overflow-y: auto;
    overflow-x: hidden;
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}

/* Sidebar toggle button (desktop only) */
.sidebar-toggle {
    display: none;
}

@media (min-width: 769px) {
    .sidebar-toggle {
        display: block;
        position: absolute;
        top: 12px;
        right: 12px;
        background: none;
        border: none;
        cursor: pointer;
        font-size: 16px;
        color: #999;
        padding: 4px 8px;
        transition: color 0.2s ease;
        z-index: 10;
    }

    .sidebar-toggle:hover {
        color: #333;
    }

    .map-overlay {
        transition: transform 0.3s ease;
    }

    .map-overlay.collapsed {
        transform: translateX(calc(-100% + 32px));
    }

    .map-overlay.collapsed .map-overlay-content {
        opacity: 0;
        pointer-events: none;
    }

    .map-overlay.collapsed .sidebar-toggle {
        right: 4px;
        color: #666;
    }
}

.map-overlay.dark-theme .sidebar-toggle {
    color: #666;
}

.map-overlay.dark-theme .sidebar-toggle:hover {
    color: #fff;
}

.map-overlay-content::-webkit-scrollbar {
    width: 6px;
}

.map-overlay-content::-webkit-scrollbar-track {
    background: transparent;
    margin: 1rem 0;
}

.map-overlay-content::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.map-overlay-content::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

.map-overlay.dark-theme {
    background: rgba(0, 0, 0, 0.3);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.3), 
        inset 0 2px 10px rgba(255, 255, 255, 0.1);
}

.map-overlay.dark-theme h3 {
    color: #ffffff;
}

.map-overlay.dark-theme p {
    color: #cccccc;
}

.map-overlay.dark-theme .basemap-selector label {
    color: #cccccc;
}

.map-overlay.dark-theme .camera-mode label {
    color: #cccccc;
}

.map-overlay.dark-theme .camera-btn {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.map-overlay.dark-theme .camera-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

.map-overlay.dark-theme .camera-btn.active {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    color: #ffffff;
}

.map-overlay.dark-theme .back-link {
    color: #ffffff;
}

.map-overlay.dark-theme .attributions p {
    color: #aaa;
}

.map-overlay.dark-theme .attributions a {
    color: #aaa;
}

.map-overlay.dark-theme .attributions a:hover {
    color: #ffffff;
}

.map-overlay.dark-theme .legend-item.animating::after {
    color: #ffffff;
}

.map-overlay.dark-theme .basemap-btn {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.map-overlay.dark-theme .basemap-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

.map-overlay.dark-theme .basemap-btn.active {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    color: #ffffff;
}

.map-overlay h3 {
    font-family: 'Source Serif 4', serif;
    margin: 0 0 10px 0;
    font-size: 16px;
    font-weight: 400;
    color: var(--primary-color);
}

.map-overlay p {
    margin: 0 0 10px 0;
    color: #666;
}

.legend {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 15px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
    touch-action: manipulation;
}

.legend-item:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.legend-color {
    width: 16px;
    height: 3px;
    border-radius: 2px;
    position: relative;
}

.legend-item {
    position: relative;
}

.legend-item.animating::after {
    content: '';
    position: absolute;
    right: 6px;
    top: 50%;
    width: 14px;
    height: 14px;
    background-image: url('train-wheel.svg');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    transform: translateY(-50%);
    animation: trainWheel 1.5s linear infinite;
    transform-origin: center center;
}

.legend-item.completed::after {
    content: '✓';
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    color: #4CAF50;
    font-weight: bold;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes trainWheel {
    0% { transform: translateY(-50%) rotate(0deg); }
    100% { transform: translateY(-50%) rotate(360deg); }
}

.maplibregl-ctrl-logo {
    display: none !important;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.basemap-selector {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 8px;
}

.basemap-selector label {
    font-size: 12px;
    font-weight: 500;
    color: #666;
    white-space: nowrap;
}

.basemap-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-top: 8px;
}

.basemap-btn {
    flex: 1;
    min-width: 50px;
    padding: 6px 8px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    font-size: 10px;
    color: var(--text-color);
    cursor: pointer;
    transition: var(--transition-standard);
    touch-action: manipulation; /* Prevents double-tap zoom */
}

.basemap-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
}

.basemap-btn.active {
    background: rgba(255, 255, 255, 0.7);
    border-color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
    color: var(--primary-color);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.camera-mode {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 8px;
}

.camera-mode label {
    font-size: 12px;
    font-weight: 500;
    color: #666;
    white-space: nowrap;
}

.camera-buttons {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.camera-btn {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    font-size: 10px;
    color: var(--text-color);
    cursor: pointer;
    transition: var(--transition-standard);
    touch-action: manipulation;
}

.camera-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
}

.camera-btn.active {
    background: rgba(255, 255, 255, 0.7);
    border-color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
    color: var(--primary-color);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.admin-section {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.admin-section label:first-child {
    font-size: 12px;
    font-weight: 500;
    color: #e67300;
    margin-bottom: 8px;
    display: block;
}

.admin-toggles {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.admin-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--text-color);
    cursor: pointer;
}

.admin-toggle input[type="checkbox"] {
    width: 14px;
    height: 14px;
    cursor: pointer;
}

.projection-switch {
    position: relative;
    display: flex;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(10px);
    padding: 2px;
}

.switch-slider {
    position: absolute;
    top: 2px;
    left: 2px;
    width: calc(50% - 2px);
    height: calc(100% - 4px);
    background: rgba(255, 255, 255, 0.7);
    border-radius: 4px;
    transition: transform 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.projection-switch.flat .switch-slider {
    transform: translateX(100%);
}

.switch-option {
    position: relative;
    z-index: 1;
    flex: 1;
    padding: 6px 10px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--text-color);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
}

.switch-option.active {
    color: var(--primary-color);
}

.switch-option svg {
    display: block;
}

.map-overlay.dark-theme .projection-switch {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.map-overlay.dark-theme .switch-slider {
    background: rgba(255, 255, 255, 0.3);
}

.map-overlay.dark-theme .switch-option {
    color: #fff;
}

.map-overlay.dark-theme .switch-option.active {
    color: #fff;
}

/* Terrain toggle styles */
.terrain-toggle {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    display: none; /* Hidden by default, shown on localhost only */
    align-items: center;
    gap: 8px;
}

.terrain-toggle label {
    font-size: 12px;
    font-weight: 500;
    color: #666;
    white-space: nowrap;
}

.terrain-switch {
    position: relative;
    display: flex;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(10px);
    padding: 2px;
}

.terrain-switch.terrain-on .switch-slider {
    transform: translateX(100%);
}

.map-overlay.dark-theme .terrain-toggle {
    border-color: rgba(255, 255, 255, 0.1);
}

.map-overlay.dark-theme .terrain-toggle label {
    color: #cccccc;
}

.map-overlay.dark-theme .terrain-switch {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.back-link {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition-standard);
}

.back-link:hover {
    opacity: 0.7;
}

.attributions {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.attributions p {
    font-size: 10px;
    line-height: 1.4;
    color: #999;
    margin: 0;
}

.attributions a {
    color: #999;
    text-decoration: none;
}

.attributions a:hover {
    color: var(--primary-color);
}

/* Route Creator */
.route-creator {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.route-creator label {
    display: block;
    margin-bottom: 8px;
    font-size: 12px;
    font-weight: 500;
    color: #666;
}

.station-input-wrapper {
    position: relative;
    margin-bottom: 8px;
}

.station-input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    font-size: 12px;
    color: var(--text-color);
    box-sizing: border-box;
    transition: var(--transition-standard);
}

.station-input:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.2);
}

.station-input::placeholder {
    color: #999;
}

.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1001;
    display: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.autocomplete-dropdown.visible {
    display: block;
}

.autocomplete-item {
    padding: 8px 10px;
    cursor: pointer;
    font-size: 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
    background: rgba(0, 0, 0, 0.05);
}

.autocomplete-item .country {
    font-size: 10px;
    color: #999;
}

.autocomplete-item .country small {
    background: rgba(153, 15, 61, 0.15);
    color: #990f3d;
    padding: 1px 4px;
    border-radius: 3px;
    margin-left: 4px;
    font-size: 9px;
}

.autocomplete-item.osm-search-option {
    color: #990f3d;
    font-style: italic;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.autocomplete-item.osm-loading,
.autocomplete-item.osm-message {
    color: #666;
    font-style: italic;
    pointer-events: none;
}

.autocomplete-item.osm-result {
    background: rgba(153, 15, 61, 0.03);
}

.add-stop-link {
    display: block;
    font-size: 11px;
    color: #888;
    text-decoration: none;
    cursor: pointer;
    margin: 4px 0 8px 0;
    touch-action: manipulation;
}

.add-stop-link:hover {
    color: var(--primary-color);
}

.via-input-wrapper {
    position: relative;
    margin-bottom: 8px;
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.via-input-wrapper .autocomplete-dropdown {
    width: calc(100% - 38px); /* Account for remove button */
}

.via-input-wrapper .station-input {
    flex: 1;
}

.via-input-wrapper .remove-via-btn {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 4px 8px;
    font-size: 16px;
    line-height: 1;
    border-radius: 4px;
    transition: var(--transition-standard);
    touch-action: manipulation;
}

.via-input-wrapper .remove-via-btn:hover {
    background: rgba(255, 0, 0, 0.1);
    color: #c00;
}

.create-route-btn {
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: 6px;
    background: var(--primary-color);
    color: white;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-standard);
    margin-top: 4px;
    touch-action: manipulation;
}

.create-route-btn:hover {
    opacity: 0.9;
}

.create-route-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Create your own button (shown in default mode) */
.create-own-btn {
    width: 100%;
    padding: 10px;
    margin-top: 15px;
    border: 1px dashed rgba(0, 0, 0, 0.3);
    border-radius: 6px;
    background: transparent;
    color: var(--text-color);
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition-standard);
    touch-action: manipulation;
}

.create-own-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.5);
}

/* User routes legend */
.user-routes-legend {
    margin-top: 15px;
}

.user-routes-legend label {
    display: block;
    margin-bottom: 8px;
    font-size: 12px;
    font-weight: 500;
    color: #666;
}

.user-route-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    padding: 6px;
    border-radius: 4px;
    margin-bottom: 4px;
    background: rgba(0, 0, 0, 0.03);
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.user-route-item:hover {
    background: rgba(0, 0, 0, 0.08);
}

.user-route-item .route-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-route-item .route-distance {
    font-size: 10px;
    color: #888;
    white-space: nowrap;
}

.share-btn,
.create-new-btn {
    flex: 1;
    padding: 8px;
    margin-top: 10px;
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    background: transparent;
    color: var(--text-color);
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition-standard);
    touch-action: manipulation;
}

.share-btn:hover,
.create-new-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.3);
}

.share-btn.copied {
    background: rgba(76, 175, 80, 0.1);
    border-color: #4CAF50;
    color: #4CAF50;
}

.url-reminder {
    font-size: 11px;
    color: #e67e22;
    margin: 8px 0 0 0;
    padding: 6px 8px;
    background: rgba(230, 126, 34, 0.1);
    border-radius: 4px;
    text-align: center;
}

/* Idle mode destination marker */
.idle-marker {
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: fadeInMarker 0.3s ease-out;
}

@keyframes fadeInMarker {
    from { opacity: 0; }
    to { opacity: 1; }
}

.idle-marker.fade-out {
    animation: fadeOutMarker 0.3s ease-in forwards;
}

@keyframes fadeOutMarker {
    from { opacity: 1; }
    to { opacity: 0; }
}

.idle-marker-dot {
    width: 12px;
    height: 12px;
    background: #990f3d;
    border: 2px solid white;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.idle-marker-label {
    background: white;
    color: #333;
    padding: 4px 10px;
    border-radius: 4px;
    font-family: 'Source Serif 4', serif;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 4px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    white-space: nowrap;
}

/* Speed marker for realistic speed mode */
.speed-marker {
    display: flex;
    align-items: center;
    gap: 4px;
    pointer-events: none;
    transform: translateX(-7px); /* Center the dot on the coordinate */
}

.speed-marker-dot {
    width: 10px;
    height: 10px;
    background: #990f3d;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    flex-shrink: 0;
}

.speed-marker-label {
    background: rgba(0, 0, 0, 0.75);
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.user-route-item .delete-btn {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 2px 6px;
    font-size: 14px;
    line-height: 1;
    border-radius: 3px;
    transition: var(--transition-standard);
}

.user-route-item .delete-btn:hover {
    background: rgba(255, 0, 0, 0.1);
    color: #c00;
}

/* Back to showcase link */
.back-to-showcase {
    display: block;
    margin-top: 12px;
    font-size: 11px;
    color: #666;
    text-decoration: none;
    cursor: pointer;
}

.back-to-showcase:hover {
    color: var(--primary-color);
}

/* Editable map title for create mode */
.map-title-input {
    display: none;
    width: 100%;
    font-family: 'Source Serif 4', serif;
    font-size: 16px;
    font-weight: 400;
    color: var(--primary-color);
    background: transparent;
    border: none;
    border-bottom: 1px dashed rgba(0, 0, 0, 0.2);
    padding: 0 0 4px 0;
    margin: 0 0 10px 0;
    outline: none;
    box-sizing: border-box;
}

.map-title-input::placeholder {
    color: #999;
    font-style: italic;
}

.map-title-input:focus {
    border-bottom-color: var(--primary-color);
}

/* Hide elements based on mode */
.create-mode .default-legend,
.create-mode .create-own-btn {
    display: none;
}

.create-mode #overlay-title {
    display: none;
}

.create-mode .map-title-input {
    display: block;
}

.default-mode .route-creator,
.default-mode .user-routes-legend,
.default-mode .back-to-showcase,
.default-mode .map-title-input {
    display: none;
}

/* Dark theme additions */
.map-overlay.dark-theme .create-own-btn {
    border-color: rgba(255, 255, 255, 0.3);
    color: #ffffff;
}

.map-overlay.dark-theme .create-own-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.5);
}

.map-overlay.dark-theme .user-route-item {
    background: rgba(255, 255, 255, 0.05);
}

.map-overlay.dark-theme .user-route-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.map-overlay.dark-theme .user-route-item .route-distance {
    color: #999;
}

.map-overlay.dark-theme .share-btn,
.map-overlay.dark-theme .create-new-btn {
    border-color: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.map-overlay.dark-theme .share-btn:hover,
.map-overlay.dark-theme .create-new-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
}

.map-overlay.dark-theme .url-reminder {
    color: #f39c12;
    background: rgba(243, 156, 18, 0.15);
}

.map-overlay.dark-theme .user-routes-legend label {
    color: #cccccc;
}

.map-overlay.dark-theme .back-to-showcase {
    color: #aaa;
}

.map-overlay.dark-theme .back-to-showcase:hover {
    color: #ffffff;
}

.map-overlay.dark-theme .map-title-input {
    color: #ffffff;
    border-bottom-color: rgba(255, 255, 255, 0.2);
}

.map-overlay.dark-theme .map-title-input::placeholder {
    color: #888;
}

.map-overlay.dark-theme .map-title-input:focus {
    border-bottom-color: rgba(255, 255, 255, 0.5);
}

/* Dark theme for route creator */
.map-overlay.dark-theme .station-input {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.map-overlay.dark-theme .station-input::placeholder {
    color: #aaa;
}

.map-overlay.dark-theme .route-creator label {
    color: #cccccc;
}

.map-overlay.dark-theme .autocomplete-dropdown {
    background: rgba(30, 30, 30, 0.95);
    border-color: rgba(255, 255, 255, 0.1);
}

.map-overlay.dark-theme .autocomplete-item {
    color: #ffffff;
    border-bottom-color: rgba(255, 255, 255, 0.05);
}

.map-overlay.dark-theme .autocomplete-item:hover,
.map-overlay.dark-theme .autocomplete-item.selected {
    background: rgba(255, 255, 255, 0.1);
}

.map-overlay.dark-theme .add-stop-link {
    color: #888;
}

.map-overlay.dark-theme .add-stop-link:hover {
    color: #fff;
}

.map-overlay.dark-theme .remove-via-btn {
    color: #888;
}

.map-overlay.dark-theme .remove-via-btn:hover {
    background: rgba(255, 100, 100, 0.2);
    color: #f88;
}

/* Desktop header styling */
.map-overlay h3 {
    font-family: 'Source Serif 4', serif;
    margin: 0 0 10px 0;
    font-size: 16px;
    font-weight: 400;
    color: var(--primary-color);
}

/* Hide mobile elements on desktop */
.mobile-header {
    display: none;
}

.expand-button {
    display: none;
}

/* Mobile styles */
@media (max-width: 768px) {
    .map-overlay {
        position: absolute;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        max-width: none;
        border-radius: 1rem 1rem 0 0;
        padding: 1rem;
        padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
        transform: translateY(calc(100% - 80px - env(safe-area-inset-bottom, 0px)));
        transition: transform 0.3s ease;
        z-index: 1000;
    }

    .map-overlay.expanded {
        transform: translateY(0);
    }

    .map-overlay > h3:not(.mobile-header h3) {
        display: none; /* Hide desktop header on mobile */
    }

    .mobile-header h3 {
        font-size: 14px;
        margin: 0;
    }

    .map-overlay p {
        font-size: 12px;
        margin: 0 0 8px 0;
        display: none; /* Hide description when collapsed */
    }

    .map-overlay.expanded p {
        display: block;
    }

    .mobile-header {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 1rem;
        cursor: pointer;
    }

    .expand-button {
        display: block !important;
        background: none;
        border: none;
        color: var(--text-color);
        font-size: 18px;
        cursor: pointer;
        padding: 4px;
        border-radius: 50%;
        transition: var(--transition-standard);
        touch-action: manipulation;
    }

    .expand-button:hover {
        background: rgba(255, 255, 255, 0.1);
    }

    .legend {
        display: none;
    }

    .map-overlay.expanded .legend {
        display: flex;
    }

    /* Compact settings on mobile */
    .basemap-selector,
    .camera-mode,
    .terrain-toggle {
        display: flex;
        align-items: center;
        gap: 8px;
        margin-top: 10px;
        padding-top: 10px;
    }

    .basemap-selector label,
    .camera-mode label,
    .terrain-toggle label {
        font-size: 10px;
        margin-bottom: 0;
        white-space: nowrap;
        min-width: fit-content;
    }

    .basemap-grid {
        gap: 4px;
        margin-top: 6px;
    }

    .camera-buttons {
        flex: 1;
        gap: 3px;
        margin-top: 0;
    }

    .basemap-btn,
    .camera-btn {
        font-size: 9px;
        padding: 4px 5px;
        min-width: unset;
    }

    .switch-option {
        padding: 4px 8px;
    }

    .switch-option svg {
        width: 12px;
        height: 12px;
    }

    .attributions {
        margin-top: 10px;
        padding-top: 10px;
        display: none;
    }

    .map-overlay.expanded .attributions {
        display: block;
    }

    /* Prevent iOS auto-zoom on input focus */
    .station-input,
    .map-title-input {
        font-size: 16px;
    }

    /* Hide title input on mobile when collapsed, show only when expanded */
    .create-mode .map-title-input {
        display: none !important;
    }

    .map-overlay.expanded.create-mode .map-title-input {
        display: block !important;
    }

    /* Hide mobile header title when input is visible (to avoid duplication) */
    .map-overlay.expanded.create-mode #mobile-header-title {
        display: none;
    }

    /* Dark theme mobile adjustments */
    .map-overlay.dark-theme .expand-button {
        color: #ffffff;
    }

    .map-overlay.dark-theme .mobile-header h3 {
        color: #ffffff;
    }
}

/* Static route info on iconic route pages (SEO content) */
.route-info {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 12px;
    color: #666;
}

.route-info h2 {
    font-family: 'Source Serif 4', serif;
    font-size: 14px;
    font-weight: 400;
    color: var(--primary-color);
    margin: 12px 0 6px 0;
}

.route-info p {
    margin: 0 0 8px 0;
}

.route-info .route-stations {
    margin: 0 0 10px 0;
    padding-left: 18px;
}

.route-info .route-stations li {
    margin-bottom: 2px;
}

.route-info a {
    color: #990f3d;
    text-decoration: none;
}

.route-info a:hover {
    text-decoration: underline;
}

.map-overlay.dark-theme .route-info {
    border-top-color: rgba(255, 255, 255, 0.1);
    color: #cccccc;
}

.map-overlay.dark-theme .route-info h2 {
    color: #ffffff;
}

.map-overlay.dark-theme .route-info a {
    color: #f29db8;
}

