:root {
  --bg: #0e0f11;
  --surface: #17191c;
  --surface-2: #202328;
  --line: #2b2f35;
  --text: #f3f4f6;
  --muted: #9aa0a8;
  --faint: #6b7178;
  --accent: #ff7a1a;
  --accent-ink: #1a0d02;
  --accent-soft: rgba(255, 122, 26, .14);
  --good: #3ddc84;
  --bad: #ff5a5f;
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tabs-h: 64px;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
  overscroll-behavior-y: none;
  min-height: 100dvh;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

#app {
  padding: calc(var(--safe-top) + 12px) 16px calc(var(--tabs-h) + var(--safe-bottom) + 24px);
  max-width: 560px;
  margin: 0 auto;
}
body.no-tabs #app { padding-bottom: calc(var(--safe-bottom) + 24px); }

/* ---------- en-têtes */
.top { display: flex; align-items: center; gap: 12px; min-height: 44px; margin-bottom: 8px; }
.top h1 { font-size: 28px; line-height: 1.1; margin: 0; letter-spacing: -.02em; flex: 1; }
.top .sub { color: var(--muted); font-size: 14px; }
.back { background: none; border: 0; color: var(--accent); padding: 8px 4px; font-size: 17px; display: flex; align-items: center; gap: 2px; margin-left: -4px; }
.back svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2.4; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; margin: 28px 4px 10px; }

/* ---------- blocs */
.card { background: var(--surface); border-radius: var(--radius); padding: 16px; }
.card + .card { margin-top: 10px; }
.list { background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 0; background: none; width: 100%; text-align: left; }
.row + .row { border-top: 1px solid var(--line); }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .meta { color: var(--muted); font-size: 14px; }
.row .value { font-weight: 700; font-variant-numeric: tabular-nums; }
.chev { width: 16px; height: 16px; stroke: var(--faint); fill: none; stroke-width: 2.4; flex: none; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--surface); border-radius: var(--radius); padding: 14px 12px; }
.stat b { display: block; font-size: 28px; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat span { color: var(--muted); font-size: 13px; }
.stat.hl b { color: var(--accent); }

/* ---------- boutons */
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 52px; border-radius: 14px; border: 0; background: var(--surface-2); font-weight: 600; font-size: 17px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: none; color: var(--accent); }
.btn.danger { background: none; color: var(--bad); }
.btn:disabled { opacity: .5; }
.btn:active, .row:active, .tab:active { transform: scale(.98); }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }
.chip { border: 0; background: var(--surface-2); color: var(--muted); border-radius: 999px; padding: 8px 14px; font-size: 14px; font-weight: 600; white-space: nowrap; }
.chip.on { background: var(--accent-soft); color: var(--accent); }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px 2px; }
.chips::-webkit-scrollbar { display: none; }

/* ---------- formulaires */
.field { display: block; margin-bottom: 14px; }
.field span { display: block; color: var(--muted); font-size: 14px; margin: 0 4px 6px; }
.input { width: 100%; min-height: 50px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-size: 16px; outline: none; }
.input:focus { border-color: var(--accent); }
textarea.input { min-height: 80px; resize: vertical; }
.error { color: var(--bad); font-size: 14px; margin: 0 4px 12px; }
.hint { color: var(--muted); font-size: 14px; margin: 8px 4px; }

/* ---------- connexion */
.auth { min-height: calc(100dvh - var(--safe-top) - 60px); display: flex; flex-direction: column; justify-content: center; }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.brand img { width: 56px; height: 56px; border-radius: 14px; }
.brand b { font-size: 30px; letter-spacing: -.02em; }
.brand div span { display: block; color: var(--muted); font-size: 15px; }

