:root {
  --bg: #0f1115; --card: #1a1d24; --card2: #222632; --line: #2c313d;
  --text: #f2f3f5; --muted: #9aa1ad; --accent: #ff6b35; --accent2: #2e86de;
  --ok: #2ecc71; --warn: #f5b041; --bad: #e74c3c;
  --safe-top: env(safe-area-inset-top); --safe-bot: env(safe-area-inset-bottom);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif; }
body { min-height: 100vh; overscroll-behavior-y: none; }
a { color: var(--accent2); }
h1, h2, h3, h4 { margin: 0; }
h2 { font-size: 22px; } h3 { font-size: 17px; margin-bottom: 4px; }
p { margin: 6px 0; }

.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 10px; padding: calc(var(--safe-top) + 10px) 16px 10px; background: rgba(15,17,21,.92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top h1 { font-size: 18px; flex: 1; }
.logo { font-weight: 800; color: var(--accent); letter-spacing: .5px; }
.icon { background: none; border: 0; color: var(--text); font-size: 30px; line-height: 1; padding: 0 6px 0 0; }

.pad { padding: 14px 14px 30px; max-width: 640px; margin: 0 auto; }
.has-nav { padding-bottom: calc(90px + var(--safe-bot)); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin: 10px 0; }
.card.ok { border-color: rgba(46,204,113,.5); background: rgba(46,204,113,.08); }
.card.warn { border-color: rgba(245,176,65,.5); background: rgba(245,176,65,.08); }
.card.goal { background: linear-gradient(135deg, #2a1d17, #1a1d24); border-color: #4a2d20; }
.card.center, .center { text-align: center; }
.warnbox { background: rgba(245,176,65,.12); border: 1px solid rgba(245,176,65,.4); padding: 10px; border-radius: 10px; }
details.card summary, details summary { cursor: pointer; font-weight: 600; }
.sec { margin: 18px 4px 4px; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .6px; }
.muted { color: var(--muted); } .small { font-size: 13.5px; }
.okc { color: var(--ok); } .warnc { color: var(--warn); }
.row { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.inline { display: flex; gap: 8px; } .inline input { flex: 1; }
.btnrow { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; } .btnrow .btn { flex: 1; }
.links { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--card2); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { background: transparent; border-color: var(--bad); color: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); width: 100%; }
.btn.big { width: 100%; padding: 16px; font-size: 17px; margin-top: 10px; }
.btn.small { padding: 7px 10px; font-size: 14px; }
.btn:disabled { opacity: .45; }

label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.lbl { font-size: 14px; color: var(--muted); display: block; margin-bottom: 6px; }
input, select, textarea { font: inherit; font-size: 16px; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; width: 100%; }
textarea { font-size: 13px; font-family: ui-monospace, Menlo, monospace; }

.seg { display: flex; gap: 6px; } .seg.wrap { flex-wrap: wrap; }
.seg label { flex: 1; } .seg input { display: none; }
.seg span { display: block; text-align: center; padding: 10px 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 14px; white-space: nowrap; }
.seg input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.day { padding: 12px 0; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; font-size: 14px; }
.day.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }

.hero { text-align: center; padding: 30px 10px 10px; }
.hero-mark { width: 74px; height: 74px; margin: 0 auto 14px; border-radius: 20px; background: var(--accent); display: grid; place-items: center; font-size: 32px; font-weight: 800; }
.kpi { display: flex; justify-content: space-between; align-items: baseline; } .kpi b { font-size: 34px; color: var(--accent); }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; text-align: center; }
.grid3 b { display: block; font-size: 22px; } .grid3 span { font-size: 12px; color: var(--muted); }
.paces { width: 100%; border-collapse: collapse; } .paces td { padding: 6px 0; border-bottom: 1px solid var(--line); } .paces td:last-child { text-align: right; font-weight: 700; }

.session { cursor: pointer; } .session.hard { border-left: 4px solid var(--accent); }
.session.big h3 { font-size: 21px; margin: 6px 0; }
.sess-top { display: flex; justify-content: space-between; }
.when { font-weight: 700; color: var(--accent); }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 20px; background: var(--card2); color: var(--muted); }
.meta { color: var(--muted); font-size: 14px; }
.defi { border-left: 4px solid var(--accent2); }

