/* ============================================================
   Refonte mobile — chargée uniquement sous 860px via l'attribut
   media du <link>, donc aucune règle n'atteint le desktop.
   ============================================================ */

:root {
  --m-gutter: 1.05rem;
  --m-radius: 1.5rem;
  --m-radius-sm: 1.1rem;
  --m-tabbar: 4.15rem;
  --m-spring: cubic-bezier(0.22, 1, 0.36, 1);
  --m-safe-b: env(safe-area-inset-bottom, 0px);
  --m-safe-t: env(safe-area-inset-top, 0px);
  /* Fond plus profond que le desktop : les cartes doivent décoller. */
  --m-bg: #08090b;
  --m-card: #14161a;
  --m-card-2: #1b1e24;
  --m-hairline: rgba(255, 255, 255, 0.07);
}

html {
  -webkit-text-size-adjust: 100%;
  background: var(--m-bg);
}

body {
  overflow-x: clip;
  padding-bottom: calc(var(--m-tabbar) + var(--m-safe-b) + 0.6rem);
  background: var(--m-bg);
  -webkit-tap-highlight-color: transparent;
}

.sidebar,
.topbar {
  display: none !important;
}

.app-shell {
  display: block;
  min-height: auto;
}

/* ---------- En-tête ---------- */

.mtopbar {
  display: block;
  padding: calc(var(--m-safe-t) + 0.9rem) var(--m-gutter) 0.35rem;
}

.mtop-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.7rem;
}

.mtop-avatar {
  width: 2.6rem;
  height: 2.6rem;
  object-fit: contain;
  background: var(--m-card);
  border-radius: 999px;
}

.mtop-hello {
  display: grid;
  line-height: 1.2;
}

.mtop-hello span {
  color: var(--muted);
  font-size: 0.86rem;
}

.mtop-hello strong {
  font-size: 1.02rem;
  font-weight: 800;
}

.mtop-actions {
  display: flex;
  gap: 0.45rem;
}

.micon {
  display: grid;
  place-items: center;
  width: 2.7rem;
  height: 2.7rem;
  padding: 0;
  background: var(--m-card);
  border: 1px solid var(--m-hairline);
  border-radius: 999px;
  color: var(--text);
  transition: transform 200ms var(--m-spring), background 200ms ease;
}

.micon:active {
  transform: scale(0.9);
  background: rgba(var(--accent-rgb), 0.2);
}

.micon svg {
  width: 1.15rem;
  height: 1.15rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mtop-title {
  margin: 1.15rem 0 0.15rem;
  font-size: 1.95rem;
  font-weight: 800;
  letter-spacing: -0.032em;
  line-height: 1.12;
}

.mtop-date {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

/* ---------- Barre d'onglets ---------- */

.mtabs {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.2rem;
  position: fixed;
  left: 0.55rem;
  right: 0.55rem;
  bottom: calc(0.5rem + var(--m-safe-b));
  z-index: 50;
  padding: 0.42rem;
  background: rgba(20, 22, 26, 0.86);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  border: 1px solid var(--m-hairline);
  border-radius: 999px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
}

.mtab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.62rem 0.35rem;
  background: none;
  border: 0;
  border-radius: 999px;
  color: var(--subtle);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
  transition: background 320ms var(--m-spring), color 260ms ease, flex-grow 320ms var(--m-spring);
}

.mtab svg {
  width: 1.3rem;
  height: 1.3rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Onglet actif : pilule pleine avec le libellé qui se déplie. */
.mtab-label {
  max-width: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-width 320ms var(--m-spring), opacity 200ms ease, margin 320ms var(--m-spring);
}

.mtab.active {
  flex-grow: 2.2;
  background: rgba(var(--accent-rgb), 0.17);
  color: var(--accent-text);
}

.mtab.active .mtab-label {
  max-width: 6rem;
  margin-left: 0.4rem;
  opacity: 1;
}

.mtab:active {
  transform: scale(0.94);
}

/* ---------- Vues ---------- */

.view {
  padding: 0.55rem var(--m-gutter) 1.5rem;
}

.view.active {
  animation: mFadeUp 380ms var(--m-spring) both;
}

@keyframes mFadeUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.grid.two-col,
.grid.three-col,
.grid.four-col,
.dashboard-grid {
  grid-template-columns: minmax(0, 1fr) !important;
  gap: 0.7rem;
}

.stat-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 0.7rem;
}

.panel,
.sidebar-card,
.stat-card,
.meal-card,
.timeline-item,
.source-card,
.exercise-card {
  background: var(--m-card);
  border-color: var(--m-hairline);
  border-radius: var(--m-radius-sm);
}

.panel {
  padding: 1.05rem;
}

.panel-header h2,
h2 {
  font-size: 1.14rem;
  letter-spacing: -0.015em;
}

.stat-card strong {
  font-size: 1.5rem;
  letter-spacing: -0.02em;
}

input,
select,
textarea {
  font-size: 16px;
  border-radius: 0.85rem;
}

.primary-button,
.ghost-button,
.danger-button {
  min-height: 3rem;
  border-radius: 999px;
  transition: transform 170ms var(--m-spring);
}

.primary-button:active,
.ghost-button:active,
.danger-button:active {
  transform: scale(0.97);
}

/* ---------- Carte héros de séance ---------- */

.m-hero {
  position: relative;
  overflow: hidden;
  margin: 0 0 0.85rem;
  padding: 1.15rem 1.15rem 1.05rem;
  background:
    radial-gradient(120% 100% at 85% 0%, rgba(var(--accent-rgb), 0.28), transparent 62%),
    var(--m-card-2);
  border: 1px solid rgba(var(--accent-rgb), 0.28);
  border-radius: var(--m-radius);
  animation: mPop 380ms var(--m-spring) both;
}

@keyframes mPop {
  from {
    opacity: 0;
    transform: scale(0.98) translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.m-hero-top {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.5rem;
  color: var(--accent-text);
  font-size: 0.82rem;
  font-weight: 800;
}

.m-live-dot {
  width: 0.52rem;
  height: 0.52rem;
  background: var(--accent);
  border-radius: 999px;
}

.m-hero.running .m-live-dot {
  animation: mPulse 1.7s ease-in-out infinite;
}

@keyframes mPulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0.55);
  }
  50% {
    box-shadow: 0 0 0 0.5rem rgba(var(--accent-rgb), 0);
  }
}

