:root {
  --bg: #0e1512;
  --card: #16201c;
  --card2: #1c2823;
  --text: #e8f1ec;
  --muted: #93a89e;
  --accent: #2dd4b0;
  --accent-dim: #1a7a68;
  --warn: #f0a35e;
  --danger: #e5636c;
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); margin-top: .6rem; }

/* ---------- Connexion ---------- */
#login-view {
  display: flex; align-items: center; justify-content: center;
  min-height: 100dvh; padding: 1rem;
}
.login-card {
  background: var(--card); border-radius: var(--radius);
  padding: 2rem; width: 100%; max-width: 340px; text-align: center;
}
.login-card h1 { font-size: 1.5rem; margin-bottom: .3rem; }
.login-card form { margin-top: 1.4rem; display: grid; gap: .8rem; }

input, button, select {
  font: inherit; color: inherit; border-radius: 10px; border: 1px solid #2c3b34;
}
input {
  background: var(--bg); padding: .75rem .9rem; width: 100%;
}
input:focus { outline: 2px solid var(--accent-dim); }
button {
  background: var(--accent); color: #06231c; font-weight: 700;
  padding: .75rem 1rem; border: none; cursor: pointer;
}
button.ghost {
  background: transparent; color: var(--muted); border: 1px solid #2c3b34;
  padding: .4rem .7rem;
}

/* ---------- Header ---------- */
header {
  padding: max(env(safe-area-inset-top), .8rem) 1rem .8rem;
  background: linear-gradient(180deg, #12241d, var(--bg));
  position: sticky; top: 0; z-index: 5;
}
.header-row { display: flex; justify-content: space-between; align-items: center; }
header h1 { font-size: 1.15rem; }
.profile-switch {
  display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-top: .7rem;
}
.profile-switch button {
  background: var(--card); color: var(--muted); font-weight: 600;
  border: 1px solid #2c3b34; padding: .55rem;
}
.profile-switch button.active {
  background: var(--accent); color: #06231c; border-color: var(--accent);
}

/* ---------- Layout ---------- */
main { padding: 1rem 1rem calc(4.6rem + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; }
h2 { font-size: 1.05rem; margin: 1.1rem 0 .6rem; }
h2:first-child { margin-top: 0; }

.card {
  background: var(--card); border-radius: var(--radius);
  padding: .9rem 1rem; margin-bottom: .7rem;
}
.card h3 { font-size: .98rem; margin-bottom: .25rem; }
.card .sub { font-size: .82rem; color: var(--muted); }

.banner {
  background: linear-gradient(135deg, #133228, #16201c);
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius); padding: .9rem 1rem; margin-bottom: .9rem;
}
.banner strong { color: var(--accent); }

.badge {
  display: inline-block; font-size: .72rem; font-weight: 700;
  padding: .15rem .55rem; border-radius: 999px; margin-left: .4rem;
  background: var(--accent-dim); color: #dffef6; vertical-align: middle;
}
.badge.warn { background: #5c3d1e; color: #ffd9ae; }

.kcal-pill { font-size: .78rem; color: var(--accent); font-weight: 600; }

/* checkbox rows */
.check-row {
  display: flex; align-items: center; gap: .7rem;
  background: var(--card); border-radius: var(--radius);
  padding: .8rem 1rem; margin-bottom: .6rem; cursor: pointer;
}
.check-row input { width: 1.35rem; height: 1.35rem; accent-color: var(--accent); flex: none; }
.check-row.done .label { text-decoration: line-through; color: var(--muted); }
.check-row .label { flex: 1; }

/* ---------- Entraînement ---------- */
details.seance {
  background: var(--card); border-radius: var(--radius);
  margin-bottom: .7rem; overflow: hidden;
}
details.seance summary {
  padding: .9rem 1rem; cursor: pointer; font-weight: 600; list-style: none;
  display: flex; justify-content: space-between; align-items: center;
}
details.seance summary::after { content: "▾"; color: var(--muted); }
details[open].seance summary::after { content: "▴"; }
.exo {
  padding: .7rem 1rem; border-top: 1px solid #24312b;
}
.exo .exo-head { display: flex; justify-content: space-between; gap: .6rem; }
.exo .exo-head b { font-size: .92rem; }
.exo .scheme { color: var(--accent); font-weight: 700; white-space: nowrap; font-size: .85rem; }
.exo .tip { font-size: .82rem; color: var(--muted); margin-top: .25rem; }
.exo .alt { font-size: .78rem; color: #6f8a7f; margin-top: .15rem; font-style: italic; }
.note { background: var(--card2); border-radius: var(--radius); padding: .8rem 1rem; font-size: .85rem; color: var(--muted); margin-bottom: .7rem; }

/* ---------- Repas ---------- */
.meal-row {
  display: flex; justify-content: space-between; align-items: center; gap: .6rem;
  background: var(--card); border-radius: var(--radius);
  padding: .8rem 1rem; margin-bottom: .55rem; cursor: pointer;
}
.meal-row .day { color: var(--accent); font-weight: 700; font-size: .78rem; min-width: 2.2rem; }
.meal-row .name { flex: 1; font-size: .92rem; }
.meal-row .kcal { font-size: .78rem; color: var(--muted); white-space: nowrap; }

.grocery-cat { margin-bottom: .8rem; }
.grocery-cat h3 { font-size: .85rem; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; margin-bottom: .4rem; }
.grocery-item {
  display: flex; align-items: center; gap: .6rem; padding: .35rem 0; font-size: .9rem;
}
.grocery-item input { width: 1.1rem; height: 1.1rem; accent-color: var(--accent); }
.grocery-item.done span { text-decoration: line-through; color: var(--muted); }
.grocery-item .qty { margin-left: auto; color: var(--muted); font-size: .82rem; }

/* ---------- Modal recette ---------- */
#modal {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .6);
  display: flex; align-items: flex-end; justify-content: center; z-index: 20;
}
.modal-card {
  background: var(--card2); width: 100%; max-width: 640px;
  border-radius: var(--radius) var(--radius) 0 0;
  max-height: 88dvh; overflow-y: auto; padding: 1.1rem 1.1rem 2rem;
}
.modal-card h3 { margin-bottom: .2rem; }
.modal-card .close { float: right; }
.modal-card ul, .modal-card ol { margin: .5rem 0 .9rem 1.2rem; font-size: .9rem; }
.modal-card li { margin-bottom: .3rem; }
.portions { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin: .7rem 0; }
.portion { background: var(--card); border-radius: 10px; padding: .7rem; }
.portion h4 { font-size: .85rem; color: var(--accent); margin-bottom: .35rem; }
.portion ul { margin: 0 0 0 1rem; font-size: .82rem; }

/* ---------- Progrès ---------- */
.chart-card { background: var(--card); border-radius: var(--radius); padding: 1rem; margin-bottom: .8rem; }
.chart-card svg { width: 100%; height: auto; display: block; }
form.weight-form { display: flex; gap: .6rem; margin-bottom: .9rem; }
form.weight-form input[type="date"] { flex: 1.4; }
form.weight-form input[type="number"] { flex: 1; }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: #101a16; border-top: 1px solid #24312b;
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  text-align: center; padding: .55rem 0 .5rem; text-decoration: none;
  color: var(--muted); font-size: .68rem; font-weight: 600;
}
.tabbar a span { display: block; font-size: 1.15rem; margin-bottom: .1rem; }
.tabbar a.active { color: var(--accent); }