/* ---------- séance en cours */
.log-top { position: sticky; top: 0; z-index: 5; background: var(--bg); margin: calc(-12px - var(--safe-top)) -16px 8px; padding: calc(var(--safe-top) + 8px) 16px 10px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.log-top .grow { flex: 1; }
.log-top .clock { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.log-top input[type=date] { background: none; border: 0; color: var(--muted); font-size: 14px; padding: 0; min-height: 0; }
.link { background: none; border: 0; color: var(--accent); font-weight: 600; font-size: 16px; padding: 8px 4px; }
.link.muted { color: var(--muted); }

.ex { background: var(--surface); border-radius: var(--radius); padding: 14px 12px 8px; margin-bottom: 12px; }
.ex-head { display: flex; align-items: flex-start; gap: 8px; padding: 0 4px; }
.ex-head .grow { flex: 1; }
.ex-head b { font-size: 17px; }
.ex-last { color: var(--muted); font-size: 13px; margin-top: 2px; }
.icon-btn { border: 0; background: none; color: var(--faint); width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.icon-btn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; }
.sets { width: 100%; border-collapse: collapse; margin-top: 8px; }
.sets th { color: var(--faint); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; padding: 4px; text-align: center; }
.sets td { padding: 4px; text-align: center; }
.sets td:first-child { color: var(--muted); width: 36px; font-variant-numeric: tabular-nums; }
.sets td:last-child { width: 40px; }
.sets input { width: 100%; min-height: 44px; text-align: center; border-radius: 10px; border: 1px solid transparent; background: var(--surface-2); font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; outline: none; }
.sets input:focus { border-color: var(--accent); }
.sets .pr-tag { color: var(--accent); font-size: 11px; font-weight: 700; }
.add-set { width: 100%; margin-top: 4px; border: 0; background: none; color: var(--accent); font-weight: 600; padding: 12px; font-size: 15px; }

/* ---------- graphique */
.chart { width: 100%; height: 190px; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--faint); font-size: 11px; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: url(#fade); }
.chart .dot { fill: var(--bg); stroke: var(--accent); stroke-width: 2; }
.chart .dot.last { fill: var(--accent); }
.big-num { font-size: 40px; font-weight: 800; letter-spacing: -.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.big-num small { font-size: 18px; color: var(--muted); font-weight: 600; margin-left: 4px; }
.delta { font-size: 14px; font-weight: 600; margin-top: 6px; }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }
.delta.flat { color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- groupe */
.bar-row { display: grid; grid-template-columns: 90px 1fr 70px; align-items: center; gap: 10px; padding: 8px 0; }
.bar-row .who { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .track { height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar-row .fill { height: 100%; border-radius: 99px; background: var(--faint); }
.bar-row.me .fill { background: var(--accent); }
.bar-row .v { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-weight: 700; color: var(--accent); flex: none; }
.rank { width: 22px; color: var(--faint); font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }

/* ---------- fil / séances */
.w-sum { color: var(--muted); font-size: 14px; margin-top: 2px; }
.w-sets { margin-top: 10px; display: grid; gap: 4px; font-size: 14px; }
.w-sets div { display: flex; justify-content: space-between; gap: 12px; }
.w-sets span:last-child { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.empty { text-align: center; color: var(--muted); padding: 28px 16px; }
.empty b { display: block; color: var(--text); font-size: 17px; margin-bottom: 4px; }

/* ---------- barre d'onglets */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: space-around; align-items: center; height: calc(var(--tabs-h) + var(--safe-bottom)); padding: 0 8px var(--safe-bottom); background: rgba(14, 15, 17, .86); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); border-top: 1px solid var(--line); }
.tab { border: 0; background: none; color: var(--faint); display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; font-weight: 600; padding: 6px 10px; min-width: 60px; }
.tab svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.tab.on { color: var(--text); }
.tab-main { width: 52px; height: 52px; min-width: 0; border-radius: 16px; background: var(--accent); color: var(--accent-ink); padding: 0; justify-content: center; }
.tab-main svg { stroke-width: 2.6; }
.tab-main.live { background: var(--good); }

/* ---------- feuilles (sélecteur d'exercice, confirmations) */
.backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .55); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease-out; }
.sheet { width: 100%; max-width: 560px; background: var(--surface); border-radius: 20px 20px 0 0; padding: 10px 16px calc(var(--safe-bottom) + 16px); max-height: 88dvh; display: flex; flex-direction: column; animation: up .22s cubic-bezier(.2, .8, .2, 1); }
.sheet .grab { width: 40px; height: 5px; border-radius: 9px; background: var(--line); margin: 0 auto 12px; flex: none; }
.sheet h3 { margin: 0 0 6px; font-size: 20px; }
.sheet p { color: var(--muted); margin: 0 0 18px; }
.sheet .scroll { overflow-y: auto; margin: 0 -16px; padding: 0 16px; -webkit-overflow-scrolling: touch; }
.sheet .list { background: var(--surface-2); }
.sheet .cat { color: var(--muted); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; margin: 18px 4px 8px; }
.sheet .btn + .btn { margin-top: 8px; }
.toast { position: fixed; left: 50%; bottom: calc(var(--tabs-h) + var(--safe-bottom) + 16px); transform: translateX(-50%); z-index: 60; background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 600; font-size: 15px; max-width: calc(100% - 32px); animation: up .2s ease-out; }
.pr-card { background: linear-gradient(135deg, var(--accent-soft), transparent); border: 1px solid rgba(255, 122, 26, .35); }
.pr-card b { color: var(--accent); }
.spinner { width: 28px; height: 28px; margin: 60px auto; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }

@keyframes up { from { transform: translateY(24px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; } }
@media (hover: hover) { .row:hover { background: var(--surface-2); } }

/* ---------- v2 : titres */
.title-lg { font-size: 28px; line-height: 1.15; margin: 0 0 4px; letter-spacing: -.02em; }
p.sub { color: var(--muted); font-size: 15px; margin: 0 0 8px; }
.meta { color: var(--muted); font-size: 14px; }
.h2-row { display: flex; align-items: baseline; justify-content: space-between; }
.h2-row .link { font-size: 15px; }
.pill { flex: none; font-size: 12px; font-weight: 700; padding: 5px 10px; border-radius: 99px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill.live { background: var(--accent-soft); color: var(--accent); }
.back svg, .icon-btn svg, .tool svg, .ex-note svg, .ch-icon svg, .check svg, .chev { stroke-linecap: round; stroke-linejoin: round; }

/* ---------- v2 : séance */
.progress-line { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: 4px; }
.progress-line div { height: 100%; background: var(--good); border-radius: 99px; transition: width .3s; }
.log-top .icon-btn { color: var(--muted); }
.ex-note { display: flex; align-items: flex-start; gap: 6px; margin-top: 8px; padding: 0; border: 0; background: none; color: var(--faint); font-size: 13px; text-align: left; }
.ex-note svg { width: 15px; height: 15px; flex: none; margin-top: 1px; stroke: currentColor; fill: none; stroke-width: 2; }
.ex-note.has { color: #ffc38f; }
.ex-note.card { padding: 12px 14px; font-size: 14px; color: var(--muted); }
.ex-note.card.has { color: #ffc38f; }
.set-num { border: 0; background: none; color: var(--muted); font-weight: 600; font-size: 15px; width: 32px; height: 32px; border-radius: 8px; font-variant-numeric: tabular-nums; }
.sets td:last-child { width: 52px; }
.check { width: 44px; height: 44px; border-radius: 12px; border: 0; background: var(--surface-2); color: var(--faint); display: grid; place-items: center; }
.check svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2.6; }
.check.on { background: var(--good); color: #062612; }
.sets tr.done input { background: rgba(61, 220, 132, .1); color: var(--good); }

/* ---------- v2 : minuteur de repos */
.rest-bar { position: fixed; left: 8px; right: 8px; z-index: 30; bottom: calc(var(--tabs-h) + var(--safe-bottom) + 8px); max-width: 544px; margin: 0 auto; background: #1d2a22; border: 1px solid rgba(61, 220, 132, .35); border-radius: 18px; overflow: hidden; box-shadow: 0 10px 30px rgba(0, 0, 0, .45); animation: up .2s ease-out; }
body.no-tabs .rest-bar { bottom: calc(var(--safe-bottom) + 8px); }
.rest-track { height: 4px; background: rgba(255, 255, 255, .06); }
.rest-track div { height: 100%; background: var(--good); transition: width .25s linear; }
.rest-row { display: flex; align-items: center; gap: 8px; padding: 10px 10px 10px 16px; }
.rest-row .grow { flex: 1; }
.rest-label { font-size: 12px; color: var(--good); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.rest-time { font-size: 26px; font-weight: 800; line-height: 1.1; }
.rest-btn { border: 0; border-radius: 12px; background: rgba(255, 255, 255, .08); min-width: 50px; height: 44px; padding: 0 12px; font-weight: 700; font-size: 15px; }
.rest-btn.main { background: var(--good); color: #062612; }
.rest-bar.over { background: #1f3b2a; animation: pulse .8s ease-in-out 3; }
body.resting #app { padding-bottom: calc(var(--tabs-h) + var(--safe-bottom) + 110px); }
body.resting.no-tabs #app { padding-bottom: calc(var(--safe-bottom) + 110px); }
@keyframes pulse { 50% { transform: scale(1.02); } }

/* ---------- v2 : accueil / fil */
.cheer { border: 0; background: var(--surface-2); color: var(--muted); border-radius: 99px; height: 38px; min-width: 56px; padding: 0 12px; font-size: 15px; font-weight: 700; flex: none; }
.cheer.on { background: var(--accent-soft); color: var(--accent); }
.cheer-count { color: var(--muted); font-size: 14px; font-weight: 600; flex: none; }

/* ---------- v2 : régularité */
.heat { display: grid; grid-template-rows: repeat(7, 1fr); grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; }
.heat i { aspect-ratio: 1; border-radius: 3px; background: var(--surface-2); }
.heat i.on { background: var(--accent); }
.heat i.future { background: transparent; }

/* ---------- v2 : défis */
.ch-card { display: block; width: 100%; text-align: left; border: 0; color: inherit; }
.ch-head { display: flex; align-items: flex-start; gap: 12px; }
.ch-head .grow { flex: 1; min-width: 0; }
.ch-icon { width: 38px; height: 38px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; }
.ch-icon svg { width: 21px; height: 21px; stroke: currentColor; fill: none; stroke-width: 2; }
.ch-top { margin-top: 12px; display: grid; gap: 6px; }
.ch-top div { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.ch-top .grow { flex: 1; }
.ch-top .me b, .ch-top .me .grow { color: var(--accent); }
.me-row { background: var(--accent-soft); }
.radio { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--faint); flex: none; }
.radio.on { border: 7px solid var(--accent); }
.date-inline { background: none; border: 0; color: var(--accent); font-size: 16px; font-weight: 600; text-align: right; }

/* ---------- v2 : plus / outils */
.tools { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tool { border: 0; background: var(--surface); border-radius: var(--radius); padding: 16px 14px; text-align: left; display: flex; flex-direction: column; gap: 2px; }
.tool svg { width: 26px; height: 26px; stroke: var(--accent); fill: none; stroke-width: 1.9; margin-bottom: 8px; }
.tool b { font-size: 16px; }
.tool span { color: var(--muted); font-size: 13px; }
.switch { appearance: none; -webkit-appearance: none; width: 51px; height: 31px; border-radius: 99px; background: var(--surface-2); position: relative; flex: none; margin: 0; cursor: pointer; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 2px 4px rgba(0, 0, 0, .3); }
.switch:checked { background: var(--good); }
.switch:checked::after { transform: translateX(20px); }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface); border-radius: 12px; padding: 3px; margin: 12px 0; }
.seg button { border: 0; background: none; border-radius: 10px; padding: 10px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--surface-2); color: var(--text); }
.dial { text-align: center; padding: 34px 0 26px; }
.dial-time { font-size: 76px; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.big-input { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.barbell { display: flex; align-items: center; gap: 3px; overflow-x: auto; padding: 4px 0; }
.barbell .sleeve { width: 34px; height: 12px; background: #8b9098; border-radius: 3px; flex: none; }
.barbell .sleeve.end { width: 16px; }
.plate { flex: none; width: 30px; display: grid; place-items: center; border-radius: 5px; font-size: 11px; font-weight: 800; color: #fff; writing-mode: vertical-rl; transform: rotate(180deg); }
.p25 { height: 120px; background: #d6333b; }
.p20 { height: 112px; background: #2f6fd6; }
.p15 { height: 100px; background: #e3b21c; color: #221a00; }
.p10 { height: 86px; background: #2f9a4f; }
.p5 { height: 70px; background: #eceff3; color: #1a1a1a; }
.p2_5 { height: 56px; background: #b8323a; width: 24px; }
.p1_25 { height: 46px; background: #9aa0a8; width: 22px; color: #111; }
.chart { height: auto; }
