/* ═══════ Bien-Être — mobile-first ═══════ */
/* Thème sombre par défaut — design « Mon Bien-être » */
:root {
  --bg: #0a0a0b;
  --card: #151517;
  --card2: #1e1e21;
  --txt: #f2f4f2;
  --muted: #8b8f8c;
  --accent: #34d97b;
  --accent-soft: #103824;
  --p-col: #34d97b;
  --c-col: #f2a83b;
  --l-col: #f2d43b;
  --eau-col: #4aa8f0;
  --border: #26262a;
  --danger: #e05252;
  --radius: 18px;
  --shadow: 0 2px 12px rgba(0, 0, 0, .4);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--txt);
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
  min-height: 100vh;
}
.hidden { display: none !important; }
button { font-family: inherit; border: none; background: none; color: inherit; cursor: pointer; }
input, textarea {
  font-family: inherit; font-size: 1rem; color: var(--txt);
  background: var(--bg); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; width: 100%; outline: none;
}
input:focus, textarea:focus { border-color: var(--accent); }

/* ─── Onboarding ─── */
#onboarding { padding: 24px 20px calc(24px + env(safe-area-inset-bottom)); max-width: 480px; margin: 0 auto; }
.onb-logo { font-size: 3rem; text-align: center; margin-top: 12px; }
.onb-card h1 { text-align: center; margin-bottom: 4px; }
.onb-card > p { text-align: center; margin-bottom: 20px; }

/* ─── Generic ─── */
.card {
  background: var(--card); border-radius: var(--radius);
  padding: 16px; margin: 0 16px 14px; box-shadow: var(--shadow);
}
.muted { color: var(--muted); }
.small-text { font-size: .85rem; line-height: 1.4; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.field-title { font-weight: 700; margin-bottom: 8px; }
.seg { display: flex; gap: 6px; background: var(--bg); border-radius: 12px; padding: 4px; }
.seg button {
  flex: 1; padding: 9px 4px; border-radius: 9px; font-size: .85rem; font-weight: 600;
  color: var(--muted); line-height: 1.2;
}
.seg button.active { background: var(--accent); color: #fff; }
.seg button small { font-weight: 400; opacity: .85; }
.seg.small button { padding: 6px 4px; font-size: .8rem; }
.btn-primary {
  display: block; width: 100%; background: var(--accent); color: #fff;
  font-size: 1rem; font-weight: 700; padding: 14px; border-radius: 14px; margin-top: 8px;
}
.btn-primary:active { opacity: .85; }
.btn-secondary {
  display: block; width: 100%; background: var(--accent-soft); color: var(--accent);
  font-size: .92rem; font-weight: 700; padding: 12px; border-radius: 12px; margin-top: 8px;
}
.btn-row { display: flex; gap: 10px; }
.btn-row .btn-secondary { flex: 1; }

/* ─── Page head ─── */
.page-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(18px + env(safe-area-inset-top)) 20px 12px;
}
.page-head h2 { font-size: 1.4rem; }
.date-label { font-size: .85rem; color: var(--muted); text-transform: capitalize; }
.head-emoji { font-size: 1.6rem; font-weight: 700; color: var(--accent); }
#journal-total { font-size: 1rem; }

/* ─── Tabs ─── */
.tab { display: none; max-width: 520px; margin: 0 auto; }
.tab.active { display: block; }
#tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  display: flex; justify-content: space-around; align-items: center;
  background: var(--card); border-top: 1px solid var(--border);
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
}
#tabbar button {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: .68rem; font-weight: 600; color: var(--muted); flex: 1; padding: 4px 0;
}
#tabbar button span { font-size: 1.3rem; }
#tabbar button.active { color: var(--accent); }
#tab-add {
  background: var(--accent); color: #fff !important; border-radius: 50%;
  width: 52px; height: 52px; max-width: 52px; flex: none !important;
  font-size: 1.7rem !important; margin-top: -18px; box-shadow: 0 4px 12px rgba(16,185,129,.4);
  justify-content: center;
}

/* ─── Hero : anneau + reste ─── */
.ring-card { padding: 18px 16px 14px; }
.hero { display: flex; align-items: center; gap: 14px; }
.ring-wrap { position: relative; width: 46%; min-width: 150px; flex: none; }
#kcal-ring { transform: rotate(-90deg); width: 100%; }
.ring-bg { fill: none; stroke: var(--card2); stroke-width: 14; }
.ring-fg {
  fill: none; stroke: var(--accent); stroke-width: 14; stroke-linecap: round;
  stroke-dasharray: 540; stroke-dashoffset: 540; transition: stroke-dashoffset .6s ease, stroke .3s;
  filter: drop-shadow(0 0 6px rgba(52, 217, 123, .45));
}
.ring-fg.over { stroke: #ef6c5a; filter: drop-shadow(0 0 6px rgba(239,108,90,.45)); }
.ring-center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
}
.ring-big { font-size: 1.9rem; font-weight: 800; line-height: 1; }
.ring-sub { color: var(--muted); font-size: .62rem; margin-top: 3px; }
.ring-sub2 { color: var(--muted); font-size: .62rem; }
.ring-pct { margin-top: 4px; font-size: .72rem; font-weight: 800; color: var(--accent); }
.hero-right { flex: 1; min-width: 0; }
.hero-rest-label { font-size: .85rem; color: var(--txt); }
.hero-rest { font-size: 1.5rem; font-weight: 800; color: var(--accent); line-height: 1.15; }
.hero-rest.over { color: #ef6c5a; }
.hero-sub { font-size: .7rem; color: var(--muted); margin: 3px 0 10px; }
.chip {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  background: var(--card2); border-radius: 12px; padding: 8px 10px; margin-bottom: 6px;
}
.chip span { font-size: 1rem; }
.chip-lbl { font-size: .65rem; color: var(--muted); }
.chip-val { font-size: .8rem; font-weight: 700; }

/* ─── Tuiles macros ─── */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.tile { background: var(--card2); border-radius: 14px; padding: 10px 8px; text-align: center; }
.tile-head { font-size: .62rem; font-weight: 700; color: var(--muted); white-space: nowrap; overflow: hidden; }
.tile-val { font-size: .95rem; font-weight: 800; margin-top: 4px; }
.tile-target { font-size: .58rem; color: var(--muted); margin: 1px 0 6px; }
.bar { height: 5px; border-radius: 6px; background: var(--bg); overflow: hidden; }
.fill { height: 100%; width: 0; border-radius: 6px; transition: width .5s ease; }
.fill-p { background: var(--p-col); }
.fill-c { background: var(--c-col); }
.fill-l { background: var(--l-col); }
.fill-eau { background: var(--eau-col); }
.tile-pct { font-size: .68rem; font-weight: 800; margin-top: 5px; }
.pct-p { color: var(--p-col); } .pct-c { color: var(--c-col); }
.pct-l { color: var(--l-col); } .pct-eau { color: var(--eau-col); }

/* ─── Mes repas (accueil) ─── */
.hm-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.hm-title { font-weight: 800; }
.hm-total { font-size: .85rem; font-weight: 700; color: var(--muted); }
.hm-row {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 10px 0; border-top: 1px solid var(--border);
}
.hm-ico {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center; font-size: 1rem;
  background: var(--accent-soft);
}
.hm-info { flex: 1; min-width: 0; }
.hm-name { font-size: .88rem; font-weight: 700; }
.hm-macros { font-size: .68rem; color: var(--muted); margin-top: 2px; }
.hm-kcal { font-size: .82rem; font-weight: 800; color: var(--accent); background: var(--accent-soft); padding: 4px 9px; border-radius: 999px; white-space: nowrap; }
.hm-kcal.empty { color: var(--muted); background: var(--card2); }

/* ─── Stats ─── */
.stat-row { display: flex; gap: 0; margin: 0 16px 14px; gap: 10px; }
.stat { flex: 1; margin: 0; text-align: center; padding: 12px 6px; }
.stat-emoji { font-size: 1.4rem; }
.stat-val { font-size: 1.15rem; font-weight: 800; margin-top: 2px; }
.stat-lbl { font-size: .7rem; color: var(--muted); }

/* ─── Coach ─── */
.coach-title { font-weight: 700; margin-bottom: 6px; }
.coach-msg { font-size: .9rem; line-height: 1.45; }
.big-add { margin: 4px 16px 20px; width: calc(100% - 32px); }

/* ─── Journal ─── */
.day-nav { display: flex; align-items: center; gap: 10px; }
.day-btn { font-size: 1.5rem; color: var(--accent); padding: 0 8px; font-weight: 700; }
.meal-card { margin-bottom: 14px; }
.meal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.meal-title { font-weight: 700; }
.meal-kcal { font-size: .85rem; color: var(--muted); font-weight: 600; }
.meal-actions { display: flex; gap: 4px; }
.meal-actions button { font-size: 1.1rem; padding: 4px 8px; border-radius: 8px; }
.meal-actions .add-food { color: var(--accent); font-weight: 800; }
.food-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 0; border-top: 1px solid var(--border); gap: 8px;
}
.food-name { font-size: .92rem; flex: 1; }
.food-qty { font-size: .78rem; color: var(--muted); }
.food-kcal { font-size: .88rem; font-weight: 700; white-space: nowrap; }
.food-del { color: var(--muted); font-size: 1rem; padding: 4px 6px; }
.meal-empty { color: var(--muted); font-size: .85rem; padding: 8px 0; border-top: 1px solid var(--border); }

/* ─── Modals ─── */
.modal {
  position: fixed; inset: 0; z-index: 100; background: rgba(10, 20, 15, .5);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal-sheet {
  background: var(--card); border-radius: 22px 22px 0 0; width: 100%; max-width: 520px;
  max-height: 88vh; overflow-y: auto; padding: 18px 18px calc(24px + env(safe-area-inset-bottom));
  -webkit-overflow-scrolling: touch;
}
.small-sheet { max-height: 70vh; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-close { font-size: 1.1rem; color: var(--muted); background: var(--bg); border-radius: 50%; width: 32px; height: 32px; }
.add-tabs { margin-top: 10px; }
.add-tabs button { font-size: .75rem; padding: 8px 2px; }
.add-pane { margin-top: 14px; }
#add-meal-seg button { font-size: .78rem; }

/* ─── Résultats recherche ─── */
.results { margin-top: 10px; }
.result-row {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 11px 4px; border-bottom: 1px solid var(--border); width: 100%; text-align: left;
}
.result-info { flex: 1; min-width: 0; }
.result-name { font-size: .92rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-detail { font-size: .75rem; color: var(--muted); }
.result-kcal { font-weight: 700; font-size: .9rem; color: var(--accent); white-space: nowrap; }
.or-sep { text-align: center; color: var(--muted); font-size: .8rem; margin: 12px 0 8px; }
#barcode-video { width: 100%; border-radius: 12px; }

/* ─── Quantité ─── */
.qty-per100 { font-size: .85rem; margin-bottom: 10px; }
.qty-quick { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.qty-quick button {
  background: var(--bg); border: 1px solid var(--border); border-radius: 999px;
  padding: 7px 14px; font-size: .85rem; font-weight: 600;
}
.qty-quick button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.weight-input-row { display: flex; gap: 10px; align-items: center; }
.weight-input-row input { flex: 1; }
.weight-input-row .btn-primary { width: auto; margin: 0; padding: 12px 20px; }
.qty-unit { font-weight: 700; color: var(--muted); }
.qty-preview { margin-top: 12px; font-size: .9rem; color: var(--muted); text-align: center; }

/* ─── Poids ─── */
.chart-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.chart-head .seg { flex: 1; }
.trend { font-size: .9rem; font-weight: 700; white-space: nowrap; }
.trend.down { color: var(--accent); }
.trend.up { color: var(--p-col); }
#weight-chart { width: 100%; height: auto; }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; }
.chart-area { fill: var(--accent); opacity: .12; }
.chart-dot { fill: var(--accent); }
.chart-goal { stroke: var(--c-col); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart-label { font-size: 11px; fill: var(--muted); }

/* ─── Toast ─── */
#toast {
  position: fixed; bottom: calc(100px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  background: var(--txt); color: var(--bg); padding: 10px 20px; border-radius: 999px;
  font-size: .9rem; font-weight: 600; z-index: 200; white-space: nowrap;
  box-shadow: var(--shadow);
}

/* ─── Semaine ─── */
.week-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 4px; }
.week-grid > div { text-align: center; background: var(--card2); border-radius: 12px; padding: 10px 4px; }
.week-val { font-size: 1.1rem; font-weight: 800; }
.week-lbl { font-size: .7rem; color: var(--muted); margin-top: 2px; }

/* ─── Saisie naturelle : quantités modifiables ─── */
.text-qty { width: 64px; padding: 8px; text-align: right; flex: none; }
.text-qty.est { border-color: var(--c-col); background: rgba(242,177,52,.08); }

/* ─── Moyenne mobile ─── */
.chart-ma { fill: none; stroke: var(--l-col); stroke-width: 2; stroke-dasharray: 6 4; opacity: .8; }

/* ─── Repas favoris ─── */
.fav-meal {
  display: flex; justify-content: space-between; align-items: center; width: 100%;
  background: var(--accent-soft); border-radius: 14px; padding: 13px 14px; margin-bottom: 8px; text-align: left;
}
.fav-meal-name { font-weight: 700; color: var(--accent); }
.fav-meal-detail { font-size: .75rem; color: var(--muted); margin-top: 2px; }
