:root {
  --ink: #2b2723;
  --chalk: #fffdf8;
  --paper: #f6efe1;
  --muted: #8c8274;
  --fill: #f1e9da;
  --line: #e6dac3;
  --accent: #e2552d;
  --sun: #ffd84d;
  --lift: 0 2px 0 rgba(43, 39, 35, .12);
  --display: Jost, Futura, "Avenir Next", system-ui, sans-serif;
  --panel-w: 400px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 500 13px/1.5 Inter, system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
img { display: block; max-width: 100%; }
.muted { color: var(--muted); }
.hidden, [hidden] { display: none !important; }

/* Boutons et champs : coins nets, pas d'ombre */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 14px; border: 1px solid var(--ink);
  background: var(--chalk); border-radius: 0; text-decoration: none; white-space: nowrap;
}
.btn.solid { background: var(--ink); color: var(--chalk); }
.btn.ghost { border-color: var(--line); }
.btn.small { min-height: 30px; padding: 0 10px; }
.btn:disabled { opacity: .4; cursor: default; }
.btn.done { background: var(--fill); border-color: var(--fill); color: var(--muted); }
.field { display: grid; gap: 4px; }
.field > span { color: var(--muted); }
.input, textarea.input, select.input {
  width: 100%; min-height: 40px; padding: 9px 10px; border: 1px solid var(--line);
  border-radius: 0; background: var(--chalk);
}
textarea.input { min-height: 80px; resize: vertical; }
.input:focus { outline: none; border-color: var(--ink); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px;
  border: 1px solid var(--line); background: var(--chalk); border-radius: 0;
}
.chip[aria-pressed="true"] { border-color: var(--ink); }
.chip[aria-pressed="false"] { color: var(--muted); }
.sq { width: 8px; height: 8px; flex: none; display: inline-block; }

/* ---------- Carte publique ---------- */
.app { position: fixed; inset: 0; }
#map { position: absolute; inset: 0; background: #f2f1ed; }

/* En-tête : nom + menu, puis les deux usages */
.top {
  position: absolute; z-index: 5; display: grid; gap: 6px; pointer-events: none;
  top: calc(12px + env(safe-area-inset-top, 0px)); left: 12px; width: min(420px, calc(100% - 24px));
}
.top > * { pointer-events: auto; }
.brandrow { display: flex; gap: 6px; }
.brand { flex: 1; background: var(--chalk); padding: 9px 12px; line-height: 1.25; text-decoration: none; }
.brand b { font-weight: 600; }
.brand span { color: var(--muted); }
.iconbtn { width: 40px; min-height: 40px; border: 0; background: var(--chalk); font-size: 16px; }
.modes { display: flex; background: var(--chalk); }
.modes button { flex: 1; height: 42px; border: 0; background: none; color: var(--muted); font-weight: 600; }
.modes button[aria-selected="true"] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--ink); }
.modes i { font-style: normal; display: inline-block; min-width: 18px; margin-left: 6px; padding: 0 5px; background: var(--fill); color: var(--ink); }
.modes .gift i.on { background: var(--accent); color: #fff; }

/* Bande de photos synchronisée avec la carte */
.strip {
  position: absolute; z-index: 5; left: 0; right: 0; bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none;
  padding: 0 max(12px, calc(50% - 170px));
}
.strip::-webkit-scrollbar { display: none; }
.card {
  flex: none; width: min(340px, 82vw); scroll-snap-align: center; display: grid; grid-template-columns: 96px 1fr; gap: 12px;
  padding: 8px; background: var(--chalk); border: 0; text-align: left; cursor: pointer;
}
.card.on { outline: 2px solid var(--ink); outline-offset: -2px; }
.card img { width: 96px; height: 96px; object-fit: cover; background: var(--fill); }
.card .t { display: grid; align-content: start; gap: 2px; min-width: 0; }
.card b { font-size: 14px; line-height: 1.3; }
.card .row2 { display: flex; gap: 6px; margin-top: 6px; }
.card .row2 a, .card .row2 span { border: 1px solid var(--ink); padding: 2px 9px; font-size: 12px; text-decoration: none; }
.card .row2 .solid { background: var(--ink); color: var(--chalk); }
.card.gone img { filter: grayscale(1); opacity: .7; }
.card.empty { grid-template-columns: 1fr; cursor: default; }
.fresh { color: var(--accent); }

.menu { position: absolute; z-index: 7; top: calc(60px + env(safe-area-inset-top, 0px)); left: 12px; width: min(420px, calc(100% - 24px)); background: var(--chalk); display: grid; }
.menu button, .menu a { text-align: left; padding: 12px 14px; border: 0; border-top: 1px solid var(--line); background: none; text-decoration: none; }
.menu button:first-child { border-top: 0; }
.menu .muted { display: block; font-size: 12px; }

.panel {
  position: absolute; z-index: 6; top: 12px; right: 12px; bottom: 12px; width: var(--panel-w);
  background: var(--chalk); overflow-y: auto; overscroll-behavior: contain;
  transform: translateX(calc(100% + 24px)); transition: transform .25s ease;
}
body.panel-open .panel { transform: none; }
body.panel-open .strip { display: none; }
.panel-close { position: sticky; top: 0; z-index: 2; display: flex; justify-content: flex-end; height: 0; }
.panel-close button { width: 40px; height: 40px; border: 0; background: var(--chalk); font-size: 18px; }
.pad { padding: 16px; }
.stack > * + * { margin-top: 12px; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--muted); }
.meta .sq { margin-right: 2px; }
h1, h2, h3 { font-size: 13px; font-weight: 600; margin: 0; }
h2.big { font-size: 17px; font-weight: 600; line-height: 1.3; }
p { margin: 0; }
.sep { border-top: 1px solid var(--line); }

