:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #f0efe9;
  --text: #1d2420;
  --muted: #5f6b64;
  --border: #dedcd4;
  --accent: #2f7d4f;
  --accent-contrast: #ffffff;
  --danger: #b3261e;
  --warn: #8a5a00;
  --carbs: #d98b1f;
  --fat: #c9483b;
  --protein: #3569b8;
  --ok: #2f7d4f;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 2px 8px rgb(0 0 0 / 4%);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141816;
    --surface: #1d2320;
    --surface-2: #262d29;
    --text: #e8ece9;
    --muted: #9ba8a0;
    --border: #333c37;
    --accent: #5dbb84;
    --accent-contrast: #0f1a13;
    --danger: #f2877e;
    --warn: #e0b04d;
    --carbs: #eba64a;
    --fat: #ec7d70;
    --protein: #7da6ea;
    --ok: #5dbb84;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141816;
  --surface: #1d2320;
  --surface-2: #262d29;
  --text: #e8ece9;
  --muted: #9ba8a0;
  --border: #333c37;
  --accent: #5dbb84;
  --accent-contrast: #0f1a13;
  --danger: #f2877e;
  --warn: #e0b04d;
  --carbs: #eba64a;
  --fat: #ec7d70;
  --protein: #7da6ea;
  --ok: #5dbb84;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}

h1, h2, h3 { line-height: 1.2; margin: 0 0 .6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .6rem; }
a { color: var(--accent); }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.warn { color: var(--warn); }

/* En-tête ---------------------------------------------------------------- */

.app-header {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .6rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1.15rem; }
.tabs { display: flex; gap: .25rem; margin-left: auto; }
.tab {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  padding: .45rem .8rem;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}
.tab svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab-more svg { stroke-width: 3.2; }
.tab.active { background: var(--accent); color: var(--accent-contrast); }
.more-menu {
  position: absolute;
  right: 1rem;
  top: calc(100% + .3rem);
  z-index: 30;
  display: flex;
  flex-direction: column;
  min-width: 17rem;
  padding: .35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .18);
}
.more-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: .1rem;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  padding: .65rem .8rem;
  border-radius: 10px;
  cursor: pointer;
}
.more-item span { color: var(--muted); font-size: .85rem; }
.more-item:hover, .more-item:focus-visible { background: var(--surface-2); }
.more-item.active strong { color: var(--accent); }

/* iPad et téléphone : barre d'onglets en bas, à portée de pouce */
@media (max-width: 1024px) {
  .app-header { position: static; justify-content: center; padding: .5rem 1rem; }
  .brand { font-size: 1.05rem; }
  .tabs {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    margin: 0;
    gap: 0;
    padding: .3rem .4rem calc(.3rem + env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, .06);
  }
  .tab { flex: 1 1 0; flex-direction: column; gap: .15rem; padding: .35rem .2rem; border-radius: 12px; font-size: .78rem; }
  .tab svg { width: 1.45rem; height: 1.45rem; }
  .tab.active { background: none; color: var(--accent); }
  .tab.active svg { background: color-mix(in srgb, var(--accent) 14%, transparent); border-radius: 999px; padding: .1rem .7rem; width: 3rem; box-sizing: content-box; }
  .more-menu {
    position: fixed;
    top: auto;
    left: .6rem;
    right: .6rem;
    bottom: calc(4.4rem + env(safe-area-inset-bottom));
    min-width: 0;
  }
  body { padding-bottom: calc(4.6rem + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(5.2rem + env(safe-area-inset-bottom)); }
}

.to-top {
  position: fixed;
  right: 1rem;
  bottom: calc(1.2rem + env(safe-area-inset-bottom));
  z-index: 15;
  width: 2.8rem;
  height: 2.8rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--accent);
  font-size: 1.3rem;
  font-weight: 700;
  box-shadow: var(--shadow);
  cursor: pointer;
}
@media (max-width: 1024px) {
  .to-top { bottom: calc(5.2rem + env(safe-area-inset-bottom)); }
}

/* Mise en page ----------------------------------------------------------- */

main { max-width: 1100px; margin: 0 auto; padding: 1rem; }
.view { display: flex; flex-direction: column; gap: 1rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}

.card-grid { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.recipe-card { display: block; width: 100%; font: inherit; text-align: left; color: inherit; cursor: pointer; transition: border-color .15s; }
.recipe-card:hover { border-color: var(--accent); }
.recipe-card h3 { margin: 0; }
.card-top { display: flex; justify-content: space-between; gap: .5rem; align-items: start; margin-bottom: .3rem; }
.per-serving { margin: .4rem 0; }

.badge {
  font-size: .72rem;
  padding: .15rem .5rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}

.toolbar { display: flex; gap: .6rem; flex-wrap: wrap; }
.toolbar > input, .toolbar > select { flex: 1 1 200px; }

.empty { text-align: center; padding: 2rem 1rem; }
.empty-inline { padding: .5rem 0; margin: 0; }

.notice {
  background: var(--surface-2);
  border-radius: 10px;
  padding: .6rem .8rem;
  margin: 0;
  font-size: .92rem;
}

/* Formulaires ------------------------------------------------------------ */

input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .55rem .7rem;
  width: 100%;
  min-width: 0;
}
input:focus, select:focus, textarea:focus, button:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
input:disabled, select:disabled { background: var(--surface-2); color: var(--text); opacity: 1; }
textarea { resize: vertical; }
label { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; color: var(--muted); }
label > input, label > select, label > textarea { color: var(--text); }

