@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

:root {
  --fond: #0b0b0d;
  --surface: #141417;
  --surface-2: #1d1d22;
  --bordure: rgb(255 255 255 / 0.07);
  --texte: #f4f4f5;
  --discret: #8b8b93;
  --accent: #bfdbfe;
  --accent-2: #c7d2fe;
  --accent-texte: #0b0b0d;
  --succes: #bbf7d0;
  --alerte: #fca5a5;
  --rayon: 20px;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --fond: #f5f5f4;
    --surface: #ffffff;
    --surface-2: #f0f0ee;
    --bordure: rgb(0 0 0 / 0.07);
    --texte: #0b0b0d;
    --discret: #76767e;
    --accent: #2563eb;
    --accent-2: #7c3aed;
    --accent-texte: #ffffff;
    --succes: #15803d;
    --alerte: #b91c1c;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }

html {
  font-size: 14px;
  background: var(--fond);
}

body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font: 1rem/1.5 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: 1rem; letter-spacing: -0.01em; }

button, input { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; padding: 0; touch-action: manipulation; }

/* En-tête */
.barre {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: calc(env(safe-area-inset-top) + 0.75rem) 1.25rem 0.5rem;
  background: color-mix(in srgb, var(--fond) 80%, transparent);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
}
.barre h1 { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions { display: flex; gap: 0.5rem; align-items: center; }
.actions form { margin: 0; }

.pilule {
  white-space: nowrap;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--bordure);
  font-size: 0.85rem;
  font-weight: 500;
  transition: background 0.15s, transform 0.1s;
}
.pilule:hover { background: var(--surface-2); }
.pilule:active { transform: scale(0.96); }
.pilule.petit { padding: 0.3rem 0.7rem; font-size: 0.8rem; }

main {
  max-width: 46rem;
  margin: 0 auto;
  padding: 0.5rem 1.25rem calc(6rem + env(safe-area-inset-bottom));
}

/* Accueil */
.date {
  margin: 0.75rem 0 0.25rem;
  color: var(--discret);
  font-size: 0.85rem;
}
.date::first-letter, .resume:first-child::first-letter, #liste-historique .carte-titre::first-letter { text-transform: uppercase; }
.salut {
  font-size: 2rem;
  font-weight: 650;
  letter-spacing: -0.03em;
  margin-bottom: 1.5rem;
}

.bandeau {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin: 0.75rem 0 0;
  padding: 0.6rem 0.9rem;
  border-radius: 14px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 22%, transparent), color-mix(in srgb, var(--accent-2) 18%, transparent));
  font-size: 0.85rem;
}

.grille {
  display: grid;
  gap: 1rem;
}
@media (min-width: 40rem) {
  .grille { grid-template-columns: 1fr 1fr; }
  .carte.large { grid-column: 1 / -1; }
}

.carte {
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
}

