/* Bel Œil — styles (mobile d'abord) */
:root {
  --bg: #f2f4f6;
  --card: #ffffff;
  --ink: #2c3540;
  --muted: #7b8794;
  --line: #e3e8ee;
  --accent: #2e9e5b;
  --accent-ink: #175c33;
  --bad: #d05555;
  --ver: #2e9e5b; --eau: #2e8fc0; --arc: #c2842f; --vue: #8a63c9;
  --vie: #d95f8a; --cal: #58a39b; --neu: #a8b3bd;
  --radius: 18px;
  --shadow: 0 6px 24px rgba(30, 45, 60, 0.14);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink); background: var(--bg);
  user-select: none;
}

#map { position: fixed; inset: 0; }

/* ---------- barre du haut ---------- */
#topbar {
  position: fixed; top: calc(8px + var(--safe-top)); left: 10px; right: 10px;
  display: flex; align-items: center; gap: 8px; z-index: 20; pointer-events: none;
}
#topbar > * { pointer-events: auto; }
.brand {
  background: var(--card); border-radius: 999px; padding: 8px 14px;
  font-weight: 700; font-size: 15px; box-shadow: var(--shadow);
}
.brand-eye { margin-right: 2px; }
.chip {
  background: var(--card); border-radius: 999px; padding: 7px 12px;
  font-size: 13px; box-shadow: var(--shadow); white-space: nowrap;
}
.iconbtn {
  background: var(--card); border: none; border-radius: 999px;
  width: 36px; height: 36px; font-size: 15px; font-weight: 700; color: var(--ink);
  box-shadow: var(--shadow); cursor: pointer; flex: none;
}
#btn-donate { margin-left: auto; }

/* ---------- recherche ---------- */
#fab-search {
  position: fixed; top: calc(60px + var(--safe-top)); left: 50%; transform: translateX(-50%);
  z-index: 20; border: none; background: var(--card); color: var(--muted);
  border-radius: 999px; padding: 12px 22px; font-size: 15px; box-shadow: var(--shadow);
  cursor: pointer; width: min(86vw, 420px); text-align: left;
}

/* ---------- légende ---------- */
#legend {
  position: fixed; bottom: calc(86px + var(--safe-bottom)); left: 0; right: 0;
  display: flex; gap: 6px; overflow-x: auto; padding: 4px 10px; z-index: 15;
  scrollbar-width: none;
}
#legend::-webkit-scrollbar { display: none; }
.legend-chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  background: var(--card); border: 1.5px solid transparent; border-radius: 999px;
  padding: 6px 11px; font-size: 12.5px; box-shadow: var(--shadow); cursor: pointer;
}
.legend-chip .dot { width: 10px; height: 10px; border-radius: 50%; }
.legend-chip.active { border-color: var(--ink); font-weight: 600; }

/* ---------- frise horaire ---------- */
#timeline {
  position: fixed; bottom: calc(14px + var(--safe-bottom)); left: 10px; right: 10px;
  display: flex; align-items: center; gap: 10px; z-index: 15;
  background: var(--card); border-radius: 999px; padding: 8px 14px; box-shadow: var(--shadow);
}
#time-slider { flex: 1; accent-color: var(--accent); }
#time-label { font-size: 13px; font-weight: 700; min-width: 52px; text-align: right; }
#timeline .iconbtn { box-shadow: none; background: var(--bg); width: 32px; height: 32px; }

/* ---------- panneaux (bottom sheets) ---------- */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--card); border-radius: 22px 22px 0 0; box-shadow: 0 -8px 30px rgba(30,45,60,.2);
  padding: 10px 16px calc(16px + var(--safe-bottom)); max-height: 82vh; overflow-y: auto;
  transform: translateY(105%); transition: transform .28s ease;
}
.sheet.open { transform: translateY(0); }
.sheet .grab { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 2px auto 10px; }
.sheet h2 { font-size: 17px; margin: 4px 0 10px; display: flex; align-items: center; gap: 8px; }
.sheet h3 { font-size: 13px; margin: 14px 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.sheet-close { position: absolute; top: 12px; right: 12px; }

.backdrop {
  position: fixed; inset: 0; z-index: 25; background: rgba(20,30,40,.25);
  opacity: 0; pointer-events: none; transition: opacity .25s;
}
.backdrop.show { opacity: 1; pointer-events: auto; }

/* champs itinéraire */
.field { position: relative; margin-bottom: 8px; }
.field input[type="text"] {
  width: 100%; border: 1.5px solid var(--line); border-radius: 12px;
  padding: 11px 12px 11px 34px; font-size: 15px; background: var(--bg); color: var(--ink);
}
.field .pin { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); font-size: 14px; }
.autolist {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 5; background: var(--card);
  border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; margin-top: 4px;
}
.autolist button {
  display: block; width: 100%; text-align: left; background: none; border: none;
  padding: 10px 12px; font-size: 14px; color: var(--ink); cursor: pointer;
  border-bottom: 1px solid var(--line);
}
.autolist button:last-child { border-bottom: none; }
.autolist button:active { background: var(--bg); }
.autolist .sub { display: block; color: var(--muted); font-size: 12px; }

