:root {
  --bg: #f3f1ec;
  --surface: #ffffff;
  --surface-2: #f8f7f4;
  --ink: #15192b;
  --ink-2: #4b5165;
  --ink-3: #868b9b;
  --line: #e4e1d9;
  --navy: #14213d;
  --accent: #e2001a;
  --rt: #0a9c6b;
  --late: #c26a00;
  --bad: #c8102e;
  --shadow: 0 1px 2px rgba(20, 25, 43, .06), 0 6px 24px rgba(20, 25, 43, .06);
  --radius: 14px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1220; --surface: #171c2e; --surface-2: #1d2337; --ink: #eef0f6; --ink-2: #b4b9c9; --ink-3: #7d8397;
    --line: #2a3046; --navy: #0b1020; --rt: #2fd59a; --late: #ffb547; --bad: #ff5a6e;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 28px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--ink);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- en-tête ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 20px 10px;
  background: var(--navy); color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--accent); display: grid; place-items: center; }
.brand-mark svg { width: 22px; height: 22px; fill: #fff; }
.brand-text { font-size: 15px; letter-spacing: .01em; opacity: .92; }
.brand-text b { font-weight: 800; letter-spacing: .06em; margin-right: 4px; opacity: 1; }
.top-right { display: flex; align-items: center; gap: 14px; }
.clock { font: 600 20px/1 var(--mono); font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.rt-status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; opacity: .85; }
.rt-status i { width: 8px; height: 8px; border-radius: 50%; background: #8a90a3; }
.rt-status.ok i { background: #2fd59a; box-shadow: 0 0 0 0 rgba(47,213,154,.6); animation: pulse 2s infinite; }
.rt-status.ko i { background: #ff5a6e; }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px rgba(47,213,154,0); } 100% { box-shadow: 0 0 0 0 rgba(47,213,154,0); } }

main { max-width: 860px; margin: 0 auto; padding: 18px 16px 48px; }

/* ---------- recherche ---------- */
.search {
  position: relative; display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 6px 6px 6px 14px; box-shadow: var(--shadow);
}
.search:focus-within { border-color: var(--ink-3); }
.search-ico { width: 20px; height: 20px; fill: var(--ink-3); flex: none; }
.search input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink);
  font-size: 17px; padding: 10px 4px;
}
.search input::-webkit-search-cancel-button { display: none; }
.btn-near {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  border: 0; border-radius: 10px; padding: 10px 12px; background: var(--surface-2); color: var(--ink-2); font-size: 14px; font-weight: 600;
}
.btn-near:hover { background: var(--line); }
.btn-near svg { width: 18px; height: 18px; fill: currentColor; }
.btn-near.busy svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 520px) { .btn-near span { display: none; } }

.suggest {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 30;
  list-style: none; margin: 0; padding: 6px; max-height: 60vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.suggest li {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px; border-radius: 10px; cursor: pointer;
}
.suggest li[aria-selected="true"], .suggest li:hover { background: var(--surface-2); }
.suggest .s-name { font-weight: 600; }
.suggest .s-sub { color: var(--ink-3); font-size: 13px; margin-left: 6px; font-weight: 400; }
.suggest .s-lines { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.suggest .s-empty { color: var(--ink-3); cursor: default; }

.favs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.fav-chip {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: 6px 12px 6px 10px; font-size: 14px; font-weight: 600; color: var(--ink-2);
}
.fav-chip svg { width: 14px; height: 14px; fill: #f2b01e; }
.fav-chip:hover { border-color: var(--ink-3); color: var(--ink); }

/* ---------- badges lignes ---------- */
.badge {
  --c: #5c6670; --t: #fff;
  display: inline-grid; place-items: center; min-width: 30px; height: 26px; padding: 0 7px;
  background: var(--c); color: var(--t); border-radius: 6px;
  font: 800 14px/1 system-ui, sans-serif; letter-spacing: .01em; white-space: nowrap;
}
.badge.tram { border-radius: 50%; min-width: 28px; width: 28px; height: 28px; padding: 0; font-size: 15px; }
.badge.sm { min-width: 24px; height: 20px; font-size: 12px; padding: 0 5px; }
.badge.tram.sm { width: 22px; min-width: 22px; height: 22px; font-size: 12px; }
.badge.lg { min-width: 42px; height: 36px; font-size: 18px; border-radius: 8px; }
.badge.tram.lg { width: 40px; min-width: 40px; height: 40px; font-size: 19px; border-radius: 50%; }

/* ---------- tableau ---------- */
.board { margin-top: 20px; }
.board-head { margin-bottom: 14px; }
.board-title { display: flex; align-items: center; gap: 10px; }
.board-title h1 { font-size: clamp(24px, 4.2vw, 34px); line-height: 1.1; margin: 0; letter-spacing: -.015em; font-weight: 800; }
.fav-toggle { border: 0; background: transparent; padding: 6px; border-radius: 8px; }
.fav-toggle svg { width: 24px; height: 24px; fill: transparent; stroke: var(--ink-3); stroke-width: 1.6; }
.fav-toggle[aria-pressed="true"] svg { fill: #f2b01e; stroke: #f2b01e; }
.place-lines { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filters button {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 10px 4px 5px;
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2);
}
.filters button.all { padding: 6px 12px; }
.filters button.on { border-color: var(--ink); color: var(--ink); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--ink); }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 7px; font-size: 13px; font-weight: 600; color: var(--ink-3); }
.seg button.on { background: var(--navy); color: #fff; }

.notice { background: var(--surface); border: 1px dashed var(--line); color: var(--ink-2); border-radius: 12px; padding: 12px 14px; font-size: 14px; margin-bottom: 12px; }

.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.dep {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px;
  padding: 13px 16px; border-top: 1px solid var(--line); cursor: pointer; transition: background .15s;
}
.dep:first-child { border-top: 0; }
.dep:hover { background: var(--surface-2); }
.dep:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }
.dep-main { min-width: 0; }
.dep-head { font-weight: 700; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dep-head .arrow { color: var(--ink-3); font-weight: 400; margin-right: 4px; }
.dep-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 3px; font-size: 13px; color: var(--ink-3); }
.dep-meta .plat { border: 1px solid var(--line); border-radius: 5px; padding: 0 6px; font-weight: 600; color: var(--ink-2); }
.dep-meta .veh { color: var(--rt); font-weight: 600; }
.dep-when { text-align: right; min-width: 74px; }
.dep-min { font: 800 24px/1 system-ui, sans-serif; font-variant-numeric: tabular-nums; letter-spacing: -.02em; display: inline-flex; align-items: baseline; gap: 3px; }
.dep-min small { font-size: 13px; font-weight: 700; color: var(--ink-2); letter-spacing: 0; }
.dep-min.now { font-size: 15px; text-transform: uppercase; letter-spacing: .04em; color: var(--rt); animation: blink 1.4s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .45; } }
.dep-clock { display: flex; justify-content: flex-end; align-items: center; gap: 6px; margin-top: 4px; font: 500 13px/1 var(--mono); font-variant-numeric: tabular-nums; color: var(--ink-3); }
.dep-clock s { opacity: .7; }
.dep-clock .delay { color: var(--late); font-family: system-ui, sans-serif; font-weight: 700; }
.dep-clock .early { color: var(--rt); font-family: system-ui, sans-serif; font-weight: 700; }
.rt-dot, .th-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.rt-dot { background: var(--rt); box-shadow: 0 0 0 3px color-mix(in srgb, var(--rt) 20%, transparent); }
.th-dot { border: 1.5px solid var(--ink-3); }
.dep.theo .dep-min { color: var(--ink-2); font-weight: 700; }
.dep.cancel .dep-head, .dep.cancel .dep-clock { text-decoration: line-through; color: var(--ink-3); }
.dep .tag-bad { display: inline-block; background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); border-radius: 6px; padding: 3px 8px; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }

/* vue par ligne */
.grp { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; padding: 13px 16px; border-top: 1px solid var(--line); }
.grp:first-child { border-top: 0; }
.grp-times { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.chip-time {
  border: 0; background: var(--surface-2); border-radius: 8px; padding: 6px 9px; min-width: 52px; text-align: center;
  font: 800 16px/1 system-ui, sans-serif; font-variant-numeric: tabular-nums;
}
.chip-time small { font-size: 11px; font-weight: 700; color: var(--ink-2); margin-left: 2px; }
.chip-time.rt { box-shadow: inset 0 -2px 0 var(--rt); }
.chip-time.now { color: var(--rt); }
.chip-time.cancel { text-decoration: line-through; color: var(--ink-3); }

.foot { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; margin: 12px 4px 0; font-size: 12px; color: var(--ink-3); }
.legend { display: inline-flex; align-items: center; gap: 6px; }
#updated { margin-left: auto; }

.skeleton { height: 64px; border-top: 1px solid var(--line); background: linear-gradient(90deg, transparent, var(--surface-2), transparent); background-size: 200% 100%; animation: sh 1.2s infinite; }
@keyframes sh { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- état vide ---------- */
.empty { text-align: center; color: var(--ink-3); padding: 56px 16px 0; }
.empty-art svg { width: 220px; max-width: 70%; }
.empty-art .rail { stroke: var(--line); stroke-width: 3; }
.empty-art .tram rect:not(.win) { fill: var(--navy); }
.empty-art .tram .win { fill: var(--bg); }
.empty-art .tram circle { fill: var(--ink-3); }
.empty-art .tram path { stroke: var(--ink-3); stroke-width: 2; fill: none; }
.empty-art .tram { animation: roll 6s ease-in-out infinite; }
@keyframes roll { 0%, 100% { transform: translateX(-14px); } 50% { transform: translateX(14px); } }

/* ---------- panneau course ---------- */
.sheet { position: fixed; inset: 0; z-index: 50; display: flex; justify-content: flex-end; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(10, 14, 28, .45); animation: fade .2s; }
.sheet-panel {
  position: relative; width: min(460px, 100%); height: 100%; background: var(--surface);
  display: flex; flex-direction: column; box-shadow: -10px 0 40px rgba(0,0,0,.2); animation: slide .25s ease-out;
}
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
@media (max-width: 640px) {
  .sheet { align-items: flex-end; }
  .sheet-panel { width: 100%; height: 88vh; border-radius: 18px 18px 0 0; animation-name: up; }
  @keyframes up { from { transform: translateY(40px); opacity: 0; } }
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 16px 12px; }
.sheet-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.sheet-title .t { font-weight: 800; font-size: 18px; line-height: 1.2; }
.sheet-title .s { font-size: 13px; color: var(--ink-3); }
.sheet-close { border: 0; background: var(--surface-2); width: 36px; height: 36px; border-radius: 50%; font-size: 22px; line-height: 1; flex: none; }
.map { height: 230px; flex: none; background: var(--surface-2); }
.map .maplibregl-ctrl-attrib { font-size: 10px; }
.map .maplibregl-popup-content { padding: 6px 10px; border-radius: 8px; font: 600 13px/1.3 system-ui, sans-serif; color: #15192b; }
.timeline { list-style: none; margin: 0; padding: 14px 16px 28px; overflow: auto; flex: 1; }
.tl { display: grid; grid-template-columns: 54px 22px 1fr; gap: 10px; align-items: stretch; min-height: 42px; }
.tl-time { text-align: right; font: 600 14px/1.2 var(--mono); font-variant-numeric: tabular-nums; padding-top: 2px; }
.tl-time s { display: block; font-size: 11px; color: var(--ink-3); }
.tl-time.rt { color: var(--rt); }
.tl-rail { position: relative; }
.tl-rail::before { content: ""; position: absolute; left: 9px; top: 0; bottom: 0; width: 4px; background: var(--c); }
.tl:first-child .tl-rail::before { top: 9px; }
.tl:last-child .tl-rail::before { bottom: calc(100% - 13px); }
.tl-rail::after { content: ""; position: absolute; left: 4px; top: 4px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 3px solid var(--c); box-sizing: border-box; }
.tl.passed { opacity: .45; }
.tl.here .tl-rail::after { width: 18px; height: 18px; left: 2px; top: 2px; background: var(--c); }
.tl.here .tl-name { font-weight: 800; }
.tl-name { padding: 2px 0 12px; }
.tl-name a { color: inherit; text-decoration: none; }
.tl-name a:hover { text-decoration: underline; }
.tl-name .tag-bad { margin-left: 6px; font-size: 11px; color: var(--bad); font-weight: 700; text-transform: uppercase; }
.tl-veh { position: absolute; left: 0; width: 22px; height: 22px; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center; z-index: 1; transform: translateY(-50%); box-shadow: 0 0 0 3px var(--surface); }
.tl-veh svg { width: 13px; height: 13px; fill: #fff; }

.veh-marker-in { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.35); }
.veh-marker-in svg { width: 14px; height: 14px; fill: #fff; }

/* ---------- mode affichage (kiosque) ---------- */
body.kiosk .finder, body.kiosk .toolbar, body.kiosk .fav-toggle, body.kiosk .foot .legend { display: none; }
body.kiosk main { max-width: none; padding: 2vh 3vw; }
body.kiosk .board { margin-top: 0; }
body.kiosk .board-title h1 { font-size: 5vh; }
body.kiosk .dep { padding: 1.6vh 2vw; }
body.kiosk .dep-head { font-size: 3.2vh; }
body.kiosk .dep-min { font-size: 4.4vh; }
body.kiosk .dep-meta, body.kiosk .dep-clock { font-size: 2vh; }
body.kiosk .badge.lg { height: 5.4vh; min-width: 6vh; font-size: 3vh; }
body.kiosk .badge.tram.lg { width: 5.6vh; height: 5.6vh; min-width: 5.6vh; }
body.kiosk .top { padding: 1.4vh 3vw; }
body.kiosk .clock { font-size: 3.6vh; }

@media (max-width: 520px) {
  .top { padding-left: 14px; padding-right: 14px; }
  .brand-text { font-size: 14px; }
  .brand-text span, .rt-status span { display: none; }
  .clock { font-size: 18px; }
}
