:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-2: #f0f3f8;
    --text: #101828;
    --muted: #667085;
    --line: #e4e7ec;
    --brand: #0b63ce;
    --brand-2: #0b7ae8;
    --brand-soft: #e8f1ff;
    --success: #169c59;
    --warning: #c97a00;
    --danger: #c62828;
    --shadow: 0 14px 45px rgba(16, 24, 40, .08);
    --radius-lg: 24px;
    --radius-md: 18px;
}

html[data-theme="dark"] {
    --bg: #07101d;
    --surface: #0d1726;
    --surface-2: #132134;
    --text: #f4f7fb;
    --muted: #98a6b8;
    --line: #243247;
    --brand: #4e9bff;
    --brand-2: #6db0ff;
    --brand-soft: #102d4f;
    --success: #51d48f;
    --warning: #ffbc63;
    --danger: #ff7474;
    --shadow: 0 16px 55px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }

.topbar { position: sticky; top: 0; z-index: 1050; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(16px); border-bottom: 1px solid var(--line); }
.topbar-inner { min-height: 68px; display: flex; align-items: center; gap: 24px; }
.brand { display: flex; align-items: center; gap: 11px; min-width: 200px; }
.brand-mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 13px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; font-weight: 800; letter-spacing: -.06em; }
.brand strong { display: block; line-height: 1; }
.brand small { color: var(--muted); font-size: 11px; }
.topnav { gap: 8px; margin-left: auto; }
.topnav a { padding: 9px 12px; border-radius: 10px; color: var(--muted); font-weight: 600; }
.topnav a.active, .topnav a:hover { background: var(--surface-2); color: var(--text); }
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.status-pill { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 999px; padding: 7px 10px; background: var(--surface); font-size: 12px; white-space: nowrap; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warning); box-shadow: 0 0 0 4px color-mix(in srgb, var(--warning) 14%, transparent); }
.status-pill.ok .status-dot { background: var(--success); box-shadow: 0 0 0 4px color-mix(in srgb, var(--success) 14%, transparent); }
.status-pill.bad .status-dot { background: var(--danger); box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 14%, transparent); }
.icon-btn, .ghost-btn { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 11px; min-height: 38px; padding: 0 12px; cursor: pointer; }
.icon-btn { width: 38px; padding: 0; }

.hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; padding-top: clamp(48px, 9vw, 100px); padding-bottom: 42px; }
.eyebrow { display: inline-flex; color: var(--brand); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .12em; }
.hero h1 { margin: 9px 0 13px; font-size: clamp(36px, 5vw, 68px); line-height: .97; letter-spacing: -.05em; max-width: 780px; }
.hero h1 span { color: var(--brand); }
.hero p { max-width: 680px; color: var(--muted); font-size: clamp(15px, 1.5vw, 18px); margin: 0; }
.hero-clock { text-align: right; flex: 0 0 auto; }
.hero-clock span { display: block; font-size: clamp(34px, 6vw, 64px); font-weight: 700; letter-spacing: -.05em; line-height: 1; }
.hero-clock small { color: var(--muted); }

.section-heading, .card-heading { display: flex; justify-content: space-between; align-items: end; gap: 18px; }
.section-heading { margin-bottom: 16px; }
.section-heading h2, .card-heading h2 { margin: 5px 0 0; font-size: 20px; letter-spacing: -.03em; }
.section-link, .back-link { color: var(--brand); font-weight: 700; font-size: 13px; }
.back-link { background: transparent; border: 0; padding: 0; cursor: pointer; }
.muted-copy, .muted-count { color: var(--muted); font-size: 13px; }

.routes-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; }
.route-card { position: relative; overflow: hidden; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-md); padding: 17px; min-height: 160px; box-shadow: 0 8px 24px rgba(16,24,40,.03); cursor: pointer; transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; }
.route-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--brand) 35%, var(--line)); }
.route-number { display: grid; place-items: center; width: 50px; height: 50px; border-radius: 15px; color: #fff; font-size: 23px; font-weight: 800; margin-bottom: 20px; }
.route-card h3 { font-size: 15px; margin: 0 0 7px; }
.route-card .route-dests { color: var(--muted); font-size: 12px; line-height: 1.55; min-height: 38px; }
.route-card .route-open { position: absolute; right: 16px; bottom: 16px; font-weight: 800; color: var(--brand); }
.skeleton-card { height: 160px; border-radius: var(--radius-md); background: linear-gradient(90deg, var(--surface) 15%, var(--surface-2) 45%, var(--surface) 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border: 1px solid var(--line); }
@keyframes shimmer { to { background-position: -200% 0; } }

.info-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 16px; }
.info-item { display: flex; gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 15px; }
.info-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--brand-soft); color: var(--brand); font-weight: 900; }
.info-item strong, .info-item small { display: block; }
.info-item strong { font-size: 13px; }
.info-item small { color: var(--muted); font-size: 11px; margin-top: 2px; }

