/*
  Direction visuelle — carnet de salle, lisible d'une main, sous les néons.
  Palette : encre bleu-ardoise #1B2232 (fond), panneau #242D42, ligne #3B4963, texte #EEF1F7,
  et les couleurs des disques olympiques pour les types de série : blanc (échauffement),
  bleu (travail), rouge (échec), jaune (drop). Vert #34C27A réservé à « validé ».
  Typo : Big Shoulders Display (chiffres et titres, esprit disques estampés) + Atkinson Hyperlegible (texte).
  Élément mémorable : le disque. Chaque série est un disque coloré ; le minuteur est un disque qui se vide.
*/
@font-face { font-family: "Big Shoulders Display"; font-weight: 700; font-display: swap; src: url("../fonts/big-shoulders-display-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Big Shoulders Display"; font-weight: 800; font-display: swap; src: url("../fonts/big-shoulders-display-latin-800-normal.woff2") format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 400; font-display: swap; src: url("../fonts/atkinson-hyperlegible-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 700; font-display: swap; src: url("../fonts/atkinson-hyperlegible-latin-700-normal.woff2") format("woff2"); }

:root {
  --ink: #1b2232;
  --panel: #242d42;
  --panel2: #2e3952;
  --line: #3b4963;
  --text: #eef1f7;
  --muted: #a2aec4;
  --white: #e8ecf3;
  --blue: #3d7dff;
  --red: #ef4b50;
  --yellow: #f7c61b;
  --ok: #34c27a;
  --danger: #ff6b6f;
  --display: "Big Shoulders Display", "Arial Narrow", Impact, sans-serif;
  --body: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  --tabs-h: 72px;
  --timer-h: 84px;
  /* Marge basse minimale de 14 px : dans un aperçu en iframe ou un navigateur sans zone sûre, env() vaut 0 et la barre Home d'iOS recouvrirait les boutons. */
  --safe-b: max(env(safe-area-inset-bottom, 0px), 14px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--ink); color-scheme: dark; }
body {
  margin: 0; background: var(--ink); color: var(--text);
  font: 17px/1.4 var(--body);
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; font-family: var(--display); font-weight: 800; line-height: 1.05; letter-spacing: 0.005em; }
h1 { font-size: 40px; }
h2 { font-size: 28px; }
h3 { font-size: 22px; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus-visible, .btn:focus-within { outline: 3px solid var(--yellow); outline-offset: 2px; border-radius: 8px; }

#app { min-height: 100dvh; }
#view {
  padding: calc(16px + var(--safe-t)) 16px calc(var(--tabs-h) + var(--safe-b) + 24px);
  max-width: 640px; margin: 0 auto; outline: none;
}
body.has-timer #view { padding-bottom: calc(var(--tabs-h) + var(--timer-h) + var(--safe-b) + 24px); }

/* ---------- Navigation ---------- */
#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--panel); border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b); height: calc(var(--tabs-h) + var(--safe-b));
}
#tabs button {
  background: none; border: 0; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 13px; min-height: 56px; padding: 0;
}
#tabs svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#tabs button[aria-current="page"] { color: var(--text); }
#tabs button[aria-current="page"] span { font-weight: 700; border-bottom: 3px solid var(--blue); padding-bottom: 1px; }

/* ---------- Boutons, champs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--panel2); font-weight: 700;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #0c2a1a; }
.btn.ghost { background: transparent; }
.btn.danger { border-color: var(--danger); color: var(--danger); background: transparent; }
.btn.block { width: 100%; }
.btn.sm { min-height: 40px; padding: 0 12px; font-size: 15px; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 12px; }
.stack-lg > * + * { margin-top: 24px; }

/* :where() = spécificité nulle : les classes (.name, .cell input…) gardent la main. */
:where(input:not([type="checkbox"]):not([type="file"]):not([type="hidden"]), select, textarea) {
  width: 100%; min-height: 48px; padding: 8px 12px; border-radius: 10px;
  background: var(--ink); border: 1.5px solid var(--line); font-size: 17px;
}
textarea { min-height: 88px; resize: vertical; }
label.field { display: block; }
label.field > span { display: block; font-size: 14px; color: var(--muted); margin-bottom: 4px; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; }
.toggle input { width: 28px; height: 28px; accent-color: var(--blue); flex: none; }

.seg { display: flex; border: 1.5px solid var(--line); border-radius: 12px; overflow: hidden; }
.seg button { flex: 1; min-height: 44px; background: transparent; border: 0; color: var(--muted); font-weight: 700; padding: 0 8px; }
.seg button + button { border-left: 1.5px solid var(--line); }
.seg button[aria-pressed="true"], .seg button[aria-selected="true"] { background: var(--panel2); color: var(--text); box-shadow: inset 0 -3px 0 var(--blue); }

/* ---------- Page Séance ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.next-day { background: var(--panel); border-radius: 16px; padding: 16px; }
.next-day h1 { margin-bottom: 4px; }
.ex-list { list-style: none; margin: 12px 0 16px; padding: 0; columns: 1; }
.ex-list li { padding: 6px 0; border-top: 1px solid var(--line); }
.ex-list li:first-child { border-top: 0; }
.cycle-strip { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 12px; scrollbar-width: none; }
.cycle-strip .day { flex: none; min-width: 88px; padding: 8px 12px; border-radius: 12px; background: var(--panel); border: 1.5px solid transparent; text-align: center; }
.cycle-strip .day b { display: block; font-family: var(--display); font-size: 20px; font-weight: 800; }
.cycle-strip .day.now { border-color: var(--blue); }
.cycle-strip .day.past { opacity: .6; }

.session-head { position: sticky; top: 0; z-index: 10; background: var(--ink); margin: 0 -16px 8px; padding: calc(8px + var(--safe-t)) 16px 8px; border-bottom: 1px solid var(--line); }
.session-head .name { font-family: var(--display); font-weight: 800; font-size: 28px; background: transparent; border: 0; padding: 0; min-height: 36px; width: 100%; border-radius: 6px; }
.session-head .gym { background: transparent; border: 0; padding: 0; min-height: 28px; font-size: 15px; color: var(--muted); width: 100%; }

.ex { background: var(--panel); border-radius: 16px; padding: 12px 12px 14px; margin-top: 16px; }
.ex.superset { border-left: 5px solid var(--yellow); }
.ex-head { display: flex; align-items: flex-start; gap: 8px; }
.ex-head h2 { flex: 1; font-size: 26px; }
.icon-btn { flex: none; width: 44px; height: 44px; border-radius: 12px; background: transparent; border: 0; color: var(--muted); display: grid; place-items: center; }
.icon-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.ex-meta { font-size: 14px; color: var(--muted); margin: 2px 0 8px; }
.note-btn { display: block; width: 100%; text-align: left; background: var(--ink); border: 1.5px dashed var(--line); border-radius: 10px; padding: 8px 12px; min-height: 40px; color: var(--muted); font-size: 15px; margin-bottom: 8px; }
.note-btn.has { color: var(--text); border-style: solid; }
.note-input { margin-bottom: 8px; }

.set { display: grid; grid-template-columns: 44px 1fr 1fr 80px 46px; gap: 6px; align-items: start; padding: 8px 0; border-top: 1px solid var(--line); }
.set:first-of-type { border-top: 0; }
.plate {
  --c: var(--blue); --fg: #fff;
  position: relative; width: 44px; height: 44px; border-radius: 50%; border: 0; padding: 0;
  font-family: var(--display); font-weight: 800; font-size: 24px; color: var(--fg);
  background: radial-gradient(circle, var(--c) 0 58%, rgba(0,0,0,.28) 59% 63%, var(--c) 64% 100%);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.14);
  display: grid; place-items: center;
}
[data-type="warmup"] .plate { --c: var(--white); --fg: #1b2232; }
[data-type="failure"] .plate { --c: var(--red); }
[data-type="drop"] .plate { --c: var(--yellow); --fg: #1b2232; }
.plate .side { position: absolute; right: -4px; bottom: -4px; width: 20px; height: 20px; border-radius: 50%; background: var(--ink); color: var(--text); font-family: var(--body); font-size: 12px; font-weight: 700; display: grid; place-items: center; border: 1.5px solid var(--line); }
.cell { display: block; min-width: 0; }
.cell input { min-width: 0; text-align: center; font-family: var(--display); font-weight: 700; font-size: 26px; padding: 4px 4px; min-height: 48px; }
.cell small { display: block; text-align: center; font-size: 11.5px; color: var(--muted); margin-top: 2px; white-space: nowrap; }
.chip { min-height: 48px; border-radius: 10px; border: 1.5px solid var(--line); background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.15; font-size: 13px; padding: 0 4px; }
.chip b { font-size: 13px; }
.chip span { color: var(--muted); }
.chip.has-rpe span { color: var(--text); }
.check { width: 46px; height: 48px; border-radius: 12px; border: 2px solid var(--line); background: transparent; display: grid; place-items: center; color: var(--muted); }
.check svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.set[data-done="1"] .check { background: var(--ok); border-color: var(--ok); color: #0c2a1a; }
.set[data-done="1"] .cell input { background: var(--panel2); }
.set[data-skipped="1"] { grid-template-columns: 44px 1fr 46px; align-items: center; }
.set[data-skipped="1"] .skipped-label { color: var(--muted); font-size: 15px; }
.ex-actions { display: flex; gap: 8px; margin-top: 8px; }

.finish { margin-top: 24px; }

/* ---------- Minuteur ---------- */
#timerbar {
  position: fixed; left: 0; right: 0; bottom: calc(var(--tabs-h) + var(--safe-b)); z-index: 19;
  height: var(--timer-h); background: var(--panel2); border-top: 1px solid var(--line);
  display: none; align-items: center; gap: 12px; padding: 0 12px;
}
body.has-timer #timerbar { display: flex; }
.disc { --p: 100; --c: var(--blue); flex: none; width: 54px; height: 54px; border-radius: 50%; background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--line) 0); display: grid; place-items: center; }
.disc::after { content: ""; width: 34px; height: 34px; border-radius: 50%; background: var(--panel2); box-shadow: inset 0 0 0 3px rgba(255,255,255,.06); }
#timerbar.done .disc { --c: var(--ok); }
.t-main { flex: 1; min-width: 0; }
.t-time { font-family: var(--display); font-weight: 800; font-size: 44px; line-height: 1; font-variant-numeric: tabular-nums; }
.t-label { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#timerbar { gap: 10px; }
#timerbar .btn { min-height: 44px; padding: 0 10px; flex: none; }

/* ---------- Bottom sheet ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(8, 11, 18, .62); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 640px; max-height: 88dvh; overflow: auto; background: var(--panel); border-radius: 20px 20px 0 0; padding: 12px 16px calc(20px + var(--safe-b)); animation: up .18s ease-out; }
.sheet .grab { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet h2 { margin-bottom: 12px; }
@keyframes up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.rpe-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.rpe-grid button { min-height: 48px; border-radius: 10px; border: 1.5px solid var(--line); background: transparent; font-family: var(--display); font-weight: 700; font-size: 22px; }
.rpe-grid button[aria-pressed="true"] { background: var(--blue); border-color: var(--blue); color: #fff; }
.type-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.type-grid button { min-height: 64px; border-radius: 12px; border: 1.5px solid var(--line); background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 13px; }
.type-grid button[aria-pressed="true"] { border-color: var(--text); background: var(--panel2); }
.type-grid .dot { width: 22px; height: 22px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 2px rgba(255,255,255,.18); }

.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; }
.list-btn { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 8px 4px; background: transparent; border: 0; text-align: left; }
.list-btn .t { flex: 1; min-width: 0; }
.list-btn .t b { display: block; }
.tag { display: inline-block; font-size: 13px; padding: 1px 8px; border-radius: 99px; border: 1.5px solid var(--line); color: var(--muted); }
.tag.now { border-color: var(--blue); color: var(--text); }

.panel { background: var(--panel); border-radius: 16px; padding: 14px 16px; }
.panel h3 { margin-bottom: 8px; }
.day-card { background: var(--panel); border-radius: 16px; padding: 12px; margin-top: 12px; }
.day-card .name-in { font-family: var(--display); font-weight: 800; font-size: 26px; background: transparent; border: 0; min-height: 40px; padding: 0 4px; }
.mini { display: flex; align-items: center; gap: 4px; padding: 2px 0; border-top: 1px solid var(--line); }
.mini .t { flex: 1; min-width: 0; padding: 8px 4px; }
.mini .icon-btn { width: 40px; height: 40px; }
.badge-ss { font-size: 12px; color: var(--yellow); border: 1.5px solid var(--yellow); border-radius: 99px; padding: 0 8px; }

.warm-row { display: grid; grid-template-columns: 1fr 1fr 44px; gap: 8px; align-items: end; margin-top: 8px; }
.kv { display: grid; grid-template-columns: 1fr 110px; gap: 8px; align-items: center; margin-top: 8px; }
.kv input { text-align: center; }

.hist-item { display: block; width: 100%; text-align: left; background: var(--panel); border: 0; border-radius: 14px; padding: 12px 14px; margin-top: 10px; }
.hist-item b.d { font-family: var(--display); font-size: 22px; font-weight: 800; display: block; }
.stats { display: flex; gap: 16px; flex-wrap: wrap; font-size: 15px; color: var(--muted); }
.stats b { color: var(--text); }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty h2 { color: var(--text); margin-bottom: 8px; }

#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabs-h) + var(--safe-b) + 16px); z-index: 60; background: var(--text); color: var(--ink); padding: 10px 16px; border-radius: 12px; font-weight: 700; max-width: 90vw; display: none; }
body.has-timer #toast { bottom: calc(var(--tabs-h) + var(--timer-h) + var(--safe-b) + 16px); }
#toast.show { display: block; }

/* ---------- v1.1 : progression, records, rappel, stats, suivi ---------- */
.set { position: relative; }
.pr-tag { position: absolute; top: -7px; right: 56px; z-index: 1; font-family: var(--display); font-weight: 800; font-size: 13px; letter-spacing: .04em; background: var(--yellow); color: var(--ink); border-radius: 6px; padding: 0 6px; line-height: 18px; }
.pr-tag.inline { position: static; display: inline-block; vertical-align: middle; }
.prog { margin: 6px 0 4px; border-radius: 12px; }
.prog.raise { display: flex; align-items: center; gap: 10px; justify-content: space-between; padding: 10px 12px; background: var(--panel2); border: 1.5px solid var(--blue); font-size: 15px; }
.prog.raise .btn { flex: none; }
.prog.hold { color: var(--muted); padding: 0 2px; }
.banner { background: var(--panel2); border: 1.5px solid var(--yellow); border-radius: 14px; padding: 12px 14px; margin-bottom: 14px; display: flex; flex-direction: column; gap: 10px; font-size: 15px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--text); font: inherit; font-weight: 700; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 4px; text-align: left; }
.good { color: var(--ok); }
.warn { color: var(--yellow); margin-top: 12px; }
.compare h3 { margin-bottom: 6px; }
.cmp li { padding: 6px 0; display: block; }
.cmp .n { display: block; font-weight: 700; }
.vol { list-style: none; margin: 0 0 8px; padding: 0; }
.vol li { margin-top: 12px; }
.vl { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.bar { position: relative; height: 14px; border-radius: 7px; background: var(--panel); margin-top: 5px; overflow: hidden; }
.bar .zone { position: absolute; top: 0; bottom: 0; background: rgba(238,241,247,.12); }
.bar .fill { position: absolute; left: 0; top: 3px; bottom: 3px; border-radius: 4px; background: var(--blue); }
.seg.wrap { flex-wrap: wrap; }
.seg.wrap button { min-width: 30%; }
.datenav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.datenav .dl-main { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; font-family: var(--display); font-size: 24px; text-transform: capitalize; }
.datenav .icon-btn { font-size: 28px; width: 52px; height: 52px; }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.sec-head h3 { margin: 0; }
.li-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; }
.li-row .icon-btn { font-size: 24px; flex: none; }
.prog-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; margin-top: 10px; }
.prog-row .meter, .prog-row small { grid-column: 1 / -1; }
.meter { height: 8px; background: var(--ink); border-radius: 4px; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--blue); border-radius: 4px; }
table.trend, .chart-table table { width: 100%; border-collapse: collapse; font-size: 15px; }
table.trend th, table.trend td, .chart-table th, .chart-table td { padding: 6px 4px; border-top: 1px solid var(--line); text-align: right; }
table.trend th:first-child, .chart-table th:first-child, .chart-table td:first-child { text-align: left; font-weight: 400; }
table.trend thead th { border-top: 0; color: var(--muted); font-weight: 400; }
.chart-table { margin-top: 6px; }
.chart-table summary, details summary { cursor: pointer; color: var(--muted); font-size: 14px; min-height: 40px; display: flex; align-items: center; }
.chart { position: relative; margin-top: 10px; touch-action: pan-y; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; opacity: .7; }
.chart .ax { fill: var(--muted); font-size: 11px; font-family: var(--body); }
.chart .dl { fill: var(--text); font-size: 12px; font-family: var(--body); font-weight: 700; }
.chart .mk { stroke: var(--panel); stroke-width: 2; }
.chart .xh { stroke: var(--muted); stroke-width: 1; }
.chart .tip { position: absolute; top: 0; pointer-events: none; background: var(--text); color: var(--ink); border-radius: 8px; padding: 4px 8px; font-size: 13px; display: flex; flex-direction: column; white-space: nowrap; }
.chart .tip[hidden], .chart .xh[hidden] { display: none; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; font-size: 14px; color: var(--text); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chk { display: inline-flex; }
.chk input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chk span { border: 1.5px solid var(--line); border-radius: 99px; padding: 6px 12px; font-size: 14px; min-height: 36px; display: inline-flex; align-items: center; }
.chk input:checked + span { background: var(--panel2); border-color: var(--blue); color: var(--text); }
.chk input:focus-visible + span { outline: 3px solid var(--blue); outline-offset: 2px; }
.food { display: inline-flex; border: 1.5px solid var(--line); border-radius: 99px; overflow: hidden; }
.chip-btn { background: none; border: 0; color: var(--text); padding: 6px 4px 6px 12px; min-height: 40px; font-size: 14px; }
.chip-btn small { color: var(--muted); }
.chip-x { background: none; border: 0; color: var(--muted); padding: 0 12px 0 8px; font-size: 18px; }
pre.recipe { white-space: pre-wrap; font-family: var(--body); font-size: 14px; background: var(--ink); border-radius: 10px; padding: 10px; color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
@media (min-width: 700px) { body { font-size: 18px; } }

/* lecteur de code-barres */
.scan { position: fixed; inset: 0; z-index: 70; background: #000; display: flex; flex-direction: column; }
.scan video { flex: 1; min-height: 0; width: 100%; object-fit: cover; }
.scan-frame { position: absolute; left: 8%; right: 8%; top: 28%; height: 22vh; border: 3px solid var(--yellow); border-radius: 14px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.45); pointer-events: none; }
.scan-bar { padding: 12px 16px calc(12px + var(--safe-b)); background: var(--ink); display: grid; gap: 10px; }
.scan-msg { margin: 0; font-weight: 700; }
