/* ---------- Tokens ---------- */
/* Style « quai de gare » :
   - bandeau bleu nuit de la signalétique des gares, texte blanc ;
   - jaune des affiches d'horaire (départs) pour ce qui se lit en premier ;
   - rouge signal réservé à la trotteuse de l'horloge et aux alertes ;
   - filets épais en tête de carte, comme sur les affiches suisses ; papier légèrement chaud.
   Les couleurs des données (--series-*, --heat-*, --seq-*) ne changent pas. */
:root {
  color-scheme: light;
  --page:        #f3f2ee;
  --surface:     #ffffff;
  --surface-2:   #ecebe6;
  --text:        #111418;
  --text-2:      #464b53;
  --muted:       #7c8088;
  --grid:        #e2e1db;
  --axis:        #c2c1b8;
  --border:      rgba(17,20,24,0.12);
  --rule:        #111418;     /* filet de tête des cartes */
  --sign:        #1a2440;     /* bleu nuit des panneaux */
  --sign-ink:    #ffffff;
  --poster:      #ffd200;     /* jaune affiche d'horaire */
  --poster-ink:  #111418;
  --signal:      #d8232a;     /* rouge signal */
  --btn:         #1a2440;
  --accent:      #2a78d6;
  --accent-ink:  #1c4f9c;
  --series-1:    #2a78d6;   /* Interruption */
  --series-2:    #eb6834;   /* Restriction  */
  --series-3:    #1baf7a;
  --series-4:    #eda100;
  --series-5:    #e87ba4;
  --heat-none:   #b9b7af;
  --ref-map:     #6f6d66;
  --good-text:   #006300;
  --bad-text:    #b42323;
  --critical:    #d03b3b;
  --seq-0: #cde2fb; --seq-1: #9ec5f4; --seq-2: #6da7ec; --seq-3: #3987e5; --seq-4: #256abf; --seq-5: #184f95; --seq-6: #0d366b;
  /* Rampe de chaleur (vert = aucun incident -> rouge foncé = le pire) pour la carte des tronçons */
  --heat-0: #1a9641; --heat-1: #74b83a; --heat-2: #c9c21b; --heat-3: #f2a516; --heat-4: #ea6a26; --heat-5: #cf2f26; --heat-6: #7f0a0a; --heat-violet: #7b3fc4;
  --shadow: 0 1px 2px rgba(0,0,0,.04);
  --radius: 4px;
  --font: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0e1116; --surface: #161a21; --surface-2: #1f252e;
    --text: #eef0f3; --text-2: #b9bec7; --muted: #868b94;
    --grid: #262c35; --axis: #39404b; --border: rgba(255,255,255,0.10);
    --rule: #c9ced6; --sign: #0b1428; --poster: #e8bf00; --signal: #e5484d; --btn: #3a6fd0;
    --accent: #3987e5; --accent-ink: #86b6ef;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --series-5: #d55181; --heat-none: #55544f; --ref-map: #b5b3ab;
    --good-text: #0ca30c; --bad-text: #e66767; --critical: #d03b3b;
    --seq-0: #1d2a3a; --seq-1: #104281; --seq-2: #184f95; --seq-3: #256abf; --seq-4: #3987e5; --seq-5: #6da7ec; --seq-6: #b7d3f6;
    --heat-0: #2fb35a; --heat-1: #8fd14f; --heat-2: #e6d22e; --heat-3: #f5a623; --heat-4: #f26b38; --heat-5: #e53935; --heat-6: #ff4d6d; --heat-violet: #b07cf0;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0e1116; --surface: #161a21; --surface-2: #1f252e;
  --text: #eef0f3; --text-2: #b9bec7; --muted: #868b94;
  --grid: #262c35; --axis: #39404b; --border: rgba(255,255,255,0.10);
  --rule: #c9ced6; --sign: #0b1428; --poster: #e8bf00; --signal: #e5484d; --btn: #3a6fd0;
  --accent: #3987e5; --accent-ink: #86b6ef;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --series-5: #d55181; --heat-none: #55544f; --ref-map: #b5b3ab;
  --good-text: #0ca30c; --bad-text: #e66767; --critical: #d03b3b;
  --seq-0: #1d2a3a; --seq-1: #104281; --seq-2: #184f95; --seq-3: #256abf; --seq-4: #3987e5; --seq-5: #6da7ec; --seq-6: #b7d3f6;
  --heat-0: #2fb35a; --heat-1: #8fd14f; --heat-2: #e6d22e; --heat-3: #f5a623; --heat-4: #f26b38; --heat-5: #e53935; --heat-6: #ff4d6d; --heat-violet: #b07cf0;
  --shadow: none;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--text); font: 15px/1.5 var(--font); }