.control-panel { display: flex; gap: 12px; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); box-shadow: 0 8px 28px rgba(16,24,40,.04); }
.control-group { min-width: 180px; }
.control-group.grow { flex: 1; }
.control-group label { display: block; color: var(--muted); font-size: 11px; font-weight: 700; margin-bottom: 6px; }
.form-control, .form-select { min-height: 44px; border-color: var(--line); background-color: var(--surface); color: var(--text); }
.form-control:focus, .form-select:focus { border-color: var(--brand); box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--brand) 14%, transparent); }

.route-dashboard { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(300px, .9fr); gap: 14px; }
.timeline-card, .schedule-card, .mini-map-card, .trip-nav-card, .map-legend-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: 0 8px 28px rgba(16,24,40,.04); }
.timeline-card, .schedule-card { padding: 20px; }
.source-badge { padding: 7px 10px; border-radius: 999px; font-size: 11px; font-weight: 800; white-space: nowrap; }
.source-gps { color: var(--success); background: color-mix(in srgb, var(--success) 11%, var(--surface)); }
.source-projected { color: var(--brand); background: var(--brand-soft); }
.source-theoretical { color: var(--warning); background: color-mix(in srgb, var(--warning) 11%, var(--surface)); }
.selected-trip-hero { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.big-trip-time { font-size: 36px; font-weight: 800; letter-spacing: -.05em; line-height: 1; }
.big-trip-time small { font-size: 12px; letter-spacing: 0; color: var(--muted); font-weight: 600; }
.trip-meta { color: var(--muted); font-size: 12px; text-align: right; }
.stop-timeline { padding-top: 16px; }
.stop-row { display: grid; grid-template-columns: 18px 1fr auto; gap: 12px; position: relative; min-height: 56px; }
.stop-row .rail { position: relative; display: flex; justify-content: center; }
.stop-row .rail::before { content: ""; width: 2px; background: var(--line); position: absolute; top: 0; bottom: 0; }
.stop-row:first-child .rail::before { top: 50%; }
.stop-row:last-child .rail::before { bottom: 50%; }
.stop-row .dot { position: relative; z-index: 1; margin-top: 4px; width: 10px; height: 10px; border-radius: 50%; border: 3px solid var(--surface); background: var(--muted); box-shadow: 0 0 0 1px var(--line); }
.stop-row.active .dot, .stop-row.passed .dot { background: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.stop-row.bus .dot { width: 14px; height: 14px; background: var(--success); box-shadow: 0 0 0 5px color-mix(in srgb, var(--success) 15%, transparent); }
.stop-row .stop-name { font-weight: 650; font-size: 13px; }
.stop-row .stop-sub { font-size: 11px; color: var(--muted); margin-top: 3px; }
.stop-row .stop-time { font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums; }

.route-side { display: grid; gap: 14px; align-content: start; }
.mini-map-card { position: relative; overflow: hidden; height: 330px; }
.line-map { width: 100%; height: 100%; }
.map-overlay-label { position: absolute; left: 12px; top: 12px; z-index: 500; padding: 7px 10px; border-radius: 999px; font-size: 11px; font-weight: 800; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(8px); border: 1px solid var(--line); }
.trip-nav-card { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; padding: 10px; }
.trip-nav-btn { border: 1px solid var(--line); background: var(--surface-2); color: var(--text); border-radius: 12px; padding: 10px; font-weight: 700; font-size: 12px; cursor: pointer; }
.trip-nav-btn:disabled { opacity: .45; cursor: not-allowed; }
#tripCounter { text-align: center; color: var(--muted); font-size: 11px; font-weight: 700; white-space: nowrap; }

.trip-strip { display: flex; gap: 8px; overflow-x: auto; padding-top: 15px; scrollbar-width: thin; }
.trip-chip { flex: 0 0 auto; min-width: 104px; padding: 11px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 13px; cursor: pointer; color: var(--text); text-align: left; }
.trip-chip strong { display: block; font-size: 14px; }
.trip-chip small { display: block; color: var(--muted); font-size: 10px; margin-top: 3px; }
.trip-chip.active { background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand) 36%, var(--line)); }
.trip-chip.current { box-shadow: inset 0 0 0 2px var(--success); }