.m-hero-name {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.m-hero-caption {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.m-hero-clock {
  display: block;
  margin-top: 0.1rem;
  color: var(--accent-text);
  font-size: 3.05rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.045em;
  line-height: 1.08;
}

.m-hero.paused .m-hero-clock {
  color: var(--muted);
}

/* Rangée de pastilles d'info, comme les sous-cartes de la référence. */
.m-hero-pills {
  display: flex;
  gap: 0.45rem;
  margin: 0.85rem 0 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.m-hero-pills::-webkit-scrollbar {
  display: none;
}

.m-pill {
  flex: 1 0 auto;
  display: grid;
  gap: 0.1rem;
  min-width: 6.2rem;
  padding: 0.55rem 0.7rem;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid var(--m-hairline);
  border-radius: 0.95rem;
}

.m-pill span {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
}

.m-pill strong {
  font-size: 0.92rem;
  font-weight: 800;
}

/* Barre d'action pleine largeur en pied de carte héros. */
.m-hero-action {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  margin-top: 0.85rem;
  padding: 0.85rem 1rem;
  background: var(--accent);
  border: 0;
  border-radius: 1.05rem;
  color: var(--accent-ink);
  font-size: 1rem;
  font-weight: 800;
  transition: transform 180ms var(--m-spring), filter 180ms ease;
}

.m-hero-action:active {
  transform: scale(0.975);
  filter: brightness(0.94);
}

.m-hero-action .m-ha-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 1.5rem;
  height: 1.5rem;
}

.m-hero-action .m-ha-icon svg {
  width: 1.15rem;
  height: 1.15rem;
  fill: currentColor;
}

.m-hero-action .m-ha-label {
  flex: 1;
  text-align: center;
}

.m-hero-action .m-ha-value {
  padding-left: 0.7rem;
  border-left: 1px solid rgba(0, 0, 0, 0.22);
  font-variant-numeric: tabular-nums;
  opacity: 0.85;
}

.m-hero-secondary {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.7rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--m-hairline);
  border-radius: 1.05rem;
  color: var(--text);
  font-weight: 800;
  transition: transform 180ms var(--m-spring);
}

.m-hero-secondary:active {
  transform: scale(0.975);
}

/* ---------- Titre de section ---------- */

.m-sechead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin: 1.25rem 0 0.65rem;
}

.m-sechead h2 {
  margin: 0;
  font-size: 1.22rem;
  font-weight: 800;
  letter-spacing: -0.022em;
}

.m-sechead .m-seclink {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
  background: none;
  border: 0;
  padding: 0;
}

/* ---------- Carrousel des jours ---------- */

.m-daystrip {
  display: flex;
  gap: 0.5rem;
  margin: 0 calc(var(--m-gutter) * -1);
  padding: 0.15rem var(--m-gutter) 0.45rem;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}

