/* Yaduretard — langage visuel aligné sur Ventur : fond marine, cartes arrondies à fine bordure,
   bleu d'action, boutons hauts (≥ 52 px), état clair / sombre selon le système. */
:root {
  color-scheme: dark;
  --bg: #0a101c; --card: #111a2c; --card-2: #16213a; --line: #1f2c45; --line-2: #2a3a5a;
  --text: #e8edf7; --muted: #93a0b8;
  --primary: #2f6df6; --primary-hover: #4a80ff; --on-primary: #fff; --primary-soft: rgba(47, 109, 246, .18);
  --ok: #3ddba3; --ok-soft: rgba(61, 219, 163, .14);
  --warn: #f2b84b; --warn-soft: rgba(242, 184, 75, .15);
  --bad: #ff8a95; --bad-soft: rgba(255, 122, 134, .15);
  --neutral-soft: rgba(147, 160, 184, .16);
  --shadow: 0 10px 28px rgba(0, 0, 0, .35);
  --radius: 20px; --radius-sm: 14px; --tap: 52px;
  --font: Inter, "Roboto", system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] { color-scheme: light; --bg: #eef2f9; --card: #ffffff; --card-2: #f4f7fc; --line: #dde4f0; --line-2: #c9d3e5; --text: #0f1a30; --muted: #5b6882; --primary: #1a5cff; --primary-hover: #0f4de0; --primary-soft: rgba(26, 92, 255, .10); --ok: #0a7d55; --ok-soft: rgba(10, 125, 85, .11); --warn: #8f5f00; --warn-soft: rgba(201, 138, 0, .14); --bad: #c42b3c; --bad-soft: rgba(196, 43, 60, .10); --neutral-soft: rgba(91, 104, 130, .12); --shadow: 0 8px 24px rgba(30, 50, 100, .10); }
}
:root[data-theme="light"] { color-scheme: light; --bg: #eef2f9; --card: #ffffff; --card-2: #f4f7fc; --line: #dde4f0; --line-2: #c9d3e5; --text: #0f1a30; --muted: #5b6882; --primary: #1a5cff; --primary-hover: #0f4de0; --primary-soft: rgba(26, 92, 255, .10); --ok: #0a7d55; --ok-soft: rgba(10, 125, 85, .11); --warn: #8f5f00; --warn-soft: rgba(201, 138, 0, .14); --bad: #c42b3c; --bad-soft: rgba(196, 43, 60, .10); --neutral-soft: rgba(91, 104, 130, .12); --shadow: 0 8px 24px rgba(30, 50, 100, .10); }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 16px/1.45 var(--font); min-height: 100dvh; -webkit-tap-highlight-color: transparent; }
h1, h2, h3, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.noscript { padding: 24px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 8px; top: -60px; background: var(--primary); color: var(--on-primary); padding: 10px 14px; border-radius: 10px; z-index: 100; }
.skip:focus { top: 8px; }
.muted { color: var(--muted); }
.ic { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 10px; }
main:focus { outline: none; }

/* ---------- En-tête ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: calc(12px + var(--sat)) 16px 8px; max-width: 1080px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo { width: 44px; height: 44px; border-radius: 13px; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; box-shadow: 0 6px 16px rgba(47, 109, 246, .35); }
.brand h1 { font-size: 20px; line-height: 1.1; font-weight: 750; letter-spacing: -.01em; }
.brand p { font-size: 13px; color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); font-size: 13px; font-weight: 600; max-width: 62vw; }
.pill #status-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.pill[data-state="ok"] .dot { background: var(--ok); }
.pill[data-state="warn"] .dot { background: var(--warn); border-radius: 2px; transform: rotate(45deg); }
.pill[data-state="bad"] .dot { background: var(--bad); border-radius: 2px; }
.pill[data-state="load"] .dot { background: var(--primary); animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .3; } }

/* ---------- Navigation (barre basse sur mobile) ---------- */
.tabbar { position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5, 1fr); padding: 6px 8px calc(6px + var(--sab)); background: color-mix(in srgb, var(--card) 94%, transparent); backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
.tabbar button { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 56px; border: 0; background: none; color: var(--muted); font-size: 11.5px; font-weight: 600; border-radius: 14px; }
.tabbar button[aria-current="page"] { color: var(--primary); background: var(--primary-soft); }
.badge { position: absolute; top: 4px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: #0a101c; font-size: 11px; line-height: 18px; text-align: center; font-weight: 800; }

/* ---------- Mini-radar persistant ---------- */
.dock { position: sticky; top: 0; z-index: 30; padding: calc(6px + var(--sat)) 16px 6px; max-width: 1080px; margin: 0 auto; background: linear-gradient(var(--bg) 78%, transparent); }
.radar { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 8px 14px 6px; box-shadow: var(--shadow); }
.radar-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 13px; }
.radar-route { font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.radar-train { color: var(--muted); white-space: nowrap; font-weight: 600; }
.track { position: relative; height: 52px; margin: 4px 12px 0; }
.line, .line-done { position: absolute; left: 0; right: 0; top: 20px; height: 4px; border-radius: 2px; }
.line { background: var(--line-2); }
.line-done { background: var(--primary); transform-origin: left center; transform: scaleX(0); transition: transform 1s linear; }
.track.cancelled .line { background: repeating-linear-gradient(90deg, var(--bad) 0 6px, transparent 6px 12px); }
.stn { position: absolute; top: 16px; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; background: var(--card); border: 3px solid var(--line-2); }
.stn.main { border-color: var(--primary); }
.stn.up { opacity: .55; }
.stn-label { position: absolute; top: 31px; font-size: 11px; line-height: 1.2; max-width: 96px; transform: translateX(-50%); text-align: center; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stn-label.main { color: var(--text); font-weight: 650; }
.stn-label.first { transform: translateX(-12px); text-align: left; }
.stn-label.last { transform: translateX(calc(-100% + 12px)); text-align: right; }
.train { position: absolute; top: 4px; left: 0; width: 30px; height: 28px; margin-left: -15px; border-radius: 10px; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; box-shadow: 0 4px 12px rgba(47, 109, 246, .5); will-change: transform; transition: transform 1s linear; z-index: 2; }
.train .ic { width: 18px; height: 18px; }
.train.late { background: var(--warn); color: #1b1300; }
.train.important { background: var(--bad); color: #1b0509; }
.tbadge { position: absolute; top: -12px; left: 50%; transform: translateX(-50%); padding: 0 6px; border-radius: 8px; background: var(--card); color: var(--text); border: 1px solid var(--line-2); font-size: 11px; font-weight: 800; line-height: 16px; white-space: nowrap; }
.radar-foot { font-size: 12.5px; color: var(--muted); min-height: 18px; margin-top: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.radar-foot strong { color: var(--text); }

/* ---------- Structure ---------- */
main { max-width: 1080px; margin: 0 auto; padding: 8px 16px calc(96px + var(--sab)); }
.cols { display: grid; gap: 16px; }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 2px 10px; }
.sec-head h2, .sec-head h3 { font-size: 18px; font-weight: 750; letter-spacing: -.01em; }
.sec-head .muted { font-size: 13px; }
.hint { color: var(--muted); font-size: 13.5px; margin: 0 2px 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.block { margin-bottom: 16px; }
.block h3 { font-size: 17px; font-weight: 750; margin-bottom: 10px; }
.block .sec-head h3 { margin-bottom: 0; }

/* ---------- Sélecteur de trajet ---------- */
.picker { position: relative; display: grid; gap: 10px; }
.field label { display: block; font-size: 13px; font-weight: 650; color: var(--muted); margin: 0 2px 6px; }
.combo { position: relative; }
.combo input { width: 100%; height: var(--tap); padding: 0 14px 0 44px; border-radius: var(--radius-sm); border: 1px solid var(--line-2); background: var(--card-2); font-size: 17px; font-weight: 600; }
.combo input::placeholder { color: var(--muted); font-weight: 400; }
.combo input:focus { border-color: var(--primary); outline: 3px solid var(--primary-soft); outline-offset: 0; }
.combo .lead { position: absolute; left: 13px; top: 15px; color: var(--primary); pointer-events: none; }
.options { position: absolute; z-index: 50; left: 0; right: 0; top: calc(100% + 6px); margin: 0; padding: 6px; list-style: none; background: var(--card); border: 1px solid var(--line-2); border-radius: var(--radius-sm); box-shadow: var(--shadow); max-height: 46vh; overflow: auto; }
.options li { display: flex; align-items: center; min-height: 48px; padding: 0 12px; border-radius: 10px; font-weight: 600; cursor: pointer; }
.options li[aria-selected="true"], .options li:hover { background: var(--primary-soft); }
.options li.empty { color: var(--muted); cursor: default; font-weight: 400; }
.swap { position: absolute; right: 18px; top: 86px; z-index: 5; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line-2); background: var(--card); color: var(--primary); display: grid; place-items: center; box-shadow: var(--shadow); }
.swap .ic { transform: rotate(90deg); }
.picker-actions { display: flex; gap: 10px; margin-top: 4px; }
.form-error { color: var(--bad); font-size: 14px; font-weight: 600; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: var(--tap); padding: 0 20px; border-radius: var(--radius-sm); border: 1px solid var(--line-2); background: var(--card-2); font-weight: 700; font-size: 16px; }
.btn:hover { border-color: var(--primary); }
.btn.primary { flex: 1; background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.icon { width: var(--tap); padding: 0; flex: none; }
#fav-toggle[aria-pressed="true"] { color: var(--warn); border-color: var(--warn); background: var(--warn-soft); }
#fav-toggle[aria-pressed="true"] .ic { fill: currentColor; }
.favs { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.favs:empty { display: none; }
.chip-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--card); font-size: 14px; font-weight: 650; max-width: 100%; }
.chip-btn .ic { width: 16px; height: 16px; color: var(--warn); fill: currentColor; }
.chip-btn[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-soft); }
.chip-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Statuts (icône + texte, jamais la couleur seule) ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; max-width: 100%; padding: 3px 10px; border-radius: 999px; font-size: 13px; line-height: 1.2; font-weight: 700; background: var(--neutral-soft); color: var(--text); }
.chip .ic { width: 15px; height: 15px; stroke-width: 2.6; }
.chip.ontime { background: var(--ok-soft); color: var(--ok); }
.chip.delayed { background: var(--warn-soft); color: var(--warn); }
.chip.important, .chip.cancelled { background: var(--bad-soft); color: var(--bad); }
.chip.cancelled { text-decoration: none; box-shadow: inset 0 0 0 1.5px currentColor; }
.chip.arrived { background: var(--neutral-soft); color: var(--muted); }
.chip.unknown { background: var(--neutral-soft); color: var(--muted); }
.chip.running { background: var(--primary-soft); color: var(--primary); }
.chip.est { background: transparent; color: var(--muted); box-shadow: inset 0 0 0 1px var(--line-2); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }

/* ---------- Carte « prochain train » ---------- */
.hero { margin-top: 12px; display: grid; gap: 10px; }
.hero-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.hero-label { font-size: 13px; color: var(--muted); font-weight: 650; }
.hero-time { font-size: 52px; line-height: 1; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.hero-time.cancelled { text-decoration: line-through; text-decoration-thickness: 4px; color: var(--muted); }
.sched { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; margin-top: 4px; }
.sched s { opacity: .9; }
.hero-eta { font-size: 18px; font-weight: 750; text-align: right; }
.hero-eta small { display: block; font-size: 13px; font-weight: 600; color: var(--muted); }
.hero-meta { color: var(--muted); font-size: 14.5px; }
.hero-meta strong { color: var(--text); }
.empty-card { text-align: center; padding: 28px 16px; color: var(--muted); }
.empty-card .ic { width: 34px; height: 34px; margin-bottom: 8px; }
.empty-card strong { display: block; color: var(--text); font-size: 17px; margin-bottom: 4px; }

/* ---------- Listes de trains ---------- */
.list { display: grid; gap: 10px; }
.trow { display: grid; grid-template-columns: minmax(0, auto) minmax(0, 1fr); gap: 6px 14px; align-items: center; width: 100%; text-align: left; padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--card); min-height: 72px; }
.trow:hover { border-color: var(--line-2); }
.trow[aria-pressed="true"] { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.trow .t { max-width: 118px; min-width: 0; font-size: 26px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.05; }
.trow .t.cancelled { text-decoration: line-through; color: var(--muted); }
.trow .t small { display: block; font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: 0; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trow .main { min-width: 0; display: grid; gap: 6px; }
.trow .dest { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trow .dest span { color: var(--muted); font-weight: 500; }
.skeleton { height: 72px; border-radius: var(--radius); background: linear-gradient(90deg, var(--card) 25%, var(--card-2) 50%, var(--card) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border: 1px solid var(--line); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Segmented / formulaires ---------- */
.seg { display: inline-flex; padding: 4px; gap: 4px; border-radius: var(--radius-sm); background: var(--card-2); border: 1px solid var(--line); margin-bottom: 10px; max-width: 100%; }
.seg button { min-height: 44px; padding: 0 16px; border: 0; border-radius: 10px; background: none; color: var(--muted); font-weight: 700; }
.seg button[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); }
.seg.small { margin: 0; } .seg.small button { min-height: 36px; padding: 0 12px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.switch { position: relative; flex: none; width: 60px; height: 36px; border-radius: 18px; border: 1px solid var(--line-2); background: var(--card-2); padding: 0; }
.switch span { position: absolute; top: 3px; left: 3px; width: 28px; height: 28px; border-radius: 50%; background: var(--muted); transition: transform .2s, background .2s; }
.switch[aria-checked="true"] { background: var(--primary-soft); border-color: var(--primary); }
.switch[aria-checked="true"] span { transform: translateX(24px); background: var(--primary); }
.check { display: flex; align-items: center; gap: 12px; min-height: 48px; font-weight: 600; }
.check input { width: 22px; height: 22px; accent-color: var(--primary); }
.select-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; font-weight: 600; }
.select-row select { height: 44px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--card-2); padding: 0 10px; }
#notif-options { display: grid; gap: 4px; margin-bottom: 8px; }

/* ---------- Alertes / historique ---------- */
.alert-card { border-left: 4px solid var(--warn); }
.alert-card h4 { margin: 0 0 4px; font-size: 16px; }
.alert-card p { color: var(--muted); font-size: 14px; }
.grid4 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
.stat { background: var(--card-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; }
.stat b { display: block; font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat span { font-size: 13px; color: var(--muted); }
.hrow { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 14.5px; }
.hrow b { font-variant-numeric: tabular-nums; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0 0 12px; font-size: 14.5px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; text-align: right; font-weight: 650; overflow-wrap: anywhere; }

/* ---------- Fiche train (dialog) ---------- */
dialog { padding: 0; border: 1px solid var(--line-2); background: var(--card); color: var(--text); border-radius: 24px 24px 0 0; width: min(100%, 640px); max-width: 100%; max-height: 88dvh; margin: auto auto 0; overflow: auto; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(3, 8, 18, .6); backdrop-filter: blur(3px); }
.sheet-grab { width: 44px; height: 5px; border-radius: 3px; background: var(--line-2); margin: 10px auto 0; }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 12px 18px 8px; position: sticky; top: 0; background: var(--card); z-index: 2; }
.sheet-head h2 { font-size: 20px; font-weight: 800; }
#sheet-body { padding: 4px 18px calc(24px + var(--sab)); display: grid; gap: 16px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 0 0 14px 28px; min-height: 48px; }
.timeline li::before { content: ""; position: absolute; left: 7px; top: 6px; bottom: -6px; width: 3px; background: var(--line-2); }
.timeline li:last-child::before { display: none; }
.timeline li::after { content: ""; position: absolute; left: 0; top: 4px; width: 17px; height: 17px; border-radius: 50%; background: var(--card); border: 3px solid var(--line-2); }
.timeline li.passed::before { background: var(--primary); }
.timeline li.passed::after { border-color: var(--primary); background: var(--primary); }
.timeline li.here::after { border-color: var(--primary); background: var(--card); box-shadow: 0 0 0 4px var(--primary-soft); }
.timeline li.skipped .nm { text-decoration: line-through; color: var(--muted); }
.timeline .nm { font-weight: 650; }
.timeline li.focus .nm { color: var(--primary); }
.timeline .tm { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.timeline .tm s { color: var(--muted); font-weight: 500; margin-right: 6px; }
.timeline .sub { grid-column: 1 / -1; font-size: 12.5px; color: var(--muted); }

.toast { position: fixed; left: 50%; bottom: calc(86px + var(--sab)); transform: translateX(-50%); z-index: 90; max-width: min(92vw, 460px); padding: 12px 18px; border-radius: 14px; background: var(--text); color: var(--bg); font-weight: 650; box-shadow: var(--shadow); }

/* ---------- Tablette / bureau ---------- */
@media (min-width: 720px) {
  .grid4 { grid-template-columns: repeat(4, 1fr); }
  dialog { border-radius: 24px; margin: auto; }
  .sheet-grab { display: none; }
}
@media (min-width: 900px) {
  .topbar { padding-top: calc(18px + var(--sat)); }
  .tabbar { position: static; order: 2; display: flex; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 16px; background: var(--card); backdrop-filter: none; }
  .tabbar button { flex-direction: row; gap: 8px; min-height: 44px; padding: 0 14px; font-size: 14px; }
  .badge { position: static; margin-left: 2px; }
  .pill { order: 3; max-width: 260px; }
  .cols { grid-template-columns: minmax(340px, 400px) 1fr; align-items: start; }
  main { padding-bottom: 48px; }
  .toast { bottom: 24px; }
  .hero-time { font-size: 60px; }
}
@media (max-width: 380px) {
  .hero-time { font-size: 46px; }
  .brand p { display: none; }
}

/* ---------- Mouvement réduit ---------- */
@media (prefers-reduced-motion: reduce) {
  .train, .line-done, .switch span { transition: none !important; }
  .skeleton, .pill[data-state="load"] .dot { animation: none; }
}
