/* ===========================================================================
   Le carnet de Soraya — Design system
   Mobile-first · romantique raffiné · thèmes clair & sombre.

   Architecture : tokens sémantiques (--bg, --surface, --text, --primary…)
   redéfinis par thème. Les composants ne référencent JAMAIS une couleur brute,
   uniquement des tokens — le mode sombre est un simple échange de variables.
   =========================================================================== */

/* ---------------------------------------------------------------------------
   1. TOKENS — Thème clair (défaut)
   --------------------------------------------------------------------------- */
:root {
  color-scheme: light;

  /* Palette brute (référence interne) */
  --c-cream:       #fdf7f2;
  --c-cream-2:     #f6eae1;
  --c-terracotta:  #c4633f;
  --c-terracotta-2:#a94f30;
  --c-plum:        #5b2a40;
  --c-plum-2:      #7d4360;
  --c-rose:        #e8a598;
  --c-rose-deep:   #d97f6e;
  --c-gold:        #c98a2e;
  --c-green:       #5e9b73;
  --c-red:         #cf5246;

  /* Surfaces & fonds */
  --bg:            #fbf3ed;
  --bg-tint-1:     rgba(232, 165, 152, 0.20);
  --bg-tint-2:     rgba(125, 67, 96, 0.10);
  --surface:       #fffaf6;
  --surface-2:     #f7ece4;
  --surface-3:     #f1e2d8;
  --surface-inset: #fbf2ec;

  /* Texte */
  --text:          #2f2421;
  --text-soft:     #6f5d57;
  --text-faint:    #9c8a82;
  --on-accent:     #fffaf6;   /* texte sur surfaces colorées vives */

  /* Lignes & bordures */
  --border:        #efe0d6;
  --border-soft:   #f3e8e0;
  --border-strong: #e4cfc2;

  /* Couleurs de marque (sémantiques) */
  --primary:       #c4633f;
  --primary-strong:#a94f30;
  --primary-tint:  rgba(196, 99, 63, 0.12);
  --plum:          #5b2a40;
  --plum-soft:     #7d4360;
  --rose:          #e8a598;
  --rose-deep:     #d97f6e;
  --gold:          #c98a2e;
  --green:         #5e9b73;
  --red:           #cf5246;

  /* Dégradés signature */
  --grad-feature:  linear-gradient(145deg, #6a3450 0%, #4d2236 100%);
  --grad-warm:     linear-gradient(145deg, #e9a895 0%, #d2715d 100%);
  --grad-primary:  linear-gradient(145deg, #cf6e48 0%, #b4542f 100%);
  --grad-gold:     linear-gradient(145deg, #e0b15a 0%, #c98a2e 100%);
  --sheen:         linear-gradient(180deg, rgba(255,255,255,.22), rgba(255,255,255,0));

  /* Élévation — ombres teintées prune, en couches */
  --shadow-sm:  0 1px 2px rgba(67, 30, 47, 0.06), 0 2px 6px rgba(67, 30, 47, 0.06);
  --shadow:     0 2px 6px rgba(67, 30, 47, 0.07), 0 12px 28px rgba(67, 30, 47, 0.10);
  --shadow-lg:  0 8px 20px rgba(67, 30, 47, 0.10), 0 24px 50px rgba(67, 30, 47, 0.16);
  --shadow-color:0 10px 30px rgba(196, 99, 63, 0.28);
  --ring:       0 0 0 3px rgba(217, 127, 110, 0.30);

  /* Rayons */
  --radius-xl: 26px;
  --radius:    20px;
  --radius-sm: 13px;
  --radius-xs: 9px;

  /* Typographie */
  --font:      "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --display:   "Fraunces", "Georgia", "Times New Roman", serif;

  /* Glassmorphism (header / tabbar) */
  --glass:      rgba(255, 250, 246, 0.72);
  --glass-line: rgba(91, 42, 64, 0.10);

  /* Surfaces colorées : texte lisible posé dessus */
  --on-feature: #fdeee8;
  --on-warm:    #4a1f10;
}

/* ---------------------------------------------------------------------------
   2. TOKENS — Thème sombre (aubergine chaud, jamais noir pur)
   --------------------------------------------------------------------------- */
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg:            #1b1016;
  --bg-tint-1:     rgba(217, 127, 110, 0.14);
  --bg-tint-2:     rgba(125, 67, 96, 0.22);
  --surface:       #271721;
  --surface-2:     #32202c;
  --surface-3:     #3d2937;
  --surface-inset: #20131b;

  --text:          #f4e7e0;
  --text-soft:     #cdb4ac;
  --text-faint:    #9a7f7a;
  --on-accent:     #fff6f1;

  --border:        rgba(255, 235, 225, 0.10);
  --border-soft:   rgba(255, 235, 225, 0.07);
  --border-strong: rgba(255, 235, 225, 0.18);

  --primary:       #e8895f;
  --primary-strong:#f0a07d;
  --primary-tint:  rgba(232, 137, 95, 0.18);
  --plum:          #d9a6bd;
  --plum-soft:     #c98aa6;
  --rose:          #e8a598;
  --rose-deep:     #ec9683;
  --gold:          #e6b860;
  --green:         #78b98c;
  --red:           #e87a6e;

  --grad-feature:  linear-gradient(145deg, #4a2338 0%, #2c1320 100%);
  --grad-warm:     linear-gradient(145deg, #b9604e 0%, #8c3f33 100%);
  --grad-primary:  linear-gradient(145deg, #d4744d 0%, #b1542f 100%);
  --grad-gold:     linear-gradient(145deg, #c69646 0%, #a4762f 100%);
  --sheen:         linear-gradient(180deg, rgba(255,255,255,.10), rgba(255,255,255,0));

  --shadow-sm:  0 1px 2px rgba(0, 0, 0, 0.30), 0 2px 6px rgba(0, 0, 0, 0.30);
  --shadow:     0 2px 8px rgba(0, 0, 0, 0.36), 0 14px 30px rgba(0, 0, 0, 0.46);
  --shadow-lg:  0 10px 24px rgba(0, 0, 0, 0.45), 0 28px 60px rgba(0, 0, 0, 0.58);
  --shadow-color:0 12px 32px rgba(232, 137, 95, 0.28);
  --ring:       0 0 0 3px rgba(232, 137, 95, 0.35);

  --glass:      rgba(33, 19, 27, 0.72);
  --glass-line: rgba(255, 235, 225, 0.10);

  --on-feature: #f4e2da;
  --on-warm:    #2a0f0a;
}

/* Suit le réglage système tant qu'aucun thème explicite n'est choisi. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    color-scheme: dark;
    --bg:#1b1016; --bg-tint-1:rgba(217,127,110,.14); --bg-tint-2:rgba(125,67,96,.22);
    --surface:#271721; --surface-2:#32202c; --surface-3:#3d2937; --surface-inset:#20131b;
    --text:#f4e7e0; --text-soft:#cdb4ac; --text-faint:#9a7f7a; --on-accent:#fff6f1;
    --border:rgba(255,235,225,.10); --border-soft:rgba(255,235,225,.07); --border-strong:rgba(255,235,225,.18);
    --primary:#e8895f; --primary-strong:#f0a07d; --primary-tint:rgba(232,137,95,.18);
    --plum:#d9a6bd; --plum-soft:#c98aa6; --rose:#e8a598; --rose-deep:#ec9683;
    --gold:#e6b860; --green:#78b98c; --red:#e87a6e;
    --grad-feature:linear-gradient(145deg,#4a2338 0%,#2c1320 100%);
    --grad-warm:linear-gradient(145deg,#b9604e 0%,#8c3f33 100%);
    --grad-primary:linear-gradient(145deg,#d4744d 0%,#b1542f 100%);
    --grad-gold:linear-gradient(145deg,#c69646 0%,#a4762f 100%);
    --sheen:linear-gradient(180deg,rgba(255,255,255,.10),rgba(255,255,255,0));
    --shadow-sm:0 1px 2px rgba(0,0,0,.30),0 2px 6px rgba(0,0,0,.30);
    --shadow:0 2px 8px rgba(0,0,0,.36),0 14px 30px rgba(0,0,0,.46);
    --shadow-lg:0 10px 24px rgba(0,0,0,.45),0 28px 60px rgba(0,0,0,.58);
    --shadow-color:0 12px 32px rgba(232,137,95,.28); --ring:0 0 0 3px rgba(232,137,95,.35);
    --glass:rgba(33,19,27,.72); --glass-line:rgba(255,235,225,.10);
    --on-feature:#f4e2da; --on-warm:#2a0f0a;
  }
}

/* ---------------------------------------------------------------------------
   3. BASE
   --------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 16px;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(at 100% 0%, var(--bg-tint-1) 0, transparent 42%),
    radial-gradient(at 0% 100%, var(--bg-tint-2) 0, transparent 42%);
  background-attachment: fixed;
  line-height: 1.55;
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-bottom: calc(86px + env(safe-area-inset-bottom));
  transition: background-color .4s ease, color .4s ease;
}

a { color: var(--primary); text-decoration: none; }

img, svg, canvas { max-width: 100%; }

h1, h2, h3, h4 {
  font-family: var(--display);
  font-weight: 600;
  line-height: 1.12;
  color: var(--plum);
  letter-spacing: -0.018em;
  margin: 0 0 0.4em;
  font-optical-sizing: auto;
}
h1 { font-size: 1.72rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.08rem; font-weight: 600; }
h4 { font-size: 0.95rem; }

p { margin: 0 0 0.7em; }
p:last-child { margin-bottom: 0; }

small { font-size: 0.8rem; }
b, strong { font-weight: 700; }

::selection { background: var(--rose); color: var(--plum); }

:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: var(--radius-xs);
}

.serif    { font-family: var(--display); }
.italic   { font-style: italic; }
.display  { font-family: var(--display); font-weight: 600; letter-spacing: -0.02em; }

/* ---------------------------------------------------------------------------
   4. MISE EN PAGE
   --------------------------------------------------------------------------- */
.wrap {
  max-width: 600px;
  margin: 0 auto;
  padding: 16px 18px 12px;
  animation: page-in .45s cubic-bezier(.22,.61,.36,1) both;
}

@keyframes page-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* En-tête vitrée, collante */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px calc(12px);
  padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--glass);
  backdrop-filter: saturate(160%) blur(16px);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  border-bottom: 1px solid var(--glass-line);
}
.app-header .brand {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
  font-family: var(--display);
  font-weight: 600;
  font-style: italic;
  color: var(--plum);
  font-size: 1.22rem;
  letter-spacing: -0.02em;
}
.app-header .brand small {
  font-style: normal;
  font-family: var(--font);
  font-size: .62rem;
  font-weight: 600;
  color: var(--rose-deep);
  letter-spacing: .22em;
  text-transform: uppercase;
  margin-top: 3px;
}
.header-actions { display: flex; align-items: center; gap: 6px; }

/* Bouton icône rond (thème, profil…) */
.icon-btn {
  -webkit-appearance: none; appearance: none;
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--plum);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform .12s ease, background .2s ease, color .2s ease, box-shadow .2s ease;
}
.icon-btn:hover { color: var(--primary); }
.icon-btn:active { transform: scale(.92); }
.icon-btn svg { width: 21px; height: 21px; }

/* Bascule de thème : icône soleil/lune qui pivote */
.theme-toggle .sun { display: none; }
.theme-toggle .moon { display: block; }
:root[data-theme="dark"] .theme-toggle .sun { display: block; }
:root[data-theme="dark"] .theme-toggle .moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .moon { display: none; }
}
.theme-toggle svg { transition: transform .5s cubic-bezier(.34,1.56,.64,1); }
.theme-toggle:active svg { transform: rotate(40deg); }

/* ---------------------------------------------------------------------------
   5. CARTES
   --------------------------------------------------------------------------- */
.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}
.card.pad-lg { padding: 22px; }
.card.tight  { padding: 14px; }

/* Carte « héros » prune */
.card.feature {
  color: var(--on-feature);
  background: var(--grad-feature);
  border: none;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card.feature::before {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(circle at 88% -10%, rgba(232,165,152,.30), transparent 45%),
    radial-gradient(circle at 0% 120%, rgba(201,138,46,.18), transparent 50%);
  pointer-events: none;
}
.card.feature > * { position: relative; }
.card.feature h1, .card.feature h2, .card.feature h3 { color: #fff; }

/* Carte « chaude » rosée */
.card.warm {
  color: var(--on-warm);
  background: var(--grad-warm);
  border: none;
  box-shadow: var(--shadow);
}
.card.warm h1, .card.warm h2, .card.warm h3 { color: #fff; }

/* Carte vitrée subtile */
.card.glass {
  background: var(--glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-color: var(--glass-line);
}

/* Lien-carte : tout le bloc cliquable */
a.card { display: block; color: inherit; transition: transform .14s ease, box-shadow .2s ease; }
a.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
a.card:active { transform: translateY(0); }

/* ---------------------------------------------------------------------------
   6. GRILLE DE STATISTIQUES
   --------------------------------------------------------------------------- */
.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 11px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 15px 8px;
  text-align: center;
  min-width: 0;
  box-shadow: var(--shadow-sm);
  transition: transform .14s ease, box-shadow .2s ease;
}
a.stat { color: inherit; display: block; }
a.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
a.stat:active { transform: translateY(0); }
.stat .num {
  font-family: var(--display);
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--primary);
  display: block;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.stat .lbl {
  font-size: .66rem; color: var(--text-soft); font-weight: 600;
  text-transform: uppercase; letter-spacing: .07em; margin-top: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block;
}

/* ---------------------------------------------------------------------------
   7. BOUTONS
   --------------------------------------------------------------------------- */
.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: inherit; font-size: 1rem; font-weight: 600; line-height: 1;
  padding: 14px 20px;
  border-radius: 999px; border: 1px solid transparent;
  cursor: pointer;
  color: var(--on-accent);
  background: var(--grad-primary);
  box-shadow: var(--shadow-sm), 0 6px 16px rgba(196,99,63,.24);
  transition: transform .1s ease, filter .18s ease, box-shadow .2s ease, background .2s ease;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
.btn::after { /* sheen léger en haut */
  content: ""; position: absolute; inset: 0 0 50% 0;
  background: var(--sheen); pointer-events: none; opacity: .9;
}
.btn:hover { filter: brightness(1.04); box-shadow: var(--shadow), 0 8px 20px rgba(196,99,63,.30); }
.btn:active { transform: scale(.975); }
.btn svg { width: 18px; height: 18px; }

.btn.block { display: flex; width: 100%; }
.btn.lg    { padding: 16px 24px; font-size: 1.05rem; }
.btn.sm    { padding: 9px 14px; font-size: .85rem; box-shadow: var(--shadow-sm); }
.btn.xs    { padding: 7px 11px; font-size: .78rem; box-shadow: none; }

.btn.plum  { background: var(--grad-feature); box-shadow: var(--shadow-sm), 0 6px 16px rgba(91,42,64,.26); }
.btn.gold  { background: var(--grad-gold); color: #3c2a06; box-shadow: var(--shadow-sm), 0 6px 16px rgba(201,138,46,.26); }

.btn.ghost {
  background: transparent; color: var(--primary);
  border: 1.5px solid var(--border-strong); box-shadow: none;
}
.btn.ghost::after { display: none; }
.btn.ghost:hover { background: var(--primary-tint); filter: none; border-color: var(--rose-deep); }

.btn.soft {
  background: var(--surface-2); color: var(--plum);
  border: 1px solid var(--border); box-shadow: none;
}
.btn.soft::after { display: none; }
.btn.soft:hover { background: var(--surface-3); filter: none; }

.btn.danger {
  background: transparent; color: var(--red);
  border: 1.5px solid var(--border-strong); box-shadow: none;
}
.btn.danger::after { display: none; }
.btn.danger:hover { background: rgba(207,82,70,.08); border-color: var(--red); filter: none; }

.btn:disabled { opacity: .5; pointer-events: none; }

/* Bouton ✕ rond compact (suppression d'item) */
.btn-x {
  -webkit-appearance: none; appearance: none;
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text-faint); cursor: pointer; flex: 0 0 auto;
  transition: transform .1s ease, background .2s, color .2s;
}
.btn-x:hover { background: rgba(207,82,70,.10); color: var(--red); }
.btn-x:active { transform: scale(.9); }
.btn-x svg { width: 15px; height: 15px; }

/* ---------------------------------------------------------------------------
   8. FORMULAIRES
   --------------------------------------------------------------------------- */
label {
  font-size: .82rem; color: var(--text-soft); font-weight: 600;
  display: block; margin-bottom: 6px; letter-spacing: -0.005em;
}
input, select, textarea {
  width: 100%;
  font-family: inherit; font-size: 1rem;
  padding: 13px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color .18s ease, box-shadow .18s ease, background .2s ease;
  -webkit-appearance: none; appearance: none;
}
textarea { resize: vertical; line-height: 1.5; }
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23a94f30' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
  padding-right: 40px;
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--rose-deep); box-shadow: var(--ring); background: var(--surface);
}
input[type="checkbox"], input[type="radio"] { width: auto; }
.field { margin-bottom: 15px; }
.field:last-child { margin-bottom: 0; }
.row { display: flex; gap: 11px; }
.row > * { flex: 1; min-width: 0; }
.help { font-size: .76rem; color: var(--text-soft); margin: 5px 0 0; }
.errorlist, ul.errorlist {
  color: var(--red); font-size: .8rem; list-style: none; padding: 0; margin: 6px 0 0;
}

/* Contrôle segmenté (onglets pilule) */
.segment {
  display: inline-flex; gap: 4px; padding: 4px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px;
}
.segment button, .segment a {
  border: none; background: transparent; cursor: pointer;
  font-family: inherit; font-size: .85rem; font-weight: 600; color: var(--text-soft);
  padding: 8px 14px; border-radius: 999px; transition: all .18s ease;
}
.segment .on, .segment [aria-selected="true"] {
  background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm);
}

/* ---------------------------------------------------------------------------
   9. BARRES DE PROGRESSION & MACROS
   --------------------------------------------------------------------------- */
.progress {
  background: var(--surface-3);
  border-radius: 999px; height: 11px; overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0,0,0,.06);
}
.progress > span {
  display: block; height: 100%; border-radius: 999px;
  background: var(--grad-primary);
  transition: width .7s cubic-bezier(.22,.61,.36,1);
  position: relative;
}
.progress.kcal    > span { background: var(--grad-primary); }
.progress.protein > span { background: linear-gradient(90deg, var(--plum-soft), var(--plum)); }
.progress.carbs   > span { background: var(--grad-gold); }
.progress.fat     > span { background: linear-gradient(90deg, var(--rose), var(--rose-deep)); }
.card.feature .progress { background: rgba(255,255,255,.16); box-shadow: none; }

.macro-row {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: .85rem; margin: 12px 0 5px;
}
.macro-row:first-child { margin-top: 4px; }
.macro-row b { color: var(--plum); font-variant-numeric: tabular-nums; }
.card.feature .macro-row, .card.feature .macro-row b { color: var(--on-feature); }

/* ---------------------------------------------------------------------------
   10. PASTILLES / BADGES
   --------------------------------------------------------------------------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 11px; border-radius: 999px;
  font-size: .73rem; font-weight: 600; letter-spacing: .01em;
  background: var(--surface-2); color: var(--plum-soft);
  border: 1px solid var(--border);
}
.chip.pr   { background: var(--grad-gold); color: #3c2a06; border: none; }
.chip.rose { background: var(--primary-tint); color: var(--primary-strong); border: none; }
.card.feature .chip { background: rgba(255,255,255,.18); color: #fff; border-color: rgba(255,255,255,.22); }

.badge-done, .badge-todo {
  padding: 4px 10px; border-radius: 999px; font-size: .7rem; font-weight: 700;
  letter-spacing: .01em; display: inline-flex; align-items: center; gap: 4px;
}
.badge-done { background: rgba(94,155,115,.16); color: var(--green); }
.badge-todo { background: rgba(207,82,70,.14); color: var(--red); }

/* ---------------------------------------------------------------------------
   11. LISTES
   --------------------------------------------------------------------------- */
.list { list-style: none; padding: 0; margin: 0; }
.list li {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 13px 0; border-bottom: 1px solid var(--border-soft);
}
.list li:last-child { border-bottom: none; }
.list li:first-child { padding-top: 4px; }

.muted { color: var(--text-soft); }
.faint { color: var(--text-faint); }
.tiny  { font-size: .77rem; }
.nowrap{ white-space: nowrap; }

/* ---------------------------------------------------------------------------
   12. SÉANCE D'ENTRAÎNEMENT
   --------------------------------------------------------------------------- */
.exercise-block { padding: 16px 0; border-bottom: 1px solid var(--border-soft); }
.exercise-block:last-child { border-bottom: none; }

.set-head, .set-row {
  display: grid;
  grid-template-columns: 26px minmax(0,1fr) minmax(0,1fr) 96px;
  gap: 9px; align-items: center;
}
.set-head {
  font-size: .68rem; color: var(--text-faint); text-transform: uppercase;
  letter-spacing: .06em; margin-bottom: 8px; font-weight: 600;
}
.set-row { margin-bottom: 9px; }
.set-row input { padding: 11px 8px; text-align: center; }
.set-row .setn {
  font-family: var(--display); font-weight: 600; font-size: 1rem;
  color: var(--plum-soft); text-align: center;
}

/* Bouton À faire (rouge) / Fait (vert) */
.setbtn {
  font-family: inherit; font-weight: 700; font-size: .8rem;
  padding: 11px 4px; border-radius: var(--radius-xs); border: none; cursor: pointer;
  width: 100%; color: #fff;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  transition: transform .1s ease, background .2s ease, box-shadow .2s ease;
  -webkit-tap-highlight-color: transparent;
}
.setbtn:active { transform: scale(.93); }
.setbtn.todo { background: var(--red); box-shadow: 0 4px 12px rgba(207,82,70,.30); }
.setbtn.done { background: var(--green); box-shadow: 0 4px 12px rgba(94,155,115,.30); }

/* Barre de progression de séance (collante sous le header) */
.session-progress {
  position: sticky; top: 70px; z-index: 35;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.session-progress .pct {
  font-family: var(--display); font-size: 1.5rem; font-weight: 600;
  color: var(--primary); font-variant-numeric: tabular-nums;
}
.session-progress .progress { height: 12px; margin-top: 9px; }

/* Minuteur de repos */
.rest-timer { position: sticky; bottom: calc(82px + env(safe-area-inset-bottom)); z-index: 30; }
.rest-bar {
  background: var(--grad-feature); color: #fff; border-radius: var(--radius);
  padding: 12px 12px 12px 18px; display: flex; align-items: center; gap: 10px;
  justify-content: space-between; box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255,255,255,.10);
}
.rest-bar .time {
  font-family: var(--display); font-size: 1.55rem; font-weight: 600;
  font-variant-numeric: tabular-nums; flex: 1;
}
.rest-bar .btn { background: rgba(255,255,255,.16); color: #fff; box-shadow: none; border: none; }
.rest-bar .btn::after { display: none; }
.rest-bar .btn:hover { background: rgba(255,255,255,.26); filter: none; }

/* ---------------------------------------------------------------------------
   13. BARRE DE NAVIGATION BASSE
   --------------------------------------------------------------------------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 45;
  display: flex; justify-content: space-around;
  background: var(--glass);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid var(--glass-line);
  padding: 9px 6px calc(9px + env(safe-area-inset-bottom));
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--text-soft); font-size: .64rem; font-weight: 600; flex: 1;
  padding: 3px 0; border-radius: var(--radius-sm);
  transition: color .2s ease;
  position: relative;
}
.tabbar a .ic { display: flex; align-items: center; justify-content: center; height: 24px; }
.tabbar a svg { width: 23px; height: 23px; stroke-width: 1.9; transition: transform .2s ease; }
.tabbar a.active { color: var(--primary); }
.tabbar a.active svg { transform: translateY(-1px); }
.tabbar a.active::before {
  content: ""; position: absolute; top: -9px; left: 50%; transform: translateX(-50%);
  width: 22px; height: 3px; border-radius: 999px; background: var(--primary);
}
.tabbar a:active svg { transform: scale(.88); }

/* ---------------------------------------------------------------------------
   14. MESSAGES FLASH (toasts)
   --------------------------------------------------------------------------- */
.flashes {
  position: fixed; top: calc(64px + env(safe-area-inset-top)); left: 0; right: 0;
  z-index: 60; max-width: 600px; margin: 0 auto; padding: 0 18px;
  pointer-events: none;
}
.flash {
  pointer-events: auto;
  padding: 13px 16px; border-radius: var(--radius-sm); margin-bottom: 10px;
  font-size: .9rem; font-weight: 500;
  box-shadow: var(--shadow); border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  display: flex; align-items: center; gap: 9px;
  animation: toast-in .4s cubic-bezier(.22,.61,.36,1) both;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: none; } }
.flash.success { border-left: 4px solid var(--green); }
.flash.error   { border-left: 4px solid var(--red); }
.flash.info    { border-left: 4px solid var(--rose-deep); }

/* ---------------------------------------------------------------------------
   15. MESSAGES CACHÉS (le cœur émotionnel)
   --------------------------------------------------------------------------- */
.love-card {
  position: relative;
  background:
    radial-gradient(circle at 100% 0%, rgba(232,165,152,.14), transparent 60%),
    var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 22px; margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}
.love-card .heart { font-size: 1.4rem; display: inline-block; }
.love-card .msg {
  font-family: var(--display); font-style: italic; font-weight: 400;
  font-size: 1.16rem; color: var(--plum); line-height: 1.5; margin: 8px 0 0;
}
.love-card .when { font-size: .72rem; color: var(--text-soft); margin-top: 12px; }
.love-card.locked {
  background: var(--surface-2); border-style: dashed; border-color: var(--border-strong);
  text-align: center; color: var(--text-soft);
}
.love-card.locked .msg { color: var(--text-faint); font-size: 1.02rem; }
.love-card.locked .lock { font-size: 1.7rem; opacity: .8; }
.love-card.locked .when { color: var(--text-faint); }

/* ---------------------------------------------------------------------------
   16. SÉLECTEUR D'HUMEUR
   --------------------------------------------------------------------------- */
.mood-pick { display: flex; gap: 8px; justify-content: space-between; }
.mood-pick label { flex: 1; text-align: center; cursor: pointer; margin: 0; }
.mood-pick input { display: none; }
.mood-pick .face {
  font-size: 1.85rem; display: block; padding: 9px 0;
  border-radius: var(--radius-sm); border: 1.5px solid transparent;
  background: var(--surface-2); opacity: .5;
  transition: transform .15s ease, opacity .15s ease, border-color .15s ease, background .15s ease;
}
.mood-pick label:active .face { transform: scale(.92); }
.mood-pick input:checked + .face {
  opacity: 1; border-color: var(--rose-deep); background: var(--primary-tint);
  transform: scale(1.08); box-shadow: var(--shadow-sm);
}

/* ---------------------------------------------------------------------------
   17. CÉLÉBRATION
   --------------------------------------------------------------------------- */
.celebrate {
  min-height: 72vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
}
.celebrate .burst { font-size: 4.2rem; animation: pop .7s cubic-bezier(.34,1.56,.64,1) both; }
.celebrate h1 { font-size: 2.1rem; animation: rise .6s .12s ease both; }
@keyframes pop {
  0% { transform: scale(0) rotate(-22deg); }
  70% { transform: scale(1.22) rotate(4deg); }
  100% { transform: scale(1) rotate(0); }
}
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
.confetti {
  position: fixed; top: -12px; width: 9px; height: 15px;
  border-radius: 2px; opacity: .95; z-index: 70; will-change: transform;
  animation: fall linear forwards;
}
@keyframes fall { to { transform: translateY(108vh) rotate(560deg); opacity: 1; } }

.reveal   { animation: rise .55s ease both; }
.reveal-2 { animation: rise .55s .08s ease both; }
.reveal-3 { animation: rise .55s .16s ease both; }

/* ---------------------------------------------------------------------------
   18. ÉTATS VIDES & DIVERS
   --------------------------------------------------------------------------- */
.section-title {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: 26px 2px 12px;
}
.section-title:first-child { margin-top: 6px; }
.section-title h1, .section-title h2 { margin: 0; }
.section-title .tiny { white-space: nowrap; }

.empty {
  text-align: center; color: var(--text-soft);
  padding: 36px 18px; background: var(--surface);
  border: 1px dashed var(--border-strong); border-radius: var(--radius);
}
.empty .big {
  font-size: 2.6rem; display: block; margin: 0 auto 10px;
  width: max-content; max-width: 100%;
  animation: float 3.5s ease-in-out infinite;
}
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

.center { text-align: center; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.stack-sm > * + * { margin-top: 8px; }
.mt  { margin-top: 14px; }  .mb  { margin-bottom: 14px; }
.mt-lg { margin-top: 22px; } .mb-lg { margin-bottom: 22px; }
.mt-0 { margin-top: 0; }     .mb-0 { margin-bottom: 0; }
.hr { height: 1px; background: var(--border); border: none; margin: 18px 0; }

canvas { max-width: 100%; }

/* Détails dépliables (« ＋ Ajouter ») */
details > summary { list-style: none; cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }
details[open] > summary.btn { background: var(--surface-3); }

/* ---------------------------------------------------------------------------
   20. CONFIGURATEUR DE PROGRAMME
   --------------------------------------------------------------------------- */
/* Compteur − N + (séries / répétitions) */
.stepper {
  display: inline-flex; align-items: stretch;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  overflow: hidden; background: var(--surface);
}
.stepper button {
  -webkit-appearance: none; appearance: none; border: none;
  background: var(--surface-2); color: var(--plum);
  width: 40px; font-size: 1.25rem; font-weight: 700; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s ease, transform .1s ease;
  -webkit-tap-highlight-color: transparent;
}
.stepper button:hover { background: var(--surface-3); }
.stepper button:active { transform: scale(.9); }
.stepper input {
  width: 50px; border: none; border-radius: 0; background: transparent;
  text-align: center; font-weight: 700; font-variant-numeric: tabular-nums;
  padding: 10px 2px; -moz-appearance: textfield; appearance: textfield;
}
.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper input:focus { box-shadow: none; }

/* Ligne d'exercice dans l'éditeur de journée */
.cfg-ex { padding: 16px 0; border-bottom: 1px solid var(--border-soft); }
.cfg-ex:last-of-type { border-bottom: none; }
.cfg-ex .top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.cfg-ex .title { min-width: 0; }
.cfg-ex .title b { display: block; line-height: 1.2; }
.cfg-ex .acts { display: flex; gap: 6px; flex: 0 0 auto; }
.cfg-ex .params { display: flex; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.cfg-ex .param { display: flex; align-items: center; gap: 9px; }
.cfg-ex .param .k {
  font-size: .72rem; font-weight: 700; color: var(--text-soft);
  text-transform: uppercase; letter-spacing: .04em;
}

/* Note de progression au-dessus d'un exercice (séance) */
.prog-note {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 3px 8px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 11px; margin: 0 0 12px;
  line-height: 1.45;
}
.prog-note b { color: var(--primary); font-variant-numeric: tabular-nums; }

/* Groupe de choix (questionnaire du configurateur d'activité) */
.choice-group { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 4px; }
.choice-group button {
  flex: 1 1 auto; min-width: 86px;
  font-family: inherit; font-size: .85rem; font-weight: 600;
  padding: 11px 10px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: var(--surface); color: var(--text-soft);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .1s ease;
}
.choice-group button:hover { border-color: var(--rose-deep); }
.choice-group button:active { transform: scale(.96); }
.choice-group button.on { background: var(--primary-tint); border-color: var(--rose-deep); color: var(--primary-strong); }

/* Explication du calcul des kcal */
#kcal-explain .target { color: var(--primary); }
#kcal-explain .hr { margin: 12px 0; }
#kcal-explain p { margin: 4px 0 0; }

/* Bouton stylé en lien discret (ex. « Se déconnecter ») */
.linkbtn {
  -webkit-appearance: none; appearance: none;
  background: none; border: none; padding: 4px 2px; margin: 0;
  font-family: inherit; color: var(--text-soft); cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--border-strong);
  transition: color .2s ease;
}
.linkbtn:hover { color: var(--primary); }

/* ---------------------------------------------------------------------------
   19. ACCESSIBILITÉ — mouvement réduit
   --------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .confetti { display: none; }
}
