/* ── Reset + primitives Cocoach V3 « Braise » ──
   Toutes les classes V1/V2 existent encore (le JS les génère) ; V3 remplace
   l'anneau readiness par la jauge graduée (.gauge-*), ajoute .card--attn
   (entrée requise), .coach-note/.hand (manuscrit) et .prog-row (programme).
   Typo : titres en Lora (--font-display), données en Plex Mono (--font-mono). */

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  color: var(--color-text-primary);
  background: var(--color-bg-primary);
  min-height: 100dvh;
  padding-bottom: calc(78px + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 {
  font-family: var(--font-display);
  font-size: 25px;
  font-weight: 600;
  letter-spacing: -0.005em;
}
h2 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0;
}
h3 { font-size: 14px; font-weight: 700; }
p  { margin: 0; }

/* La machine écrit en mono : chiffres tabulaires partout */
.num, .stat b, .gauge-score { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* La main du coach (Caveat) — à garder rare, ≤ 2 occurrences par écran */
.hand {
  font-family: var(--font-hand);
  font-size: 20px;
  line-height: 1.3;
  color: var(--color-pen);
  font-weight: 600;
}

button { font-family: inherit; }
input, select, textarea {
  font-family: inherit;
  font-size: 15px;
  color: var(--color-text-primary);
  background: var(--color-bg-input);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 11px 13px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-xlight);
}

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

/* ── Layout ── */
.page {
  max-width: 560px;
  margin: 0 auto;
  padding: 18px 16px 24px;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 2px 18px;
}
.page-header .eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--color-accent);
  margin-bottom: 3px;
}
.page-header .sub { color: var(--color-text-secondary); font-size: 13px; margin-top: 3px; }

/* ── Cartes ── */
.card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
}
.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  color: var(--color-text-secondary);
  margin-bottom: 12px;
}
.card-title .ic { color: var(--color-accent); flex: 0 0 auto; }

/* Entrée requise (RPE à noter…) : cadre ambre d'instrument */
.card--attn {
  border-color: var(--color-warning);
  background: var(--color-warning-bg);
}
.card--attn .card-title { color: var(--color-warning); }
.card--attn .card-title .ic { color: var(--color-warning); }

/* Note du coach — filet cuivre + écriture manuscrite */
.coach-note { border-left: 3px solid var(--color-accent); padding: 2px 4px 2px 13px; }
.coach-note .who {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--color-accent);
}
.coach-note .hand { margin-top: 3px; font-size: 21px; }

/* Lignes de programme (séance du jour, plan) : heure mono cuivre + titre Lora */
.prog-row { display: flex; gap: 12px; align-items: baseline; padding: 9px 0; }
.prog-row + .prog-row { border-top: 1px solid var(--color-border); }
.prog-row .ph {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 12.5px;
  color: var(--color-accent);
  white-space: nowrap;
  flex: 0 0 auto;
}
.prog-row .pt { font-family: var(--font-display); font-size: 16px; font-weight: 600; }
.prog-row .pm { font-family: var(--font-mono); font-size: 10.5px; color: var(--color-text-secondary); margin-top: 3px; }

/* ── Tuiles de stats (readiness, sommeil…) ── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.stat {
  background: var(--color-bg-inset);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  min-width: 0;
}
.stat .lbl {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat b {
  display: block;
  font-size: 18px;
  font-weight: 600;
  margin-top: 3px;
}
.stat b small { font-size: 11px; font-weight: 400; color: var(--color-text-secondary); }

/* ── Jauge readiness (remplace l'anneau V2) ── */
.gauge-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.gauge-score {
  font-weight: 600;
  font-size: 46px;
  line-height: 1;
  letter-spacing: -0.03em;
}
.gauge-score small { font-size: 14px; color: var(--color-text-muted); font-weight: 400; }
.gauge-verdict {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 16px;
  line-height: 1.35;
  text-align: right;
}
.gauge-verdict b { font-style: normal; font-weight: 600; }
.gauge { margin-top: 12px; }
.gauge svg { width: 100%; height: auto; display: block; }
.zone-chip {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  padding: 4px 10px;
  border: 1px solid currentColor;
  border-radius: var(--radius-sm);
}
.zone-chip--GREEN  { color: var(--zone-green); }
.zone-chip--BLUE   { color: var(--zone-blue); }
.zone-chip--YELLOW { color: var(--zone-yellow); }
.zone-chip--RED    { color: var(--zone-red); }

/* ── Icônes SVG (js/icons.js) ── */
.ic { display: inline-block; vertical-align: -0.18em; flex-shrink: 0; }
.ic--muted { color: var(--color-text-muted); }
[data-icon] { display: inline-flex; align-items: center; justify-content: center; }

/* Pastille ronde de type de séance (calendrier, séance du jour, pickers) */
.act-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  flex: 0 0 36px;
  background: var(--color-bg-secondary);
  color: var(--color-text-secondary);
}
.act-chip--muay-thai { background: var(--session-muay-thai-bg); color: var(--session-muay-thai); }
.act-chip--muscu     { background: var(--session-muscu-bg);     color: var(--session-muscu); }
.act-chip--cardio    { background: var(--session-cardio-bg);    color: var(--session-cardio); }
.act-chip--mobilite  { background: var(--session-mobilite-bg);  color: var(--session-mobilite); }
.act-chip--repos     { background: var(--session-repos-bg);     color: var(--session-repos); }

