:root {
    --panel-bg: rgba(15, 23, 42, 0.92);
    --panel-border: rgba(255, 255, 255, 0.08);
    --panel-radius: 10px;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --accent: #3b82f6;
    --bus-color: #ef4444;
    --tram-color: #f97316;
    --trolley-color: #3b82f6;
    --train-bv: #22c55e;
    --train-pv: #6b7280;
    --train-kpv: #f97316;
    --train-mbv: #3b82f6;
    --traffic-low: #22c55e;
    --traffic-mid: #eab308;
    --traffic-high: #ef4444;
}

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

body, html { width: 100%; height: 100%; overflow: hidden; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }

#map { width: 100%; height: 100%; }

/* Panels */
.panel { position: absolute; z-index: 1000; }
.panel-left { top: 12px; left: 12px; }
.panel-right { top: 12px; right: 12px; }

.panel-btn {
    display: flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border: none; border-radius: 8px;
    background: var(--panel-bg); color: var(--text-primary);
    cursor: pointer; position: relative; backdrop-filter: blur(8px);
    border: 1px solid var(--panel-border);
}
.panel-btn:hover { background: rgba(30, 41, 59, 0.95); }

.badge {
    position: absolute; top: -4px; right: -4px;
    background: var(--accent); color: white; font-size: 10px;
    min-width: 16px; height: 16px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600;
}

.panel-body {
    margin-top: 6px; background: var(--panel-bg); border-radius: var(--panel-radius);
    padding: 8px; min-width: 220px; backdrop-filter: blur(8px);
    border: 1px solid var(--panel-border);
}

.layer-item {
    display: flex; align-items: center; gap: 8px; padding: 8px 10px;
    border-radius: 6px; cursor: pointer; color: var(--text-primary);
    font-size: 13px; transition: background 0.15s;
}
.layer-item:hover { background: rgba(255, 255, 255, 0.06); }
.layer-item .dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.layer-item label { flex: 1; cursor: pointer; user-select: none; }
.layer-item input[type="checkbox"] { accent-color: var(--accent); }
.layer-item .warn { color: #f59e0b; font-size: 11px; }

/* Search */
#search-input {
    width: 260px; padding: 10px 14px; border: 1px solid var(--panel-border);
    border-radius: 8px; background: var(--panel-bg); color: var(--text-primary);
    font-size: 14px; outline: none; backdrop-filter: blur(8px);
}
#search-input::placeholder { color: var(--text-secondary); }
#search-input:focus { border-color: var(--accent); }

.search-results {
    margin-top: 4px; background: var(--panel-bg); border-radius: var(--panel-radius);
    max-height: 300px; overflow-y: auto; border: 1px solid var(--panel-border);
}
.search-result {
    padding: 8px 14px; cursor: pointer; color: var(--text-primary);
    font-size: 13px; border-bottom: 1px solid var(--panel-border);
}
.search-result:hover { background: rgba(255, 255, 255, 0.06); }
.search-result small { color: var(--text-secondary); display: block; }

/* Detail Panel */
.detail-panel {
    position: absolute; top: 60px; left: 12px; z-index: 1001;
    background: var(--panel-bg); border-radius: var(--panel-radius);
    padding: 16px; width: 300px; max-height: calc(100vh - 140px);
    overflow-y: auto; color: var(--text-primary); font-size: 13px;
    line-height: 1.6; backdrop-filter: blur(8px);
    border: 1px solid var(--panel-border);
    transition: transform 0.25s ease, opacity 0.25s ease;
}
.detail-panel.hidden { transform: translateX(-320px); opacity: 0; pointer-events: none; }
.detail-close {
    position: absolute; top: 8px; right: 10px; background: none;
    border: none; color: var(--text-secondary); font-size: 20px;
    cursor: pointer; line-height: 1;
}
.detail-close:hover { color: var(--text-primary); }
.detail-panel h3 { font-size: 15px; margin-bottom: 8px; }
.detail-panel .tag {
    display: inline-block; padding: 2px 8px; border-radius: 4px;
    font-size: 11px; font-weight: 600; color: white;
}
.detail-panel .row { display: flex; justify-content: space-between; padding: 3px 0; }
.detail-panel .row .label { color: var(--text-secondary); }
.detail-panel .divider { height: 1px; background: var(--panel-border); margin: 8px 0; }

/* Timeline Panel */
.timeline-panel {
    position: absolute; bottom: 0; left: 0; right: 0; z-index: 1001;
    background: var(--panel-bg); padding: 10px 16px 14px;
    backdrop-filter: blur(8px); border-top: 1px solid var(--panel-border);
    transition: transform 0.25s ease;
}
.timeline-panel.hidden { transform: translateY(100%); }
.timeline-header {
    display: flex; align-items: center; gap: 12px; margin-bottom: 8px;
}
.timeline-btn {
    background: none; border: 1px solid var(--panel-border);
    color: var(--text-primary); width: 32px; height: 32px;
    border-radius: 6px; cursor: pointer; font-size: 14px;
}
.timeline-btn:hover { background: rgba(255, 255, 255, 0.06); }
#timeline-time { color: var(--text-primary); font-size: 14px; font-variant-numeric: tabular-nums; }
.timeline-slider {
    width: 100%; height: 6px; -webkit-appearance: none; appearance: none;
    background: rgba(255, 255, 255, 0.15); border-radius: 3px; outline: none;
}
.timeline-slider::-webkit-slider-thumb {
    -webkit-appearance: none; width: 16px; height: 16px;
    border-radius: 50%; background: var(--accent); cursor: pointer;
}

