:root {
  color-scheme: dark;
  --bg: #0e0e10;
  --card: #1b1b1f;
  --card-2: #232328;
  --ink: #f4f3f1;
  --ink-soft: #b9b8c0;
  --ink-muted: #7d7c85;
  --accent: #ff3d1a;
  --accent-2: #ff6a45;
  --good: #3ddc63;
  --warn: #ffb020;
  --critical: #ff5a5a;
  --line: #2b2b30;
  --font-display: -apple-system, "SF Pro Display", "Segoe UI", system-ui, sans-serif;
  --font-body: -apple-system, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  margin: 0;
  overscroll-behavior-y: none;
}

body {
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

#app {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
  min-height: 100%;
}

.ecran {
  display: none;
  flex: 1;
  flex-direction: column;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  gap: 16px;
}
.ecran.actif { display: flex; }

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0;
  text-wrap: balance;
}
h1 { font-size: 1.7rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 0.95rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.06em; }

p { margin: 0; line-height: 1.5; }
.muted { color: var(--ink-muted); font-size: 0.85rem; }

.entete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 8px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 1.3rem;
  letter-spacing: 0.02em;
}
.logo .barre { color: var(--accent); }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  border-radius: 14px;
  padding: 14px 18px;
  font-size: 1rem;
  font-weight: 700;
  min-height: 48px;
}
button:active { transform: scale(0.98); }

.btn-principal { background: var(--accent); color: #180400; }
.btn-secondaire { background: var(--card-2); color: var(--ink); }
.btn-fantome { background: transparent; color: var(--ink-soft); border: 1px solid var(--line); }
.btn-danger { background: transparent; color: var(--critical); border: 1px solid var(--critical); }
.btn-bloc { width: 100%; }
.btn-icone { padding: 10px; min-height: 40px; min-width: 40px; border-radius: 10px; background: var(--card-2); color: var(--ink-soft); font-weight: 900; }

input[type="text"], input[type="password"], input[type="number"] {
  font-family: inherit;
  background: var(--card-2);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 12px;
  padding: 13px 14px;
  font-size: 1rem;
  width: 100%;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.carte {
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.liste { display: flex; flex-direction: column; gap: 10px; }

.seance-item {
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.seance-item .infos { display: flex; flex-direction: column; gap: 4px; }
.seance-item .nb-exos { color: var(--ink-muted); font-size: 0.82rem; }

.spacer { flex: 1; }

.exo-form-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card-2);
  border-radius: 12px;
  padding: 10px 12px;
}
.exo-form-row .nom { flex: 1; font-weight: 600; }
.exo-form-row .type-tag {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  background: var(--bg);
  padding: 3px 8px;
  border-radius: 999px;
}
.exo-form-row .series-input {
  width: 40px;
  text-align: center;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 8px;
  padding: 6px 4px;
  font-weight: 700;
}

.select-exercice {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  background: var(--card-2);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.chip.selectionne { background: var(--accent); border-color: var(--accent); color: #180400; }

/* Écran entraînement */
.entrainement-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.progression-texte { color: var(--ink-muted); font-size: 0.85rem; font-weight: 700; }

.exercice-courant {
  text-align: center;
  padding: 24px 0 8px;
}
.exercice-courant .nom-exo {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 1.6rem;
  text-wrap: balance;
}
.exercice-courant .serie-num {
  margin-top: 6px;
  color: var(--accent-2);
  font-weight: 700;
  font-size: 0.95rem;
}

.saisie {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  padding: 20px 0;
}
.stepper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.stepper .label-champ { font-size: 0.75rem; color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.stepper .valeur {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: 2.4rem;
  min-width: 100px;
  text-align: center;
}
.stepper .boutons { display: flex; gap: 10px; }
.stepper .boutons button {
  width: 48px; height: 48px; border-radius: 50%;
  font-size: 1.4rem; padding: 0; display: flex; align-items: center; justify-content: center;
}

.chrono-affichage {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: 3rem;
  text-align: center;
  padding: 20px 0;
}

/* Repos */
.repos-anneau {
  position: relative;
  width: 220px;
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 12px auto;
}
.repos-anneau svg { transform: rotate(-90deg); transition: stroke-dashoffset 0.1s linear; }
.repos-chiffre {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 900;
  font-size: 3.4rem;
}

/* Coach */
.coach-carte {
  background: linear-gradient(180deg, var(--card) 0%, var(--card-2) 100%);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 16px;
  padding: 18px;
  white-space: pre-wrap;
  line-height: 1.55;
}
.coach-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent-2);
  font-weight: 800;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.chargement {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex: 1;
}
.spin {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  animation: tourner 0.8s linear infinite;
}
@keyframes tourner { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spin { animation: none; }
}

.historique-item {
  background: var(--card);
  border-radius: 16px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.historique-item .ligne1 { display: flex; justify-content: space-between; font-weight: 700; }
.historique-item .date { color: var(--ink-muted); font-size: 0.8rem; font-weight: 500; }

.erreur-texte { color: var(--critical); font-size: 0.85rem; min-height: 1.2em; }

.toast {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--card-2);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 50;
}
.toast.visible { opacity: 1; }

::-webkit-scrollbar { display: none; }