.grid-2, .grid-3 { display: grid; gap: .7rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-card { display: flex; flex-direction: column; gap: .8rem; }
.name-field input { font-size: 1.15rem; font-weight: 600; }

@media (max-width: 480px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-3 > :first-child { grid-column: 1 / -1; }
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .3rem;
  font: inherit;
  font-weight: 600;
  padding: .55rem .95rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.small-btn { padding: .3rem .7rem; font-size: .85rem; }

.icon-btn {
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 1rem;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  cursor: pointer;
  flex: none;
}
.icon-btn:hover { background: var(--surface-2); }

.link {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font-weight: 600;
}
.link:not(:disabled):hover { color: var(--accent); text-decoration: underline; }
.link:disabled { cursor: default; }

.segmented {
  display: inline-flex;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
  align-self: flex-start;
  max-width: 100%;
  flex-wrap: wrap;
}
.segmented button {
  border: 0;
  background: none;
  font: inherit;
  font-size: .9rem;
  color: var(--muted);
  padding: .35rem .75rem;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}
.segmented button.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
.segmented.small button { font-size: .82rem; padding: .3rem .55rem; }

.dialog-actions { display: flex; gap: .6rem; justify-content: flex-end; flex-wrap: wrap; margin-top: .8rem; }
.dialog-actions.left { justify-content: flex-start; }
.spacer { flex: 1; }

/* Couleurs des macronutriments ------------------------------------------ */

.chips { display: flex; gap: .35rem; flex-wrap: wrap; }
.chip {
  font-size: .78rem;
  font-weight: 600;
  padding: .1rem .45rem;
  border-radius: 6px;
  background: var(--surface-2);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.chip.carbs, .carbs { color: var(--carbs); }
.chip.fat, .fat { color: var(--fat); }
.chip.protein, .protein { color: var(--protein); }
.dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; margin-right: .35rem; vertical-align: baseline; }
.dot.carbs { background: var(--carbs); }
.dot.fat { background: var(--fat); }
.dot.protein { background: var(--protein); }

.macro-bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--surface-2); gap: 2px; }
.macro-bar .seg.carbs { background: var(--carbs); }
.macro-bar .seg.fat { background: var(--fat); }
.macro-bar .seg.protein { background: var(--protein); }
.macro-legend { display: flex; flex-wrap: wrap; gap: .3rem .9rem; font-size: .82rem; color: var(--muted); margin-top: .45rem; }

/* Recette ---------------------------------------------------------------- */

.recipe-head { display: flex; justify-content: space-between; align-items: center; gap: .6rem; flex-wrap: wrap; }
.recipe-head .actions { display: flex; gap: .5rem; }
.back { text-decoration: none; font-weight: 600; }

.recipe-layout { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }
.recipe-main { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.recipe-side { position: sticky; top: 5rem; }
@media (max-width: 860px) {
  .recipe-layout { grid-template-columns: minmax(0, 1fr); }
  .recipe-side { position: static; order: -1; }
}

.section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .6rem; }
.section-head h2 { margin: 0; }

.ingredient-list, .import-list, .picker-results { list-style: none; margin: 0; padding: 0; }
.ingredient {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 7.5rem auto;
  grid-template-areas: "name qty remove" "values values values";
  gap: .3rem .6rem;
  align-items: center;
  padding: .65rem 0;
  border-bottom: 1px solid var(--border);
}
.ingredient:last-child { border-bottom: 0; }
.ingredient.missing { color: var(--warn); }
.ingredient .ing-name { grid-area: name; }
.ing-name { display: flex; flex-direction: column; min-width: 0; }
.ingredient .ing-qty { grid-area: qty; }
.ing-qty { flex-direction: row; align-items: center; gap: .3rem; }
.ing-qty input { text-align: right; padding: .4rem .5rem; }
.ingredient .ing-values { grid-area: values; }
.ing-values { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.ing-values .kcal { font-size: .82rem; color: var(--muted); margin-right: .2rem; font-variant-numeric: tabular-nums; }
.ingredient .icon-btn { grid-area: remove; }
.ingredient:not(:has(.icon-btn)) { grid-template-columns: minmax(0, 1fr) 7.5rem; grid-template-areas: "name qty" "values values"; }
.total-weight { margin: .6rem 0 0; }

.steps { margin: 0; padding-left: 1.3rem; display: flex; flex-direction: column; gap: .4rem; }

.summary-card h2 { margin-bottom: .7rem; }
.big-kcal { font-size: 2rem; font-weight: 700; margin: .7rem 0 0; font-variant-numeric: tabular-nums; }
.nutri-table { width: 100%; border-collapse: collapse; margin: .6rem 0 1rem; font-variant-numeric: tabular-nums; }
.nutri-table th { text-align: left; font-weight: 600; padding: .35rem 0; color: var(--text); }
.nutri-table td { text-align: right; padding: .35rem 0; font-weight: 600; }
.nutri-table tr { border-bottom: 1px solid var(--border); }
.nutri-table tr.sub th { font-weight: 400; padding-left: 1rem; color: var(--muted); }
.nutri-table tr.sub td { font-weight: 400; color: var(--muted); }
.small-title { font-size: .85rem; color: var(--muted); font-weight: 600; margin-bottom: .45rem; }

/* Bibliothèque ------------------------------------------------------------ */

.food-table { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.food-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) repeat(6, 4.2rem);
  gap: .4rem;
  align-items: center;
  padding: .55rem .9rem;
  font-variant-numeric: tabular-nums;
}
.food-row > span:not(:first-child) { text-align: right; }
.food-row.head { font-size: .8rem; font-weight: 700; color: var(--muted); background: var(--surface-2); }
.food-item { border-top: 1px solid var(--border); }
.food-item summary { cursor: pointer; list-style: none; }
.food-item summary::-webkit-details-marker { display: none; }
.food-item[open] summary { background: var(--surface-2); }
.food-name { display: flex; flex-direction: column; font-weight: 600; }
.food-name small { font-weight: 400; font-size: .78rem; }
.food-calc { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; padding: .7rem .9rem .9rem; font-size: .9rem; }
.food-calc label { flex-direction: row; align-items: center; gap: .4rem; }
.food-calc input { width: 6rem; }
.food-calc output { flex-basis: 100%; }

@media (max-width: 700px) {
  .food-row.head { display: none; }
  .food-row { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .15rem .6rem; }
  .food-row .food-name { grid-column: 1 / -1; margin-bottom: .2rem; }
  .food-row > span:not(:first-child) { text-align: left; font-size: .85rem; }
  .food-row > span[data-label]::before { content: attr(data-label) " "; color: var(--muted); font-weight: 400; }
}

/* Import ------------------------------------------------------------------ */