/* segmentés + puces d'options */
.seg-group { display: flex; background: var(--bg); border-radius: 12px; padding: 4px; gap: 4px; }
.seg-group button {
  flex: 1; border: none; background: none; border-radius: 9px; padding: 9px 4px;
  font-size: 13.5px; color: var(--muted); cursor: pointer;
}
.seg-group button.active { background: var(--card); color: var(--ink); font-weight: 700; box-shadow: 0 2px 8px rgba(30,45,60,.12); }

.chips-row { display: flex; flex-wrap: wrap; gap: 6px; }
.opt-chip {
  border: 1.5px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 7px 13px; font-size: 13px; color: var(--ink); cursor: pointer;
}
.opt-chip.active { border-color: var(--accent); background: #eaf6ee; color: var(--accent-ink); font-weight: 700; }
.chips-row input[type="number"], .chips-row input[type="time"] {
  border: 1.5px solid var(--line); border-radius: 999px; padding: 6px 10px; font-size: 13px;
  width: 86px; background: var(--card); color: var(--ink);
}

/* curseurs de filtres */
.fslider { display: flex; align-items: center; gap: 10px; margin: 7px 0; }
.fslider .flabel { flex: none; width: 118px; font-size: 13.5px; }
.fslider input { flex: 1; accent-color: var(--accent); }
.fslider .fval { flex: none; width: 46px; font-size: 12px; color: var(--muted); text-align: right; }
.fslider.bad input { accent-color: var(--bad); }

.toggle-row { display: flex; align-items: center; justify-content: space-between; margin: 10px 0; font-size: 14px; }
.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { display: none; }
.switch span {
  position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: .2s; cursor: pointer;
}
.switch span::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }

.btn-row { display: flex; gap: 8px; margin-top: 14px; }
.btn {
  flex: 1; border: none; border-radius: 14px; padding: 14px 10px; font-size: 15px;
  font-weight: 700; cursor: pointer; background: var(--bg); color: var(--ink);
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.small { padding: 9px 12px; font-size: 13px; flex: none; }

/* ---------- carte des résultats ---------- */
#result-card {
  position: fixed; left: 10px; right: 10px; bottom: calc(64px + var(--safe-bottom)); z-index: 22;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 12px 14px; display: none;
}
#result-card.show { display: block; }
.route-line { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 14.5px; }
.route-line .swatch { width: 18px; height: 5px; border-radius: 3px; flex: none; }
.route-line b { font-weight: 700; }
.route-line .delta { color: var(--muted); font-size: 12.5px; margin-left: auto; }
.beauty-badge {
  background: #eaf6ee; color: var(--accent-ink); font-weight: 700; font-size: 12px;
  padding: 3px 8px; border-radius: 999px;
}

/* étapes */
.steps-list { margin: 8px 0 0; padding: 0; list-style: none; max-height: 34vh; overflow-y: auto; }
.steps-list li { display: flex; gap: 10px; align-items: baseline; padding: 7px 2px; border-bottom: 1px solid var(--line); font-size: 14px; }
.steps-list .icon { flex: none; width: 26px; text-align: center; font-size: 16px; }
.steps-list .d { margin-left: auto; color: var(--muted); font-size: 12.5px; white-space: nowrap; }

