/* Couleurs et formes reprises de la maquette validée le 25/11/2026. */
:root {
  --bg: #F6F7F5;
  --card: #FFFFFF;
  --line: #E3E6E2;
  --line-soft: #EEF0ED;
  --field: #C9CFC9;
  --btn-line: #D5DAD5;
  --fg: #17201C;
  --muted: #55605A;
  --faint: #9AA6A0;
  --primary: #0F6B5C;
  --primary-soft: #E3F1EE;
  --primary-tint: #F3F8F6;
  --seg: #E9ECE8;
  --dark: #17201C;
  --dark-line: #34403A;
  --dark-muted: #B8C4BE;
  --mint: #8FE3CC;
  --amber: #F4B860;
  --lilac: #A9B8F5;
  --unoff-bg: #FEF3C7;
  --unoff-fg: #92400E;
  --unoff-dot: #D97706;
  --prov: #6D28D9;
  --prov-fg: #5B21B6;
  --ok-fg: #166534; --ok-bg: #DCFCE7; --ok-bar: #16A34A;
  --partiel-fg: #92400E; --partiel-bg: #FEF3C7; --partiel-bar: #D97706;
  --faible-fg: #991B1B; --faible-bg: #FEE2E2; --faible-bar: #DC2626;
  --exces-fg: #FFFFFF; --exces-bg: #B91C1C; --exces-bar: #B91C1C;
  --info-fg: #4B5563; --info-bg: #F1F2F0; --info-bar: #C9CFC9;
  --tabs-h: 64px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.app { max-width: 560px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; }
main { padding-top: env(safe-area-inset-top); padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 16px); outline: none; }
.loading { padding: 40px 20px; color: var(--muted); text-align: center; }
.error { margin: 24px 16px; padding: 16px; border-radius: 16px; background: var(--faible-bg); color: var(--faible-fg); }

.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* En-têtes d'écran */
.head { padding: 20px 16px 8px; display: flex; flex-direction: column; gap: 12px; }
.eyebrow { font-size: 12px; font-weight: 700; color: var(--primary); letter-spacing: 0.08em; text-transform: uppercase; }
h1 { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -0.01em; line-height: 1.15; }
.lead { font-size: 13px; color: var(--muted); line-height: 1.45; margin: 0; }
.label { font-size: 13px; font-weight: 600; color: var(--muted); }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.back { align-self: flex-start; display: flex; align-items: center; gap: 4px; height: 44px; padding: 0 8px 0 0; border: none; background: transparent; font-size: 15px; font-weight: 600; color: var(--primary); }

