/* ==========================================================================
   Coach — Design system
   --------------------------------------------------------------------------
   Mobile-first. Deux thèmes (clair/sombre) pilotés par prefers-color-scheme,
   surchargeables via [data-theme] sur <html>.

   Typographie : pile système. Décision assumée — sur iPhone cela donne
   SF Pro (la police de l'app Santé d'Apple), le rendu est natif, il n'y a
   aucune requête réseau, la CSP reste stricte (font-src 'self') et la PWA
   fonctionne hors ligne. Une webfont aurait coûté ~200 ko pour un gain
   esthétique discutable sur une app de données.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Jetons
   -------------------------------------------------------------------------- */
:root {
  /* Palette de marque */
  --brand-500: #f97316;   /* orange — énergie, effort */
  --brand-600: #ea580c;
  --brand-400: #fb923c;

  --success-500: #16a34a;
  --success-400: #22c55e;
  --warn-500:    #d97706;
  --danger-500:  #dc2626;
  --info-500:    #2563eb;

  /* Couleurs sémantiques par métrique — cohérentes dans toute l'app */
  --metric-weight:  #6366f1;
  --metric-energy:  #f97316;
  --metric-protein: #0891b2;
  --metric-carbs:   #d97706;
  --metric-fat:     #a855f7;
  --metric-sleep:   #7c3aed;
  --metric-steps:   #059669;
  --metric-heart:   #e11d48;

  /* Espacement — échelle 4px */
  --sp-1: 0.25rem;  --sp-2: 0.5rem;   --sp-3: 0.75rem;  --sp-4: 1rem;
  --sp-5: 1.25rem;  --sp-6: 1.5rem;   --sp-8: 2rem;     --sp-10: 2.5rem;
  --sp-12: 3rem;    --sp-16: 4rem;

  /* Rayons */
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 22px; --r-full: 999px;

  /* Typographie */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui,
               "Helvetica Neue", Arial, sans-serif;
  --font-num: ui-rounded, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;

  --text-xs: 0.75rem;  --text-sm: 0.875rem; --text-base: 1rem;
  --text-lg: 1.125rem; --text-xl: 1.375rem; --text-2xl: 1.75rem;
  --text-3xl: 2.25rem; --text-4xl: 3rem;

  /* Profondeur */
  --z-base: 1; --z-sticky: 10; --z-nav: 20; --z-overlay: 30; --z-modal: 40; --z-toast: 50;

  /* Mouvement */
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --dur-fast: 150ms;
  --dur: 220ms;

  /* Gabarit */
  --container: 42rem;
  --nav-height: 4.25rem;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* --- Thème clair (défaut) --- */
:root,
:root[data-theme="light"] {
  --bg:            #f6f7f9;
  --surface:       #ffffff;
  --surface-2:     #f2f4f7;
  --surface-sunk:  #eceff3;
  --border:        #dde1e7;
  --border-strong: #c4cad3;

  --text:       #0f172a;   /* 15.4:1 sur --surface */
  --text-muted: #4b5563;   /* 7.6:1  — jamais plus clair, lisibilité des données */
  --text-faint: #6b7280;   /* 4.8:1  — réservé aux libellés secondaires */
  --text-on-brand: #ffffff;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);

  --brand:      var(--brand-600);
  --brand-soft: #fff1e6;
  --success:    var(--success-500);
  --success-soft: #e8f6ec;
  --warn:       var(--warn-500);
  --warn-soft:  #fdf3e3;
  --danger:     var(--danger-500);
  --danger-soft:#fdeaea;
  --info:       var(--info-500);
  --info-soft:  #e8effd;
}

/* --- Thème sombre --- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:            #0a0d12;
    --surface:       #141920;
    --surface-2:     #1b212a;
    --surface-sunk:  #0f141a;
    --border:        #262d38;
    --border-strong: #38414f;

    --text:       #f1f5f9;
    --text-muted: #a9b4c2;
    --text-faint: #8b96a5;
    --text-on-brand: #1a0f06;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.55);

    --brand:      var(--brand-500);
    --brand-soft: #2a1608;
    --success:    var(--success-400);
    --success-soft: #0d2417;
    --warn:       #f59e0b;
    --warn-soft:  #2a1d06;
    --danger:     #f87171;
    --danger-soft:#2a1010;
    --info:       #60a5fa;
    --info-soft:  #0d1a2e;
  }
}

:root[data-theme="dark"] {
  --bg:            #0a0d12;
  --surface:       #141920;
  --surface-2:     #1b212a;
  --surface-sunk:  #0f141a;
  --border:        #262d38;
  --border-strong: #38414f;

  --text:       #f1f5f9;
  --text-muted: #a9b4c2;
  --text-faint: #8b96a5;
  --text-on-brand: #1a0f06;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.55);

  --brand:      var(--brand-500);
  --brand-soft: #2a1608;
  --success:    var(--success-400);
  --success-soft: #0d2417;
  --warn:       #f59e0b;
  --warn-soft:  #2a1d06;
  --danger:     #f87171;
  --danger-soft:#2a1010;
  --info:       #60a5fa;
  --info-soft:  #0d1a2e;
}

/* --------------------------------------------------------------------------
   2. Réinitialisation
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

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

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);   /* 16px minimum sur mobile */
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;            /* garde-fou anti-débordement horizontal */
  min-height: 100dvh;
}