/* ---------- fiche de rue ---------- */
.score-bar { display: flex; align-items: center; gap: 8px; margin: 5px 0; font-size: 13.5px; }
.score-bar .sl { flex: none; width: 110px; }
.score-bar .track { flex: 1; height: 8px; border-radius: 4px; background: var(--bg); overflow: hidden; position: relative; }
.score-bar .fill2 { position: absolute; top: 0; height: 100%; border-radius: 4px; }
.score-bar .fill { display: block; height: 100%; border-radius: 4px; }
.score-bar .sv { flex: none; width: 30px; text-align: right; color: var(--muted); font-size: 12px; }
.amb-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 2px; }
.amb-chip { font-size: 12px; padding: 4px 10px; border-radius: 999px; color: #fff; font-weight: 600; }
.hours-strip { display: flex; gap: 2px; margin: 6px 0 2px; }
.hours-strip .hcell { flex: 1; height: 26px; border-radius: 4px; background: var(--bg); position: relative; }
.hours-strip-labels { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--muted); margin-bottom: 8px; }
.street-actions { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
.street-actions .btn { flex: 1 1 40%; font-size: 13px; padding: 11px 6px; }
.street-actions .btn.on { background: #eaf6ee; color: var(--accent-ink); }

/* ---------- guidage ---------- */
#guidance {
  position: fixed; top: calc(8px + var(--safe-top)); left: 10px; right: 10px; z-index: 40;
  background: var(--accent-ink); color: #fff; border-radius: var(--radius);
  padding: 12px 14px; display: none; align-items: center; gap: 12px; box-shadow: var(--shadow);
}
#guidance.show { display: flex; }
#guidance .g-icon { font-size: 26px; flex: none; }
#guidance .g-main { flex: 1; }
#guidance .g-dist { font-size: 13px; opacity: .85; }
#guidance .g-text { font-size: 15.5px; font-weight: 700; }
#guidance .iconbtn { background: rgba(255,255,255,.18); color: #fff; box-shadow: none; }

/* ---------- onboarding / chargement / toast ---------- */
#onboarding {
  position: fixed; inset: 0; z-index: 60; background: rgba(24,34,44,.45);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.ob-card {
  background: var(--card); border-radius: 24px; padding: 28px 22px 20px; max-width: 380px;
  text-align: center; box-shadow: var(--shadow);
}
.ob-emoji { font-size: 44px; }
.ob-card h2 { font-size: 19px; margin: 12px 0 8px; }
.ob-card p { font-size: 14.5px; color: var(--muted); line-height: 1.5; margin: 0 0 18px; }
.ob-dots { display: flex; gap: 6px; justify-content: center; margin-bottom: 16px; }
.ob-dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.ob-dots span.on { background: var(--accent); }

#loading {
  position: fixed; inset: 0; z-index: 70; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
}
.loading-card { text-align: center; color: var(--muted); font-size: 14.5px; }
.loading-eye { font-size: 46px; animation: blink 2.2s infinite; margin-bottom: 10px; }
@keyframes blink { 0%, 92%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.1); } }

#toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(140px + var(--safe-bottom));
  z-index: 80; background: var(--ink); color: #fff; border-radius: 999px; padding: 10px 18px;
  font-size: 14px; box-shadow: var(--shadow); opacity: 0; transition: opacity .3s; pointer-events: none;
  max-width: 86vw; text-align: center;
}
#toast.show { opacity: 1; }

/* menu contextuel carte */
#map-menu {
  position: fixed; z-index: 45; background: var(--card); border-radius: 14px;
  box-shadow: var(--shadow); overflow: hidden; display: none; min-width: 180px;
}
#map-menu button {
  display: block; width: 100%; border: none; background: none; text-align: left;
  padding: 12px 14px; font-size: 14px; cursor: pointer; color: var(--ink);
  border-bottom: 1px solid var(--line);
}
#map-menu button:last-child { border-bottom: none; }

.maplibregl-ctrl-bottom-right { bottom: 96px; }
.muted { color: var(--muted); font-size: 13px; }

/* ---------- v1.5 : nouveaux composants ---------- */

/* vitesse repliée */
.collapse-row { display: flex; align-items: center; gap: 10px; margin: 14px 0 6px; font-size: 14px; }
.iconbtn.big { width: 44px; height: 44px; font-size: 20px; background: var(--bg); box-shadow: none; }

/* sélecteur de durée */
.dur-select {
  border: 1.5px solid var(--line); border-radius: 999px; padding: 9px 14px;
  font-size: 14px; background: var(--card); color: var(--ink); max-width: 100%;
}
#rp-arrive-wrap { margin-top: 8px; }
#rp-arrive-box input[type="time"] {
  border: 1.5px solid var(--line); border-radius: 999px; padding: 6px 10px;
  font-size: 13px; background: var(--card); color: var(--ink);
}