.carte-tete {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.carte-titre {
  color: var(--discret);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.chiffres {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}
.chiffre { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.grand-chiffre {
  font-size: clamp(1.25rem, 6vw, 1.6rem);
  font-weight: 650;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.libelle { color: var(--discret); font-size: 0.8rem; }

.exercice {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.25rem 1rem;
  padding: 0.7rem 0;
  border-top: 1px solid var(--bordure);
}
.exercice .nom { font-weight: 500; }
.exercice .detail {
  color: var(--discret);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}
.chiffres + .exercice { margin-top: 1rem; }

.detail { color: var(--discret); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.resume { margin: 0.5rem 0 0; font-size: 0.9rem; color: var(--discret); font-variant-numeric: tabular-nums; }
.resume:first-child { margin-top: 0; font-size: 1.05rem; color: var(--texte); font-weight: 500; }
.vide { color: var(--discret); margin: 0.25rem 0; font-size: 0.9rem; }

/* Progression */
.segments {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: var(--surface-2);
}
.segments button {
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  color: var(--discret);
  font-size: 0.8rem;
  font-weight: 500;
}
.segments button.actif { background: var(--texte); color: var(--fond); }

.puces { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1rem; }
.puce {
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--bordure);
  background: var(--surface-2);
  font-size: 0.85rem;
  transition: background 0.15s, border-color 0.15s;
}
.puce:hover { border-color: color-mix(in srgb, var(--texte) 25%, transparent); }
.puce.actif {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-texte);
  border-color: transparent;
  font-weight: 600;
}

.graphe { color: var(--accent); }
.graphe .courbe { display: block; width: 100%; height: auto; overflow: visible; }
.graphe .point { fill: var(--surface); stroke: currentColor; stroke-width: 1.5; }
.graphe .point.dernier { fill: currentColor; stroke: none; }
.graphe .axe { fill: var(--discret); font-size: 10px; font-family: inherit; }

/* Records */
.ligne-record {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.75rem;
  align-items: baseline;
  padding: 0.6rem 0;
  border-top: 1px solid var(--bordure);
}
.ligne-record .nom { font-weight: 500; }
.ligne-record .valeur { font-weight: 600; font-variant-numeric: tabular-nums; }
.ligne-record .detail { text-align: right; min-width: 5.5rem; }

/* Boutons d'action */
.bouton {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  height: 3.5rem;
  margin-top: 1.25rem;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-texte);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  box-shadow: 0 10px 30px -12px color-mix(in srgb, var(--accent) 70%, transparent);
  transition: transform 0.12s, box-shadow 0.2s, opacity 0.15s;
}
.bouton svg {
  width: 1.2rem;
  height: 1.2rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.2s;
}
.bouton:hover svg { transform: translateX(2px); }
.bouton:active { transform: scale(0.98); }
.bouton:disabled { opacity: 0.45; }

.bouton-discret {
  display: block;
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.75rem;
  border-radius: 14px;
  color: var(--discret);
  font-size: 0.9rem;
}
.bouton-discret:hover { background: var(--surface); color: var(--texte); }
.actions-accueil { margin-top: 1.5rem; }
.actions-accueil .bouton { margin-top: 0; }

/* Choix d'exercice */
#form-choix { display: flex; flex-direction: column; gap: 0.5rem; padding-top: 1rem; }
#form-choix .bouton { margin-top: 1.5rem; }
.etiquette { color: var(--discret); font-size: 0.8rem; letter-spacing: 0.04em; }
.petit-titre { margin: 1.5rem 0 0.6rem; }

.champ {
  width: 100%;
  padding: 0.75rem 0;
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--bordure);
  border-radius: 0;
  outline: none;
  transition: border-color 0.2s;
}
.champ:focus { border-bottom-color: var(--texte); }
.champ::placeholder { color: var(--discret); opacity: 0.5; }

/* Saisie */
.entete-exercice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding-top: 0.25rem;
}
.entete-exercice h2 { font-size: 1.6rem; letter-spacing: -0.02em; }
.repos {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--bordure);
  color: var(--discret);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}
.repos input {
  width: 3rem;
  padding: 0;
  border: 0;
  background: none;
  text-align: right;
  outline: none;
  color: var(--texte);
}

.cadrans { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin: 1.25rem 0 1rem; }
.cadran {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: ns-resize;
  outline: none;
  transition: border-color 0.2s;
}
.cadran:focus-visible { border-color: var(--discret); }
.cadran .etiquette { display: block; }
.cadran-tete { display: flex; justify-content: space-between; align-items: center; }
.cadran .valeur.texte { font-size: 1.1rem; letter-spacing: -0.01em; }
.cadran .valeur {
  font-size: 3rem;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.04em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.series { list-style: none; margin: 0.5rem 0 0; padding: 0; }
.series li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 0;
  border-top: 1px solid var(--bordure);
  font-variant-numeric: tabular-nums;
  font-size: 0.95rem;
}
.series li span:first-child { color: var(--discret); width: 1.5rem; }
h3.etiquette { margin: 1.75rem 0 0.25rem; }

.bas {
  position: sticky;
  bottom: 0;
  margin: 0 -1.25rem;
  padding: 1.5rem 1.25rem calc(1rem + env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, transparent, var(--fond) 2rem);
}
.bas .bouton { margin-top: 0; }

