/* ==========================================================================
   Carnet de forme v3 · habillage « Dossard trail »
   Vert lac, granit, orange balise. Chiffres en Saira Condensed, texte en Atkinson Hyperlegible.
   Un seul élément fort : le dossard (forme du jour). Tout le reste est calme.
   ========================================================================== */
:root {
  --font: "Atkinson Hyperlegible", system-ui, -apple-system, sans-serif;
  --font-chiffres: "Saira Condensed", "Atkinson Hyperlegible", system-ui, sans-serif;
  --bg: #E9EDEA; --surface: #F7F8F6; --surface2: #FFFFFF; --wash: #DFE5E1;
  --ink: #1E2423; --ink2: #4E5855; --muted: #77817D;
  --grid: #D2D9D5; --axis: #B3BDB8; --ring: rgba(30, 36, 35, .08);
  --accent: #0F5C57; --accent-ink: #FFFFFF; --accent-doux: #D5E7E4;
  --balise: #E8590C; --balise-doux: #FBE3D6;
  --good: #2E8B4F; --warn: #B98200; --serious: #E8590C; --crit: #C42E2B;
  --s1: #0F5C57; --s2: #E8590C;
  --bib: #FDFDFB; --bib-ink: #1A201F; --courbe: #CBD4CF;
  --ombre: 0 10px 30px rgba(15, 40, 36, .16);
  --ombre-douce: 0 2px 10px rgba(15, 40, 36, .08);
  --r: 14px; --r-petit: 10px;
  --onglets: calc(64px + env(safe-area-inset-bottom, 0px));
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0D1412; --surface: #141D1B; --surface2: #1A2523; --wash: #1C2725;
    --ink: #E6ECE9; --ink2: #AEB9B4; --muted: #7B8783;
    --grid: #24302D; --axis: #35433F; --ring: rgba(255, 255, 255, .07);
    --accent: #4DB6A9; --accent-ink: #06211E; --accent-doux: #16332F;
    --balise: #FF7A33; --balise-doux: #3A2316;
    --good: #4CC17A; --warn: #F2B92B; --serious: #FF7A33; --crit: #F0605C;
    --s1: #4DB6A9; --s2: #FF7A33;
    --bib: #EEF1EE; --bib-ink: #18201E; --courbe: #1F2B28;
    --ombre: 0 12px 34px rgba(0, 0, 0, .55); --ombre-douce: 0 2px 12px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}

/* ---------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: env(safe-area-inset-top, 0px); }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 var(--font); -webkit-tap-highlight-color: transparent;
  padding: env(safe-area-inset-top, 0px) max(16px, env(safe-area-inset-right, 0px)) calc(var(--onglets) + 24px) max(16px, env(safe-area-inset-left, 0px));
  overscroll-behavior-y: none;
}
[hidden] { display: none !important; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { font-size: 16px; } /* sinon iOS zoome au focus */
h1, h2, h3 { margin: 0; text-wrap: balance; }
h1 { font-family: var(--font-chiffres); font-weight: 700; font-size: 30px; line-height: 1.05; }
h2 { font-family: var(--font-chiffres); font-weight: 700; font-size: 24px; line-height: 1.1; }
h3 { font-size: 15px; font-weight: 700; color: var(--ink2); }
p { margin: 0; }
.sub { color: var(--ink2); font-size: 14.5px; }
.note { color: var(--muted); font-size: 13px; }
.chiffre { font-family: var(--font-chiffres); font-weight: 700; font-variant-numeric: tabular-nums; }
.vh { position: absolute !important; width: 1px; height: 1px; opacity: 0; overflow: hidden; pointer-events: none; }
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

#app { max-width: 640px; margin: 0 auto; }
.vue { display: flex; flex-direction: column; gap: 14px; padding-top: 10px; }
.entete { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; }
.entete .actions { display: flex; gap: 6px; }
.section { display: flex; flex-direction: column; gap: 10px; }
.section-tete { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }

/* ---------------------------------------------------------------- cartes et listes */
.carte { background: var(--surface); border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.carte.accent { border-left: 4px solid var(--accent); border-radius: 0 var(--r) var(--r) 0; }
.carte.alerte { border-left: 4px solid var(--balise); border-radius: 0 var(--r) var(--r) 0; }
.carte.plate { background: transparent; padding: 4px 0; }
.liste { display: flex; flex-direction: column; background: var(--surface); border-radius: var(--r); overflow: hidden; }
.ligne { display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-height: 52px; border-top: 1px solid var(--grid); background: none; border-left: 0; border-right: 0; border-bottom: 0; width: 100%; text-align: left; }
.ligne:first-child { border-top: 0; }
button.ligne { cursor: pointer; }
button.ligne:active { background: var(--wash); }
.ligne .ligne-corps { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.ligne .ligne-titre { font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.ligne .ligne-sous { font-size: 13.5px; color: var(--ink2); }
.ligne .ligne-fin { font-family: var(--font-chiffres); font-weight: 700; font-size: 18px; white-space: nowrap; }
.ligne img.vignette { width: 48px; height: 48px; border-radius: 10px; object-fit: cover; flex: none; }
.ligne .attente-pastille { font-size: 12px; color: var(--balise); font-weight: 700; }

/* ---------------------------------------------------------------- boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 10px 18px; border-radius: var(--r-petit); border: 0;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 15.5px;
  cursor: pointer; text-decoration: none; user-select: none; -webkit-user-select: none;
}
.btn:active { filter: brightness(.94); }
.btn[disabled] { opacity: .5; cursor: default; }
.btn[aria-busy="true"] { opacity: .7; }
.btn.ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--axis); }
.btn.doux { background: var(--accent-doux); color: var(--accent); }
.btn.danger { background: var(--crit); color: #fff; }
.btn.petit { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.btn.large { width: 100%; }
.btn.rond { width: 46px; min-width: 46px; padding: 0; border-radius: 50%; font-size: 22px; }
.btn-lien { background: none; border: 0; padding: 6px 0; min-height: 36px; color: var(--accent); font-weight: 700; font-size: 14.5px; cursor: pointer; text-align: left; }
.btn-icone { background: none; border: 0; width: 44px; height: 44px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: var(--ink2); cursor: pointer; }
.btn-icone:active { background: var(--wash); }
.rangee { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.rangee.etire > * { flex: 1; }

/* ---------------------------------------------------------------- saisie */
.champ { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--ink2); min-width: 0; }
.champ > span { font-weight: 700; }
.champ small { color: var(--muted); }
.champ input, .champ select, .champ textarea, input.inp, textarea.inp, select.inp {
  width: 100%; min-height: 46px; padding: 10px 12px; border-radius: var(--r-petit);
  border: 1.5px solid var(--axis); background: var(--surface2); color: var(--ink);
  font-size: 16px; -webkit-appearance: none; appearance: none;
}
.champ textarea, textarea.inp { min-height: 76px; resize: vertical; line-height: 1.4; }
.champ input:focus, .champ textarea:focus, .champ select:focus, .inp:focus { border-color: var(--accent); outline: none; }
.grille2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grille4 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 520px) { .grille4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.recherche { position: relative; }
.recherche input { padding-left: 40px; }
.recherche svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }

.pastilles { display: flex; flex-wrap: wrap; gap: 8px; }
.pastilles button {
  display: inline-flex; flex-direction: column; align-items: flex-start; justify-content: center;
  min-height: 42px; padding: 7px 14px; border-radius: 999px; border: 1.5px solid var(--axis);
  background: var(--surface2); color: var(--ink); font-size: 15px; cursor: pointer; text-align: left; line-height: 1.15;
}
.pastilles button small { font-size: 12px; color: var(--muted); font-weight: 400; }
.pastilles button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.pastilles button[aria-pressed="true"] small { color: inherit; opacity: .85; }
.pastilles.petites button { min-height: 36px; padding: 5px 12px; font-size: 14px; }
.pastilles.grosses button { min-height: 54px; padding: 10px 18px; font-size: 16.5px; border-radius: 14px; }

.compteur { display: inline-flex; align-items: center; gap: 10px; }
.compteur-v { min-width: 84px; text-align: center; font-family: var(--font-chiffres); font-weight: 700; font-size: 22px; font-variant-numeric: tabular-nums; }

.segmente { display: flex; background: var(--wash); border-radius: 12px; padding: 3px; gap: 3px; }
.segmente button { flex: 1; min-height: 40px; border: 0; border-radius: 9px; background: transparent; color: var(--ink2); font-weight: 700; font-size: 14.5px; cursor: pointer; }
.segmente button[aria-checked="true"] { background: var(--surface2); color: var(--ink); box-shadow: var(--ombre-douce); }

input[type="range"] { width: 100%; height: 36px; accent-color: var(--accent); }

/* ---------------------------------------------------------------- jauges */
.barre { display: flex; flex-direction: column; gap: 5px; }
.barre-tete { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; color: var(--ink2); }
.barre-tete b { color: var(--ink); font-family: var(--font-chiffres); font-weight: 700; font-size: 17px; font-variant-numeric: tabular-nums; }
.barre-tete b small { font-family: var(--font); font-weight: 400; font-size: 12.5px; color: var(--muted); }
.barre-fond { height: 9px; border-radius: 5px; background: var(--wash); overflow: hidden; }
.barre-fond i { display: block; height: 100%; border-radius: 5px; background: var(--accent); transition: width .35s ease; }
.barre-fond i.depasse { background: var(--balise); }
.barre-fond i.prot { background: var(--good); }
.anneau { position: relative; flex: none; }
.anneau svg { display: block; }
.anneau-centre { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; line-height: 1; }

/* ---------------------------------------------------------------- états */
.vide { padding: 18px 4px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; color: var(--ink2); }
.attente { display: flex; align-items: center; gap: 10px; font-size: 14.5px; color: var(--ink2); padding: 6px 0; }
.attente-s { font-variant-numeric: tabular-nums; color: var(--muted); }
.pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); animation: pulse 1.1s ease-in-out infinite; flex: none; }
@keyframes pulse { 0%, 100% { opacity: .25; transform: scale(.8); } 50% { opacity: 1; transform: scale(1.1); } }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--wash); color: var(--ink2); }
.badge.ok { background: var(--accent-doux); color: var(--accent); }
.badge.balise { background: var(--balise-doux); color: var(--balise); }
.forme { font-style: normal; } /* ▲ ■ ● : la forme double la couleur */
.bandeau { position: sticky; top: 0; z-index: 30; margin: 0 -16px; padding: calc(env(safe-area-inset-top, 0px) + 6px) 16px 8px; background: var(--balise); color: #fff; font-size: 14px; font-weight: 700; display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.bandeau button { background: rgba(255,255,255,.2); color: #fff; border: 0; border-radius: 8px; min-height: 34px; padding: 4px 10px; font-weight: 700; }

/* ---------------------------------------------------------------- barre d'onglets */
.onglets {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  padding: 6px max(8px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px));
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border-top: 1px solid var(--ring);
}
.onglets-rangee { max-width: 560px; margin: 0 auto; display: flex; align-items: flex-end; justify-content: space-between; }
.onglet {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-height: 52px; padding: 6px 2px 4px; border: 0; background: none; color: var(--muted);
  font-size: 11.5px; line-height: 1.1; cursor: pointer; position: relative;
}
.onglet[aria-current="page"] { color: var(--accent); font-weight: 700; }
.onglet[aria-current="page"]::before { content: ""; position: absolute; top: -7px; left: 30%; right: 30%; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent); }
.onglet .compte { position: absolute; top: 2px; right: 24%; min-width: 17px; height: 17px; border-radius: 9px; background: var(--balise); color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; padding: 0 4px; }
.onglet-plus { flex: 1; display: flex; justify-content: center; }
.onglet-plus button {
  width: 58px; height: 58px; border-radius: 50%; border: 0; margin-top: -22px;
  background: var(--balise); color: #fff; box-shadow: var(--ombre); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.onglet-plus button:active { transform: scale(.95); }

/* ---------------------------------------------------------------- feuilles (bottom sheets) */
#feuilles { position: relative; z-index: 60; }
.voile { position: fixed; inset: 0; background: rgba(5, 15, 13, .45); opacity: 0; transition: opacity .22s ease; z-index: 60; }
.voile.entre { opacity: 1; }
.voile.sort { opacity: 0; }
.feuille {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 61; max-height: 92dvh; max-width: 640px; margin: 0 auto;
  display: flex; flex-direction: column; background: var(--bg); border-radius: 18px 18px 0 0;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, .25); transform: translateY(100%); transition: transform .26s cubic-bezier(.2, .8, .2, 1);
  outline: none;
}
.feuille.pleine { height: 92dvh; }
.feuille.entre { transform: translateY(0); }
.feuille.sort { transform: translateY(100%); }
.feuille-tete { display: flex; align-items: center; gap: 8px; padding: 14px 16px 8px; position: relative; touch-action: none; }
.feuille-tete h2 { flex: 1; font-size: 22px; }
.poignee { position: absolute; top: 6px; left: 50%; width: 38px; height: 5px; margin-left: -19px; border-radius: 3px; background: var(--axis); }
.feuille-fermer { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--wash); color: var(--ink2); font-size: 24px; line-height: 1; cursor: pointer; flex: none; }
.feuille-corps { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 4px 16px 16px; display: flex; flex-direction: column; gap: 14px; flex: 1; overscroll-behavior: contain; }
.feuille-pied { padding: 10px 16px calc(12px + env(safe-area-inset-bottom, 0px)); display: flex; gap: 10px; border-top: 1px solid var(--ring); background: var(--bg); }
.feuille-pied .btn { flex: 1; }

