:root {
  --accent: #B5326E;
  --accent-strong: #962558;
  --accent-soft: #F7E3EC;
  --on-accent: #ffffff;
  --bg: #FBF7F9;
  --surface: #ffffff;
  --surface-2: #F3ECF0;
  --text: #2A1F25;
  --muted: #6B5B64;
  --border: #E6DAE0;
  --ok: #1F7A4D;
  --ok-soft: #DDF2E6;
  --warn: #9A5B00;
  --warn-soft: #FFF0D6;
  --danger: #A8242B;
  --danger-soft: #FBE1E2;
  --prop: #A99AA2;
  --protein: #2E6DB4;
  --radius: 18px;
  --tabbar-h: 68px;
  --shadow: 0 2px 10px rgba(60, 20, 40, .07);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent: #E06AA1;
    --accent-strong: #F08BBA;
    --accent-soft: #3D2232;
    --on-accent: #1A0F15;
    --bg: #141016;
    --surface: #211B23;
    --surface-2: #2C242F;
    --text: #F4EDF1;
    --muted: #BBAAB4;
    --border: #3A3040;
    --ok: #6DD39C;
    --ok-soft: #1D3328;
    --warn: #F2B45B;
    --warn-soft: #3A2C17;
    --danger: #FF8A8F;
    --danger-soft: #3D1E21;
    --prop: #7C6E76;
    --protein: #7FB2EE;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --accent: #E06AA1;
  --accent-strong: #F08BBA;
  --accent-soft: #3D2232;
  --on-accent: #1A0F15;
  --bg: #141016;
  --surface: #211B23;
  --surface-2: #2C242F;
  --text: #F4EDF1;
  --muted: #BBAAB4;
  --border: #3A3040;
  --ok: #6DD39C;
  --ok-soft: #1D3328;
  --warn: #F2B45B;
  --warn-soft: #3A2C17;
  --danger: #FF8A8F;
  --danger-soft: #3D1E21;
  --prop: #7C6E76;
  --protein: #7FB2EE;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 18px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px);
}
h1, h2, h3 { line-height: 1.2; margin: 0; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.08rem; }
p { margin: .4em 0; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.center { text-align: center; }
[hidden] { display: none !important; }

/* ---------- Barre du haut ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 1.3rem; flex: 1; }
.icon-btn {
  min-width: 44px; min-height: 44px; border: 0; border-radius: 12px;
  background: transparent; font-size: 1.5rem; cursor: pointer; color: var(--text);
}
.back-btn { font-size: 2rem; line-height: 1; margin-left: -8px; color: var(--accent); }

main { padding: 16px; max-width: 640px; margin: 0 auto; outline: none; }

/* ---------- Barre d'onglets ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  text-decoration: none; color: var(--muted); font-size: .74rem; font-weight: 600;
}
.tabbar svg { width: 27px; height: 27px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a.active { color: var(--accent); }
.tabbar a.active svg { stroke-width: 2.4; }

/* ---------- Cartes ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.card-head a { font-weight: 600; text-decoration: none; white-space: nowrap; }
.section-title { margin: 22px 4px 10px; font-size: 1.1rem; }
.section-title:first-child { margin-top: 4px; }

.hello { margin: 4px 4px 14px; }
.hello h2 { font-size: 1.45rem; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 12px 20px; border-radius: 14px;
  border: 2px solid var(--accent); background: var(--accent); color: var(--on-accent);
  font-weight: 700; font-size: 1rem; cursor: pointer; text-decoration: none; text-align: center;
}
.btn:active { transform: scale(.98); }
.btn.secondary { background: transparent; color: var(--accent); }
.btn.ghost { background: var(--surface-2); border-color: var(--surface-2); color: var(--text); }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn.block { display: flex; width: 100%; }
.btn.small-btn { min-height: 44px; padding: 8px 14px; font-size: .92rem; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row > .btn { flex: 1 1 140px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.seg { display: flex; background: var(--surface-2); border-radius: 14px; padding: 4px; margin-bottom: 14px; }
.seg a, .seg button {
  flex: 1; text-align: center; padding: 11px 6px; border-radius: 11px; border: 0; background: transparent;
  text-decoration: none; color: var(--muted); font-weight: 700; font-size: .95rem; cursor: pointer;
}
.seg .on { background: var(--surface); color: var(--accent); box-shadow: var(--shadow); }

/* ---------- Formulaires ---------- */
label.field { display: block; margin-bottom: 14px; font-weight: 600; }
label.field > span { display: block; margin-bottom: 6px; }
input[type=text], input[type=number], input[type=date], input[type=time], input[type=search], select, textarea {
  width: 100%; min-height: 52px; padding: 12px 14px; border-radius: 12px;
  border: 2px solid var(--border); background: var(--surface); font-size: 1.05rem;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check {
  display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 4px; cursor: pointer; font-weight: 500;
}
.check input { width: 28px; height: 28px; accent-color: var(--accent); flex: none; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 44px; padding: 8px 14px; border-radius: 999px; border: 2px solid var(--border);
  background: var(--surface); font-weight: 600; cursor: pointer; font-size: .95rem;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.radio-list label {
  display: flex; gap: 12px; align-items: center; padding: 12px; border: 2px solid var(--border);
  border-radius: 14px; margin-bottom: 8px; cursor: pointer;
}
.radio-list input { width: 24px; height: 24px; accent-color: var(--accent); flex: none; }
.radio-list label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

/* Notes 0 à 10 */
.scale { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin: 6px 0 4px; }
.scale button {
  min-height: 48px; border-radius: 12px; border: 2px solid var(--border); background: var(--surface);
  font-weight: 700; font-size: 1.05rem; cursor: pointer;
}
.scale button.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.scale button.lvl-mid.on { background: var(--warn); border-color: var(--warn); color: #fff; }
.scale button.lvl-high.on { background: var(--danger); border-color: var(--danger); color: #fff; }

/* ---------- Progression ---------- */
.progress { margin: 10px 0; }
.progress-top { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; margin-bottom: 6px; }
.bar { height: 16px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .4s; }
.bar.protein > i { background: var(--protein); }
.bar.walk > i { background: var(--ok); }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat { background: var(--surface-2); border-radius: 14px; padding: 12px; }
.stat b { display: block; font-size: 1.35rem; }
.stat span { color: var(--muted); font-size: .86rem; }

/* ---------- Listes ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-bottom: 1px solid var(--border); }
.list > li:last-child { border-bottom: 0; }
.item {
  display: flex; align-items: center; gap: 12px; padding: 12px 2px; min-height: 60px;
  text-decoration: none; color: inherit; width: 100%; background: none; border: 0; text-align: left; cursor: pointer;
}
.item .grow { flex: 1; min-width: 0; }
.item .title { font-weight: 600; display: block; }
.item .sub { color: var(--muted); font-size: .88rem; display: block; }
.item .chev { color: var(--muted); font-size: 1.4rem; }
.item .thumb { width: 64px; height: 54px; flex: none; background: var(--surface-2); border-radius: 12px; padding: 3px; }
.item .thumb .figure { width: 100%; height: 100%; }
.item .emoji { font-size: 1.6rem; width: 40px; text-align: center; flex: none; }
.food-line { display: flex; align-items: center; gap: 8px; padding: 8px 0; }
.food-line .grow { flex: 1; min-width: 0; }
.food-line .kc { font-weight: 700; white-space: nowrap; }
.del-btn { min-width: 44px; min-height: 44px; border: 0; background: transparent; color: var(--muted); font-size: 1.2rem; cursor: pointer; border-radius: 10px; }

.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700;
  background: var(--surface-2); color: var(--muted); vertical-align: middle;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

/* ---------- Messages ---------- */
.note { border-radius: 14px; padding: 12px 14px; margin: 10px 0; font-size: .95rem; background: var(--surface-2); }
.note.ok { background: var(--ok-soft); }
.note.warn { background: var(--warn-soft); }
.note.danger { background: var(--danger-soft); }
.note.accent { background: var(--accent-soft); }
.note b { display: block; margin-bottom: 2px; }
.disclaimer { font-size: .84rem; color: var(--muted); margin: 8px 4px; }
.reminder {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px;
  background: var(--accent-soft); margin-bottom: 10px;
}
.reminder .grow { flex: 1; }
.reminder .emoji { font-size: 1.5rem; }

/* ---------- Exercices ---------- */
.figure { display: block; width: 100%; height: auto; }
.figure-wrap { background: var(--surface-2); border-radius: var(--radius); padding: 10px; margin-bottom: 12px; }
.figure-wrap .figure { max-width: 340px; margin: 0 auto; }
.fg-body, .fg-hi { fill: none; stroke: var(--text); stroke-width: 5.5; stroke-linecap: round; stroke-linejoin: round; }
.fg-hi { stroke: var(--accent); }
.fg-head { fill: var(--text); }
.fg-prop { stroke: var(--prop); stroke-width: 3; stroke-linecap: round; }
.fg-propfill { fill: var(--prop); opacity: .55; }
.fg-mat { fill: var(--prop); opacity: .3; }
.fg-arrow { stroke: var(--accent); stroke-width: 2.2; stroke-linecap: round; }
.fg-ahead { fill: var(--accent); }
.fg-arrowdash { fill: none; stroke: var(--accent); stroke-width: 2; stroke-dasharray: 4 3; }
.fg-accentfill { fill: var(--accent); }
.fg-band { stroke: var(--ok); stroke-width: 2.5; stroke-dasharray: 5 3; }

.steps { padding-left: 1.3em; margin: 8px 0; }
.steps li { margin-bottom: 6px; }
.meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.meta span { background: var(--surface-2); border-radius: 10px; padding: 6px 10px; font-weight: 600; font-size: .92rem; }
.sets { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.set-btn {
  min-width: 64px; min-height: 64px; border-radius: 16px; border: 3px solid var(--accent);
  background: var(--surface); color: var(--accent); font-weight: 800; font-size: 1.05rem; cursor: pointer;
}
.set-btn.done { background: var(--accent); color: var(--on-accent); }
.locked { opacity: .65; }

.timer { text-align: center; padding: 6px 0 4px; }
.timer .time { font-size: 3.2rem; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: 1px; }
.timer.running .time { color: var(--accent); }

/* Yoga */
.yoga-player { text-align: center; }
.yoga-player .figure-wrap .figure { max-width: 300px; }
.ring { width: 170px; height: 170px; margin: 6px auto; position: relative; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 10; }
.ring .track { stroke: var(--surface-2); }
.ring .val { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset 1s linear; }
.ring .label { position: absolute; inset: 0; display: grid; place-items: center; font-size: 2.2rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.dots { display: flex; gap: 6px; justify-content: center; margin: 8px 0; }
.dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--border); }
.dots i.on { background: var(--accent); }

/* Habitudes */
.habit { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.habit:last-child { border-bottom: 0; }
.habit .tick {
  width: 52px; height: 52px; border-radius: 50%; border: 3px solid var(--accent); background: var(--surface);
  color: var(--on-accent); font-size: 1.5rem; font-weight: 800; flex: none; cursor: pointer;
}
.habit .tick.on { background: var(--accent); }
.habit .grow { flex: 1; min-width: 0; }
.habit .streak { font-size: .86rem; color: var(--muted); }
.week { display: flex; gap: 4px; margin-top: 4px; }
.week i { width: 22px; height: 22px; border-radius: 6px; background: var(--surface-2); font-style: normal; font-size: .66rem; display: grid; place-items: center; color: var(--muted); }
.week i.on { background: var(--accent); color: var(--on-accent); }

/* Graphiques */
.chart { width: 100%; height: auto; display: block; }
.ch-grid { stroke: var(--border); stroke-width: 1; }
.ch-label { fill: var(--muted); font-size: 10px; }
.ch-val { fill: var(--text); font-size: 9px; font-weight: 700; }
.ch-line { fill: none; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.ch-dash { stroke-dasharray: 5 4; stroke-width: 2; }
.s-accent { stroke: var(--accent); fill: var(--accent); }
.ch-line.s-accent { fill: none; }
.s-protein { stroke: var(--protein); fill: var(--protein); }
.ch-line.s-protein { fill: none; }
.s-muted { stroke: var(--muted); fill: var(--muted); }
.ch-line.s-muted { fill: none; }
.ch-bar { fill: var(--ok); opacity: .55; }
.ch-bar-hi { opacity: 1; }
.ch-goal { stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 5 4; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .85rem; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 14px; height: 4px; border-radius: 2px; vertical-align: middle; margin-right: 5px; }
.chart-empty { padding: 24px 0; text-align: center; }

/* Feuille (modale du bas) */
.sheet-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(20, 8, 14, .45); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: var(--bg); width: 100%; max-width: 640px; max-height: 92vh; border-radius: 22px 22px 0 0;
  display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom);
}
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px 8px; }
.sheet-head h2 { flex: 1; }
.sheet-body { overflow-y: auto; padding: 4px 16px 20px; -webkit-overflow-scrolling: touch; }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px);
  z-index: 60; max-width: 560px; margin: 0 auto; padding: 14px 18px; border-radius: 14px;
  background: var(--text); color: var(--bg); font-weight: 600; text-align: center; box-shadow: 0 6px 24px rgba(0,0,0,.2);
}

.onboarding { max-width: 520px; margin: 0 auto; }
.onboarding .logo { width: 84px; height: 84px; border-radius: 22px; display: block; margin: 8px auto 12px; }

.tip-card .tip-icon { font-size: 2rem; }
.qty { display: flex; align-items: center; gap: 10px; }
.qty button { width: 52px; height: 52px; border-radius: 14px; border: 2px solid var(--border); background: var(--surface); font-size: 1.5rem; font-weight: 700; cursor: pointer; }
.qty output { min-width: 60px; text-align: center; font-size: 1.3rem; font-weight: 800; }
.daynav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.daynav b { text-align: center; flex: 1; }
.daynav button { min-width: 52px; min-height: 52px; border-radius: 14px; border: 2px solid var(--border); background: var(--surface); font-size: 1.4rem; cursor: pointer; }
.star { border: 0; background: none; font-size: 1.5rem; min-width: 44px; min-height: 44px; cursor: pointer; color: var(--muted); }
.star.on { color: #E0A100; }
