:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f1f4;
  --line: #e6e8ec;
  --text: #0e1116;
  --muted: #6b7280;
  --faint: #9aa1ac;
  --accent: #e3051b;
  --accent-soft: #fde8ea;
  --live: #10a35a;
  --late: #d97706;
  --bad: #dc2626;
  --star: #f5b301;
  --radius: 18px;
  --shadow: 0 1px 2px rgb(16 24 40 / 0.04), 0 6px 24px rgb(16 24 40 / 0.06);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0f12;
    --surface: #16191e;
    --surface-2: #1f232a;
    --line: #262b33;
    --text: #f2f4f7;
    --muted: #9aa3af;
    --faint: #6b7380;
    --accent: #ff4d5e;
    --accent-soft: #3a1418;
    --live: #34d27f;
    --late: #f5a524;
    --bad: #f87171;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
button, input { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.shell { max-width: 560px; margin: 0 auto; padding: 0 16px calc(96px + env(safe-area-inset-bottom)); }
.view { padding-top: calc(20px + env(safe-area-inset-top)); }

/* ---------- en-têtes ---------- */
.hello { display: flex; align-items: center; justify-content: space-between; margin: 8px 2px 18px; }
.hello h1 { font-size: 28px; line-height: 1.15; font-weight: 800; letter-spacing: -0.02em; margin: 0; }
.hello p { margin: 4px 0 0; color: var(--muted); }
.logo {
  width: 44px; height: 44px; border-radius: 14px; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 13px; letter-spacing: 0.04em;
}

.page-head { display: flex; align-items: center; gap: 12px; margin: 4px 0 18px; min-height: 44px; }
.page-head h1 { font-size: 22px; font-weight: 800; letter-spacing: -0.015em; margin: 0; flex: 1; min-width: 0; }
.page-head .sub { color: var(--muted); font-size: 14px; margin-top: 2px; }

.icon-btn {
  width: 44px; height: 44px; border-radius: 14px; border: 0; display: grid; place-items: center;
  background: var(--surface); box-shadow: var(--shadow); cursor: pointer; flex: none;
}
.icon-btn.plain { background: transparent; box-shadow: none; width: 36px; height: 36px; border-radius: 10px; }
.icon-btn:active { transform: scale(0.96); }
.star-on svg { fill: var(--star); stroke: var(--star); }

/* ---------- recherche ---------- */
.search {
  display: flex; align-items: center; gap: 10px; padding: 0 16px; height: 54px;
  background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); color: var(--muted);
}
.search input { flex: 1; border: 0; outline: 0; background: transparent; height: 100%; color: var(--text); font-size: 16px; min-width: 0; }
.search input::placeholder { color: var(--faint); }
.search:focus-within { outline: 2px solid var(--text); outline-offset: 0; }

.results { margin-top: 10px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.result {
  display: flex; align-items: center; gap: 12px; padding: 13px 16px; width: 100%; text-align: left;
  border: 0; background: none; cursor: pointer; border-top: 1px solid var(--line);
}
.result:first-child { border-top: 0; }
.result:hover, .result:focus-visible { background: var(--surface-2); outline: none; }
.result .r-icon { width: 34px; height: 34px; border-radius: 10px; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); }
.result .r-icon svg { width: 18px; height: 18px; }
.result .r-main { flex: 1; min-width: 0; }
.result .r-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result .r-sub { color: var(--muted); font-size: 13px; display: flex; gap: 4px; flex-wrap: wrap; margin-top: 3px; }

/* ---------- sections & cartes ---------- */
.section { margin-top: 26px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 0 4px 10px; }
.section-head h2 { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0; }
.link-btn { border: 0; background: none; color: var(--accent); font-weight: 600; font-size: 14px; cursor: pointer; padding: 4px; }

.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.stack { display: grid; gap: 10px; }

.empty {
  text-align: center; padding: 28px 20px; color: var(--muted); background: var(--surface);
  border-radius: var(--radius); border: 1.5px dashed var(--line);
}
.empty strong { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; }
.empty .icon { width: 44px; height: 44px; border-radius: 14px; background: var(--surface-2); display: grid; place-items: center; margin: 0 auto 12px; }
.notice { padding: 14px 16px; border-radius: 14px; background: var(--surface-2); color: var(--muted); font-size: 14px; }
.notice.error { background: var(--accent-soft); color: var(--accent); }