img, svg, video { display: block; max-width: 100%; height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { line-height: 1.2; font-weight: 700; letter-spacing: -0.02em; }
h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }

p { max-width: 68ch; }  /* longueur de ligne lisible */

/* Accessibilité : focus toujours visible, jamais supprimé */
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}
:focus:not(:focus-visible) { outline: none; }

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

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0;
  margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; top: -100%; left: var(--sp-4); z-index: var(--z-toast);
  background: var(--brand); color: var(--text-on-brand);
  padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); font-weight: 600;
}
.skip-link:focus { top: var(--sp-4); }

/* --------------------------------------------------------------------------
   3. Gabarit
   -------------------------------------------------------------------------- */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--sp-4);
}

.main {
  flex: 1;
  padding-block: var(--sp-5) calc(var(--nav-height) + var(--safe-bottom) + var(--sp-8));
}

@media (min-width: 900px) {
  :root { --container: 60rem; }
  .main { padding-bottom: var(--sp-12); }
}

.stack       { display: flex; flex-direction: column; gap: var(--sp-4); }
.stack-sm    { display: flex; flex-direction: column; gap: var(--sp-2); }
.stack-lg    { display: flex; flex-direction: column; gap: var(--sp-6); }
.row         { display: flex; align-items: center; gap: var(--sp-3); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.grid-2      { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
.grid-auto   { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: var(--sp-3); }

/* --------------------------------------------------------------------------
   4. En-tête
   -------------------------------------------------------------------------- */
.header {
  position: sticky; top: 0; z-index: var(--z-sticky);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--border);
  padding-block: var(--sp-3);
  padding-top: max(var(--sp-3), env(safe-area-inset-top, 0px));
}

.header__inner { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }

.header__greeting { font-size: var(--text-sm); color: var(--text-muted); }
.header__title { font-size: var(--text-xl); font-weight: 700; letter-spacing: -0.02em; }

.avatar {
  width: 2.5rem; height: 2.5rem; border-radius: var(--r-full);
  background: var(--surface-2); border: 1px solid var(--border);
  display: grid; place-items: center; font-weight: 600; font-size: var(--text-sm);
  color: var(--text-muted); overflow: hidden; flex-shrink: 0;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* --------------------------------------------------------------------------
   5. Cartes
   -------------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  box-shadow: var(--shadow-sm);
}
.card--flush { padding: 0; overflow: hidden; }
.card--sunk { background: var(--surface-sunk); box-shadow: none; }

.card__header { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.card__title { font-size: var(--text-sm); font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }

/* Carte cliquable */
a.card, button.card {
  display: block; width: 100%; text-align: left; cursor: pointer;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background var(--dur) var(--ease);
}
a.card:hover, button.card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  text-decoration: none;
}

/* --------------------------------------------------------------------------
   6. Affichage des données de santé
   -------------------------------------------------------------------------- */

/* Une statistique = un libellé, une valeur, une unité, un contexte.
   Les chiffres utilisent des chasses tabulaires : les colonnes restent
   alignées quand les valeurs changent, ce qui évite l'effet "sautillant". */
.stat { display: flex; flex-direction: column; gap: var(--sp-1); }

.stat__label {
  font-size: var(--text-xs); font-weight: 600; color: var(--text-faint);
  text-transform: uppercase; letter-spacing: 0.06em;
}

.stat__value {
  font-family: var(--font-num);
  font-size: var(--text-2xl); font-weight: 700; line-height: 1.1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.stat__value--lg { font-size: var(--text-3xl); }
.stat__value--sm { font-size: var(--text-xl); }

.stat__unit { font-size: 0.5em; font-weight: 600; color: var(--text-muted); margin-left: 0.15em; }
.stat__meta { font-size: var(--text-xs); color: var(--text-muted); }

/* État "donnée absente" : explicite, jamais un 0 trompeur. */
.stat__value--empty { color: var(--text-faint); font-weight: 600; font-size: var(--text-xl); }

/* Variation : la couleur n'est jamais le seul indicateur (flèche + signe). */
.delta { display: inline-flex; align-items: center; gap: 0.25em; font-size: var(--text-sm); font-weight: 600; font-variant-numeric: tabular-nums; }
.delta--up   { color: var(--success); }
.delta--down { color: var(--info); }
.delta--flat { color: var(--text-muted); }
.delta--warn { color: var(--warn); }

/* --------------------------------------------------------------------------
   7. Barres de progression (calories, macros)
   -------------------------------------------------------------------------- */
.progress { display: flex; flex-direction: column; gap: var(--sp-2); }
.progress__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-2); }
.progress__name { font-size: var(--text-sm); font-weight: 600; }
.progress__figures { font-size: var(--text-sm); color: var(--text-muted); font-variant-numeric: tabular-nums; }

