@font-face {
  font-family: 'Nunito Sans';
  src: url('../fonts/nunito-sans-latin.woff2') format('woff2');
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --ground: #EFE9E1;
  --card: #FFFFFF;
  --surface: #F5F0EA;
  --line: #E4DBD0;
  --ink: #2A2522;
  --ink-2: #6B625B;
  --act: #1F7A5C;
  --act-strong: #17624A;
  --act-soft: #E2EEE7;
  --tile: #EAF2EC;
  --prop: #B9AEA3;
  --danger: #A33A2C;

  --r-card: 24px;
  --r-row: 20px;
  --r-btn: 18px;
  --r-chip: 14px;
  --shadow: 0 1px 2px rgb(74 52 30 / 0.05), 0 8px 22px -14px rgb(74 52 30 / 0.28);
  --shadow-lift: 0 2px 4px rgb(74 52 30 / 0.06), 0 18px 40px -18px rgb(74 52 30 / 0.4);
  --spring: cubic-bezier(0.3, 1.32, 0.6, 1);
  --out: cubic-bezier(0.16, 1, 0.3, 1);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--ground); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: 'Nunito Sans', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--ground);
  -webkit-tap-highlight-color: transparent;
  caret-color: var(--act);
}
::selection { background: var(--act-soft); color: var(--ink); }
:focus-visible { outline: 3px solid var(--act); outline-offset: 2px; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p, ol, ul { margin: 0; }
ol, ul { padding: 0; list-style: none; }
.num { font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }

/* ——— Structure */
.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 16px calc(104px + var(--safe-b));
}
.view-head { padding: 22px 4px 0; }
.view-head .when { font-size: 15px; font-weight: 600; color: var(--ink-2); }
.view-head h1 { font-size: 30px; font-weight: 800; line-height: 1.1; letter-spacing: -0.01em; margin-top: 6px; }
.view-head .lede { font-size: 15px; font-weight: 600; color: var(--ink-2); margin-top: 6px; }
.section-title { font-size: 18px; font-weight: 800; margin: 30px 4px 12px; }
.section-title small { font-size: 14px; font-weight: 600; color: var(--ink-2); margin-left: 6px; }

.card {
  background: var(--card);
  border-radius: var(--r-card);
  padding: 20px;
  box-shadow: var(--shadow);
}
.view-head + .card { margin-top: 16px; }