.m-daystrip::-webkit-scrollbar {
  display: none;
}

.m-daystrip .tab-button {
  flex: 0 0 auto;
  display: grid;
  gap: 0.05rem;
  scroll-snap-align: center;
  min-width: 7.6rem;
  padding: 0.68rem 0.9rem;
  background: var(--m-card);
  border: 1px solid var(--m-hairline);
  border-radius: 1.05rem;
  text-align: left;
  transition: transform 220ms var(--m-spring), border-color 220ms ease, background 220ms ease;
}

.m-daystrip .tab-button .m-day {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.m-daystrip .tab-button .m-name {
  font-size: 0.98rem;
  font-weight: 800;
  letter-spacing: -0.012em;
}

.m-daystrip .tab-button.active {
  background: rgba(var(--accent-rgb), 0.16);
  border-color: rgba(var(--accent-rgb), 0.5);
  color: var(--accent-text);
}

.m-daystrip .tab-button.active .m-day {
  color: var(--accent-text);
}

.m-daystrip .tab-button:active {
  transform: scale(0.95);
}

/* ---------- Carrousel d'exercices ---------- */

.m-carousel {
  display: flex !important;
  gap: 0.7rem;
  margin: 0 calc(var(--m-gutter) * -1);
  padding: 0 var(--m-gutter);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding: 0 var(--m-gutter);
  scrollbar-width: none;
}

.m-carousel::-webkit-scrollbar {
  display: none;
}

.m-carousel > .exercise-card {
  flex: 0 0 100%;
  scroll-snap-align: center;
  border-radius: var(--m-radius);
  overflow: hidden;
}

.m-carousel .exercise-media {
  min-height: 13.5rem;
  border-radius: 0;
}

/* 180 px maximum : limite imposée par la licence Gym visual. */
.m-carousel .exercise-media img {
  width: min(100%, 180px);
}

#training .exercise-body {
  padding-bottom: 1rem;
}

#training .exercise-preview {
  display: grid;
  gap: 0.42rem;
}

#training .exercise-preview .muted {
  margin-bottom: 0;
}

body.is-mobile:not(.session-active) #training .exercise-session-tools {
  display: none;
}

body.is-mobile.session-active #training .exercise-session-tools {
  display: grid;
  gap: 0.8rem;
  padding-top: 0.25rem;
}

body.is-mobile:not(.session-active) #training .exercise-preview .muted {
  display: none;
}

body.is-mobile #training .custom-exercise-panel,
body.is-mobile #training .workout-history-panel {
  display: none;
}

body.is-mobile.session-active #training .custom-exercise-panel {
  display: block;
}

.m-dots {
  display: flex;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.8rem 0 0.1rem;
}

.m-dots i {
  width: 0.42rem;
  height: 0.42rem;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  transition: width 280ms var(--m-spring), background 280ms ease;
}

.m-dots i.on {
  width: 1.3rem;
  background: var(--accent);
}

/* ---------- Minuteur de repos ---------- */

.rest-timer {
  left: var(--m-gutter);
  right: var(--m-gutter);
  bottom: calc(var(--m-tabbar) + var(--m-safe-b) + 1rem);
  width: auto;
  grid-template-columns: 4.6rem minmax(0, 1fr);
  grid-template-areas:
    "ring head"
    "ring actions";
  align-items: center;
  gap: 0.25rem 0.9rem;
  padding: 0.95rem;
  background: var(--m-card-2);
  border: 1px solid rgba(var(--accent-rgb), 0.3);
  border-left-width: 1px;
  border-radius: var(--m-radius);
}

.m-ring {
  grid-area: ring;
  width: 4.6rem;
  height: 4.6rem;
  transform: rotate(-90deg);
}

.m-ring-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.1);
  stroke-width: 9;
}

.m-ring-value {
  fill: none;
  stroke: var(--accent);
  stroke-width: 9;
  stroke-linecap: round;
  transition: stroke-dashoffset 900ms linear;
}

.rest-timer-head {
  grid-area: head;
}

.rest-timer-head strong {
  font-size: 1.85rem;
  letter-spacing: -0.03em;
}

.rest-timer-bar {
  display: none;
}

.rest-timer-actions {
  grid-area: actions;
}

.rest-timer-actions .ghost-button {
  min-height: 2.3rem;
}

/* ---------- Feuilles modales ---------- */

.guide-modal,
.admin-modal {
  align-items: end;
  padding: 0;
}

