:root {
  --green: #2f5d3a;
  --green-2: #4c8a58;
  --brown: #7a4a22;
  --bg: #ffffff;
  --text: #1f2421;
  --muted: #6b736d;
  --line: #e4e7e3;
  --soft: #f3f5f2;
  --danger: #b3261e;
  --shadow: 0 6px 24px rgba(0,0,0,.18);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #1b1f1c; --text: #eef1ee; --muted: #a2aba4; --line: #323833; --soft: #252a26; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg); }
button { font: inherit; cursor: pointer; }
#map { position: fixed !important; inset: 0; width: 100%; height: 100%; }
.hidden { display: none !important; }

.topbar {
  position: fixed; top: calc(10px + var(--safe-top)); left: 12px; right: 12px;
  display: flex; justify-content: space-between; align-items: center; pointer-events: none; z-index: 5;
}
.brand { pointer-events: auto; background: var(--green); color: #fff; font-weight: 800; letter-spacing: .3px; padding: 9px 14px; border-radius: 999px; box-shadow: var(--shadow); }
.avatar-btn { pointer-events: auto; width: 42px; height: 42px; border-radius: 50%; border: 2px solid #fff; background: var(--bg); box-shadow: var(--shadow); padding: 0; overflow: hidden; font-size: 18px; }
.avatar-btn img { width: 100%; height: 100%; object-fit: cover; }

.filters { position: fixed; top: calc(62px + var(--safe-top)); left: 12px; display: flex; gap: 6px; z-index: 5; }
.chip { border: 0; background: var(--bg); color: var(--text); padding: 7px 12px; border-radius: 999px; box-shadow: 0 2px 8px rgba(0,0,0,.15); font-size: 14px; }
.chip.active { background: var(--green); color: #fff; }

.fab { position: fixed; right: 16px; bottom: calc(22px + var(--safe-bottom)); width: 60px; height: 60px; border-radius: 50%; border: 0; background: var(--brown); color: #fff; font-size: 30px; box-shadow: var(--shadow); z-index: 5; }
.fab-small { width: 46px; height: 46px; font-size: 22px; bottom: calc(94px + var(--safe-bottom)); right: 23px; background: var(--bg); color: var(--green); }

.crosshair { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -100%); font-size: 40px; z-index: 4; pointer-events: none; filter: drop-shadow(0 3px 3px rgba(0,0,0,.4)); }
.place-bar { position: fixed; left: 12px; right: 12px; bottom: calc(16px + var(--safe-bottom)); background: var(--bg); border-radius: 16px; padding: 14px; box-shadow: var(--shadow); z-index: 6; text-align: center; }
.place-bar .row { display: flex; gap: 8px; margin-top: 10px; }
.place-bar .btn { flex: 1; }

.btn { border: 0; background: var(--green); color: #fff; padding: 12px 16px; border-radius: 12px; font-weight: 600; }
.btn.ghost { background: var(--soft); color: var(--text); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn.small { padding: 7px 10px; font-size: 14px; border-radius: 9px; }
.btn:disabled { opacity: .5; }

.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.25); z-index: 9; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; max-height: 82vh; overflow-y: auto; z-index: 10;
  background: var(--bg); border-radius: 20px 20px 0 0; box-shadow: var(--shadow);
  padding: 8px 18px calc(22px + var(--safe-bottom)); animation: up .18s ease-out;
}
@media (min-width: 700px) { .sheet { left: auto; right: 16px; bottom: 16px; width: 420px; border-radius: 20px; max-height: calc(100vh - 32px); } }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.grip { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 4px auto 10px; }
.sheet-close { position: absolute; top: 10px; right: 12px; border: 0; background: var(--soft); color: var(--text); width: 32px; height: 32px; border-radius: 50%; }
.sheet h2 { margin: 4px 40px 4px 0; font-size: 21px; }
.sheet h3 { font-size: 15px; margin: 18px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.meta { color: var(--muted); font-size: 14px; }
.desc { margin: 10px 0; line-height: 1.4; }

label { display: block; font-size: 14px; font-weight: 600; margin: 12px 0 5px; }
input[type=text], textarea {
  width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--soft); color: var(--text); font: inherit; font-size: 16px;
}
textarea { min-height: 70px; resize: vertical; }
.actions { display: flex; gap: 8px; margin-top: 16px; }
.actions .btn { flex: 1; }

.crit { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.crit:last-child { border-bottom: 0; }
.stars { display: inline-flex; gap: 2px; }
.stars button { border: 0; background: none; font-size: 24px; padding: 2px; color: var(--line); line-height: 1; }
.stars button.on { color: #e0a412; }
.bar { flex: 1; height: 8px; background: var(--soft); border-radius: 8px; margin: 0 10px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--green-2); border-radius: 8px; }
.score { font-weight: 700; min-width: 32px; text-align: right; }
.big-score { font-size: 34px; font-weight: 800; color: var(--green); }

.review { padding: 10px 0; border-top: 1px solid var(--line); }
.review .who { font-weight: 600; }
.review .mini { color: var(--muted); font-size: 13px; }

.list-item { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.list-item img, .list-item .ph { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: var(--soft); display: grid; place-items: center; }
.list-item .grow { flex: 1; }
.row-inline { display: flex; gap: 8px; }
.row-inline input { flex: 1; }
.empty { color: var(--muted); font-size: 14px; padding: 6px 0; }

.toast { position: fixed; left: 50%; bottom: calc(100px + var(--safe-bottom)); transform: translateX(-50%); background: #222; color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 20; font-size: 14px; max-width: 90vw; text-align: center; }

/* Marqueurs */
.pin { display: grid; place-items: center; transform: translate(-50%, -100%); }
.pin .bubble { min-width: 34px; height: 34px; padding: 0 6px; border-radius: 17px; display: grid; place-items: center; font-weight: 800; font-size: 13px; color: #fff; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.35); }
.pin .tail { width: 0; height: 0; border-left: 6px solid transparent; border-right: 6px solid transparent; border-top: 8px solid #fff; margin-top: -1px; }
.pin.friend .bubble { outline: 3px solid #3b82f6; }
.pin.mine .bubble { outline: 3px solid #e0a412; }

.login-wrap { display: flex; justify-content: center; margin: 18px 0 6px; min-height: 44px; }

.me-dot { width: 16px; height: 16px; border-radius: 50%; background: #3b82f6; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(59,130,246,.25); transform: translate(-50%, -50%); }

/* Avatars */
.av { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex: none; background: var(--soft); }
.av-ph { display: inline-grid; place-items: center; font-size: 14px; }
.av-xl { width: 88px; height: 88px; border-radius: 50%; object-fit: cover; background: var(--soft); border: 3px solid var(--green-2); display: grid; place-items: center; font-size: 38px; }
.who-btn { display: inline-flex; align-items: center; gap: 8px; border: 0; background: none; color: var(--text); padding: 2px 0; text-align: left; }
.who-btn .who { font-weight: 600; }
.who-btn.author { margin: 4px 0 2px; font-size: 14px; }

/* Profil */
.profile-head { display: flex; gap: 16px; align-items: center; margin: 4px 40px 12px 0; }
.profile-av { position: relative; flex: none; }
.av-edit { position: absolute; right: -2px; bottom: -2px; width: 32px; height: 32px; border-radius: 50%; background: var(--brown); color: #fff; display: grid; place-items: center; font-size: 15px; cursor: pointer; margin: 0; border: 2px solid var(--bg); }
.profile-id h2 { margin: 0 0 4px; }
.grade-badge { display: inline-block; background: var(--green); color: #fff; font-weight: 700; font-size: 13px; padding: 4px 10px; border-radius: 999px; margin-bottom: 4px; }
.pill { display: inline-block; font-size: 13px; padding: 5px 10px; border-radius: 999px; background: var(--soft); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 6px 0 14px; }
.stat { background: var(--soft); border-radius: 12px; padding: 10px 6px; text-align: center; }
.stat b { display: block; font-size: 22px; color: var(--green-2); }
.stat span { font-size: 12px; color: var(--muted); }
.progress-wrap { margin-bottom: 4px; }
.progress-label { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.progress { height: 10px; background: var(--soft); border-radius: 10px; overflow: hidden; margin-bottom: 6px; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--green-2), #e0a412); border-radius: 10px; }
.meta.small { font-size: 12px; margin-top: 2px; }
.meta.center { text-align: center; }
.list-item.link { width: 100%; border: 0; border-top: 1px solid var(--line); background: none; color: var(--text); text-align: left; font: inherit; }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.actions.wrap { flex-wrap: wrap; }

/* Photos */
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.thumb { position: relative; width: 72px; height: 72px; border-radius: 10px; overflow: hidden; background: var(--soft); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb.add { display: grid; place-items: center; font-size: 28px; color: var(--muted); border: 2px dashed var(--line); cursor: pointer; margin: 0; font-weight: 400; }
.thumb-x { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(0,0,0,.65); color: #fff; font-size: 11px; padding: 0; }
.gallery { display: flex; gap: 6px; overflow-x: auto; margin: 10px 0; padding-bottom: 4px; scroll-snap-type: x mandatory; }
.gallery img { height: 120px; width: auto; max-width: 180px; object-fit: cover; border-radius: 10px; flex: none; scroll-snap-align: start; cursor: zoom-in; }
.review-photos { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.review-photos img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; cursor: zoom-in; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.9); z-index: 30; display: grid; place-items: center; padding: 16px; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }
