html, body { height: 100%; margin: 0; }
body { font: var(--font); background: var(--paper); color: var(--ink); }

#app { display: flex; height: 100dvh; position: relative; }

/* la baguette: une capsule qui se déplie, à la markup — pas de panneau */
#baguette {
  position: absolute; top: 12px; right: 12px; z-index: 950;
  display: flex; align-items: center; gap: 6px;
  height: 36px; width: 36px; padding: 0 3px; box-sizing: border-box;
  border-radius: 999px; overflow: hidden;
  background: var(--card, #fffdf7); border: 1px solid var(--border, #d8d2c0);
  box-shadow: 0 3px 10px rgba(0, 0, 0, .13);
  transition: width .28s cubic-bezier(.4, 0, .2, 1), box-shadow .28s, border-color .28s;
}
#baguette.ouverte {
  width: min(330px, calc(100vw - 24px));
  box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
}
#wandbtn {
  flex: none; width: 28px; height: 28px; padding: 0;
  border: none; background: none; font-size: 16px; line-height: 1; cursor: pointer;
  transition: transform .2s;
}
#baguette.ouverte #wandbtn { transform: rotate(-14deg); }
#wandtxt {
  flex: 1; min-width: 0; border: none; outline: none; background: transparent;
  font: inherit; font-size: 13px; color: var(--ink, #111);
  opacity: 0; transition: opacity .18s .1s;
}
#wandtxt::placeholder { color: var(--hint, #8a8472); }
.ouverte #wandtxt { opacity: 1; }
#wandsend {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  border: none; background: var(--accent, #c4621f); color: #fff;
  font-size: 14px; line-height: 1; cursor: pointer;
  opacity: 0; transform: scale(.5); transition: opacity .18s .1s, transform .18s .1s;
}
.ouverte #wandsend { opacity: 1; transform: scale(1); }
#wandsend:hover { transform: scale(1.1); }
#wandstatus { display: none; flex: 1; min-width: 0; font-size: 12px; color: var(--muted); white-space: nowrap; }
#baguette.occupe #wandtxt, #baguette.occupe #wandsend { display: none; }
#baguette.occupe #wandstatus { display: block; }
#baguette.occupe { width: min(330px, calc(100vw - 24px)); border-color: var(--accent, #c4621f); animation: pouls 1.2s ease-in-out infinite; }
#baguette.occupe #wandstatus::after { content: "…"; animation: points 1.2s steps(4) infinite; }
#baguette.erreur { width: min(330px, calc(100vw - 24px)); animation: secousse .4s; border-color: #a5533d; }
#baguette.erreur #wandstatus { display: block; color: #a5533d; }
#baguette.refus { height: auto; min-height: 36px; padding: 6px 3px; border-radius: 14px; align-items: flex-start; }
#baguette.refus #wandstatus { display: block; white-space: pre-line; color: #a5533d; }
#baguette.erreur #wandtxt { display: none; }
@keyframes pouls { 50% { box-shadow: 0 0 0 5px rgba(196, 98, 31, .12); } }
@keyframes points { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "…"; } }
@keyframes secousse {
  20% { transform: translateX(-5px); } 40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); } 80% { transform: translateX(2px); }
}

#timeline {
  width: 380px; min-width: 380px;
  display: flex; flex-direction: column;
  border-right: 1px solid var(--border, #d8d2c0);
  background: var(--paper);
}
#triphead { position: relative; padding: 18px 18px 10px; border-bottom: 1px solid var(--border, #d8d2c0); }
#exportbtn {
  position: absolute; top: 16px; right: 14px;
  width: 28px; height: 28px; border-radius: 50%; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border, #d8d2c0); background: var(--card, #fffdf7);
  color: var(--muted); font: inherit; font-size: 13px; line-height: 1; cursor: pointer;
}
#exportbtn:hover { color: var(--accent); border-color: var(--accent); }
/* toggle pluie: rond comme exportbtn, juste à sa gauche; inactif = fond carte/gris,
   actif = fond accent/blanc (voir aussi la version téléphone plus bas) */
#pluiebtn {
  position: absolute; top: 16px; right: 48px;
  width: 28px; height: 28px; border-radius: 50%; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border, #d8d2c0); background: var(--card, #fffdf7);
  color: var(--muted); font: inherit; font-size: 13px; line-height: 1; cursor: pointer;
}
#pluiebtn:hover { border-color: var(--accent); }
#pluiebtn.actif { background: var(--accent, #c4621f); border-color: var(--accent, #c4621f); color: #fff; }
#chronoligne { display: none; }
#triphead h1 { margin: 0; font-size: 20px; letter-spacing: .02em; }
#triphead .sub { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* la réserve de fin permet à CHAQUE jour d'atteindre le haut du fil, même sur un grand
   écran: elle doit approcher une hauteur de fenêtre, sinon le scroll bute avant le seuil */
