/* Tokens : seul endroit où vivent couleurs, espacements et typo. */
:root {
  color-scheme: light;
  --bg: #f4f2ed;
  --surface: #ffffff;
  --surface-2: #ece9e2;
  --text: #1c1d1f;
  --muted: #595e64;
  --border: #d9d5cc;
  --accent: #b93b0b;
  --accent-text: #ffffff;
  --ok: #166534;     --ok-bg: #dcfce7;
  --done: #1e40af;   --done-bg: #dbeafe;
  --partial: #854d0e; --partial-bg: #fef3c7;
  --missed: #991b1b; --missed-bg: #fee2e2;
  --bubble: #fbe6dc;

  --font: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --fs-sm: .8125rem;
  --fs: 1rem;
  --fs-lg: 1.25rem;
  --fs-xl: 1.75rem;
  --s1: .25rem; --s2: .5rem; --s3: .75rem; --s4: 1rem; --s5: 1.5rem; --s6: 2rem;
  --radius: 1rem;
  --shadow: 0 1px 2px rgb(0 0 0 / .06), 0 4px 16px rgb(0 0 0 / .05);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #121315;
    --surface: #1c1e21;
    --surface-2: #26292d;
    --text: #eceef0;
    --muted: #a4aab1;
    --border: #33373c;
    --accent: #ff8a5c;
    --accent-text: #1a0b04;
    --ok: #86efac;      --ok-bg: #12301e;
    --done: #93c5fd;    --done-bg: #152440;
    --partial: #fcd34d; --partial-bg: #3a2a08;
    --missed: #fca5a5;  --missed-bg: #3d1515;
    --bubble: #3a2219;
    --shadow: none;
  }
}

/* Base */
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: var(--fs)/1.5 var(--font); -webkit-font-smoothing: antialiased;
}
main { max-width: 40rem; margin: 0 auto; padding: var(--s4); display: grid; gap: var(--s4); }
h1, h2, h3, p { margin: 0; }
h2 { font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.muted { color: var(--muted); font-size: var(--fs-sm); }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Boutons et champs */
button, .btn {
  font: inherit; font-weight: 600; border: 0; border-radius: 999px; cursor: pointer;
  padding: var(--s3) var(--s5); background: var(--accent); color: var(--accent-text);
}
.btn-ghost { font-weight: 600; text-decoration: none; white-space: nowrap; background: transparent; color: var(--muted); padding: var(--s2) var(--s3); font-size: var(--fs-sm); }
input {
  font: inherit; width: 100%; padding: var(--s3); border-radius: calc(var(--radius) / 2);
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
}

/* Barre du haut */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.topbar h1 { font-size: var(--fs-lg); }
.brand span { color: var(--accent); }

/* Carte */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: var(--s4); box-shadow: var(--shadow); display: grid; gap: var(--s3); min-width: 0;
}
.card-hero { border-top: 4px solid var(--accent); }
.hero-title { font-size: var(--fs-xl); line-height: 1.15; }

/* Fonction (étiquette) */
.chip {
  display: inline-block; font-size: var(--fs-sm); font-weight: 600; padding: var(--s1) var(--s3);
  border-radius: 999px; background: var(--surface-2); color: var(--text);
}

/* Cibles */
.targets { display: grid; grid-template-columns: repeat(auto-fit, minmax(6.5rem, 1fr)); gap: var(--s2); margin: 0; }
.targets div { background: var(--surface-2); border-radius: calc(var(--radius) / 2); padding: var(--s2) var(--s3); }
.targets dt { font-size: var(--fs-sm); color: var(--muted); }
.targets dd { margin: 0; font-weight: 600; }

