/* Nutrition — palette soft summer SOMBRE (lilas / rose poudré).
   Thème sombre assumé, un seul monde visuel (comme la maquette validée). */

:root {
  --fond: #17131F;
  --surface: #241E33;
  --surface-2: #1C1727;
  --encre: #ECE6F3;
  --encre-douce: #ABA1BC;
  --encre-faible: #776E88;
  --ligne: #322A44;
  --ligne-douce: #272033;
  --lilas: #B49AD6;        /* accent primaire — calories, actions */
  --lilas-clair: #CDBBEE;
  --rose: #D3A0B6;         /* protéines */
  --rose-alerte: #D6A6AF;  /* hors zone */
  --sauge: #9CC0AC;
  --rayon: 20px;
  --rayon-s: 14px;
  --ombre: 0 1px 0 var(--ligne-douce), 0 18px 34px -28px rgba(0,0,0,.6);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  color: var(--encre);
  background:
    radial-gradient(120% 90% at 88% -12%, color-mix(in srgb, var(--lilas) 26%, transparent), transparent 60%),
    radial-gradient(95% 78% at 0% 112%, color-mix(in srgb, var(--rose) 22%, transparent), transparent 58%),
    var(--fond);
  background-attachment: fixed;
  font: 400 16px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
  min-height: 100vh;
}
button, input, textarea, select { font: inherit; color: inherit; }
.rond, .titre, .anneau-grand, .kv-n, .prot-l, .prot-v, .carte-titre, .zone, .pill,
.meal-nom, .meal-kcal, .fab, .pa-n, .moyenne-n, .jour-kcal {
  font-family: ui-rounded, "SF Pro Rounded", -apple-system, system-ui, sans-serif;
}

/* ---------- structure ---------- */
.app { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
.vue {
  padding: calc(14px + env(safe-area-inset-top)) 18px 0;
  max-width: 540px; margin: 0 auto;
  display: flex; flex-direction: column; gap: 14px;
}
.entete { margin: 6px 2px 2px; padding-right: 44px; }
.entete-reglages { display: flex; align-items: center; justify-content: space-between; padding-right: 0; }
.date { margin: 0 0 3px; color: var(--encre-faible); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; font-weight: 600; }
.titre { margin: 0; font-size: 27px; font-weight: 600; letter-spacing: -.02em; }
.pied-espace { height: 8px; }

.rouage {
  position: fixed; top: calc(12px + env(safe-area-inset-top)); right: 14px; z-index: 20;
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--ligne);
  background: color-mix(in srgb, var(--surface) 80%, transparent); color: var(--encre-douce);
  font-size: 18px; backdrop-filter: blur(8px); cursor: pointer;
}

/* ---------- cartes ---------- */
.carte, .carte-anneau {
  background: var(--surface); border: 1px solid var(--ligne);
  border-radius: var(--rayon); box-shadow: var(--ombre);
  padding: 18px; display: flex; flex-direction: column; gap: 12px;
}
.carte-titre { margin: 0; font-size: 15px; font-weight: 600; }
.aide { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--encre-faible); }

