/* Muscu Maison — salle de sport.
   Fond : sol en caoutchouc (gris anthracite moucheté). Couleur d'accent :
   celle du profil, prise dans le code couleur des disques de fonte
   (rouge 25 kg, bleu 20, jaune 15, vert 10). Chiffres en Big Shoulders
   Display, lisibles d'un coup d'œil entre deux séries ; texte en Atkinson
   Hyperlegible Next, dessinée pour la lisibilité. */

@font-face {
  font-family: "Big Shoulders Display";
  src: url("/static/fonts/big-shoulders.woff") format("woff");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("/static/fonts/atkinson-next.woff") format("woff");
  font-weight: 200 800;
  font-display: swap;
}

:root {
  --floor: #1f2226;      /* sol caoutchouc */
  --floor-2: #2a2e33;    /* tapis, cartes */
  --floor-3: #353a40;
  --chalk: #eef0ea;      /* craie */
  --chalk-2: #b7bcb4;
  --chalk-3: #7d837d;
  --line: #3d434a;
  --p: #2563c9;          /* couleur du profil (remplacée en JS) */
  --p-ink: #ffffff;      /* texte sur la couleur du profil */
  --ok: #3fb26b;
  --warn: #f2b705;
  --bad: #e2533f;
  --num: "Big Shoulders Display", Impact, sans-serif;
  --txt: "Atkinson Hyperlegible Next", system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh;
  background-color: var(--floor);
  background-image:
    radial-gradient(rgba(255, 255, 255, .045) 1px, transparent 1.4px),
    radial-gradient(rgba(0, 0, 0, .22) 1px, transparent 1.4px);
  background-size: 9px 11px, 13px 7px;
  background-position: 0 0, 4px 3px;
  color: var(--chalk);
  font-family: var(--txt);
  font-size: 16px; line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--p); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.num { font-family: var(--num); font-variant-numeric: tabular-nums; letter-spacing: .01em; }

#app { max-width: 520px; margin: 0 auto; padding: calc(10px + env(safe-area-inset-top, 0px)) 16px calc(96px + var(--safe-b)); }
body.timing #app { padding-bottom: calc(190px + var(--safe-b)); }

/* ------------------------------------------------------------- en-tête */