.progress__track {
  height: 0.625rem; border-radius: var(--r-full);
  background: var(--surface-sunk); border: 1px solid var(--border);
  overflow: hidden; position: relative;
}
.progress__fill {
  height: 100%; border-radius: var(--r-full);
  background: var(--bar-color, var(--brand));
  transition: width var(--dur) var(--ease);
  max-width: 100%;
}
/* Dépassement de l'objectif : hachures, lisible sans dépendre de la couleur. */
.progress__fill--over {
  background-image: repeating-linear-gradient(45deg,
    transparent, transparent 4px,
    rgba(255, 255, 255, 0.28) 4px, rgba(255, 255, 255, 0.28) 8px);
}

.bar-energy  { --bar-color: var(--metric-energy); }
.bar-protein { --bar-color: var(--metric-protein); }
.bar-carbs   { --bar-color: var(--metric-carbs); }
.bar-fat     { --bar-color: var(--metric-fat); }

/* Anneau de progression (calories du jour) */
.ring { display: grid; place-items: center; position: relative; }
.ring svg { transform: rotate(-90deg); }
.ring__track { stroke: var(--surface-sunk); }
.ring__value { stroke: var(--brand); stroke-linecap: round; transition: stroke-dashoffset 600ms var(--ease); }
.ring__center { position: absolute; text-align: center; }

