* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body { font: 14px/1.4 system-ui, sans-serif; }

#viewbox { position: fixed; inset: 0; overflow: hidden; background: #e8e8e8; touch-action: none; cursor: grab; }
#viewbox:active { cursor: grabbing; }
#map { position: absolute; top: 0; left: 0; will-change: transform; }
img.tile { position: absolute; width: 256px; height: 256px; user-select: none; -webkit-user-drag: none; opacity: 0; transition: opacity .15s linear; contain: layout paint style; }
img.tile.loaded, img.tile.stale, img.tile.fallback { opacity: 1; }
@media (prefers-reduced-motion: reduce) { img.tile { transition: none; } }
.marker { position: absolute; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: #ef4444; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.4); z-index: 5; }
/* pins emoji (domicile 🏠, travail 🏭) : pointe en bas au centre */
.marker.emoji { width: auto; height: auto; margin: 0; transform: translate(-50%, -90%); background: none; border: 0; box-shadow: none; font-size: 24px; line-height: 1; filter: drop-shadow(0 1px 2px rgba(0,0,0,.5)); }
canvas.overlay { position: absolute; top: 0; left: 0; pointer-events: none; z-index: 4; will-change: transform; }

#controls { display: contents; }
#search-box { position: fixed; top: 10px; left: 50%; transform: translateX(-50%); display: flex; height: 40px; background: rgba(255,255,255,.7); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); border-radius: 22px; box-shadow: 0 1px 5px rgba(0,0,0,.3); overflow: hidden; z-index: 10; transition: border-radius .25s ease; }
#s { border: 0; min-width: 0; padding: 0 16px; width: 260px; font: inherit; outline: none; background: transparent; transition: width .25s ease, padding .25s ease, opacity .2s ease; }
#bs { border: 0; width: 40px; cursor: pointer; color: transparent; background: transparent url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAARCAYAAADdRIy+AAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAAd0SU1FB9kCBxQkAPQ1ZpQAAAGrSURBVDjLjdRNiE5xFAbw372v14zvkEGsjLD20UghKTay1uykyEIWSpY2Stmp2dhMoWQ1USYbScrKhpKyGkVDNDaGfM21ed5ct/cOp/7dc+89/+c8z/k/9xYoUPkTu7EXm7EQM3iO+3jfp/6v6NTyJbiEY1iE13iXfB+O4BdeoAxo0Q+0yLqGCRxFt1GzChfDctR/xDncxY5ak7KW9+I8JjE8H9iagJ36R9Nek5u43FZUYicGcCv3ZQtYhTk8xFYsbgPcgGnM1jb1A+vFMwxifRtgmdOba1FR1WrhR8MhRRPwA9ZFdtlgVo9ewy34mn0a9inK+KrC4TA9EZvUZe7BweQHAvipoaKABXiVNYoHmeV1PMZbbMcmnIlHh/JuPHabCc7PurS1MfU4VmN5vozjYSdgE7iBFdlzG/u1zGlbvoaleIKnkTaEQ9iIjznhQVyNoiuYwli/wXdwEiOxU5W5vsQdPMLpzLMbT47F7NO4UPRhW9V+FgP4jO+NxiM4G6azebYMk50W+WWG/C12KRpefBO2u7AyDbuY6sxj5uYqatcCX3AvhzgcX479BrxnZh85IOwcAAAAAElFTkSuQmCC") no-repeat center / 16px; }
/* replié : juste la loupe dans un rond */
#search-box.collapsed { width: 40px; border-radius: 50%; justify-content: center; }
#search-box.collapsed #s { flex: 0 0 0; width: 0; min-width: 0; padding: 0; border: 0; opacity: 0; }
@media (prefers-reduced-motion: reduce) { #s { transition: none; } }

/* menu d'autocomplete (positionné en JS sous la barre) */
.ac-list { position: fixed; z-index: 20; background: rgba(255,255,255,.92); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); border-radius: 12px; box-shadow: 0 4px 16px rgba(0,0,0,.28); overflow-y: auto; max-height: 320px; }
.ac-list[hidden] { display: none; }
.ac-item { padding: 8px 14px; cursor: pointer; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ac-item:hover, .ac-item.active { background: rgba(37,99,235,.15); }

#layers { position: fixed; top: 10px; right: 10px; display: flex; flex-direction: column; gap: 4px; z-index: 10; align-items: stretch; width: max-content; }
.layer-btn { display: flex; align-items: center; gap: 6px; border: 0; background: rgba(255,255,255,.7); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); padding: 5px 8px; cursor: pointer; font: inherit; box-shadow: 0 1px 3px rgba(0,0,0,.3); border-radius: 4px; text-align: left; }
.layer-btn[hidden] { display: none; } /* sinon display:flex écrase l'attribut hidden */
.layer-btn .name { flex: 1; white-space: nowrap; }
.layer-btn .thumb { flex: 0 0 22px; width: 22px; height: 22px; border-radius: 3px; background: #dcd7cc center / cover no-repeat; box-shadow: inset 0 0 0 1px rgba(0,0,0,.25); }
#layers-list { display: flex; flex-direction: column; gap: 4px; }
#layers-list[hidden] { display: none; }
#layers-list .layer-btn { background: rgba(255,255,255,.4); }
#layers-list .layer-btn:hover { background: rgba(255,255,255,.7); }
.thumb[data-layer="plan"] { background-image: url("https://tile.openstreetmap.org/6/33/23.png"); }
.thumb[data-layer="sat"] { background-image: url("https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/6/23/33"); }
.thumb[data-layer="relief"] { background-image: url("https://tile.opentopomap.org/6/33/23.png"); }
.thumb[data-layer="toner"] { background-image: url("https://tiles.stadiamaps.com/tiles/stamen_toner/6/33/23.png"); }
.thumb[data-layer="aquarelle"] { background-image: url("https://tiles.stadiamaps.com/tiles/stamen_watercolor/6/33/23.jpg"); }

#geo-btn { position: fixed; bottom: 140px; right: 10px; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; border: 0; border-radius: 50%; background: rgba(255,255,255,.7); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); color: #4a4a4a; cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,.3); z-index: 11; }
#geo-btn:hover { color: #2563eb; }
#geo-btn.loading { opacity: .5; }
#share-btn { position: fixed; bottom: 188px; right: 10px; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; border: 0; border-radius: 50%; background: rgba(255,255,255,.7); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); color: #4a4a4a; cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,.3); z-index: 11; }
#share-btn:hover { color: #2563eb; }
#toast { position: fixed; bottom: 40px; left: 50%; transform: translateX(-50%) translateY(8px); background: rgba(30,30,30,.92); color: #fff; font-size: 13px; padding: 8px 16px; border-radius: 20px; z-index: 30; opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease; max-width: 80vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
/* globe animé pendant la recherche */
/* spinner CSS (0 octet, net à tout DPI) au lieu d'un GIF/AVIF chargé */
#bs.loading { background: #fff; color: transparent; position: relative; }
#bs.loading::after { content: ''; position: absolute; inset: 0; margin: auto; width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid rgba(0,0,0,.18); border-top-color: rgba(0,0,0,.55); animation: bs-spin .6s linear infinite; }
@keyframes bs-spin { to { transform: rotate(360deg); } }
/* échelle : bracket ⊔ dont la largeur correspond à la distance affichée */
#ladder { position: fixed; bottom: 10px; left: 10px; box-sizing: border-box; padding: 1px 2px 2px; font-size: 11px; line-height: 1.3; text-align: center; white-space: nowrap; color: #222; background: rgba(255,255,255,.6); border: 2px solid #333; border-top: 0; z-index: 10; }
#attribution { position: fixed; bottom: 0; right: 134px; background: rgba(255,255,255,.7); font-size: 11px; padding: 2px 6px; z-index: 10; }
#attribution a { color: #333; }

/* échelle de zoom en pyramide (cliquable) */
#zoombar { position: fixed; top: 6px; left: 0; width: 34px; height: 200px; z-index: 10; }
.pz { position: absolute; left: 6px; height: 0; border-top: 6px solid #fffff0; opacity: .5; cursor: pointer; filter: drop-shadow(0 0 1px rgba(0,0,0,.7)); }
.pz:hover { border-top-color: #fff; opacity: 1; }

/* --- Mantan : carburant, rayon, moins chère, fiche station --- */
#fuel-btn { position: fixed; bottom: 236px; right: 10px; min-width: 40px; height: 40px; padding: 0 12px; border: 0; border-radius: 20px; background: rgba(255,255,255,.7); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); color: #15803d; font: 600 13px/1 system-ui, sans-serif; cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,.3); z-index: 11; }
#prefs { position: fixed; bottom: 284px; right: 10px; width: 220px; padding: 12px 14px; border-radius: 14px; background: rgba(255,255,255,.85); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); box-shadow: 0 4px 16px rgba(0,0,0,.28); z-index: 12; }
#prefs[hidden] { display: none; }
.prefs-title { font-weight: 600; font-size: 13px; margin: 6px 0 4px; }
#fuel-list label { display: inline-flex; align-items: center; gap: 4px; margin: 2px 8px 2px 0; font-size: 13px; cursor: pointer; }
#radius { width: 100%; accent-color: #16a34a; }
#profile-btn { width: 100%; margin-top: 10px; border: 0; border-radius: 10px; padding: 8px; background: rgba(22,163,74,.12); color: #15803d; font: 600 13px/1 system-ui, sans-serif; cursor: pointer; }
#profile { position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%); width: min(340px, calc(100vw - 24px)); max-height: 80vh; overflow-y: auto; padding: 16px 18px; border-radius: 16px; background: rgba(255,255,255,.94); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); box-shadow: 0 8px 32px rgba(0,0,0,.35); z-index: 26; }
#profile[hidden] { display: none; }
.pf-close { position: absolute; top: 10px; right: 10px; width: 32px; height: 32px; border: 0; border-radius: 50%; background: rgba(0,0,0,.06); cursor: pointer; font-size: 14px; }
#profile p { font-size: 13px; color: #444; }
#profile label { display: block; font-size: 13px; font-weight: 600; margin: 10px 0 2px; }
#profile input[type="text"], #profile input[type="email"], #profile select { width: 100%; padding: 8px 10px; border: 1px solid rgba(0,0,0,.15); border-radius: 8px; font: inherit; background: #fff; }
#profile input[type="range"] { width: 100%; accent-color: #16a34a; }
.pf-check { display: flex; align-items: center; gap: 6px; }
.pf-check input { accent-color: #16a34a; }
.pf-email { font-size: 13px; color: #666; margin-bottom: 4px; }
.pf-login-btn, .pf-save { width: 100%; margin-top: 12px; border: 0; border-radius: 10px; padding: 11px; background: #16a34a; color: #fff; font: 600 14px/1 system-ui, sans-serif; cursor: pointer; }
.pf-logout { width: 100%; margin-top: 8px; border: 0; border-radius: 10px; padding: 9px; background: rgba(0,0,0,.06); color: #555; font: 600 13px/1 system-ui, sans-serif; cursor: pointer; }
.sheet-trend { font-size: 13px; font-weight: 600; margin: 4px 0; }
.sheet-trend.up { color: #b91c1c; }
.sheet-trend.down { color: #15803d; }
.sheet-trend:empty { display: none; }
.sheet-spark { width: 100%; height: 36px; display: block; }
#best-btn { position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%); height: 44px; padding: 0 18px; border: 0; border-radius: 22px; background: #16a34a; color: #fff; font: 600 14px/1 system-ui, sans-serif; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,.35); z-index: 11; white-space: nowrap; }
#best-btn.loading { opacity: .6; }
#hint { position: fixed; top: 60px; left: 50%; transform: translateX(-50%); background: rgba(30,30,30,.8); color: #fff; font-size: 13px; padding: 6px 14px; border-radius: 16px; z-index: 9; pointer-events: none; }
#hint[hidden] { display: none; }
#sheet { position: fixed; left: 0; right: 0; bottom: 0; max-height: 60vh; overflow-y: auto; background: rgba(255,255,255,.92); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border-radius: 18px 18px 0 0; box-shadow: 0 -4px 20px rgba(0,0,0,.3); padding: 16px 18px calc(16px + env(safe-area-inset-bottom)); z-index: 25; }
#sheet[hidden] { display: none; }
.sheet-close { position: absolute; top: 10px; right: 10px; width: 32px; height: 32px; border: 0; border-radius: 50%; background: rgba(0,0,0,.06); cursor: pointer; font-size: 14px; }
.sheet-title { font-size: 17px; font-weight: 700; padding-right: 36px; }
.sheet-addr { color: #555; font-size: 13px; margin-top: 2px; }
.sheet-dist { color: #15803d; font-size: 13px; font-weight: 600; margin-top: 2px; }
.sheet-dist:empty { display: none; }
.sheet-prices { margin: 10px 0; }
.price-row { display: flex; align-items: baseline; gap: 8px; padding: 4px 0; border-bottom: 1px solid rgba(0,0,0,.06); }
.price-row span:first-child { flex: 1; }
.price-row span:nth-child(2) { font-variant-numeric: tabular-nums; font-weight: 600; }
.price-row small { color: #999; font-size: 11px; min-width: 105px; text-align: right; }
.price-row.pref { background: rgba(22,163,74,.08); border-radius: 6px; padding: 4px 6px; font-weight: 700; color: #15803d; }
.sheet-actions { display: flex; gap: 10px; margin-top: 8px; }
.sheet-go, .sheet-go-alt { flex: 1; text-align: center; padding: 11px 0; border-radius: 12px; text-decoration: none; font-weight: 600; }
.sheet-go { background: #16a34a; color: #fff; }
.sheet-go-alt { background: rgba(0,0,0,.06); color: #333; }
.sheet-go-alt[hidden] { display: none; }

/* minimap : vue régionale (tuiles) + rectangle de cadrage */
#lmap { position: fixed; right: 0; bottom: 0; width: 128px; height: 128px; overflow: hidden; border-top: 1px solid #000; border-left: 1px solid #000; z-index: 10; cursor: pointer; background: #aad3df; }
#lmap_tiles { position: absolute; inset: 0; opacity: .9; }
#lmap_tiles img { image-rendering: auto; }
#mask_lmap { position: absolute; border: 2px solid #ef4444; box-sizing: border-box; pointer-events: none; z-index: 2; }