/* Route Planner */
.route-toggle-btn {
    position: absolute; bottom: 20px; left: 12px; z-index: 1000;
}
.route-panel {
    position: absolute; top: 0; left: 0; bottom: 0; z-index: 1001;
    background: var(--panel-bg); border-radius: 0;
    padding: 16px; width: 480px; color: var(--text-primary);
    backdrop-filter: blur(8px); border-right: 1px solid var(--panel-border);
    transition: transform 0.25s ease;
    display: flex; flex-direction: column;
    overflow: hidden;
}
.route-panel.hidden { transform: translateX(-100%); pointer-events: none; }
.route-inputs { display: flex; flex-direction: column; gap: 6px; }
.route-input-row { display: flex; align-items: center; gap: 8px; }
.route-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.route-input-row input {
    flex: 1; padding: 8px 10px; border: 1px solid var(--panel-border);
    border-radius: 6px; background: rgba(255,255,255,0.06); color: var(--text-primary);
    font-size: 13px; cursor: pointer;
}
.route-input-row input::placeholder { color: var(--text-secondary); }
.route-btn {
    flex: 1; padding: 8px; border: none; border-radius: 6px;
    background: var(--accent); color: white; font-size: 13px;
    font-weight: 600; cursor: pointer;
}
.route-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.route-btn:not(:disabled):hover { background: #2563eb; }
.route-btn-secondary {
    padding: 8px 12px; border: 1px solid var(--panel-border); border-radius: 6px;
    background: transparent; color: var(--text-secondary); font-size: 13px;
    cursor: pointer;
}
.route-btn-secondary:hover { background: rgba(255,255,255,0.06); }

.route-preferences {
    display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px;
}
.pref-chip {
    font-size: 11px; padding: 4px 10px; border-radius: 14px;
    background: rgba(255,255,255,0.06); color: var(--text-secondary);
    border: 1px solid var(--panel-border); cursor: pointer;
    transition: all 0.15s;
}
.pref-chip:hover { background: rgba(255,255,255,0.1); }
.pref-chip.active {
    background: var(--accent); color: white;
    border-color: var(--accent);
}

#route-results { margin-top: 10px; flex: 1; overflow-y: auto; min-height: 0; }
.route-journey {
    background: rgba(255,255,255,0.04); border-radius: 8px;
    padding: 12px 14px; margin-bottom: 10px; cursor: pointer;
    border: 1px solid var(--panel-border);
}
.route-journey:hover { background: rgba(255,255,255,0.08); }
.route-journey-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 10px; font-size: 14px;
}
.route-journey-header strong { font-size: 16px; color: var(--text-primary); }
.route-journey-header .route-times {
    font-size: 14px; color: var(--accent); font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.route-leg {
    display: grid; grid-template-columns: 38px 1fr; gap: 0 8px;
    font-size: 12px; color: var(--text-secondary); padding: 6px 0;
}
.route-leg .leg-time {
    font-size: 11px; color: var(--text-secondary); text-align: right;
    font-variant-numeric: tabular-nums;
}
.route-leg .leg-body {
    display: flex; align-items: center; gap: 6px;
}
.route-leg .tag {
    font-size: 11px; padding: 2px 8px; border-radius: 4px;
    font-weight: 600; color: white; white-space: nowrap;
}
.route-transit-group {
    border-left: 3px solid var(--accent); margin: 6px 0 6px 46px;
    padding: 6px 0 6px 12px; background: rgba(255,255,255,0.02);
    border-radius: 0 6px 6px 0;
}
.route-transit-group .leg-detail {
    font-size: 12px; color: var(--text-secondary); padding: 3px 0;
    display: flex; align-items: center; gap: 6px;
}
.route-transit-group .leg-detail .stop-name { color: var(--text-primary); }

.route-focus .vehicle-label { opacity: 0.15 !important; }
.route-focus .vehicle-label.route-active { opacity: 1 !important; }
.route-focus .metro-station-marker { opacity: 0.15 !important; }

.hidden { display: none !important; }

/* Mobile */
@media (max-width: 768px) {
    #search-input { width: calc(100vw - 80px); }
    .panel-right { right: 8px; left: 56px; }
    .panel-left { top: 8px; left: 8px; }

    .detail-panel {
        top: auto; bottom: 0; left: 0; right: 0;
        width: 100%; max-height: 60vh;
        border-radius: var(--panel-radius) var(--panel-radius) 0 0;
    }
    .detail-panel.hidden { transform: translateY(100%); }

    .route-panel { width: 100%; }

    .panel-body {
        position: fixed; bottom: 0; left: 0; right: 0;
        border-radius: var(--panel-radius) var(--panel-radius) 0 0;
        max-height: 50vh; overflow-y: auto;
    }
}

/* MapLibre overrides */
.maplibregl-ctrl-attrib { font-size: 10px !important; }