/* --------------------------------------------------------------------------
   8. Boutons — cible tactile 44px minimum
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: 2.875rem;              /* 46px */
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--r-md); border: 1px solid transparent;
  font-size: var(--text-base); font-weight: 600; letter-spacing: -0.01em;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), opacity var(--dur-fast) var(--ease);
}
.btn:hover { text-decoration: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }

.btn--primary { background: var(--brand); color: var(--text-on-brand); }
.btn--primary:hover:not(:disabled) { background: var(--brand-600); }

.btn--success { background: var(--success); color: #fff; }

.btn--secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn--secondary:hover:not(:disabled) { background: var(--surface-sunk); border-color: var(--border-strong); }

.btn--ghost { background: transparent; color: var(--text-muted); }
.btn--ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }

.btn--danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn--danger:hover:not(:disabled) { background: var(--danger-soft); }

.btn--block { width: 100%; }
.btn--sm { min-height: 2.25rem; padding: var(--sp-2) var(--sp-3); font-size: var(--text-sm); }

.btn__spinner {
  width: 1em; height: 1em; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent;
  animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Bouton Google — respecte les règles de marque (fond blanc, logo officiel) */
.btn--google {
  background: #ffffff; color: #1f1f1f; border-color: #dadce0;
  font-weight: 500; box-shadow: var(--shadow-sm);
}
.btn--google:hover:not(:disabled) { background: #f8f9fa; }

/* --------------------------------------------------------------------------
   9. Actions rapides
   -------------------------------------------------------------------------- */
.quick-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-3); }
@media (min-width: 30rem) { .quick-actions { grid-template-columns: repeat(4, 1fr); } }

.quick-action {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--sp-2); padding: var(--sp-4) var(--sp-2); min-height: 5.5rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  color: var(--text); font-size: var(--text-xs); font-weight: 600; text-align: center;
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.quick-action:hover { border-color: var(--brand); background: var(--brand-soft); text-decoration: none; }
.quick-action svg { width: 1.5rem; height: 1.5rem; color: var(--brand); }

/* --------------------------------------------------------------------------
   10. Navigation basse (mobile)
   -------------------------------------------------------------------------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: var(--z-nav);
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
}

.tabbar__item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.2rem; min-height: var(--nav-height); padding: var(--sp-2) var(--sp-1);
  color: var(--text-faint); font-size: 0.6875rem; font-weight: 600;
  cursor: pointer; text-decoration: none;
  transition: color var(--dur-fast) var(--ease);
}
.tabbar__item:hover { color: var(--text-muted); text-decoration: none; }
.tabbar__item[aria-current="page"] { color: var(--brand); }
.tabbar__item svg { width: 1.375rem; height: 1.375rem; }

@media (min-width: 900px) {
  .tabbar {
    position: sticky; top: var(--sp-4); bottom: auto;
    max-width: var(--container); margin: 0 auto var(--sp-6);
    grid-template-columns: repeat(5, 1fr);
    border: 1px solid var(--border); border-radius: var(--r-xl);
  }
  .tabbar__item { min-height: 3.5rem; flex-direction: row; gap: var(--sp-2); font-size: var(--text-sm); }
}

/* --------------------------------------------------------------------------
   11. Formulaires
   -------------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: var(--sp-2); }
.field__label { font-size: var(--text-sm); font-weight: 600; }
.field__hint { font-size: var(--text-xs); color: var(--text-muted); }
.field__error { font-size: var(--text-sm); color: var(--danger); font-weight: 500; }

.input, .select, .textarea {
  width: 100%; min-height: 2.875rem;
  padding: var(--sp-3); border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--border-strong);
  color: var(--text); font-size: var(--text-base);  /* 16px : évite le zoom iOS */
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent);
}
.input[aria-invalid="true"] { border-color: var(--danger); }
.textarea { min-height: 7rem; resize: vertical; line-height: 1.6; }

