        :root {
            --background: #f2f7ff;
            --card: #ffffff;
            --primary: #1990ff;
            --primary-dark: #0f6fc7;
            --accent: #10b981;
            --text: #0f172a;
            --muted: #475569;
            --border: #d9e3f4;
        }

        /* --- CORE LAYOUT --- */
        body {
            margin: 0;
            padding: 16px 20px 18px;
            display: flex;
            flex-direction: column;
            align-items: center;
            min-height: 100vh;
            background: radial-gradient(circle at 20% 20%, rgba(16,185,129,0.08), transparent 30%), radial-gradient(circle at 80% 0%, rgba(25,144,255,0.08), transparent 28%), var(--background);
            font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
            color: var(--text);
            position: relative;
        }

        .inspire-btn {
            padding: 10px 15px;
            border: none;
            border-radius: 8px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s;
            font-size: 14px;
            display: flex;
            align-items: center;
            justify-content: center;
            color: #fff;
            text-decoration: none;
            
            /* Glitter effect */
            background: linear-gradient(45deg, #1990ff, #60a5fa, #ffffff, #1990ff);
            background-size: 300% 300%;
            animation: glitter 3s ease infinite;
            box-shadow: 0 4px 15px rgba(25, 144, 255, 0.4);
            text-shadow: 0 1px 2px rgba(0,0,0,0.1);
            width: 100%; /* Fill container */
        }

        .inspire-btn:hover {
            transform: translateY(-1px);
            box-shadow: 0 6px 20px rgba(25, 144, 255, 0.6);
        }

        @keyframes glitter {
            0% { background-position: 0% 50%; }
            50% { background-position: 100% 50%; }
            100% { background-position: 0% 50%; }
        }

        h1 {
            margin-top: 0;
            font-weight: 700;
            letter-spacing: 3px;
            font-size: 26px;
            color: var(--text);
            text-align: center;
            position: relative;
            padding-bottom: 6px;
        }

        h1::after {
            content: "Trip Builder";
            display: block;
            font-weight: 500;
            letter-spacing: 1px;
            font-size: 14px;
            color: var(--muted);
            margin-top: 4px;
        }

        .version-tag {
            margin: 4px 0 12px;
            font-size: 12px;
            color: var(--muted);
            text-align: center;
        }

        /* --- THE MAP CONTAINER --- */
                .map-wrapper {
            position: relative;
            width: 100%;
            max-width: 900px;
            height: 60vh;
            min-height: 400px;
            border-radius: 16px;
            overflow: hidden;
            box-shadow: 0 20px 40px -5px rgba(15, 23, 42, 0.15), 0 0 0 1px rgba(15, 23, 42, 0.05);
            background: #eef2f6;
            margin-bottom: 20px;
            transition: all 0.3s ease;
        }

        .map-wrapper.pseudo-fullscreen {
            position: fixed;
            top: 0;
            left: 0;
            width: 100vw;
            height: 100vh;
            max-width: none;
            max-height: none;
            z-index: 9999;
            border-radius: 0;
            margin: 0;
        }


        #map {
            width: 100%;
            height: 100%;
            background: #f8f9fa;
            z-index: 1; 
        }

        /* --- VINTAGE MAP STYLE --- */
        /* Only apply filter when the map has the 'vintage-look' class */
        #map.vintage-look .leaflet-tile-pane {
            filter: sepia(0.5) contrast(1.1) brightness(0.9) grayscale(0.2);
        }
        
        .custom-div-icon {
            background: transparent;
            border: none;
        }

        .drag-marker {
            background-color: #fff;
            border: 2px solid var(--primary);
            border-radius: 50%;
            box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.5), 0 4px 6px rgba(0,0,0,0.2);
            cursor: grab;
            z-index: 1000 !important;
        }
        
        #route-interaction-path {
            fill: none;
            stroke: transparent;
            stroke-width: 30px;
            stroke-linecap: round;
            stroke-linejoin: round;
            pointer-events: stroke;
            cursor: grab;
        }

        /* --- SVG OVERLAY LAYER --- */
        #route-overlay {
            width: 1px;
            height: 1px;
            overflow: visible !important;
            position: absolute;
            top: 0;
            left: 0;
            z-index: auto; /* Managed by Leaflet pane */
            pointer-events: none; /* Let clicks pass through empty areas */
        }

        .flight-path-line {
            fill: none;
            stroke: #d32f2f;
            stroke-width: 3;
            stroke-dasharray: 8, 6;
            stroke-linecap: round;
            filter: drop-shadow(1px 2px 2px rgba(0,0,0,0.3));
            vector-effect: non-scaling-stroke;
        }

        /* Helicopter Group */
        .heli-group {
            offset-rotate: auto 0deg; 
            offset-path: none; 
            transform-origin: 0px 0px; 
            display: none; 
            will-change: transform, offset-distance;
        }

        .heli-body { fill: #333; }
        
        .rotor {
            transform-origin: 15px 5px;
            animation: spinRotor 0.1s linear infinite;
        }

        @keyframes spinRotor {
            0% { transform: scaleX(1); }
            50% { transform: scaleX(0.1); }
            100% { transform: scaleX(1); }
        }

        /* --- CONTROL PANEL --- */
        .controls {
            margin-bottom: 20px;
            background: #fff;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
            width: 100%;
            max-width: 900px;
            box-sizing: border-box;
            display: grid;
            gap: 15px;
            border: 1px solid var(--border);
        }

        .input-group {
            display: flex;
            gap: 10px;
            align-items: center;
            flex-wrap: wrap;
        }

        .control-actions {
            display: flex;
            gap: 10px;
            justify-content: space-between;
            align-items: center;
            flex-wrap: wrap;
            margin-top: 10px;
            width: 100%;
            max-width: 900px;
            box-sizing: border-box;
        }

        /* --- TRIP SUMMARY --- */
        .trip-summary {
            width: 100%;
            max-width: 900px;
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
            gap: 12px;
            margin: 10px 0 18px;
        }

        .summary-item {
            background: var(--card);
            border: 1px solid var(--border);
            border-radius: 12px;
            padding: 12px 14px;
            box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
            min-height: 76px;
        }

        .summary-label {
            font-size: 12px;
            letter-spacing: 0.4px;
            text-transform: uppercase;
            color: var(--muted);
            margin-bottom: 4px;
        }

        .summary-value {
            font-weight: 700;
            font-size: 20px;
            color: var(--text);
            line-height: 1.2;
        }

        .summary-sub {
            font-size: 12px;
            color: var(--muted);
            margin-top: 4px;
        }

        .summary-warning {
            color: #c71f1f;
        }

        label {
            font-weight: bold;
            font-size: 14px;
            color: var(--muted);
            min-width: 60px;
        }

        input[type="text"] {
            flex-grow: 1;
            padding: 10px;
            border: 1px solid var(--border);
            border-radius: 8px;
            font-size: 16px;
            background: #f8fafc;
        }

        /* Map Style Dropdown */
        select {
            padding: 10px;
            border: 1px solid var(--border);
            border-radius: 8px;
            font-size: 14px;
            background-color: #fff;
            cursor: pointer;
        }

        button {
            padding: 10px 15px;
            border: none;
            border-radius: 8px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s;
            font-size: 14px;
            display: flex;
            align-items: center;
            gap: 5px;
            color: #fff;
        }

        button.primary {
            background: linear-gradient(135deg, var(--primary), var(--primary-dark));
            box-shadow: 0 10px 20px rgba(25, 144, 255, 0.25);
        }

        button.primary:hover {
            transform: translateY(-1px);
            box-shadow: 0 14px 28px rgba(25, 144, 255, 0.25);
        }

        button.secondary {
            background: #e2e8f0;
            color: var(--text);
        }

        button.secondary:hover {
            background: #cbd5e1;
        }

        button.action-btn {
            background: linear-gradient(135deg, var(--accent), #0f9f6e);
            box-shadow: 0 10px 20px rgba(16, 185, 129, 0.2);
        }

        .share-link:hover { text-decoration: underline; }
        
        /* City Label on Map */
        .map-label {
            color: var(--text);
            font-family: 'Inter', sans-serif;
            font-size: 12px;
            font-weight: bold;
            text-align: left;
            white-space: nowrap;
            text-transform: uppercase; 
            text-shadow: 1px 1px 0 #fff, -1px -1px 0 #fff, 1px -1px 0 #fff, -1px 1px 0 #fff;
        }

        .drag-marker {
            width: 14px;
            height: 14px;
            background: #d32f2f;
            border: 3px solid #fff;
            border-radius: 50%;
            box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
        }

        .map-status {
            position: absolute;
            top: 12px;
            left: 50%;
            transform: translateX(-50%);
            background: rgba(15, 23, 42, 0.9);
            color: #fff;
            padding: 8px 14px;
            border-radius: 999px;
            font-size: 13px;
            font-weight: 600;
            display: none;
            align-items: center;
            gap: 8px;
            box-shadow: 0 10px 25px rgba(15, 23, 42, 0.3);
            pointer-events: none;
            z-index: 1200;
        }

        .map-status.loading::before {
            content: "";
            width: 14px;
            height: 14px;
            border-radius: 50%;
            border: 2px solid rgba(255,255,255,0.4);
            border-top-color: #fff;
            animation: spin 0.8s linear infinite;
        }

        .map-status.success {
            background: rgba(16, 185, 129, 0.9);
        }

        .map-status.info {
            background: rgba(25, 144, 255, 0.9);
        }

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

        .api-counter {
            font-size: 12px;
            color: var(--muted);
            margin-top: -6px;
            margin-bottom: 6px;
            text-align: center;
        }

        .helipaddy-popup-title {
            font-weight: 700;
            color: var(--text);
        }

        .helipaddy-popup-link {
            color: var(--primary-dark);
            text-decoration: none;
        }

        .helipaddy-popup-link:hover {
            text-decoration: underline;
        }

        .api-errors {
            margin: 12px 0 6px;
            padding: 10px 12px;
            background: #fff4f4;
            border: 1px solid #fca5a5;
            border-radius: 8px;
            color: #b91c1c;
            font-size: 12px;
            display: none;
            max-width: 900px;
            width: 100%;
            box-sizing: border-box;
        }

        .route-fit-control a {
            width: 28px;
            height: 28px;
            line-height: 28px;
            text-align: center;
            font-size: 14px;
            font-weight: 700;
            color: #111;
            background: #fff;
        }

        .stop-actions {
            display: flex;
            gap: 8px;
        }

        .stop-actions button {
            padding: 6px 10px;
            border: none;
            border-radius: 6px;
            font-weight: 600;
            cursor: pointer;
            font-size: 13px;
        }

        .stop-actions .add-btn {
            background: #0ea5e9;
            color: #fff;
        }

        .stop-actions .delete-btn {
            background: #ef4444;
            color: #fff;
        }

        .route-fit-control a:hover {
            background: #f1f5f9;
        }

        /* --- MODAL POPUP STYLES --- */
        .modal-overlay {
            display: none;
            position: fixed;
            top: 0; left: 0;
            width: 100%; height: 100%;
            background: rgba(0,0,0,0.5);
            z-index: 2000; /* Above everything */
            justify-content: center;
            align-items: center;
        }
        .modal-overlay.open { display: flex; }
        
        .modal-content {
            position: relative;
            background: #fff;
            padding: 25px;
            border-radius: 10px;
            width: 90%;
            max-width: 500px;
            box-shadow: 0 18px 35px rgba(15, 23, 42, 0.2);
            text-align: left;
        }

        .close-modal-x {
            position: absolute;
            top: 15px;
            right: 15px;
            background: none;
            border: none;
            font-size: 28px;
            color: #94a3b8;
            cursor: pointer;
            padding: 0;
            line-height: 1;
            width: 30px;
            height: 30px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 50%;
            transition: all 0.2s;
        }

        .close-modal-x:hover {
            color: #475569;
            background: #f1f5f9;
        }

        .modal-content h3 {
            margin-top: 0;
            color: #2c3e50;
        }

        .modal-content input {
            width: 100%;
            padding: 10px;
            margin: 15px 0;
            box-sizing: border-box;
            border: 2px solid #3498db;
            border-radius: 4px;
            font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
            font-size: 14px;
            color: #333;
            background: #f0f8ff;
        }
        
        .modal-actions {
            display: flex;
            justify-content: flex-end;
            gap: 10px;
        }

        .modal-hint {
            margin: 0 0 12px;
            font-size: 14px;
            color: var(--muted);
        }

        .share-preview {
            margin: 8px 0 10px;
            padding: 10px;
            background: #f8fafc;
            border: 1px dashed var(--border);
            border-radius: 6px;
            font-family: monospace;
            font-size: 13px;
            color: #1f2937;
            word-break: break-all;
        }

        .turnstile-wrapper {
            margin: 10px 0 6px;
        }

        .modal-status {
            margin: 6px 0 12px;
            font-size: 13px;
            color: var(--muted);
        }

        .modal-status.success { color: #0f9f6e; }
        .modal-status.error { color: #d32f2f; }

        /* --- LEG TABLE --- */
        .legs-card {
            margin-top: 20px;
            background: #fff;
            padding: 16px 20px;
            border-radius: 12px;
            box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
            width: 100%;
            max-width: 900px;
            box-sizing: border-box;
            border: 1px solid var(--border);
        }

        .legs-card h3 {
            margin: 0 0 10px;
            font-size: 16px;
            font-weight: 700;
            color: var(--text);
            letter-spacing: 0.5px;
        }

        .legs-table {
            width: 100%;
            border-collapse: collapse;
        }

        .legs-table th,
        .legs-table td {
            text-align: left;
            padding: 10px 8px;
            font-size: 14px;
        }

        .legs-table th {
            color: var(--muted);
            font-weight: 600;
            border-bottom: 1px solid var(--border);
        }

        .legs-table td {
            color: var(--text);
            border-bottom: 1px solid #eef2f7;
        }

        .legs-table .long-leg {
            color: #c71f1f;
            font-weight: 700;
        }

        .legs-table tbody tr:nth-child(even) {
            background: #f8fafc;
        }

        .legs-table .empty-state {
            text-align: center;
            color: var(--muted);
        }

        .pending-cell {
            position: relative;
            color: var(--muted);
        }

        .pending-cell::after {
            content: '...';
            display: inline-block;
            letter-spacing: 2px;
            animation: pulseDots 1s ease-in-out infinite;
        }

        .error-state {
            padding: 24px;
            text-align: center;
            color: #d32f2f;
            background: #fef2f2;
            border-radius: 8px;
            border: 1px solid #fee2e2;
        }

        .error-detail {
            font-family: monospace;
            margin: 8px 0;
            font-size: 13px;
        }

        .error-hint {
            color: var(--muted);
            font-size: 13px;
            margin-top: 8px;
        }

        @keyframes pulseDots {
            0% { opacity: 0.3; transform: translateY(0); }
            50% { opacity: 1; transform: translateY(-1px); }
            100% { opacity: 0.3; transform: translateY(0); }
        }

        /* --- TRIP LIBRARY --- */
        .trip-library-content {
            max-width: 800px;
            width: 90%;
            max-height: 85vh;
            overflow-y: auto;
        }

        .trip-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
            gap: 16px;
            margin: 16px 0;
        }

        .trip-card {
            background: #f8fafc;
            border: 1px solid var(--border);
            border-radius: 8px;
            overflow: hidden;
            display: flex;
            flex-direction: column;
        }

        .trip-card img {
            width: 100%;
            height: 140px;
            object-fit: cover;
            background: #e2e8f0;
        }

        .trip-card-body {
            padding: 12px;
            flex: 1;
            display: flex;
            flex-direction: column;
        }

        .trip-card h4 {
            margin: 0 0 8px;
            font-size: 16px;
            color: var(--text);
        }

        .trip-card p {
            margin: 0 0 12px;
            font-size: 13px;
            color: var(--muted);
            flex: 1;
            line-height: 1.4;
        }

        .trip-card .actions {
            margin-top: auto;
        }

        .trip-card button {
            width: 100%;
            padding: 8px;
            font-size: 13px;
        }