.minuteur {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  padding: 0.35rem 0.35rem 0.35rem 1.25rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--bordure);
  font-variant-numeric: tabular-nums;
}
.compte { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.02em; }

/* Historique */
#liste-historique { display: grid; gap: 1rem; }
#liste-historique .carte-titre { color: var(--texte); text-transform: none; letter-spacing: 0; font-size: 0.95rem; }

/* Message */
.message {
  position: fixed;
  left: 50%;
  bottom: calc(1.25rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 2.5rem);
  padding: 0.6rem 1rem;
  border-radius: 999px;
  background: var(--texte);
  color: var(--fond);
  font-size: 0.85rem;
  font-weight: 500;
  z-index: 3;
}

/* Connexion : mêmes tokens et formes que l'accueil */
body.login {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 1.25rem;
}
.connexion {
  width: 100%;
  max-width: 20rem;
  animation: entree 0.7s var(--ease) backwards;
}
.ligne-connexion {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}
.connexion input {
  flex: none;
  width: 100%;
  height: 3.5rem;
  padding: 0 1.25rem;
  font: inherit;
  font-size: 1rem;
  text-align: center;
  color: var(--texte);
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: 18px;
  outline: none;
  transition: border-color 0.25s, box-shadow 0.25s, transform 0.25s var(--ease);
}
.connexion input::placeholder { color: var(--discret); }
.connexion input:focus {
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 16%, transparent);
}
.connexion .bouton {
  flex: none;
  display: grid;
  place-items: center;
  width: 3.5rem;
  height: 3.5rem;
  margin: 0;
  padding: 0;
  border-radius: 50%;
  box-shadow: 0 10px 30px -12px color-mix(in srgb, var(--accent) 70%, transparent);
  animation: entree 0.6s 0.15s var(--ease) backwards;
}
.connexion .bouton svg { width: 1.2rem; height: 1.2rem; }
.erreur {
  margin: 0.25rem 0 0;
  color: var(--alerte);
  font-size: 0.85rem;
  text-align: center;
  animation: secouer 0.45s var(--ease);
}