.map-page-shell { position: relative; min-height: calc(100vh - 170px); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; background: var(--surface); }
.network-map { min-height: calc(100vh - 172px); }
.map-legend-card { position: absolute; top: 14px; right: 14px; z-index: 600; width: min(330px, calc(100% - 28px)); padding: 14px; }
.legend-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.legend-list { margin-top: 12px; display: grid; gap: 9px; font-size: 11px; color: var(--muted); }
.legend-list > div { display: flex; align-items: center; gap: 8px; }
.legend-marker { width: 14px; height: 14px; border-radius: 5px; display: inline-block; }
.bus-real { background: #10b981; box-shadow: 0 0 0 4px rgba(16,185,129,.15); }
.bus-projected { background: #3b82f6; box-shadow: 0 0 0 4px rgba(59,130,246,.15); }
.bus-theoretical { background: #f59e0b; box-shadow: 0 0 0 4px rgba(245,158,11,.15); }
.legend-stop { width: 10px; height: 10px; border: 2px solid var(--brand); border-radius: 50%; }
.map-stats { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--text); font-size: 12px; }

.bus-marker { width: 38px; height: 38px; border-radius: 12px; color: #fff; display: grid; place-items: center; font-size: 16px; font-weight: 900; border: 2px solid rgba(255,255,255,.95); box-shadow: 0 8px 18px rgba(0,0,0,.24); transform-origin: center; }
.bus-marker.gps { background: #10b981; }
.bus-marker.projected { background: #3b82f6; }
.bus-marker.theoretical { background: #f59e0b; }
.stop-marker { width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 3px solid var(--brand); box-shadow: 0 4px 10px rgba(0,0,0,.18); }

.toast-host { position: fixed; left: 16px; right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); z-index: 2000; display: grid; justify-items: center; pointer-events: none; }
.toast { pointer-events: auto; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); font-size: 12px; }
.alert-inline { border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 13px; padding: 11px 13px; font-size: 12px; }
.alert-inline.error { border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); color: var(--danger); }

.leaflet-control-zoom a, .leaflet-bar a { background: var(--surface) !important; color: var(--text) !important; border-color: var(--line) !important; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--text); }
.leaflet-popup-content { font-size: 12px; }

@media (max-width: 1050px) {
    .routes-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .route-dashboard { grid-template-columns: 1fr; }
    .route-side { grid-template-columns: 1.3fr .7fr; }
}

@media (max-width: 760px) {
    .topbar-inner { min-height: 60px; }
    .brand { min-width: 0; }
    .brand small { display: none; }
    .status-text { display: none; }
    .hero { padding-top: 42px; flex-direction: column; align-items: flex-start; }
    .hero-clock { text-align: left; }
    .routes-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .route-card { min-height: 148px; padding: 14px; }
    .route-number { width: 44px; height: 44px; margin-bottom: 18px; }
    .info-strip { grid-template-columns: 1fr; }
    .control-panel { flex-direction: column; }
    .route-dashboard { grid-template-columns: 1fr; }
    .route-side { grid-template-columns: 1fr; }
    .mini-map-card { height: 260px; }
    .trip-nav-card { grid-template-columns: 1fr; }
    #tripCounter { order: -1; }
    .map-page-shell { min-height: calc(100vh - 145px); }
    .network-map { min-height: calc(100vh - 147px); }
    .map-legend-card { top: auto; right: 8px; bottom: 8px; width: calc(100% - 16px); }
}

@media (max-width: 430px) {
    .routes-grid { grid-template-columns: 1fr 1fr; }
    .route-card .route-dests { font-size: 11px; }
    .selected-trip-hero { align-items: flex-start; flex-direction: column; }
    .trip-meta { text-align: left; }
}

/* ==========================================
   STYLE DU BADGE BUS SUR LA TIMELINE
   ========================================== */
.stop-row .rail {
    position: relative;
    display: flex;
    justify-content: center;
}

.bus-icon-badge {
    position: absolute;
    left: -6px;
    top: -4px;
    font-size: 1.1rem;
    z-index: 5;
    animation: pulse-bus 1.5s infinite ease-in-out;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

@keyframes pulse-bus {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* ==========================================
   OPTIMISATIONS MOBILE & RESPONSIVE (GLOBAL)
   ========================================== */
@media (max-width: 760px) {
    body {
        font-size: 14px;
    }

    .container, .container-fluid {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    /* Agrandissement des zones tactiles (conforme aux standards mobiles min 44px) */
    button, .btn, select, .trip-chip, .trip-nav-btn {
        min-height: 44px;
    }

    /* Adaptation des en-têtes de ligne sur mobile */
    .hero {
        padding-top: 24px;
        padding-bottom: 24px;
    }

    /* Le sélecteur de course et contrôles en colonne sur petits écrans */
    .control-panel {
        flex-direction: column;
        gap: 8px;
        padding: 10px;
    }

    .control-group {
        min-width: 100%;
    }

    /* Amélioration de la disposition des infos du trajet actif */
    .selected-trip-hero {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .trip-meta {
        text-align: left;
    }

    /* Hauteur de la mini-carte sur mobile */
    .mini-map-card {
        height: 280px;
    }
}

/* Empêche le zoom automatique non désiré sur iOS lors du clic sur les champs */
input, select, textarea {
    font-size: 16px !important;
}

/* Suppression des surbrillances tactiles agressives sur mobile */
* {
    -webkit-tap-highlight-color: transparent;
}
/* ==========================================================
   TIMELINE BUS / POSITION DYNAMIQUE
   ========================================================== */
.route-progress-shell {
    position: relative;
}

.stop-timeline-rows {
    position: relative;
    z-index: 2;
}

.timeline-bus-marker {
    position: absolute;
    left: -3px;
    top: 0;
    z-index: 8;
    width: 26px;
    height: 26px;
    margin-top: -13px;
    border-radius: 9px;
    display: grid;
    place-items: center;
    background: var(--surface);
    border: 2px solid var(--success);
    box-shadow: 0 5px 16px rgba(0,0,0,.22), 0 0 0 5px color-mix(in srgb, var(--success) 14%, transparent);
    font-size: 15px;
    line-height: 1;
    transform: translateX(-50%);
    pointer-events: none;
    transition: top .7s ease, border-color .25s ease, box-shadow .25s ease;
}

.timeline-bus-marker.gps {
    border-color: var(--success);
    box-shadow: 0 5px 16px rgba(0,0,0,.22), 0 0 0 5px color-mix(in srgb, var(--success) 14%, transparent);
}

.timeline-bus-marker.projected {
    border-color: var(--brand);
    box-shadow: 0 5px 16px rgba(0,0,0,.22), 0 0 0 5px color-mix(in srgb, var(--brand) 14%, transparent);
}

.timeline-bus-marker.theoretical {
    border-color: var(--warning);
    box-shadow: 0 5px 16px rgba(0,0,0,.22), 0 0 0 5px color-mix(in srgb, var(--warning) 14%, transparent);
}

.timeline-bus-marker span {
    transform: translateY(-.5px);
}

.stop-row {
    min-height: 54px;
}

.stop-row .rail::before {
    width: 3px;
}

.stop-row .dot {
    width: 11px;
    height: 11px;
}

.stop-row.bus .dot {
    width: 14px;
    height: 14px;
}

.bus-icon-badge {
    display: none;
}

/* ==========================================================
   HORAIRES / LISIBILITÉ
   ========================================================== */
.trip-strip {
    padding-bottom: 3px;
    scroll-padding-inline: 12px;
}

.trip-chip {
    transition: transform .15s ease, border-color .15s ease, background .15s ease;
}

.trip-chip:active {
    transform: scale(.98);
}

.trip-chip.active {
    scroll-margin-inline: 12px;
}

/* ==========================================================
   GROSSE OPTIMISATION MOBILE
   ========================================================== */
@media (max-width: 760px) {
    .topbar {
        position: sticky;
        top: 0;
    }

    .topbar-inner {
        min-height: 58px;
        gap: 8px;
    }

    .brand {
        gap: 8px;
    }

    .brand-mark {
        width: 36px;
        height: 36px;
        border-radius: 11px;
    }

    .brand strong {
        font-size: 14px;
    }

    .topnav {
        gap: 3px;
    }

    .topnav a {
        padding: 8px 9px;
        font-size: 12px;
    }

    .topbar-actions {
        gap: 5px;
    }

    .icon-btn,
    .ghost-btn {
        min-height: 42px;
    }

    .hero h1 {
        font-size: clamp(28px, 10vw, 40px);
        line-height: 1.02;
    }

    .route-dashboard {
        gap: 10px;
    }

    .timeline-card,
    .schedule-card {
        padding: 13px;
        border-radius: 18px;
    }

    .selected-trip-hero {
        padding: 12px 0 14px;
    }

    .big-trip-time {
        font-size: 30px;
    }

    .trip-meta {
        font-size: 11px;
        max-width: 100%;
    }

    .stop-timeline {
        padding-top: 10px;
    }

    .stop-row {
        grid-template-columns: 18px minmax(0, 1fr) auto;
        gap: 8px;
        min-height: 48px;
    }

    .stop-row .stop-name {
        font-size: 12px;
        line-height: 1.2;
        overflow-wrap: anywhere;
    }

    .stop-row .stop-sub {
        font-size: 10px;
        margin-top: 2px;
    }

    .stop-row .stop-time {
        font-size: 12px;
        white-space: nowrap;
    }

    .stop-row .badge {
        font-size: 9px !important;
        padding: 3px 5px;
        vertical-align: middle;
    }

    .timeline-bus-marker {
        left: -1px;
        width: 28px;
        height: 28px;
        font-size: 16px;
    }

    .trip-strip {
        gap: 7px;
        margin-left: -2px;
        margin-right: -2px;
        padding-top: 11px;
        padding-bottom: 5px;
    }

    .trip-chip {
        min-width: 92px;
        padding: 9px 10px;
        border-radius: 11px;
    }

    .trip-chip strong {
        font-size: 13px;
    }

    .trip-chip small {
        font-size: 9px;
        line-height: 1.25;
    }

    .trip-nav-card {
        gap: 7px;
        padding: 8px;
    }

    .trip-nav-btn {
        width: 100%;
        padding: 9px 8px;
    }

    .mini-map-card {
        height: 250px;
        border-radius: 18px;
    }

    .map-overlay-label {
        left: 8px;
        top: 8px;
        font-size: 10px;
        padding: 6px 8px;
    }

    .map-legend-card {
        max-height: 38vh;
        overflow: auto;
        padding: 11px;
        border-radius: 16px;
    }

    .info-item {
        padding: 12px;
    }

    .control-panel {
        border-radius: 16px;
    }

    .control-group label {
        margin-bottom: 5px;
    }

    .form-control,
    .form-select {
        min-height: 46px;
    }

    .route-number {
        flex: 0 0 auto;
    }
}

@media (max-width: 480px) {
    .topnav a {
        padding-left: 7px;
        padding-right: 7px;
    }

    .topnav a:nth-child(2) {
        display: none;
    }

    .status-pill {
        display: none;
    }

    .hero {
        padding-top: 18px;
        padding-bottom: 16px;
    }

    .section-heading,
    .card-heading {
        align-items: flex-start;
    }

    .section-heading h2,
    .card-heading h2 {
        font-size: 18px;
    }

    .timeline-card,
    .schedule-card {
        padding: 11px;
    }

    .stop-row {
        grid-template-columns: 16px minmax(0, 1fr) auto;
        min-height: 46px;
        gap: 7px;
    }

    .stop-row .stop-name {
        font-size: 11px;
    }

    .stop-row .stop-sub {
        font-size: 9px;
    }

    .stop-row .stop-time {
        font-size: 11px;
    }

    .timeline-bus-marker {
        width: 26px;
        height: 26px;
        font-size: 14px;
    }

    .mini-map-card {
        height: 225px;
    }
}

/* ==========================================================
   NAVIGATION HORAIRES FIXE : gauche / droite de l'écran
   ========================================================== */
html {
    scroll-behavior: auto;
}

.trip-nav-card {
    min-height: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    pointer-events: none;
}

#prevTrip,
#nextTrip {
    position: fixed !important;
    top: 50%;
    z-index: 1500;
    width: 48px !important;
    height: 48px !important;
    min-width: 48px !important;
    min-height: 48px !important;
    padding: 0 !important;
    margin: 0 !important;
    display: grid !important;
    place-items: center !important;
    transform: translateY(-50%);
    border: 1px solid var(--line) !important;
    border-radius: 50% !important;
    background: color-mix(in srgb, var(--surface) 94%, transparent) !important;
    color: var(--text) !important;
    box-shadow: 0 10px 28px rgba(0, 0, 0, .20);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    pointer-events: auto;
    font-size: 0 !important;
    line-height: 1 !important;
    transition: transform .16s ease, opacity .16s ease, border-color .16s ease;
}

#prevTrip {
    left: max(10px, env(safe-area-inset-left));
}

#nextTrip {
    right: max(10px, env(safe-area-inset-right));
}

#prevTrip::before,
#nextTrip::before {
    display: block;
    font-family: Arial, sans-serif;
    font-size: 29px;
    font-weight: 300;
    line-height: 1;
}

#prevTrip::before {
    content: '‹';
    transform: translateX(-1px);
}

#nextTrip::before {
    content: '›';
    transform: translateX(1px);
}

