/* ============================================================
   TMB SUMMER BOOK v2 — Design system "Sportif & Aéré"
   Cartes spacieuses, gros boutons tactiles, palette dynamique.
   ============================================================ */

/* ============================================================
   TOKENS — source unique pour toute l'app + la page de style
   (design/index.html). Modifier une valeur ici la répercute partout :
   c'est le point d'entrée pour harmoniser un changement de design.
   ============================================================ */
:root {
  /* Couleurs de fonction (app "Sportif & Aéré" : admin/coach/joueur) */
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --green: #16a34a;
  --green-dim: #dcfce7;
  --orange: #f97316;
  --orange-dim: #ffedd5;
  --teal: #0d9488;
  --teal-dim: #ccfbf1;
  --red: #dc2626;
  --red-dim: #fee2e2;

  /* Couleur de marque TMB (accent principal de toute l'app) */
  --tmb-red: #c8102e;
  --tmb-red-dark: #7a0a1c;
  --tmb-red-light: #ff4d5e;

  /* Neutres */
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-dim: #475569;
  --text-faint: #94a3b8;

  /* Échelle d'espacement / rayons / ombres */
  --radius: 3px;
  --radius-sm: 3px;
  --shadow: 0 4px 20px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.10);
  --pad: 24px;

  /* Effet "gloss" très léger (reflet du haut vers le bas) sur boutons et
     cartes — un seul curseur pour tout doser : monte/descend
     --gloss-opacity (0 = désactivé, ~0.10-0.14 = discret, au-delà ça
     devient un vrai reflet plastique). Invisible sur les surfaces déjà
     blanches en thème clair (blanc sur blanc = pas de contraste
     possible), c'est normal et sans conséquence : il se voit surtout
     sur les boutons colorés et en thème sombre. */
  --gloss-opacity: 0.10;
  --gloss: linear-gradient(180deg, rgba(255, 255, 255, var(--gloss-opacity)) 0%, rgba(255, 255, 255, 0) 55%);

  /* Indique au navigateur que la page gère elle-même le thème clair :
     sans ça, certains mobiles (Chrome Android en tête) continuent
     d'appliquer leur propre fond clair natif sur les champs de saisie
     (suggestions/auto-remplissage), par-dessus nos couleurs. */
  color-scheme: light;
}

