:root {
  --bg: #0f1115;
  --panel: rgba(18, 20, 26, 0.94);
  --panel-solid: #14161c;
  --raise: #1c1f27;
  --raise-2: #242833;
  --line: #2a2e39;
  --text: #eef0f4;
  --muted: #8d95a5;
  --faint: #5d6474;
  --accent: #e0457b;
  --accent-ink: #fff;
  --ok: #3ccf91;
  --warn: #f2b33d;
  --bad: #ff5f5f;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45), 0 1px 0 rgba(255, 255, 255, 0.04) inset;
  --radius: 16px;
  --font: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: var(--font); /* chiffres de largeur fixe de Barlow (tabular-nums), plus de police « code » */
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #eef0f3;
  --panel: rgba(255, 255, 255, 0.95);
  --panel-solid: #fff;
  --raise: #f3f4f7;
  --raise-2: #e8eaef;
  --line: #e2e5eb;
  --text: #15171c;
  --muted: #5f6676;
  --faint: #98a0ae;
  --accent: #b3204f;
  --ok: #138a5a;
  --warn: #b07405;
  --bad: #d03030;
  --shadow: 0 10px 34px rgba(20, 24, 40, 0.16), 0 0 0 1px rgba(20, 24, 40, 0.05);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
/* pas de zoom de la page au double tap (le pincement reste possible) ; la carte garde ses propres gestes */
html, body, body * { touch-action: manipulation; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-variant-numeric: tabular-nums; /* horaires et compteurs alignés */
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
#map { position: fixed; inset: 0; }
button { font: inherit; color: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }

/* ---------- panneau ---------- */
.panel {
  position: fixed; top: 16px; left: 16px; z-index: 5;
  width: 372px; max-height: calc(100dvh - 32px);
  display: flex; flex-direction: column;
  background: var(--panel);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  transition: max-height 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.sheet-handle { display: none; }

.brand { display: flex; align-items: center; gap: 10px; padding: 14px 12px 12px 14px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  overflow: hidden; background: #99063a;
  box-shadow: 0 4px 14px rgba(153, 6, 58, 0.35);
}
.brand-mark img { display: block; width: 100%; height: 100%; }
.brand-text { flex: 1; min-width: 0; }
.brand .brand-title { margin: 0; font-size: 15.5px; font-weight: 800; }
.brand p { margin: 1px 0 0; font-size: 12px; color: var(--muted); }
.live {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 10px; border-radius: 999px; background: var(--raise);
  font-family: var(--mono); font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.live[data-state="ok"] .live-dot { background: var(--ok); box-shadow: 0 0 0 0 var(--ok); animation: pulse 2.4s infinite; }
.live[data-state="slow"] .live-dot { background: var(--warn); }
.live[data-state="down"] .live-dot { background: var(--bad); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent); }
  70% { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.icon-btn {
  width: 34px; height: 34px; border-radius: 10px; border: 0; flex: none;
  background: transparent; display: grid; place-items: center; cursor: pointer;
  color: var(--muted); transition: background 0.15s, color 0.15s, transform 0.12s;
}
.icon-btn:hover { background: var(--raise); color: var(--text); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn svg { width: 19px; height: 19px; }
#collapseBtn svg { transition: transform 0.25s; }
.panel[data-collapsed="true"] #collapseBtn svg { transform: rotate(180deg); }
.panel[data-collapsed="true"] .panel-body { display: none; }

.panel-body { overflow-y: auto; padding: 0 14px 14px; overscroll-behavior: contain; scrollbar-width: thin; }

/* recherche */
.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--raise); border: 1px solid transparent; border-radius: 12px;
  padding: 0 10px; height: 42px; transition: border-color 0.15s, background 0.15s;
}
.search:focus-within { border-color: var(--accent); background: var(--panel-solid); }
.search svg { width: 17px; height: 17px; color: var(--muted); flex: none; }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: 14.5px; }
.search input::placeholder { color: var(--faint); }
.search input::-webkit-search-cancel-button { display: none; }
.search kbd { font-family: var(--mono); font-size: 11px; color: var(--faint); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }
.results { list-style: none; margin: 6px 0 0; padding: 4px; background: var(--panel-solid); border: 1px solid var(--line); border-radius: 12px; }
.results li { display: flex; align-items: center; gap: 10px; padding: 8px 8px; border-radius: 8px; cursor: pointer; }
.results li[aria-selected="true"], .results li:hover { background: var(--raise); }
.results .r-title { font-weight: 600; }
.results .r-sub { font-size: 12px; color: var(--muted); }
.results .r-main { flex: 1; min-width: 0; }
.results .r-badges { display: flex; gap: 3px; flex-wrap: wrap; justify-content: flex-end; max-width: 45%; }
.r-icon { width: 28px; height: 28px; border-radius: 8px; background: var(--raise-2); display: grid; place-items: center; flex: none; color: var(--muted); }
.r-icon svg { width: 16px; height: 16px; }

/* onglets */
.tabs {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px;
  margin: 12px 0 2px; padding: 3px; border-radius: 12px; background: var(--raise);
}
.tabs [role=tab] {
  height: 34px; border: 0; border-radius: 9px; background: transparent; cursor: pointer;
  font-weight: 600; font-size: 13px; color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: color 0.15s, background-color 0.15s;
}
.tabs [role=tab]:hover { color: var(--text); }
.tabs [role=tab][aria-selected="true"] { background: var(--panel-solid); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18); }
.tab-count {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--warn); color: #1d1606;
  font-family: var(--mono); font-size: 11px; font-weight: 600; display: inline-grid; place-items: center;
}
.tab-count[hidden], .tabs[hidden] { display: none; }