.guide-panel,
.admin-panel {
  width: 100%;
  max-height: 88vh;
  padding-bottom: calc(1.3rem + var(--m-safe-b));
  border-radius: var(--m-radius) var(--m-radius) 0 0;
  border-bottom: 0;
  animation: mSheet 380ms var(--m-spring) both;
}

@keyframes mSheet {
  from {
    transform: translateY(100%);
  }
  to {
    transform: none;
  }
}

.guide-media {
  width: 9.5rem;
  height: 9.5rem;
}

/* ---------- Divers ---------- */

.planner-row {
  grid-template-columns: 5.4rem repeat(4, 8rem) 6rem;
  min-width: 0;
}

.food-list {
  max-height: 14rem;
}

.theme-panel {
  bottom: calc(var(--m-tabbar) + var(--m-safe-b) + 1rem);
}

.save-state {
  position: fixed;
  left: 50%;
  top: calc(var(--m-safe-t) + 0.5rem);
  transform: translateX(-50%);
  z-index: 60;
}

@media (prefers-reduced-motion: reduce) {
  .view.active,
  .m-hero,
  .guide-panel,
  .admin-panel {
    animation: none;
  }

  .m-hero.running .m-live-dot {
    animation: none;
  }
}

/* Le panneau « Programme » perd son habillage : la carte héros porte
   déjà le nom de la séance, son focus et le compteur. */
.m-progpanel {
  margin: 0 0 0.2rem;
  padding: 0;
  background: none;
  border: 0;
}

.m-progpanel .panel-header,
.m-progpanel > div:not(.tabs) {
  display: none;
}

/* Les pastilles défilent, elles ne doivent ni rétrécir ni se couper. */
.m-hero-pills {
  margin-right: calc(var(--m-gutter) * -1);
  padding-right: var(--m-gutter);
}

.m-pill {
  flex: 0 0 auto;
  min-width: 5.6rem;
}

.m-pill span {
  white-space: nowrap;
}

/* ============================================================
   Passage en mise en page « à plat » : plus de conteneurs
   visibles, le contenu respire directement sur le fond.
   ============================================================ */

.main-area {
  padding: 0;
}

.view {
  padding: 0;
}

.panel,
.sidebar-card,
.stat-card,
.meal-card,
.timeline-item,
.source-card,
.exercise-card {
  background: transparent;
  border-color: transparent;
  border-radius: var(--m-radius-sm);
}

/* Les panneaux gardent leur retrait interne : sans lui, le texte
   collerait aux bords maintenant que la vue n'a plus de padding. */
.panel {
  padding: 0.35rem var(--m-gutter) 1rem;
}

.stat-card,
.meal-card,
.timeline-item,
.source-card {
  padding-left: 0;
  padding-right: 0;
}

.stat-grid,
.grid.two-col,
.grid.three-col,
.grid.four-col,
.dashboard-grid {
  padding: 0 var(--m-gutter);
}

.mtop-avatar {
  background: none;
}

/* Les carrousels portaient une marge négative pour compenser le
   padding de la vue : celui-ci a disparu, elle n'a plus lieu d'être. */
.m-daystrip,
.m-carousel {
  margin: 0;
}

.m-hero {
  margin: 0 var(--m-gutter) 0.85rem;
}

/* La rangée de courbes devient un carrousel : elle doit défiler
   horizontalement, pas se répartir en grille. */
.grid.two-col.m-carousel,
.grid.m-carousel {
  padding: 0 var(--m-gutter) !important;
  grid-template-columns: none !important;
}

.m-carousel > .panel {
  flex: 0 0 100%;
  scroll-snap-align: center;
  padding-left: 0;
  padding-right: 0;
}

.m-dots[hidden] {
  display: none;
}

/* Le sélecteur de couleur déplacé dans l'en-tête mobile adopte
   l'apparence des boutons ronds qui l'entourent. */
.mtop-actions .icon-button {
  width: 2.7rem;
  height: 2.7rem;
  background: var(--m-card);
  border: 1px solid var(--m-hairline);
  border-radius: 999px;
}

.mtop-actions .icon-button:active {
  transform: scale(0.9);
}

.mtop-actions .icon-button svg {
  width: 1.15rem;
  height: 1.15rem;
}

/* Le panneau s'ouvre en feuille ancrée en bas, au-dessus des onglets. */
.theme-panel {
  position: fixed;
  left: var(--m-gutter);
  right: var(--m-gutter);
  top: auto;
  bottom: calc(var(--m-tabbar) + var(--m-safe-b) + 1rem);
  width: auto;
  padding: 1rem;
  background: var(--m-card-2);
  border: 1px solid var(--m-hairline);
  border-radius: var(--m-radius);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6);
  animation: mSheet 300ms var(--m-spring) both;
}