#steps { list-style: none; margin: 0; padding: 0 14px calc(100vh - 430px); overflow-y: auto; flex: 1; }

.dayhead {
  /* la ligne du jour reste ÉPINGLÉE en haut du fil une fois dépassée; les lignes
     s'empilent (top posé en inline: 28px par jour) */
  height: 28px; box-sizing: border-box;
  background: var(--paper, #f3efe0);
  border-bottom: 1px solid var(--border, #d8d2c0);
  transition: color .25s;
  display: flex; align-items: center; gap: 7px;
  font-size: 11px; text-transform: lowercase; letter-spacing: .12em;
  color: var(--muted); margin: 0 -14px; padding: 0 18px;
  cursor: pointer; user-select: none;
}
.dayhead .dcaret { transition: transform .15s; display: inline-block; }
.dayhead:not(.plie) .dcaret { transform: rotate(90deg); }
.dayhead .dnom { white-space: nowrap; }
.dayhead .dsum { margin-left: auto; letter-spacing: .02em; font-size: 13px; white-space: nowrap; overflow: hidden; }
/* l'air AVANT une ligne de jour vit dans le jalon (statique, il glisse sous la pile);
   la ligne sticky n'a AUCUNE marge, sinon top:0 épingle le bord de marge et le contenu
   défile dans l'interstice */
.jalon { height: 14px; margin: 0; padding: 0; border: none; list-style: none; }
.jalon:first-child { height: 10px; }
/* seule une ligne DÉPASSÉE s'épingle (le top d'empilement est posé en inline) */
.dayhead.passe { position: sticky; z-index: 6; }
.dayhead.jourfocus { color: var(--ink); }
/* le jour sous les yeux respire; les autres reculent */
.sqplie { opacity: .62; }
.step.jfitem { padding: 11px 12px; margin: 5px 0; }
.jfitem .steptitle { font-size: 14.5px; }
.jfitem .steptime, .jfitem .stepday { font-size: 12px; }
.jfitem .stepnum { font-size: 18px; }
.step.trajet.jfitem { padding: 8px 0 8px 16px; }
.jfitem .tduree { font-size: 14px; }
.jfitem .tem { font-size: 16px; }
.jfitem .tlieux { font-size: 12px; }
.leg.jfitem { font-size: 12px; padding: 4px 0 4px 16px; }

.jnum {
  flex: none; min-width: 17px; height: 17px; border-radius: 999px;
  background: var(--accent, #c4621f); color: #fff;
  font-size: 10px; line-height: 17px; text-align: center; font-weight: 700;
  letter-spacing: 0; padding: 0 2px; box-sizing: border-box;
}
/* soleil et changement d'heure: memes lignes discretes que midi */
.midi.soleil { color: #b08a52; }
.midi.heurechange { color: var(--accent, #c4621f); font-size: 11px; letter-spacing: .06em; }
/* midi: la ligne pointillée qui coupe la journée en deux */
.midi {
  list-style: none; display: flex; align-items: center; gap: 8px;
  margin: 7px 4px 7px 20px; color: var(--hint, #8a8472); font-size: 10px;
  letter-spacing: .1em;
}
.midi::after { content: ""; flex: 1; border-top: 1px dotted var(--border, #d8d2c0); }
/* l'enroulement: hauteur + fondu, easing doux; jamais un display:none sec */
#steps .step, #steps .leg, #steps .midi {
  max-height: 120px;
  transition: max-height .3s cubic-bezier(.3, .7, .3, 1), opacity .22s,
    margin .3s cubic-bezier(.3, .7, .3, 1), padding .3s cubic-bezier(.3, .7, .3, 1),
    border-color .3s;
  overflow: hidden;
}
#steps.sansanim .step, #steps.sansanim .leg, #steps.sansanim .midi { transition: none !important; }
#steps .cache {
  max-height: 0; opacity: 0;
  margin-top: 0; margin-bottom: 0;
  padding-top: 0; padding-bottom: 0;
  border-color: transparent;
  pointer-events: none;
}

#modebtn { display: none; }
#planbtn { display: none; }

/* trajet entre deux étapes, dans le fil vertical */
.leg {
  color: var(--muted); font-size: 11px;
  margin-left: 20px; padding: 3px 0 3px 16px;
  border-left: 2px dotted var(--border, #d8d2c0);
  list-style: none;
}

.step {
  position: relative;
  display: flex; gap: 10px; align-items: flex-start;
  padding: 9px 10px; margin: 4px 0;
  border: 1px solid transparent; border-radius: 10px;
  cursor: pointer;
}
.step:hover { background: var(--card, #fffdf7); border-color: var(--border, #d8d2c0); }
.step.sel {
  background: var(--card, #fffdf7);
  border-color: var(--accent);
  box-shadow: 0 1px 4px rgba(196, 98, 31, .18);
}

.stepnum {
  flex: none; width: 24px;
  font-size: 16px; line-height: 1.25; text-align: center;
}
.step.nogeo .stepnum { opacity: .6; }

/* trajet = le fil lui-même: connecteur durée-d'abord, coloré par son mode (--mc) */
.step.trajet {
  display: flex; align-items: baseline; gap: 8px;
  margin: 2px 0 2px 20px; padding: 6px 0 6px 16px;
  border: none; border-left: 3px dashed var(--mc, var(--accent));
  border-radius: 0;
}
.step.trajet:hover { background: var(--card, #fffdf7); }
.step.trajet.sel {
  background: var(--card, #fffdf7);
  border-left-color: var(--mc, var(--accent));
  box-shadow: none;
}
.tem { font-size: 15px; }
.tduree { font-size: 13px; }
.tlieux { font-size: 11px; color: var(--muted); min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tduree { white-space: nowrap; }
.nuits { margin-left: auto; flex: none; font-size: 11px; color: var(--muted); }

.stepbody { min-width: 0; flex: 1; }
.steptop { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.stepday { display: none; color: var(--hint, #8a8472); font-size: 11px; }
.steptime { color: var(--muted); font-size: 11px; flex: none; }
.steptitle { font-size: 13px; font-weight: 600; }
.stepquoi { display: flex; gap: 8px; align-items: baseline; margin-top: 2px; font-size: 11.5px; color: var(--muted); }
.stepquoi span { flex: 1; min-width: 0; }
.stepquoi b { flex: none; font-weight: 500; font-size: 11px; color: var(--hint, #8a8472); }


/* --- vue Plan: cartes-jour, à la place du fil (grand écran) ou en feuille (téléphone) --- */
/* le choix Fil/Plan est gardé en localStorage, donc partagé entre les deux gabarits d'une
   même session (redimensionner franchit le seuil sans recharger): les règles qui font du
   #plan desktop un remplaçant du fil restent scopées au-delà de 720px, sinon un
   #timeline.vueplan hérité du desktop casserait le ruban mobile (steps caché à tort). */
#plan { display: none; }
@media (min-width: 721px), (orientation: landscape) {
  #plan { flex: 1; overflow-y: auto; padding: 0 14px calc(100vh - 430px); }
  #timeline.vueplan #steps { display: none; }
  #timeline.vueplan #plan { display: block; }
}

.plancard {
  border: 1px solid var(--border, #d8d2c0); border-radius: 10px;
  background: var(--card, #fffdf7); padding: 10px 12px; margin: 8px 0;
}
.planhead { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.planvibe { font-size: 11.5px; color: var(--muted); line-height: 1.4; margin: 0 0 8px; }
.ptrajet { font-size: 13px; font-weight: 600; }
.pmeta { font-size: 11.5px; color: var(--muted); }
.planalerts { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 6px; }
.planpluie { display: flex; gap: 6px; align-items: baseline; font-size: 11px; color: var(--hint, #8a8472); margin: 8px 0 0; padding: 6px 0 0; border-top: 1px dashed var(--border, #d8d2c0); }
.planpluie .pe { flex: none; }
.planwarn { background: var(--danger-bg); color: var(--danger); }
.planstops { display: flex; flex-direction: column; gap: 3px; }
.planstop {
  display: flex; flex-direction: column; gap: 2px;
  padding: 4px 6px; margin: 0 -6px; border-radius: 6px; cursor: pointer; font-size: 12px;
}
.planstop:hover { background: var(--paper); }
.planstop.sel { background: var(--card, #fffdf7); box-shadow: inset 0 0 0 1.5px var(--accent); }
.planstop .pt { display: flex; align-items: center; gap: 6px; min-width: 0; }
.planstop .pe { flex: none; }
.planstop b { font-size: 12.5px; font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.planstop .pq { color: var(--muted); padding-left: 60px; }
.planstop .ph, .planleg .ph { flex: none; width: 34px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.planstop.stay b { font-weight: 500; color: var(--muted); }
.planleg {
  display: flex; align-items: center; gap: 6px; min-width: 0;
  padding: 1px 6px; margin: 0 -6px; border-radius: 6px; font-size: 11px; color: var(--hint, #8a8472); cursor: pointer;
}
.planleg.go { cursor: default; }
.planleg .pe { flex: none; }
.planleg .pl { color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.planleg[data-id]:hover { background: var(--paper); }
.planleg.sel { background: var(--card, #fffdf7); box-shadow: inset 0 0 0 1.5px var(--accent); }
.planstop .pd { color: var(--hint, #8a8472); font-size: 11px; flex: none; }
.planstop .pjeux { flex: none; }
/* optionnel: contour pointillé, titre en gris, chip « option » */
.popt { flex: none; font-size: 10px; border: 1px dashed var(--muted); background: transparent; color: var(--muted); padding: 0 5px; }
.planstop.opt { border: 1px dashed var(--border, #d8d2c0); }
.planstop.opt b { color: var(--muted); font-weight: 500; }
.step.opt { border-style: dashed; }
.step.opt .steptitle { color: var(--muted); font-weight: 500; }
.mk.opt { border-style: dashed; }

#map { flex: 1; min-width: 0; touch-action: none; }

/* le moteur de décors */
.scene { position: absolute; top: 0; left: 0; transform-origin: 0 0; pointer-events: none; user-select: none; -webkit-user-drag: none; }
#traits { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
#calque { position: absolute; inset: 0; z-index: 6; pointer-events: none; }
/* pas de will-change ici: ~45 ancres = un troupeau de calques composites sur iOS */
.anc { position: absolute; left: 0; top: 0; pointer-events: auto; cursor: pointer; }
.anc.pil { pointer-events: none; }

/* scrubber (mobile seulement) */
#scrub { display: none; position: relative; height: 26px; margin: 4px 18px 0; touch-action: none; }
#scrub .track, #scrub .fill {
  position: absolute; left: 0; top: 11px; height: 4px; border-radius: 2px;
}
#scrub .track { right: 0; background: var(--border, #d8d2c0); }
#scrub .fill { width: 0; background: var(--accent); }
/* le pouls de la pastille quand on change de jour */
#jourcap.pouls .jnum { animation: jpouls .4s cubic-bezier(.3, 1.5, .5, 1); }
@keyframes jpouls { 0% { transform: scale(1); } 45% { transform: scale(1.45); } 100% { transform: scale(1); } }

#scrub .jtick {
  position: absolute; top: 9px; width: 2px; height: 8px; border-radius: 1px;
  background: #bdb49c; transform: translateX(-50%);
}
#scrub .knob {
  position: absolute; top: 6px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent, #c4621f); border: 2px solid #fff;
  transform: translateX(-50%); box-sizing: border-box;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  transition: left .18s ease-out;
}
#scrub .fill { transition: width .18s ease-out; }

/* markers: pastille emoji + petit badge d'ordre; la taille suit le zoom via --mks */
.mk {
  position: relative;
  width: var(--mks, 32px); height: var(--mks, 32px); border-radius: 50%;
  background: var(--card, #fffdf7);
  border: 2px solid var(--accent);
  box-shadow: 0 1px 4px rgba(0,0,0,.3);
  box-sizing: border-box;
  display: flex; align-items: center; justify-content: center;
  transform: translate(-50%, -50%);
  transition: width .15s, height .15s;
}
.mk .e { font-size: calc(var(--mks, 32px) * .5); line-height: 1; }
.mk b {
  position: absolute; right: calc(var(--mks, 32px) * -.16); bottom: calc(var(--mks, 32px) * -.16);
  min-width: calc(var(--mks, 32px) * .47); height: calc(var(--mks, 32px) * .47);
  border-radius: 999px;
  background: var(--accent); color: #fff;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-weight: 700; font-size: calc(var(--mks, 32px) * .29);
  line-height: calc(var(--mks, 32px) * .47 - 3px);
  text-align: center; border: 1.5px solid var(--paper, #f3efe0);
  box-sizing: border-box; padding: 0 2px;
}
.mk.stay { border-color: #7a3d12; }
.mk.stay b { background: #7a3d12; }
.mk.sel { border-color: #111; transform: translate(-50%, -50%) scale(1.18); }
.mk.sel b { background: #111; }
/* badge nuitées */
.mk i {
  position: absolute; top: calc(var(--mks, 32px) * -.2); left: calc(var(--mks, 32px) * -.24);
  font-style: normal; font-size: calc(var(--mks, 32px) * .27); line-height: 1;
  background: var(--paper, #f3efe0); border: 1px solid var(--border, #d8d2c0);
  border-radius: 999px; padding: 2px 4px; white-space: nowrap;
}
/* focus jour: le reste du voyage s'estompe; l'heure s'affiche sous l'emoji */
.anc.estompe { opacity: .25; transition: opacity .3s; }
.mk u {
  position: absolute; top: calc(100% + 3px); left: 50%; transform: translateX(-50%);
  font-size: calc(var(--mks, 32px) * .30); line-height: 1.1;
  background: var(--card, #fffdf7); color: var(--muted);
  border: 1px solid var(--border, #d8d2c0); border-radius: 999px;
  padding: 1px 6px; text-decoration: none; white-space: nowrap;
}
/* groupe de lieu (plusieurs étapes fusionnées au dézoom) */
.mk.grp {
  width: auto; border-radius: 999px; gap: calc(var(--mks, 32px) * .06);
  padding: 0 calc(var(--mks, 32px) * .18);
  box-shadow: 3px 3px 0 -1px var(--card, #fffdf7), 3px 3px 0 0 var(--accent), 0 1px 4px rgba(0,0,0,.3);
}
.mk.grp .e { font-size: calc(var(--mks, 32px) * .42); }
.mk.grp .plus { font-size: calc(var(--mks, 32px) * .28); color: var(--muted); font-weight: 700; }

/* pastille temps de trajet sur la carte; suit le zoom via --mks comme les marqueurs */
.legpill {
  display: inline-flex; align-items: center; gap: calc(var(--mks, 32px) * .12);
  transform: translate(-50%, 0);
  background: var(--card, #fffdf7); color: var(--ink, #111);
  border: 1.5px solid var(--accent); border-radius: 999px;
  padding: calc(var(--mks, 32px) * .06) calc(var(--mks, 32px) * .25);
  font-size: calc(var(--mks, 32px) * .34); font-weight: 600; white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
}

/* fond "vif": les tuiles voyager saturées */
.tiles-vif { filter: saturate(1.7) contrast(1.03); }

/* --- mobile: carte plein écran, ruban en bas, scrubber ------------------- */
/* téléphone en PORTRAIT seulement: en paysage on prend le gabarit deux colonnes */
@media (max-width: 720px) and (orientation: portrait) {
  #app { flex-direction: column; }
  #map { order: 1; min-height: 0; }
  #timeline {
    order: 2; width: 100%; min-width: 0; flex: none;
    border-right: none; border-top: 1px solid var(--border, #d8d2c0);
    display: grid; grid-template-columns: auto 1fr; align-items: center;
  }
  #triphead { padding: 4px 4px 0 18px; border-bottom: none; }
  #triphead h1 { font-size: 14px; }
  /* la ligne chronologique est une PHRASE: « ❷ mardi 20 octobre · 10:00 » — la date
     reste, l'heure avance au swipe */
  #app:not(.liste) #chronoligne {
    grid-row: 2; grid-column: 1 / 3;
    display: flex; align-items: center; justify-content: flex-start; gap: 6px;
    padding: 3px 16px 0 14px;
    font-size: 11.5px; color: var(--muted); letter-spacing: .08em; text-transform: lowercase;
  }
  /* chevrons prev/next: cible au pouce généreuse, glyphe discret */
  #chronoligne button {
    border: 0; background: none; margin: -6px 0; padding: 6px 10px;
    font: inherit; font-size: 13px; line-height: 1; color: var(--accent);
    cursor: pointer;
  }
  #jprev { margin-left: -10px; }
  #jourcap { display: inline-flex; align-items: center; gap: 6px; }
  #heurecap { color: var(--ink, #111); letter-spacing: .06em; }
  #heurecap:not(:empty)::before { content: "· "; color: var(--muted); }
  #heurecap.maj { animation: heureavance .28s ease-out; }
  @keyframes heureavance {
    from { opacity: 0; transform: translateX(6px); }
    to { opacity: 1; transform: translateX(0); }
  }
  /* l'heure et la date vivent sur la ligne chronologique, plus dans les cartes */
  /* la date reste sur la ligne chronologique; l'heure revient dans chaque carte (demande du 09/09) */
  #app:not(.liste) .step .stepday { display: none; }
  #app:not(.liste) .step .steptime { display: inline; font-size: 12px; }
  #app:not(.liste) .step .steptop { flex-wrap: nowrap; align-items: baseline; }
  #app:not(.liste) .step .steptitle { flex: 1 1 0; }
  #triphead .sub { display: none; }
  #scrub { display: block; margin: 4px 18px 0 14px; }
  #steps { grid-column: 1 / 3; }
  #steps {
    grid-row: 3; grid-column: 1 / 3;
    display: flex; gap: 10px;
    overflow-x: auto; overflow-y: hidden;
    scroll-snap-type: x mandatory;
    /* l'indicateur home flotte: on ne réserve qu'une partie du safe-area */
    padding: 6px 14px max(8px, calc(env(safe-area-inset-bottom) - 16px));
  }
  #steps::-webkit-scrollbar { display: none; }
  .leg { display: none; }
  /* ruban: un jour = une barre verticale avec sa pastille; midi = un pointillé vertical */
  #app:not(.liste) .dayhead {
    position: static; flex: none; width: 26px; height: auto;
    margin: 0; padding: 8px 0 0;
    border: none; border-left: 2px solid var(--border, #d8d2c0);
    background: transparent;
    flex-direction: column; align-items: center; justify-content: flex-start;
  }
  #app:not(.liste) .dayhead .dnom,
  #app:not(.liste) .dayhead .dsum,
  #app:not(.liste) .dayhead .jnum,
  #app:not(.liste) .dayhead .dcaret,
  #app:not(.liste) .dayhead .dwx { display: none; }
  #app:not(.liste) .dayhead { width: 14px; }
  #app:not(.liste) .midi {
    position: static; flex: none; width: 0; height: auto; max-height: none;
    margin: 0 2px; padding: 0; align-self: stretch;
    border: none; border-left: 1px dotted var(--border, #d8d2c0);
    color: transparent; font-size: 0;
  }
  #app:not(.liste) .midi::after { display: none; }
  #app:not(.liste) .midi.cache { opacity: 1; border-color: var(--border, #d8d2c0); }
  #app:not(.liste) .sqplie { opacity: 1; }
  #app:not(.liste) .step.jfitem { padding: 9px 10px; margin: 0; }
  #app:not(.liste) .jfitem .steptitle { font-size: 13px; }
  #app:not(.liste) .jfitem .steptime, #app:not(.liste) .jfitem .stepday { font-size: 11px; }
  .step {
    flex: none; width: 74vw; max-width: 340px; margin: 0;
    scroll-snap-align: center;
    background: var(--card, #fffdf7); border-color: var(--border, #d8d2c0);
    max-height: none; overflow: hidden;
  }
  .stepday { display: inline; }
  /* ruban: toutes les cartes restent visibles, pas d'enroulement */
  #app:not(.liste) #steps .step.cache {
    max-height: none; opacity: 1; pointer-events: auto;
    padding: 9px 10px; border-color: var(--border, #d8d2c0);
  }
  #app:not(.liste) #steps .step.trajet.cache { border-color: var(--mc, var(--accent)); padding: 8px; }
  .step.trajet {
    width: 40vw; max-width: 170px;
    flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    border: 1px dashed var(--mc, var(--accent)); border-radius: 10px;
    background: var(--card, #fffdf7); padding: 6px 8px; margin: 0;
  }
  .step.trajet .tlieux { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.25; }
  /* la carte du ruban CENTRE le nom: nowrap le rognerait des deux côtés, on rend le repli */
  .tlieux { text-align: center; white-space: normal; }
    /* compact mais LISIBLE: titre sur 2 lignes max, lieu sur 1, notes masquées */
  .steptop { min-width: 0; }
  .steptitle {
    flex: 1 1 100%; min-width: 0;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden;
  }
  /* description en entier sur le ruban: la carte grandit avec son texte */
    
  #playbtn { left: 10px; bottom: 12px; width: 36px; height: 36px; }
  /* mini-polaroid mobile: en bas a gauche au-dessus du play, tap = plein ecran.
     #map #polaroid: specificite superieure aux regles de base qui vivent PLUS BAS
     dans le fichier (sinon left+right cumulés etirent la carte) */
  #map #polaroid { left: 10px; right: auto; bottom: 58px; padding: 4px 4px 3px; transform: rotate(-2deg); }
  #map #polaroid img { width: 92px; height: 64px; }
  #map #polaroid .pleg { display: none; }
  @keyframes sePose {
    from { opacity: 0; transform: rotate(3deg) translateY(12px) scale(.85); }
    to { opacity: 1; transform: rotate(-2deg) translateY(0) scale(1); }
  }
  /* mobile: la colonne de boutons flotte sur la carte, sous l'île dynamique:
     liste/carte, pluie, puis la baguette; l'export n'existe pas sur mobile.
     #pluiebtn vit dans #triphead (position:relative) mais doit flotter en haut à
     droite de la CARTE, donc position:fixed (relatif au viewport, pas à #triphead).
     z-index au-dessus de #plansheet (1300): la bascule reste possible feuille Plan ouverte. */
  #pluiebtn {
    position: fixed; top: calc(env(safe-area-inset-top) + 54px); right: 12px; z-index: 1400;
    width: 34px; height: 34px; font-size: 15px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .15);
  }
  #baguette {
    top: calc(env(safe-area-inset-top) + 98px); right: 10px;
    height: 34px; width: 34px;
  }
  #wandbtn { width: 26px; height: 26px; font-size: 14px; }
  #exportbtn { display: none; }

  /* bouton Plan: dans la ligne chronologique, juste sous le scrubber, poussé à droite */
  #app:not(.liste) #planbtn {
    display: inline-flex; align-items: center; justify-content: center;
    margin-left: auto; width: 22px; height: 22px; padding: 0;
    font: inherit; font-size: 11px; line-height: 1; color: var(--muted);
    background: var(--card, #fffdf7); border: 1px solid var(--border, #d8d2c0);
    border-radius: 50%; cursor: pointer;
  }

  /* bouton liste/carte: en haut à droite de l'écran, icône du mode où l'on va */
  #modebtn {
    display: block; position: absolute;
    top: calc(env(safe-area-inset-top) + 10px); right: 12px; z-index: 900;
    width: 34px; height: 34px; padding: 0;
    font: inherit; font-size: 15px; line-height: 1;
    background: var(--card, #fffdf7); border: 1px solid var(--border, #d8d2c0);
    border-radius: 50%; cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .15);
  }

  /* mode liste: fil vertical plein écran sans carte, pilules de jours actives */
  #app.liste #map { display: none; }
  #app.liste #timeline {
    flex: 1; min-height: 0; border-top: none;
    padding-top: env(safe-area-inset-top);
    grid-template-rows: auto minmax(0, 1fr);
  }
  #app.liste #scrub { display: none; }
  /* mode liste = la vue Plan du grand écran, plein écran (plus de cartes empilées) */
  #app.liste #steps { display: none !important; }
  #app.liste #plan {
    display: block; grid-row: 3; grid-column: 1 / 3;
    align-self: stretch; min-height: 0; overflow-y: auto; overflow-x: hidden;
    padding: 8px 14px calc(100dvh - 380px);
  }
  #app.liste #planbtn, #app:not(.liste) #planbtn { display: none; }
  #app.liste #steps.jamais {
    grid-row: 3; grid-column: 1 / 3;
    /* le grid mobile centre ses items (align-items): ici il faut étirer, sinon le fil
       déborde hors piste et ne scrolle jamais */
    align-self: stretch; min-height: 0;
    display: block; overflow-y: auto; overflow-x: hidden;
    scroll-snap-type: none;
    padding: 8px 14px calc(100dvh - 380px);
  }
  #app.liste .dayhead { display: flex; }
  #app.liste .leg { display: block; }
  #app.liste .midi { display: flex; }
  #app.liste .step {
    display: flex; width: auto; max-width: none; margin: 4px 0;
    background: transparent; border-color: transparent;
  }
  #app.liste .step.sel { background: var(--card, #fffdf7); border-color: var(--accent); }
  #app.liste .step.trajet {
    width: auto; max-width: none;
    flex-direction: row; align-items: baseline; justify-content: flex-start; gap: 8px;
    border: none; border-left: 3px dashed var(--mc, var(--accent)); border-radius: 0;
    background: transparent; padding: 6px 0 6px 16px; margin: 2px 0 2px 20px;
  }
  #app.liste .tlieux { text-align: left; }
  #app.liste   #app.liste   #app.liste .stepday { display: none; }
}

/* rideau du tour de chauffe au démarrage */
#rideau {
  position: absolute; inset: 0; z-index: 980;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background: var(--paper, #f3efe0);
}
#rideau .remoji { font-size: 34px; }
#rideau .rmsg { font-size: 12px; color: var(--muted); letter-spacing: .08em; }

/* --- le delice ------------------------------------------------------------ */
/* lumiere du jour: un voile teinte selon l'heure de l'evenement */
#lumiere {
  position: absolute; inset: 0; z-index: 4;
  pointer-events: none;
  transition: background 1.1s ease;
}
/* le voyageur: l'emoji qui parcourt un trajet */
#voyageur {
  position: absolute; left: 0; top: 0; z-index: 8;
  font-size: 20px; pointer-events: none;
  transform-origin: center;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .25));
  margin-left: -10px; margin-top: -10px;
}
/* pop elastique du marqueur selectionne, et la lune qui se leve sur un dodo */
.mk.sel { animation: mkpop .38s cubic-bezier(.3, 1.5, .5, 1); }
@keyframes mkpop {
  0% { transform: translate(-50%, -50%) scale(.7); }
  60% { transform: translate(-50%, -50%) scale(1.3); }
  100% { transform: translate(-50%, -50%) scale(1.18); }
}
.mk.sel i { animation: lune .55s ease-out; }
@keyframes lune {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}
/* J-n et le repere maintenant */
#jmoins {
  margin-left: auto;
  font-size: 11px; color: var(--accent, #c4621f); letter-spacing: .1em;
}
#scrub .maintenant {
  position: absolute; top: 4px; width: 2px; height: 18px;
  background: var(--ink, #111); opacity: .5;
  transform: translateX(-50%);
}
/* nous, pendant le voyage: un point qui pulse */
.anc.nous span {
  display: block; width: 14px; height: 14px; border-radius: 50%;
  background: #3d6ea5; border: 2.5px solid #fff;
  transform: translate(-50%, -50%);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .35);
  animation: pulse 2.2s ease-out infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(61, 110, 165, .45); }
  70% { box-shadow: 0 0 0 14px rgba(61, 110, 165, 0); }
  100% { box-shadow: 0 0 0 0 rgba(61, 110, 165, 0); }
}

/* le bouton play du mode presentation */
#playbtn {
  position: absolute; left: 12px; bottom: 14px; z-index: 950;
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--border, #d8d2c0); background: var(--card, #fffdf7);
  color: var(--accent, #c4621f); font-size: 18px; line-height: 1; cursor: pointer;
  box-shadow: 0 3px 10px rgba(0, 0, 0, .14);
  transition: transform .15s;
}
#playbtn:hover { transform: scale(1.08); }
#playbtn.joue { background: var(--accent, #c4621f); color: #fff; border-color: var(--accent, #c4621f); }

/* photo du lieu (appui long) et poster (carte bilan) */
#photovue, #postervue {
  position: fixed; inset: 0; z-index: 1500;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: rgba(24, 19, 12, .88);
  animation: apparait .22s ease-out;
}
#photovue[hidden], #postervue[hidden] { display: none; }
#photovue img, #postervue img {
  max-width: 92vw; max-height: 80vh; border-radius: 12px;
  box-shadow: 0 12px 50px rgba(0, 0, 0, .5);
}
#photovue .pcap { color: #f3efe0; font-size: 14px; letter-spacing: .04em; }
#posterpartage {
  font: inherit; font-size: 13px; cursor: pointer;
  background: var(--accent, #c4621f); color: #fff;
  border: none; border-radius: 999px; padding: 8px 22px;
}
@keyframes apparait { from { opacity: 0; } to { opacity: 1; } }
/* la carte bilan */
.step.bilan { border-style: dashed; border-color: var(--accent, #c4621f); background: var(--card, #fffdf7); }

/* feuille Plan (téléphone): overlay plein écran par-dessus la carte, safe-area respectée */
#plansheet {
  position: fixed; inset: 0; z-index: 1300;
  display: flex; flex-direction: column;
  background: var(--paper, #f3efe0);
  padding-top: env(safe-area-inset-top);
}
#plansheet[hidden] { display: none; }
#plansheet header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border, #d8d2c0);
  font-size: 13px; font-weight: 700; letter-spacing: .04em;
}
#plansheet .planclose {
  border: none; background: none; font-size: 16px; line-height: 1; color: var(--muted); cursor: pointer;
  padding: 4px 6px;
}
#plansheet .plansheetbody {
  flex: 1; overflow-y: auto;
  padding: 8px 14px calc(16px + env(safe-area-inset-bottom));
}

/* le polaroid: la photo du lieu posee en bas a droite de la carte (desktop) */
#polaroid {
  position: absolute; right: 16px; bottom: 16px; z-index: 940;
  background: #fffdf7; padding: 8px 8px 6px;
  border: 1px solid var(--border, #d8d2c0); border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .22);
  transform: rotate(-2.5deg);
  cursor: zoom-in;
}
#polaroid[hidden] { display: none; }
#polaroid img { display: block; width: 190px; height: 130px; object-fit: cover; border-radius: 3px; }
#polaroid .pleg { font-size: 11px; color: var(--muted); padding: 6px 2px 2px; letter-spacing: .04em; }
#polaroid.pose { animation: sePose .38s cubic-bezier(.3, 1.4, .5, 1); }
@keyframes sePose {
  from { opacity: 0; transform: rotate(3deg) translateY(14px) scale(.9); }
  to { opacity: 1; transform: rotate(-2.5deg) translateY(0) scale(1); }
}

/* téléphone en paysage: Plan à gauche, carte à droite, en-tête compacté, encoche respectée */
@media (orientation: landscape) and (max-height: 520px) {
  #timeline { width: 46vw; min-width: 300px; padding-left: env(safe-area-inset-left); }
  #triphead { padding: 6px 10px 4px; }
  #triphead h1 { font-size: 15px; }
  #triphead .sub { display: none; }
  #plan { padding: 0 10px 40vh; }
  .plancard { padding: 8px 10px; }
  #pluiebtn { width: 22px; height: 22px; font-size: 12px; }
}

/* bouton "y aller" (Google Maps, voiture) */
a.yaller { flex: none; margin-left: auto; padding: 0 7px; font-size: 12px; line-height: 20px; text-decoration: none; color: var(--ink, inherit); border: 1px solid var(--border, #d8d2c0); border-radius: 999px; background: var(--card, #fffdf7); }
a.yaller:hover { border-color: var(--accent); }

/* météo du jour (Open-Meteo): emoji + max/min, rien quand aucune prévision */
.dwx { white-space: nowrap; letter-spacing: .02em; text-transform: none; font-size: 11.5px; color: var(--muted); }
.dwx:empty { display: none; }
.dayhead .dwx { flex: none; }
#jourcap { white-space: nowrap; min-width: 0; }
#jourcap .jdate { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
#jourcap .jnum, #jourcap .dwx { flex: none; }
#heurecap { white-space: nowrap; flex: none; }
#jourcap .dwx { margin-left: 2px; letter-spacing: 0; font-size: 10.5px; }
.planhead { flex-wrap: nowrap; }
.planhead .ptrajet { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.planhead .jnum, .planhead .pmeta { flex: none; white-space: nowrap; }
.planhead .dwx { margin-left: auto; flex: none; }