/* Animations : fluides, courtes, toujours désactivables */
:root {
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes entree {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}
@keyframes apparaitre {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes secouer {
  0%, 100% { transform: none; }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(2px); }
}
@keyframes rebond {
  0% { transform: scale(1); }
  35% { transform: scale(1.07); }
  100% { transform: scale(1); }
}
@keyframes dessiner {
  from { stroke-dashoffset: 1; }
  to { stroke-dashoffset: 0; }
}
@keyframes toast {
  from { opacity: 0; transform: translate(-50%, 14px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* Vues : entrée douce à chaque affichage */
main > section:not([hidden]) {
  animation: entree 0.45s var(--ease) backwards;
}

/* Cartes : entrée en cascade */
.grille > .carte {
  animation: entree 0.55s var(--ease) backwards;
  animation-delay: calc(var(--i, 0) * 70ms + 60ms);
}

.grille > .carte,
.carte {
  transition: transform 0.35s var(--ease), box-shadow 0.35s var(--ease), border-color 0.35s;
}
@media (hover: hover) {
  .carte:hover {
    transform: translateY(-2px);
    border-color: color-mix(in srgb, var(--texte) 12%, transparent);
    box-shadow: 0 18px 40px -26px rgb(0 0 0 / 0.7);
  }
}

.bandeau { animation: entree 0.5s var(--ease) backwards; }
.minuteur { animation: entree 0.45s var(--ease) backwards; }
.message { animation: toast 0.4s var(--ease) backwards; }
#titre.fondu { animation: apparaitre 0.35s var(--ease) backwards; }

/* Séries : la dernière ajoutée arrive en glissant */
.series li.nouvelle { animation: entree 0.45s var(--ease) backwards; }

/* Chiffres : léger rebond quand la valeur change */
.cadran .valeur.rebond { animation: rebond 0.3s var(--ease); }

/* Courbe : tracé progressif puis points qui apparaissent */
.graphe .trait {
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  animation: dessiner 1.2s var(--ease) backwards;
}
.graphe .aire { animation: apparaitre 0.9s 0.35s var(--ease) backwards; }
.graphe .point { animation: apparaitre 0.35s var(--ease) backwards; animation-delay: calc(var(--k, 0) * 45ms + 700ms); }

/* Boutons et pastilles : retour de couleur fluide */
.puce, .pilule, .segments button, .rond, .bouton-discret {
  transition: background 0.25s var(--ease), color 0.25s var(--ease), border-color 0.25s, transform 0.12s var(--ease), opacity 0.2s;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Recherche d'exercice */
.recherche-form { margin-top: 0.5rem; }
.recherche {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  height: 3.5rem;
  padding: 0 1.1rem;
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: 18px;
  transition: border-color 0.25s, box-shadow 0.25s;
}
.recherche:focus-within {
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 16%, transparent);
}
.recherche > svg {
  flex: none;
  width: 1.15rem;
  height: 1.15rem;
  fill: none;
  stroke: var(--discret);
  stroke-width: 2;
  stroke-linecap: round;
}
.recherche input {
  flex: 1;
  min-width: 0;
  padding: 0;
  background: none;
  border: 0;
  outline: none;
  font-size: 1.05rem;
  color: var(--texte);
  -webkit-appearance: none;
  appearance: none;
}
.recherche input::placeholder { color: var(--discret); }
.recherche input::-webkit-search-cancel-button { display: none; }

.resultats {
  display: grid;
  gap: 0.25rem;
  margin: 0.75rem 0 0;
  padding: 0;
  list-style: none;
}
.resultats li { list-style: none; }

.ligne-exercice {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.95rem 1rem;
  border-radius: 16px;
  text-align: left;
  background: transparent;
  animation: entree 0.4s var(--ease) backwards;
  animation-delay: calc(var(--i, 0) * 28ms);
  transition: background 0.2s, transform 0.12s var(--ease);
}
.ligne-exercice:hover { background: var(--surface); }
.ligne-exercice:active { transform: scale(0.985); }
.ligne-exercice .nom { font-weight: 500; }
.ligne-exercice .detail {
  color: var(--discret);
  font-size: 0.8rem;
  white-space: nowrap;
}
.ligne-exercice.creer {
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 18%, transparent), color-mix(in srgb, var(--accent-2) 14%, transparent));
  border: 1px dashed color-mix(in srgb, var(--accent) 45%, transparent);
}
.ligne-exercice.creer .nom { color: var(--accent); }

/* Bouton d'ajout compact sur l'accueil */
.actions-accueil .bouton-plus {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: max-content;
  height: 3rem;
  margin: 1.5rem auto 0;
  padding: 0 1.25rem 0 1rem;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-texte);
  font-weight: 600;
  box-shadow: 0 10px 30px -12px color-mix(in srgb, var(--accent) 70%, transparent);
  transition: transform 0.12s var(--ease);
}
.actions-accueil .bouton-plus:active { transform: scale(0.96); }
.bouton-plus svg {
  width: 1.2rem;
  height: 1.2rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
}

/* Boutons ronds de l'en-tête : retour et déconnexion */
.rond-barre {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--bordure);
  color: var(--texte);
  transition: background 0.2s, transform 0.12s var(--ease);
}
.rond-barre:hover { background: var(--surface-2); }
.rond-barre:active { transform: scale(0.92); }
.rond-barre svg {
  width: 1.2rem;
  height: 1.2rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Le poids (avec son unité) reste sur une ligne */
.cadran .valeur { white-space: nowrap; }
.cadran {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.5rem;
  min-height: 7.5rem;
  padding: 0.9rem 1rem;
}
.cadran .etiquette { display: block; }
.cadran .valeur { text-align: left; }
.cadran .valeur-poids { display: flex; align-items: baseline; gap: 0.3rem; }
.cadran .unite { color: var(--discret); font-size: 0.9rem; font-weight: 500; }
#cadran-poids .valeur:not(.texte) { font-size: 2.6rem; }
#cadran-poids .cadran-tete { margin-bottom: 0.25rem; }

/* Confirmation de déconnexion */
.confirmation {
  width: min(20rem, calc(100% - 2.5rem));
  margin: auto;
  padding: 1.5rem;
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  background: var(--surface);
  color: var(--texte);
  box-shadow: 0 30px 80px -30px rgb(0 0 0 / 0.6);
}
.confirmation[open] { animation: entree 0.35s var(--ease) backwards; }
.confirmation::backdrop {
  background: rgb(0 0 0 / 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: apparaitre 0.25s var(--ease) backwards;
}
.feuille-titre { margin: 0; font-size: 1.1rem; font-weight: 600; }
.feuille-texte { margin: 0.4rem 0 0; color: var(--discret); font-size: 0.9rem; }
.feuille-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin-top: 1.25rem; }
.feuille-actions .bouton { margin-top: 0; height: 2.75rem; font-size: 0.9rem; box-shadow: none; }
.bouton-secondaire {
  height: 2.75rem;
  border-radius: 18px;
  background: var(--surface-2);
  border: 1px solid var(--bordure);
  color: var(--texte);
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.2s;
}
.bouton-secondaire:hover { background: color-mix(in srgb, var(--surface-2) 80%, var(--texte) 8%); }

.conseil {
  margin: 0.5rem 0 0;
  padding: 0 0.5rem;
  color: var(--discret);
  font-size: 0.8rem;
  text-align: center;
}

/* Règles graduées de répétitions et de poids */
.regle {
  position: relative;
  height: 3.9rem;
  margin: 0.25rem -1rem -0.9rem;
  overflow: hidden;
  touch-action: pan-y;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
.regle:active { cursor: grabbing; }
.regle::before,
.regle::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2.5rem;
  z-index: 1;
  pointer-events: none;
}
.regle::before { left: 0; background: linear-gradient(to right, var(--surface), transparent); }
.regle::after { right: 0; background: linear-gradient(to left, var(--surface), transparent); }
.graduations {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  will-change: transform;
}
.graduations .trait {
  position: absolute;
  bottom: 1.2rem;
  width: 1px;
  height: 0.45rem;
  background: var(--discret);
  opacity: 0.45;
}
.graduations .trait.majeure {
  height: 0.9rem;
  opacity: 0.9;
}
.graduations .nombre {
  position: absolute;
  bottom: 0;
  transform: translateX(-50%);
  color: var(--discret);
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.regle .curseur {
  position: absolute;
  left: 50%;
  top: 0.25rem;
  bottom: 1.2rem;
  width: 2px;
  margin-left: -1px;
  border-radius: 2px;
  background: var(--accent);
  z-index: 2;
  pointer-events: none;
}

/* Chronomètre de repos : anneau qui se vide, chiffres lisibles de loin */
.minuteur {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  margin: 1.5rem 0 0;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 0;
}
.minuteur .anneau {
  position: relative;
  width: 22rem;
  height: 22rem;
  max-width: 80vw;
  max-height: 80vw;
}
.minuteur svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.minuteur .piste {
  fill: none;
  stroke: var(--surface-2);
  stroke-width: 9;
}
.minuteur .progres {
  fill: none;
  stroke-width: 9;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  opacity: 0;
  transition: stroke-dashoffset 0.25s linear, stroke 0.4s var(--ease);
}
.minuteur[data-etat="vert"] .progres { stroke: #4ade80; }
.minuteur[data-etat="ambre"] .progres { stroke: #fbbf24; }
.minuteur[data-etat="rouge"] .progres { stroke: #f87171; }
.minuteur .compte {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 4.6rem;
  font-weight: 650;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.minuteur .controles {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  margin: 1.5rem 0 2.35rem;
}
.minuteur .controles .pilule { min-width: 4.5rem; padding: 0.55rem 1rem; }
.rond-action {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--bordure);
  color: var(--texte);
  transition: background 0.2s, transform 0.12s var(--ease);
}
.rond-action:hover { background: color-mix(in srgb, var(--surface-2) 80%, var(--texte) 8%); }
.rond-action:active { transform: scale(0.92); }
.rond-action svg {
  width: 1.15rem;
  height: 1.15rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
#valider { margin-top: 0; }

/* Bouton d'ajout flottant : carré arrondi, toujours visible sur l'accueil */
.bouton-flottant {
  position: fixed;
  right: 1.25rem;
  bottom: calc(1.25rem + env(safe-area-inset-bottom));
  z-index: 3;
  display: grid;
  place-items: center;
  width: 3.75rem;
  height: 3.75rem;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-texte);
  box-shadow: 0 14px 34px -12px color-mix(in srgb, var(--accent) 75%, transparent);
  transition: transform 0.15s var(--ease), box-shadow 0.25s var(--ease);
}
.bouton-flottant:hover { box-shadow: 0 18px 40px -12px color-mix(in srgb, var(--accent) 85%, transparent); }
.bouton-flottant:active { transform: scale(0.92); }
.bouton-flottant svg {
  width: 1.6rem;
  height: 1.6rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
}

/* Bouton Valider la série (thème sombre) : fond gris des cartes, texte blanc,
   contour et coche au dégradé d'origine */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) #valider {
    background:
      linear-gradient(var(--surface), var(--surface)) padding-box,
      linear-gradient(135deg, var(--accent), var(--accent-2)) border-box;
    color: #ffffff;
    border: 1px solid transparent;
    box-shadow: none;
  }
  :root:not([data-theme="light"]) #valider svg { stroke: var(--accent); }
}
:root[data-theme="dark"] #valider {
  background:
    linear-gradient(var(--surface), var(--surface)) padding-box,
    linear-gradient(135deg, var(--accent), var(--accent-2)) border-box;
  color: #ffffff;
  border: 1px solid transparent;
  box-shadow: none;
}
:root[data-theme="dark"] #valider svg { stroke: var(--accent); }

/* Suppression dans l'historique */
.actions-ligne { display: flex; align-items: center; gap: 0.5rem; }
.bouton-icone {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 10px;
  color: var(--discret);
  transition: background 0.2s, color 0.2s;
}
.bouton-icone:hover { background: var(--surface-2); color: var(--texte); }
.bouton-icone svg, .chip-x svg {
  width: 1rem;
  height: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.exercice-historique { padding: 0.75rem 0; border-top: 1px solid var(--bordure); }
.ligne-haut { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.exercice-historique .nom { font-weight: 500; }
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.25rem 0.3rem 0.25rem 0.7rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--bordure);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}
.chip-x {
  display: grid;
  place-items: center;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  color: var(--discret);
}
.chip-x:hover { background: var(--bordure); color: var(--texte); }
.bouton-danger {
  background: linear-gradient(135deg, #f87171, #fb7185);
  color: #0c0c0c;
  box-shadow: none;
}

/* Vignettes d'exercice (photo ou icône par défaut) */
.vignette {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 2.25rem;
  height: 2.25rem;
  overflow: hidden;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--bordure);
  color: var(--discret);
  cursor: pointer;
  transition: transform 0.15s var(--ease);
}
.vignette:hover { transform: scale(1.05); }
.vignette:active { transform: scale(0.95); }
.vignette img { width: 100%; height: 100%; object-fit: cover; }
.vignette svg, .icone-exercice svg {
  width: 55%;
  height: 55%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}
.gauche { display: flex; align-items: center; gap: 0.6rem; min-width: 0; }
.nom-avec-vignette { display: flex; align-items: center; gap: 0.6rem; }
.titre-exercice { display: flex; align-items: center; gap: 0.6rem; }
.titre-exercice .vignette { width: 2.6rem; height: 2.6rem; }
.icone-exercice {
  display: inline-grid;
  place-items: center;
  color: var(--discret);
}

/* Fiche exercice */
.fiche, .agrandi {
  width: min(22rem, calc(100% - 2.5rem));
  margin: auto;
  padding: 1rem 1.25rem 1.25rem;
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  background: var(--surface);
  color: var(--texte);
  box-shadow: 0 30px 80px -30px rgb(0 0 0 / 0.6);
}
.fiche[open] { animation: entree 0.35s var(--ease) backwards; }
.fiche::backdrop, .agrandi::backdrop {
  background: rgb(0 0 0 / 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.fiche-entete { display: flex; justify-content: flex-end; margin: 0; }
.fiche-visuel {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  margin: 0.25rem 0 0.75rem;
  border-radius: 16px;
  background: var(--surface-2);
  overflow: hidden;
}
.fiche-visuel img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.fiche-visuel .icone-exercice { width: 100%; height: 100%; }
.fiche-visuel .icone-exercice svg { width: 40%; height: 40%; }
.fiche-nom { font-size: 1.2rem; margin-bottom: 0.75rem; }
.fiche-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.75rem; }
.fiche-liste { display: grid; border-top: 1px solid var(--bordure); }
.ligne-action {
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--bordure);
  text-align: left;
  font-size: 0.95rem;
}
.ligne-action.danger { color: #f87171; }
.renommer { display: flex; gap: 0.5rem; padding: 0.6rem 0; }
.champ-fin {
  flex: 1;
  min-width: 0;
  padding: 0.5rem 0.2rem;
  font-size: 1rem;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--bordure);
  outline: none;
  color: var(--texte);
}
.champ-fin:focus { border-bottom-color: var(--texte); }
.agrandi { width: min(40rem, calc(100% - 1.5rem)); padding: 0.5rem; }
.agrandi img { display: block; width: 100%; height: auto; border-radius: 12px; cursor: zoom-out; }
.vignette .icone-exercice { width: 100%; height: 100%; }
.vignette .icone-exercice svg { width: 50%; height: 50%; }

/* Modification d'une série depuis l'historique */
.chip-texte {
  padding: 0;
  font: inherit;
  color: inherit;
  font-variant-numeric: tabular-nums;
}
.chip-texte:hover { text-decoration: underline; text-underline-offset: 0.2em; }
.champs-serie { display: grid; gap: 0.25rem; margin-top: 0.75rem; }
.champs-serie .etiquette { margin-top: 0.5rem; }

/* Fiche exercice : boutons icônes centrés */
.fiche-visuel { margin: 0 0 0.9rem; }
.fiche-outils {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.outil {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  flex: none;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--bordure);
  color: var(--texte);
  transition: background 0.2s, transform 0.12s var(--ease), opacity 0.2s;
}
.outil:hover { background: color-mix(in srgb, var(--surface-2) 80%, var(--texte) 8%); }
.outil:active { transform: scale(0.92); }
.outil svg {
  width: 1.2rem;
  height: 1.2rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.outil.principal {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-texte);
  border: 0;
}
.outil.danger { color: #f87171; }
.fiche-renommer {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1rem;
}
.fiche-renommer .champ-fin { font-size: 1.05rem; }
.fiche-pied {
  display: flex;
  justify-content: center;
  padding-top: 0.75rem;
  border-top: 1px solid var(--bordure);
}

/* Photo agrandie : plein écran, croix visible en haut à droite */
.agrandi {
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #000;
  display: grid;
  place-items: center;
  box-shadow: none;
}
.agrandi img {
  max-width: 100%;
  max-height: 100dvh;
  object-fit: contain;
  border-radius: 0;
  cursor: zoom-out;
}
.agrandi-fermer {
  position: fixed;
  top: calc(1rem + env(safe-area-inset-top));
  right: 1rem;
  margin: 0;
}
.fermer-grand {
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: rgb(255 255 255 / 0.15);
  color: #fff;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.fermer-grand svg {
  width: 1.5rem;
  height: 1.5rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
}

/* Fenêtre fermée = masquée (le plein écran ne doit pas réapparaître en bas de page) */
dialog:not([open]) { display: none; }

/* Fiche : supprimer à gauche, fermer à droite, sur la même ligne ; espace sous la ligne */
.fiche-entete {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0 0 1rem;
}
#fiche-valider-nom { border-radius: 14px; }