#prevTrip:hover:not(:disabled),
#nextTrip:hover:not(:disabled) {
    transform: translateY(-50%) scale(1.06);
    border-color: var(--brand) !important;
}

#prevTrip:active:not(:disabled),
#nextTrip:active:not(:disabled) {
    transform: translateY(-50%) scale(.95);
}

#prevTrip:disabled,
#nextTrip:disabled {
    opacity: .28;
    cursor: default;
    box-shadow: none;
}

#tripCounter {
    position: fixed;
    top: 76px;
    left: 50%;
    z-index: 1450;
    transform: translateX(-50%);
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
    box-shadow: 0 8px 20px rgba(0, 0, 0, .12);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    pointer-events: none;
    white-space: nowrap;
}

/* Le bus se déplace sur la ligne : pas de doublons "Bus ici" sur plusieurs arrêts. */
.stop-row.bus-near .dot {
    background: var(--success);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--success) 15%, transparent);
}

.schedule-updated-at {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 500;
}

@media (max-width: 760px) {
    #prevTrip,
    #nextTrip {
        width: 44px !important;
        height: 44px !important;
        min-width: 44px !important;
        min-height: 44px !important;
        box-shadow: 0 8px 22px rgba(0, 0, 0, .22);
    }

    #prevTrip {
        left: max(8px, env(safe-area-inset-left));
    }

    #nextTrip {
        right: max(8px, env(safe-area-inset-right));
    }

    #prevTrip::before,
    #nextTrip::before {
        font-size: 27px;
    }

    #tripCounter {
        top: 67px;
        padding: 5px 9px;
        font-size: 10px;
    }

    .route-dashboard {
        gap: 10px;
    }

    .timeline-card,
    .schedule-card {
        border-radius: 18px;
    }

    .selected-trip-hero {
        gap: 6px;
    }

    .trip-meta {
        line-height: 1.35;
    }

    .stop-row {
        min-height: 50px;
    }

    .trip-strip {
        scroll-padding-left: 6px;
        scroll-padding-right: 6px;
        overscroll-behavior-x: contain;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 430px) {
    #prevTrip,
    #nextTrip {
        width: 42px !important;
        height: 42px !important;
        min-width: 42px !important;
        min-height: 42px !important;
    }

    #prevTrip {
        left: max(6px, env(safe-area-inset-left));
    }

    #nextTrip {
        right: max(6px, env(safe-area-inset-right));
    }

    #tripCounter {
        top: 65px;
    }

    .schedule-updated-at {
        font-size: 9px;
    }
}