/* ——— Boutons */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 56px; padding: 0 20px;
  border: 0; border-radius: var(--r-btn);
  font-size: 18px; font-weight: 800;
  transition: transform 320ms var(--spring), background-color 160ms;
}
.btn:active { transform: scale(0.97); transition-duration: 90ms; }
.btn-primary { background: var(--act); color: #fff; }
.btn-primary:active { background: var(--act-strong); }
.btn-primary .btn-aside { font-weight: 600; opacity: 0.85; }
.btn-soft { background: var(--surface); color: var(--ink); }
.btn-plain { background: transparent; color: var(--ink); min-height: 48px; }
.btn-danger { background: transparent; color: var(--danger); min-height: 48px; }
.btn[disabled] { background: var(--surface); color: var(--ink-2); }

.icon-btn {
  display: grid; place-items: center;
  width: 44px; height: 44px; border: 0; border-radius: 14px;
  background: transparent; color: var(--ink-2);
  transition: transform 320ms var(--spring), background-color 160ms;
}
.icon-btn:active { transform: scale(0.92); background: var(--surface); transition-duration: 90ms; }
.icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.link {
  border: 0; background: none; padding: 10px 0; color: var(--act);
  font-weight: 800; font-size: 15px; display: inline-flex; align-items: center; gap: 4px;
}

/* ——— Choix de durée */
.seg { display: flex; gap: 8px; margin-top: 16px; border: 0; padding: 0; }
.seg label { flex: 1; position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span {
  display: block; text-align: center; padding: 11px 0;
  border-radius: var(--r-chip); background: var(--surface);
  font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums;
  transition: background-color 160ms, color 160ms;
}
.seg input:checked + span { background: var(--ink); color: #fff; }
.seg input:focus-visible + span { outline: 3px solid var(--act); outline-offset: 2px; }

/* ——— Séance du jour */
.today h2 { font-size: 24px; font-weight: 800; line-height: 1.15; }
.today .meta { font-size: 15px; font-weight: 600; color: var(--ink-2); margin-top: 4px; }
.today .btn { margin-top: 16px; }
.today .note { font-size: 14px; font-weight: 600; color: var(--ink-2); margin-top: 12px; text-align: center; }
.resume { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.resume p { flex: 1; font-size: 15px; font-weight: 700; }
.resume .btn { width: auto; min-height: 44px; font-size: 16px; padding: 0 16px; }

/* ——— Lignes d'exercice */
.rows { display: grid; gap: 10px; }
.row {
  display: flex; align-items: center; gap: 4px;
  background: var(--card); border-radius: var(--r-row);
  box-shadow: var(--shadow);
  padding: 4px 4px 4px 0;
}
.row-main {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 14px;
  border: 0; background: none; text-align: left;
  padding: 8px 4px 8px 12px; border-radius: var(--r-row);
  transition: transform 320ms var(--spring);
}
.row-main:active { transform: scale(0.98); transition-duration: 90ms; }
.row-text { min-width: 0; }
.row-text b { display: block; font-size: 16px; font-weight: 700; line-height: 1.25; }
.row-text span { display: block; font-size: 14px; font-weight: 600; color: var(--ink-2); margin-top: 2px; font-variant-numeric: tabular-nums; }
.row .chev { color: var(--ink-2); margin: 0 6px 0 auto; flex: none; }

.tile {
  --tile-bg: var(--tile);
  flex: none; width: 56px; height: 56px; border-radius: var(--r-chip);
  background: var(--tile-bg); padding: 5px;
}
.tile.flow { --tile-bg: var(--surface); }

/* ——— Pictogrammes */
.pic { display: block; width: 100%; height: 100%; overflow: visible; }
.pic-ink { fill: none; stroke: var(--ink); stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; }
.pic-torso { stroke-width: 8.5; }
.pic-halo { fill: none; stroke: var(--tile-bg, var(--tile)); stroke-width: 13; stroke-linecap: round; stroke-linejoin: round; }
.pic-head { fill: var(--ink); }
.pic-halo-fill { fill: var(--tile-bg, var(--tile)); }
.pic-prop { fill: none; stroke: var(--prop); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.pic-mat { stroke: var(--prop); stroke-width: 3; stroke-linecap: round; }

/* ——— Semaine */
.week { display: grid; gap: 8px; }
.week label {
  display: flex; align-items: center; gap: 12px; position: relative;
  background: var(--card); border-radius: var(--r-row); padding: 14px 16px;
  box-shadow: var(--shadow); cursor: pointer;
  outline: 2px solid transparent; outline-offset: -2px;
  transition: outline-color 160ms;
}
.week input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.week label:has(input:checked) { outline-color: var(--ink); }
.week label:has(input:focus-visible) { outline: 3px solid var(--act); }
.week .txt { flex: 1; }
.week b { display: block; font-weight: 700; }
.week span { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.state { flex: none; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; }
.state.done { background: var(--ink); border-color: var(--ink); color: #fff; }
.state .icon { width: 15px; height: 15px; stroke-width: 3; }

/* ——— Barre d'onglets */
.tabs {
  position: fixed; left: 0; right: 0; bottom: calc(12px + var(--safe-b));
  margin: 0 auto; width: calc(100% - 24px); max-width: 456px; height: 66px;
  display: flex; background: var(--card); border-radius: 22px; box-shadow: 0 10px 30px -12px rgb(74 52 30 / 0.35), 0 1px 2px rgb(74 52 30 / 0.06);
  z-index: 10;
}
.tabs a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  color: var(--ink-2); text-decoration: none; font-size: 12px; font-weight: 700; border-radius: 22px;
}
.tabs a[aria-current='page'] { color: var(--act); }
.tabs a[aria-current='page'] .icon { stroke-width: 2.4; }

/* ——— Bibliothèque */
.chips { display: flex; gap: 8px; overflow-x: auto; margin: 16px -16px 0; padding: 2px 16px 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 0; border-radius: var(--r-chip); background: var(--card);
  padding: 9px 14px; font-size: 15px; font-weight: 700; box-shadow: var(--shadow);
}
.chip[aria-pressed='true'] { background: var(--ink); color: #fff; }
.lib { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.lib-card {
  border: 0; text-align: left; background: var(--card); border-radius: var(--r-row);
  padding: 10px 10px 14px; box-shadow: var(--shadow);
  transition: transform 320ms var(--spring);
}
.lib-card:active { transform: scale(0.97); transition-duration: 90ms; }
.lib-card .tile { width: 100%; height: auto; aspect-ratio: 1; padding: 10px; }
.lib-card b { display: block; font-size: 15px; font-weight: 700; line-height: 1.25; margin: 10px 4px 0; }
.lib-card span { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 3px 4px 0; }

/* ——— Programme */
.progress-line { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.progress-line b { font-size: 34px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.bar { height: 10px; border-radius: 5px; background: var(--surface); margin-top: 14px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--ink); border-radius: 5px; }
.card p.small { font-size: 15px; font-weight: 600; color: var(--ink-2); margin-top: 12px; }
.field { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.field label { font-weight: 700; }
.field input[type='date'] {
  border: 0; background: var(--surface); border-radius: 12px; padding: 10px 12px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.phase { margin-top: 26px; }
.phase h2 { font-size: 18px; font-weight: 800; margin: 0 4px; }
.phase h2 small { font-size: 14px; font-weight: 600; color: var(--ink-2); margin-left: 6px; }
.phase > p { font-size: 15px; font-weight: 600; color: var(--ink-2); margin: 4px 4px 12px; max-width: 60ch; }
.weeks { background: var(--card); border-radius: var(--r-card); box-shadow: var(--shadow); padding: 6px 16px; }
.weeks li { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; }
.weeks li + li { border-top: 1px solid var(--line); }
.weeks li b { font-weight: 700; }
.weeks li.now b::after { content: ' · en cours'; font-weight: 600; color: var(--ink-2); }
.dots { display: flex; gap: 8px; }
.dots .state { width: 28px; height: 28px; font-size: 12px; font-weight: 800; color: var(--ink-2); }
.dots .state.done { color: #fff; }
.swaps li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; }
.swaps li + li { border-top: 1px solid var(--line); }
.swaps span { font-size: 15px; font-weight: 600; }
.settings .btn { margin-top: 12px; }

/* ——— Journal */
.log { display: grid; gap: 10px; }
.log li { background: var(--card); border-radius: var(--r-row); padding: 14px 16px; box-shadow: var(--shadow); }
.log b { display: block; font-size: 17px; font-weight: 800; }
.log span { display: block; margin-top: 2px; font-size: 14px; font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.empty { text-align: center; padding: 36px 20px; }
.empty .tile { width: 96px; height: 96px; margin: 0 auto 16px; padding: 10px; }
.empty p { font-weight: 600; color: var(--ink-2); max-width: 30ch; margin: 6px auto 0; }
.empty b { font-size: 18px; font-weight: 800; }

/* ——— Feuilles (bottom sheets) */
.sheet {
  border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 480px;
  max-height: 88dvh; border-radius: 26px 26px 0 0; background: var(--card); color: var(--ink);
  box-shadow: 0 -10px 40px -20px rgb(42 37 34 / 0.4);
}
.sheet[open] { animation: sheet-in 380ms var(--out); }
.sheet::backdrop { background: rgb(42 37 34 / 0.38); animation: fade-in 240ms ease-out; }
@keyframes sheet-in { from { transform: translateY(100%); } }
@keyframes fade-in { from { opacity: 0; } }
.sheet-in { padding: 10px 20px calc(24px + var(--safe-b)); }
.grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 14px; }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.sheet h2 { font-size: 22px; font-weight: 800; line-height: 1.2; }
.sheet .sub { font-size: 15px; font-weight: 600; color: var(--ink-2); margin-top: 4px; }
.sheet .big-tile { width: 100%; max-width: 260px; aspect-ratio: 1; height: auto; margin: 6px auto 18px; padding: 16px; border-radius: 22px; }
.cues { display: grid; gap: 10px; margin-top: 16px; }
.cues li { display: grid; grid-template-columns: 26px 1fr; gap: 10px; font-size: 16px; font-weight: 600; }
.cues li::before {
  counter-increment: cue; content: counter(cue);
  width: 26px; height: 26px; border-radius: 50%; background: var(--surface);
  display: grid; place-items: center; font-size: 13px; font-weight: 800;
}
.cues { counter-reset: cue; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tag { font-size: 13px; font-weight: 700; padding: 5px 10px; border-radius: 10px; background: var(--surface); color: var(--ink-2); }
.sheet .btn { margin-top: 18px; }
.pick-group { margin-top: 20px; }
.pick-group h3 { font-size: 14px; font-weight: 800; color: var(--ink-2); margin-bottom: 8px; }
.pick { display: grid; gap: 8px; }
.pick .row { box-shadow: none; background: var(--surface); }
.pick .tile { --tile-bg: var(--card); }
.flow-list { display: grid; gap: 8px; margin-top: 16px; }
.flow-list li { display: flex; align-items: center; gap: 12px; }
.flow-list .tile { width: 48px; height: 48px; }
.flow-list b { flex: 1; font-weight: 700; }
.flow-list span { font-size: 14px; font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.choice { display: grid; gap: 4px; margin-top: 18px; }
.choice .btn { margin-top: 0; }

/* ——— Lecteur de séance */
.player {
  position: fixed; inset: 0; z-index: 20; background: var(--ground);
  display: grid; grid-template-rows: auto 1fr auto;
  max-width: 480px; margin: 0 auto;
  padding: 8px 16px calc(16px + var(--safe-b));
}
.p-top { display: flex; align-items: center; gap: 10px; height: 52px; }
.p-top .count { font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; min-width: 4.2ch; text-align: right; }
.segs { flex: 1; display: flex; gap: 4px; }
.segs i { flex: 1; height: 6px; border-radius: 3px; background: linear-gradient(to right, var(--ink) var(--f, 0%), var(--line) var(--f, 0%)); }

.p-body { position: relative; display: grid; min-height: 0; padding-top: 6px; }
.work {
  display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 14px;
  background: var(--card); border-radius: 28px; box-shadow: var(--shadow-lift); padding: 18px 20px 20px; min-height: 0;
}
.work .stage { --tile-bg: var(--tile); position: relative; background: var(--tile); border: 0; border-radius: 22px; min-height: 0; padding: 0; }
.work .stage { overflow: hidden; }
.work .stage .pic { position: absolute; inset: 12px; width: calc(100% - 24px); height: calc(100% - 24px); }
/* Cases fixes : bloc titre réservé pour deux lignes (aligné en haut), consignes sur trois. */
.work .head { min-height: 84px; }
.work h2 { font-size: 26px; font-weight: 800; line-height: 1.15; }
.work .meta { font-size: 15px; font-weight: 600; color: var(--ink-2); margin-top: 2px; }
.work .line { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-top: 12px; }
.big { font-size: 6rem; font-weight: 800; line-height: 0.9; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.unit { font-size: 17px; font-weight: 700; color: var(--ink-2); margin-top: 6px; }
.sets { display: flex; gap: 6px; padding-bottom: 6px; }
.sets i { width: 16px; height: 16px; border-radius: 50%; border: 2.5px solid var(--ink); position: relative; }
.sets i.done { background: var(--ink); }
.sets i.now { box-shadow: 0 0 0 3px var(--act-soft); }
.sets i.skip::after { content: ''; position: absolute; left: -4px; right: -4px; top: 50%; height: 2.5px; margin-top: -1.25px; background: var(--ink); transform: rotate(-35deg); }
.sets-label { font-size: 14px; font-weight: 700; color: var(--ink-2); text-align: right; margin-bottom: 4px; }
.cue { font-size: 15px; font-weight: 600; line-height: 1.45; color: var(--ink-2); margin-top: 12px; height: 4.35em; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.tbar { height: 8px; border-radius: 4px; background: var(--surface); margin-top: 14px; overflow: hidden; }
.tbar i { display: block; height: 100%; width: 100%; background: var(--ink); transform-origin: left; transform: scaleX(var(--p, 0)); }

.p-actions { padding-top: 12px; }
.p-actions .btn-primary { min-height: 64px; font-size: 20px; }
.p-actions .alt { display: flex; justify-content: space-between; margin-top: 6px; }
.p-actions .alt .btn { width: auto; font-size: 16px; padding: 0 12px; color: var(--ink-2); }

/* Pause : une grande carte-bouton qui se remplit de vert. */
.rest {
  position: relative; width: 100%; height: 100%; min-height: 0; border: 0; padding: 0;
  border-radius: 28px; background: var(--card); box-shadow: var(--shadow-lift); overflow: hidden; text-align: left;
  transition: transform 320ms var(--spring);
}
.rest:active { transform: scale(0.985); transition-duration: 90ms; }
.rest-layer {
  position: absolute; inset: 0; display: grid; grid-template-rows: auto 1fr auto auto; padding: 24px;
}
.rest-layer.fill {
  background: var(--act); color: #fff;
  clip-path: inset(calc(var(--left, 1) * 100%) 0 0 0);
}
.rest-layer .lbl { font-size: 20px; font-weight: 800; }
.rest-layer .time { align-self: center; justify-self: center; font-size: 6rem; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1; }
.rest-layer .next { display: flex; align-items: center; gap: 14px; }
.rest-layer .next .tile { width: 60px; height: 60px; }
.rest-layer.fill .next .tile { --tile-bg: rgb(255 255 255 / 0.16); }
.rest-layer.fill .pic-ink, .rest-layer.fill .pic-head { stroke: #fff; }
.rest-layer.fill .pic-head { fill: #fff; }
.rest-layer.fill .pic-halo { stroke: #2C8466; }
.rest-layer.fill .pic-halo-fill { fill: #2C8466; }
.rest-layer.fill .pic-prop, .rest-layer.fill .pic-mat { stroke: rgb(255 255 255 / 0.45); }
.rest-layer.fill .next .tile { background: #2C8466; }
.rest-layer .next b { display: block; font-size: 19px; font-weight: 800; line-height: 1.2; }
.rest-layer .next span { display: block; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 1px; }
.rest-layer .hint { font-size: 15px; font-weight: 700; margin-top: 18px; }
.rest-layer:not(.fill) .hint, .rest-layer:not(.fill) .next span { color: var(--ink-2); }
.tick { animation: tick 1s var(--out); }
@keyframes tick { from { transform: scale(1.08); } }

.done-view { display: grid; align-content: center; text-align: center; gap: 8px; }
.done-view .tile { width: 132px; height: 132px; margin: 0 auto 12px; padding: 12px; border-radius: 28px; }
.done-view h2 { font-size: 30px; font-weight: 800; }
.done-view p { font-weight: 600; color: var(--ink-2); }
.stats { display: flex; justify-content: center; gap: 28px; margin: 18px 0 6px; }
.stats b { display: block; font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stats span { font-size: 14px; font-weight: 600; color: var(--ink-2); }

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