/* sections du menu */
.group { padding: 14px 0 16px; border-top: 1px solid var(--line); }
.group:first-child { border-top: 0; padding-top: 10px; }
.group-head { display: flex; align-items: center; gap: 10px; min-height: 36px; margin-bottom: 8px; }
.group-head h2 { margin: 0; font-size: 14px; font-weight: 700; color: var(--text); }
.group-head .gcount { flex: 1; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.group-head .gcount b { font-family: var(--mono); font-weight: 600; color: var(--text); }
.group-head.plain { margin-top: 16px; }
.group-note { margin: 8px 0 0; font-size: 12px; line-height: 1.45; color: var(--muted); }
.vis {
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: transparent; cursor: pointer;
  display: grid; place-items: center; color: var(--muted); flex: none;
  transition: background-color 0.15s, color 0.15s, transform 0.12s;
}
.vis svg { width: 18px; height: 18px; }
.vis .i-off { display: none; }
.vis[aria-pressed="false"] { color: var(--faint); border-style: dashed; }
.vis[aria-pressed="false"] .i-on { display: none; }
.vis[aria-pressed="false"] .i-off { display: block; }
.vis:hover { background: var(--raise); color: var(--text); }
.vis:active { transform: scale(0.95); }

/* lignes de train */
.line-list { list-style: none; margin: 0 -6px; padding: 0; }
.line-row {
  width: 100%; min-height: 48px; padding: 6px; border: 0; border-radius: 10px; background: transparent; cursor: pointer;
  display: flex; align-items: center; gap: 12px; text-align: left; transition: background-color 0.15s, transform 0.12s;
}
.line-row:hover { background: var(--raise); }
.line-row:active { transform: scale(0.99); }
.lr-main { flex: 1; min-width: 0; display: grid; gap: 1px; }
.lr-main b { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lr-main small { font-size: 12px; color: var(--muted); }
.line-row[data-live="1"] .lr-main small { color: var(--ok); }
.badge.num { width: 34px; min-width: 34px; height: 28px; padding: 0; border-radius: 8px; font-family: var(--mono); font-size: 12.5px; font-weight: 600; color: #fff; cursor: inherit; flex: none; }
.badge.num.mini { width: 28px; min-width: 28px; height: 20px; font-size: 11px; border-radius: 6px; }

/* sous-groupes de bus */
details.sub + details.sub { margin-top: 2px; }
details.sub summary {
  display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 8px; margin: 0 -8px; border-radius: 10px;
  font-size: 13px; font-weight: 600; color: var(--muted);
}
details.sub summary:hover { background: var(--raise); color: var(--text); }
details.sub summary::after {
  content: ""; width: 7px; height: 7px; margin-left: auto; border-right: 1.8px solid var(--faint); border-bottom: 1.8px solid var(--faint);
  transform: rotate(-45deg); transition: transform 0.2s cubic-bezier(0.23, 1, 0.32, 1);
}
details.sub[open] summary { color: var(--text); }
details.sub[open] summary::after { transform: rotate(45deg); }
details.sub .sub-n { font-family: var(--mono); font-size: 11.5px; color: var(--faint); font-weight: 500; }
details.sub .badges { padding: 4px 0 10px; }
details summary { list-style: none; cursor: pointer; }
details summary::-webkit-details-marker { display: none; }

.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge {
  min-width: 34px; height: 34px; padding: 0 9px; border-radius: 10px; border: 0; cursor: pointer;
  background: var(--c); color: var(--t, #fff); font-weight: 800; font-size: 14px;
  display: inline-grid; place-items: center; transition: transform 0.12s, box-shadow 0.15s, opacity 0.15s;
}
@media (hover: hover) and (pointer: fine) {
  button.badge:hover { transform: translateY(-1px); box-shadow: 0 4px 12px color-mix(in srgb, var(--c) 40%, transparent); }
}
button.badge:active { transform: scale(0.95); }
.badge.tram { border-radius: 50%; width: 38px; height: 38px; padding: 0; font-size: 15.5px; }
.badges.small .badge { min-width: 32px; height: 28px; font-size: 12px; border-radius: 7px; padding: 0 7px; }
.badge.mini { min-width: 22px; height: 20px; font-size: 11px; border-radius: 6px; padding: 0 5px; cursor: default; }
.badge.mini.tram { width: 20px; height: 20px; font-size: 11px; }

/* gares */
.st-list { list-style: none; margin: 0 -6px; padding: 0; }
.st-row {
  width: 100%; min-height: 52px; padding: 7px 6px; border: 0; border-radius: 10px; background: transparent; cursor: pointer;
  display: grid; gap: 3px; text-align: left; transition: background-color 0.15s;
}
.st-row:hover { background: var(--raise); }
.st-name { font-size: 13.5px; font-weight: 600; }
.st-next { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 12.5px; color: var(--muted); }
.st-dest { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-time { font-family: var(--mono); font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.st-time.late { color: var(--warn); }
.st-none { color: var(--muted); }

/* info trafic */
.alerts { list-style: none; padding: 10px 0 0; margin: 0; display: grid; gap: 8px; }
.alerts li { background: var(--raise); border-radius: 10px; padding: 10px 12px; display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; align-items: start; }
.alerts .a-title { font-weight: 700; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.alerts .a-msg { grid-column: 2; font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.alerts .sev { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; background: var(--warn); }
.alerts .sev.s3, .alerts .sev.s4 { background: var(--bad); }
.alerts .sev.s1 { background: var(--faint); }
.alerts li.empty-state { display: block; background: transparent; padding: 18px 2px; color: var(--muted); font-size: 13px; }

.near-btn {
  margin-top: 12px; width: 100%; height: 44px; border-radius: 12px; border: 1px solid var(--line);
  background: transparent; color: var(--text); font-weight: 600; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px; transition: background-color 0.15s, transform 0.12s;
}
.near-btn:hover { background: var(--raise); }
.near-btn:active { transform: scale(0.98); }
.near-btn svg { width: 17px; height: 17px; color: var(--accent); }

.sources { margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--line); font-size: 12px; line-height: 1.5; color: var(--faint); }
.sources summary { display: flex; align-items: center; min-height: 36px; color: var(--muted); font-weight: 600; }
.sources summary::after {
  content: ""; width: 6px; height: 6px; margin-left: 8px; border-right: 1.6px solid var(--faint); border-bottom: 1.6px solid var(--faint);
  transform: rotate(45deg) translateY(-2px);
}
.sources[open] summary::after { transform: rotate(-135deg); }
.sources p { margin: 4px 0 6px; }
.sources a { color: var(--muted); }
.deps li.clickable { cursor: pointer; border-radius: 8px; }
@media (hover: hover) and (pointer: fine) { .deps li.clickable:hover { background: var(--raise); } }


/* ---------- fiche détail ---------- */
.detail { margin-top: 12px; animation: rise 0.22s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.d-top { display: flex; align-items: flex-start; gap: 10px; }
.d-top .badge { flex: none; cursor: default; }
.d-title { flex: 1; min-width: 0; }
.d-title h3 { margin: 0; font-size: 16.5px; font-weight: 800; line-height: 1.25; }
.d-title p { margin: 3px 0 0; color: var(--muted); font-size: 12.5px; }
/* fermer la fiche : pastille contrastée, toujours visible en haut de la fiche (en-tête collant) */
.d-top { position: sticky; top: 0; z-index: 4; margin: -12px -14px 0; padding: 12px 14px 10px; background: var(--panel-solid); }
.d-close {
  width: 36px; height: 36px; border-radius: 50%; margin: -2px -2px 0 0;
  background: var(--raise-2); color: var(--text); border: 1px solid var(--line);
}
.d-close svg { width: 18px; height: 18px; stroke-width: 2.4; }
.d-close:hover { background: var(--line); color: var(--text); }
.d-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* zone de toucher élargie à 44 px sans grossir le visuel */
.d-close { position: relative; }
.d-close::after { content: ''; position: absolute; inset: -5px; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 12px 0 4px; }
.fact { background: var(--raise); border-radius: 10px; padding: 8px 10px; }
.fact b { display: block; font-family: var(--mono); font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.fact span { font-size: 11px; color: var(--muted); }
.fact.late b { color: var(--warn); }
.fact.ok b { color: var(--ok); }
.fact.bad b { color: var(--bad); }
.d-actions { display: flex; gap: 6px; margin-top: 10px; }
.btn {
  height: 34px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: transparent;
  font-weight: 600; font-size: 12.5px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; transition: background-color 0.15s, border-color 0.15s, color 0.15s, transform 0.12s;
}
.btn:hover { background: var(--raise); }
.btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn svg { width: 15px; height: 15px; }
.seg { display: inline-flex; background: var(--raise); border-radius: 10px; padding: 3px; margin: 12px 0 6px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; font-weight: 600; font-size: 12.5px; color: var(--muted); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--panel-solid); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,0.2); }

.deps { list-style: none; margin: 8px 0 0; padding: 0; }
.deps li { display: flex; align-items: center; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--line); }
.deps li:last-child { border-bottom: 0; }
.deps .dest { flex: 1; min-width: 0; }
.deps .dest b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.deps .dest small { color: var(--muted); font-size: 11.5px; }
.deps .times { display: flex; gap: 10px; align-items: baseline; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.deps .t { font-weight: 600; font-size: 14px; white-space: nowrap; }
.deps .t.rt { color: var(--ok); }
.deps .t.rt::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin-right: 5px; vertical-align: 2px; opacity: 0.85; }
.deps .t.next { color: var(--muted); font-weight: 500; font-size: 12.5px; }
.deps .delay { font-size: 11.5px; font-weight: 700; color: var(--warn); }
.deps .delay.cancel { color: var(--bad); }
.deps .clock { font-family: var(--mono); font-weight: 600; width: 46px; flex: none; }
.empty { color: var(--muted); font-size: 13px; padding: 14px 0 6px; }
.loading { color: var(--muted); font-size: 13px; padding: 14px 0; display: flex; align-items: center; gap: 8px; }
.loading::before { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.stops-line { list-style: none; margin: 10px 0 0; padding: 0 0 0 4px; }
.stops-line li { position: relative; padding: 5px 0 5px 20px; display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.stops-line li::before { content: ""; position: absolute; left: 4px; top: 0; bottom: 0; width: 3px; background: var(--c); opacity: 0.6; }
.stops-line li::after { content: ""; position: absolute; left: 1px; top: 50%; width: 9px; height: 9px; margin-top: -4.5px; border-radius: 50%; background: var(--panel-solid); border: 2px solid var(--c); }
.stops-line li.past { color: var(--faint); }
.stops-line li .tm { font-family: var(--mono); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.d-section { margin-top: 14px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }

/* ---------- contrôles carte ---------- */
.map-ctrl { position: fixed; right: 16px; top: 16px; z-index: 4; display: grid; gap: 8px; }
.icon-btn.float { width: 42px; height: 42px; border-radius: 12px; background: var(--panel); box-shadow: var(--shadow); border: 1px solid var(--line); color: var(--text); backdrop-filter: blur(14px); }
.icon-btn.float:hover { background: var(--panel-solid); }
:root[data-theme="dark"] .i-moon, :root[data-theme="light"] .i-sun { display: none; }
.icon-btn.txt { font-weight: 800; font-size: 13px; letter-spacing: 0.02em; }
.icon-btn.txt[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.maplibregl-ctrl-bottom-right { right: 6px; bottom: 6px; }
.maplibregl-ctrl-group { background: var(--panel) !important; border: 1px solid var(--line); border-radius: 12px !important; box-shadow: var(--shadow) !important; overflow: hidden; }
.maplibregl-ctrl-group button { width: 40px !important; height: 40px !important; }
.maplibregl-ctrl-group button + button { border-top: 1px solid var(--line) !important; }
:root[data-theme="dark"] .maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(1); }
.maplibregl-ctrl-attrib { background: color-mix(in srgb, var(--panel-solid) 75%, transparent) !important; color: var(--muted); font-size: 10.5px; }
.maplibregl-ctrl-attrib a { color: var(--muted) !important; }
:root[data-theme="dark"] .maplibregl-ctrl-attrib-button { filter: invert(1); }

.user-dot { width: 18px; height: 18px; border-radius: 50%; background: #3b82f6; border: 3px solid #fff; box-shadow: 0 0 0 8px rgba(59, 130, 246, 0.22), 0 2px 6px rgba(0,0,0,0.4); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 10;
  background: var(--panel-solid); color: var(--text); border: 1px solid var(--line); box-shadow: var(--shadow);
  padding: 10px 14px; border-radius: 12px; font-size: 13px; max-width: calc(100vw - 32px);
}

.map-tip {
  font-family: var(--font); font-size: 12.5px; font-weight: 600; color: var(--text);
}
.maplibregl-popup-content { background: var(--panel-solid) !important; color: var(--text); border-radius: 10px !important; padding: 7px 10px !important; box-shadow: var(--shadow) !important; border: 1px solid var(--line); }
.maplibregl-popup-tip { display: none; }

/* ---------- mobile : panneau en bas ---------- */
@media (max-width: 640px) {
  .panel {
    top: auto; left: 0; right: 0; bottom: 0; width: 100%;
    max-height: 62dvh; border-radius: 20px 20px 0 0; border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .panel[data-collapsed="true"] { max-height: 140px; }
  .panel.dragging { transition: none; }
  .sheet-handle, .brand { touch-action: none; }
  .panel[data-collapsed="true"] .panel-body { display: block; overflow: hidden; }
  .panel[data-collapsed="true"] .panel-body > :not(.search) { display: none; }
  .sheet-handle { display: block; width: 100%; height: 22px; border: 0; background: transparent; position: relative; cursor: pointer; flex: none; }
  .sheet-handle::after { content: ""; position: absolute; left: 50%; top: 9px; width: 40px; height: 4px; margin-left: -20px; border-radius: 2px; background: var(--faint); opacity: 0.6; }
  .brand { padding-top: 0; cursor: pointer; }
  .brand p { display: none; }
  #collapseBtn { display: none; }
  .map-ctrl { top: 12px; right: 12px; }
  .maplibregl-ctrl-bottom-right { display: none; }
  .toast { bottom: auto; top: 16px; }
  .search kbd { display: none; }
  .search input { font-size: 16px; } /* sous 16 px, l'iPhone agrandit la page quand on touche le champ */
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.alerts .a-lines { grid-column: 2; display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.brand .brand-title { line-height: 1.15; white-space: nowrap; }
.brand-kicker { display: block; font-size: 10.5px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); margin-bottom: 1px; }

/* sections repliables du menu */
.g-toggle {
  display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 6px 0 0; margin: 0;
  border: 0; background: transparent; color: inherit; font: inherit; cursor: pointer; border-radius: 8px;
}
.g-toggle::after {
  content: ""; width: 7px; height: 7px; margin-top: -3px; border-right: 1.8px solid var(--muted); border-bottom: 1.8px solid var(--muted);
  transform: rotate(45deg); transition: transform 0.2s cubic-bezier(0.23, 1, 0.32, 1);
}
.g-toggle[aria-expanded="false"]::after { transform: rotate(-45deg); margin-top: 0; }
.g-toggle:hover::after { border-color: var(--text); }
.group:has(.group-body[hidden]) { padding-bottom: 6px; }
.group:has(.group-body[hidden]) .group-head { margin-bottom: 0; }

/* page de texte (mentions légales) */
body.doc { overflow: auto; height: auto; min-height: 100%; font-size: 15px; line-height: 1.6; }
.doc-head, .doc-body { max-width: 720px; margin: 0 auto; padding: 0 20px; }
.doc-head { padding-top: 28px; padding-bottom: 8px; }
.doc-back {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 12px 0 6px; margin-left: -6px;
  border-radius: 10px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px;
  transition: background-color 0.15s, color 0.15s;
}
.doc-back:hover { background: var(--raise); color: var(--text); }
.doc-back svg { width: 18px; height: 18px; }
.doc-kicker { margin: 22px 0 4px; font-size: 11px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); }
.doc h1 { margin: 0; font-size: 26px; font-weight: 800; line-height: 1.2; }
.doc-meta { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.doc-toc { display: flex; flex-wrap: wrap; gap: 6px; margin: 18px 0 4px; }
.doc-toc a {
  display: inline-flex; align-items: center; min-height: 32px; padding: 0 12px; border-radius: 999px;
  background: var(--raise); color: var(--text); text-decoration: none; font-size: 13px; font-weight: 600;
  transition: background-color 0.15s;
}
.doc-toc a:hover { background: var(--raise-2); }
.doc-body { padding-bottom: 64px; }
.doc-body section { padding: 26px 0 6px; border-top: 1px solid var(--line); margin-top: 22px; scroll-margin-top: 16px; }
.doc-body h2 { margin: 0 0 10px; font-size: 19px; font-weight: 800; }
.doc-body h3 { margin: 20px 0 6px; font-size: 15.5px; font-weight: 700; }
.doc-body p, .doc-body li { max-width: 68ch; color: var(--text); }
.doc-body p { margin: 0 0 12px; }
.doc-body ul { margin: 0 0 12px; padding-left: 20px; }
.doc-body li { margin: 4px 0; }
.doc-body a { color: var(--accent); text-underline-offset: 2px; }
.doc-body dl { display: grid; grid-template-columns: minmax(140px, max-content) 1fr; gap: 6px 18px; margin: 0 0 12px; }
.doc-body dt { color: var(--muted); font-weight: 600; font-size: 14px; }
.doc-body dd { margin: 0; }
.doc-note { font-size: 13.5px; color: var(--muted) !important; }
.doc-table { width: 100%; border-collapse: collapse; margin: 6px 0 14px; font-size: 14px; }
.doc-table th { text-align: left; font-size: 12.5px; font-weight: 700; color: var(--muted); padding: 8px 10px 8px 0; border-bottom: 1px solid var(--line); }
.doc-table td { padding: 9px 10px 9px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.doc-table td:first-child { font-weight: 600; width: 45%; }
mark.todo { background: color-mix(in srgb, var(--warn) 22%, transparent); color: var(--text); padding: 1px 4px; border-radius: 4px; font-weight: 600; }
.doc-status { margin-left: 8px; color: var(--ok); font-size: 13.5px; }
@media (max-width: 640px) {
  .doc-body dl { grid-template-columns: 1fr; gap: 2px; }
  .doc-body dd { margin-bottom: 8px; }
  .doc h1 { font-size: 22px; }
  .doc-table td:first-child { width: 50%; }
}
.legal-link { display: inline-flex; align-items: center; min-height: 36px; font-size: 12px; color: var(--muted); font-weight: 600; text-underline-offset: 2px; }
.legal-link:hover { color: var(--text); }

/* libre-service : choix du type et de la zone */
.mm-types { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.mm-chip {
  min-height: 64px; padding: 8px 6px; border-radius: 12px; border: 1px solid var(--line); background: transparent; cursor: pointer;
  display: grid; justify-items: center; align-content: center; gap: 3px; color: var(--muted);
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, transform 0.12s;
}
.mm-chip:active { transform: scale(0.97); }
.mm-ico { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--raise-2); color: var(--muted); transition: background-color 0.15s, color 0.15s; }
.mm-ico svg { width: 18px; height: 18px; }
.mm-lab { font-size: 12px; font-weight: 600; }
.mm-n { font-family: var(--mono); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.mm-chip[aria-pressed="true"] { border-color: color-mix(in srgb, var(--c) 55%, transparent); background: color-mix(in srgb, var(--c) 12%, transparent); color: var(--text); }
.mm-chip[aria-pressed="true"] .mm-ico { background: var(--c); color: #fff; }
.mm-chip[aria-pressed="false"] { border-style: dashed; }
@media (hover: hover) and (pointer: fine) { .mm-chip:hover { border-color: var(--faint); } }
.mm-scope { display: grid; grid-template-columns: 1fr 1fr; width: 100%; margin: 10px 0 0; }
.mm-scope button { min-height: 32px; }
.badge.mm-badge { width: 38px; height: 38px; padding: 0; border-radius: 50%; color: #fff; cursor: default; }
.badge.mm-badge svg { width: 22px; height: 22px; }

/* « Mes lignes » */
.fav-group .badges { margin-bottom: 10px; }
.fav-scope { display: grid; grid-template-columns: 1fr 1fr; width: 100%; margin: 0 0 4px; }
.fav-scope button { min-height: 32px; }
.link-btn {
  min-height: 36px; padding: 0; border: 0; background: transparent; cursor: pointer;
  color: var(--muted); font: 600 12.5px var(--font); text-decoration: underline; text-underline-offset: 3px;
}
.link-btn:hover { color: var(--text); }
.near-btn svg[viewBox] path { stroke-linejoin: round; }
.fav-pick {
  padding: 12px; border-radius: 12px; border: 1px dashed var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}
.fav-pick p { margin: 0 0 10px; font-size: 13px; line-height: 1.45; color: var(--muted); }
.fav-pick p b { display: block; color: var(--text); font-size: 13.5px; }
.fav-done { width: 100%; justify-content: center; height: 40px; background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.fav-done:hover { background: var(--accent); filter: brightness(1.08); }

/* ligne choisie : petite coche dans un coin */
.badge.is-fav { position: relative; }
.badge.is-fav::after, .line-row.is-fav .badge::after {
  content: ""; position: absolute; top: -4px; right: -4px; width: 13px; height: 13px; border-radius: 50%;
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 6.2l2 2 4-4.4' fill='none' stroke='white' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 11px no-repeat;
  box-shadow: 0 0 0 2px var(--panel-solid);
}
.line-row.is-fav .badge { position: relative; }
.fav-group .badge.is-fav::after { display: none; }

/* mode choix : les lignes deviennent des cases à cocher */
.picking .group:not(.fav-group) [data-route] { cursor: copy; }
.picking .group:not(.fav-group) .badge:not(.is-fav) { opacity: 0.55; }
.picking .group:not(.fav-group) .line-row:not(.is-fav) { opacity: 0.6; }

/* en mode « mes lignes », les boutons œil des modes n'ont plus d'effet : on l'indique */
.fav-on .group-head .vis:is([data-vis="tram"], [data-vis="bus"], [data-vis="boat"], [data-vis="train"]) { opacity: 0.35; pointer-events: none; }

/* bouton étoile des fiches */
.fav-btn svg { width: 16px; height: 16px; }
.fav-btn[aria-pressed="true"] svg { fill: currentColor; }
.near-btn svg { width: 17px; height: 17px; }

/* ---------- pages indexables (texte généré par tools/build_pages.py) ---------- */
.seo { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 13px; line-height: 1.55; color: var(--muted); }
.seo h1 { margin: 6px 0 8px; font-size: 18px; line-height: 1.25; font-weight: 800; color: var(--text); text-wrap: balance; }
.seo h2 { margin: 16px 0 6px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.seo h3 { margin: 12px 0 4px; font-size: 13px; font-weight: 700; color: var(--text); }
.seo p { margin: 0 0 8px; }
.seo b { color: var(--text); font-weight: 700; }
.seo a { color: var(--text); text-underline-offset: 2px; text-decoration-color: var(--faint); }
.seo a:hover { text-decoration-color: currentColor; }
.seo-crumbs { font-size: 12px; color: var(--faint); }
.seo-crumbs a { color: var(--muted); }
.seo-stops { margin: 0; padding: 0 0 0 22px; }
.seo-stops li { padding: 2px 0; }
.seo-stops small, .seo-near small { color: var(--faint); font-size: 11.5px; }
.seo-lines, .seo-near, .seo-list { list-style: none; margin: 0; padding: 0; }
.seo-lines li { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.seo-near li, .seo-list li { padding: 3px 0; }
.seo-list li::before { content: "·"; margin-right: 6px; color: var(--faint); }
.seo-badges { margin: 4px 0 8px; gap: 5px; }
.seo-links { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 12px; }
.seo a.badge, .seo-home a.badge, .seo .badge { text-decoration: none; color: var(--t, #fff); cursor: pointer; }
.seo .alerts .a-title, .seo .alerts .a-msg { margin: 0; white-space: pre-line; }
.seo-home .seo-links a { color: var(--muted); }
.seo-home .seo-badges { margin-top: 6px; }

/* localisation en cours */
#locateBtn[aria-busy="true"] svg { animation: spin 1.2s linear infinite; }
.toast { max-width: min(92vw, 420px); line-height: 1.45; }

/* ---------- état des lignes en direct (retards, info trafic) ---------- */
.state { flex: none; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; line-height: 1.5;
  color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); }
.state.s1 { color: var(--warn); background: color-mix(in srgb, var(--warn) 16%, transparent); }
.state.s2 { color: var(--bad); background: color-mix(in srgb, var(--bad) 16%, transparent); }
.state-line { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-top: 12px; padding: 9px 12px; border-radius: 10px;
  background: color-mix(in srgb, var(--ok) 10%, var(--raise)); font-size: 12.5px; color: var(--muted); }
.state-line b { color: var(--ok); font-size: 13.5px; }
.state-line.s1 { background: color-mix(in srgb, var(--warn) 12%, var(--raise)); }
.state-line.s1 b { color: var(--warn); }
.state-line.s2 { background: color-mix(in srgb, var(--bad) 12%, var(--raise)); }
.state-line.s2 b { color: var(--bad); }
.fav-states { margin-bottom: 10px; }
.fav-states .line-row { align-items: center; }
.fav-states .lr-main small { white-space: normal; }
/* pastille en bas à droite des badges du menu (la coche « Mes lignes » est en haut) : orange si ralenti, rouge si perturbé */
#panel-lines .badge[data-route] { position: relative; }
#panel-lines .badge[data-state]::before { content: ""; position: absolute; bottom: -3px; right: -3px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--warn); box-shadow: 0 0 0 2px var(--panel-solid); }
#panel-lines .badge[data-state="s2"]::before { background: var(--bad); }
.deps .dest small .delay { font-size: 11px; }

/* ---------- parkings ---------- */
.park-kind { margin-bottom: 8px; }
.pk { display: inline-block; font-size: 10.5px; font-weight: 800; color: #fff; background: #2f6fde; border-radius: 4px; padding: 0 4px; line-height: 1.5; }
.pk.pr { background: #b3204f; }
.badge.pk-badge { --c: #2f6fde; --t: #fff; font-size: 13px; }
.badge.pk-badge.pr { --c: #b3204f; font-size: 11px; }
.park-info { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 12px 0 0; font-size: 12.5px; }
.park-info dt { color: var(--muted); }
.park-info dd { margin: 0; }