a { color: var(--accent-ink); text-decoration-thickness: 1px; text-underline-offset: 2px; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h2 { font-size: 1.02rem; font-weight: 600; }
h3 { font-size: .95rem; font-weight: 600; margin-top: 1.4em; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* ---------- Header : bandeau de signalétique ---------- */
.site-header { background: var(--sign); color: var(--sign-ink); position: sticky; top: 0; z-index: 1000; }
.header-inner { display: flex; align-items: center; gap: 20px; min-height: 62px; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--sign-ink); text-decoration: none; white-space: nowrap; }
.brand-txt { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-weight: 700; font-size: 1.02rem; letter-spacing: .005em; }
.brand-sub { font-size: .68rem; text-transform: uppercase; letter-spacing: .12em; opacity: .7; margin-top: 3px; }

/* Horloge de gare */
.clock { width: 38px; height: 38px; flex: none; filter: drop-shadow(0 1px 0 rgba(0,0,0,.35)); }
.clock-face { fill: #fff; stroke: #0b0f17; stroke-width: 1.5; }
.clock-hand { fill: #111418; }
.clock-sec { fill: var(--signal); }

/* Onglets */
.tabs { display: flex; gap: 2px; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { display: inline-flex; align-items: center; padding: 0 12px; min-height: 62px; color: rgba(255,255,255,.78); text-decoration: none; font-size: .92rem; font-weight: 500; white-space: nowrap; box-shadow: inset 0 -4px 0 transparent; }
.tabs a:hover { color: #fff; background: rgba(255,255,255,.06); }
.tabs a.active { color: #fff; font-weight: 650; box-shadow: inset 0 -4px 0 var(--poster); }

.header-tools { display: flex; align-items: center; gap: 8px; flex: none; }
.lang { display: flex; border: 1px solid rgba(255,255,255,.28); border-radius: 4px; overflow: hidden; }
.lang button { font: inherit; font-size: .74rem; font-weight: 600; letter-spacing: .06em; background: transparent; color: rgba(255,255,255,.72); border: 0; padding: 6px 8px; cursor: pointer; min-height: 32px; }
.lang button + button { border-left: 1px solid rgba(255,255,255,.18); }
.lang button:hover { color: #fff; background: rgba(255,255,255,.08); }
.lang button[aria-pressed="true"] { background: #fff; color: var(--sign); }
.theme-toggle { flex: none; width: 34px; height: 34px; border: 1px solid rgba(255,255,255,.28); border-radius: 4px; background: transparent; color: rgba(255,255,255,.8); cursor: pointer; display: grid; place-items: center; }
.theme-toggle svg { width: 17px; height: 17px; }
.theme-toggle:hover { color: #fff; background: rgba(255,255,255,.08); }
.site-header :focus-visible { outline-color: var(--poster); }

/* Voie ferrée sous le bandeau, vue de côté : rail clair, traverses, lit de ballast */
.rail { height: 11px; background:
    linear-gradient(#d5d9e0, #d5d9e0) 0 0 / 100% 3px no-repeat,              /* rail */
    repeating-linear-gradient(90deg, #8b7d6b 0 6px, transparent 6px 14px) 0 3px / 100% 5px no-repeat,   /* traverses */
    linear-gradient(#0f1830, #0f1830) 0 8px / 100% 3px no-repeat; }          /* ballast */

/* Easter egg : le train roule sur le rail (couche au-dessus, ne capte aucun clic) */
.train-lane { position: absolute; left: 0; right: 0; bottom: 11px; height: 58px; overflow: hidden; pointer-events: none; }
.train { position: absolute; left: 0; bottom: -2px; display: none; overflow: visible; will-change: transform; }
.train-lane.run .train { display: block; animation: train-run var(--train-s, 11s) linear forwards var(--train-pause-delay, 0s), train-chug .3s ease-in-out infinite alternate; animation-play-state: var(--train-state, running), running; }
@keyframes train-run { from { translate: -190px 0; } to { translate: calc(100vw + 20px) 0; } }
@keyframes train-chug { from { transform: translateY(0); } to { transform: translateY(-.7px); } }
.train .wheel { transform-box: fill-box; transform-origin: center; animation: wheel-spin .45s linear infinite; }
@keyframes wheel-spin { to { transform: rotate(360deg); } }
.train .puff { transform-box: fill-box; transform-origin: center; opacity: 0; animation: puff var(--d, 2s) ease-out infinite; animation-delay: var(--delay, 0s); }
@keyframes puff { 0% { opacity: .9; transform: translate(0, 0) scale(.5); } 60% { opacity: .45; } 100% { opacity: 0; transform: translate(var(--dx, -30px), var(--dy, -20px)) scale(var(--s, 2.4)); } }
@media (prefers-reduced-motion: reduce) { .train-lane { display: none; } }

.statusbar { border-bottom: 1px solid var(--border); background: var(--surface); font-size: .82rem; color: var(--text-2); }
.statusbar .wrap { padding-top: 6px; padding-bottom: 6px; display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: center; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-right: 6px; vertical-align: 1px; }
.dot.live { background: #0ca30c; }
.dot.stale { background: #fab219; }

@media (max-width: 980px) {
  .header-inner { flex-wrap: wrap; gap: 4px 12px; padding-top: 10px; }
  .header-tools { margin-left: auto; }
  .tabs { order: 3; width: 100%; margin-left: 0; }
  .tabs a { min-height: 46px; }
}
@media (max-width: 520px) { .brand-sub { display: none; } .brand-name { font-size: .92rem; } .tabs a { padding: 0 9px; } }

main.wrap { padding-top: 20px; padding-bottom: 40px; }

/* ---------- Tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.tile-label { font-size: .82rem; color: var(--text-2); }
.tile-value { font-size: 1.85rem; font-weight: 600; line-height: 1.15; margin-top: 4px; }
.tile-value small { font-size: .9rem; font-weight: 500; color: var(--text-2); margin-left: 2px; }
.tile-foot { font-size: .8rem; color: var(--muted); margin-top: 4px; }
.delta-up { color: var(--bad-text); }     /* plus de dérangements = mauvais */
.delta-down { color: var(--good-text); }

/* ---------- Cards / grid ---------- */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.span-2 { grid-column: 1 / -1; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.card-sub { margin: 2px 0 0; font-size: .82rem; color: var(--text-2); }
.chart { position: relative; width: 100%; min-height: 120px; }
.chart svg { display: block; overflow: visible; }
.chart text { fill: var(--muted); font: 11px var(--font); font-variant-numeric: tabular-nums; }
.chart .lbl { fill: var(--text-2); font-size: 12px; }
.chart .val { fill: var(--text); font-size: 12px; font-weight: 500; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .mark, .chart g.bar:hover .mark { opacity: .82; }
.chart .hover-band { fill: var(--surface-2); opacity: 0; }
.chart g.col:hover .hover-band { opacity: 1; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: .82rem; color: var(--text-2); margin: 0 0 8px; padding: 0; list-style: none; }
.legend li { display: flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.hbars { display: flex; flex-direction: column; gap: 4px; }
.hb-row { display: grid; grid-template-columns: minmax(90px, 38%) 1fr auto; align-items: center; gap: 10px; padding: 3px 4px; border-radius: 6px; }
.hb-row:hover { background: var(--surface-2); }
.hb-row.clickable { cursor: pointer; }
.hb-label { font-size: .84rem; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hb-track { height: 14px; }
.hb-bar { height: 14px; border-radius: 0 4px 4px 0; }
.hb-val { font-size: .82rem; color: var(--text); font-variant-numeric: tabular-nums; min-width: 3.2em; text-align: right; }
.seq-legend { display: flex; align-items: center; gap: 2px; font-size: .75rem; color: var(--muted); margin-top: 6px; justify-content: flex-end; }
.seq-legend i { width: 18px; height: 10px; border-radius: 2px; display: inline-block; }
.seq-legend span { margin: 0 6px; }
.empty { color: var(--muted); font-size: .9rem; padding: 24px 0; text-align: center; }

.data-table { margin-top: 8px; font-size: .85rem; }
.data-table summary { cursor: pointer; color: var(--text-2); }
.data-table table { margin-top: 8px; }

/* ---------- Map ---------- */
.map { height: 380px; border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.leaflet-container { font: 13px var(--font); background: var(--surface-2); }
.basemap { opacity: .75; }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) .basemap { filter: invert(1) brightness(.85) contrast(.9); opacity: .6; } }
:root[data-theme="dark"] .basemap { filter: invert(1) brightness(.85) contrast(.9); opacity: .6; }
.leaflet-popup-content { margin: 10px 12px; }
.leaflet-popup-content b { display: block; margin-bottom: 2px; }
:root[data-theme="dark"] .leaflet-popup-content-wrapper, :root[data-theme="dark"] .leaflet-popup-tip { background: #262624; color: #f0efec; }


/* ---------- Pills ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--text-2); white-space: nowrap; }
.pill i { width: 8px; height: 8px; border-radius: 2px; }
.pill.ongoing { color: var(--critical); border-color: currentColor; font-weight: 600; }
.badge { display: inline-block; font-size: .78rem; font-weight: 600; color: var(--accent-ink); background: color-mix(in srgb, var(--accent) 12%, transparent); padding: 2px 10px; border-radius: 999px; margin: 0 0 10px; }

/* ---------- Filters ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 14px; }
.filters label { display: flex; flex-direction: column; gap: 3px; font-size: .78rem; color: var(--text-2); min-width: 0; }
.filters .f-grow { flex: 1 1 240px; }
input, select, .btn, .seg button {
  font: inherit; font-size: .9rem; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; min-height: 36px;
}
input[type="search"] { width: 100%; }
select { max-width: 220px; }
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn { cursor: pointer; background: var(--accent); color: #fff; border-color: transparent; font-weight: 550; }
.btn:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; color: var(--text-2); border-color: var(--border); font-weight: 500; }
.seg { display: flex; flex-direction: column; gap: 3px; }
.seg-btns { display: flex; }
.seg-label { font-size: .78rem; color: var(--text-2); }
.seg button { cursor: pointer; border-radius: 0; margin-left: -1px; color: var(--text-2); }
.seg button:first-of-type { border-radius: 8px 0 0 8px; margin-left: 0; }
.seg button:last-of-type { border-radius: 0 8px 8px 0; }
.seg button.on { background: var(--surface-2); color: var(--text); font-weight: 600; }

/* ---------- Table ---------- */
.result-count { font-size: .85rem; color: var(--text-2); margin: 0 0 8px; }
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--grid); vertical-align: top; }
th { font-weight: 600; color: var(--text-2); font-size: .8rem; background: var(--surface); position: sticky; top: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.events tbody tr.ev { cursor: pointer; }
table.events tbody tr.ev:hover { background: var(--surface-2); }
table.events td:first-child { white-space: nowrap; font-variant-numeric: tabular-nums; }
table.events .route { font-weight: 550; }
table.events .cause-raw { display: block; font-size: .78rem; color: var(--muted); }
tr.detail td { background: var(--surface-2); padding: 12px 16px 14px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 6px 0 6px 14px; border-left: 2px solid var(--axis); margin-left: 4px; }
.timeline time { font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.timeline b { display: block; font-weight: 600; font-size: .86rem; }
.timeline p { margin: 2px 0 0; font-size: .84rem; color: var(--text-2); white-space: pre-line; }
.pager { display: flex; gap: 6px; justify-content: center; align-items: center; margin-top: 14px; font-size: .88rem; color: var(--text-2); }
.pager button { font: inherit; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 8px; padding: 6px 12px; cursor: pointer; }
.pager button:disabled { opacity: .4; cursor: default; }

@media (max-width: 700px) {
  table.events thead { display: none; }
  table.events tr.ev { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 10px 12px; border-bottom: 1px solid var(--grid); }
  table.events tr.ev td { border: 0; padding: 0; }
  table.events tr.ev td:nth-child(2) { grid-column: 1 / -1; order: -1; }
  table.events tr.ev td:nth-child(5), table.events tr.ev td:nth-child(7) { display: none; }
  tr.detail { display: block; } tr.detail td { display: block; }
}

/* ---------- Prose ---------- */
.prose { max-width: 820px; }
.prose p, .prose li { color: var(--text-2); }
.prose strong { color: var(--text); }
.prose ul { padding-left: 1.2em; }
.prose li { margin: 4px 0; }
.checklist { list-style: none; padding-left: 0 !important; }
.checklist li { padding-left: 24px; position: relative; }
.checklist li::before { content: ""; position: absolute; left: 2px; top: .5em; width: 10px; height: 10px; border: 1.5px solid var(--axis); border-radius: 3px; }

/* ---------- Comparaisons ---------- */
:root { --ref: #b5b3ab; }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) { --ref: #5e5d58; } }
:root[data-theme="dark"] { --ref: #5e5d58; }
.section-title { font-size: 1.1rem; margin: 28px 0 12px; }
.lead { color: var(--text-2); max-width: 900px; margin: 0 0 6px; font-size: .92rem; }
.note { color: var(--muted); font-size: .8rem; max-width: 900px; margin-top: 16px; }
.region-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-bottom: 16px; }
.region-card .tile-value { margin-bottom: 8px; }
.region-card .tile-label { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text); }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
.region-card dl { display: grid; grid-template-columns: 1fr auto; gap: 3px 12px; margin: 0; font-size: .84rem; }
.region-card dt { color: var(--text-2); }
.region-card dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
table.axes tr { cursor: pointer; }
table.axes tbody tr:hover { background: var(--surface-2); }
table.axes .ax-name { display: flex; align-items: center; gap: 8px; font-weight: 550; white-space: nowrap; }
table.axes .ax-name i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
table.axes tr.total td { color: var(--text-2); }
table.axes .err { color: var(--bad-text); font-size: .8rem; }

/* ---------- Tooltip ---------- */
.tooltip { position: fixed; z-index: 2000; pointer-events: none; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: .82rem; box-shadow: 0 4px 16px rgba(0,0,0,.12); max-width: 280px; }
.tooltip .tt-title { font-weight: 600; margin-bottom: 4px; }
.tooltip .tt-row { display: flex; align-items: center; gap: 8px; justify-content: space-between; font-variant-numeric: tabular-nums; }
.tooltip .tt-row span:first-child { display: flex; align-items: center; gap: 6px; color: var(--text-2); }
.tooltip i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }

.site-footer { border-top: 1px solid var(--border); color: var(--muted); font-size: .8rem; padding: 18px 0 28px; }

/* ---------- Carte de chaleur du réseau ---------- */
.map-lg { height: 560px; }
@media (max-width: 700px) { .map-lg { height: 420px; } }
.heat-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-top: 10px; font-size: .8rem; color: var(--text-2); }
.heat-legend .hl-item { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.heat-legend .hl-item i { width: 22px; height: 6px; border-radius: 3px; display: inline-block; }
.heat-legend .hl-title { color: var(--text); font-weight: 600; }
.leaflet-popup-content ol { margin: 4px 0 0; padding-left: 16px; }
.leaflet-popup-content li { margin: 2px 0; }

/* ---------- Période, mode de carte, filtres actifs ---------- */
.period { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.period label { display: flex; flex-direction: column; gap: 3px; font-size: .78rem; color: var(--text-2); }
.map-mode { display: flex; flex-direction: column; gap: 3px; font-size: .78rem; color: var(--text-2); flex: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: -2px 0 8px; }
.chips:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; padding: 3px 4px 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.chip button { border: 0; background: transparent; color: var(--text-2); cursor: pointer; font-size: .95rem; line-height: 1; padding: 0 6px; border-radius: 999px; }
.chip button:hover { color: var(--text); background: var(--border); }
.hb-row.active { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--text); }
.legend li.has-tip { cursor: help; }
.info { color: var(--muted); font-size: .85em; }
@media (max-width: 700px) { .card-head { flex-wrap: wrap; } }
#s-netmap-card { scroll-margin-top: 72px; }
.map-tools { display: flex; gap: 10px; flex-wrap: wrap; }
.axes-scale { display: flex; align-items: center; gap: 4px; font-size: .78rem; color: var(--text-2); margin: 0 0 8px; }
.axes-scale i { width: 18px; height: 8px; border-radius: 2px; display: inline-block; }
.axes-scale span { margin: 0 4px; }
.grad-bar { display: inline-block; width: 160px; height: 8px; border-radius: 4px; vertical-align: middle; margin: 0 6px; }
.has-tip { cursor: help; }
.tooltip { max-width: 340px; }
.hl-item i.dash { background: repeating-linear-gradient(90deg, var(--text-2) 0 6px, transparent 6px 10px) !important; height: 3px !important; }
.tooltip .tt-item { margin: 4px 0 0; font-weight: 400; color: var(--text-2); line-height: 1.4; }
.tooltip .tt-item b { color: var(--text); font-weight: 600; }
.tooltip .tt-note { margin: 8px 0 0; font-size: .78rem; color: var(--muted); }

/* ---------- Avertissement à l'arrivée ---------- */
.disclaimer { background: color-mix(in srgb, #fab219 14%, var(--surface)); border-bottom: 1px solid var(--border); font-size: .86rem; }
.disclaimer .wrap { display: flex; align-items: center; gap: 16px; padding-top: 10px; padding-bottom: 10px; }
.disclaimer p { margin: 0; color: var(--text); flex: 1; }
.disclaimer .btn { flex: none; min-height: 30px; padding: 4px 12px; }
.hint { margin: 2px 0 6px; font-size: .84rem; color: var(--text-2); }
.hint b { color: var(--text); }
.site-footer #status { display: inline-block; margin-top: 4px; }

/* ---------- Anneau (durées) ---------- */
.donut { display: flex; align-items: center; gap: 28px; flex-wrap: wrap; justify-content: center; }
.donut svg { flex: none; overflow: visible; }
.chart .donut-pct { font-size: 11px; font-weight: 600; }
.chart .donut-total { fill: var(--text); font-size: 20px; font-weight: 600; }
.chart .donut-sub { fill: var(--muted); font-size: 11px; }
.donut-legend { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 12px auto auto auto; gap: 6px 10px; align-items: center; font-size: .86rem; }
.donut-legend li { display: contents; }
.donut-legend i { width: 12px; height: 12px; border-radius: 3px; }
.donut-legend b { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.donut-legend .muted { text-align: right; font-variant-numeric: tabular-nums; font-size: .8rem; }

/* ---------- Mise en évidence d'une ligne ou d'un tronçon sur la carte : billes qui défilent ---------- */
.flow-beads { stroke-dasharray: 0.1 18; animation: flow 1.4s linear infinite; }
@keyframes flow { to { stroke-dashoffset: -18.1; } }
@media (prefers-reduced-motion: reduce) { .flow-beads { animation: none; } }

/* =====================================================================
   Style « quai de gare » : surcharges des composants
   ===================================================================== */
h2 { font-weight: 650; letter-spacing: -.003em; }

/* Cartes : feuilles d'affiche, filet épais en tête */
.card, .tile { border-radius: var(--radius); border-top: 3px solid var(--rule); }
.table-wrap { border-radius: var(--radius); }

/* Tuiles : libellé en petites capitales, chiffre étroit et gras, comme sur les tableaux de départ */
.tile-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .09em; font-weight: 600; color: var(--text-2); }
.tile-value { font-weight: 700; font-size: 2.1rem; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.region-card .tile-label { text-transform: none; letter-spacing: 0; font-size: .9rem; }

/* Boutons */
.btn { background: var(--btn); border-radius: 4px; }
input, select, .btn, .seg button, .pager button { border-radius: 4px; }
.seg button:first-of-type { border-radius: 4px 0 0 4px; }
.seg button:last-of-type { border-radius: 0 4px 4px 0; }
.seg button.on { background: var(--sign); color: #fff; border-color: var(--sign); }
:root[data-theme="dark"] .seg button.on { background: var(--btn); border-color: var(--btn); }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) .seg button.on { background: var(--btn); border-color: var(--btn); } }

/* Intertitres des comparaisons : panneau de gare (bleu nuit, liseré blanc intérieur) */
.section-title { margin: 32px 0 14px; }
.section-title .sign { display: inline-block; background: var(--sign); color: #fff; padding: 7px 16px 8px; border-radius: 3px;
  box-shadow: inset 0 0 0 2px var(--sign), inset 0 0 0 3.5px rgba(255,255,255,.9); font-weight: 650; letter-spacing: .01em; font-size: 1rem; }

/* Avertissement : affiche jaune des départs */
.disclaimer { background: var(--poster); color: var(--poster-ink); border-bottom: 0; }
.disclaimer p { color: var(--poster-ink); }
.disclaimer a { color: var(--poster-ink); font-weight: 600; }
.poster-tag { display: inline-block; background: var(--poster-ink); color: var(--poster); padding: 1px 8px; border-radius: 2px; margin-right: 4px; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; }
.disclaimer .btn.ghost { color: var(--poster-ink); border-color: rgba(17,20,24,.45); }
.disclaimer .btn.ghost:hover { background: rgba(17,20,24,.08); }

/* Historique : en-tête de tableau façon affiche d'horaire, heure en gras */
table.events thead th { background: var(--poster); color: var(--poster-ink); font-size: .74rem; text-transform: uppercase; letter-spacing: .07em; border-bottom: 2px solid var(--poster-ink); }
table.events td:first-child { font-weight: 650; }
.empty .clear-track { display: block; font-size: 1.05rem; color: var(--text); margin-bottom: 4px; letter-spacing: .02em; }
.empty .clear-track::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--heat-0); margin-right: 8px; vertical-align: 1px; }

/* Entreprises : petit liseré aux couleurs des livrées (repère discret, pas des logos) */
.co { white-space: nowrap; }
.co::before { content: ""; display: inline-block; width: 3px; height: .9em; margin-right: 4px; vertical-align: -1px; border-radius: 1px; background: var(--axis); }
.co[data-co="SBB"]::before { background: #d8232a; }            /* rouge */
.co[data-co="BLS"]::before { background: #3f9a35; }            /* vert */
.co[data-co="SOB"]::before { background: #b06c3c; }            /* cuivre du Traverso */
.co[data-co="RHB"]::before, .co[data-co="MGB"]::before { background: #a51d2d; }
.co[data-co="DB"]::before, .co[data-co="ÖBB"]::before { background: #c8102e; }

/* « En cours » : voyant rouge qui pulse doucement */
.pill.ongoing { color: var(--signal); }
.pill.ongoing::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .pill.ongoing::before { animation: none; } }

/* Onglets actifs dans les cartes */
.hb-row.active { box-shadow: inset 3px 0 0 var(--poster-ink); }
:root[data-theme="dark"] .hb-row.active { box-shadow: inset 3px 0 0 var(--poster); }

/* Pied de page */
.site-footer { border-top: 0; background: var(--sign); color: rgba(255,255,255,.72); margin-top: 24px; }
.site-footer .muted-2 { color: rgba(255,255,255,.5); }
.site-footer a { color: #fff; }

/* =====================================================================
   Bulles d'information : panneau bleu nuit, liseré jaune (signalétique)
   ===================================================================== */
.tooltip { background: var(--sign); color: #fff; border: 1px solid rgba(255,255,255,.12); border-top: 3px solid var(--poster);
  border-radius: 4px; padding: 10px 13px 11px; font-size: .82rem; line-height: 1.45; max-width: 340px;
  box-shadow: 0 10px 28px rgba(0,0,0,.28), 0 2px 6px rgba(0,0,0,.18); }
.tooltip .tt-title { font-weight: 700; font-size: .88rem; color: #fff; margin-bottom: 6px; letter-spacing: .005em; }
.tooltip .tt-row { gap: 14px; padding: 1px 0; }
.tooltip .tt-row span:first-child { color: rgba(255,255,255,.72); }
.tooltip .tt-row b { color: #fff; font-weight: 600; }
.tooltip i { box-shadow: 0 0 0 1px rgba(255,255,255,.35); }
.tooltip .muted { color: rgba(255,255,255,.62) !important; }
/* Bulles d'aide (ⓘ) : une option par ligne, nom en jaune, filet fin entre les options */
.tooltip .tt-item { margin: 0; padding: 5px 0; color: rgba(255,255,255,.82); line-height: 1.45; }
.tooltip .tt-item + .tt-item { border-top: 1px solid rgba(255,255,255,.1); }
.tooltip .tt-item b { display: block; color: var(--poster); font-weight: 650; margin-bottom: 1px; }
.tooltip .tt-note { margin: 6px 0 0; padding-top: 7px; border-top: 1px solid rgba(255,255,255,.18); font-size: .78rem; color: rgba(255,255,255,.66); }

/* Pastille « i » à la place du symbole ⓘ */
span.has-tip { display: inline-flex; align-items: center; gap: 5px; }
.info { position: relative; display: inline-block; flex: none; width: 15px; height: 15px; border-radius: 50%; vertical-align: middle; margin-left: 3px;
  font-size: 0; color: transparent; overflow: hidden;
  background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--axis); transition: background .15s, box-shadow .15s; }
span.has-tip .info { margin-left: 0; }
.info::before { content: "i"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font: 700 10px/1 "Helvetica Neue", Helvetica, Arial, sans-serif; color: var(--text-2); }
.has-tip:hover .info, .has-tip:focus-visible .info { background: var(--poster); box-shadow: inset 0 0 0 1px var(--poster-ink); }
.has-tip:hover .info::before, .has-tip:focus-visible .info::before { color: var(--poster-ink); }

/* Bulles au survol des cartes Leaflet : même panneau */
.leaflet-tooltip { background: var(--sign); color: #fff; border: 1px solid rgba(255,255,255,.12); border-top: 3px solid var(--poster); border-radius: 4px;
  padding: 7px 10px 8px; font: 13px/1.4 var(--font); box-shadow: 0 8px 22px rgba(0,0,0,.28); }
.leaflet-tooltip .muted { color: rgba(255,255,255,.65); }
.leaflet-tooltip-top::before { border-top-color: var(--sign); }
.leaflet-tooltip-bottom::before { border-bottom-color: var(--poster); }
.leaflet-tooltip-left::before { border-left-color: var(--sign); }
.leaflet-tooltip-right::before { border-right-color: var(--sign); }

/* Fenêtres au clic sur la carte : fiche claire avec filet de tête */
.leaflet-popup-content-wrapper { border-radius: 4px; border-top: 3px solid var(--sign); background: var(--surface); color: var(--text); box-shadow: 0 10px 28px rgba(0,0,0,.22); }
.leaflet-popup-tip { background: var(--surface); }
.leaflet-popup-content { font: 13px/1.45 var(--font); }
.leaflet-popup-content b { font-size: .95rem; margin-bottom: 4px; }
.leaflet-popup-content .muted { color: var(--muted); }
:root[data-theme="dark"] .leaflet-popup-content-wrapper, :root[data-theme="dark"] .leaflet-popup-tip { background: var(--surface-2); color: var(--text); }
:root[data-theme="dark"] .leaflet-popup-content-wrapper { border-top-color: var(--poster); }
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .leaflet-popup-content-wrapper, :root:where(:not([data-theme="light"])) .leaflet-popup-tip { background: var(--surface-2); color: var(--text); }
  :root:where(:not([data-theme="light"])) .leaflet-popup-content-wrapper { border-top-color: var(--poster); }
}
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