/* Galerie de la fiche */
.gallery { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; background: var(--fill); }
.gallery figure { flex: none; width: 100%; margin: 0; scroll-snap-align: start; position: relative; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.gallery figcaption { position: absolute; left: 0; bottom: 12px; }
.tag { background: var(--chalk); padding: 3px 8px; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.gone-img { filter: grayscale(1) contrast(.9); opacity: .7; }

/* Avant / après */
.compare { position: relative; aspect-ratio: 1; overflow: hidden; background: var(--fill); user-select: none; }
.compare img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.compare .after { clip-path: inset(0 0 0 var(--cut, 50%)); }
.compare .bar { position: absolute; top: 0; bottom: 0; left: var(--cut, 50%); width: 2px; background: var(--chalk); }
.compare input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: ew-resize; margin: 0; }
.compare .l, .compare .r { position: absolute; top: 12px; }
.compare .l { left: 12px; } .compare .r { right: 12px; }

/* Historique */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 74px 1fr; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.timeline li:first-child { border-top: 0; }
.timeline time { color: var(--muted); }
.timeline img { width: 72px; height: 72px; object-fit: cover; margin-top: 6px; }
.badge { display: inline-block; padding: 0 6px; background: var(--fill); }
.badge.dark { background: var(--ink); color: var(--chalk); }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.actions .wide { grid-column: 1 / -1; }
.signal { display: grid; gap: 6px; padding: 12px; background: var(--fill); }

/* Marqueurs */
.marker { width: 46px; height: 46px; padding: 3px; background: var(--chalk); cursor: pointer; }
.marker img { width: 100%; height: 100%; object-fit: cover; }
.marker .sq { position: absolute; right: -3px; top: -3px; width: 10px; height: 10px; border: 2px solid var(--chalk); box-sizing: content-box; }
.marker.gone { opacity: .55; }
.marker.gone img { filter: grayscale(1); }
.marker.zone { width: 34px; height: 34px; display: grid; place-items: center; padding: 0; font-weight: 600; }
.marker .cnt { position: absolute; left: -6px; top: -8px; min-width: 18px; height: 18px; padding: 0 4px; display: grid; place-items: center; background: var(--ink); color: var(--chalk); font-size: 10px; font-weight: 600; }
.marker { position: absolute; }
.card .seen { color: var(--ink); font-size: 12px; }
.seen-big { font-size: 13px; }
.seen-big b { font-size: 22px; font-weight: 600; margin-right: 4px; }
.book { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.book li { border-top: 1px solid var(--line); padding-top: 8px; }
.book li:first-child { border-top: 0; padding-top: 0; }
.book p { margin-top: 2px; }
.marker.giftpin { background: var(--accent); }
.marker.active { width: 62px; height: 62px; outline: 2px solid var(--ink); z-index: 2; }
.marker.found::after { content: '✓'; position: absolute; left: -6px; bottom: -6px; width: 18px; height: 18px; display: grid; place-items: center; background: var(--ink); color: var(--chalk); font-size: 11px; }
.city-marker { background: var(--ink); color: var(--chalk); padding: 6px 10px; cursor: pointer; white-space: nowrap; }
.me-dot { width: 16px; height: 16px; border-radius: 50%; background: #2c6bed; border: 3px solid var(--chalk); }

/* Liste */
.list { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 10px; }
.list button { text-align: left; border: 0; padding: 0; background: none; }
.list img { width: 100%; aspect-ratio: 1; object-fit: cover; margin-bottom: 6px; background: var(--fill); }

/* Chasse */
.progress { display: flex; gap: 3px; }
.progress i { flex: 1; height: 4px; background: var(--fill); }
.progress i.on { background: var(--ink); }
.clue { padding: 14px; background: var(--fill); }
.quiz { display: grid; gap: 6px; }
.quiz button { text-align: left; min-height: 40px; padding: 8px 12px; border: 1px solid var(--line); background: var(--chalk); }
.quiz button.right { border-color: #3c7a5a; background: #e8f1ec; }
.quiz button.wrong { border-color: var(--accent); background: #f8e7e2; }
.lesson { padding: 14px; border: 1px solid var(--ink); }
.hunt-card { display: block; width: 100%; text-align: left; padding: 14px; border: 1px solid var(--line); background: var(--chalk); }
.hunt-card:hover { border-color: var(--ink); }

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 50; transform: translateX(-50%);
  background: var(--ink); color: var(--chalk); padding: 10px 14px; max-width: calc(100% - 32px);
}

.maplibregl-ctrl-attrib { font-size: 10px; }

@media (max-width: 760px) {
  :root { --panel-w: 100%; }
  .panel {
    top: auto; left: 0; right: 0; bottom: 0; width: 100%; max-height: 86vh;
    transform: translateY(105%); padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .card { grid-template-columns: 80px 1fr; }
  .card img { width: 80px; height: 80px; }
}


/* ---------- Habillage « stickers sur papier » ---------- */
#map { background: var(--paper); }
.btn { border-radius: 10px; font-family: var(--display); font-weight: 600; }
.input, textarea.input, select.input, .chip { border-radius: 10px; }
h2.big { font-family: var(--display); font-size: 21px; }
h3 { font-family: var(--display); font-size: 15px; }
.brand, .iconbtn, .modes, .menu, .legend, .card { border-radius: 14px; box-shadow: var(--lift); }
.brand { font-family: var(--display); font-size: 15px; }
.modes { padding: 3px; gap: 3px; }
.modes button { border-radius: 11px; font-family: var(--display); height: 38px; }
.modes button[aria-selected="true"] { background: var(--sun); box-shadow: none; }
.modes i { border-radius: 8px; }
.legend { justify-self: start; display: flex; gap: 12px; padding: 6px 10px; background: var(--chalk); font-size: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 13px; height: 13px; border-radius: 4px; }
.legend .f { background: var(--accent); }
.legend .o { border: 2px solid var(--ink); background: var(--chalk); }
.menu { overflow: hidden; }

/* Repères : un sticker par œuvre, l'icône dit le type */
.marker {
  width: 44px; height: 44px; padding: 0; display: grid; place-items: center; cursor: pointer;
  background: var(--chalk); color: var(--ink); border: 2.5px solid var(--ink); border-radius: 12px; box-shadow: 0 3px 0 rgba(43, 39, 35, .2);
}
.marker > svg { width: 26px; height: 26px; }
/* Pas de rotate/scale CSS ici : appliqués avant le transform de MapLibre, ils déplaceraient le repère. */
.marker.take { background: var(--accent); color: #fff; border-color: #fff; }
.marker.eph { border-style: dashed; }
.marker.active { outline: none; z-index: 3; width: 58px; height: 58px; }
.marker.active > svg { width: 32px; height: 32px; }
.marker.gone { opacity: .5; }
.marker .cnt { left: auto; right: -9px; top: -9px; min-width: 22px; height: 22px; border-radius: 11px; border: 2px solid #fff; background: var(--ink); color: #fff; font: 700 10px/1 var(--display); }
.marker .tag-take { position: absolute; left: 50%; top: calc(100% + 4px); transform: translateX(-50%); white-space: nowrap; padding: 3px 6px; border-radius: 6px; background: var(--accent); color: #fff; font: 700 9px/1 var(--display); letter-spacing: .05em; text-transform: uppercase; }
.marker.found::after { left: -8px; bottom: -8px; border-radius: 50%; background: #3c7a5a; border: 2px solid #fff; }

/* Bande de cartes */
.card { border-radius: 16px; }
.card img, .card .ph { border-radius: 10px; }
.card .ph { width: 96px; height: 96px; display: grid; place-items: center; background: var(--fill); color: var(--ink); }
.card .ph svg { width: 46px; height: 46px; }
.card b { font-family: var(--display); font-size: 15px; }
.card .kind { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.card.take .kind { color: var(--accent); }
.card .row2 a, .card .row2 span { border-radius: 9px; font-family: var(--display); font-weight: 600; }
.card.on { outline: 2.5px solid var(--ink); }

/* Fiche */
.panel { border-radius: 18px; box-shadow: var(--lift); }
.gallery { border-radius: 18px 18px 0 0; overflow-x: auto; }
.panel-close button { border-radius: 0 18px 0 12px; }
.badge { border-radius: 6px; }
.signal, .clue, .lesson, .hunt-card, .quiz button { border-radius: 12px; }
.seen-big b { font-family: var(--display); font-size: 18px; font-weight: 600; }
.toast { border-radius: 12px; font-family: var(--display); }

@media (max-width: 760px) {
  .card .ph { width: 80px; height: 80px; }
  .panel { border-radius: 18px 18px 0 0; }
}

/* Tout ce que j'ai donné */
.given { padding: 12px; border-radius: 12px; background: var(--fill); }
.given-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.given-list button { display: grid; grid-template-columns: 64px 1fr; gap: 12px; width: 100%; padding: 0; border: 0; background: none; text-align: left; }
.given-list img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; background: var(--fill); }
.given-list b { font-family: var(--display); }

/* Repère avec photo : la photo remplit le sticker, le type en pastille */
.marker.photo { width: 52px; height: 52px; padding: 0; background: var(--chalk); border: 3px solid var(--chalk); outline: 2.5px solid var(--ink); }
/* La photo est calée dans le cadre (en grille, une photo en portrait débordait par le bas). */
.marker.photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 9px; display: block; }
.marker.photo.take { outline-color: var(--accent); }
.marker.photo .ti { position: absolute; right: -8px; bottom: -8px; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: var(--chalk); color: var(--ink); border: 2px solid var(--ink); }
.marker.photo.take .ti { background: var(--accent); color: #fff; border-color: #fff; }
.marker.photo .ti svg { width: 13px; height: 13px; }
.marker.photo.active { width: 68px; height: 68px; outline: 2.5px solid var(--ink); }
.marker.photo.take.active { outline-color: var(--accent); }
.marker.photo .tag-take { top: calc(100% + 8px); }

/* Vue de loin : stickers réduits, sans pastilles (elles reviennent en zoomant) */
body.far .marker { width: 34px; height: 34px; border-width: 2px; border-radius: 9px; }
body.far .marker > svg { width: 18px; height: 18px; }
body.far .marker.photo { width: 36px; height: 36px; border-width: 2px; }
body.far .marker.photo img { border-radius: 7px; }
body.far .marker .ti, body.far .marker .cnt, body.far .marker .tag-take { display: none; }
body.far .marker.active { width: 46px; height: 46px; }
body.far .marker.photo.active { width: 52px; height: 52px; }

/* Simplification : carte = photo, titre, une ligne, Google Maps */
.card { grid-template-columns: 84px 1fr; align-items: center; }
.card img, .card .ph { width: 84px; height: 84px; }
.card .t { gap: 4px; }
.card .line { font-size: 13px; color: var(--muted); }
.card .line.hot { color: var(--accent); }
.card .maps { justify-self: start; margin-top: 4px; padding: 4px 10px; border-radius: 9px; background: var(--ink); color: var(--chalk); font: 600 12px/1.3 var(--display); text-decoration: none; }
.panel .meta { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.links { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.linkbtn { border: 0; background: none; padding: 4px 0; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; font-size: 13px; }
.hist summary { cursor: pointer; font: 600 15px/1.3 var(--display); list-style: none; }
.hist summary::after { content: ' +'; color: var(--muted); }
.hist[open] summary::after { content: ' −'; }
.hist .timeline { margin-top: 10px; }
@media (max-width: 760px) {
  .card img, .card .ph { width: 72px; height: 72px; }
  .card { grid-template-columns: 72px 1fr; }
}

/* Sans photo : une bande avec l'icône, pas un grand carré vide */
.gallery.nophoto img { aspect-ratio: 3 / 1; object-fit: contain; padding: 18px 0; background: var(--fill); }