.import-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 7.5rem;
  gap: .6rem;
  align-items: center;
  padding: .6rem 0;
  border-bottom: 1px solid var(--border);
}
.import-row.todo .link { color: var(--warn); }
.import-row.excluded { opacity: .5; }
.imp-text { display: flex; flex-direction: column; min-width: 0; }
.check input { width: 1.2rem; height: 1.2rem; }

/* Boîtes de dialogue ----------------------------------------------------- */

.dialog {
  border: 0;
  padding: 0;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  width: min(560px, calc(100vw - 2rem));
  max-height: min(720px, calc(100dvh - 2rem));
}
.dialog::backdrop { background: rgb(0 0 0 / 45%); }
.dialog-body { display: flex; flex-direction: column; gap: .7rem; padding: 1rem; max-height: inherit; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; }
.dialog-head h2 { margin: 0; }
.hint { font-size: .85rem; color: var(--muted); margin: 0; }

.picker-search { display: grid; grid-template-columns: 1fr; gap: .5rem; }
.picker-results { overflow-y: auto; min-height: 200px; max-height: 50dvh; margin: 0 -1rem; }
.picker-results button {
  display: flex;
  flex-direction: column;
  width: 100%;
  text-align: left;
  border: 0;
  background: none;
  font: inherit;
  color: var(--text);
  padding: .55rem 1rem;
  cursor: pointer;
  border-top: 1px solid var(--border);
}
.picker-results button:hover, .picker-results button:focus-visible { background: var(--surface-2); }
.picker-results .name { font-weight: 600; }
.picker-qty { display: flex; flex-direction: column; gap: .7rem; }
.picker-selected { font-weight: 700; font-size: 1.05rem; margin: 0; }

/* Notification ------------------------------------------------------------ */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(1.2rem + env(safe-area-inset-bottom));
  transform: translate(-50%, 150%);
  background: var(--text);
  color: var(--bg);
  padding: .65rem 1rem;
  border-radius: 10px;
  font-size: .92rem;
  max-width: calc(100vw - 2rem);
  transition: transform .25s, opacity .25s;
  opacity: 0;
  pointer-events: none;
  z-index: 100;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

/* Repas ------------------------------------------------------------------- */