/* ---------- anneau ---------- */
.carte-anneau { gap: 0; }
.anneau-row { display: flex; align-items: center; gap: 18px; }
.anneau { position: relative; width: 130px; height: 130px; flex: 0 0 130px; }
.anneau svg { transform: rotate(-90deg); }
.anneau-fond { fill: none; stroke: var(--ligne); stroke-width: 11; }
.anneau-jauge { fill: none; stroke: url(#grad-anneau); stroke-width: 11; stroke-linecap: round;
  stroke-dasharray: 351.9; stroke-dashoffset: 351.9; transition: stroke-dashoffset .5s ease; }
.anneau-centre { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.anneau-grand { font-size: 30px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.anneau-unite { font-size: 11px; font-weight: 600; color: var(--encre-faible); margin-top: 3px; }
.anneau-cote { flex: 1; display: flex; flex-direction: column; gap: 11px; }
.kv { display: flex; flex-direction: column; gap: 1px; }
.kv-n { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.kv-k { font-size: 11px; color: var(--encre-faible); }

.zone { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px;
  border-radius: 999px; padding: 6px 12px; font-size: 12.5px; font-weight: 600; }
.zone.ok { background: color-mix(in srgb, var(--lilas) 22%, var(--surface)); color: var(--lilas-clair); }
.zone.over { background: color-mix(in srgb, var(--rose-alerte) 24%, var(--surface)); color: var(--rose-alerte); }

/* ---------- protéines ---------- */
.prot { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--ligne-douce); }
.prot-haut { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 9px; }
.prot-l { font-size: 14px; font-weight: 600; }
.prot-l span { color: var(--rose); font-weight: 600; }
.prot-v { font-size: 13px; font-weight: 600; color: var(--encre-douce); font-variant-numeric: tabular-nums; }
.piste { height: 9px; border-radius: 999px; background: var(--ligne); overflow: hidden; }
.piste-remplie { height: 100%; border-radius: 999px; width: 0;
  background: linear-gradient(90deg, var(--rose), var(--lilas)); transition: width .4s ease; }
.prot-note { margin: 8px 0 0; font-size: 11.5px; color: var(--encre-faible); }

.libres { display: flex; gap: 8px; margin-top: 14px; }
.libre { flex: 1; background: var(--surface-2); border-radius: var(--rayon-s); padding: 11px 12px; }
.libre-n { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; font-family: ui-rounded, system-ui, sans-serif; }
.libre-k { font-size: 10.5px; color: var(--encre-faible); margin-top: 1px; }
.libre-k em { font-style: normal; color: var(--lilas-clair); }

/* ---------- repas ---------- */
.repas { display: flex; flex-direction: column; gap: 10px; }
.meal { background: var(--surface); border: 1px solid var(--ligne); border-radius: var(--rayon-s);
  box-shadow: var(--ombre); overflow: hidden; }
.meal-h { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 10px; }
.meal-nom { display: flex; align-items: center; gap: 9px; font-size: 14.5px; font-weight: 600; }
.mdot { width: 9px; height: 9px; border-radius: 3px; }
.meal-kcal { font-size: 12.5px; font-weight: 600; color: var(--encre-douce); font-variant-numeric: tabular-nums; }
.item { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 14px; border-top: 1px solid var(--ligne-douce); }
.item-nm { font-size: 13px; min-width: 0; }
.item-nm small { display: block; color: var(--encre-faible); font-size: 11px; margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-droite { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.item-kc { font-size: 12.5px; font-weight: 600; color: var(--encre-douce); font-variant-numeric: tabular-nums; font-family: ui-rounded, system-ui, sans-serif; }
.item-suppr { width: 24px; height: 24px; border-radius: 50%; border: 0; background: transparent;
  color: var(--encre-faible); font-size: 16px; line-height: 1; cursor: pointer; }
.item-suppr:hover { color: var(--rose-alerte); }
.meal-add { display: flex; align-items: center; gap: 8px; width: 100%; padding: 11px 14px;
  border: 0; border-top: 1px solid var(--ligne-douce); background: transparent;
  color: var(--lilas-clair); font-size: 12.5px; font-weight: 600; cursor: pointer; text-align: left; }
.meal-add .plus { width: 18px; height: 18px; border-radius: 50%; border: 1.6px solid var(--lilas);
  display: grid; place-items: center; font-size: 13px; }
.meal-vide .meal-kcal { color: var(--encre-faible); }

/* ---------- nav ---------- */
.onglets {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; z-index: 30;
  width: 100%; max-width: 540px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 40px calc(10px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border-top: 1px solid var(--ligne); backdrop-filter: blur(12px);
}
.onglets > button[data-vue] {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  border: 0; background: transparent; cursor: pointer;
  color: var(--encre-faible); font-size: 10.5px; font-weight: 600;
  font-family: ui-rounded, system-ui, sans-serif;
}
.onglets > button[data-vue] span { font-size: 19px; line-height: 1; }
.onglets > button.actif { color: var(--lilas-clair); }
.fab { width: 54px; height: 54px; margin-top: -26px; border-radius: 50%; border: 0; cursor: pointer;
  background: linear-gradient(150deg, var(--lilas), var(--rose)); color: #2E2340;
  display: grid; place-items: center; font-size: 28px; line-height: 1;
  box-shadow: 0 14px 26px -8px color-mix(in srgb, var(--lilas) 60%, transparent), inset 0 1px 0 rgba(255,255,255,.35); }
.fab span { margin-top: -2px; }

/* ---------- boutons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: var(--rayon-s); padding: 13px 16px;
  font-size: 15px; font-weight: 600; cursor: pointer; width: 100%;
  font-family: ui-rounded, system-ui, sans-serif; }
.btn-plein { background: linear-gradient(150deg, var(--lilas), var(--rose)); color: #2E2340; }
.btn-doux { background: var(--surface-2); border-color: var(--ligne); color: var(--encre); }
.btn-fantome { background: transparent; border-color: var(--ligne); color: var(--encre-douce); }
.btn-danger { color: var(--rose-alerte); border-color: color-mix(in srgb, var(--rose-alerte) 40%, var(--ligne)); }

/* ---------- réglages ---------- */
.entete-reglages { padding-top: 6px; }
.btn-fermer { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--ligne);
  background: var(--surface-2); color: var(--encre-douce); font-size: 15px; cursor: pointer; }
.ligne { display: flex; align-items: center; justify-content: space-between; gap: 14px; font-size: 14px; }
.ligne input, .ligne select { width: 46%; text-align: right; background: var(--surface-2);
  border: 1px solid var(--ligne); border-radius: 10px; padding: 9px 11px; }
.ligne select { text-align: left; }
.ligne.interrupteur input { width: auto; transform: scale(1.3); accent-color: var(--lilas); }
.champ { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--encre-douce); }
.champ textarea { background: var(--surface-2); border: 1px solid var(--ligne); border-radius: 10px;
  padding: 10px; resize: vertical; }
.version { text-align: center; color: var(--encre-faible); font-size: 12px; margin: 6px 0 0; }

/* ---------- journal ---------- */
.moyenne { display: flex; gap: 10px; }
.moyenne-bloc { flex: 1; background: var(--surface-2); border-radius: var(--rayon-s); padding: 12px 14px; }
.moyenne-n { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.moyenne-k { font-size: 11px; color: var(--encre-faible); margin-top: 2px; }
.moyenne-vide { color: var(--encre-faible); font-size: 13px; }
.liste-jours { display: flex; flex-direction: column; gap: 8px; }
.jour { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--surface); border: 1px solid var(--ligne); border-radius: var(--rayon-s); padding: 13px 15px; box-shadow: var(--ombre); }
.jour-gauche { display: flex; align-items: center; gap: 11px; min-width: 0; }
.jour-pastille { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.jour-date { font-size: 13.5px; text-transform: capitalize; }
.jour-sous { font-size: 11px; color: var(--encre-faible); margin-top: 1px; }
.jour-kcal { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- panneau ajout ---------- */
.ajout { position: fixed; inset: 0; z-index: 50; background: var(--fond);
  display: flex; flex-direction: column; padding: calc(10px + env(safe-area-inset-top)) 18px calc(16px + env(safe-area-inset-bottom));
  overflow-y: auto; max-width: 540px; margin: 0 auto; }
.ajout-tete { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.ajout-repas { display: flex; gap: 6px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.ajout-repas button { flex: 0 0 auto; border: 1px solid var(--ligne); background: var(--surface-2);
  color: var(--encre-douce); border-radius: 999px; padding: 7px 13px; font-size: 12.5px; font-weight: 600; cursor: pointer;
  font-family: ui-rounded, system-ui, sans-serif; }
.ajout-repas button.actif { background: color-mix(in srgb, var(--lilas) 24%, var(--surface)); color: var(--lilas-clair); border-color: transparent; }

.recherche { display: flex; align-items: center; gap: 10px; background: var(--surface);
  border: 1px solid var(--ligne); border-radius: var(--rayon-s); padding: 12px 14px; margin-bottom: 8px; }
.recherche svg { width: 18px; height: 18px; color: var(--encre-faible); flex: 0 0 auto; }
.recherche input { flex: 1; border: 0; background: transparent; outline: none; font-size: 15px; }
.scan { display: flex; align-items: center; justify-content: center; gap: 9px; width: 100%;
  padding: 12px; border-radius: var(--rayon-s); border: 1.4px dashed color-mix(in srgb, var(--lilas) 55%, var(--ligne));
  background: transparent; color: var(--lilas-clair); font-size: 13px; font-weight: 600; cursor: pointer; margin-bottom: 12px;
  font-family: ui-rounded, system-ui, sans-serif; }
.scan svg { width: 18px; height: 18px; }

.sous-lab { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .12em;
  color: var(--encre-faible); margin: 16px 2px 9px; }
.resu { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%;
  padding: 12px 14px; background: var(--surface); border: 1px solid var(--ligne); border-radius: var(--rayon-s);
  margin-bottom: 8px; cursor: pointer; text-align: left; }
.resu-g { display: flex; align-items: center; gap: 12px; min-width: 0; }
.resu-vig { width: 36px; height: 36px; border-radius: 10px; flex: 0 0 auto; object-fit: cover;
  background: color-mix(in srgb, var(--lilas) 15%, var(--surface)); display: grid; place-items: center; font-size: 17px; }
.resu-nm { font-size: 13.5px; min-width: 0; }
.resu-nm small { display: block; color: var(--encre-faible); font-size: 11px; margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.resu-add { width: 30px; height: 30px; border-radius: 50%; flex: 0 0 auto;
  background: color-mix(in srgb, var(--lilas) 16%, var(--surface)); color: var(--lilas-clair);
  display: grid; place-items: center; font-size: 18px; font-weight: 600; font-family: ui-rounded, system-ui, sans-serif; }
.etat { text-align: center; color: var(--encre-faible); font-size: 13px; padding: 22px 10px; }

/* étape portion */
#ajout-portion { padding-top: 4px; }
.portion-retour { border: 0; background: transparent; color: var(--lilas-clair); font-size: 14px; font-weight: 600; cursor: pointer; padding: 6px 0; margin-bottom: 6px; font-family: ui-rounded, system-ui, sans-serif; }
.portion-tete { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.portion-nom { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -.01em; }
.etoile { border: 0; background: transparent; color: var(--lilas); font-size: 24px; cursor: pointer; line-height: 1; }
.etoile.on { color: var(--lilas-clair); }
.portion-marque { margin: 4px 0 0; color: var(--encre-douce); font-size: 13px; }
.portion-base { margin: 4px 0 16px; color: var(--encre-faible); font-size: 12px; }
.portion-champ { display: flex; align-items: center; justify-content: space-between; font-size: 14px; margin-bottom: 10px; }
.portion-champ input { width: 120px; text-align: right; background: var(--surface-2);
  border: 1px solid var(--ligne); border-radius: 10px; padding: 11px 12px; font-size: 16px; font-weight: 600; }
.portion-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.portion-chips button { border: 1px solid var(--ligne); background: var(--surface-2); color: var(--encre-douce);
  border-radius: 999px; padding: 7px 13px; font-size: 12.5px; font-weight: 600; cursor: pointer;
  font-family: ui-rounded, system-ui, sans-serif; }
.portion-apercu { display: flex; gap: 8px; margin-bottom: 18px; }
.pa { flex: 1; background: var(--surface); border: 1px solid var(--ligne); border-radius: var(--rayon-s); padding: 12px 8px; text-align: center; }
.pa-n { display: block; font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.pa-k { font-size: 10.5px; color: var(--encre-faible); }
.pa:first-child .pa-n { color: var(--lilas-clair); }
.pa:nth-child(2) .pa-n { color: var(--rose); }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(96px + env(safe-area-inset-bottom));
  z-index: 90; background: var(--encre); color: var(--fond); padding: 11px 18px; border-radius: 999px;
  font-size: 13.5px; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.4);
  display: flex; align-items: center; gap: 14px; max-width: 88vw; }
.toast button { border: 0; background: transparent; color: var(--lilas); font-weight: 700; cursor: pointer; font-size: 13.5px; }

/* ---------- overlay scan ---------- */
.scan-ov { position: fixed; inset: 0; z-index: 80; background: #000;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; }
.scan-ov video { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.scan-cadre { position: relative; z-index: 1; width: 74%; max-width: 320px; aspect-ratio: 1.6;
  border: 2px solid rgba(255,255,255,.85); border-radius: 16px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.45); }
.scan-ov #scan-annuler { position: relative; z-index: 1; width: auto; padding: 12px 26px;
  background: rgba(255,255,255,.14); color: #fff; border-color: rgba(255,255,255,.35); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
