/* ── AUTH WALL ───────────────────────────────── */
.auth-wall {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.auth-wall.hidden { display: none; }
.auth-card {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px 28px;
  text-align: center;
}
.auth-logo { font-size: 48px; margin-bottom: 14px; }
.auth-card h1 { font-size: 21px; font-weight: 800; margin-bottom: 4px; }
.auth-sub { font-size: 13px; color: var(--muted); margin-bottom: 26px; }
.auth-field { margin-bottom: 13px; text-align: left; }
.auth-field label { display: block; font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 6px; letter-spacing: .03em; }
.auth-field input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 15px;
  padding: 11px 14px;
  font-family: inherit;
  transition: border-color .15s;
}
.auth-field input:focus { outline: none; border-color: var(--accent); }
.auth-submit {
  width: 100%;
  margin-top: 6px;
  padding: 13px;
  background: var(--accent);
  color: #1b1b1f;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
.auth-error { font-size: 13px; color: var(--red); margin-top: 11px; min-height: 18px; }
.user-chip-header { font-size: 11px; color: var(--muted); margin-top: 2px; display: flex; align-items: center; gap: 6px; }
.logout-link { background: none; border: none; color: var(--muted); font-size: 11px; cursor: pointer; padding: 0; font-family: inherit; text-decoration: underline; }
.auth-version { display:inline-block; font-size:10px; letter-spacing:.05em; color:var(--muted); background:rgba(255,255,255,0.06); border:1px solid rgba(255,255,255,0.12); border-radius:100px; padding:2px 10px; margin-bottom:16px; cursor:pointer; font-family:inherit; transition:background .15s, border-color .15s; }
.auth-version:hover { background:rgba(255,255,255,.12); border-color:rgba(255,255,255,.3); }
#changelogDialog { border:none; border-radius:18px; background:var(--card); color:var(--text); padding:0; width:88%; max-width:340px; box-shadow:0 16px 48px rgba(0,0,0,.5); }
#changelogDialog::backdrop { background:rgba(0,0,0,.55); }
.changelog-content { padding:24px 20px 20px; }
.changelog-title { font-size:17px; font-weight:800; margin-bottom:16px; }
.changelog-list { list-style:none; padding:0; margin:0 0 20px; display:flex; flex-direction:column; gap:10px; }
.changelog-list li { font-size:13px; display:flex; gap:10px; align-items:baseline; }
.changelog-badge { font-size:10px; font-weight:700; color:var(--accent); background:rgba(255,122,24,.12); border-radius:20px; padding:2px 8px; white-space:nowrap; flex-shrink:0; }
.changelog-close { width:100%; padding:12px; background:var(--card-alt); border:1px solid var(--border); border-radius:10px; color:var(--text); font-size:14px; font-weight:600; cursor:pointer; font-family:inherit; }
.auth-switch { background:none; border:none; color:var(--muted); font-size:13px; cursor:pointer; margin-top:14px; display:block; width:100%; font-family:inherit; text-align:center; padding:0; text-decoration:underline; }

:root {
  --bg: #15161a;
  --card: #1f2127;
  --card-alt: #25282f;
  --text: #f2f2f4;
  --muted: #9a9ca4;
  --accent: #ff7a18;
  --green: #36c98a;
  --red: #ef5868;
  --border: #2e3038;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 90px;
  -webkit-tap-highlight-color: transparent;
}

header {
  padding: 18px 16px 12px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
  border-bottom: 1px solid var(--border);
}

header h1 {
  margin: 0 0 4px;
  font-size: 20px;
  letter-spacing: 0.5px;
}

.tabs {
  display: flex;
  position: sticky;
  top: 57px;
  z-index: 4;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 12px 8px;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  border-bottom: 2px solid transparent;
}

.tab-btn.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.page { display: none; }
.page.active { display: block; }

.ravito-intro {
  padding: 14px 16px 4px;
}

.ravito-intro .primary {
  width: 100%;
}

.ravito-note {
  font-size: 11px;
  color: var(--muted);
  margin: 8px 0 0;
  text-align: center;
}

.ravito-list {
  padding: 8px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ravito-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.ravito-item.past {
  opacity: 0.4;
}

.ravito-item.active {
  background: linear-gradient(135deg, rgba(255,122,24,0.25), var(--card));
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 0 18px rgba(255,122,24,0.55);
  opacity: 1;
  animation: ravito-glow 1.6s ease-in-out infinite;
}

@keyframes ravito-glow {
  0%, 100% { box-shadow: 0 0 0 1px var(--accent), 0 0 14px rgba(255,122,24,0.45); }
  50% { box-shadow: 0 0 0 1px var(--accent), 0 0 26px rgba(255,122,24,0.85); }
}

.ravito-banner {
  position: fixed;
  top: 110px;
  left: 16px;
  right: 16px;
  z-index: 20;
  background: var(--accent);
  color: #1b1b1f;
  font-weight: 700;
  text-align: center;
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  transform: translateY(-140%);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.ravito-banner.show {
  transform: translateY(0);
  opacity: 1;
}

.ravito-elapsed {
  font-weight: 700;
  font-size: 15px;
  min-width: 52px;
}

.ravito-food {
  flex: 1;
  font-size: 14px;
}

.ravito-time {
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
}

.subtitle {
  font-size: 12px;
  color: var(--muted);
}

.summary {
  display: flex;
  gap: 10px;
  padding: 14px 16px 4px;
  overflow-x: auto;
}

.summary .stat {
  background: var(--card);
  border-radius: 12px;
  padding: 10px 14px;
  flex: 1;
  min-width: 100px;
  text-align: center;
}

.summary .stat .label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
}

.summary .stat .value {
  font-size: 18px;
  font-weight: 600;
  margin-top: 2px;
}

.summary .stat.ahead .value { color: var(--green); }
.summary .stat.behind .value { color: var(--red); }

.checkpoints {
  padding: 8px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cp-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}

.cp-card .cp {
  border: none;
  border-radius: 0;
}

.maps-btn {
  display: block;
  text-align: center;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  background: var(--card-alt);
  border-top: 1px solid var(--border);
  text-decoration: none;
}

.cp {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.cp.done { background: var(--card-alt); border-color: #3a3d46; }

.cp .icon { font-size: 22px; width: 28px; text-align: center; }

.cp .info { flex: 1; min-width: 0; }

.cp .name { font-weight: 600; font-size: 15px; }

.cp .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }

.cp .times { text-align: right; }

.cp .planned {
  font-size: 13px;
  color: var(--muted);
}

.cp .eta {
  font-size: 17px;
  font-weight: 700;
  margin-top: 2px;
}

.cp .real {
  font-size: 17px;
  font-weight: 700;
  margin-top: 2px;
  color: var(--text);
}

.cp .delta {
  font-size: 11px;
  margin-top: 2px;
}

.delta.ahead { color: var(--green); }
.delta.behind { color: var(--red); }
.delta.onpace { color: var(--muted); }

.cp .cp-opt {
  font-size: 17px;
  font-weight: 700;
  color: var(--green);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.cp .cp-pess {
  font-size: 13px;
  color: var(--red);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

dialog {
  border: none;
  border-radius: 16px;
  background: var(--card);
  color: var(--text);
  padding: 0;
  width: 90%;
  max-width: 340px;
}

dialog::backdrop { background: rgba(0,0,0,0.6); }

#editForm {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#editForm h2 { margin: 0; font-size: 17px; }

#editForm label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

#editForm input[type=time] {
  background: var(--card-alt);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 10px;
  font-size: 18px;
}

.dialog-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

button {
  border: none;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 15px;
  font-weight: 600;
  flex: 1;
}

button.primary { background: var(--accent); color: #1b1b1f; }
button.secondary { background: var(--card-alt); color: var(--text); border: 1px solid var(--border); }

footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 60%, transparent);
}

footer button { width: 100%; }

/* ── PHASE 1 — Beta 0.2 ─────────────────────────────────────── */
.offline-bar { display:none; position:fixed; top:0; left:0; right:0; background:#92400e; color:#fde68a; font-size:13px; font-weight:600; text-align:center; padding:8px 16px; z-index:9999; }
.offline-bar.show { display:block; }
.cp.cutoff-risk { border-color:var(--red) !important; background:rgba(248,113,113,.06); }
.cutoff-badge { font-size:10px; font-weight:700; color:var(--red); background:rgba(248,113,113,.15); border:1px solid rgba(248,113,113,.4); border-radius:20px; padding:2px 6px; margin-top:4px; }
.summary .stat.eta .value { color:var(--accent); font-variant-numeric:tabular-nums; }
.delta.ahead { color:var(--green); }
.delta.behind { color:var(--red); }
.delta.onpace { color:var(--muted); }

/* ── PHASE 2 — Multi-coureurs ───────────────────────────────── */
.runner-tabs-bar {
  display: flex;
  gap: 8px;
  padding: 10px 16px 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.runner-tabs-bar::-webkit-scrollbar { display: none; }
.runner-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: border-color .15s, background .15s;
}
.runner-tab.active {
  border-color: var(--accent);
  background: rgba(52,211,153,.1);
  color: var(--accent);
}
.tab-bib { font-weight: 800; font-variant-numeric: tabular-nums; }
.runner-bypass-chip {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  padding: 2px 0;
  margin-top: 2px;
}

/* ── PHASE 3 — Tabs + Carte ─────────────────────────────────── */
.tabs { display:flex; gap:4px; padding:10px 16px 0; background:var(--bg); border-bottom:1px solid var(--border); }
.tab-btn { flex:1; padding:9px 4px; background:none; border:none; border-bottom:2px solid transparent; color:var(--muted); font-size:13px; font-weight:600; cursor:pointer; font-family:inherit; transition:all .15s; }
.tab-btn.active { color:var(--text); border-bottom-color:var(--accent); }
.page { display:none; }
.page.active { display:block; }
#map { height: calc(100dvh - 200px); width: 100%; }
.runner-dot {
  width: 22px; height: 22px;
  background: #ffffff; border: 3px solid #111827;
  border-radius: 50%;
  animation: runner-blink 1s step-start infinite;
  box-shadow: 0 0 0 3px rgba(255,255,255,.4);
}
@keyframes runner-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* ── Profil d'altitude ───────────────────────────────────────── */
.profile-wrap { padding: 12px 0 0; overflow: hidden; }
.profile-canvas { display: block; width: 100%; height: 260px; touch-action: none; }

/* ── Mobile ──────────────────────────────────────────────────── */
html { overflow-x: hidden; }
body { overflow-x: hidden; max-width: 100vw; }
@media (max-width: 420px) {
  .tab-btn { font-size: 12px; padding: 11px 4px; }
  .summary .stat { min-width: 80px; }
}

/* ── Feature: ETA hero + Cutoff alert + Map recenter ─────────── */
.eta-hero {
  margin: 14px 16px 0;
  padding: 18px 20px;
  background: linear-gradient(135deg, rgba(255,122,24,0.15) 0%, var(--card) 100%);
  border: 1px solid rgba(255,122,24,0.35);
  border-radius: 16px;
  text-align: center;
}
.eta-hero-time {
  font-size: 46px;
  font-weight: 800;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  letter-spacing: -1.5px;
  line-height: 1;
}
.eta-hero-label {
  font-size: 13px;
  color: var(--muted);
  margin-top: 6px;
}
.cutoff-alert {
  display: none;
  position: fixed;
  top: 110px;
  left: 12px;
  right: 12px;
  z-index: 30;
  background: var(--red);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  text-align: center;
  padding: 10px 16px;
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(239,88,104,0.5);
  animation: cutoff-pulse 2s ease-in-out infinite;
}
@keyframes cutoff-pulse {
  0%, 100% { box-shadow: 0 6px 20px rgba(239,88,104,0.5); }
  50%       { box-shadow: 0 6px 28px rgba(239,88,104,0.9); }
}
.map-recenter-btn {
  position: absolute;
  bottom: 80px;
  right: 12px;
  z-index: 1000;
  width: 44px;
  height: 44px;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  padding: 0;
  flex: none;
}

/* ── Profil interactif + Export PDF ─────────────────────────── */
.profile-wrap { position: relative; }
#profileOverlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; }
.profile-tip {
  display: none;
  position: absolute;
  pointer-events: none;
  align-items: center;
  gap: 8px;
  background: var(--card-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 12px;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  z-index: 10;
}
.tip-km { font-weight: 700; color: var(--text); }
.tip-ele { color: var(--green); font-weight: 600; }
.tip-cp { color: var(--accent); }
.pdf-btn {
  font-size: 12px;
  font-weight: 600;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  padding: 5px 12px;
  cursor: pointer;
  flex: none;
}
.pdf-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── Feature: Bannière d'installation PWA ────────────────────── */
.install-banner {
  position: fixed;
  left: 12px; right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 9998;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 14px;
  box-shadow: 0 14px 44px rgba(0,0,0,0.6);
  transform: translateY(180%);
  opacity: 0;
  pointer-events: none;
  transition: transform .38s cubic-bezier(.16,1,.3,1), opacity .38s;
}
.install-banner.show { transform: translateY(0); opacity: 1; pointer-events: auto; }
.install-logo { width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0; }
.install-text { flex: 1; min-width: 0; }
.install-title { font-weight: 700; font-size: 14px; }
.install-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; line-height: 1.35; }
.install-sub b { color: var(--text); font-weight: 700; }
.install-btn {
  flex: none;
  background: var(--accent);
  color: #1b1b1f;
  border: none;
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
.install-close {
  flex: none;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
  padding: 4px 6px;
  width: auto;
}

/* ── Feature: Bouton d'abonnement push ───────────────────────── */
.push-toggle {
  margin-top: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 100px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  cursor: pointer;
  font-family: inherit;
  width: auto;
  flex: none;
  transition: color .15s, border-color .15s, background .15s;
}
.push-toggle.on { color: var(--accent); border-color: var(--accent); background: rgba(255,122,24,.1); }
.push-toggle:disabled { opacity: .5; }