.actions-inline { display: flex; gap: .4rem; flex-wrap: wrap; }
.ing-title { font-weight: 600; }
.carb-total { margin: .2rem 0 .1rem; color: var(--carbs); font-weight: 600; }
.carb-total span { font-size: 2.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.meal-save { display: flex; flex-direction: column; gap: .2rem; margin-top: 1rem; }
.saved-meal {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: .6rem;
  align-items: center;
  padding: .6rem 0;
  border-bottom: 1px solid var(--border);
}
.saved-meal:last-child { border-bottom: 0; }
.saved-actions { display: flex; align-items: center; gap: .2rem; }
.add-to-meal { display: flex; gap: .5rem; align-items: center; margin-top: 1rem; }
.add-to-meal .ing-qty { width: 7.5rem; }
.rp-top { align-items: center; }
.dialog.confirm { width: min(420px, calc(100vw - 2rem)); }
.back.link { color: var(--accent); }

/* Portions et objectifs --------------------------------------------------- */

.servings-control { display: flex; flex-direction: column; gap: .4rem; padding-bottom: 1rem; margin-bottom: 1rem; border-bottom: 1px solid var(--border); }
.servings-control h2 { margin: 0; }
.servings-control p { margin: 0; }
.stepper { display: flex; align-items: center; gap: .4rem; }
.stepper input { width: 5rem; text-align: center; font-size: 1.3rem; font-weight: 700; padding: .35rem; }
.step {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 1.4rem;
  font-weight: 700;
  cursor: pointer;
}
.step:disabled { opacity: .4; cursor: not-allowed; }
.check-line { flex-direction: row; align-items: flex-start; gap: .45rem; font-size: .85rem; }
.check-line input { width: auto; margin-top: .15rem; }

.target-box { display: flex; flex-direction: column; gap: .5rem; margin-top: 1.2rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.target-box h3 { margin: 0; }
.target-row { display: flex; align-items: center; gap: .45rem; }
.target-row input { width: 5.5rem; }
.target-row select { flex: 1; }
#target-result { display: flex; flex-direction: column; gap: .45rem; align-items: flex-start; }
#target-result p { margin: 0; }
.target-answer strong { font-size: 1.15rem; }

.goals { display: flex; flex-direction: column; gap: .75rem; margin: 1rem 0; }
.goals h3 { margin: 0; }
.goal { display: flex; flex-direction: column; gap: .3rem; }
.goal-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.goal-label { flex-direction: row; font-weight: 600; font-size: .95rem; }
.goal-label.carbs { color: var(--carbs); }
.goal-label.fat { color: var(--fat); }
.goal-label.protein { color: var(--protein); }
.goal-input { display: flex; align-items: center; gap: .3rem; color: var(--muted); font-size: .9rem; }
.goal-input input { width: 5rem; text-align: right; padding: .3rem .5rem; }
.goal-bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.goal-bar span { display: block; height: 100%; border-radius: 4px; }
.goal-bar .carbs { background: var(--carbs); }
.goal-bar .fat { background: var(--fat); }
.goal-bar .protein { background: var(--protein); }
.goal-bar .over { background: var(--danger); }
.goal-status { display: flex; justify-content: space-between; gap: .5rem; font-variant-numeric: tabular-nums; }

/* Ratio cétogène ----------------------------------------------------------- */

.keto-box { display: flex; flex-direction: column; gap: .5rem; margin-top: 1.2rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.keto-head { display: flex; justify-content: space-between; align-items: baseline; }
.keto-head h3 { margin: 0; }
.ratio-value { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.ratio-value.ok, .ok-text { color: var(--ok); }
.ratio-value.low { color: var(--warn); }
.keto-target { flex-direction: row; align-items: center; gap: .4rem; }
.keto-target input { width: 4.5rem; text-align: center; padding: .3rem; }
.keto-result { display: flex; flex-direction: column; gap: .4rem; align-items: flex-start; }
.keto-result p { margin: 0; }
.keto-add { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; }
.keto-add strong { font-size: 1.15rem; }
.keto-add select { width: auto; }
.chip.ratio { color: var(--warn); }
.chip.ratio.ok { color: var(--ok); }
.ratio-target { margin: .4rem 0 0; }

/* Variantes de ratio -------------------------------------------------------- */

.variant-control { display: flex; flex-direction: column; gap: .55rem; padding-bottom: 1rem; margin-bottom: 1rem; border-bottom: 1px solid var(--border); }
.variant-control.compact { padding-bottom: .8rem; }
.variant-control h2 { margin: 0; }
.variant-control p { margin: 0; }
.table-scroll { overflow-x: auto; }
.variant-table { width: 100%; border-collapse: collapse; font-size: .85rem; font-variant-numeric: tabular-nums; }
.variant-table th, .variant-table td { padding: .3rem .35rem; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
.variant-table tbody th, .variant-table thead th:first-child { text-align: left; font-weight: 600; color: var(--muted); }
.variant-table thead th { font-weight: 700; }
.variant-table thead th.current { color: var(--accent); }
.variant-table tr.fat td { color: var(--fat); }
.variant-table tr.carbs td { color: var(--carbs); }
.variant-table tr.protein td { color: var(--protein); }
.variant-actions { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.variant-actions select { width: auto; }

/* Export Thermomix ---------------------------------------------------------- */

.tm-export summary { display: flex; align-items: baseline; gap: .6rem; cursor: pointer; list-style: none; }
.tm-export summary::-webkit-details-marker { display: none; }
.tm-export summary::before { content: '▸'; color: var(--accent); transition: transform .15s; }
.tm-export[open] summary::before { transform: rotate(90deg); }
.tm-export summary h2 { margin: 0; }
.tm-body { display: flex; flex-direction: column; gap: .8rem; margin-top: .8rem; }
.tm-how { margin: 0; padding-left: 1.2rem; display: flex; flex-direction: column; gap: .3rem; }
.tm-field { display: flex; flex-direction: column; gap: .3rem; }
.tm-field-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.tm-field-head label { color: var(--text); font-weight: 600; }
.tm-field textarea { font-size: .9rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
@media (prefers-reduced-motion: reduce) { .tm-export summary::before { transition: none; } }

.tm-ai { display: flex; flex-direction: column; gap: .6rem; padding: .9rem; border-radius: 12px; background: var(--surface-2); }
.tm-ai h3 { margin: 0; }
.tm-ai p { margin: 0; }
.tm-ai .notice { background: var(--surface); }
.tm-ai textarea { font-size: .9rem; line-height: 1.45; background: var(--surface); }
.tm-raw { display: flex; flex-direction: column; gap: .8rem; }
.tm-raw > summary { cursor: pointer; font-weight: 600; color: var(--muted); }
.tm-raw[open] > summary { margin-bottom: .6rem; }
.tm-raw > *:not(summary) + * { margin-top: .8rem; }

/* Boutons − / + des quantités ------------------------------------------------ */

.ingredient { grid-template-columns: minmax(0, 1fr) auto auto; }
.ingredient:not(:has(.icon-btn)) { grid-template-columns: minmax(0, 1fr) auto; }
.qty-stepper { display: flex; align-items: center; gap: .25rem; color: var(--muted); font-size: .9rem; }
.qty-stepper input { width: 4.6rem; text-align: center; padding: .4rem .3rem; }
.qty-btn {
  width: 2.1rem;
  height: 2.1rem;
  flex: none;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}
.qty-btn:disabled { opacity: .4; cursor: not-allowed; }
@media (max-width: 480px) {
  .ingredient { grid-template-areas: "name name remove" "qty qty qty" "values values values"; }
  .ingredient:not(:has(.icon-btn)) { grid-template-areas: "name name" "qty qty" "values values"; }
}

.variant-table tr.ref th, .variant-table tr.ref td { color: var(--muted); font-style: italic; }

.segmented .count { font-size: .78em; font-weight: 600; opacity: .7; font-variant-numeric: tabular-nums; }
.recipe-count { margin: -.4rem 0 0; }

/* Recettes pour compléter le repas ------------------------------------------ */
.ms-filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .6rem 0 .2rem; }
.ms-filters input[type="search"] { flex: 1 1 12rem; min-width: 0; }
.ms-filters select { flex: 0 1 auto; }
.ms-keto { display: flex; flex-direction: row; align-items: center; gap: .4rem; font-size: .9rem; color: var(--text); }
.ms-keto input { width: auto; margin: 0; }
#ms-results .saved-meal { grid-template-columns: minmax(0, 1fr) auto; }
#ms-results .ing-name { display: flex; flex-direction: column; gap: .3rem; }
@media (max-width: 480px) {
  #ms-results .saved-meal { grid-template-columns: minmax(0, 1fr); }
  #ms-results .saved-actions { justify-content: flex-end; }
}

/* Création -------------------------------------------------------------------- */
.cr-results { list-style: none; margin: .4rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .2rem; }
.cr-results button {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: .6rem;
  padding: .55rem .7rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.cr-results button:hover, .cr-results button:focus-visible { border-color: var(--accent); }
.cr-chosen { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .7rem; }
.cr-chip { display: inline-flex; align-items: center; gap: .1rem; padding: .15rem .2rem .15rem .7rem; border: 1px solid var(--border); border-radius: 999px; font-size: .9rem; }
.cr-chip .icon-btn { width: 1.9rem; height: 1.9rem; }
.cr-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); gap: .6rem; margin: .8rem 0 .3rem; }
.cr-form label { display: flex; flex-direction: column; gap: .25rem; font-size: .88rem; font-weight: 600; }
.cr-checks { display: flex; flex-wrap: wrap; gap: .35rem; margin: .5rem 0; }
.chip.warn { color: var(--warn); }
.cr-card .saved-meal { grid-template-columns: minmax(0, 1fr) auto; }

/* Produits ------------------------------------------------------------------ */
#pr-search { margin: .7rem 0 .3rem; }
.pr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15.5rem, 1fr)); gap: .8rem; margin-top: .6rem; }
.pr-item { border: 1px solid var(--border); border-radius: 12px; padding: .8rem; display: flex; flex-direction: column; gap: .5rem; }
.pr-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; }
.pr-head h3 { margin: 0; font-size: 1rem; }
.pr-head p { margin: .15rem 0 0; }
.pr-table { margin: 0; }
.pr-table th, .pr-table td { font-size: .88rem; }
.pr-table thead th { color: var(--muted); font-weight: 600; }
.pr-item .actions-inline { margin-top: auto; justify-content: flex-end; }
@media (max-width: 640px) {
  #cr-similar .saved-meal { grid-template-columns: minmax(0, 1fr); }
  #cr-similar .saved-actions { justify-content: flex-end; }
}
.cr-status { margin: .7rem 0 0; padding: .6rem .8rem; border-radius: 10px; background: var(--surface-2); }
.cr-status.busy { color: var(--accent); font-weight: 600; }
.cr-status.warn { color: var(--warn); }
.cr-badges { display: flex; flex-direction: column; gap: .35rem; margin: .5rem 0 .3rem; }
.cr-badge-row { display: flex; flex-wrap: wrap; gap: .35rem; }
.cr-badge-row:empty { display: none; }
.cr-badge {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: .85rem;
  padding: .3rem .7rem;
  border-radius: 999px;
  cursor: pointer;
}
.cr-badge .count { font-size: .78em; opacity: .7; font-variant-numeric: tabular-nums; }
.cr-badge.active { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.cr-badge:disabled { opacity: .45; cursor: default; }
.cr-badge.clear { border-style: dashed; color: var(--muted); }
.cr-more { list-style: none; display: flex; justify-content: center; padding: .6rem 0; }

/* Liste des recettes : mon ratio et badges -------------------------------- */
.filter-card { display: flex; flex-direction: column; gap: .6rem; padding: .8rem 1rem; }
.my-ratio { display: flex; flex-direction: row; align-items: center; justify-content: flex-start; gap: .6rem; font-weight: 600; color: var(--text); }
.my-ratio select { width: auto; }
.filter-card .cr-badges { margin: 0; }
.load-more { display: flex; justify-content: center; padding: .5rem 0 1rem; }
@media (max-width: 640px) {
  .filter-card .cr-badge-row { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -1rem; padding: 0 1rem; }
  .filter-card .cr-badge-row::-webkit-scrollbar { display: none; }
  .filter-card .cr-badge { flex: 0 0 auto; }
}

/* Fiche recette : titre, barre compacte -------------------------------------- */
.recipe-title h1 { margin: 0; font-size: 1.5rem; line-height: 1.2; }
.recipe-title p { margin: .3rem 0 0; }
.quick-card { display: none; flex-direction: column; gap: .6rem; }
.quick-row { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; }
.stepper.small { display: flex; align-items: center; gap: .3rem; }
.stepper.small .step { width: 2.2rem; height: 2.2rem; }
.stepper.small input { width: 3.2rem; text-align: center; }
.quick-more { align-self: flex-start; background: none; border: 0; color: var(--accent); font: inherit; font-weight: 600; padding: 0; cursor: pointer; }
@media (max-width: 860px) {
  .recipe-side { order: 0; }
  .quick-card { display: flex; }
  #summary .servings-control, #summary .variant-control > .segmented { display: none; }
}

/* Mode cuisine -------------------------------------------------------------- */
dialog.cook {
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 1rem 1.2rem calc(1rem + env(safe-area-inset-bottom));
  border: 0;
  background: var(--bg);
  color: var(--text);
  font-size: calc(1rem * var(--cook-size, 1.2));
  overflow-y: auto;
}
.cook-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .6rem; }
.cook-head h2 { margin: 0; font-size: 1.3em; }
.cook-tools { display: flex; gap: .4rem; }
.cook-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 1.4rem; margin-top: .6rem; }
@media (max-width: 860px) { .cook-body { grid-template-columns: 1fr; } }
.cook-body h3 { margin: 0 0 .5rem; font-size: 1em; color: var(--muted); }
.cook-ings, .cook-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.cook-ings button, .cook-steps button {
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: .6em .8em;
  cursor: pointer;
  line-height: 1.4;
}
.cook-ings button { display: flex; gap: .7em; align-items: baseline; }
.cook-ings strong { min-width: 4.2em; color: var(--accent); }
.cook-ings button.done { opacity: .45; text-decoration: line-through; }
.cook-steps { counter-reset: step; }
.cook-steps button::before { counter-increment: step; content: counter(step) ". "; font-weight: 700; color: var(--muted); }
.cook-steps button.past { opacity: .5; }
.cook-steps button.current { border: 2px solid var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); font-weight: 600; }
.cook-nav { display: flex; justify-content: space-between; gap: .6rem; margin-top: .8rem; position: sticky; bottom: 0; padding: .5rem 0; background: var(--bg); }
.cook-nav .btn { flex: 1; font-size: 1em; padding: .7em; }

