:root {
  --bg: #0f1114;
  --panel: #171a1f;
  --panel-2: #1e2229;
  --line: #2a2f38;
  --text: #e9ecf1;
  --muted: #8b93a1;
  --accent: #c8f169;
  --accent-ink: #14180c;
  --run: #6cc7ff;
  --food: #ffb867;
  --danger: #ff6b6b;
  --ok: #7ee2a8;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
a { color: inherit; }
h1 { font-size: 1.45rem; margin: .2rem 0 1rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 1.6rem 0 .6rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
h3 { font-size: 1rem; margin: 0; }
.wrap { max-width: 860px; margin: 0 auto; padding: 18px 16px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num { font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.right { text-align: right; }
.stack > * + * { margin-top: 10px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }

/* barre de navigation */
.topbar { display: none; }
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(15,17,20,.94); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabs a { text-decoration: none; text-align: center; padding: 9px 0 8px; font-size: .72rem; color: var(--muted); }
.tabs a svg { display: block; margin: 0 auto 3px; width: 22px; height: 22px; }
.tabs a.on { color: var(--accent); }
@media (min-width: 900px) {
  body { padding-bottom: 0; }
  .tabs { position: sticky; top: 0; bottom: auto; border-top: 0; border-bottom: 1px solid var(--line);
          grid-template-columns: repeat(5, auto); justify-content: center; gap: 28px; }
  .tabs a { display: flex; align-items: center; gap: 7px; font-size: .9rem; padding: 14px 4px; }
  .tabs a svg { margin: 0; width: 18px; height: 18px; }
}

/* cartes */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.card + .card { margin-top: 10px; }
.card.link { display: block; text-decoration: none; }
.card.link:hover { border-color: #3a414d; }
.grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat .v { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--muted); font-size: .8rem; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--line); font-size: .78rem; color: var(--muted); }
.pill.accent { color: var(--accent); border-color: #4a5a24; }
.pill.run { color: var(--run); border-color: #24485e; }
.pill.food { color: var(--food); border-color: #5e4424; }
.list { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list > * { display: flex; align-items: center; gap: 10px; padding: 12px 14px; text-decoration: none; }
.list > * + * { border-top: 1px solid var(--line); }
.list > a:hover { background: var(--panel-2); }
.empty { padding: 26px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }

/* formulaires */
label { display: block; font-size: .8rem; color: var(--muted); margin-bottom: 4px; }
input, select, textarea {
  width: 100%; background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 11px; font: inherit; font-size: 16px; /* évite le zoom iOS */
}
input:focus, select:focus, textarea:focus { outline: 2px solid #4a5a24; border-color: #4a5a24; }
textarea { min-height: 70px; resize: vertical; }
.fields { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: #3d4450; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 6px 10px; font-size: .85rem; border-radius: 8px; }
.btn.icon { padding: 8px 10px; }
details > summary { cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details.fold > summary { color: var(--muted); font-size: .9rem; padding: 6px 0; }
details.fold > summary::before { content: "▸ "; }
details.fold[open] > summary::before { content: "▾ "; }

/* muscu */
.exo { scroll-margin-top: 70px; }
.exo .head { display: flex; gap: 8px; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
.prev { font-size: .82rem; color: var(--muted); margin-bottom: 8px; }
.prev b { color: var(--text); font-weight: 600; }
.set { display: grid; grid-template-columns: 28px 1fr 1fr auto auto; gap: 8px; align-items: center; margin-bottom: 6px; }
.set .idx { color: var(--muted); font-size: .85rem; text-align: center; }
.set input { padding: 8px 9px; text-align: center; }
.set.todo input { border-style: dashed; color: var(--muted); }
.set.done .check { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.unit { position: relative; }
.unit span { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); font-size: .75rem; color: var(--muted); pointer-events: none; }
.unit input { padding: 8px 34px 8px 9px; text-align: center; }
.addset { display: grid; grid-template-columns: 28px 1fr 1fr auto; gap: 8px; align-items: center; }

/* nutrition */
.bar { height: 10px; background: var(--panel-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.bar > i { display: block; height: 100%; background: var(--food); border-radius: 99px; }
.bar.done > i { background: var(--ok); }
.macros { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; }
.macros .v { font-weight: 700; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.macros .l { font-size: .75rem; color: var(--muted); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; font-variant-numeric: tabular-nums; }
th { font-size: .75rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
td.n, th.n { text-align: right; }
.table-wrap { overflow-x: auto; }
.search-results { margin-top: 6px; max-height: 320px; overflow-y: auto; }
.search-results button { width: 100%; text-align: left; background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 9px 11px; margin-bottom: 5px; font: inherit; cursor: pointer; }
.search-results button:hover { border-color: var(--food); }
.search-results .meta { font-size: .78rem; color: var(--muted); }
.picked { border: 1px solid #5e4424; background: #211a12; border-radius: 10px; padding: 9px 11px; }
.flash { background: #17261d; border: 1px solid #2f5a3f; color: var(--ok); padding: 10px 12px; border-radius: 10px; margin-bottom: 12px; }
.chart-box { position: relative; height: 220px; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; text-align: center; }
.week .d { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 2px; font-size: .72rem; color: var(--muted); }
.week .d.today { border-color: #4a5a24; }
.week .dots { margin-top: 5px; height: 16px; display: flex; justify-content: center; gap: 4px; align-items: center; }
.week .dot { width: 9px; height: 9px; border-radius: 50%; }
.dot.m { background: var(--accent); }
.dot.r { background: var(--run); }
video#scan { width: 100%; border-radius: 10px; background: #000; margin-top: 8px; }

/* programme */
.today-card { border-color: #4a5a24; background: linear-gradient(180deg, #1b2113, var(--panel) 60%); }
.vol-row { display: grid; grid-template-columns: 120px 1fr 28px; gap: 10px; align-items: center; margin-bottom: 7px; font-size: .9rem; }
.vol-row .bar { height: 8px; }
.prog-items { margin-top: 10px; }
.prog-item { border-top: 1px solid var(--line); }
.prog-item > summary { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; }
.prog-item > summary .idx { color: var(--muted); width: 18px; flex: none; font-size: .85rem; padding-top: 1px; }
.prog-item > summary .right { display: flex; flex-direction: column; align-items: flex-end; flex: none; }
.prog-item .tip { display: block; color: var(--muted); font-size: .8rem; margin-top: 2px; }
.principles p { margin: 0 0 8px; font-size: .9rem; }
.target { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; }
.sug { font-size: .82rem; padding: 7px 10px; border-radius: 9px; background: var(--panel-2); border: 1px solid var(--line); margin-bottom: 8px; }
.sug.up { border-color: #4a5a24; color: var(--accent); }
.tipline { font-size: .8rem; color: var(--muted); margin: -2px 0 8px; }

/* minuteur de repos */
.timer { position: fixed; left: 12px; right: 12px; bottom: calc(68px + env(safe-area-inset-bottom)); z-index: 30;
  display: flex; align-items: center; gap: 10px; background: #1b2113; border: 1px solid #4a5a24; border-radius: 14px;
  padding: 10px 12px; box-shadow: 0 8px 30px rgba(0,0,0,.5); max-width: 520px; margin: 0 auto; }
.timer .t { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--accent); min-width: 64px; }
.timer.over { background: #2a1d10; border-color: var(--food); }
.timer.over .t { color: var(--food); }
@media (min-width: 900px) { .timer { bottom: 20px; } }

/* photos d'exercices */
.demo { position: relative; aspect-ratio: 3 / 2; border-radius: 12px; overflow: hidden; background: #000; margin: 6px 0 6px; max-width: 520px; }
.demo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.demo.anim img:nth-child(2) { animation: demo-swap 2.6s ease-in-out infinite; }
@keyframes demo-swap { 0%, 38% { opacity: 0; } 50%, 88% { opacity: 1; } 100% { opacity: 0; } }
.demo-tag { position: absolute; left: 8px; bottom: 8px; font-size: .7rem; background: rgba(0,0,0,.6); color: #fff; padding: 2px 7px; border-radius: 99px; }
.video-link { color: var(--muted); text-decoration: none; display: inline-block; margin-bottom: 4px; }
.video-link:hover { color: var(--text); }
.thumb { width: 46px; height: 46px; border-radius: 10px; object-fit: cover; flex: none; background: var(--panel-2); border: 1px solid var(--line); }
.thumb.empty { display: inline-block; }
.demo-fold { margin: -2px 0 6px; }
.demo-fold > summary { padding: 2px 0 6px; }
.prog-item > summary .thumb { width: 38px; height: 38px; border-radius: 8px; }
.img-results { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-top: 8px; }
.img-results button { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 0; overflow: hidden; cursor: pointer; color: var(--text); text-align: left; font: inherit; }
.img-results button:hover { border-color: var(--accent); }
.img-results img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; display: block; background: #000; }
.img-results span { display: block; padding: 6px 8px; font-size: .78rem; }
@media (prefers-reduced-motion: reduce) { .demo.anim img:nth-child(2) { animation: none; } }
