/* Interface pensée pour un téléphone tenu d'une main : cibles larges, actions
   importantes en bas d'écran, hiérarchie visuelle qui met l'heure en avant. */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --text: #12161d;
  --text-dim: #5d6675;
  --line: #dfe3ea;
  --accent: #0f62d6;
  --accent-soft: #e7efff;
  --ok: #12805c;
  --warn: #b45309;
  --radius: 16px;
  --tap: 46px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --surface: #141b28;
    --surface-2: #1c2534;
    --text: #eef2f8;
    --text-dim: #97a2b4;
    --line: #263042;
    --accent: #5b9dff;
    --accent-soft: #17263f;
    --ok: #34d39f;
    --warn: #fbbf24;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}

body {
  padding-bottom: calc(64px + var(--safe-b));
  max-width: 640px;
  margin: 0 auto;
}

.view { padding: 12px 14px 8px; }
.view[hidden] { display: none; }

.app-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 2px 12px;
}
.app-header h1 {
  font-size: 22px;
  line-height: 1.2;
  margin: 0;
  flex: 1;
  letter-spacing: -0.02em;
}
.stop-title { flex: 1; min-width: 0; }
.stop-title h1 { font-size: 20px; }
.stop-lines { margin: 3px 0 0; font-size: 13px; color: var(--text-dim); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 12px;
  position: relative;
}

/* --- champs départ / destination --- */
.fields { padding: 4px 0; }
.field {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  min-height: var(--tap);
}
.field-label {
  width: 46px;
  flex: none;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}
.field input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 17px;
  font-weight: 600;
  padding: 6px 0;
  outline: none;
}
.field input::placeholder { color: var(--text-dim); font-weight: 400; }
.field-clear {
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font-size: 22px;
  line-height: 1;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  visibility: hidden;
}
.field input:not(:placeholder-shown) ~ .field-clear { visibility: visible; }
.field-sep { padding-left: 60px; }
.field-sep span { display: block; height: 1px; background: var(--line); }

/* --- suggestions --- */
.suggest {
  list-style: none;
  margin: 0;
  padding: 6px 0;
  border-top: 1px solid var(--line);
  max-height: 46vh;
  overflow-y: auto;
}
.suggest li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 14px;
  cursor: pointer;
  min-height: var(--tap);
}
.suggest li:active, .suggest li.on { background: var(--surface-2); }
.suggest .s-name { flex: 1; font-weight: 600; min-width: 0; }
.suggest .s-star { color: var(--warn); }

/* --- date et heure --- */
.when { padding: 10px 12px 12px; }
.when.compact { padding: 8px 10px 10px; }
.day-row, .time-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.time-row { margin-top: 8px; }
.day-label {
  flex: 1;
  height: var(--tap);
  border: 0;
  background: var(--surface-2);
  color: var(--text);
  border-radius: 12px;
  font-size: 16px;
  font-weight: 650;
  cursor: pointer;
}
.time-label {
  height: var(--tap);
  min-width: 92px;
  border: 0;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 12px;
  font-size: 19px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  padding: 0 14px;
}
.select {
  flex: 1;
  height: var(--tap);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 12px;
  padding: 0 10px;
  font-size: 15px;
  min-width: 0;
}
.icon-btn {
  width: var(--tap);
  height: var(--tap);
  flex: none;
  border: 0;
  background: var(--surface-2);
  color: var(--text);
  border-radius: 12px;
  font-size: 20px;
  cursor: pointer;
}
.icon-btn:active { background: var(--line); }

.segmented {
  display: flex;
  background: var(--surface-2);
  border-radius: 12px;
  padding: 3px;
  flex: 1;
  min-width: 0;
}
.seg {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  border-radius: 9px;
  height: 40px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.seg.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.16); }

.chips {
  display: flex;
  gap: 7px;
  margin-top: 9px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-dim);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* --- favoris et historique --- */
.quick { margin-bottom: 12px; }
.quick h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
  margin: 14px 4px 8px;
}
.quick-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 7px;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  min-height: var(--tap);
}
.quick-row .q-sub { font-weight: 400; color: var(--text-dim); font-size: 13px; }
.quick-row .q-del {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font-size: 18px;
  padding: 4px 6px;
  cursor: pointer;
}

/* --- résultats --- */
.results { display: flex; flex-direction: column; gap: 10px; }

.journey {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 14px;
  cursor: pointer;
}
.journey.best { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.j-top {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.j-times {
  font-size: 25px;
  font-weight: 750;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.j-arrow { color: var(--text-dim); font-weight: 400; margin: 0 2px; }
.j-dur { margin-left: auto; color: var(--text-dim); font-size: 14px; font-weight: 600; white-space: nowrap; }
.j-lines { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 9px; }
.j-note { margin-top: 7px; font-size: 13px; color: var(--text-dim); }
.j-detail { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 11px; }
.j-detail[hidden] { display: none; }

.leg { display: flex; gap: 11px; padding: 5px 0; }
.leg-time {
  width: 46px;
  flex: none;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 15px;
}
.leg-body { flex: 1; min-width: 0; }
.leg-stop { font-weight: 600; }
.leg-meta { font-size: 13px; color: var(--text-dim); margin-top: 2px; }
.leg-rail {
  width: 4px;
  flex: none;
  border-radius: 3px;
  background: var(--line);
  margin: 4px 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 25px;
  padding: 0 8px;
  border-radius: 7px;
  font-size: 13.5px;
  font-weight: 800;
  letter-spacing: 0.01em;
}
.badge.sm { min-width: 28px; height: 21px; font-size: 12px; }
.walk { color: var(--text-dim); font-size: 13px; }

.dep {
  display: flex;
  align-items: center;
  gap: 11px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 11px 13px;
  min-height: var(--tap);
}
.dep-time {
  font-size: 21px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  min-width: 62px;
}
.dep-body { flex: 1; min-width: 0; }
.dep-head { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dep-in { color: var(--text-dim); font-size: 13px; white-space: nowrap; }
.dep-day { color: var(--warn); font-size: 12px; font-weight: 700; }
.rt { color: var(--ok); font-weight: 700; font-size: 13px; }
.canceled { text-decoration: line-through; opacity: .55; }

.empty, .hint {
  color: var(--text-dim);
  font-size: 14.5px;
  text-align: center;
  padding: 22px 18px;
  line-height: 1.55;
}
.hint { padding: 4px 4px 12px; text-align: left; font-size: 13.5px; }
.error { color: var(--warn); }

.stop-actions { display: flex; gap: 9px; margin-top: 14px; }
.ghost-btn {
  flex: 1;
  height: var(--tap);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 12px;
  font-size: 15px;
  font-weight: 650;
  cursor: pointer;
}

/* --- lignes --- */
.line-row {
  display: flex;
  align-items: center;
  gap: 11px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 12px 13px;
  cursor: pointer;
  min-height: var(--tap);
}
.line-name { font-weight: 600; font-size: 14.5px; flex: 1; min-width: 0; }

/* --- barre d'onglets --- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
  z-index: 20;
}
.tab {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 650;
  padding: 8px 2px 9px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-height: 56px;
}
.tab.on { color: var(--accent); }
.tab-ico { font-size: 19px; line-height: 1; }

.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(78px + var(--safe-b));
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  z-index: 30;
  max-width: 90vw;
}
.toast[hidden] { display: none; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.spinner {
  width: 20px;
  height: 20px;
  margin: 26px auto;
  border: 2.5px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2s; }
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