/* à éviter : NON / OUI (un peu · objectif 0) */
.avoid-row { display: flex; align-items: center; gap: 8px; margin: 8px 0; flex-wrap: wrap; }
.avoid-row .flabel { flex: 1 1 100%; font-size: 13.5px; }
.avoid-btns { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ab {
  border: 1.5px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 7px 14px; font-size: 12.5px; font-weight: 700; color: var(--muted); cursor: pointer;
}
.ab.active { border-color: var(--bad); background: #fbecec; color: var(--bad); }
.avoid-sub { display: inline-flex; gap: 6px; padding-left: 6px; border-left: 2px solid var(--line); }

/* liste statique (favoris) */
.autolist-static { background: var(--bg); border-radius: 12px; overflow: hidden; margin-top: 6px; }
.autolist-static button {
  display: block; width: 100%; text-align: left; background: none; border: none;
  padding: 10px 12px; font-size: 14px; color: var(--ink); cursor: pointer;
  border-bottom: 1px solid var(--line);
}
.autolist-static button:last-child { border-bottom: none; }

/* badge calme actuel */
.now-badge {
  display: inline-block; background: var(--bg); border-radius: 999px;
  padding: 4px 10px; font-size: 12.5px; font-weight: 700; margin-top: 8px;
}

/* frise des heures interactive */
.hours-scroll {
  display: flex; gap: 3px; overflow-x: auto; padding: 4px 2px; scrollbar-width: none;
  scroll-snap-type: x proximity;
}
.hours-scroll::-webkit-scrollbar { display: none; }
.hcell2 {
  flex: none; width: 30px; height: 36px; border-radius: 6px; border: none; cursor: pointer;
  display: flex; align-items: flex-end; justify-content: center; scroll-snap-align: center;
  font-size: 10px; color: var(--ink); padding-bottom: 2px;
}
.hcell2.sel { outline: 2.5px solid var(--ink); font-weight: 700; }
.hour-stats { font-size: 13px; margin: 8px 2px; line-height: 1.7; }

/* roulettes jour / mois */
.wheel {
  display: flex; gap: 4px; overflow-x: auto; padding: 4px 40vw 4px 4px; margin: 4px 0;
  scrollbar-width: none; scroll-snap-type: x mandatory;
}
.wheel::-webkit-scrollbar { display: none; }
.wheel button {
  flex: none; border: 1.5px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 6px 14px; font-size: 12.5px; color: var(--muted); cursor: pointer; scroll-snap-align: center;
}
.wheel button.sel { border-color: var(--accent); background: #eaf6ee; color: var(--accent-ink); font-weight: 700; }

/* bulles du mode trajet */
#bubbles {
  position: fixed; right: 10px; bottom: calc(150px + var(--safe-bottom)); z-index: 24;
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
}
#bubbles[hidden], .bubble-stack[hidden] { display: none !important; }
.bubble {
  width: 46px; height: 46px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--card); box-shadow: var(--shadow); font-size: 20px;
}
.bubble.main { background: var(--accent-ink); }
.bubble-stack { display: flex; flex-direction: column; gap: 8px; }

/* frise horaire masquable */
#timeline.tl-off { display: none; }

/* ---------- impression ---------- */
#print-sheet { display: none; }
@media print {
  body > *:not(#print-sheet) { display: none !important; }
  html, body { overflow: visible; height: auto; background: #fff; }
  #print-sheet { display: block; padding: 6mm; font-size: 12px; color: #222; }
  .pr-head { display: flex; gap: 10px; align-items: center; border-bottom: 2px solid #2e9e5b; padding-bottom: 6px; }
  .pr-brand { font-size: 22px; font-weight: 800; }
  .pr-head h1 { font-size: 16px; margin: 0; }
  .pr-sub { color: #555; font-size: 12px; }
  .pr-map { width: 100%; max-height: 120mm; object-fit: cover; border-radius: 6px; margin: 4mm 0; }
  .pr-legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 11px; margin: 3mm 0; }
  .pr-legend i { display: inline-block; width: 14px; height: 5px; border-radius: 2px; margin-right: 4px; }
  .pr-steps { columns: 2; font-size: 11.5px; line-height: 1.6; padding-left: 16px; }
  .pr-steps em { color: #777; }
  .pr-foot { margin-top: 4mm; font-size: 10px; color: #888; }
}