.theme-swatches {
  grid-template-columns: repeat(8, 1fr);
  gap: 0.5rem;
}

.theme-swatch {
  border-radius: 0.6rem;
}

/* ============================================================
   Champs date sur iOS. Safari donne à input[type="date"] une
   largeur intrinsèque liée au format affiché et n'applique pas
   width:100% comme les autres champs : il ressort plus large.
   On neutralise son habillage natif et on recale son contenu.
   ============================================================ */

input[type="date"],
input[type="time"],
input[type="datetime-local"] {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

/* Sans ça, iOS centre la valeur et réserve une gouttière à droite. */
input[type="date"]::-webkit-date-and-time-value,
input[type="time"]::-webkit-date-and-time-value,
input[type="datetime-local"]::-webkit-date-and-time-value {
  text-align: left;
  margin: 0;
  min-width: 0;
}

input[type="date"]::-webkit-datetime-edit,
input[type="time"]::-webkit-datetime-edit {
  padding: 0;
}

input[type="date"]::-webkit-calendar-picker-indicator {
  margin: 0 0 0 auto;
  padding: 0;
}

/* Les champs d'un même formulaire partagent exactement la même boîte. */
.form-grid .field {
  min-width: 0;
}

.form-grid input,
.form-grid select,
.form-grid textarea {
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
}

select {
  -webkit-appearance: none;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 1rem) 1.18rem, calc(100% - 0.72rem) 1.18rem;
  background-size: 0.3rem 0.3rem, 0.3rem 0.3rem;
  background-repeat: no-repeat;
  padding-right: 2rem;
}

/* ============================================================
   Barre d'onglets plaquée en bas de l'écran : pleine largeur,
   coins arrondis en haut seulement.
   ============================================================ */

.mtabs {
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0.5rem 0.5rem calc(0.5rem + var(--m-safe-b));
  border: 0;
  border-top: 1px solid var(--m-hairline);
  border-radius: var(--m-radius) var(--m-radius) 0 0;
  background: rgba(14, 16, 19, 0.92);
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.45);
}

.mtab {
  padding: 0.6rem 0.3rem;
}

.mtab svg {
  width: 1.4rem;
  height: 1.4rem;
  stroke-width: 1.7;
}

/* Hors séance, le point de « Prochaine séance » clignote pour attirer
   l'œil sur le bouton de démarrage. En séance, il garde sa pulsation
   en anneau, qui signale un chrono qui tourne. */
.m-hero:not(.running):not(.paused) .m-live-dot {
  animation: mBlink 1.4s ease-in-out infinite;
}

@keyframes mBlink {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.18;
    transform: scale(0.82);
  }
}

@media (prefers-reduced-motion: reduce) {
  .m-hero:not(.running):not(.paused) .m-live-dot {
    animation: none;
  }
}

/* ============================================================
   Sélecteur de jour : pleine largeur, collé aux bords, et d'une
   hauteur strictement égale à celle des cartes.
   La règle générique .panel plus bas dans le fichier lui
   réappliquait du padding, d'où la bande noire sur les côtés et
   le vide en dessous — on la neutralise par la spécificité.
   ============================================================ */

#training .m-progpanel {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
}

#training .m-daystrip {
  margin: 10px 0;
  padding: 0;
  gap: 0.5rem;
}

/* Retrait sur la première carte seulement : la dernière colle au bord
   droit en fin de défilement, c'est voulu. */
#training .m-daystrip .tab-button:first-child {
  margin-left: 15px;
}

#training .m-daystrip .tab-button:last-child {
  margin-right: 0;
}

/* L'écart entre le sélecteur et la carte héros vient du gap de la
   grille : 1rem était trop généreux une fois les paddings retirés. */
#training > .grid {
  gap: 0.7rem;
}

/* ============================================================
   Finitions « app native »
   ============================================================ */

button,
.mtab,
.hs-row,
.hs-day {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

html:has(body.modal-open) {
  overflow: hidden;
}

/* Barre de titre compacte qui apparaît quand le grand titre sort de
   l'écran, comme les navigation bars iOS. */
.mnav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: calc(var(--m-safe-t) + 0.72rem) var(--m-gutter) 0.72rem;
  background: rgba(8, 9, 11, 0.78);
  backdrop-filter: saturate(180%) blur(22px);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  border-bottom: 1px solid var(--m-hairline);
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}

.mnav span {
  transform: translateY(6px);
  transition: transform 320ms var(--m-spring);
}

body.m-scrolled .mnav {
  opacity: 1;
  pointer-events: auto;
}

body.m-scrolled .mnav span {
  transform: none;
}