/* ---------- badges de ligne ---------- */
.badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 30px; height: 26px; padding: 0 7px;
  border-radius: 8px; font-weight: 800; font-size: 13px; letter-spacing: -0.01em; flex: none; line-height: 1;
}
.badge.metro { border-radius: 50%; width: 28px; min-width: 28px; height: 28px; padding: 0; }
.badge.sm { min-width: 24px; height: 20px; font-size: 11px; border-radius: 6px; padding: 0 5px; }
.badge.sm.metro { width: 21px; min-width: 21px; height: 21px; }
.badge.lg { min-width: 44px; height: 38px; font-size: 18px; border-radius: 11px; }
.badge.lg.metro { width: 42px; min-width: 42px; height: 42px; }

/* ---------- favoris ---------- */
.fav { padding: 16px; display: grid; gap: 12px; cursor: pointer; }
.fav:active { transform: scale(0.995); }
.fav-top { display: flex; align-items: center; gap: 12px; }
.fav-title { flex: 1; min-width: 0; }
.fav-title .t1 { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fav-title .t2 { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fav-times { display: flex; align-items: baseline; gap: 14px; }
.next { font-size: 30px; font-weight: 800; letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.next small { font-size: 15px; font-weight: 700; letter-spacing: 0; margin-left: 2px; }
.later { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--live); margin-right: 6px; vertical-align: middle; position: relative; top: -2px; }
.live-dot::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; background: var(--live); opacity: 0.35; animation: pulse 1.8s ease-out infinite; }
@keyframes pulse { from { transform: scale(0.4); opacity: 0.5; } to { transform: scale(1.4); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .live-dot::after { animation: none; } }
.late { color: var(--late); font-weight: 600; }
.cancelled { color: var(--bad); text-decoration: line-through; }
.fav-remove { margin-left: auto; }

.trip-fav .route-chips { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; color: var(--muted); }
.sched-line { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; margin-bottom: -4px; }
.sched-line svg, .sched-edit .chip svg { width: 16px; height: 16px; }
.sched-line strong { color: var(--text); }
.sched-day { margin-left: auto; font-size: 13px; color: var(--faint); }
.week { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 4px; }
.week-day {
  display: grid; gap: 2px; justify-items: center; padding: 7px 0; border: 0; border-radius: 10px;
  background: var(--surface-2); color: var(--text); cursor: pointer; min-width: 0;
}
.week-day .wd { font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.week-day .wt { font-size: 13px; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.week-day.is-next { background: var(--accent-soft); }
.week-day.is-next .wt { color: var(--accent); }
.sched-edit { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; cursor: default; }.days { display: flex; gap: 4px; }
.day {
  width: 32px; height: 32px; border-radius: 50%; border: 1.5px solid var(--line); background: var(--surface);
  font-weight: 700; font-size: 13px; color: var(--muted); cursor: pointer; padding: 0;
}
.day[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- départs d'un arrêt ---------- */
.departure {
  display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 12px;
  padding: 14px 10px 14px 16px; border-top: 1px solid var(--line);
}
.departure:first-child { border-top: 0; }
.departure .dir { min-width: 0; }
.departure .dir .d1 { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.departure .dir .d2 { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.departure .when { text-align: right; font-weight: 800; font-size: 20px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.departure .when small { font-size: 12px; font-weight: 700; }
.departure .when .theo { display: block; font-size: 11px; color: var(--faint); font-weight: 500; letter-spacing: 0; }
.station-lines { display: flex; gap: 6px; flex-wrap: wrap; margin: -6px 0 16px; }
.updated { text-align: center; color: var(--faint); font-size: 12px; margin-top: 14px; }

/* ---------- lignes ---------- */
.line-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 8px; }
.line-grid .badge { width: 100%; height: 44px; font-size: 15px; border-radius: 12px; cursor: pointer; }
.line-grid .badge.metro { width: 44px; height: 44px; margin: 0 auto; border-radius: 50%; }

.segmented { display: flex; background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 4px; margin-bottom: 14px; }
.segmented button {
  flex: 1; border: 0; background: transparent; border-radius: 9px; padding: 9px 8px; cursor: pointer;
  font-weight: 600; font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.stops { list-style: none; margin: 0; padding: 8px 0; }
.stops li button {
  display: flex; align-items: center; gap: 14px; width: 100%; border: 0; background: none; text-align: left;
  padding: 0 16px; height: 46px; cursor: pointer; position: relative;
}
.stops li button:hover { background: var(--surface-2); }
.stops .dot { width: 14px; height: 14px; border-radius: 50%; border: 3px solid var(--c); background: var(--surface); position: relative; z-index: 1; flex: none; }
.stops li button::before { content: ""; position: absolute; left: 22px; top: 0; bottom: 0; width: 4px; background: var(--c); }
.stops li:first-child button::before { top: 50%; }
.stops li:last-child button::before { bottom: 50%; }
.stops li:first-child .dot, .stops li:last-child .dot { background: var(--c); }

/* ---------- itinéraire ---------- */
.planner { padding: 8px; display: grid; grid-template-columns: 1fr auto; gap: 0 6px; align-items: center; }
.planner .fields { display: grid; }
.field { display: flex; align-items: center; gap: 12px; padding: 0 10px; height: 52px; }
.field + .field { border-top: 1px solid var(--line); }
.field .pin { width: 12px; height: 12px; border-radius: 50%; border: 3px solid var(--text); flex: none; }
.field .pin.to { border-radius: 3px; background: var(--accent); border-color: var(--accent); }
.field input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 16px; height: 100%; }
.field input::placeholder { color: var(--faint); }
.when-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; align-items: center; }
.chip {
  border: 0; background: var(--surface); box-shadow: var(--shadow); border-radius: 999px; padding: 9px 14px;
  font-weight: 600; font-size: 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); }
.chip input { border: 0; background: transparent; outline: 0; font-weight: 600; font-size: 14px; color: inherit; padding: 0; width: 5.5em; }
.chip input::-webkit-calendar-picker-indicator { filter: invert(0.5); }

.journey { padding: 16px; cursor: pointer; display: grid; gap: 10px; }
.journey-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.journey-times { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.pill { display: inline-block; vertical-align: middle; margin-left: 6px; padding: 3px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 700; letter-spacing: 0; }
.journey-dur { font-weight: 700; color: var(--text); white-space: nowrap; }
.journey-dur small { color: var(--muted); font-weight: 500; }
.legs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.legs .walk { display: inline-flex; align-items: center; gap: 2px; }
.legs .walk svg { width: 16px; height: 16px; }
.legs .sep { color: var(--faint); }
.journey-foot { color: var(--muted); font-size: 13px; }
.journey-foot strong { color: var(--text); }

.timeline { list-style: none; margin: 0; padding: 18px 16px 8px; }
.timeline li { display: grid; grid-template-columns: 52px 22px 1fr; gap: 0 10px; position: relative; }
.timeline .time { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; padding-top: 1px; }
.timeline .time small { display: block; color: var(--faint); font-weight: 500; font-size: 11px; }
.timeline .rail { position: relative; display: flex; justify-content: center; }
.timeline .rail::before { content: ""; position: absolute; top: 0; bottom: 0; width: 4px; border-radius: 2px; background: var(--c, var(--line)); }
.timeline .rail.walking::before { background: none; border-left: 3px dotted var(--faint); width: 0; }
.timeline .rail .node { position: relative; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 3px solid var(--c, var(--faint)); margin-top: 3px; }
.timeline .body { padding-bottom: 18px; min-width: 0; }
.timeline .body .place { font-weight: 700; }
.timeline .body .info { color: var(--muted); font-size: 14px; margin-top: 4px; display: flex; align-items: center; gap: 8px; }
.timeline .body .info svg { width: 18px; height: 18px; }
.timeline .body .info strong { color: var(--text); }
.timeline details { margin-top: 6px; color: var(--muted); font-size: 13px; }
.timeline details summary { cursor: pointer; }
.timeline details ol { margin: 6px 0 0; padding-left: 18px; }

.primary {
  border: 0; background: var(--text); color: var(--bg); border-radius: 14px; height: 50px; padding: 0 18px;
  font-weight: 700; cursor: pointer; width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.primary svg { width: 18px; height: 18px; }
.ghost {
  border: 0; background: var(--surface); box-shadow: var(--shadow); border-radius: 14px; height: 50px; padding: 0 18px;
  font-weight: 700; cursor: pointer; width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.ghost svg { width: 18px; height: 18px; }
.row-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }

.skeleton { height: 92px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- barre d'onglets ---------- */
.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(12px + env(safe-area-inset-bottom));
  display: flex; gap: 4px; padding: 6px; border-radius: 22px; width: min(528px, calc(100% - 24px));
  background: color-mix(in srgb, var(--surface) 86%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 8px 32px rgb(16 24 40 / 0.12), 0 0 0 1px var(--line); z-index: 10;
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px 6px;
  border-radius: 16px; color: var(--muted); font-size: 11px; font-weight: 600;
}
.tabbar a[aria-current="page"] { color: var(--text); background: var(--surface-2); }

.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 14px;
  z-index: 20; box-shadow: 0 8px 24px rgb(0 0 0 / 0.2); white-space: nowrap;
}

@media (min-width: 720px) {
  .view { padding-top: 40px; }
  .hello h1 { font-size: 32px; }
}