.traveller-tools { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 20px; box-shadow: 0 8px 28px rgba(16,24,40,.04); }
.traveller-tools-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.traveller-tools-head h2 { margin: 3px 0 4px; }
.traveller-tools-head p { margin: 0; color: var(--muted); font-size: 13px; }
.stop-search-row { margin-top: 16px; }
.stop-search-row .form-control { min-height: 46px; }
.favorite-stops { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.favorite-stop { border: 1px solid var(--line); background: var(--surface-soft, var(--surface)); color: var(--text); border-radius: 12px; padding: 8px 11px; display: inline-flex; align-items: center; gap: 7px; }
.favorite-stop span { color: #f59e0b; }
.favorites-empty { color: var(--muted); font-size: 12px; }
.stop-results { display: grid; gap: 8px; margin-top: 12px; }
.stop-result { display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); }
.stop-result-main { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--text); text-align: left; padding: 11px 13px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.stop-result-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stop-result-main span { flex: 0 0 auto; color: var(--muted); font-size: 12px; }
.stop-favorite-btn { width: 44px; border: 0; border-left: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 21px; }
.stop-favorite-btn.is-favorite { color: #f59e0b; }
.stop-loading, .stop-empty { padding: 13px 2px; color: var(--muted); font-size: 13px; }
.stop-empty.error { color: #b42318; }
.stop-panel { position: fixed; inset: 0; z-index: 3000; display: grid; place-items: center; padding: 16px; background: rgba(15, 23, 42, .48); backdrop-filter: blur(4px); }
.stop-panel-card { width: min(620px, 100%); max-height: min(760px, 90vh); overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 20px; }
.stop-panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 10px; }
.stop-panel-head h2 { margin: 3px 0 0; }
.stop-next-list { display: grid; gap: 8px; }
.stop-departure { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.stop-line-badge { flex: 0 0 auto; min-width: 38px; padding: 6px 8px; text-align: center; border-radius: 10px; background: var(--line-color, #0b63ce); color: #fff; font-weight: 700; }
.stop-departure-main { display: flex; min-width: 0; flex-direction: column; gap: 2px; }
.stop-departure-main strong { font-size: 18px; }
.stop-departure-main span { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 760px) {
    .traveller-tools-head { align-items: flex-start; flex-direction: column; }
    .traveller-tools-head .ghost-btn { width: 100%; }
}

/* ==========================================================
   ETAPE 5 — ITINERAIRE
   ========================================================== */
.itinerary-tools { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 20px; box-shadow: 0 8px 28px rgba(16,24,40,.04); }
.itinerary-grid { display: grid; grid-template-columns: 1fr 1fr auto; gap: 12px; align-items: end; }
.itinerary-field { position: relative; }
.itinerary-field label { display:block; font-size:12px; font-weight:700; color:var(--muted); margin-bottom:6px; }
.itinerary-field input { min-height:46px; }
.itinerary-actions { display:flex; gap:8px; }
.itinerary-swap { min-width:46px; }
.itinerary-results { display:grid; gap:10px; margin-top:16px; }
.itinerary-result { border:1px solid var(--line); border-radius:16px; padding:14px; background:var(--surface); }
.itinerary-result-head { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.itinerary-result-time { font-size:18px; font-weight:800; }
.itinerary-result-meta { color:var(--muted); font-size:12px; }
.itinerary-legs { display:grid; gap:8px; margin-top:12px; }
.itinerary-leg { display:flex; align-items:center; gap:10px; }
.itinerary-line { min-width:40px; padding:6px 8px; border-radius:9px; text-align:center; font-weight:800; background:var(--line-color,#0b63ce); color:#fff; }
.itinerary-leg-main { min-width:0; display:flex; flex-direction:column; gap:2px; }
.itinerary-leg-main strong { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.itinerary-leg-main span { color:var(--muted); font-size:12px; }
.itinerary-transfer { margin:2px 0 2px 50px; color:var(--muted); font-size:12px; }
.itinerary-empty { padding:14px 2px; color:var(--muted); font-size:13px; }
.itinerary-stop-picker { position:absolute; z-index:30; left:0; right:0; top:78px; background:var(--surface); border:1px solid var(--line); border-radius:12px; box-shadow:var(--shadow); overflow:hidden; }
.itinerary-stop-option { width:100%; border:0; background:transparent; color:var(--text); text-align:left; padding:10px 12px; display:flex; justify-content:space-between; gap:12px; }
.itinerary-stop-option:hover { background:var(--surface-soft,var(--line)); }
.itinerary-stop-option span { color:var(--muted); font-size:11px; }
@media (max-width:760px) {
    .itinerary-grid { grid-template-columns:1fr; }
    .itinerary-actions { width:100%; }
    .itinerary-actions .ghost-btn { flex:1; }
    .itinerary-stop-picker { top:72px; }
}