/* Section « Dernières séances » sous le programme. */
.m-recent {
  padding: 0 var(--m-gutter);
}

.m-recent .m-sechead {
  margin-top: 0.6rem;
}

/* ============================================================
   Page Historique
   ============================================================ */

#history {
  padding: 0.35rem var(--m-gutter) 1.5rem;
}

.hs-stats {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
}

.hs-stat,
.hs-card,
.hs-rows {
  background: var(--m-card);
  border-color: var(--m-hairline);
  box-shadow: none;
}

.hs-stat {
  padding: 0.9rem;
  border-radius: var(--m-radius-sm);
}

.hs-stat-icon {
  width: 1.9rem;
  height: 1.9rem;
  margin-bottom: 0.45rem;
  border-radius: 0.65rem;
}

.hs-stat strong {
  font-size: 1.45rem;
}

.hs-stat small {
  font-size: 0.76rem;
}

.hs-top {
  grid-template-columns: minmax(0, 1fr);
  gap: 0.6rem;
  margin-top: 0.6rem;
}

.hs-card {
  padding: 1rem;
  border-radius: var(--m-radius);
}

.hs-card-head h2 {
  font-size: 1.14rem;
}

.hs-round {
  width: 2.35rem;
  height: 2.35rem;
  background: var(--m-card-2);
  border-color: var(--m-hairline);
}

.hs-day {
  max-height: none;
  font-size: 0.9rem;
}

.hs-day-more {
  border-color: var(--m-card);
}

.hs-bars {
  height: 11rem;
  gap: 0.22rem;
}

.hs-bar-fill {
  border-radius: 6px 6px 3px 3px;
}

/* Une date sur deux : sinon elles se chevauchent sur petit écran. */
.hs-bar:nth-of-type(even) small {
  display: none;
}

.hs-bar-tip {
  display: none;
}

.hs-toolbar {
  margin: 1.2rem calc(var(--m-gutter) * -1) 0.2rem;
}

.hs-filters {
  flex-wrap: nowrap;
  overflow-x: auto;
  padding: 0.1rem var(--m-gutter);
  scrollbar-width: none;
}

.hs-filters::-webkit-scrollbar {
  display: none;
}

.hs-filter {
  flex: none;
  padding: 0.55rem 0.9rem;
  background: var(--m-card);
  border-color: var(--m-hairline);
}

.hs-group {
  margin-top: 1.25rem;
}

.hs-group-head {
  margin-left: 0.25rem;
}

.hs-group-head h3 {
  font-size: 1.12rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.hs-group-head span {
  font-size: 0.76rem;
}

.hs-rows {
  border-radius: var(--m-radius-sm);
}

.hs-row {
  position: relative;
  grid-template-columns: 2.9rem minmax(0, 1fr) auto 0.8rem;
  gap: 0.75rem;
  padding: 0.72rem 0.85rem;
  border-top: 0;
}

/* Séparateur en retrait, aligné sur le texte, comme les listes iOS. */
.hs-row + .hs-row::before {
  content: "";
  position: absolute;
  top: 0;
  left: calc(0.85rem + 2.9rem + 0.75rem);
  right: 0;
  border-top: 1px solid var(--m-hairline);
}

.hs-row:hover {
  background: none;
}

.hs-row:active {
  background: rgba(255, 255, 255, 0.06);
}

.hs-date {
  width: 2.9rem;
  height: 2.9rem;
  border-radius: 0.85rem;
}

.hs-date strong {
  font-size: 1.1rem;
}

.hs-main strong {
  font-size: 0.97rem;
}

.hs-meta {
  font-size: 0.8rem;
}

.hs-figure strong {
  font-size: 0.9rem;
}

.hs-chevron {
  width: 0.8rem;
  height: 0.8rem;
}

.hs-empty {
  margin: 1.5rem auto;
}

/* ---------- Fiche détaillée : feuille qui monte du bas ---------- */

.hs-sheet {
  z-index: 70;
}

.hs-backdrop {
  opacity: calc(1 - var(--drag, 0));
}

.hs-panel {
  top: auto;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: calc(100% - var(--m-safe-t) - 1.6rem);
  background: #101216;
  border-left: 0;
  border-top: 1px solid var(--m-hairline);
  border-radius: 1.6rem 1.6rem 0 0;
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.6);
  will-change: transform;
}

.hs-sheet.is-entering .hs-panel {
  animation: mSheet 440ms var(--m-spring) both;
}

.hs-sheet.is-closing .hs-panel {
  animation: mSheetOut 260ms cubic-bezier(0.4, 0, 1, 1) both;
}

