:root {
  --bg: #101321;
  --bg-card: #1a1f33;
  --bg-card2: #232941;
  --border: #303752;
  --text: #e9ecf7;
  --text-dim: #93a0c0;
  --accent: #6c8cff;   /* en route */
  --accent2: #ffc46b;  /* l'itinéraire qui reste */
  --ok: #35c48d;       /* arrivé */
  --danger: #ef476f;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.hidden { display: none !important; }

/* ------------------------------------------------------------- bandeau */
#banner {
  text-align: center;
  padding: 9px 12px;
  font-size: 0.88rem;
  font-weight: 600;
  background: #2a2340;
  border-bottom: 1px solid #453a63;
  color: var(--accent2);
  flex-shrink: 0;
}

/* ------------------------------------------------------------- en-tête */
header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
header .avatar {
  font-size: 2rem;
  line-height: 1;
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-card2);
  border-radius: 50%;
  flex-shrink: 0;
}
h1 { font-size: 1.1rem; font-weight: 700; }
header .sub {
  display: flex; align-items: center; gap: 8px;
  margin-top: 3px;
  font-size: 0.78rem;
  color: var(--text-dim);
}

.badge {
  font-size: 0.63rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--border);
  color: var(--text-dim);
  white-space: nowrap;
}
.badge.live { background: var(--ok); color: #06251a; animation: blink 2.4s infinite; }
.badge.done { background: var(--ok); color: #06251a; }
@keyframes blink { 50% { opacity: 0.55; } }

/* ------------------------------------------------------------- structure */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
#map-wrap { position: relative; height: 46vh; flex-shrink: 0; }
#map { width: 100%; height: 100%; background: var(--bg-card2); }

#map-controls { position: absolute; top: 10px; right: 10px; z-index: 500; display: flex; flex-direction: column; gap: 6px; }
.ctl {
  width: 38px; height: 38px;
  border: 1px solid var(--border);
  background: rgba(26, 31, 51, 0.92);
  color: var(--text);
  border-radius: 10px;
  font-size: 1.05rem;
  cursor: pointer;
}
.ctl.active { border-color: var(--accent); color: var(--accent); }

#viewing {
  position: absolute; left: 10px; bottom: 10px; z-index: 500;
  display: flex; align-items: center; gap: 10px;
  background: rgba(26, 31, 51, 0.94);
  border: 1px solid var(--accent);
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 0.8rem;
}
#viewing button {
  border: 0; border-radius: 7px; padding: 4px 9px;
  background: var(--accent); color: #0b1020; font-weight: 700; cursor: pointer;
}

#panel { padding: 14px; display: flex; flex-direction: column; gap: 12px; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}
.card h2 { font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim); margin-bottom: 10px; }

/* ------------------------------------------------------------- heure d'arrivée */
#eta-card { text-align: center; }
#eta-card.arrived { border-color: var(--ok); }
.eta-label { font-size: 0.8rem; color: var(--text-dim); }
.eta-big {
  font-size: 2.9rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 2px 0;
}
#eta-card.arrived .eta-big { color: var(--ok); }
.eta-rel { font-size: 1rem; font-weight: 600; color: var(--accent); }
#eta-card.arrived .eta-rel { color: var(--ok); }

.bar {
  height: 8px;
  background: var(--bg-card2);
  border-radius: 999px;
  overflow: hidden;
  margin: 14px 0 8px;
}
.bar-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width 0.8s ease;
}
#eta-card.arrived .bar-fill { background: var(--ok); }

.eta-facts {
  display: flex; justify-content: space-between;
  font-size: 0.8rem; color: var(--text-dim);
}
.eta-note { margin-top: 10px; font-size: 0.82rem; color: var(--text-dim); }
.eta-note.quote { color: var(--text); font-style: italic; }

/* ------------------------------------------------------------- fil */
.feed { display: flex; flex-direction: column; gap: 9px; }
.feed-item { display: flex; gap: 9px; align-items: flex-start; }
.feed-icon { font-size: 1.05rem; line-height: 1.4; }
.feed-body { flex: 1; min-width: 0; }
.feed-msg { font-size: 0.88rem; }
.feed-time { font-size: 0.7rem; color: var(--text-dim); }
.empty { font-size: 0.85rem; color: var(--text-dim); }

/* ------------------------------------------------------------- historique */
.history { display: flex; flex-direction: column; gap: 7px; }
.trip-row {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  text-align: left;
  background: var(--bg-card2);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 11px;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.trip-row:hover { border-color: var(--accent); }
.trip-row.active { border-color: var(--accent); }
.trip-row .dot { font-size: 1rem; }
.trip-row .when { font-size: 0.85rem; font-weight: 600; }
.trip-row .facts { font-size: 0.72rem; color: var(--text-dim); }
.trip-row .right { margin-left: auto; font-size: 0.75rem; color: var(--text-dim); text-align: right; }

footer { text-align: center; font-size: 0.7rem; color: var(--text-dim); padding: 4px 0 14px; }

/* ------------------------------------------------------------- marqueurs */
.me-marker { position: relative; font-size: 1.5rem; line-height: 1; }
.me-marker .pulse {
  position: absolute; inset: 50% auto auto 50%;
  width: 42px; height: 42px; margin: -21px 0 0 -21px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.35;
  animation: ping 2s ease-out infinite;
}
@keyframes ping { 70%, 100% { transform: scale(2); opacity: 0; } }
.dest-marker { font-size: 1.6rem; line-height: 1; filter: drop-shadow(0 2px 3px rgba(0,0,0,0.6)); }
.pin-marker { font-size: 1.1rem; line-height: 1; }

.leaflet-container { background: #12172a; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--bg-card); color: var(--text); }
.leaflet-bar a { background: var(--bg-card); color: var(--text); border-color: var(--border); }
.leaflet-bar a:hover { background: var(--bg-card2); }

/* ------------------------------------------------------------- page d'accueil */
.landing {
  margin: auto;
  max-width: 460px;
  padding: 36px 24px;
  text-align: center;
}
.landing .logo { font-size: 3.4rem; }
.landing h1 { font-size: 1.5rem; margin: 10px 0 14px; }
.landing p { color: var(--text-dim); line-height: 1.6; font-size: 0.94rem; margin-bottom: 12px; }

/* ------------------------------------------------------------- grand écran */
@media (min-width: 900px) {
  main { flex-direction: row; overflow: hidden; }
  #map-wrap { flex: 1; height: auto; }
  #panel { width: 390px; overflow-y: auto; border-left: 1px solid var(--border); }
  body { height: 100dvh; overflow: hidden; }
}