.input-unit { position: relative; display: flex; align-items: center; }
.input-unit .input { padding-right: 3.5rem; }
.input-unit__suffix {
  position: absolute; right: var(--sp-3);
  font-size: var(--text-sm); font-weight: 600; color: var(--text-muted); pointer-events: none;
}

/* Sélection en cartes (onboarding) */
.choice-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.choice {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-4); border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--border);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.choice:hover { border-color: var(--border-strong); }
.choice input { margin-top: 0.2rem; accent-color: var(--brand); width: 1.15rem; height: 1.15rem; flex-shrink: 0; cursor: pointer; }
.choice__body { display: flex; flex-direction: column; gap: 0.15rem; }
.choice__title { font-weight: 600; }
.choice__desc { font-size: var(--text-sm); color: var(--text-muted); }
.choice:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.choice:has(input:focus-visible) { outline: 2px solid var(--brand); outline-offset: 2px; }

/* --------------------------------------------------------------------------
   12. Badges & pastilles
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 0.35em;
  padding: 0.25rem 0.6rem; border-radius: var(--r-full);
  font-size: var(--text-xs); font-weight: 600; line-height: 1.4;
}
.badge--neutral  { background: var(--surface-2);   color: var(--text-muted); }
.badge--brand    { background: var(--brand-soft);  color: var(--brand); }
.badge--success  { background: var(--success-soft);color: var(--success); }
.badge--warn     { background: var(--warn-soft);   color: var(--warn); }
.badge--danger   { background: var(--danger-soft); color: var(--danger); }
.badge--info     { background: var(--info-soft);   color: var(--info); }

/* Marqueur d'estimation — signale une donnée approximative */
.badge--estimate { background: var(--surface-2); color: var(--text-muted); font-weight: 500; }

/* --------------------------------------------------------------------------
   13. Recommandations du coach
   -------------------------------------------------------------------------- */
.reco {
  display: flex; gap: var(--sp-3); padding: var(--sp-4);
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--accent, var(--brand));
  border-radius: var(--r-md);
}
.reco--info    { --accent: var(--info); }
.reco--success { --accent: var(--success); }
.reco--warn    { --accent: var(--warn); }
.reco--alert   { --accent: var(--danger); }

.reco__icon { flex-shrink: 0; width: 1.25rem; height: 1.25rem; color: var(--accent, var(--brand)); margin-top: 0.15rem; }
.reco__body { display: flex; flex-direction: column; gap: var(--sp-1); min-width: 0; flex: 1; }
.reco__dismiss { flex-shrink: 0; margin: -0.25rem -0.25rem auto auto; }
.reco__title { font-weight: 650; font-size: var(--text-base); }
.reco__text { font-size: var(--text-sm); color: var(--text-muted); line-height: 1.55; }

/* --------------------------------------------------------------------------
   14. États vides / chargement
   -------------------------------------------------------------------------- */
.empty {
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-3);
  padding: var(--sp-10) var(--sp-5); text-align: center;
}
.empty svg { width: 2.5rem; height: 2.5rem; color: var(--text-faint); }
.empty__title { font-weight: 650; }
.empty__text { font-size: var(--text-sm); color: var(--text-muted); max-width: 32ch; }

/* Squelette — réserve la place pour éviter les sauts de mise en page */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-sunk) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer { to { background-position: -200% 0; } }
.skeleton--text { height: 1em; margin-block: 0.3em; }
.skeleton--stat { height: 2.5rem; width: 60%; }

/* --------------------------------------------------------------------------
   15. Notifications
   -------------------------------------------------------------------------- */
.toasts {
  position: fixed; left: var(--sp-4); right: var(--sp-4);
  bottom: calc(var(--nav-height) + var(--safe-bottom) + var(--sp-4));
  z-index: var(--z-toast);
  display: flex; flex-direction: column; gap: var(--sp-2);
  pointer-events: none;
}
@media (min-width: 640px) { .toasts { left: auto; right: var(--sp-6); max-width: 24rem; } }