:root[data-theme="dark"] {
  /* Noir neutre (pas de teinte bleutée), fidèle à la plaquette design. */
  --bg: #0a0a0b;
  --surface: #18181a;
  --surface-2: #222224;
  --border: #38383b;
  --text: #f5f5f5;
  --text-dim: #c8c8cb;
  --text-faint: #8f8f93;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 14px 36px rgba(0, 0, 0, 0.65);
  --green-dim: #10301f;
  --orange-dim: #3a2410;
  --teal-dim: #0f2e2b;
  --red-dim: #3a141c;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
/* Ambiance "sombre et intense" (plaquette design) : lueurs rouges
   diffuses sur le fond noir, sans gêner la lecture du contenu. */
:root[data-theme="dark"] body {
  background:
    radial-gradient(ellipse 900px 480px at 105% -8%, rgba(200, 16, 46, 0.20), transparent 60%),
    radial-gradient(ellipse 700px 480px at -10% 105%, rgba(200, 16, 46, 0.14), transparent 55%),
    var(--bg);
  background-attachment: fixed;
}
button, input, select, textarea { font-family: inherit; font-size: 1rem; }
h1, h2, h3, p { margin: 0; }
a { color: var(--tmb-red); }

.hidden { display: none !important; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  padding: calc(12px + env(safe-area-inset-top, 0px)) var(--pad) 12px;
  background: var(--surface);
  border-bottom: 3px solid var(--tmb-red);
}
.topbar-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-ball { display: flex; align-items: center; flex-shrink: 0; }
.topbar-logo-img { height: 32px; width: auto; object-fit: contain; }
.topbar-titles { min-width: 0; }
.topbar-titles .name { font-weight: 800; font-size: 1.05rem; color: var(--tmb-red); }
.topbar-titles .sub { font-size: 0.8rem; color: var(--text-faint); }
.topbar-user { display: flex; align-items: center; gap: 12px; }
.user-name { font-weight: 600; }
.role-badge {
  padding: 4px 12px; border-radius: 999px; font-size: 0.8rem; font-weight: 700;
  background: var(--tmb-red); color: #fff;
}
.role-badge.role-admin { background: var(--orange); }
.role-badge.role-coach { background: var(--blue); border: 2px solid var(--tmb-red); }
.role-badge.role-player { background: var(--green); }

/* ---------- Buttons ---------- */
.btn-primary, .btn-secondary, .btn-ghost, .btn-danger-ghost {
  min-height: 48px;
  padding: 12px 22px;
  border-radius: var(--radius-sm);
  border: none;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.08s ease, opacity 0.15s ease;
}
.btn-primary { background: var(--gloss), var(--tmb-red); color: #fff; }
.btn-primary:hover { background: var(--gloss), var(--tmb-red-dark); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }
:root[data-theme="dark"] .btn-primary:not(:disabled) { box-shadow: 0 6px 20px rgba(200, 16, 46, 0.4); }
:root[data-theme="dark"] .btn-primary:not(:disabled):hover { box-shadow: 0 8px 26px rgba(200, 16, 46, 0.55); }
.btn-secondary { background: var(--gloss), var(--surface); color: var(--text); border: 1.5px solid var(--border); }
.btn-secondary:hover { border-color: var(--blue); color: var(--blue); }
.btn-ghost { background: transparent; color: var(--text-dim); border: 1.5px solid var(--border); min-height: 40px; padding: 8px 16px; }
.btn-ghost:hover { border-color: var(--red); color: var(--red); }
.btn-danger-ghost { background: var(--gloss), var(--red-dim); color: var(--red); min-height: 40px; padding: 8px 16px; }
.btn-danger-ghost:hover { background: var(--gloss), var(--red); color: #fff; }
.btn-block { width: 100%; }
.btn-publish { margin-top: 20px; background: var(--gloss), var(--green); }
.btn-publish:hover { background: var(--gloss), #128a3e; }

/* ---------- Interrupteur de thème (section Profil) ---------- */
/* Volontairement discret : une simple ligne avec un petit interrupteur,
   plutôt que le gros bouton emoji qui vivait auparavant dans la topbar. */
.theme-switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 4px 0 18px; cursor: pointer; font-weight: 600;
}
.theme-switch { position: relative; display: inline-flex; flex-shrink: 0; }
.theme-switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.theme-switch-track {
  width: 40px; height: 22px; border-radius: 999px; background: var(--border);
  display: block; position: relative; transition: background 0.15s ease;
}
.theme-switch-knob {
  position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--surface); box-shadow: var(--shadow); transition: transform 0.15s ease;
}
.theme-switch input:checked ~ .theme-switch-track { background: var(--tmb-red); }
.theme-switch input:checked ~ .theme-switch-track .theme-switch-knob { transform: translateX(18px); }
.theme-switch input:focus-visible ~ .theme-switch-track { outline: 2px solid var(--tmb-red); outline-offset: 2px; }

/* ---------- Layout ---------- */
#appRoot { max-width: 980px; margin: 0 auto; padding: 0 var(--pad) 64px; }
.page { padding-top: 28px; display: flex; flex-direction: column; gap: 20px; }
.page-eyebrow { font-size: 0.85rem; font-weight: 700; color: var(--tmb-red); text-transform: uppercase; letter-spacing: 0.04em; }
.page-title { font-size: 1.6rem; font-weight: 800; }
.section-title { font-size: 1.05rem; font-weight: 800; margin-top: 8px; }

/* ---------- Cards / forms ---------- */
.card, .info-card, .plan-card, .empty-state, .editor-toolbar {
  background: var(--gloss), var(--surface);
  border-radius: var(--radius);
  padding: var(--pad);
  box-shadow: var(--shadow);
}
.empty-state { text-align: center; color: var(--text-dim); }
.field { display: flex; flex-direction: column; gap: 6px; flex: 1; margin-bottom: 14px; }
.field-grow { flex: 2; }
.field label { font-size: 0.85rem; font-weight: 700; color: var(--text-dim); }
.field input, .field select, .field textarea {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  min-height: 48px;
  -webkit-appearance: none;
  appearance: none;
}
.field textarea { min-height: 64px; resize: vertical; }
.field input::placeholder, .field textarea::placeholder { color: var(--text-faint); opacity: 1; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--tmb-red);
  background: var(--surface) !important;
  color: var(--text) !important;
}

/* Auto-remplissage / suggestions du navigateur (Chrome Android en
   particulier) : sans ce correctif, le champ passe à un fond clair
   imposé par le navigateur alors que le texte reste clair en thème
   sombre — quasi illisible. On force nos propres couleurs par-dessus,
   avec !important car le navigateur applique les siennes en priorité. */
.field input:-webkit-autofill,
.field input:-webkit-autofill:hover,
.field input:-webkit-autofill:focus,
.field input:-webkit-autofill:active {
  -webkit-text-fill-color: var(--text) !important;
  -webkit-box-shadow: 0 0 0 1000px var(--surface-2) inset !important;
  box-shadow: 0 0 0 1000px var(--surface-2) inset !important;
  caret-color: var(--text) !important;
  transition: background-color 9999s ease-in-out 0s;
}
.field-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-error { color: var(--red); font-size: 0.9rem; min-height: 1.2em; }

/* ---------- Auth (page de connexion / inscription — thème rouge TMB) ---------- */
.auth-wrap {
  position: relative; overflow: hidden;
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: var(--pad);
  background:
    radial-gradient(circle at 15% 0%, rgba(255, 77, 94, 0.35), transparent 55%),
    linear-gradient(160deg, var(--tmb-red) 0%, var(--tmb-red-dark) 75%);
}
/* Fines lignes diagonales lumineuses (clin d'œil à la plaquette design) —
   discrètes, ne gênent jamais la lecture du formulaire. */
.auth-wrap::before {
  content: ""; position: absolute; inset: -25% -25%;
  background: repeating-linear-gradient(115deg, rgba(255, 255, 255, 0.06) 0 2px, transparent 2px 64px);
  pointer-events: none;
}
.auth-card {
  position: relative; z-index: 1;
  width: 100%; max-width: 440px;
  background: var(--gloss), var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  padding: 40px 34px;
  text-align: center;
}
.auth-logo-img { height: 192px; max-width: 100%; margin-bottom: 18px; object-fit: contain; }
.auth-card h1 { font-size: 1.5rem; font-weight: 900; line-height: 1.15; color: var(--tmb-red); letter-spacing: -0.01em; }
.auth-sub { color: var(--text-dim); margin: 12px 0 26px; font-size: 0.92rem; line-height: 1.5; }
.auth-tabs { display: flex; background: var(--surface-2); border-radius: var(--radius-sm); padding: 4px; margin-bottom: 22px; }
.auth-tab { flex: 1; border: none; background: transparent; padding: 10px; border-radius: var(--radius); font-weight: 700; color: var(--text-dim); cursor: pointer; min-height: 44px; }
.auth-tab.active { background: var(--gloss), var(--tmb-red); color: #fff; }
.auth-form { text-align: left; }
.auth-form .field input:focus { border-color: var(--tmb-red); }
.auth-wrap .btn-primary { background: var(--tmb-red); }
.auth-wrap .btn-primary:hover { background: var(--tmb-red-dark); }
.auth-hint { color: var(--text-faint); font-size: 0.85rem; margin-top: 14px; }
.boot-error { padding: 40px; text-align: center; color: var(--red); font-weight: 700; }

@media (max-width: 480px) {
  .auth-card { padding: 32px 22px; }
  .auth-logo-img { height: 156px; }
}

/* ---------- Tabs (admin) ---------- */
.tabs { display: flex; gap: 10px; flex-wrap: wrap; }
.tab {
  min-height: 44px; padding: 10px 18px; border-radius: 999px; border: 1.5px solid var(--border);
  background: var(--gloss), var(--surface); color: var(--text-dim); font-weight: 700; cursor: pointer;
}
.tab.active { background: var(--gloss), var(--tmb-red); color: #fff; border-color: var(--tmb-red); }

/* ---------- Admin: users table ---------- */
.admin-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.table-wrap { overflow-x: auto; background: var(--gloss), var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; min-width: 640px; }
.data-table th, .data-table td { padding: 14px 16px; text-align: left; border-bottom: 1px solid var(--border); }
.data-table th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-faint); }
.data-table select { min-height: 40px; border-radius: var(--radius); border: 1.5px solid var(--border); padding: 6px 10px; background: var(--surface-2); }
.data-table tr:last-child td { border-bottom: none; }

/* ---------- Program editor ---------- */
/* Cartes de section colorées : un accent différent par bloc logique
   (semaine / jour / exercices) pour repérer la structure d'un coup d'œil. */
.section-card { border-left: 5px solid transparent; }
.section-eyebrow { font-size: 0.75rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 12px; }
.section-card--week { border-left-color: var(--blue); }
.section-card--week .section-eyebrow { color: var(--blue); }
.section-card--day { border-left-color: var(--orange); }
.section-card--day .section-eyebrow { color: var(--orange); }
.section-card--exo { border-left-color: var(--teal); }
.section-card--exo .section-eyebrow { color: var(--teal); }

.editor-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 16px var(--pad); }
.locked-cat { font-weight: 700; }
.week-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.week-tab { min-height: 44px; min-width: 44px; padding: 8px 16px; border-radius: 999px; border: 1.5px solid var(--border); background: var(--gloss), var(--surface); font-weight: 800; cursor: pointer; }
.week-tab.active { background: var(--gloss), var(--orange); color: #fff; border-color: var(--orange); }
.week-tab.round { border-radius: 50%; width: 48px; height: 48px; min-width: 48px; padding: 0; }
.week-tab.is-rest { background: var(--gloss), var(--surface-2); color: var(--text-faint); }
.week-tab.is-empty { border-style: dashed; color: var(--text-faint); }
#edDayTabs.week-tabs { gap: 6px; }
#edDayTabs .week-tab { min-width: 40px; padding: 8px 10px; font-size: 0.85rem; }

.checkbox-row { display: flex; align-items: center; gap: 10px; font-weight: 600; margin: 4px 0 16px; cursor: pointer; }
.checkbox-row input { width: 20px; height: 20px; }

.exo-edit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.exo-edit-card { background: var(--gloss), var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }

/* Mini-formulaire inline "Nouvel exercice" / "Modifier cet exercice"
   (bibliothèque partagée, voir assets/js/40-component-program-editor.js) */
.lib-form { border-top: 1.5px dashed var(--border); margin: 4px 0 16px; padding-top: 14px; }
.lib-form-hint { color: var(--text-faint); font-size: 0.82rem; margin: -6px 0 12px; }

/* ---------- Player: progress ---------- */
.progress-card {
  display: flex; align-items: center; gap: 20px;
}
:root[data-theme="dark"] .progress-card {
  background: linear-gradient(135deg, var(--surface) 0%, #26121a 100%);
  border: 1px solid rgba(200, 16, 46, 0.28);
}
.progress-ring {
  --pct: 0;
  width: 108px; height: 108px; border-radius: 50%; flex-shrink: 0;
  background: conic-gradient(var(--tmb-red) calc(var(--pct) * 1%), var(--border) 0);
  display: flex; align-items: center; justify-content: center;
  transition: box-shadow 0.2s ease;
}
:root[data-theme="dark"] .progress-ring { box-shadow: 0 0 28px rgba(200, 16, 46, 0.45); }
.progress-ring-inner {
  width: 84px; height: 84px; border-radius: 50%; background: var(--surface);
  display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: 1.35rem;
  color: var(--tmb-red);
}
.progress-labels .title { font-weight: 800; }
.progress-labels .sub { color: var(--text-dim); font-size: 0.9rem; margin-top: 2px; }

/* ---------- Player: day list (aperçu semaine) ---------- */
.day-list { display: flex; flex-direction: column; gap: 12px; }
.day-card {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: var(--gloss), var(--surface); border: none; border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow); cursor: pointer; text-align: left;
  font: inherit; color: var(--text); min-height: 64px; width: 100%;
}
.day-card:disabled { cursor: default; opacity: 0.75; }
.day-card.done { border: 2px solid var(--green); }
.day-card.is-today { border: 2px solid var(--tmb-red); }
.day-name { font-weight: 800; display: flex; align-items: center; gap: 8px; }
.day-today-badge {
  background: var(--tmb-red); color: #fff; font-size: 0.68rem; font-weight: 800;
  padding: 2px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.03em;
}
.day-session { color: var(--text-dim); font-size: 0.9rem; margin-top: 2px; }
.status-pill {
  padding: 6px 14px; border-radius: 999px; font-weight: 800; font-size: 0.82rem; flex-shrink: 0;
  background: var(--surface-2); color: var(--text-dim);
}
.status-pill.done { background: var(--green-dim); color: var(--green); }
.status-pill.partial { background: var(--orange-dim); color: var(--orange); }
.status-pill.todo { background: var(--surface-2); color: var(--text-dim); }
.status-pill.rest { background: var(--surface-2); color: var(--text-faint); }

/* ---------- Player: exercise cards ---------- */
.player-exo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.player-exo-card {
  background: var(--gloss), var(--surface);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  border: 2px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.player-exo-card.is-done { background: var(--gloss), var(--green-dim); border-color: var(--green); }
.pe-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pe-name {
  font: inherit; text-align: left; background: none; border: none; padding: 0; color: inherit; cursor: pointer;
  font-weight: 800; font-size: 1.02rem;
}
.pe-name:hover { color: var(--tmb-red); text-decoration: underline; }
.pe-check {
  border: none; background: var(--surface-2); border-radius: var(--radius);
  width: 44px; height: 44px; font-size: 20px; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.pe-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.pe-chip {
  background: var(--surface-2); border-radius: 999px; padding: 4px 10px;
  font-size: 0.8rem; font-weight: 700; color: var(--text-dim);
}
.pe-video { display: inline-block; margin-top: 8px; font-weight: 700; font-size: 0.92rem; }

/* ---------- Page dédiée d'un exercice (chrono + vidéo/description) ---------- */
.exo-video-embed { position: relative; padding-top: 56.25%; height: 0; overflow: hidden; border-radius: var(--radius); background: #000; }
.exo-video-embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.exo-schema-img { max-width: 100%; border-radius: var(--radius); margin-top: 12px; display: block; }
.exo-detail-desc { color: var(--text-dim); line-height: 1.6; margin-top: 12px; }

.chrono-widget { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.chrono-mode-switch { display: flex; background: var(--surface-2); border-radius: var(--radius-sm); padding: 4px; }
.chrono-mode-btn { border: none; background: transparent; padding: 8px 16px; border-radius: var(--radius); font-weight: 700; color: var(--text-dim); cursor: pointer; min-height: 40px; }
.chrono-mode-btn.active { background: var(--gloss), var(--tmb-red); color: #fff; }
.chrono-display { font-size: 3rem; font-weight: 900; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.chrono-widget.chrono-finished .chrono-display { color: var(--tmb-red); }
.chrono-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* ---------- Error boundary (voir assets/js/02-error-boundary.js) ---------- */
.error-card { border: 1.5px solid var(--red-dim); }
.error-card p:first-child { font-weight: 800; color: var(--red); }
.error-detail { font-size: 0.85rem; color: var(--text-faint); margin-top: 6px; word-break: break-word; }
.error-card .btn-secondary { margin-top: 16px; }

/* ---------- Toast ---------- */
/* Fond volontairement fixe (pas var(--text), qui devient quasi blanc en
   thème sombre — texte blanc sur fond blanc, illisible). Le toast est un
   pavé flottant ponctuel : pas besoin qu'il s'inverse avec le thème, il
   doit juste rester lisible dans les deux cas. */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--gloss), #1f2937; color: #fff; padding: 14px 22px; border-radius: 999px;
  font-weight: 600; box-shadow: var(--shadow-lg); z-index: 50; max-width: 90vw; text-align: center;
}
.toast-error { background: var(--gloss), var(--red); }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  :root { --pad: 14px; --radius: 14px; }
  body { font-size: 15px; }

  .topbar {
    padding: calc(10px + env(safe-area-inset-top, 0px)) var(--pad) 10px;
    flex-wrap: wrap; gap: 10px;
  }
  .topbar-titles .sub { display: none; }
  .topbar-user { width: 100%; justify-content: space-between; }
  .topbar-logo-img { height: 26px; }

  .auth-card { padding: 28px 20px; }
  .progress-card { flex-direction: column; align-items: flex-start; }
  .field-row { flex-direction: column; }

  .page-title { font-size: 1.35rem; }
  #appRoot { padding: 0 var(--pad) 48px; }

  /* Onglets et sélecteurs de semaine/jour : défilement horizontal plutôt
     que retour à la ligne, pour rester utilisables au pouce sur petit écran. */
  .tabs, .week-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar, .week-tabs::-webkit-scrollbar { display: none; }
  .tabs .tab, .week-tabs .week-tab { flex-shrink: 0; }

  .editor-toolbar { flex-direction: column; align-items: stretch; gap: 12px; }
  .admin-actions { flex-direction: column; align-items: stretch; }
  .admin-actions .btn-primary, .admin-actions .btn-secondary { width: 100%; }

  .exo-edit-grid, .player-exo-grid { grid-template-columns: 1fr; }

  .day-card { padding: 14px 16px; }
  .chrono-display { font-size: 2.4rem; }
}

@media (max-width: 400px) {
  .auth-card { padding: 24px 16px; }
  .auth-logo-img { height: 132px; }
  .auth-card h1 { font-size: 1.3rem; }
}

/* ---------- Section nav (Entraînement / Programme / Admin / Profil) ---------- */
/* Un seul composant (assets/js/25-section-nav.js), deux présentations :
   rangée de pastilles sous la topbar sur desktop, pilule flottante en
   bas d'écran sur mobile (voir media query plus bas). Les sections
   affichées dépendent du rôle courant. */
.section-nav {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  max-width: 980px; margin: 0 auto;
  padding: 14px var(--pad) 0;
}
.section-nav-item {
  display: flex; align-items: center; gap: 8px;
  border: 1.5px solid var(--border); background: var(--gloss), var(--surface); color: var(--text-dim);
  font-weight: 700; font-size: 0.9rem; padding: 10px 18px; border-radius: 999px; cursor: pointer;
  min-height: 44px;
}
.section-nav-item .sn-icon-wrap { display: flex; align-items: center; justify-content: center; }
.section-nav-item .sn-icon svg { display: block; width: 20px; height: 20px; }
/* Onglet actif : gris en thème clair, rouge TMB en thème sombre (demande
   explicite : "noir et rouge theme dark et blanc et gris pour le light"). */
.section-nav-item.active { color: var(--text); background: var(--gloss), var(--border); }
:root[data-theme="dark"] .section-nav-item.active { color: #fff; background: var(--gloss), var(--tmb-red); border-color: var(--tmb-red); }

@media (max-width: 640px) {
  body.has-section-nav #appRoot { padding-bottom: calc(90px + env(safe-area-inset-bottom, 0px)); }

  /* En dessous de 640px : barre flottante icônes seules, avec un badge
     circulaire derrière l'icône active (inspiré de la maquette fournie :
     fond sombre, pastille pleine derrière l'icône active uniquement,
     pas toute la largeur du bouton). */
  .section-nav {
    position: fixed; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    z-index: 30; max-width: none; margin: 0; padding: 8px 6px;
    justify-content: space-around; gap: 2px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 999px;
    box-shadow: var(--shadow-lg);
  }
  .section-nav-item {
    flex: 1; flex-direction: column; justify-content: center; gap: 0;
    border: none; background: transparent; padding: 4px 2px; min-height: 52px;
  }
  .section-nav-item .sn-icon-wrap {
    width: 42px; height: 42px; border-radius: 50%;
    transition: background 0.15s ease, color 0.15s ease;
  }
  .section-nav-item .sn-icon svg { width: 22px; height: 22px; }
  .section-nav-item .sn-label { display: none; }
  .section-nav-item.active { background: none; border-color: transparent; color: var(--text-faint); }
  .section-nav-item.active .sn-icon-wrap { background: var(--border); color: var(--text); }
  :root[data-theme="dark"] .section-nav-item.active .sn-icon-wrap { background: rgba(200, 16, 46, 0.18); color: var(--tmb-red); }
}