/* Badge de Statut de séance : icône + texte + style de bordure, jamais la couleur seule */
.badge {
  display: inline-flex; align-items: center; gap: var(--s1); white-space: nowrap;
  font-size: var(--fs-sm); font-weight: 600; padding: 2px var(--s3); border-radius: 999px;
  border: 2px solid currentColor;
}
.badge::before { font-weight: 700; }
.badge-reussie { color: var(--ok); background: var(--ok-bg); }
.badge-reussie::before { content: "✓"; }
.badge-realisee { color: var(--done); background: var(--done-bg); border-style: double; border-width: 3px; }
.badge-realisee::before { content: "●"; }
.badge-partielle { color: var(--partial); background: var(--partial-bg); border-style: dashed; }
.badge-partielle::before { content: "½"; }
.badge-manquee { color: var(--missed); background: var(--missed-bg); border-style: dotted; }
.badge-manquee::before { content: "✕"; }

/* Jauge */
.gauges { display: grid; grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr)); gap: var(--s3); }
.gauge-head { display: flex; justify-content: space-between; gap: var(--s2); align-items: baseline; }
.gauge-value { font-weight: 700; }
.gauge { height: .5rem; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin: var(--s1) 0; }
.gauge > span { display: block; height: 100%; width: var(--v); background: var(--accent); border-radius: inherit; }

/* Graphique en barres */
.bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: var(--s2); align-items: end; height: 6rem; margin: 0; padding: 0; list-style: none; }
.bars li { display: grid; grid-template-rows: 1fr auto; height: 100%; gap: var(--s1); text-align: center; }
.bars .bar { align-self: end; height: var(--h); min-height: 3px; background: var(--accent); border-radius: 4px 4px 2px 2px; }
.bars .bar.zero { background: var(--border); }

/* Liste de séances */
.sessions { list-style: none; margin: 0; padding: 0; display: grid; }
.sessions li { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) 0; border-top: 1px solid var(--border); }
.sessions li:first-child { border-top: 0; }
.sessions .day { width: 2.5rem; color: var(--muted); font-size: var(--fs-sm); }
.sessions .title { flex: 1; min-width: 0; overflow-wrap: anywhere; }

/* Bulle de chat */
.bubble { max-width: 90%; padding: var(--s3) var(--s4); border-radius: var(--radius); background: var(--surface-2); }
.bubble-coach { background: var(--bubble); border-bottom-left-radius: var(--s1); }
.bubble-me { justify-self: end; background: var(--accent); color: var(--accent-text); border-bottom-right-radius: var(--s1); }
.bubble-from { font-size: var(--fs-sm); font-weight: 600; margin-bottom: var(--s1); }

/* Login */
.login { min-height: 100dvh; align-content: center; max-width: 22rem; }
.login form { display: grid; gap: var(--s3); }
.error { color: var(--missed); font-weight: 600; }
.demo-note { text-align: center; }

/* Liens, formulaires empilés, tableau de données */
a { color: var(--accent); }
.stack { display: grid; gap: var(--s3); }
.sync-ok { color: var(--ok); font-weight: 600; }
.data { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.data th, .data td { padding: var(--s2) var(--s1); text-align: right; border-top: 1px solid var(--border); }
.data thead th { border-top: 0; color: var(--muted); font-weight: 600; }
.data th:first-child { text-align: left; }
.data abbr { text-decoration: none; }

/* Navigation, jour courant, formulaire */
.plain { color: inherit; text-decoration: none; }
.nav { display: flex; align-items: center; gap: 0; flex-wrap: wrap; justify-content: flex-end; }
.nav .btn-ghost { padding: var(--s2); }
.pager { display: flex; justify-content: space-between; }
.btn { display: inline-block; text-decoration: none; }
.is-today { background: var(--surface-2); margin: 0 calc(-1 * var(--s2)); padding-left: var(--s2) !important; padding-right: var(--s2) !important; border-radius: calc(var(--radius) / 2); }
.sessions .day { line-height: 1.2; }
.sessions .chip { font-size: .75rem; padding: 0 var(--s2); }
textarea { font: inherit; width: 100%; padding: var(--s3); border-radius: calc(var(--radius) / 2); border: 1px solid var(--border); background: var(--surface-2); color: var(--text); }
.sessions .done { font-size: var(--fs-sm); font-weight: 600; }
.sessions .free { font-size: var(--fs-sm); color: var(--muted); font-style: italic; }
.sessions .badge { align-self: center; }
.sessions .detail { font-size: var(--fs-sm); }
.push-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); }