.toast {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--accent, var(--brand));
  box-shadow: var(--shadow-lg); font-size: var(--text-sm);
  pointer-events: auto;
  animation: toast-in var(--dur) var(--ease);
}
.toast--success { --accent: var(--success); }
.toast--error   { --accent: var(--danger); }
.toast--info    { --accent: var(--info); }
@keyframes toast-in { from { opacity: 0; transform: translateY(0.5rem); } }

/* --------------------------------------------------------------------------
   16. Graphiques
   -------------------------------------------------------------------------- */
.chart { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart__grid  { stroke: var(--border); stroke-width: 1; }
.chart__axis  { fill: var(--text-faint); font-size: 11px; font-family: var(--font-num); }
.chart__line  { fill: none; stroke: var(--series, var(--brand)); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.chart__area  { fill: var(--series, var(--brand)); opacity: 0.10; }
.chart__point { fill: var(--surface); stroke: var(--series, var(--brand)); stroke-width: 2.5; }
.chart__trend { stroke: var(--text-faint); stroke-width: 1.5; stroke-dasharray: 4 4; fill: none; }

/* Alternative accessible : tableau de données associé au graphique */
.data-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.data-table th, .data-table td { padding: var(--sp-2) var(--sp-3); text-align: right; border-bottom: 1px solid var(--border); }
.data-table th:first-child, .data-table td:first-child { text-align: left; }
.data-table thead th { color: var(--text-muted); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.05em; }
.table-wrap { overflow-x: auto; }

/* --------------------------------------------------------------------------
   17. Divers
   -------------------------------------------------------------------------- */
.divider { height: 1px; background: var(--border); border: 0; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-center { text-align: center; }
.mt-auto { margin-top: auto; }
.hidden { display: none !important; }

/* Avertissement médical — présent partout où l'app conseille */
.medical-notice {
  display: flex; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface-2); border-radius: var(--r-md);
  font-size: var(--text-xs); color: var(--text-muted); line-height: 1.5;
}
.medical-notice svg { width: 1rem; height: 1rem; flex-shrink: 0; margin-top: 0.15rem; }

/* Page centrée (connexion, erreurs, accès restreint) */
.centered-page {
  min-height: 100dvh;
  display: grid; place-items: center;
  padding: var(--sp-6) var(--sp-4);
}
.centered-page__inner {
  width: 100%; max-width: 26rem;
  display: flex; flex-direction: column; gap: var(--sp-5); text-align: center;
}

.logo-mark {
  width: 3.5rem; height: 3.5rem; margin-inline: auto;
  display: grid; place-items: center;
  background: var(--brand); color: var(--text-on-brand);
  border-radius: var(--r-lg);
}
.logo-mark svg { width: 2rem; height: 2rem; }

/* --------------------------------------------------------------------------
   Calendrier
   -------------------------------------------------------------------------- */

/* Bascule de vue : mois / semaine / jour */
.seg {
  display: flex; gap: 2px; padding: 3px;
  background: var(--surface-sunk); border-radius: var(--r-md);
}
.seg__item {
  flex: 1; text-align: center; padding: var(--sp-2) var(--sp-3);
  font-size: var(--text-sm); font-weight: 600; color: var(--text-muted);
  border-radius: calc(var(--r-md) - 3px); transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.seg__item:hover { text-decoration: none; color: var(--text); }
.seg__item[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* Barre de navigation : précédent / libellé / suivant */
.cal-nav { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.cal-nav__label { font-weight: 600; text-transform: capitalize; }

/* Grille mensuelle */
.cal-head, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-head { margin-bottom: 4px; }
.cal-head span {
  text-align: center; font-size: var(--text-xs); font-weight: 600;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em;
}

.cal-cell {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  min-height: 3.1rem; padding: var(--sp-2) 2px;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface); color: var(--text);
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.cal-cell:hover { border-color: var(--border-strong); text-decoration: none; }
.cal-cell--out { background: transparent; color: var(--text-muted); opacity: 0.55; }
.cal-cell--today { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.cal-cell__num { font-size: var(--text-sm); font-variant-numeric: tabular-nums; line-height: 1; }
.cal-cell--today .cal-cell__num { color: var(--brand); font-weight: 700; }

.cal-dots { display: flex; gap: 3px; min-height: 6px; align-items: center; }
.cal-dot { width: 6px; height: 6px; border-radius: var(--r-full); background: var(--text-muted); }
.cal-dot--done    { background: var(--success); }
.cal-dot--planned { background: var(--brand); }
.cal-dot--skipped { background: var(--text-muted); }
.cal-dot--meal    { background: var(--metric-protein); }
.cal-dot--weight  { background: var(--metric-weight); }

/* Légende */
.cal-legend { display: flex; flex-wrap: wrap; gap: var(--sp-3); font-size: var(--text-xs); color: var(--text-muted); }
.cal-legend span { display: inline-flex; align-items: center; gap: var(--sp-2); }

/* Vue semaine : liste de jours */
.cal-day-row {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  transition: border-color var(--dur) var(--ease);
}
.cal-day-row:hover { border-color: var(--border-strong); text-decoration: none; }
.cal-day-row--today { border-color: var(--brand); }
.cal-day-row__date {
  flex-shrink: 0; width: 3rem; text-align: center; line-height: 1.1;
}
.cal-day-row__dow { font-size: var(--text-xs); color: var(--text-muted); text-transform: uppercase; }
.cal-day-row__num { font-size: var(--text-xl); font-weight: 700; font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------------------
   Suivi du cycle
   -------------------------------------------------------------------------- */

/* Puce à cocher (symptômes) */
.chip-check { display: inline-flex; align-items: center; cursor: pointer; }
.chip-check input { position: absolute; opacity: 0; width: 0; height: 0; }
.chip-check span {
  display: inline-block; padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border); border-radius: var(--r-full);
  font-size: var(--text-sm); color: var(--text-muted); background: var(--surface);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.chip-check input:checked + span { background: var(--brand); border-color: var(--brand); color: var(--text-on-brand); }
.chip-check input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }

/* Pastilles « règles » sur le calendrier */
.cal-dot--period { background: var(--danger); }
.cal-dot--period-predicted { background: transparent; border: 1.5px solid var(--danger); }

/* Bandeau de phase du cycle */
.phase-pill {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-3); border-radius: var(--r-full);
  font-size: var(--text-xs); font-weight: 600;
  background: var(--surface-sunk); color: var(--text);
}
.phase-pill__dot { width: 8px; height: 8px; border-radius: var(--r-full); background: var(--brand); }
.phase-pill__dot--menstrual { background: var(--danger); }
.phase-pill__dot--follicular { background: var(--metric-steps); }
.phase-pill__dot--ovulation { background: var(--metric-protein); }
.phase-pill__dot--luteal { background: var(--metric-fat); }
.phase-pill__dot--unknown { background: var(--text-muted); }

/* --------------------------------------------------------------------------
   Logo de marque
   Deux fichiers (trait sombre / trait blanc) basculés selon le thème, en
   suivant le même schéma que les couleurs : prefers-color-scheme par défaut,
   surchargeable par [data-theme] sur <html>.
   -------------------------------------------------------------------------- */
.brand-logo { display: block; width: 8.5rem; height: auto; margin-inline: auto; }
.brand-logo--light { display: none; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand-logo--dark  { display: none; }
  :root:not([data-theme="light"]) .brand-logo--light { display: block; }
}
:root[data-theme="dark"]  .brand-logo--dark  { display: none; }
:root[data-theme="dark"]  .brand-logo--light { display: block; }
:root[data-theme="light"] .brand-logo--dark  { display: block; }
:root[data-theme="light"] .brand-logo--light { display: none; }