/* Repas : résumé toujours visible sur iPad portrait et téléphone ------------- */
.meal-bar { display: none; }
@media (max-width: 860px) {
  .meal-bar {
    position: fixed;
    left: .6rem;
    right: .6rem;
    bottom: calc(4.6rem + env(safe-area-inset-bottom));
    z-index: 14;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .3rem .6rem;
    padding: .5rem .8rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .12);
    cursor: pointer;
  }
  .meal-bar .chips { display: flex; gap: .3rem; flex-wrap: wrap; }
  .view:has(.meal-bar) { padding-bottom: 4.5rem; }
  body:has(.meal-bar) .to-top { bottom: calc(9.4rem + env(safe-area-inset-bottom)); }
}
@media (max-width: 640px) {
  .section-head:has(> .actions-inline) { flex-wrap: wrap; }
  .section-head > .actions-inline { width: 100%; }
  .section-head > .actions-inline .btn { flex: 1; }
}
.filter-selects { display: flex; flex-wrap: wrap; gap: .5rem 1.4rem; }
.filter-selects select { max-width: 100%; }
.filter-selects .my-ratio { min-width: 0; max-width: 100%; }
.filter-selects .my-ratio select { min-width: 0; flex: 1 1 auto; }
@media (max-width: 640px) {
  .filter-selects { flex-direction: column; }
  .filter-selects .my-ratio { justify-content: space-between; }
  .filter-selects .my-ratio select { flex: 0 1 60%; }
}
#prep-card .section-head { flex-wrap: wrap; gap: .5rem; }
.tm7-steps li { margin-bottom: .2rem; }
.place-field { display: flex; align-items: center; gap: .3rem; min-width: 0; max-width: 100%; }
.place-clear { flex: 0 0 auto; width: 2.4rem; height: 2.4rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text); font-size: 1rem; cursor: pointer; }
.place-clear:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.place-clear:disabled { opacity: .35; cursor: default; }
@media (max-width: 640px) {
  .place-field .my-ratio { flex: 1 1 auto; }
}
.recipe-head { flex-wrap: wrap; gap: .5rem; }
.recipe-head .actions { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: flex-end; }
@media (max-width: 480px) {
  .recipe-head .actions { width: 100%; }
  .recipe-head .actions .btn { flex: 1 1 auto; }
}