/* Boutons */
.chip-btn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border: 1px solid var(--btn-line); border-radius: 18px; background: var(--card); font-size: 13px; font-weight: 600; white-space: nowrap; flex-shrink: 0; }
.chip-btn[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }
.choice { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.choice button { height: 48px; padding: 0 14px; border-radius: 14px; font-size: 15px; font-weight: 700; border: 1px solid var(--btn-line); background: var(--card); }
.choice button[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }
.seg { display: grid; gap: 4px; padding: 4px; background: var(--seg); border-radius: 12px; }
.seg.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.seg.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.seg button { min-height: 44px; border: none; border-radius: 9px; font-size: 13px; font-weight: 600; line-height: 1.2; padding: 4px; background: transparent; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--fg); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
.seg.big button { font-size: 15px; }
.btn-outline { margin: 12px 16px 0; width: calc(100% - 32px); height: 52px; border: 1px solid var(--primary); border-radius: 14px; background: var(--card); font-size: 15px; font-weight: 700; color: var(--primary); display: flex; align-items: center; justify-content: center; gap: 8px; }
.btn-main { height: 52px; border-radius: 14px; font-size: 15px; font-weight: 700; border: 1px solid var(--primary); background: var(--primary); color: #fff; }
.btn-main.done { background: var(--primary-soft); color: var(--primary); }
.link-btn { border: none; background: transparent; color: var(--primary); font-weight: 600; padding: 8px 0; text-align: left; font-size: 14px; }

/* Cartes */
.card { margin: 16px 16px 0; background: var(--card); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.card.pad { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.card-title { font-size: 15px; font-weight: 800; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; padding: 14px 16px 6px; gap: 8px; }
.later { margin: 12px 16px 0; border: 1px dashed var(--faint); border-radius: 16px; padding: 14px 16px; display: flex; gap: 12px; align-items: flex-start; }
.later strong { display: block; font-size: 14px; }
.later span { display: block; font-size: 13px; color: var(--muted); line-height: 1.45; margin-top: 4px; }
.later svg { flex-shrink: 0; margin-top: 2px; color: var(--primary); }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* Nom du repas */
.meal-name { display: flex; flex-direction: column; gap: 2px; }
.meal-name input { font-size: 26px; font-weight: 800; border: none; border-bottom: 1px dashed var(--field); background: transparent; padding: 2px 0 4px; outline: none; letter-spacing: -0.01em; width: 100%; border-radius: 0; }

/* Liste des aliments du repas */
.item { display: flex; align-items: center; gap: 8px; padding: 10px 8px 10px 16px; border-top: 1px solid var(--line-soft); }
.item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.item-name { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-sub { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.qty { display: flex; align-items: center; border: 1px solid var(--btn-line); border-radius: 12px; height: 44px; overflow: hidden; flex-shrink: 0; background: var(--card); }
.qty button { width: 34px; height: 44px; border: none; background: #F6F7F5; font-size: 18px; }
.qty input { width: 48px; height: 44px; border: none; text-align: right; font-size: 16px; font-weight: 700; padding: 0; outline: none; background: var(--card); }
.qty .u { font-size: 13px; color: var(--muted); padding: 0 6px 0 2px; }
.icon-btn { width: 36px; height: 44px; border: none; background: transparent; color: var(--muted); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.add-row { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 52px; border: none; border-top: 1px solid var(--line-soft); background: var(--primary-tint); font-size: 15px; font-weight: 700; color: var(--primary); }
.empty { margin: 0; padding: 8px 16px 14px; font-size: 14px; color: var(--muted); }

/* Badges */
.badge-unoff { display: inline-flex; align-items: center; height: 18px; padding: 0 6px; border-radius: 9px; background: var(--unoff-bg); color: var(--unoff-fg); font-size: 11px; font-weight: 600; }
.badge-prov { display: inline-flex; align-items: center; height: 18px; padding: 0 6px; border-radius: 9px; border: 1px dashed var(--prov); color: var(--prov-fg); font-size: 11px; font-weight: 600; }
.dot-unoff { display: inline-block; width: 8px; height: 8px; border-radius: 4px; background: var(--unoff-dot); margin-right: 6px; vertical-align: middle; flex-shrink: 0; }
.st { height: 22px; padding: 0 8px; border-radius: 11px; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; white-space: nowrap; }
.st.sm { height: 20px; padding: 0 7px; font-size: 11px; }
.st.ok { color: var(--ok-fg); background: var(--ok-bg); }
.st.partiel { color: var(--partiel-fg); background: var(--partiel-bg); }
.st.faible { color: var(--faible-fg); background: var(--faible-bg); }
.st.exces { color: var(--exces-fg); background: var(--exces-bg); }
.st.info { color: var(--info-fg); background: var(--info-bg); }
.bar { height: 6px; border-radius: 3px; background: var(--line-soft); overflow: hidden; }
.bar > div { height: 6px; border-radius: 3px; }
.bar .ok { background: var(--ok-bar); }
.bar .partiel { background: var(--partiel-bar); }
.bar .faible { background: var(--faible-bar); }
.bar .exces { background: var(--exces-bar); }
.bar .info { background: var(--info-bar); }

/* Carte énergie (fond sombre) */
.dark { margin: 16px 16px 0; background: var(--dark); color: #fff; border-radius: 20px; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.dark .m { color: var(--dark-muted); font-size: 12px; }
.energy-val { font-size: 40px; font-weight: 800; letter-spacing: -0.02em; line-height: 1; }
.energy-val small { font-size: 18px; font-weight: 600; color: var(--dark-muted); }
.energy-pct { font-size: 28px; font-weight: 800; color: var(--mint); text-align: right; }
.dbar { height: 8px; border-radius: 4px; background: var(--dark-line); overflow: hidden; }
.dbar > div { height: 100%; border-radius: 4px; background: var(--mint); }
.split { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--dark-line); }
.split > div { height: 12px; }
.macros { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; font-size: 12px; }
.macros span { display: flex; flex-direction: column; }
.macros b { font-weight: 700; }
.c-g { color: var(--mint); } .bg-g { background: var(--mint); }
.c-p { color: var(--amber); } .bg-p { background: var(--amber); }
.c-l { color: var(--lilac); } .bg-l { background: var(--lilac); }

/* Lignes de nutriments */
.nut { display: flex; flex-direction: column; gap: 6px; padding: 10px 0; border-top: 1px solid var(--line-soft); }
.nut-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.nut-label { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.nut-amt { font-size: 14px; font-weight: 700; white-space: nowrap; }
.nut-bottom { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.nut-ref { font-size: 12px; color: var(--muted); text-align: right; }
.nut-miss { font-size: 12px; color: var(--muted); }
.grid-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 8px; padding: 9px 16px; border-top: 1px solid var(--line-soft); align-items: center; }
.grid-row .nut-ref { text-align: left; }
.grid-row .end { justify-self: end; }
.grid-row.noref .nut-label { color: var(--muted); }
.group-btn { width: 100%; min-height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 16px; border: none; background: var(--card); text-align: left; }
.group-btn strong { display: block; font-size: 16px; font-weight: 800; }
.group-btn .small { color: var(--muted); }
.group-btn .chev { font-size: 13px; font-weight: 700; color: var(--primary); flex-shrink: 0; }
.legend { display: flex; flex-wrap: wrap; gap: 6px; }
.legend-lines { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.legend-lines > span { display: flex; align-items: center; gap: 6px; }

/* Recherche et liste d'aliments */
.search { display: flex; align-items: center; gap: 8px; height: 48px; padding: 0 14px; background: var(--card); border: 1px solid var(--field); border-radius: 14px; }
.search input { flex: 1; min-width: 0; border: none; outline: none; font-size: 16px; background: transparent; }
.cats { display: flex; gap: 8px; overflow-x: auto; padding: 0 16px 4px; margin: 0 -16px; scrollbar-width: none; }
.cats::-webkit-scrollbar { display: none; }
.sort { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 600; color: var(--muted); }
.sort select { flex: 1; min-width: 0; height: 44px; padding: 0 10px; border: 1px solid var(--field); border-radius: 12px; background: var(--card); font-size: 15px; font-weight: 600; }
.food { display: flex; align-items: center; gap: 10px; padding: 10px 8px 10px 16px; border-bottom: 1px solid var(--line-soft); }
.food:last-child { border-bottom: none; }
.food-open { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; border: none; background: transparent; padding: 0; text-align: left; }
.food-name { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 4px; }
.food-add { height: 40px; min-width: 44px; padding: 0 12px; border-radius: 12px; font-size: 13px; font-weight: 700; border: 1px solid var(--btn-line); background: var(--card); color: var(--primary); flex-shrink: 0; }
.food-add.done { border-color: var(--primary); background: var(--primary-soft); }
.list-card { margin: 0 16px; }
.more { padding: 12px 16px; font-size: 13px; color: var(--muted); }

/* Fiche aliment */
.strength { display: flex; flex-direction: column; gap: 5px; }
.strength-top { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.strength-top b { color: var(--mint); font-weight: 800; }

/* Profil */
.level { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 16px; text-align: left; border: 2px solid var(--line); background: var(--card); width: 100%; }
.level[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-tint); }
.radio { width: 22px; height: 22px; border-radius: 11px; flex-shrink: 0; border: 2px solid var(--faint); background: var(--card); }
.level[aria-pressed="true"] .radio { border-color: var(--primary); background: var(--primary); box-shadow: inset 0 0 0 4px var(--card); }
.level-txt { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.level-txt strong { font-size: 16px; font-weight: 800; }
.level-txt strong span { font-size: 13px; font-weight: 600; color: var(--muted); }
.level-txt > span { font-size: 13px; color: var(--muted); line-height: 1.4; }
.level-kcal { display: flex; flex-direction: column; align-items: flex-end; }
.level-kcal strong { font-size: 17px; font-weight: 800; }
.calc-box { background: var(--primary-tint); border-radius: 12px; padding: 12px; font-size: 13px; line-height: 1.6; }
.fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.fields label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.fields input { height: 40px; border: 1px solid var(--btn-line); border-radius: 10px; padding: 0 8px; font-size: 14px; color: var(--muted); background: #F6F7F5; min-width: 0; }

/* Feuille de route */
.road { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.road-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.road-top strong { font-size: 15px; font-weight: 800; }
.when { flex-shrink: 0; height: 22px; padding: 0 8px; border-radius: 11px; font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; color: var(--primary); background: var(--primary-soft); }
.road span.d { font-size: 13px; color: var(--muted); line-height: 1.45; }
.stack { margin: 8px 16px 0; display: flex; flex-direction: column; gap: 10px; }
.foot { margin: 16px 20px 8px; font-size: 12px; color: var(--muted); line-height: 1.5; }

/* Barre d'onglets */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--card); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); max-width: 560px; margin: 0 auto; }
.tabs button { height: 52px; border: none; background: transparent; font-size: 11px; font-weight: 700; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--muted); }
.tabs button[aria-current="page"] { color: var(--primary); }

@media (min-width: 561px) {
  .tabs { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}
