/* =====================================================================
   NUTRI — design system
   Crème & vert basilic, Fraunces (display) + Outfit (UI).
   Mobile-first, immersif (safe-areas), dark mode auto.
   ===================================================================== */

:root {
  --bg: #F3EEE2;
  --card: #FFFFFF;
  --card-2: #FAF7EE;
  --ink: #1C2A21;
  --muted: #7D8779;
  --line: #E6DFCE;
  --green-deep: #12291C;
  --green-mid: #1E5738;
  --green: #1F7A4A;
  --lime: #C9E85C;
  --lime-ink: #2A3B12;
  --p1: #3E7BFA; --p1-soft: #E9F0FE; --p1-ink: #1D4ED8;
  --p2: #F0559B; --p2-soft: #FDECF4; --p2-ink: #BE185D;
  --m-cal: #F08C1B; --m-prot: #E4573D; --m-carb: #E0A82E; --m-fat: #4E9DE0;
  --danger: #D64545;
  --shadow: 0 6px 24px rgba(28, 42, 33, .08);
  --shadow-lg: 0 -8px 40px rgba(18, 41, 28, .18);
  --r: 22px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E1410;
    --card: #17201A;
    --card-2: #1C2620;
    --ink: #EFEAD9;
    --muted: #93A296;
    --line: #26332A;
    --shadow: 0 6px 24px rgba(0, 0, 0, .35);
    --p1-soft: #1A2740; --p2-soft: #3A1B2B;
    --p1-ink: #8FB2FF; --p2-ink: #FF9CC8;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { height: 100%; }
body {
  font-family: 'Outfit', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100%;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: var(--ink); }
[hidden] { display: none !important; }

/* ============================ ÉCRAN PIN ============================ */
.pin-screen {
  min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px;
  padding: calc(var(--sat) + 20px) 24px calc(var(--sab) + 30px);
  background:
    radial-gradient(120% 70% at 80% -10%, #2E7A4C 0%, transparent 55%),
    radial-gradient(100% 60% at 0% 100%, #1C4A30 0%, transparent 50%),
    var(--green-deep);
  color: #F3EEE2;
}
.pin-hero { text-align: center; }
.pin-logo {
  width: 84px; height: 84px; margin: 0 auto 14px;
  display: grid; place-items: center;
  font-size: 42px;
  background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 28px;
  backdrop-filter: blur(8px);
}
.pin-title { font-family: 'Fraunces', serif; font-size: 40px; font-weight: 700; letter-spacing: -.5px; }
.pin-sub { margin-top: 6px; font-size: 15px; opacity: .75; max-width: 260px; }
.pin-dots { display: flex; gap: 14px; height: 16px; margin-top: 8px; }
.dot {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .45);
  transition: all .15s;
}
.dot.on { background: var(--lime); border-color: var(--lime); transform: scale(1.1); }
.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.pin-error { color: #FFB4A2; font-size: 14px; min-height: 20px; font-weight: 500; }
.pin-pad { display: grid; grid-template-columns: repeat(3, 76px); gap: 14px; }
.pin-pad button {
  height: 76px; border-radius: 50%;
  background: rgba(255, 255, 255, .09);
  border: 1px solid rgba(255, 255, 255, .12);
  font-size: 26px; font-weight: 500; color: #F3EEE2;
  transition: transform .06s, background .15s;
}
.pin-pad button:active { transform: scale(.92); background: rgba(255, 255, 255, .2); }
.pin-pad .pin-ghost { background: transparent; border-color: transparent; font-size: 20px; opacity: .7; }
.pin-pad .pin-ok { background: var(--lime); color: var(--lime-ink); font-weight: 700; border: 0; }
.pin-hint { font-size: 12px; opacity: .5; text-align: center; max-width: 250px; }

/* ============================ HEADER ============================ */
.hdr {
  background:
    radial-gradient(130% 90% at 85% -20%, #2E7A4C 0%, transparent 60%),
    radial-gradient(90% 70% at -10% 110%, #1C4A30 0%, transparent 55%),
    var(--green-deep);
  color: #F3EEE2;
  padding: calc(var(--sat) + 14px) 20px 14px;
  border-radius: 0 0 30px 30px;
  position: relative;
  z-index: 5;
}
.hdr-top { display: flex; align-items: center; justify-content: space-between; }
.hdr-greet { font-size: 13px; font-weight: 600; color: var(--lime); letter-spacing: .4px; text-transform: uppercase; }
.hdr-title { font-family: 'Fraunces', serif; font-size: 30px; font-weight: 650; letter-spacing: -.5px; line-height: 1.15; }
.hdr-gear {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, .15);
}
.hdr-gear svg { width: 21px; height: 21px; }
.hdr-week {
  margin-top: 12px;
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 16px;
  padding: 4px;
}
.wk-arrow { width: 42px; height: 38px; font-size: 24px; line-height: 1; border-radius: 12px; opacity: .85; }
.wk-arrow:active { background: rgba(255, 255, 255, .12); }
.wk-label { flex: 1; font-weight: 600; font-size: 14.5px; height: 38px; border-radius: 12px; }
.wk-label small { display: block; font-size: 10.5px; font-weight: 500; opacity: .6; text-transform: uppercase; letter-spacing: .5px; }

/* ============================ BANDEAU JOURS ============================ */
.daysbar {
  display: flex; gap: 8px;
  padding: 14px 16px 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.daysbar::-webkit-scrollbar { display: none; }
.daychip {
  flex: 0 0 46px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 7px;
  border-radius: 16px;
  background: var(--card);
  border: 1.5px solid var(--line);
  box-shadow: var(--shadow);
  transition: transform .1s;
}
.daychip:active { transform: scale(.94); }
.daychip small { font-size: 10.5px; font-weight: 600; text-transform: uppercase; color: var(--muted); }
.daychip b { font-family: 'Fraunces', serif; font-size: 17px; font-weight: 650; }
.daychip .dcdots { display: flex; gap: 3px; height: 5px; margin-top: 1px; }
.daychip .dcdots i { width: 5px; height: 5px; border-radius: 50%; }
.daychip.today { border-color: var(--green); }
.daychip.active { background: var(--lime); border-color: var(--lime); }
.daychip.active small, .daychip.active b { color: var(--lime-ink); }

/* ============================ LAYOUT ============================ */
#main { padding: 12px 16px calc(var(--sab) + 110px); }
.view { display: flex; flex-direction: column; gap: 16px; }

/* ============================ TAB BAR ============================ */
.tabbar {
  position: fixed;
  left: 14px; right: 14px;
  bottom: calc(var(--sab) + 12px);
  display: flex;
  background: color-mix(in srgb, var(--card) 82%, transparent);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--line);
  border-radius: 26px;
  padding: 7px;
  box-shadow: 0 10px 34px rgba(18, 41, 28, .22);
  z-index: 40;
}
.tab {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 0 7px;
  border-radius: 19px;
  color: var(--muted);
  position: relative;
  transition: background .15s, color .15s;
}
.tab svg { width: 22px; height: 22px; }
.tab span { font-size: 10.5px; font-weight: 600; letter-spacing: .2px; }
.tab.active { background: var(--green-deep); color: var(--lime); }
.tab-badge {
  position: absolute; top: 4px; right: calc(50% - 22px);
  min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 9px;
  background: var(--m-prot); color: #fff;
  font-size: 10px; font-weight: 700; font-style: normal;
  display: grid; place-items: center;
}

/* ============================ CARTES GÉNÉRIQUES ============================ */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.section-title {
  font-family: 'Fraunces', serif;
  font-size: 20px; font-weight: 650;
  display: flex; align-items: center; justify-content: space-between;
}
.section-title .stlink { font-family: 'Outfit'; font-size: 13px; font-weight: 600; color: var(--green); }

/* ============================ VUE JOUR ============================ */
.person-card { border-top: 4px solid var(--pc, var(--p1)); }
.person-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px 10px;
}
.avatar {
  width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700; font-size: 17px; color: #fff;
  background: var(--pc, var(--p1));
  flex-shrink: 0;
}
.person-head .pinfo { flex: 1; min-width: 0; }
.person-head .pname { font-weight: 700; font-size: 16.5px; }
.person-head .psub { font-size: 12px; color: var(--muted); }
.ring-wrap { position: relative; width: 62px; height: 62px; flex-shrink: 0; }
.ring-wrap svg { width: 62px; height: 62px; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--line); stroke-width: 6; }
.ring-plan { fill: none; stroke: color-mix(in srgb, var(--pc) 30%, transparent); stroke-width: 6; stroke-linecap: round; transition: stroke-dashoffset .6s ease; }
.ring-eat { fill: none; stroke: var(--pc); stroke-width: 6; stroke-linecap: round; transition: stroke-dashoffset .6s ease; }
.ring-txt {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  line-height: 1;
}
.ring-txt b { font-size: 14px; font-family: 'Fraunces', serif; }
.ring-txt small { font-size: 8.5px; color: var(--muted); text-transform: uppercase; margin-top: 1px; }
.macro-row { display: flex; gap: 8px; padding: 0 16px 12px; }
.macro-pill {
  flex: 1;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 7px 6px 6px;
  text-align: center;
}
.macro-pill b { font-size: 13.5px; display: block; }
.macro-pill small { font-size: 9.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .3px; color: var(--muted); }
.macro-pill .bar { display: block; height: 3.5px; border-radius: 2px; background: var(--line); margin-top: 5px; overflow: hidden; }
.macro-pill .bar i { display: block; height: 100%; border-radius: 2px; background: var(--mc); transition: width .5s ease; }

.slots { padding: 4px 12px 12px; display: flex; flex-direction: column; gap: 8px; }
.slot-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px;
  color: var(--muted);
  padding: 6px 4px 0;
  display: flex; justify-content: space-between; align-items: center;
}
.slot-add { color: var(--pc, var(--green)); font-size: 12px; font-weight: 600; padding: 4px 6px; border-radius: 8px; }
.meal-card {
  display: flex; align-items: center; gap: 11px;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 10px 12px;
}
.meal-emoji {
  width: 42px; height: 42px; flex-shrink: 0;
  display: grid; place-items: center;
  font-size: 22px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 13px;
}
.meal-info { flex: 1; min-width: 0; }
.meal-name { font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meal-macros { display: flex; gap: 8px; font-size: 11px; color: var(--muted); margin-top: 2px; flex-wrap: wrap; }
.meal-macros b { font-weight: 600; }
.meal-eat {
  width: 34px; height: 34px; flex-shrink: 0;
  border-radius: 50%;
  border: 2px solid var(--line);
  display: grid; place-items: center;
  color: transparent;
  transition: all .15s;
}
.meal-eat svg { width: 16px; height: 16px; }
.meal-eat.on { background: var(--green); border-color: var(--green); color: #fff; }
.meal-card.eaten { opacity: .65; }
.meal-card.eaten .meal-name { text-decoration: line-through; }
.empty-slot {
  border: 1.5px dashed var(--line);
  border-radius: 16px;
  padding: 11px;
  text-align: center;
  color: var(--muted);
  font-size: 13px; font-weight: 500;
}
.empty-slot:active { background: var(--card-2); }

/* ============================ VUE SEMAINE ============================ */
.wday-card { padding: 13px 15px; }
.wday-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.wday-head b { font-family: 'Fraunces', serif; font-size: 16.5px; }
.wday-head small { color: var(--muted); font-size: 12px; }
.wday-head .wsum { margin-left: auto; font-size: 11px; color: var(--muted); font-weight: 600; }
.wmeals { display: flex; flex-direction: column; gap: 5px; }
.wmeal {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px;
  padding: 6px 9px;
  border-radius: 11px;
  background: var(--soft);
  color: var(--tint);
  font-weight: 600;
}
.wmeal .wslot { font-size: 9.5px; font-weight: 700; text-transform: uppercase; opacity: .65; flex-shrink: 0; width: 30px; }
.wmeal .wname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wempty { color: var(--muted); font-size: 12.5px; font-style: italic; padding: 2px 4px; }
.btn-dup {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--card);
  border: 1.5px dashed var(--green);
  color: var(--green);
  border-radius: 16px;
  padding: 13px;
  font-weight: 600; font-size: 14px;
}

/* ============================ VUE RECETTES ============================ */
.recipes-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.recipe-card { padding: 14px 13px 12px; display: flex; flex-direction: column; gap: 8px; }
.recipe-card .remoji { font-size: 34px; }
.recipe-card .rname { font-weight: 650; font-size: 14.5px; line-height: 1.25; }
.recipe-card .rkcal {
  align-self: flex-start;
  font-size: 11px; font-weight: 700;
  background: var(--card-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 3px 8px;
  color: var(--m-cal);
}
.search-row {
  display: flex; gap: 8px;
}
.search-row input {
  flex: 1;
  background: var(--card); border: 1.5px solid var(--line);
  border-radius: 15px; padding: 12px 16px;
  outline: none; font-size: 15px;
}
.search-row input:focus { border-color: var(--green); }

/* ============================ VUE COURSES ============================ */
.shop-progress { padding: 15px 16px; }
.shop-progress .sp-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 9px; }
.shop-progress .sp-top b { font-family: 'Fraunces', serif; font-size: 18px; }
.shop-progress .sp-top small { color: var(--muted); font-weight: 600; font-size: 12.5px; }
.sp-bar { height: 9px; border-radius: 5px; background: var(--line); overflow: hidden; }
.sp-bar i { display: block; height: 100%; border-radius: 5px; background: linear-gradient(90deg, var(--green), var(--lime)); transition: width .4s ease; }
.shop-actions { display: flex; gap: 9px; }
.sbtn {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 17px; padding: 12px 4px 10px;
  box-shadow: var(--shadow);
  font-size: 11px; font-weight: 600; color: var(--ink);
}
.sbtn svg { width: 21px; height: 21px; }
.sbtn:active { transform: scale(.96); }
.sbtn.carrefour { background: #004E9F; border-color: #004E9F; color: #fff; }
.sbtn.carrefour .clogo { font-weight: 800; font-size: 19px; line-height: 21px; font-family: 'Fraunces', serif; color: #E30613; background: #fff; width: 21px; height: 21px; border-radius: 6px; display: grid; place-items: center; }
.shop-group-head {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 13.5px;
  padding: 4px 6px 0;
  color: var(--muted);
  text-transform: uppercase; letter-spacing: .6px; font-size: 11.5px;
}
.shop-items { display: flex; flex-direction: column; }
.shop-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.shop-item:last-child { border-bottom: 0; }
.scheck {
  width: 27px; height: 27px; flex-shrink: 0;
  border-radius: 9px;
  border: 2px solid color-mix(in srgb, var(--muted) 50%, transparent);
  display: grid; place-items: center;
  color: transparent;
  transition: all .13s;
}
.scheck svg { width: 15px; height: 15px; }
.scheck.on { background: var(--green); border-color: var(--green); color: #fff; }
.shop-item .sname { flex: 1; font-weight: 600; font-size: 14.5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shop-item.done .sname { text-decoration: line-through; color: var(--muted); font-weight: 500; }
.shop-item .sqty {
  font-size: 12px; font-weight: 700;
  background: var(--card-2); border: 1px solid var(--line);
  padding: 4px 9px; border-radius: 9px;
  color: var(--muted);
  flex-shrink: 0;
}
.scarrefour {
  width: 32px; height: 32px; flex-shrink: 0;
  border-radius: 10px;
  background: #EAF2FB;
  color: #004E9F;
  display: grid; place-items: center;
  font-weight: 800; font-size: 15px;
  font-family: 'Fraunces', serif;
}
@media (prefers-color-scheme: dark) { .scarrefour { background: #1B2A3D; color: #7FB3E8; } }
.sdel { width: 30px; height: 30px; color: var(--muted); display: grid; place-items: center; flex-shrink: 0; }
.sdel svg { width: 16px; height: 16px; }
.shop-add { display: flex; gap: 8px; padding: 12px 14px; }
.shop-add input[type="text"] { flex: 1; min-width: 0; background: var(--card-2); border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 13px; outline: none; }
.shop-add input[type="number"] { width: 58px; background: var(--card-2); border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 6px; text-align: center; outline: none; }
.shop-add select { width: 58px; background: var(--card-2); border: 1.5px solid var(--line); border-radius: 12px; outline: none; text-align: center; }
.shop-add button {
  width: 44px; border-radius: 12px;
  background: var(--green-deep); color: var(--lime);
  font-size: 22px; font-weight: 600;
  flex-shrink: 0;
}
.empty-state { text-align: center; padding: 36px 20px; color: var(--muted); }
.empty-state .es-emoji { font-size: 44px; margin-bottom: 10px; }
.empty-state p { font-size: 14px; max-width: 240px; margin: 0 auto; }
.empty-state button { margin-top: 14px; color: var(--green); font-weight: 600; font-size: 14px; }

/* ============================ MODE MAGASIN ============================ */
.store {
  position: fixed; inset: 0; z-index: 60;
  background: var(--green-deep);
  color: #F3EEE2;
  display: flex; flex-direction: column;
}
.store-head {
  padding: calc(var(--sat) + 14px) 18px 12px;
  display: flex; align-items: center; justify-content: space-between;
}
.store-head h2 { font-family: 'Fraunces', serif; font-size: 22px; }
.store-head .st-count { font-size: 13px; opacity: .7; }
.store-close {
  width: 42px; height: 42px; border-radius: 50%;
  background: rgba(255, 255, 255, .12);
  font-size: 19px;
}
.store-list { flex: 1; overflow-y: auto; padding: 4px 14px calc(var(--sab) + 24px); }
.store-cat { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; opacity: .55; padding: 16px 6px 8px; }
.store-item {
  width: 100%;
  display: flex; align-items: center; gap: 14px;
  background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: 18px;
  padding: 15px 16px;
  margin-bottom: 8px;
  text-align: left;
  color: inherit;
}
.store-item .stcheck {
  width: 30px; height: 30px; flex-shrink: 0;
  border-radius: 10px;
  border: 2px solid rgba(255, 255, 255, .35);
  display: grid; place-items: center;
  color: transparent;
}
.store-item .stcheck svg { width: 17px; height: 17px; }
.store-item.done { opacity: .4; }
.store-item.done .stcheck { background: var(--lime); border-color: var(--lime); color: var(--lime-ink); }
.store-item.done .stname { text-decoration: line-through; }
.store-item .stname { flex: 1; font-size: 17px; font-weight: 600; }
.store-item .stqty { font-size: 13px; font-weight: 700; opacity: .75; }

/* ============================ BOTTOM SHEET ============================ */
.sheet-overlay {
  position: fixed; inset: 0; z-index: 48;
  background: rgba(10, 20, 14, .55);
  opacity: 0;
  transition: opacity .25s;
}
.sheet-overlay.show { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: var(--card);
  border-radius: 28px 28px 0 0;
  box-shadow: var(--shadow-lg);
  transform: translateY(105%);
  transition: transform .3s cubic-bezier(.32, .72, .25, 1);
  max-height: 92dvh;
  display: flex; flex-direction: column;
}
.sheet.show { transform: translateY(0); }
.sheet-grip {
  width: 40px; height: 4.5px; border-radius: 3px;
  background: var(--line);
  margin: 10px auto 2px;
  flex-shrink: 0;
}
.sheet-body { overflow-y: auto; padding: 10px 20px calc(var(--sab) + 22px); }
.sheet-title {
  font-family: 'Fraunces', serif; font-size: 21px; font-weight: 650;
  margin-bottom: 14px;
  display: flex; align-items: center; justify-content: space-between;
}
.sheet-title .st-x { width: 34px; height: 34px; border-radius: 50%; background: var(--card-2); border: 1px solid var(--line); font-size: 15px; font-family: 'Outfit'; }

/* ---- Formulaires ---- */
.f-label { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 15px 0 6px; display: block; }
.f-input, .f-select {
  width: 100%;
  background: var(--card-2);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  outline: none;
  font-size: 15px;
  appearance: none;
}
.f-input:focus, .f-select:focus { border-color: var(--green); }
.f-row { display: flex; gap: 9px; }
.f-row > * { flex: 1; min-width: 0; }
.seg {
  display: flex; gap: 5px;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 4px;
}
.seg button {
  flex: 1;
  padding: 9px 4px;
  border-radius: 10px;
  font-size: 13px; font-weight: 600;
  color: var(--muted);
}
.seg button.on { background: var(--green-deep); color: var(--lime); }
.seg.seg-person button.on[data-v="p1"] { background: var(--p1); color: #fff; }
.seg.seg-person button.on[data-v="p2"] { background: var(--p2); color: #fff; }
.macro-inputs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.macro-inputs .mi { text-align: center; }
.macro-inputs input {
  width: 100%; text-align: center;
  background: var(--card-2); border: 1.5px solid var(--line);
  border-radius: 12px; padding: 10px 4px;
  outline: none; font-size: 15px; font-weight: 600;
}
.macro-inputs small { font-size: 9.5px; font-weight: 700; text-transform: uppercase; color: var(--mc, var(--muted)); display: block; margin-top: 4px; }
.ing-row { display: flex; gap: 7px; margin-bottom: 8px; align-items: center; }
.ing-row .f-input { flex: 1; padding: 10px 12px; }
.ing-row .ing-qty { width: 62px; flex: none; text-align: center; padding: 10px 4px; }
.ing-row .ing-unit { width: 58px; flex: none; text-align: center; padding: 10px 2px; }
.ing-row .ing-del, .ing-row .ing-off {
  width: 34px; height: 34px; flex-shrink: 0;
  border-radius: 10px;
  display: grid; place-items: center;
}
.ing-row .ing-del { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.ing-row .ing-off { color: var(--green); background: color-mix(in srgb, var(--green) 12%, transparent); font-size: 14px; }
.ing-row .ing-del svg { width: 15px; height: 15px; }
.ing-macros-hint { font-size: 10px; color: var(--green); margin: -5px 0 8px 4px; font-weight: 600; }
.ing-macros-hint.searching { color: var(--muted); }
.ing-tip { font-size: 12px; color: var(--muted); margin: 2px 0 10px; line-height: 1.4; }
.btn-scan {
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 9px;
  background: var(--green-mid); color: #fff;
  border-radius: 15px; padding: 13px;
  font-weight: 700; font-size: 14.5px; margin-top: 8px;
  transition: transform .08s;
}
.btn-scan:active { transform: scale(.97); }
.btn-scan svg { width: 19px; height: 19px; }
.auto-badge {
  display: inline-block;
  font-family: 'Outfit', sans-serif; font-size: 10px; font-weight: 700;
  color: var(--green); background: color-mix(in srgb, var(--green) 15%, transparent);
  padding: 2px 7px; border-radius: 7px;
  text-transform: none; letter-spacing: .2px; vertical-align: middle; margin-left: 6px;
}
.btn-primary {
  width: 100%;
  background: var(--green-deep); color: var(--lime);
  border-radius: 17px;
  padding: 15px;
  font-size: 16px; font-weight: 700;
  margin-top: 18px;
  transition: transform .08s;
}
.btn-primary:active { transform: scale(.97); }
.btn-secondary {
  width: 100%;
  background: var(--card-2); color: var(--ink);
  border: 1.5px solid var(--line);
  border-radius: 17px;
  padding: 13px;
  font-size: 14.5px; font-weight: 600;
  margin-top: 10px;
}
.btn-danger-line { width: 100%; color: var(--danger); font-weight: 600; font-size: 14px; padding: 13px; margin-top: 6px; }
.sheet-list { display: flex; flex-direction: column; gap: 8px; }
.sheet-list .sl-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 11px 13px;
  text-align: left;
  width: 100%;
}
.sheet-list .sl-item .sle { font-size: 24px; flex-shrink: 0; }
.sheet-list .sl-item .sln { flex: 1; font-weight: 600; font-size: 14.5px; min-width: 0; }
.sheet-list .sl-item .sln small { display: block; font-weight: 500; color: var(--muted); font-size: 11.5px; }
.sheet-list img.sl-img { width: 42px; height: 42px; border-radius: 10px; object-fit: cover; background: var(--card-2); flex-shrink: 0; }
.off-loading { text-align: center; color: var(--muted); padding: 20px; font-size: 14px; }

/* ---- Réglages ---- */
.set-person {
  border: 1px solid var(--line);
  border-left: 4px solid var(--pc);
  border-radius: 16px;
  padding: 13px 14px;
  margin-bottom: 12px;
  background: var(--card-2);
}
.set-person .f-label { margin-top: 10px; }
.set-person .f-label:first-child { margin-top: 0; }

/* ============================ TOAST ============================ */
.toast {
  position: fixed;
  left: 50%; transform: translateX(-50%) translateY(20px);
  bottom: calc(var(--sab) + 96px);
  background: var(--green-deep);
  color: #F3EEE2;
  padding: 12px 22px;
  border-radius: 16px;
  font-size: 14px; font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .3);
  z-index: 70;
  opacity: 0;
  transition: all .25s;
  pointer-events: none;
  max-width: 88vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============================ DIVERS ============================ */
.fade-in { animation: fadeIn .25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Éléments réservés au layout desktop (masqués en mobile) */
.side-brand, .side-settings { display: none; }

/* ============================ SCANNER CODE-BARRES ============================ */
.scan {
  position: fixed; inset: 0; z-index: 65;
  background: #080C09;
  color: #F3EEE2;
  display: flex; flex-direction: column;
}
.scan-head {
  padding: calc(var(--sat) + 14px) 18px 12px;
  display: flex; align-items: center; justify-content: space-between;
  position: relative; z-index: 3;
}
.scan-head h2 { font-family: 'Fraunces', serif; font-size: 20px; }
.scan-close { width: 42px; height: 42px; border-radius: 50%; background: rgba(255, 255, 255, .14); font-size: 18px; }
.scan-video-wrap { position: relative; flex: 1; overflow: hidden; background: #000; margin-top: -60px; }
.scan-video-wrap video { width: 100%; height: 100%; object-fit: cover; }
.scan-frame { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.scan-box {
  width: 78%; max-width: 440px; height: 160px;
  border: 3px solid rgba(255, 255, 255, .9);
  border-radius: 18px;
  box-shadow: 0 0 0 2000px rgba(0, 0, 0, .5);
  position: relative; overflow: hidden;
}
.scan-laser { position: absolute; left: 5%; right: 5%; height: 3px; border-radius: 2px; background: var(--lime); box-shadow: 0 0 14px var(--lime); animation: laser 2.1s ease-in-out infinite; }
@keyframes laser { 0%, 100% { top: 14%; } 50% { top: 84%; } }
.scan-hint { position: absolute; bottom: 22px; left: 0; right: 0; text-align: center; font-size: 13.5px; opacity: .85; padding: 0 24px; }
.scan-foot { padding: 16px 20px calc(var(--sab) + 20px); background: #080C09; }
.scan-status { text-align: center; font-size: 14px; min-height: 20px; margin-bottom: 12px; font-weight: 600; }
.scan-status.err { color: #FFB4A2; }
.scan-status.ok { color: var(--lime); }
.scan-manual { display: flex; gap: 8px; }
.scan-manual input { flex: 1; min-width: 0; background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .16); border-radius: 12px; padding: 12px 14px; color: #fff; outline: none; font-size: 15px; }
.scan-manual input::placeholder { color: rgba(255, 255, 255, .45); }
.scan-manual button { background: var(--lime); color: var(--lime-ink); border-radius: 12px; padding: 0 20px; font-weight: 700; flex-shrink: 0; }
.scan-manual-label { text-align: center; font-size: 12px; opacity: .55; margin-bottom: 8px; }

@media (min-width: 760px) and (max-width: 999px) {
  #main, .daysbar { max-width: 640px; margin-left: auto; margin-right: auto; }
  .hdr { border-radius: 0 0 34px 34px; }
  .hdr-top, .hdr-week { max-width: 600px; margin-left: auto; margin-right: auto; }
  .tabbar { max-width: 480px; left: 50%; transform: translateX(-50%); right: auto; width: 100%; }
  .sheet { max-width: 640px; left: 50%; transform: translateX(-50%) translateY(105%); }
  .sheet.show { transform: translateX(-50%) translateY(0); }
  .recipes-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ============================ LAYOUT DESKTOP (sidebar + colonnes) ============================ */
@media (min-width: 1000px) {
  body { background: var(--bg); }

  /* --- Sidebar (ex-tabbar) --- */
  .side-brand { display: flex; align-items: center; gap: 11px; padding: 4px 14px 20px; }
  .side-brand-logo { font-size: 27px; }
  .side-brand-name { font-family: 'Fraunces', serif; font-size: 25px; font-weight: 700; letter-spacing: -.3px; }
  .side-settings { display: flex !important; margin-top: auto; }

  .tabbar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 252px; height: 100vh;
    flex-direction: column; align-items: stretch; justify-content: flex-start;
    gap: 5px;
    border: 0; border-right: 1px solid var(--line); border-radius: 0;
    background: var(--card);
    backdrop-filter: none; -webkit-backdrop-filter: none;
    box-shadow: none;
    padding: 26px 16px;
    transform: none; max-width: none; right: auto;
    z-index: 45;
  }
  .tab {
    flex: 0 0 auto; flex-direction: row; justify-content: flex-start;
    gap: 15px; padding: 13px 16px; border-radius: 14px;
  }
  .tab svg { width: 23px; height: 23px; }
  .tab span { font-size: 15px; font-weight: 600; }
  .tab:hover { background: var(--card-2); }
  .tab.active, .tab.active:hover { background: var(--green-deep); color: var(--lime); }
  .tab-badge { position: static; margin-left: auto; top: auto; right: auto; }

  /* --- Contenu décalé à droite --- */
  .hdr {
    margin-left: 252px; border-radius: 0 0 30px 30px;
    padding-left: 44px; padding-right: 44px; padding-top: 26px; padding-bottom: 20px;
  }
  .hdr-top, .hdr-week { max-width: none; margin-left: 0; margin-right: 0; }
  .hdr-week { margin-top: 16px; max-width: 560px; }
  .hdr-title { font-size: 34px; }
  .daysbar { margin-left: 252px; max-width: none; margin-right: 0; padding: 18px 44px 4px; gap: 10px; }
  .daychip { flex: 0 0 62px; }
  #main { margin-left: 252px; max-width: 1120px; margin-right: 0; padding: 24px 44px 60px; }

  /* --- Vue Jour : les deux profils côte à côte --- */
  #view-day { flex-direction: row; align-items: flex-start; gap: 22px; }
  #view-day .person-card { flex: 1 1 0; min-width: 0; }

  /* --- Vue Semaine : grille 2 colonnes --- */
  #view-week { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
  #view-week .btn-dup { grid-column: 1 / -1; }

  /* --- Recettes : plus large --- */
  .recipes-grid { grid-template-columns: repeat(4, 1fr); gap: 16px; }
  .view > .search-row, .view > .section-title { max-width: 900px; }

  /* --- Courses : liste lisible + confortable --- */
  #view-shop { max-width: 760px; }

  /* --- Feuilles larges, centrées dans la zone de contenu (droite de la sidebar) --- */
  .sheet {
    left: 252px; right: 0;
    margin-left: auto; margin-right: auto;
    width: min(860px, calc(100vw - 252px - 64px));
    max-width: none;
    border-radius: 26px;
    transform: translateY(105%);
    max-height: 92dvh;
  }
  .sheet.show { transform: translateY(0); }
  .sheet-overlay { z-index: 48; }
  .sheet-body { padding-left: 30px; padding-right: 30px; }
  .sheet-title { font-size: 23px; }
  /* Réglages : les deux profils côte à côte */
  .set-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
  .set-grid .set-person { margin-bottom: 0; }
  /* Repas : ingrédients et macros profitent de la largeur */
  .macro-inputs { gap: 12px; }
  .ing-row .f-input { padding: 12px 14px; }

  /* Le bouton réglages du header devient superflu (présent dans la sidebar) */
  .hdr-gear { display: none; }
}