/* ---------------------------------------------------------------- messages éphémères */
#toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--onglets) + 12px); z-index: 80; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px; max-width: 520px; width: 100%;
  padding: 12px 14px; border-radius: 12px; background: #1E2423; color: #F3F6F4; box-shadow: var(--ombre);
  font-size: 15px; animation: toastEntre .22s ease;
}
.toast.sort { opacity: 0; transform: translateY(8px); transition: all .2s ease; }
.toast-texte { flex: 1; }
.toast-action { background: none; border: 0; color: #7FE0D2; font-weight: 700; min-height: 36px; padding: 0 4px; cursor: pointer; }
.toast-erreur { background: #5A1715; }
@keyframes toastEntre { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------- dossard (forme du jour) */
.bibzone { position: relative; isolation: isolate; padding: 4px 0 2px; }
.bibzone .courbes { position: absolute; inset: -20px -16px -8px; width: calc(100% + 32px); height: calc(100% + 28px); z-index: -1; color: var(--courbe); pointer-events: none; }
.bib { position: relative; display: block; width: calc(100% - 12px); margin: 4px 6px 0; padding: 0; border: 0; text-align: left; background: var(--bib); color: var(--bib-ink); border-radius: 10px; box-shadow: var(--ombre); overflow: hidden; transform: rotate(-1deg); cursor: pointer; }
.bib-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: #0F5C57; color: #fff; padding: 9px 32px 8px; }
.bib-top span { font-size: 14px; font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bib-top b { font-family: var(--font-chiffres); font-size: 21px; font-weight: 800; background: var(--balise); color: #fff; border-radius: 6px; padding: 0 9px; line-height: 1.25; white-space: nowrap; flex: none; }
.bib-corps { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 4px 16px; padding: 6px 32px 2px; }
.bib-num { font-family: var(--font-chiffres); font-weight: 800; font-size: 112px; line-height: .86; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.bib-num.vide { font-size: 84px; color: #9AA4A0; }
.bib-cote { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.bib-cote .k { font-size: 13px; color: #5B6562; }
.bib-v { display: inline-flex; align-items: center; gap: 7px; font-size: 18.5px; font-weight: 700; line-height: 1.15; }
.bib-v i { font-style: normal; font-size: 15px; }
.bib-faits { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 4px 0 0; border-top: 2px dashed #D5DBD8; padding: 9px 32px 13px; }
.bib-faits dt { font-size: 12px; color: #5B6562; }
.bib-faits dd { margin: 0; font-family: var(--font-chiffres); font-weight: 700; font-size: 22px; line-height: 1.1; }
.bib-faits dd small { font-family: var(--font); font-weight: 400; font-size: 12px; color: #5B6562; margin-left: 3px; }
.epingle { position: absolute; width: 11px; height: 11px; border-radius: 50%; background: var(--bg); box-shadow: inset 0 1px 2px rgba(0, 0, 0, .35); z-index: 2; }
.epingle.a { top: 9px; left: 10px; } .epingle.b { top: 9px; right: 10px; } .epingle.c { bottom: 10px; left: 10px; } .epingle.d { bottom: 10px; right: 10px; }
@media (max-width: 360px) { .bib-num { font-size: 92px; } .bib-corps, .bib-faits { padding-left: 24px; padding-right: 24px; } }
@media (prefers-reduced-motion: reduce) { .bib { transform: none; } }

/* ---------------------------------------------------------------- fil de la journée */
.fil { display: flex; flex-direction: column; background: var(--surface); border-radius: var(--r); overflow: hidden; }
.fil-item { display: grid; grid-template-columns: 54px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 12px 14px; border-top: 1px solid var(--grid); min-height: 60px; }
.fil-item:first-child { border-top: 0; }
.fil-heure { font-family: var(--font-chiffres); font-weight: 700; font-size: 18px; color: var(--accent); line-height: 1.05; }
.fil-heure small { display: block; font-family: var(--font); font-weight: 400; font-size: 11.5px; color: var(--muted); }
.fil-corps { min-width: 0; }
.fil-corps b { display: block; font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.fil-corps span { font-size: 13.5px; color: var(--ink2); }
.fil-item.fait .fil-corps b { color: var(--ink2); }
.fil-item.fait .fil-heure { color: var(--good); }
.fil-action { display: flex; gap: 6px; }
.coche {
  width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--axis); background: transparent; color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex: none;
}
.coche[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ---------------------------------------------------------------- textes longs du coach */
.coach-lead { font-size: 17.5px; line-height: 1.42; font-weight: 700; max-width: 42ch; }
.replie { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.recadrage { border-left: 4px solid var(--balise); background: var(--surface); border-radius: 0 12px 12px 0; padding: 10px 14px; display: flex; flex-direction: column; gap: 4px; }
.recadrage b { color: var(--balise); font-size: 14px; }
.recadrage p { font-size: 14.5px; line-height: 1.5; }

/* ---------------------------------------------------------------- connexion */
.connexion { max-width: 400px; margin: 12vh auto 0; display: flex; flex-direction: column; gap: 14px; }
