:root {
  --bg:#f2f5f0; --fg:#18261b; --muted:#66756a; --card:#ffffff; --line:#dfe6df;
  --accent:#2f5d3a; --accent-soft:#dcefdc; --accent2:#a8d5a2; --danger:#b3261e; --shadow:0 2px 10px rgba(20,40,25,.08);
}
@media (prefers-color-scheme: dark) {
  :root { --bg:#111a13; --fg:#e8efe8; --muted:#9aa89d; --card:#1b271d; --line:#2c3a2e; --accent:#5fa36f; --accent-soft:#233b28; --accent2:#7fbf87; --shadow:0 2px 10px rgba(0,0,0,.4); }
}
* { box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
html, body { height:100%; }
body { margin:0; font-family:-apple-system,system-ui,"Segoe UI",Roboto,sans-serif; background:var(--bg); color:var(--fg); display:flex; flex-direction:column; }
header { background:#2f5d3a; color:#fff; padding:calc(env(safe-area-inset-top) + 10px) 16px 10px; }
.bar { display:flex; align-items:center; justify-content:space-between; }
header h1 { margin:0; font-size:1.1rem; font-weight:700; display:flex; align-items:center; gap:10px; letter-spacing:-.01em; }
header h1 .i { width:22px; height:22px; }
.chip { background:rgba(255,255,255,.18); color:#fff; border:0; border-radius:20px; padding:6px 12px; font-size:.85rem; display:flex; gap:6px; align-items:center; margin:0; width:auto; }
.chip.busy #sync-icon .i { animation:spin 1s linear infinite; }
#sync-icon { display:flex; }
@keyframes spin { to { transform:rotate(360deg); } }
main { flex:1; overflow-y:auto; padding:14px 16px calc(80px + env(safe-area-inset-bottom)); max-width:640px; width:100%; margin:0 auto; }
nav { position:fixed; bottom:0; left:0; right:0; display:flex; background:var(--card); border-top:1px solid var(--line); padding-bottom:env(safe-area-inset-bottom); z-index:20; }
nav button { flex:1; background:none; border:0; color:var(--muted); font-size:.75rem; padding:8px 4px 6px; margin:0; display:flex; flex-direction:column; align-items:center; gap:2px; border-radius:0; }
nav button .i { width:22px; height:22px; margin-bottom:2px; }
nav button.active { color:var(--accent); font-weight:700; }
nav em { font-style:normal; background:var(--accent); color:#fff; border-radius:10px; padding:0 6px; font-size:.7rem; margin-left:4px; }
.view { display:none; animation:fade .2s ease; } .view.active { display:block; }
@keyframes fade { from { opacity:0; transform:translateY(4px); } to { opacity:1; transform:none; } }
.hidden { display:none !important; }
.card { background:var(--card); border-radius:16px; padding:16px; box-shadow:var(--shadow); margin-bottom:14px; }
.i { width:1.15em; height:1.15em; flex:none; fill:none; stroke:currentColor; stroke-width:2; stroke-linecap:round; stroke-linejoin:round; }
button { display:flex; align-items:center; justify-content:center; gap:10px; cursor:pointer; border:0; border-radius:14px; padding:14px 16px; font-size:1rem; width:100%; margin-top:10px; font-weight:600; background:var(--accent-soft); color:var(--accent); transition:transform .08s; }
button:active { transform:scale(.98); }
button:disabled { opacity:.45; }
button.primary { background:var(--accent); color:#fff; }
button.big { font-size:1.2rem; padding:20px; }
button.secondary { background:var(--card); color:var(--accent); border:2px solid var(--accent); }
button.link { background:none; color:var(--muted); font-weight:500; text-decoration:underline; padding:8px; }
button.danger { background:var(--danger); color:#fff; }
input[type=text], input[type=password], input[type=number], input[type=url], input[type=search] { width:100%; padding:13px 14px; border:1px solid var(--line); border-radius:12px; font-size:1rem; margin-top:6px; background:var(--card); color:var(--fg); }
label { display:block; margin-top:12px; font-weight:600; font-size:.9rem; }
.hint { color:var(--muted); margin:0 0 12px; line-height:1.45; } .small { font-size:.85rem; } .center { text-align:center; }
.stepper { list-style:none; display:flex; padding:0; margin:0 0 14px; gap:6px; counter-reset:s; }
.stepper li { flex:1; text-align:center; font-size:.8rem; color:var(--muted); padding:8px 0 8px; border-bottom:3px solid var(--line); }
.stepper li::before { counter-increment:s; content:counter(s); display:inline-block; width:20px; height:20px; border-radius:50%; background:var(--line); color:var(--fg); font-size:.75rem; line-height:20px; margin-right:6px; vertical-align:middle; }
.stepper li.on { color:var(--accent); font-weight:700; border-color:var(--accent); }
.stepper li.on::before { background:var(--accent); color:#fff; }
.stepper li.done { border-color:var(--accent2); } .stepper li.done::before { content:""; background:var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center/12px no-repeat; }
.ring { width:120px; height:120px; margin:10px auto; position:relative; }
.ring svg { width:100%; height:100%; transform:rotate(-90deg); }
.ring circle { fill:none; stroke-width:3.5; } .ring .bg { stroke:var(--line); } .ring .fg { stroke:var(--accent); stroke-dasharray:100.5; stroke-dashoffset:100.5; transition:stroke-dashoffset .5s linear; }
#gps-acc { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; font-weight:700; font-size:1.3rem; }
#mini-map { height:260px; border-radius:12px; margin:8px 0; background:var(--line); }
.photo-grid { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.photo-slot { position:relative; aspect-ratio:1; background:var(--card); border:2px dashed var(--line); border-radius:16px; display:flex; align-items:center; justify-content:center; overflow:hidden; margin:0; font-weight:600; box-shadow:var(--shadow); }
.photo-slot input { position:absolute; inset:0; opacity:0; width:100%; height:100%; }
.photo-slot img { position:absolute; inset:0; width:100%; height:100%; object-fit:cover; display:none; }
.photo-slot.filled { border-style:solid; border-color:var(--accent); } .photo-slot.filled img { display:block; }
.photo-slot span { position:relative; z-index:1; display:flex; flex-direction:column; align-items:center; gap:8px; color:var(--muted); font-size:.85rem; font-weight:600; }
.photo-slot span .i { width:30px; height:30px; stroke-width:1.5; color:var(--accent); }
.photo-slot.filled span { position:absolute; left:8px; bottom:8px; flex-direction:row; gap:5px; background:rgba(0,0,0,.55); color:#fff; padding:4px 8px; border-radius:8px; font-size:.75rem; backdrop-filter:blur(4px); }
.photo-slot.filled span .i { width:14px; height:14px; color:#fff; stroke-width:2; }
.photo-slot .x { display:none; position:absolute; top:8px; right:8px; z-index:2; background:rgba(0,0,0,.55); color:#fff; width:28px; height:28px; border-radius:50%; align-items:center; justify-content:center; backdrop-filter:blur(4px); }
.photo-slot .x .i { width:14px; height:14px; }
.photo-slot.filled .x { display:flex; }
.status { color:var(--muted); }
.status.loading::before { content:""; display:inline-block; width:14px; height:14px; border:2px solid var(--accent); border-right-color:transparent; border-radius:50%; margin-right:8px; vertical-align:-2px; animation:spin .8s linear infinite; }
.results { list-style:none; padding:0; margin:12px 0 0; }
.results li { background:var(--card); border-radius:14px; padding:12px; margin-top:8px; display:flex; align-items:center; gap:12px; box-shadow:var(--shadow); position:relative; overflow:hidden; }
.results li::after { content:""; position:absolute; left:0; bottom:0; height:3px; background:var(--accent2); width:var(--w,0); }
.results li .ph { width:60px; height:60px; border-radius:10px; background:var(--accent-soft); color:var(--accent); display:flex; align-items:center; justify-content:center; flex:none; } .results li .ph .i { width:26px; height:26px; stroke-width:1.5; }
.results li img, .thumb { width:60px; height:60px; object-fit:cover; border-radius:10px; background:var(--line); flex:none; }
.results li .name { flex:1; min-width:0; } .results li .name b { display:block; } .results li .name i { color:var(--muted); font-size:.85rem; }
.results li .score { font-weight:800; color:var(--accent); font-size:1.05rem; }
.results li.best { border:2px solid var(--accent); }
.chosen { display:flex; gap:12px; align-items:center; } .chosen b { display:block; font-size:1.15rem; } .chosen i { color:var(--muted); display:block; }
.pill { display:inline-block; background:var(--accent-soft); color:var(--accent); border-radius:10px; padding:2px 8px; font-size:.8rem; margin-top:4px; }
.stats { display:flex; gap:8px; overflow-x:auto; padding:10px 0; }
.stats span { flex:none; background:var(--card); border-radius:20px; padding:6px 12px; font-size:.85rem; box-shadow:var(--shadow); white-space:nowrap; }
.stats span b { color:var(--accent); }
#tree-list { list-style:none; padding:0; margin:0; }
#tree-list li { background:var(--card); border-radius:14px; padding:10px; margin-top:8px; display:flex; gap:12px; align-items:center; box-shadow:var(--shadow); }
#tree-list li .info { flex:1; min-width:0; } #tree-list li .info b { display:block; } #tree-list li .info small { color:var(--muted); display:block; }
#tree-list li .dot { width:10px; height:10px; border-radius:50%; flex:none; }
#tree-list li .del, #tree-list li .dupb { width:auto; margin:0; padding:10px; background:none; color:var(--muted); }
#tree-list li .del .i, #tree-list li .dupb .i { width:18px; height:18px; }
#tree-list li .unsynced { font-size:.75rem; color:#b8860b; display:flex !important; align-items:center; gap:4px; }
#tree-list li .unsynced .i { width:12px; height:12px; }
.links { display:flex; gap:8px; margin-bottom:10px; }
.btn-link { flex:1; display:flex; align-items:center; justify-content:center; gap:8px; padding:12px; border-radius:14px; background:var(--accent); color:#fff; font-weight:600; text-decoration:none; }
#map { height:calc(100vh - 250px); border-radius:16px; box-shadow:var(--shadow); }
.legend { display:flex; flex-wrap:wrap; gap:6px; padding:10px 0; }
.legend span { font-size:.75rem; background:var(--card); border-radius:12px; padding:3px 8px; display:flex; align-items:center; gap:5px; }
.legend i { width:10px; height:10px; border-radius:50%; display:inline-block; }
.tree-marker { width:16px; height:16px; border-radius:50%; border:2px solid #fff; box-shadow:0 0 0 1px rgba(0,0,0,.3); }
.leaflet-popup-content img { width:100%; border-radius:8px; margin-top:6px; }
.toolbar { margin-top:16px; }
#toast { position:fixed; bottom:calc(84px + env(safe-area-inset-bottom)); left:50%; transform:translateX(-50%); background:var(--fg); color:var(--bg); padding:10px 18px; border-radius:20px; z-index:100; font-size:.9rem; max-width:90vw; text-align:center; }
#viewer { position:fixed; inset:0; background:rgba(0,0,0,.92); z-index:200; display:flex; align-items:center; justify-content:center; }
#viewer img { max-width:100%; max-height:100%; } #viewer button { position:absolute; top:20px; right:20px; width:44px; height:44px; border-radius:50%; background:rgba(255,255,255,.2); color:#fff; padding:0; margin:0; display:flex; align-items:center; justify-content:center; }
.loc-btn { width:34px; height:34px; padding:0; margin:0; background:#fff; color:#18261b; display:flex; align-items:center; justify-content:center; border-radius:4px; }
.loc-btn .i { width:18px; height:18px; }
.gps-live { display:flex; align-items:center; gap:8px; font-size:.85rem; font-weight:600; color:var(--muted); background:var(--bg); border-radius:10px; padding:8px 12px; margin-bottom:12px; }
.gps-live .dot { width:10px; height:10px; border-radius:50%; background:#9aa39c; flex:none; }
.gps-live.good .dot { background:#2e9e4f; box-shadow:0 0 0 4px rgba(46,158,79,.2); } .gps-live.mid .dot { background:#e0a100; } .gps-live.bad .dot { background:#d0342c; }
.gps-live.good { color:#2e7d43; }
.seg { display:flex; background:var(--accent-soft); border-radius:12px; padding:3px; margin:4px 0 8px; }
.seg button { flex:1; margin:0; padding:8px 4px; border-radius:9px; background:none; color:var(--accent); font-size:.8rem; font-weight:600; }
.seg button.on { background:var(--accent); color:#fff; }
.mini-top { width:14px; height:14px; border-radius:50%; background:rgba(255,255,255,.95); border:3px solid #1f6f3a; box-shadow:0 1px 4px rgba(0,0,0,.5); }
.mini-tree { width:12px; height:12px; border-radius:50%; border:2px solid #fff; box-shadow:0 0 0 1px rgba(0,0,0,.4); }
.mini-lbl { background:rgba(0,0,0,.65); color:#fff; border:0; box-shadow:none; font-size:10px; font-weight:600; padding:1px 5px; border-radius:6px; }
.mini-lbl::before { display:none; }
.aim { width:44px; height:44px; border-radius:50%; border:3px solid #e8412c; background:rgba(232,65,44,.12); box-shadow:0 0 0 2px #fff, 0 2px 8px rgba(0,0,0,.4); position:relative; }
.aim::before, .aim::after { content:""; position:absolute; background:#e8412c; } .aim::before { left:50%; top:-10px; bottom:-10px; width:2px; margin-left:-1px; } .aim::after { top:50%; left:-10px; right:-10px; height:2px; margin-top:-1px; }
.aim i { position:absolute; left:50%; top:50%; width:6px; height:6px; margin:-3px 0 0 -3px; border-radius:50%; background:#fff; border:1px solid #e8412c; z-index:1; }
.banner { background:#fff4d6; color:#5b4200; border:1px solid #f0d58a; border-radius:14px; padding:12px 14px; margin-bottom:14px; font-size:.88rem; line-height:1.4; display:flex; flex-direction:column; gap:4px; }
.banner button { margin-top:6px; }
@media (prefers-color-scheme: dark) { .banner { background:#3a3016; color:#f3dfa6; border-color:#5c4a1c; } }

/* Vues 3D / plan en plein écran (pages intégrées), menu du bas conservé */
body.immersive header { display:none; }
body.immersive main { padding:0; max-width:none; overflow:hidden; }
.view.frame { position:fixed; left:0; right:0; top:0; bottom:var(--nav-h, 60px); padding:0; animation:none; }
.view.frame iframe { width:100%; height:100%; border:0; display:block; background:#1d2a20; }
.seg.list-mode { display:flex; gap:6px; margin-bottom:12px; }
.seg.list-mode button { margin:0; padding:10px; font-size:.9rem; background:var(--card); color:var(--muted); border:1px solid var(--line); }
.seg.list-mode button.on { background:var(--accent); color:#fff; border-color:var(--accent); }
.banner.dup { background:var(--accent-soft); color:var(--fg); border-color:var(--accent2); }
.banner.dup b { display:block; margin-bottom:2px; }

/* Amas d'arbres (plusieurs sujets de la même espèce au même endroit) */
.clump { padding:12px 14px; }
.clump-row { display:flex; align-items:center; justify-content:space-between; gap:10px; font-size:.9rem; font-weight:600; }
.nstep { display:flex; align-items:center; gap:10px; }
.nstep button { width:40px; height:40px; margin:0; padding:0; border-radius:50%; font-size:1.3rem; }
.nstep b { min-width:22px; text-align:center; font-size:1.15rem; }
.clump label { font-size:.85rem; font-weight:500; color:var(--muted); }
.clump input[type=range] { width:100%; accent-color:var(--accent); }
.water-lbl { color:#1f5fbf !important; font-style:italic; }
