:root {
  --ink: #14262B;
  --ink-2: #3F5258;
  --bg: #EDF1EF;
  --card: #FFFFFF;
  --line: #CFD9D6;
  --accent: #E4572E;     /* départ, actions principales */
  --blue: #2457FF;       /* tracé GPX */
  --ok: #1E8E5A;
  --warn: #B45309;
  --danger: #B42318;
  --r: 14px;
  --font: ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 16px/1.45 var(--font); -webkit-tap-highlight-color: transparent; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.05rem; margin: 22px 0 8px; }
h3 { font-size: 1.15rem; }
h4 { font-size: .95rem; margin: 18px 0 6px; color: var(--ink-2); }
a { color: inherit; }
.muted { color: var(--ink-2); font-size: .9rem; }
.warn-t { color: var(--warn); }
.empty { text-align: center; color: var(--ink-2); padding: 32px 12px; }
ul.plain { list-style: none; margin: 0; padding: 0; }

/* ---- boutons & champs ---- */
.btn { appearance: none; border: 0; background: var(--ink); color: #fff; font: inherit; font-weight: 600; padding: 12px 18px; border-radius: 12px; text-decoration: none; display: inline-flex; justify-content: center; align-items: center; cursor: pointer; min-height: 46px; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.danger { background: var(--danger); }
.btn.ghost.danger { background: transparent; color: var(--danger); }
.btn.small { min-height: 34px; padding: 6px 12px; font-size: .88rem; border-radius: 10px; }
.btn.wide { width: 100%; background: var(--accent); }
.link { background: none; border: 0; color: var(--blue); font: inherit; text-decoration: underline; padding: 0; cursor: pointer; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; background: var(--card); text-decoration: none; font-size: 1.6rem; line-height: 1; box-shadow: 0 1px 4px rgba(20,38,43,.2); flex: none; }
label { display: grid; gap: 6px; font-weight: 600; font-size: .92rem; }
input, select { font: inherit; font-weight: 400; padding: 11px 12px; border-radius: 10px; border: 1.5px solid var(--line); background: #fff; color: var(--ink); width: 100%; min-height: 46px; }
input:focus-visible, select:focus-visible, .btn:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
label.check { display: flex; gap: 10px; align-items: center; font-weight: 500; }
label.check input { width: 22px; min-height: 22px; }
.stack { display: grid; gap: 14px; }
.row { display: flex; gap: 10px; justify-content: flex-end; }
.tag { display: inline-block; font-size: .76rem; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: #E3EAE8; color: var(--ink-2); }
.tag.dark { background: var(--ink); color: #fff; }
.tag.warn { background: #FDE9C8; color: var(--warn); }
.tag.live { background: #D5F2E3; color: var(--ok); }

/* ---- pages ---- */
.page { max-width: 560px; margin: 0 auto; padding: calc(14px + var(--safe-t)) 16px calc(28px + var(--safe-b)); min-height: 100%; }
.bar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.bar h1 { flex: 1; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 8px; }
.card { display: block; background: var(--card); border-radius: var(--r); padding: 14px 16px; margin: 0 0 10px; text-decoration: none; box-shadow: 0 1px 0 var(--line); border: 1px solid var(--line); }
.card .c-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.card .tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.card:active { background: #F6F9F8; }

.auth { max-width: 420px; margin: 0 auto; padding: calc(28px + var(--safe-t)) 20px 40px; display: grid; gap: 18px; }
.brand { text-align: center; display: grid; gap: 8px; justify-items: center; }
.brand img { border-radius: 16px; }
.brand p { margin: 0; color: var(--ink-2); }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: #DDE5E2; border-radius: 12px; padding: 4px; }
.seg button { border: 0; background: transparent; font: inherit; font-weight: 600; padding: 10px; border-radius: 9px; color: var(--ink-2); cursor: pointer; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.code-box { font: 700 1.7rem/1.2 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .08em; text-align: center; background: #fff; border: 2px dashed var(--ink); border-radius: var(--r); padding: 22px 10px; user-select: all; }

.prof-top { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.av-edit { position: relative; cursor: pointer; display: block; }
.av-badge { position: absolute; left: 50%; bottom: -8px; transform: translateX(-50%); font-size: .72rem; font-weight: 700; background: var(--ink); color: #fff; padding: 2px 10px; border-radius: 99px; }

/* ---- avatar ---- */
.av { --s: 40px; --c: var(--line); width: var(--s); height: var(--s); border-radius: 50%; display: inline-grid; place-items: center; overflow: hidden; background: #C9D6D2; color: var(--ink); font-weight: 700; box-shadow: 0 0 0 3px var(--c); flex: none; }
.av img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---- écran carte ---- */
.sess { position: fixed; inset: 0; background: #dfe6e2; }
#map { position: absolute; inset: 0; }
.top { position: absolute; top: calc(10px + var(--safe-t)); left: 10px; right: 10px; display: flex; gap: 10px; align-items: center; pointer-events: none; z-index: 5; }
.top > * { pointer-events: auto; }
.ttl { background: var(--card); border-radius: 12px; padding: 6px 12px; box-shadow: 0 1px 4px rgba(20,38,43,.2); min-width: 0; display: grid; }
.ttl b, .ttl span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ttl span { font-size: .78rem; color: var(--ink-2); }
.fabs { position: absolute; right: 10px; bottom: calc(var(--sheet-h, 130px) + 12px); display: grid; gap: 10px; z-index: 4; }
.fab { width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--card); font-size: 1.25rem; box-shadow: 0 1px 5px rgba(20,38,43,.3); cursor: pointer; }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; background: var(--card); border-radius: 20px 20px 0 0; box-shadow: 0 -4px 18px rgba(20,38,43,.22); padding-bottom: var(--safe-b); z-index: 6; display: flex; flex-direction: column; max-height: 62dvh; }
.actbar { padding: 12px 14px 4px; min-height: 52px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.state { font-size: .95rem; }
.tabs { display: flex; gap: 4px; padding: 4px 10px 8px; }
.tabs button { flex: 1; border: 0; background: transparent; font: inherit; font-weight: 600; padding: 9px 6px; border-radius: 10px; color: var(--ink-2); cursor: pointer; }
.tabs button.on { background: var(--ink); color: #fff; }
.pane { overflow: auto; border-top: 1px solid var(--line); overscroll-behavior: contain; }
.pane.open { border-top: 0; }
.pane-in { padding: 14px 16px 22px; }
#o-box { padding: 14px 16px 20px; display: grid; gap: 10px; }
.sess > .sheet > #o-box { max-height: 60dvh; overflow: auto; }

/* ---- repères sur la carte ---- */
.pin { --c: #888; width: 42px; height: 42px; padding: 0; border: 0; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 4px var(--c), 0 2px 8px rgba(0,0,0,.4); display: grid; place-items: center; overflow: hidden; cursor: pointer; color: #fff; font-weight: 700; border: 3px solid #fff; }
.pin img { width: 100%; height: 100%; object-fit: cover; }
.pin.self { box-shadow: 0 0 0 4px var(--c), 0 0 0 9px rgba(36,87,255,.28), 0 2px 8px rgba(0,0,0,.4); }
.pin.stale { opacity: .55; filter: grayscale(.6); }
.dot { width: 18px; height: 18px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.dot.start { background: var(--ok); }
.dot.end { background: var(--ink); }
.maplibregl-popup-content { border-radius: 14px; padding: 12px 14px; font-family: var(--font); }
.pop { display: grid; gap: 6px; min-width: 190px; }
.pn { font-weight: 800; font-size: 1.05rem; }
.pb { display: flex; gap: 8px; margin-top: 2px; }
.pst { border-top: 1px solid var(--line); padding-top: 8px; display: grid; gap: 4px; }
.kv { display: flex; justify-content: space-between; gap: 12px; font-size: .9rem; }
.kv span { color: var(--ink-2); }

/* ---- onglet parcours ---- */
.hero { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.hero div { background: var(--bg); border-radius: 12px; padding: 10px; display: grid; gap: 2px; }
.hero small { color: var(--ink-2); font-size: .72rem; }
.hero b { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.cmp { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; margin-bottom: 12px; }
.cmp th { text-align: right; font-size: .8rem; color: var(--ink-2); font-weight: 600; padding: 4px 0; }
.cmp td { padding: 7px 0; border-top: 1px solid var(--line); text-align: right; }
.cmp td:first-child, .cmp th:first-child { text-align: left; font-weight: 600; }
.prof { width: 100%; height: auto; display: block; margin: 6px 0; }
.prof-fill { fill: #CFE0D3; stroke: #5E8A6B; stroke-width: 1.4; }
.modes { display: grid; gap: 6px; margin-bottom: 8px; }
.mode { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1.5px solid var(--line); border-radius: 12px; font-weight: 400; }
.mode:has(input:checked) { border-color: var(--ink); background: #F3F7F6; }
.mode input { width: 20px; min-height: 20px; margin-top: 3px; flex: none; }
.mode span { display: grid; gap: 1px; }
.mode em { font-style: normal; font-weight: 700; font-variant-numeric: tabular-nums; }
.mode small { color: var(--ink-2); font-size: .78rem; }

/* ---- onglet groupe ---- */
.code-row { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.code-s { font: 700 1.25rem ui-monospace, Menlo, monospace; letter-spacing: .1em; flex: 1; }
ul.plain li { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); }
ul.plain li > div { flex: 1; min-width: 0; }
.file { border: 1.5px dashed var(--line); border-radius: 12px; padding: 12px; }
.file input { border: 0; padding: 6px 0 0; min-height: 0; }
progress { width: 100%; height: 10px; }

dialog { border: 0; border-radius: 18px; padding: 0; width: min(92vw, 420px); box-shadow: 0 10px 40px rgba(0,0,0,.35); color: var(--ink); }
dialog::backdrop { background: rgba(20,38,43,.5); }
.dlg { padding: 20px; margin: 0; }

#toast { position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 12px; font-size: .92rem; max-width: 88vw; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50; text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media (min-width: 720px) { .sheet { left: auto; right: 16px; bottom: 16px; width: 400px; border-radius: 20px; max-height: 80dvh; } .fabs { right: 430px; bottom: 16px; } }