/* Picker d'icônes (sheet types d'activité) */
button.icon-pick {
  border: 2px solid var(--color-border);
  cursor: pointer;
  padding: 0;
  border-radius: var(--radius-md);
  transition: border-color 0.15s, background 0.15s;
}
button.icon-pick.selected {
  border-color: var(--color-accent);
  color: var(--color-accent);
  background: var(--color-accent-xlight);
}

/* ── Boutons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  cursor: pointer;
  padding: 13px 18px;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 700;
  color: var(--color-text-inverse);
  background: var(--accent-grad);
  box-shadow: var(--shadow-accent);
  transition: transform 0.12s, box-shadow 0.12s, opacity 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
[data-theme="dark"] .btn { color: #fff; }
.btn:active { transform: scale(0.97); box-shadow: none; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-secondary {
  background: var(--color-bg-card);
  color: var(--color-text-primary);
  border: 1.5px solid var(--color-border);
  box-shadow: none;
}
[data-theme="dark"] .btn-secondary { color: var(--color-text-primary); }
.btn-secondary:active { background: var(--color-bg-secondary); }
.btn-ghost {
  background: none;
  box-shadow: none;
  color: var(--color-accent);
  padding: 8px 12px;
}
.btn-danger { background: var(--color-danger); box-shadow: none; }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 13px; font-size: 13px; border-radius: 10px; }

/* ── Segmented control (périodes de graphe, intensité…) ── */
.seg {
  display: inline-flex;
  background: var(--color-bg-secondary);
  border-radius: var(--radius-full);
  padding: 3px;
  gap: 2px;
}
.seg button {
  border: none;
  background: none;
  cursor: pointer;
  white-space: nowrap;
  padding: 6px 13px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-secondary);
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.seg button.on {
  background: var(--color-bg-card);
  color: var(--color-text-primary);
  box-shadow: var(--shadow-sm);
}

/* ── Chips filtres / pickers (multi-options, wrap) ── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1.5px solid var(--color-border);
  background: var(--color-bg-card);
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: 7px 13px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.chip.on {
  border-color: var(--color-accent);
  background: var(--color-accent-xlight);
  color: var(--color-accent-dark);
}
[data-theme="dark"] .chip.on { color: var(--color-accent-light); }

/* ── Badges / pastilles ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  background: var(--color-bg-secondary);
  color: var(--color-text-secondary);
}
.badge-accent { background: var(--color-accent-xlight); color: var(--color-accent-dark); }
[data-theme="dark"] .badge-accent { color: var(--color-accent-light); }
.badge-success { background: var(--color-success-bg); color: var(--color-success); }
.badge-warning { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-danger  { background: var(--color-danger-bg);  color: var(--color-danger); }
.badge-info    { background: var(--color-info-bg);    color: var(--color-info); }

/* ── Barres de progression (nutrition…) ── */
.bar {
  height: 7px;
  border-radius: var(--radius-full);
  background: var(--color-bg-secondary);
  overflow: hidden;
  margin-top: 4px;
}
.bar i {
  display: block;
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--accent-grad);
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
.bar.over i { background: var(--color-warning); }

/* ── Sliders (check-in, RPE) ── */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 30px;
  padding: 0;
  border: none;
  background: none;
  box-shadow: none;
  --pct: 50%;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: var(--radius-full);
  background: linear-gradient(to right,
    var(--color-accent) var(--pct), var(--color-bg-secondary) var(--pct));
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px;
  height: 26px;
  margin-top: -9px;
  border-radius: 50%;
  background: var(--color-bg-card);
  border: 2.5px solid var(--color-accent);
  box-shadow: var(--shadow-md);
}
input[type="range"]::-moz-range-track {
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--color-bg-secondary);
}
input[type="range"]::-moz-range-progress {
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--color-accent);
}
input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--color-bg-card);
  border: 2.5px solid var(--color-accent);
  box-shadow: var(--shadow-md);
}

/* ── Lignes de liste (historique, records…) ── */
.list-row {
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
}
.list-row:last-child { border-bottom: none; padding-bottom: 2px; }