/* Valeurs à vérifier / confirmées ------------------------------------------ */
.check-box { margin-top: .5rem; }
.warn-box { padding: .6rem .7rem; border: 1px solid var(--warn); border-radius: 10px; background: color-mix(in srgb, var(--warn) 8%, var(--surface)); }
.warn-box p { margin: 0 0 .4rem; }
.link.small { background: none; border: 0; color: var(--accent); font: inherit; font-size: .85rem; padding: 0; cursor: pointer; text-decoration: underline; }

/* Ma journée -------------------------------------------------------------------- */
.slot-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .4rem .8rem; }
.slot-head h2, .slot-head h3 { margin: 0; font-size: 1.1rem; }
.slot-card .ingredient-list { margin-top: .4rem; }
.slot-actions { margin-top: .6rem; }
.fat-btn { margin-top: .5rem; align-self: flex-start; border-style: dashed; }
.day-head .section-head { align-items: center; }
.day-ratio { margin: .3rem 0 .6rem; }
.add-to-meal select { max-width: 11rem; }
dialog.menu-dialog {
  width: min(720px, calc(100vw - 1rem));
  max-height: 92dvh;
  overflow-y: auto;
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg);
  color: var(--text);
}
dialog.menu-dialog::backdrop { background: rgba(0, 0, 0, .45); }
.menu-dialog .dialog-head { display: flex; justify-content: space-between; align-items: center; gap: .6rem; }
.menu-dialog .dialog-head h2 { margin: 0; }
.menu-dialog .small-title { margin: 1rem 0 .4rem; }
.menu-dialog .cr-badge-row { margin-bottom: .2rem; }
.menu-dialog .grid-2 { margin-top: .8rem; }
.menu-dialog .dialog-actions { position: sticky; bottom: -1rem; margin: 1rem -1.1rem -1rem; padding: .7rem 1.1rem; background: var(--bg); border-top: 1px solid var(--border); }
.menu-total { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; font-weight: 600; }
.menu-slot { margin: 1rem 0; padding: .7rem .8rem; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.menu-items { margin: .4rem 0 0; padding-left: 1.1rem; display: flex; flex-direction: column; gap: .25rem; }
@media (max-width: 640px) {
  dialog.menu-dialog { width: 100vw; max-height: 100dvh; height: 100dvh; border-radius: 0; margin: 0; }
}
.day-head .section-head { flex-wrap: wrap; gap: .6rem; }
@media (max-width: 640px) {
  #day-plan { width: 100%; }
}

/* Guide des farines ----------------------------------------------------------- */
.flour-mix { display: flex; flex-direction: column; gap: .2rem; padding: .7rem .8rem; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); margin-top: .6rem; }
.flour-zone h2 { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.zone-dot { width: .8rem; height: .8rem; border-radius: 999px; display: inline-block; }
.zone-dot.top, .flour-bar span.top { background: var(--ok, #2f7d4f); }
.zone-dot.moderate, .flour-bar span.moderate { background: var(--warn); }
.zone-dot.avoid, .flour-bar span.avoid { background: var(--danger); }
.flour-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: .8rem; margin-top: .6rem; }
.flour-item { border: 1px solid var(--border); border-radius: 12px; padding: .8rem; display: flex; flex-direction: column; gap: .4rem; }
.flour-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .6rem; }
.flour-head h3 { margin: 0; font-size: 1rem; }
.flour-head p { margin: .1rem 0 0; }
.flour-carbs { text-align: right; flex: 0 0 auto; display: flex; flex-direction: column; }
.flour-carbs strong { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.flour-carbs span { font-size: .75rem; color: var(--muted); }
.flour-carbs.top strong { color: var(--ok, #2f7d4f); }
.flour-carbs.moderate strong { color: var(--warn); }
.flour-carbs.avoid strong { color: var(--danger); }
.flour-bar { height: .45rem; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.flour-bar span { display: block; height: 100%; border-radius: 999px; }
.flour-item p { margin: 0; }
.flour-links { margin: .3rem 0 0; padding-left: 1.2rem; display: flex; flex-direction: column; gap: .3rem; }
.flour-links a { color: var(--accent); }

/* Barre de recherche des recettes avec croix d'effacement */
.search-field { position: relative; flex: 1 1 200px; min-width: 0; display: flex; }
.search-field input { width: 100%; padding-right: 2.4rem; }
.search-field input::-webkit-search-cancel-button { display: none; }
.search-field .search-clear { position: absolute; right: 0.2rem; top: 50%; transform: translateY(-50%); }
.search-field .search-clear[hidden] { display: none; }

/* Statut (validée / à tester) et date de mise à jour des recettes */
.recipe-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: .25rem 0 .5rem; }
.status-badge { border: 1px solid var(--border, #ccc); border-radius: 999px; padding: .2rem .7rem; font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer; background: #fff3d6; color: #7a4b00; border-color: #e5b44d; }
.status-badge.validated { background: #def5e3; color: #17602b; border-color: #6cc287; }
.status-badge.small { padding: .05rem .5rem; font-size: .75rem; cursor: inherit; }
.card-meta { display: flex; align-items: center; gap: .5rem; margin: .1rem 0 .4rem; }
.ing-date { white-space: nowrap; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .status-badge { background: #4a3710; color: #ffd98a; border-color: #8a6a1f; }
  :root:not([data-theme="light"]) .status-badge.validated { background: #15381f; color: #a6e7b8; border-color: #3e7a50; }
}
:root[data-theme="dark"] .status-badge { background: #4a3710; color: #ffd98a; border-color: #8a6a1f; }
:root[data-theme="dark"] .status-badge.validated { background: #15381f; color: #a6e7b8; border-color: #3e7a50; }

/* Validation des quantités modifiées d'une recette fournie */
.draft-bar { border: 2px solid #e5b44d; background: #fff3d6; color: #5c3b00; border-radius: 10px; padding: .6rem .8rem; margin-bottom: .8rem; position: sticky; top: .5rem; z-index: 5; }
.draft-bar p { margin: 0 0 .5rem; }
.draft-bar[hidden] { display: none; }
.adapt-note { margin-bottom: .7rem; font-size: .9rem; background: #eef6ff; border-radius: 8px; padding: .4rem .7rem; color: #1d3f66; }
.adapt-note summary { cursor: pointer; font-weight: 600; }
:root[data-theme="dark"] .draft-bar { background: #3a2c0c; color: #ffe2a0; border-color: #8a6a1f; }
:root[data-theme="dark"] .adapt-note { background: #17283a; color: #bcd7f5; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .draft-bar { background: #3a2c0c; color: #ffe2a0; border-color: #8a6a1f; }
  :root:not([data-theme="light"]) .adapt-note { background: #17283a; color: #bcd7f5; }
}

/* Ratio à côté du titre « Ingrédients » et effet des quantités modifiées */
.ing-ratio { font-size: .9rem; font-weight: 600; margin-left: .5rem; padding: .1rem .55rem; border-radius: 999px; background: #eef1ee; color: inherit; white-space: nowrap; }
.ing-ratio.ok { background: #def5e3; color: #17602b; }
.ing-ratio.low { background: #fff3d6; color: #7a4b00; }
.ing-ratio-delta { font-weight: 500; }
.impact { font-size: .75rem; font-weight: 600; white-space: nowrap; }
.impact.down { color: #b3261e; }
.impact.up { color: #17602b; }
.impact:empty { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ing-ratio { background: #2a302b; }
  :root:not([data-theme="light"]) .ing-ratio.ok { background: #15381f; color: #a6e7b8; }
  :root:not([data-theme="light"]) .ing-ratio.low { background: #4a3710; color: #ffd98a; }
  :root:not([data-theme="light"]) .impact.down { color: #ff9a92; }
  :root:not([data-theme="light"]) .impact.up { color: #a6e7b8; }
}
:root[data-theme="dark"] .ing-ratio { background: #2a302b; }
:root[data-theme="dark"] .ing-ratio.ok { background: #15381f; color: #a6e7b8; }
:root[data-theme="dark"] .ing-ratio.low { background: #4a3710; color: #ffd98a; }
:root[data-theme="dark"] .impact.down { color: #ff9a92; }
:root[data-theme="dark"] .impact.up { color: #a6e7b8; }

/* Légumes (onglet Substituts) */
.veg-list { list-style: none; margin: .3rem 0 1rem; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .2rem .9rem; }
.veg-item { display: flex; justify-content: space-between; gap: .5rem; padding: .25rem 0; border-bottom: 1px solid rgba(128,128,128,.25); font-size: .92rem; }
.veg-carbs { font-weight: 700; white-space: nowrap; }
.veg-carbs.top { color: #17602b; }
.veg-carbs.moderate { color: #9a6200; }
.veg-carbs.avoid { color: #b3261e; }
:root[data-theme="dark"] .veg-carbs.top { color: #a6e7b8; }
:root[data-theme="dark"] .veg-carbs.moderate { color: #ffd98a; }
:root[data-theme="dark"] .veg-carbs.avoid { color: #ff9a92; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .veg-carbs.top { color: #a6e7b8; }
  :root:not([data-theme="light"]) .veg-carbs.moderate { color: #ffd98a; }
  :root:not([data-theme="light"]) .veg-carbs.avoid { color: #ff9a92; }
}

/* Dictionnaire des substitutions */
.dict-list { display: grid; gap: .35rem; }
.dict-item { border: 1px solid rgba(128,128,128,.3); border-radius: 8px; padding: .4rem .7rem; }
.dict-item summary { cursor: pointer; }
.dict-item p { margin: .4rem 0 .1rem; }

/* Temps de préparation, de cuisson et de repos */
.recipe-times { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin: .2rem 0 .5rem; }
.time-chip { border: 1px solid rgba(128,128,128,.35); border-radius: 999px; padding: .15rem .65rem; font-size: .88rem; white-space: nowrap; }
.time-chip.total { font-weight: 600; border-color: #6cc287; }
.times-edit { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .6rem; margin: .5rem 0; }
.times-edit label { display: grid; gap: .2rem; font-size: .88rem; }

/* Niveau de difficulté et import des fiches */
.level-badge { display: inline-block; border-radius: 6px; padding: .05rem .5rem; font-size: .8rem; font-weight: 600; background: #e8eefc; color: #1d3f66; }
.level-badge.small { font-size: .72rem; }
:root[data-theme="dark"] .level-badge { background: #1d2c47; color: #bcd7f5; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .level-badge { background: #1d2c47; color: #bcd7f5; } }
.dd-files { margin: .6rem 0; }
.dd-files .btn { text-align: center; }

.cr-label { align-self: center; font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; opacity: .65; margin-right: .2rem; }

/* Nouvelle recette : brouillon guidé */
.nr-view h2 { display: flex; align-items: center; gap: .5rem; }
.step-no { display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--accent, #2f6f5e); color: #fff; font-size: .9rem; font-weight: 700; flex: none; }
.nr-result-list { list-style: none; margin: .4rem 0; padding: 0; border: 1px solid var(--border, #d9dde2); border-radius: .6rem; overflow: hidden; }
.nr-result { display: flex; justify-content: space-between; align-items: center; gap: .6rem; width: 100%; padding: .6rem .8rem; border: 0; border-bottom: 1px solid var(--border, #d9dde2); background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.nr-result-list li:last-child .nr-result { border-bottom: 0; }
.nr-result:hover, .nr-result:focus-visible { background: color-mix(in srgb, var(--accent, #2f6f5e) 12%, transparent); }
.nr-pending { margin: .5rem 0; padding: .7rem .8rem; border: 1px solid var(--accent, #2f6f5e); border-radius: .6rem; }
.nr-pending-row { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.nr-pending-row strong { flex: 1 1 12rem; }
.nr-qty { display: flex; align-items: center; gap: .4rem; }
.nr-qty input { width: 6rem; text-align: right; }
.nr-checks { list-style: none; margin: .3rem 0 .8rem; padding: 0; display: grid; gap: .25rem; font-size: .95rem; }
.nr-checks .ok { color: var(--ok, #1f7a4d); }
.nr-checks .warn { color: var(--warn, #b45309); }
.btn.wide { width: 100%; }

/* Accessibilité : contraste du texte des macros (les points et barres gardent les couleurs d'origine) */
:root { --carbs-text: #8a5300; --fat-text: #b03a2e; --protein-text: #2f5fa8; --ok-text: #25683f; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --carbs-text: var(--carbs); --fat-text: var(--fat); --protein-text: var(--protein); --ok-text: var(--ok); }
}
:root[data-theme="dark"] { --carbs-text: var(--carbs); --fat-text: var(--fat); --protein-text: var(--protein); --ok-text: var(--ok); }
.chip.carbs, .carbs { color: var(--carbs-text); }
.chip.fat, .fat { color: var(--fat-text); }
.chip.protein, .protein { color: var(--protein-text); }
.dot.carbs, .macro-bar .seg.carbs { color: inherit; }
.chip.ratio.ok { color: var(--ok-text); }
.step-no { color: var(--accent-contrast); }

/* Écrans tactiles : zones à toucher d'au moins 44 px */
@media (pointer: coarse) {
  .cr-badge, .status-toggle, .icon-btn, .qty-btn, .stepper .step { min-height: 44px; }
  .icon-btn, .qty-btn, .stepper .step { min-width: 44px; }
  .cr-badge { display: inline-flex; align-items: center; }
  .back.link, .quick-more, .nr-view .link { min-height: 44px; display: inline-flex; align-items: center; }
  .keto-target input, .nr-view select, .filter-selects select { min-height: 44px; }
}
.variant-table tr.carbs td { color: var(--carbs-text); }
.variant-table tr.fat td { color: var(--fat-text); }
.variant-table tr.protein td { color: var(--protein-text); }
@media (pointer: coarse) {
  .segmented button, .small-btn, details > summary, button.link, .link { min-height: 44px; }
  .segmented button, .small-btn, button.link { display: inline-flex; align-items: center; justify-content: center; }
  details > summary { display: flex; align-items: center; }
}
@media (pointer: coarse) {
  .status-toggle { min-height: 44px; }
  .ing-qty input, .times-edit input, .servings-control input { min-height: 44px; }
}

/* Accueil épuré : recherche, genres, filtres repliables */
.genre-row { display: flex; gap: .4rem; overflow-x: auto; margin: 0 -1rem .6rem; padding: .1rem 1rem .3rem; scrollbar-width: none; -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 2rem), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 2rem), transparent); }
.genre-row::-webkit-scrollbar { display: none; }
.genre-row .cr-badge { flex: none; }
.filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin-bottom: .6rem; }
.filter-bar .recipe-count { margin: 0 0 0 auto; }
.card-line { margin: .1rem 0 .4rem; }
.recipe-card .card-top { align-items: flex-start; }
.filter-card .cr-badge-row + .cr-badge-row { margin-top: .4rem; }
.recipe-card .status-badge { white-space: nowrap; flex: none; }
.class-fields { margin-top: .7rem; }
@media (max-width: 560px) { .class-fields { grid-template-columns: minmax(0, 1fr); } }
.picker-volume-row { display: flex; gap: .5rem; }
.picker-volume-row input { flex: 1 1 auto; min-width: 0; }

/* Compteur de glucides */
.cc-list { display: grid; gap: .6rem; }
.cc-item { padding: .8rem 1rem; }
.cc-item-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; }
.cc-item h3 { margin: 0 0 .1rem; font-size: 1rem; }
.cc-item-vals { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .8rem; margin: .4rem 0 .6rem; }
.cc-pill { display: inline-flex; align-items: baseline; gap: .25rem; padding: .15rem .6rem; border-radius: 999px; background: var(--surface-2); font-weight: 700; }
.cc-pill small { font-weight: 600; }
.cc-pill.top { color: var(--ok-text, #25683f); }
.cc-pill.moderate { color: var(--warn); }
.cc-pill.avoid { color: var(--danger); }
.cc-meal-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.cc-line { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; align-items: center; gap: .6rem; padding-bottom: .6rem; border-bottom: 1px solid var(--border); }
.cc-line-name { display: grid; min-width: 0; }
.cc-line-qty { display: flex; gap: .3rem; }
.cc-line-qty input { width: 5rem; text-align: right; }
.cc-line-carbs { display: grid; text-align: right; }
.cc-total { display: flex; justify-content: space-between; align-items: baseline; margin-top: .8rem; font-size: 1.15rem; }
@media (max-width: 560px) { .cc-line { grid-template-columns: minmax(0, 1fr) auto; } .cc-line-qty { grid-column: 1 / -1; } }

/* Indicateur de compte (connexion au partage) ------------------------------ */
.account-chip { margin-left: .5rem; padding: .3rem .7rem; min-height: 32px; border-radius: 999px; border: 1px solid var(--line, #d9d6cc); background: var(--surface, #fff); color: var(--text, #1f2a24); font-size: .85rem; font-weight: 600; cursor: pointer; }
.account-chip.on { color: #1d5c39; border-color: #2f7d4f; }
.account-chip.on::before { content: '●'; color: #2f7d4f; margin-right: .35rem; }
.account-chip.warn { color: #7a4b00; border-color: #c98b1a; background: #fff6e0; }