.top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 4px 0 14px; }
.profiles { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.profiles::-webkit-scrollbar { display: none; }
.pchip {
  flex: none; display: flex; align-items: center; gap: 8px;
  border: 2px solid var(--line); background: none; border-radius: 999px;
  padding: 5px 14px 5px 6px; font-weight: 600; font-size: 15px; color: var(--chalk-2);
}
.pchip i { width: 22px; height: 22px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 5px rgba(0, 0, 0, .25), inset 0 0 0 7px var(--c); }
.pchip[aria-pressed="true"] { border-color: var(--c); color: var(--chalk); }
.icon-btn { width: 44px; height: 44px; border: 0; background: none; color: var(--chalk-2); border-radius: 50%; display: inline-grid; place-items: center; flex: none; }
.icon-btn:active { background: var(--floor-3); }
.icon-btn svg { width: 24px; height: 24px; }

h1.title { font-family: var(--num); font-weight: 800; font-size: 46px; line-height: .95; margin: 6px 0 4px; letter-spacing: .005em; }
h2.sec { font-family: var(--num); font-weight: 700; font-size: 26px; margin: 26px 0 8px; color: var(--chalk); }
.muted { color: var(--chalk-3); }
.small { font-size: 14px; }

/* ------------------------------------------------------------- boutons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 20px; border-radius: 12px; border: 0;
  background: var(--p); color: var(--p-ink); font-weight: 700; font-size: 17px;
}
.btn:active { transform: translateY(1px); filter: brightness(.95); }
.btn:disabled { opacity: .4; }
.btn.ghost { background: transparent; color: var(--chalk); box-shadow: inset 0 0 0 2px var(--line); }
.btn.dark { background: var(--floor-3); color: var(--chalk); }
.btn.danger { background: transparent; color: var(--bad); box-shadow: inset 0 0 0 2px rgba(226, 83, 63, .5); }
.btn.wide { width: 100%; }
.btn.sm { min-height: 40px; font-size: 15px; padding: 0 14px; border-radius: 10px; }
.link { border: 0; background: none; color: var(--chalk-2); text-decoration: underline; text-underline-offset: 3px; padding: 8px 0; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > .btn { flex: 1; }

/* ------------------------------------------------------------- accueil */

.today {
  position: relative; overflow: hidden;
  background: var(--floor-2); border-radius: 18px; padding: 18px 18px 18px;
  border-left: 8px solid var(--p);
}
.today .kicker { color: var(--chalk-2); font-size: 15px; }
.today .name { font-family: var(--num); font-weight: 800; font-size: 64px; line-height: .9; margin: 4px 0 8px; text-transform: uppercase; }
.today .list { color: var(--chalk-2); font-size: 15px; margin-bottom: 16px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; }
.stat { background: var(--floor-2); border-radius: 14px; padding: 10px 12px; }
.stat b { display: block; font-family: var(--num); font-weight: 800; font-size: 38px; line-height: 1; }
.stat span { font-size: 13px; color: var(--chalk-3); }
.rlist { display: grid; gap: 8px; }
.rcard {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; text-align: left; border: 0; background: var(--floor-2); border-radius: 14px; padding: 14px 16px;
}
.rcard strong { font-family: var(--num); font-size: 28px; font-weight: 700; text-transform: uppercase; line-height: 1; }
.rcard small { display: block; color: var(--chalk-3); font-size: 13px; margin-top: 3px; }
.rcard .go { color: var(--chalk-3); }

.alert { display: flex; gap: 12px; background: var(--floor-2); border-radius: 14px; padding: 12px 14px; margin: 8px 0; font-size: 15px; }
.alert::before { content: ""; flex: none; width: 4px; border-radius: 2px; background: var(--warn); }
.alert.plateau::before { background: var(--bad); }
.alert b { display: block; }
.alert .d { color: var(--chalk-3); font-size: 13px; }

/* ------------------------------------------------------------- séance */

.wk-head { position: sticky; top: 0; z-index: 5; margin: 0 -16px 10px; padding: calc(8px + env(safe-area-inset-top, 0px)) 16px 10px; background: var(--floor); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.wk-head .t { flex: 1; min-width: 0; }
.wk-head .t b { display: block; font-family: var(--num); font-size: 30px; line-height: 1; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wk-head .t span { font-size: 13px; color: var(--chalk-3); }
.wk-head .clock { font-family: var(--num); font-size: 26px; color: var(--chalk-2); }

.ex { background: var(--floor-2); border-radius: 18px; padding: 14px 14px 10px; margin: 0 0 14px; }
.ex.done { opacity: .72; }
.ex-h { display: flex; gap: 8px; align-items: flex-start; }
.ex-h .n { flex: 1; min-width: 0; }
.ex-h h3 { margin: 0; font-size: 19px; line-height: 1.2; }
.ex-h .mus { font-size: 13px; color: var(--chalk-3); }
.ex .setting { font-size: 13.5px; color: var(--chalk-2); margin-top: 6px; }
.ex .setting::before { content: "Réglage : "; color: var(--chalk-3); }
.coach {
  margin: 10px 0 4px; padding: 10px 12px; border-radius: 12px;
  background: color-mix(in srgb, var(--p) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--p) 45%, transparent);
  font-size: 14.5px;
}
.coach .big { font-family: var(--num); font-size: 26px; font-weight: 800; line-height: 1; display: inline-block; margin-right: 6px; }
.coach .tag { display: inline-block; font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: var(--p); color: var(--p-ink); vertical-align: 3px; }
.coach .tag.down { background: var(--warn); color: #241c00; }
.coach p { margin: 6px 0 0; color: var(--chalk-2); }
.coach.plateau { background: rgba(226, 83, 63, .12); border-color: rgba(226, 83, 63, .45); }
.last { font-size: 13.5px; color: var(--chalk-3); margin: 6px 0 4px; }

.sets { margin-top: 8px; }
.set-h, .set { display: grid; grid-template-columns: 26px 1fr 1fr 58px; gap: 8px; align-items: center; }
.set-h { font-size: 12px; color: var(--chalk-3); padding: 0 0 2px; }
.set-h span:nth-child(2), .set-h span:nth-child(3) { text-align: center; }
.set { padding: 5px 0; }
.set .i { font-family: var(--num); font-size: 20px; color: var(--chalk-3); text-align: center; }
.stepper { display: grid; grid-template-columns: 34px 1fr 34px; align-items: center; background: var(--floor); border-radius: 12px; height: 56px; }
.stepper button { border: 0; background: none; height: 100%; color: var(--chalk-2); font-size: 22px; font-weight: 700; }
.stepper button:active { color: var(--p); }
.stepper input {
  width: 100%; min-width: 0; border: 0; background: none; text-align: center;
  font-family: var(--num); font-weight: 800; font-size: 32px; padding: 0;
}
.stepper input::placeholder { color: var(--chalk-3); opacity: .55; }
.stepper input:focus { outline: none; color: var(--p); }
.check {
  height: 56px; border-radius: 12px; border: 2px solid var(--line); background: none;
  display: grid; place-items: center; color: var(--chalk-3);
}
.check svg { width: 28px; height: 28px; }
.set.done .check { background: var(--p); border-color: var(--p); color: var(--p-ink); }
.set.done .stepper { background: color-mix(in srgb, var(--p) 10%, var(--floor)); }
.set .pr { grid-column: 2 / 4; justify-self: center; font-family: var(--num); font-weight: 800; letter-spacing: .08em; color: var(--warn); font-size: 15px; margin-top: -2px; }
.ex-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }

.stamp {
  position: fixed; left: 50%; top: 38%; z-index: 80; pointer-events: none;
  transform: translate(-50%, -50%) rotate(-9deg);
  font-family: var(--num); font-weight: 900; font-size: 64px; line-height: .9; text-align: center;
  color: var(--warn); border: 6px solid var(--warn); border-radius: 12px; padding: 8px 18px;
  animation: stamp 1.4s ease-out forwards;
}
.stamp small { display: block; font-size: 22px; letter-spacing: .05em; }
@keyframes stamp {
  0% { transform: translate(-50%, -50%) rotate(-9deg) scale(2.2); opacity: 0; }
  14% { transform: translate(-50%, -50%) rotate(-9deg) scale(1); opacity: 1; }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -54%) rotate(-9deg) scale(1); }
}