/* ── Bottom nav ── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  justify-content: space-around;
  background: var(--nav-glass);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--color-border);
  padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
}
.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 3px 0 4px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--color-text-muted);
  -webkit-tap-highlight-color: transparent;
}
.bottom-nav a .ic {
  display: block;
  padding: 4px 16px;
  border-radius: var(--radius-full);
  box-sizing: content-box;
  transition: background 0.2s, color 0.2s;
}
.bottom-nav a::before {
  content: "";
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: transparent;
  margin-bottom: 1px;
}
.bottom-nav a.active { color: var(--color-accent); }
.bottom-nav a.active::before { background: var(--color-accent); }
.bottom-nav a.active .ic { color: var(--color-accent); }

/* ── Utilitaires ── */
.muted { color: var(--color-text-secondary); font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.hidden { display: none !important; }
.skeleton {
  border-radius: var(--radius-sm);
  min-height: 16px;
  background: linear-gradient(100deg,
    var(--color-bg-secondary) 40%, var(--color-bg-inset) 50%, var(--color-bg-secondary) 60%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
@keyframes shimmer { from { background-position: 120% 0; } to { background-position: -80% 0; } }
@keyframes pulse { 0%, 100% { opacity: 0.6; } 50% { opacity: 1; } }

/* ── Bottom sheet ── */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(24, 14, 8, 0.45);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-end;
  animation: fadeIn 0.2s;
}
@keyframes fadeIn { from { opacity: 0; } }
.sheet {
  background: var(--color-bg-card);
  border-radius: 26px 26px 0 0;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 8px 20px calc(22px + env(safe-area-inset-bottom));
  max-height: 85dvh;
  overflow-y: auto;
  animation: sheetIn 0.28s cubic-bezier(0.34, 1.3, 0.64, 1);
}
@keyframes sheetIn { from { transform: translateY(48px); opacity: 0.4; } }
.sheet-handle {
  width: 38px;
  height: 4px;
  border-radius: 2px;
  background: var(--color-border-strong);
  margin: 8px auto 16px;
}
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ── Toast ── */
.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(92px + env(safe-area-inset-bottom));
  z-index: 300;
  background: var(--color-text-primary);
  color: var(--color-bg-primary);
  font-size: 14px;
  font-weight: 600;
  padding: 11px 19px;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.25s cubic-bezier(0.34, 1.3, 0.64, 1);
  max-width: 90vw;
  text-align: center;
}
@keyframes toastIn { from { transform: translate(-50%, 12px); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ── Calendrier : bandeau semaine + groupes d'absence ── */
.week-strip {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 10px 16px 12px;
  margin: 0 -16px 14px;
  background: var(--color-bg-primary);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.week-strip::-webkit-scrollbar { display: none; }
.strip-day {
  flex: 0 0 46px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 0 7px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-bg-card);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.strip-day .wd {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}
.strip-day .num {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  padding: 2px 0 1px;
}
.strip-day.today {
  background: var(--accent-grad);
  border-color: transparent;
  box-shadow: var(--shadow-accent);
}
.strip-day.today .wd { color: rgba(255, 255, 255, 0.75); }
.strip-day.today .num { color: #fff; }
.strip-day.today .dot { background: #fff !important; }
.strip-day.absent:not(.today) {
  background: repeating-linear-gradient(-45deg,
    var(--color-bg-secondary) 0 4px, var(--color-bg-card) 4px 9px);
}
.strip-dots { display: flex; gap: 3px; height: 5px; }
.strip-dots .dot { width: 5px; height: 5px; border-radius: var(--radius-full); }
.dot--muay-thai { background: var(--session-muay-thai); }
.dot--muscu     { background: var(--session-muscu); }
.dot--cardio    { background: var(--session-cardio); }
.dot--mobilite  { background: var(--session-mobilite); }
.dot--repos     { background: var(--session-repos); }

/* Cartes jour de l'agenda */
.day-card { scroll-margin-top: 82px; padding: 12px 16px; }
.day-card.today-card { border: 1.5px solid var(--color-accent); }
.day-card .day-head {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  text-transform: capitalize;
  color: var(--color-text-secondary);
}
.day-card.today-card .day-head { color: var(--color-accent); }
.cal-entry { padding: 8px 0; cursor: pointer; }
.cal-entry + .cal-entry { border-top: 1px solid var(--color-border); }

/* Jours passés (J-3 → hier) : bandeau atténué + groupe replié en tête d'agenda */
.strip-day.past:not(.today) { opacity: 0.5; }
.past-group { margin-bottom: 14px; }
.past-group > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  list-style: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  margin: 0 2px 10px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-muted);
}
.past-group > summary::-webkit-details-marker { display: none; }
.past-group > summary::before { content: "▸"; font-size: 12px; }
.past-group[open] > summary::before { content: "▾"; }
.past-group > summary::after { content: ""; flex: 1; height: 1px; background: var(--color-border); }
.past-group .day-card { opacity: 0.75; }

/* Semaine suivante : séparateur de section */
.week-sep {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 2px 10px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-muted);
}
.week-sep::after { content: ""; flex: 1; height: 1px; background: var(--color-border); }

/* Jours d'une absence : encadrés ensemble, en-tête cliquable */
.abs-group {
  border: 1.5px dashed var(--color-border-strong);
  border-radius: var(--radius-lg);
  padding: 8px 8px 0;
  margin-bottom: 14px;
  background: repeating-linear-gradient(-45deg,
    transparent 0 14px, var(--color-bg-secondary) 14px 15px);
}
.abs-group .card { margin-bottom: 8px; }
.abs-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 6px 8px;
  cursor: pointer;
  color: var(--color-text-secondary);
  font-weight: 700;
  font-size: 13px;
}
.abs-head .ic { color: var(--color-accent); }