.phasebar { display: flex; height: 26px; border-radius: 8px; overflow: hidden; margin-bottom: 8px; }
.ph { display: grid; place-items: center; font-size: 11px; color: #fff; overflow: hidden; white-space: nowrap; }
.ph-base { background: #3d6b8f; } .ph-dev { background: #6a5acd; } .ph-spec { background: #d35400; } .ph-taper { background: #16a085; }
.week { background: var(--card); border: 1px solid var(--line); border-radius: 12px; margin: 8px 0; overflow: hidden; }
.week.current { border-color: var(--accent); }
.week.ok { border: 2px solid var(--ok); } .week.ko { border: 2px solid var(--bad); }
.wk-ok { color: var(--ok); } .wk-ko { color: var(--bad); }
.myvoice { border-top: 1px solid var(--line); padding-top: 10px; }
.myvoice summary { font-weight: 600; cursor: pointer; padding: 4px 0; }
.myvoice[open] summary { margin-bottom: 6px; }
.week summary { display: flex; flex-direction: column; padding: 11px 14px; list-style: none; }
.week summary::-webkit-details-marker { display: none; }
.srow { display: grid; grid-template-columns: 62px 1fr auto; gap: 8px; padding: 9px 14px; border-top: 1px solid var(--line); font-size: 14px; cursor: pointer; }
.srow.done { color: var(--muted); }

.steps { padding-left: 22px; margin: 6px 0; } .steps li { padding: 4px 0; }
.steps .k-work { color: var(--accent); font-weight: 600; } .steps .k-recovery { color: var(--muted); }
.check li { padding: 5px 0; }

.map { height: 300px; border-radius: 14px; margin: 10px 0; border: 1px solid var(--line); }
.rcard { display: flex; align-items: center; gap: 10px; cursor: pointer; } .rcard span:last-child { margin-left: auto; color: var(--muted); }
.rcard.sel { border-color: var(--accent); }
.dot { width: 14px; height: 14px; border-radius: 50%; } .dot.c0 { background: #e4572e; } .dot.c1 { background: #2e86de; } .dot.c2 { background: #16a085; }

.tabs { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: rgba(20,22,28,.97); border-top: 1px solid var(--line); padding-bottom: var(--safe-bot); z-index: 20; }
.tabs button { flex: 1; background: none; border: 0; color: var(--muted); font: inherit; font-size: 11px; padding: 8px 0 10px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tabs button span { font-size: 20px; } .tabs button.on { color: var(--accent); }

.toast { position: fixed; left: 16px; right: 16px; bottom: calc(100px + var(--safe-bot)); background: #333a48; color: #fff; padding: 12px 14px; border-radius: 12px; z-index: 100; box-shadow: 0 6px 24px rgba(0,0,0,.4); animation: up .25s ease; }
@keyframes up { from { transform: translateY(20px); opacity: 0; } }
.spin { width: 18px; height: 18px; border: 2.5px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: rot 0.8s linear infinite; display: inline-block; }
.spin.big { width: 36px; height: 36px; }
@keyframes rot { to { transform: rotate(360deg); } }

/* Écran de course */
.run { min-height: 100vh; display: flex; flex-direction: column; padding: calc(var(--safe-top) + 12px) 16px calc(var(--safe-bot) + 14px); gap: 6px; }
.run-top { display: flex; justify-content: space-between; color: var(--muted); font-size: 14px; }
.gps.ok { color: var(--ok); }
.run-step { font-size: 21px; font-weight: 700; min-height: 54px; }
.run-rem { font-size: 30px; font-weight: 700; color: var(--accent2); font-variant-numeric: tabular-nums; }
.run-pace { font-size: 92px; font-weight: 800; line-height: 1; text-align: center; font-variant-numeric: tabular-nums; margin-top: 6px; }
.run-pace small { font-size: 22px; color: var(--muted); font-weight: 600; }
.run-pace.slow { color: var(--warn); } .run-pace.fast { color: var(--accent2); } .run-pace.good { color: var(--ok); }
.run-target { text-align: center; color: var(--muted); font-size: 16px; min-height: 22px; }
.run-stats { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; margin: 8px 0; }
.run-stats b { display: block; font-size: 26px; font-variant-numeric: tabular-nums; } .run-stats span { font-size: 12px; color: var(--muted); }
.run-next { color: var(--muted); font-size: 14px; text-align: center; }
.run-map { flex: 1; min-height: 150px; border-radius: 14px; }
.run.mapmode { gap: 4px; }
.run.mapmode .run-step { font-size: 18px; min-height: 0; }
.run.mapmode .run-rem { font-size: 24px; }
.run.mapmode .run-pace { font-size: 60px; margin-top: 0; }
.run.mapmode .run-stats { margin: 2px 0; } .run.mapmode .run-stats b { font-size: 22px; }
.run.mapmode .run-map { min-height: 280px; }
.run-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px; }
.run-btns .btn { padding: 15px; }

#lock { position: fixed; inset: 0; background: #000; z-index: 1000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 30px; touch-action: none; user-select: none; -webkit-user-select: none; }
#lock[hidden] { display: none; }
.lock-step { color: #555; font-size: 18px; padding: 0 20px; text-align: center; }
.lock-pace { color: #444; font-size: 80px; font-weight: 800; } .lock-pace small { font-size: 20px; }
.lock-ring { width: 150px; height: 150px; border-radius: 50%; border: 3px solid #333; display: grid; place-items: center; text-align: center; color: #555; font-size: 13px; padding: 20px; transition: border-color 1.5s linear, color 1.5s; }
.lock-ring.hold { border-color: var(--accent); color: var(--accent); }
.leaflet-container { background: #1a1d24; }
.ph-recup { background: #7f8c8d; }
.checkrow { flex-direction: row; align-items: center; gap: 10px; color: var(--text); font-size: 15px; }
.checkrow input { width: 22px; height: 22px; flex: none; accent-color: var(--accent); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.prerow { border: 1px solid var(--line); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.tabs button { font-size: 10.5px; }
.race { border-left: 4px solid var(--ok); cursor: pointer; }
.addrbox .geo { justify-content: flex-start; text-align: left; font-weight: 500; }
.addrbox .geo.on { border-color: var(--ok); }
.wall-head { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 6px 0 14px; text-align: center; }
.wall-head b { display: block; font-size: 26px; color: var(--accent); } .wall-head span { font-size: 12px; color: var(--muted); }
.wall { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 10px; padding: 18px 10px; border-radius: 16px;
  background: radial-gradient(ellipse at top, #2a2f3d, #14161c 70%); border: 1px solid var(--line); }
.medal { background: none; border: 0; color: var(--text); display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 0; font: inherit; cursor: pointer; }
.medal-img { width: 100%; aspect-ratio: 3 / 4; object-fit: contain; filter: drop-shadow(0 6px 10px rgba(0,0,0,.55)); display: flex; align-items: center; justify-content: center; }
.medal-img .medal-svg { width: 80%; height: 100%; }
.medal-name { font-size: 12px; font-weight: 600; text-align: center; line-height: 1.2; max-width: 100%; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.medal-date { font-size: 11px; color: var(--muted); }
.medal-hero { display: flex; justify-content: center; padding: 20px 0 10px; background: radial-gradient(circle, #2f3545 0%, transparent 65%); }
.medal-img.big { width: 70%; max-width: 300px; }