/* ------------------------------------------------------------- minuteur de repos */

.timer {
  position: fixed; left: 0; right: 0; bottom: calc(66px + var(--safe-b)); z-index: 30;
  background: var(--floor-3); border-top: 3px solid var(--p);
  padding: 10px 16px 12px;
}
.timer .in { max-width: 520px; margin: 0 auto; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; }
.timer .lbl { font-size: 13px; color: var(--chalk-2); }
.timer .big { font-family: var(--num); font-weight: 900; font-size: 68px; line-height: .85; font-variant-numeric: tabular-nums; }
.timer .bar { grid-column: 1 / -1; height: 10px; border-radius: 5px; background: var(--floor); overflow: hidden; }
.timer .bar i { display: block; height: 100%; background: var(--p); transform-origin: left; }
.timer .ctl { display: flex; gap: 6px; }
.timer.over { border-top-color: var(--ok); }
.timer.over .big { color: var(--ok); }
.timer.over .bar i { background: var(--ok); }

/* ------------------------------------------------------------- programmes */

.item { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; background: var(--floor-2); border-radius: 14px; padding: 12px 12px 10px; margin: 8px 0; }
.item .nm { font-weight: 700; }
.item .nm small { display: block; font-weight: 400; font-size: 13px; color: var(--chalk-3); }
.item .ord { display: flex; }
.item .nums { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.item label { font-size: 12px; color: var(--chalk-3); }
.item input { width: 100%; height: 44px; border: 0; border-radius: 10px; background: var(--floor); text-align: center; font-family: var(--num); font-size: 24px; font-weight: 700; }

.field { display: block; margin: 12px 0; }
.field > span { display: block; font-size: 14px; color: var(--chalk-2); margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; border: 2px solid var(--line); border-radius: 12px; background: var(--floor);
  padding: 12px; font-size: 17px;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--p); }

/* ------------------------------------------------------------- progrès */

.vol { display: grid; gap: 7px; margin: 8px 0; }
.vrow { display: grid; grid-template-columns: 92px 1fr 34px; gap: 8px; align-items: center; font-size: 14px; }
.vrow .track { position: relative; height: 16px; background: var(--floor-2); border-radius: 4px; overflow: hidden; }
/* zone conseillée 10-20 séries (sur une échelle de 0 à 25) */
.vrow .zone { position: absolute; top: 0; bottom: 0; left: 40%; width: 40%; background: rgba(63, 178, 107, .16); border-left: 1px dashed rgba(63, 178, 107, .6); border-right: 1px dashed rgba(63, 178, 107, .6); }
.vrow .fill { position: absolute; left: 0; top: 3px; bottom: 3px; border-radius: 3px; background: var(--p); }
.vrow b { font-family: var(--num); font-size: 20px; text-align: right; }
.legend { font-size: 13px; color: var(--chalk-3); }

.exrow { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; width: 100%; text-align: left; border: 0; background: none; padding: 12px 0; border-bottom: 1px solid var(--line); }
.exrow .n { font-weight: 600; }
.exrow .r { font-family: var(--num); font-size: 24px; font-weight: 700; text-align: right; }
.exrow .s { grid-column: 1 / -1; font-size: 13px; color: var(--chalk-3); }
.exrow .s .up { color: var(--ok); }
.exrow .s .pl { color: var(--bad); }