@keyframes mSheetOut {
  to {
    transform: translateY(100%);
  }
}

.hs-panel-head {
  flex: none;
  padding: 0.55rem var(--m-gutter) 0.95rem;
  touch-action: none;
}

.hs-grabber {
  display: block;
  width: 2.4rem;
  height: 0.3rem;
  margin: 0 auto 0.75rem;
  background: rgba(255, 255, 255, 0.24);
  border-radius: 999px;
}

.hs-panel-head h2 {
  margin-top: 0.4rem;
  font-size: 1.45rem;
}

.hs-panel-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 1rem var(--m-gutter) 1.2rem;
  -webkit-overflow-scrolling: touch;
}

.hs-summary {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.hs-tile,
.hs-ex {
  background: var(--m-card);
  border-color: var(--m-hairline);
}

.hs-tile {
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "label label"
    "value delta";
  align-items: end;
  padding: 0.75rem 0.85rem;
  border-radius: 1rem;
}

.hs-tile > span:first-child {
  grid-area: label;
}

.hs-tile strong {
  grid-area: value;
  font-size: 1.2rem;
}

.hs-tile .hs-delta {
  grid-area: delta;
  margin-bottom: 0.15rem;
}

.hs-ex {
  border-radius: 1.1rem;
}

.hs-sets {
  grid-template-columns: repeat(auto-fill, minmax(3.9rem, 1fr));
}

.hs-panel-foot {
  flex: none;
  padding: 0.75rem var(--m-gutter) calc(0.75rem + var(--m-safe-b));
  background: #101216;
  border-top-color: var(--m-hairline);
}

.hs-panel-foot .danger-button {
  padding-inline: 1.2rem;
  border-radius: 999px;
}

@media (prefers-reduced-motion: reduce) {
  .hs-sheet.is-entering .hs-panel,
  .hs-sheet.is-closing .hs-panel {
    animation: none;
  }
}

/* Retouches : tuiles de stats plus denses, pied de fiche sur une ligne. */
.hs-stat {
  padding: 0.85rem 0.9rem;
}

.hs-stat-icon {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 1.75rem;
  height: 1.75rem;
  margin: 0;
}

.hs-stat-icon svg {
  width: 0.95rem;
  height: 0.95rem;
}

.hs-row {
  grid-template-columns: 2.9rem minmax(0, 1fr) auto;
}

.hs-row .hs-chevron {
  display: none;
}

.hs-panel-foot .primary-button,
.hs-panel-foot .danger-button {
  min-height: 3.1rem;
  white-space: nowrap;
  font-size: 0.98rem;
}

.hs-card-head h2 {
  white-space: nowrap;
}

.hs-segment button {
  padding: 0.35rem 0.7rem;
}

/* Écrans natifs : les styles partagés sont dans views.css. */
.mv-view {
  padding: 0.35rem var(--m-gutter) 1.5rem !important;
}

.mv-grid,
.mv-col {
  display: block;
}

/* Pas de barre de défilement visible sur mobile : on garde le
   défilement, on masque seulement la barre (page et zones internes). */
html,
body,
* {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar,
*::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

/* Feuille d'ajout de repas : grande feuille à hauteur fixe, le contenu
   change d'onglet sans que la feuille ne saute. */
.fd-panel {
  height: calc(100% - var(--m-safe-t) - 1.6rem);
}

.fd-panel .hs-panel-head {
  padding-bottom: 0.75rem;
}

.fd-foot {
  padding-top: 0.65rem;
}

/* Minuteur de repos : îlot compact au-dessus des onglets, façon
   « activité en direct », qui ne masque plus la fiche exercice. */
.rest-timer {
  grid-template-columns: 3.1rem minmax(0, 1fr) auto;
  grid-template-areas: "ring head actions";
  gap: 0.75rem;
  padding: 0.55rem 0.6rem 0.55rem 0.55rem;
  background: rgba(24, 27, 33, 0.9);
  backdrop-filter: blur(22px) saturate(1.6);
  -webkit-backdrop-filter: blur(22px) saturate(1.6);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 1.5rem;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
  animation: mSheet 380ms var(--m-spring) both;
}

body.modal-open .rest-timer {
  z-index: 80;
  bottom: calc(var(--m-safe-b) + 5.2rem);
}

.m-ring {
  width: 3.1rem;
  height: 3.1rem;
}

.rest-timer-head {
  display: grid;
  min-width: 0;
}

.rest-timer-head .eyebrow {
  margin: 0;
  font-size: 0.6rem;
}

.rest-timer-head strong {
  font-size: 1.45rem;
  line-height: 1.05;
}

.rest-timer-head small {
  overflow: hidden;
  font-size: 0.72rem;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.rest-timer-actions {
  display: flex;
  gap: 0.35rem;
}

.rest-timer-actions .ghost-button {
  min-height: 2.5rem;
  padding: 0 0.85rem;
  border-radius: 999px;
  font-size: 0.82rem;
  white-space: nowrap;
}

/* Séance : la carte principale respire jusqu'aux bords. */
#training .tr-hero {
  margin-top: 0.1rem;
}

/* Web app sur l'écran d'accueil : iOS réserve ~34 pt pour la barre
   d'accueil (safe-area). On n'en garde que la moitié sous les onglets,
   comme les apps natives, au lieu d'un grand vide. */
.mtabs {
  padding-bottom: calc(0.35rem + var(--m-safe-b) * 0.5);
}

/* Sélecteur de couleur : un peu plus haut au-dessus des onglets. */
.theme-panel {
  bottom: calc(var(--m-tabbar) + var(--m-safe-b) + 5.5rem);
}

/* Filtres dans l'en-tête d'une feuille : défilement horizontal au doigt. */
.hs-panel-head .mv-cats {
  touch-action: pan-x;
  overscroll-behavior-x: contain;
}

/* Safari élargissait la feuille à la taille de la rangée de filtres
   (contenu plus large que l'écran) : on borne tout à la largeur de
   l'écran et on rogne ce qui dépasse, coins arrondis compris. */
.hs-panel {
  max-width: 100vw;
  overflow: hidden;
}

.hs-panel > .hs-panel-head,
.hs-panel > .hs-panel-body,
.hs-panel > .hs-panel-foot {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.hs-panel-head .mv-cats {
  width: calc(100% + var(--m-gutter) * 2);
  max-width: 100vw;
  min-width: 0;
}

/* Feuille ouverte : le toast se décale pour ne pas couvrir la croix de
   fermeture, et le contenu de la feuille garde de la place sous le
   minuteur de récup, qui flotte par-dessus. */
body.modal-open .toast {
  right: calc(var(--m-gutter) + 3.4rem);
}

body.modal-open:has(.rest-timer:not([hidden])) .hs-panel-body {
  padding-bottom: 6.5rem;
}

/* Fenêtre admin : les règles « .admin-panel » plus haut ne la visaient
   pas (la fenêtre s'appelle .admin-dialog). Elle restait centrée, sous
   la barre d'onglets qui masquait son bouton : feuille par le bas,
   au-dessus de tout. */
.admin-modal {
  z-index: 75;
  align-items: end;
  padding: 0;
}

.admin-dialog {
  width: 100%;
  max-height: calc(100% - var(--m-safe-t) - 1.6rem);
  padding: 1.1rem var(--m-gutter) calc(1.3rem + var(--m-safe-b));
  background: #101216;
  border: 0;
  border-top: 1px solid var(--m-hairline);
  border-radius: 1.6rem 1.6rem 0 0;
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.6);
  overscroll-behavior: contain;
  animation: mSheet 380ms var(--m-spring) both;
}

@media (prefers-reduced-motion: reduce) {
  .admin-dialog {
    animation: none;
  }
}

/* L'ancien bouton palette est remplacé par l'entrée du menu Réglages ;
   le panneau de couleurs, lui, reste utilisé. */
.mtop-actions [data-theme-picker] > .icon-button {
  display: none;
}

.mtop-actions [data-theme-picker] {
  position: static;
}

/* Clavier ouvert : la barre d'onglets s'efface (comme dans une app
   native) au lieu de flotter au-dessus du clavier. */
body.kb-open .mtabs {
  opacity: 0;
  pointer-events: none;
  transform: translateY(1rem);
}

.mtabs {
  transition: opacity 180ms ease, transform 220ms ease;
}

/* Compensation du bug iOS (voir mobile.js, --vv-gap). */
.rest-timer {
  translate: 0 var(--vv-gap, 0px);
}

/* Barre d'onglets recalée en mesurant sa position réelle (mobile.js). */
.mtabs {
  translate: 0 var(--bar-fix, 0px);
}

.hs-sheet {
  bottom: calc(-1 * var(--vv-gap, 0px));
}

/* Barre d'onglets plus basse et plus compacte (moins de vide sous les libellés). */
.mtabs {
  padding: 0.3rem 0.5rem calc(var(--m-safe-b) * 0.45 + 0.1rem) !important;
}

.mtab {
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

/* Paramètres : page entière (comme les réglages iOS). */
.st-panel {
  height: calc(100% - var(--m-safe-t) - 0.6rem);
  max-height: none;
}
