:root {
  --blue: #0f3d5e; --terra: #c8442b; --sand: #f6f1ea; --ink: #1d2733; --muted: #64707d;
  --line: #e3dcd2; --card: #fff; --panel-w: 420px;
  --c-trail: #c8442b; --c-route: #0f6fb5; --c-rando: #2e8b57; --c-vtt: #d98b00; --c-urbain: #7a4ea3;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink);
  background: var(--sand); display: flex; flex-direction: column; }
[hidden] { display: none !important; }

.top { background: var(--blue); color: #fff; display: flex; align-items: center; gap: 16px; padding: 10px 16px; flex: none; }
.brand { color: #fff; text-decoration: none; font-weight: 600; font-size: 20px; display: flex; align-items: center; gap: 8px; letter-spacing: -.2px; }
.brand b { color: #ffb4a3; font-weight: 700; }
.logo { width: 26px; height: 26px; border-radius: 7px; background: var(--terra) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M5 23l7-11 5 7 3-4 7 8z' fill='%23fff'/%3E%3C/svg%3E") center/cover; }
.tagline { opacity: .75; flex: 1; }

.btn { font: inherit; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; }
.btn:hover { border-color: #bdb3a4; }
.btn.primary { background: var(--terra); border-color: var(--terra); color: #fff; font-weight: 600; }
.btn.primary:hover { background: #b03a23; }
.btn.primary:disabled { opacity: .5; cursor: not-allowed; }
.btn.link { background: none; border: 0; color: var(--blue); padding: 4px 0; text-decoration: underline; justify-self: start; }

main { flex: 1; display: flex; min-height: 0; }
#panel { width: var(--panel-w); flex: none; overflow-y: auto; background: var(--sand); border-right: 1px solid var(--line); }
#map { flex: 1; min-width: 0; position: relative; z-index: 0; }

#filters { padding: 14px; display: grid; gap: 10px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
#filters label, #filters legend { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
#filters label { display: grid; gap: 3px; }
input[type=search], input[type=text], input[type=number], select, textarea, input[type=file] {
  font: inherit; color: var(--ink); width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row.between { align-items: end; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.range { display: grid; grid-template-columns: 1fr auto 1fr; gap: 6px; align-items: center; }
fieldset.range legend { grid-column: 1 / -1; padding: 0; margin-bottom: 3px; }
.check { display: flex !important; align-items: center; gap: 6px; text-transform: none !important; font-weight: 500 !important; font-size: 13px !important; color: var(--ink) !important; }
.sort { text-transform: none; }
.sort select { padding: 5px 8px; }

.chips legend { padding: 0; margin-bottom: 4px; }
#type-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.chip span { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 99px; border: 1px solid var(--line); background: #fff; font-size: 13px; }
.chip span::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.chip input:checked + span { background: var(--c); border-color: var(--c); color: #fff; }
.chip input:checked + span::before { background: #fff; }
.chip input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 2px; }

#count { padding: 10px 14px 4px; color: var(--muted); font-size: 13px; }
#list { list-style: none; margin: 0; padding: 6px 12px 24px; display: grid; gap: 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--c, var(--terra)); border-radius: 10px; padding: 11px 13px; cursor: pointer; transition: box-shadow .15s, transform .15s; }
.card:hover, .card.hl { box-shadow: 0 4px 14px rgba(15, 61, 94, .16); transform: translateY(-1px); }
.card h3 { margin: 0 0 2px; font-size: 16px; line-height: 1.25; }
.card .where { color: var(--muted); font-size: 13px; }
.stats { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 7px; font-size: 14px; }
.stats b { font-weight: 700; }
.stats small { color: var(--muted); font-size: 12px; }
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; color: #fff; background: var(--c); vertical-align: middle; margin-left: 4px; }
.badge.neutral { background: #8a8174; }
.empty { padding: 30px 14px; text-align: center; color: var(--muted); }

#view-detail { padding: 14px; }
.back { margin-bottom: 8px; }
#view-detail h2 { margin: 6px 0 2px; font-size: 22px; line-height: 1.2; }
.big-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; }
.big-stats div { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; }
.big-stats b { display: block; font-size: 19px; }
.big-stats small { color: var(--muted); font-size: 12px; }
#profile-wrap { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px; position: relative; }
#profile { width: 100%; height: 150px; display: block; touch-action: none; }
#profile-tip { position: absolute; top: 6px; right: 10px; font-size: 12px; color: var(--muted); }
.desc { white-space: pre-wrap; margin: 14px 0; }
.meta { color: var(--muted); font-size: 13px; }
.actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }
#view-detail .actions { justify-content: flex-start; }
a.btn { text-decoration: none; display: inline-block; }

dialog { border: 0; border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 24px)); box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
dialog::backdrop { background: rgba(15, 30, 45, .55); }
#upload-form { padding: 20px; display: grid; gap: 12px; max-height: 92vh; overflow-y: auto; }
#upload-form h2 { margin: 0; }
#upload-form label { display: grid; gap: 4px; font-weight: 600; font-size: 13px; }
.analysis { background: var(--sand); border-radius: 8px; padding: 10px 12px; font-size: 14px; }
.analysis.warn { background: #fff4d6; }
.hint { color: var(--muted); font-size: 12px; margin: 0; }
.error { color: #b00020; margin: 0; font-weight: 600; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

.mtabs { display: none; }
.leaflet-container { font: inherit; }
.pin { width: 14px; height: 14px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.5); }

@media (max-width: 820px) {
  .tagline { display: none; }
  .top { justify-content: space-between; }
  main { position: relative; }
  #panel, #map { position: absolute; inset: 0; width: auto; border: 0; }
  body:not(.show-map) #map { visibility: hidden; }
  body.show-map #panel { visibility: hidden; }
  .mtabs { display: flex; flex: none; background: #fff; border-top: 1px solid var(--line); }
  .mtabs button { flex: 1; padding: 13px; border: 0; background: none; font: inherit; font-weight: 600; color: var(--muted); }
  .mtabs button.on { color: var(--terra); box-shadow: inset 0 3px 0 var(--terra); }
  .row { grid-template-columns: 1fr; }
  #filters .row:has(.range) { grid-template-columns: 1fr 1fr; }
}