.chart { width: 100%; height: auto; display: block; margin: 8px 0; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .ln { fill: none; stroke: var(--p); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.chart .ln2 { fill: none; stroke: var(--chalk-3); stroke-width: 2; stroke-dasharray: 4 5; }
.chart .dot { fill: var(--floor); stroke: var(--p); stroke-width: 2.5; }
.chart text { fill: var(--chalk-3); font-size: 12px; font-family: var(--txt); }
.recs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.duel { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.duel .side { background: var(--floor-2); border-radius: 14px; padding: 12px; border-top: 5px solid var(--c); }
.duel .side h4 { margin: 0 0 6px; font-family: var(--num); font-size: 24px; }
.duel .side div { display: flex; justify-content: space-between; font-size: 14px; color: var(--chalk-2); padding: 2px 0; }
.duel .side div b { font-family: var(--num); font-size: 20px; color: var(--chalk); }
.duel .side div b.lead { color: var(--c); }

.hist { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 12px; font-size: 14px; }
.hist .d { color: var(--chalk-3); }

/* ------------------------------------------------------------- machines */

.search { width: 100%; border: 2px solid var(--line); border-radius: 12px; background: var(--floor-2); padding: 12px 14px; font-size: 17px; margin: 6px 0 4px; }
.search:focus { outline: none; border-color: var(--p); }
.grp { font-family: var(--num); font-size: 22px; font-weight: 700; margin: 18px 0 2px; color: var(--chalk-2); }
.mrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; text-align: left; border: 0; background: none; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 16px; }
.mrow small { display: block; color: var(--chalk-3); font-size: 13px; }
.mrow .note { color: var(--chalk-2); }

/* ------------------------------------------------------------- navigation */

nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: #17191c; border-top: 1px solid var(--line);
  padding: 6px 8px calc(6px + var(--safe-b));
}
nav.tabs .in { display: grid; grid-template-columns: repeat(4, 1fr); max-width: 520px; margin: 0 auto; }
nav.tabs button { border: 0; background: none; color: var(--chalk-3); display: grid; justify-items: center; gap: 1px; font-size: 12px; padding: 4px 0; }
nav.tabs svg { width: 25px; height: 25px; }
nav.tabs button[aria-current="page"] { color: var(--chalk); }
nav.tabs button[aria-current="page"] svg { color: var(--p); }
nav.tabs .live { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); display: inline-block; margin-left: 4px; vertical-align: 2px; }

/* ------------------------------------------------------------- feuilles */

#sheet-root:empty { display: none; }
.scrim { position: fixed; inset: 0; z-index: 60; background: rgba(8, 9, 10, .66); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  position: relative; width: 100%; max-width: 540px; max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--floor-2); border-radius: 22px 22px 0 0; padding: 22px 18px calc(22px + var(--safe-b));
  animation: up .22s cubic-bezier(.2, .9, .3, 1);
}
@keyframes up { from { transform: translateY(50px); } }
.sheet h2 { font-family: var(--num); font-weight: 800; font-size: 34px; line-height: 1; margin: 0 44px 8px 0; }
.sheet .close { position: absolute; top: 12px; right: 10px; }
.sheet .field input, .sheet .field select, .sheet .field textarea { background: var(--floor); }
.pick-grp { font-size: 13px; color: var(--chalk-3); margin: 14px 0 4px; }
.pick { width: 100%; text-align: left; border: 0; background: var(--floor); border-radius: 10px; padding: 12px; margin: 4px 0; font-size: 16px; }
.pick small { color: var(--chalk-3); }
.colors { display: flex; gap: 10px; }
.colors button { width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--c); box-shadow: inset 0 0 0 9px rgba(0, 0, 0, .28), inset 0 0 0 12px var(--c); }
.colors button[aria-pressed="true"] { outline: 3px solid var(--chalk); outline-offset: 3px; }
.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0 14px; }

#toast {
  position: fixed; left: 50%; bottom: calc(84px + var(--safe-b)); z-index: 90; width: max-content; max-width: calc(100vw - 32px);
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  background: var(--chalk); color: var(--floor); padding: 11px 16px; border-radius: 12px; font-weight: 600; font-size: 15px;
  transition: opacity .2s, transform .2s; display: flex; gap: 12px;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#toast button { border: 0; background: none; padding: 0; font-weight: 800; text-decoration: underline; color: inherit; }
body.timing #toast { bottom: calc(196px + var(--safe-b)); }
.offline { position: fixed; top: 0; left: 0; right: 0; z-index: 95; background: var(--warn); color: #241c00; text-align: center; font-size: 13px; font-weight: 600; padding: calc(3px + env(safe-area-inset-top, 0px)) 8px 3px; }

.login { margin-top: 14vh; }
.login h1.title { font-size: 72px; }
.err { color: var(--bad); font-size: 15px; margin: 8px 0; }
.empty { text-align: center; color: var(--chalk-3); padding: 30px 10px; }

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

.gap { height: 14px; }
.mt { margin-top: 10px; }
