:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --ink: #2c2622;
  --muted: #7a716a;
  --line: #e8e0d6;
  --accent: #b4502f;
  --accent-soft: #f3e6df;
  --constance: #8a5a8c;
  --gildas: #3f6f59;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(44, 38, 34, .05), 0 8px 24px rgba(44, 38, 34, .06);
  --maxw: 880px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

a { color: inherit; text-decoration: none; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: rgba(250, 247, 242, .9);
  backdrop-filter: saturate(160%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { font-family: "Fraunces", serif; font-size: 1.35rem; font-weight: 600; letter-spacing: -.01em; }
.nav { display: flex; gap: 22px; font-size: .95rem; }
.nav a { color: var(--muted); padding: 4px 0; border-bottom: 2px solid transparent; transition: color .15s; }
.nav a:hover { color: var(--ink); }
.nav a.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Hero */
.hero { padding: 48px 0 28px; border-bottom: 1px solid var(--line); margin-bottom: 28px; }
.hero h1 { font-family: "Fraunces", serif; font-weight: 600; font-size: clamp(2rem, 5vw, 2.9rem); line-height: 1.1; margin: 0 0 14px; letter-spacing: -.02em; }
.hero p { font-size: 1.12rem; color: var(--muted); margin: 0; max-width: 60ch; }

/* Search + filters */
.search {
  flex: 1 1 220px; min-width: 0; margin: 0;
  padding: 11px 14px; font-size: 1rem; font-family: inherit;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; color: var(--ink);
}
.search:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

/* Accueil : barre flottante (catégories + recherche), à gauche */
.home-bar { position: sticky; top: 60px; z-index: 5; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; background: var(--bg); padding: 12px 0; margin-bottom: 14px; }
.cat-dd { position: relative; flex-shrink: 0; }
.cat-dd-btn { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 11px 16px; font-family: inherit; font-size: .95rem; color: var(--ink); cursor: pointer; white-space: nowrap; }
.cat-dd-btn:hover { border-color: var(--accent); }
.cat-menu { position: absolute; top: calc(100% + 6px); left: 0; min-width: 190px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; display: none; flex-direction: column; z-index: 20; }
.cat-dd.open .cat-menu { display: flex; }
.filt { background: none; border: none; text-align: left; padding: 8px 12px; font-family: inherit; font-size: .95rem; color: var(--ink); cursor: pointer; border-radius: 8px; }
.filt:hover { background: var(--bg); }
.filt.active { color: var(--accent); font-weight: 600; }

.kcal-min { color: var(--muted); font-size: .85rem; }

/* Category sections */
.cat-block { margin-bottom: 40px; }
.cat-head { display: flex; align-items: baseline; gap: 12px; margin: 0 0 4px; }
.cat-head h2 { font-family: "Fraunces", serif; font-weight: 600; font-size: 1.5rem; margin: 0; }
.cat-head .count { color: var(--muted); font-size: .9rem; }
.cat-note { color: var(--muted); font-size: .95rem; margin: 0 0 18px; max-width: 70ch; }

/* Cards grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.card {
  display: block; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px; transition: transform .12s, box-shadow .12s, border-color .12s;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: #d8cdbf; }
.card .id { font-size: .72rem; font-weight: 600; letter-spacing: .06em; color: var(--accent); }
.card h3 { font-family: "Fraunces", serif; font-weight: 500; font-size: 1.18rem; line-height: 1.25; margin: 6px 0 12px; }
.card .meta { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: .76rem; padding: 3px 9px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.empty { color: var(--muted); padding: 40px 0; text-align: center; }

/* Badge plat complet / à compléter */
.badge { display: inline-block; font-size: .73rem; font-weight: 600; padding: 3px 9px; border-radius: 6px; white-space: nowrap; }
.badge.ok { background: #e7f3ec; color: #2f6f52; }
.badge.todo { background: #f7ecdd; color: #9a6a2b; }
.badge.neutral { background: #ece6dd; color: #6f655b; }

/* Bloc « Ça va avec » */
.head-badges { margin: -8px 0 18px; }
.accord { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 28px; }
.accord-label { font-family: "Fraunces", serif; font-weight: 600; font-size: 1.1rem; margin-bottom: 8px; }
.accord-sub { font-size: .86rem; color: var(--muted); margin: 0 0 12px; max-width: 72ch; line-height: 1.5; }
.accord-sub b { color: var(--ink); font-weight: 600; }
.accord-note { color: #4a423c; margin: 0 0 14px; font-size: .98rem; }
.achip-kcal { font-size: .82em; opacity: .7; font-variant-numeric: tabular-nums; margin-left: 6px; }
.accord-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.achip { display: inline-flex; align-items: center; font-size: .9rem; padding: 7px 13px; border-radius: 999px; text-decoration: none; transition: all .12s; }
.achip.livre { background: var(--accent-soft); color: var(--accent); border: 1px solid transparent; }
a.achip.livre:hover { background: #ecd8cf; }
.achip.logique { background: transparent; color: var(--muted); border: 1px solid var(--line); }
a.achip.logique:hover { border-color: var(--accent); color: var(--ink); }
a.achip { cursor: pointer; }
.achip.plain { cursor: default; }
.accord-legend { font-size: .78rem; color: var(--muted); margin: 14px 0 0; }
.accord-legend .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin: 0 5px 0 0; vertical-align: middle; }
.accord-legend .dot.logique { margin-left: 16px; }
.accord-legend .dot.livre { background: var(--accent-soft); border: 1px solid var(--accent); }
.accord-legend .dot.logique { background: transparent; border: 1px solid var(--muted); }

/* Recipe detail */
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: .92rem; margin: 30px 0 18px; }
.back:hover { color: var(--accent); }
.recipe-head .id { font-size: .8rem; font-weight: 600; letter-spacing: .08em; color: var(--accent); }
.recipe-head h1 { font-family: "Fraunces", serif; font-weight: 600; font-size: clamp(1.8rem, 4.5vw, 2.5rem); line-height: 1.12; margin: 6px 0 18px; letter-spacing: -.02em; }

.nutri { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 8px; }
.pill { padding: 8px 14px; border-radius: 10px; font-size: .92rem; background: var(--surface); border: 1px solid var(--line); }
.pill b { font-weight: 600; }
.pill.c { border-color: #e3d2e4; background: #faf4fb; color: var(--constance); }
.pill.g { border-color: #d2e4da; background: #f3faf6; color: var(--gildas); }
.nutri-line { color: var(--muted); font-size: .95rem; margin: 4px 0 26px; }
.courses { background: var(--accent-soft); border-radius: 10px; padding: 12px 16px; font-size: .95rem; margin-bottom: 26px; }
.courses b { color: var(--accent); }

.cols { display: grid; grid-template-columns: 1fr; gap: 34px; }
@media (min-width: 720px) { .cols { grid-template-columns: 1fr 1.25fr; gap: 44px; align-items: start; } }

.section-title { font-family: "Fraunces", serif; font-weight: 600; font-size: 1.15rem; margin: 0 0 14px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }

.ingredients { list-style: none; padding: 0; margin: 0; }
.ingredients li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: .98rem; }
.ingredients li:last-child { border-bottom: 0; }
.ingredients .qty { color: var(--muted); text-align: right; white-space: nowrap; }

.steps { list-style: none; counter-reset: step; padding: 0; margin: 0; }
.steps li { position: relative; padding: 0 0 18px 42px; }
.steps li:before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 0; top: -2px;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: .85rem; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}

.gout { margin-top: 30px; background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 10px; padding: 18px 20px; }
.gout h3 { font-family: "Fraunces", serif; font-weight: 600; margin: 0 0 8px; font-size: 1.05rem; }
.gout p { margin: 0; color: #4a423c; }

/* Prose pages */
.prose { padding-top: 10px; }
.prose h1 { font-family: "Fraunces", serif; font-weight: 600; font-size: clamp(1.8rem, 4.5vw, 2.5rem); margin: 24px 0 18px; letter-spacing: -.02em; }
.prose h2 { font-family: "Fraunces", serif; font-weight: 600; font-size: 1.4rem; margin: 34px 0 10px; }
.prose p { margin: 0 0 16px; max-width: 68ch; }
.prose .lead { font-size: 1.12rem; color: var(--muted); }

.guide-table { width: 100%; border-collapse: collapse; margin: 18px 0 8px; font-size: .95rem; }
.guide-table th, .guide-table td { text-align: left; padding: 12px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.guide-table th { font-weight: 600; color: var(--muted); font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; }
.guide-table td:first-child { font-family: "Fraunces", serif; font-weight: 500; white-space: nowrap; }
@media (max-width: 600px) { .guide-table, .guide-table tbody, .guide-table tr, .guide-table td, .guide-table th { display: block; } .guide-table th { display: none; } .guide-table tr { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin-bottom: 12px; } .guide-table td { border: 0; padding: 4px 0; } .guide-table td:first-child { font-size: 1.05rem; } }

/* Footer */
.site-footer { border-top: 1px solid var(--line); margin-top: 50px; padding: 28px 0 50px; }
.site-footer p { color: var(--muted); font-size: .9rem; margin: 0; max-width: 75ch; }

/* Barre profils (accueil) */
.pbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; justify-content: space-between; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 24px; }
.pbar-profils { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.pbar-profil { font-size: .9rem; color: var(--muted); }
.pbar-profil b { color: var(--ink); font-weight: 600; }
.pbar-drinks { color: var(--accent); }
.pbar-edit { font-size: .88rem; color: var(--accent); white-space: nowrap; }
.pbar-edit:hover { text-decoration: underline; }

/* Répartition « la bonne quantité » */
.split { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 28px; }
.split-label { font-family: "Fraunces", serif; font-weight: 600; font-size: 1.1rem; margin-bottom: 14px; }
.parts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.part { border: 1px solid var(--line); border-radius: 10px; padding: 14px; background: var(--bg); }
.part-nom { font-weight: 600; margin-bottom: 6px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.part-obj { font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #ece6dd; padding: 2px 7px; border-radius: 5px; }
.part-kcal { font-family: "Fraunces", serif; font-size: 1.9rem; font-weight: 600; line-height: 1; }
.part-kcal span { font-size: .9rem; font-weight: 400; color: var(--muted); }
.part-sub { font-size: .9rem; color: #4a423c; margin-top: 4px; }
.part-cible { font-size: .8rem; color: var(--muted); margin-top: 6px; }
.doggybag { margin-top: 14px; background: var(--accent-soft); border-radius: 10px; padding: 12px 16px; font-size: .95rem; }
.doggybag b { color: var(--accent); }
.split-hint { font-size: .82rem; color: var(--muted); margin: 14px 0 0; }
.split-hint a { color: var(--accent); }
@media (max-width: 520px) { .parts { grid-template-columns: 1fr; } }

/* Répartition cliquable + réglages dépliables */
.split .parts { cursor: pointer; border-radius: 10px; transition: outline-color .12s; outline: 2px solid transparent; outline-offset: 4px; }
.split .parts:hover { outline-color: var(--accent-soft); }
.split-tap { font-size: .85rem; color: var(--muted); margin: 12px 0 0; cursor: pointer; display: inline-block; }
.split-tap:hover { color: var(--accent); }
.link-btn { background: none; border: none; color: var(--accent); font-family: inherit; font-size: .9rem; cursor: pointer; padding: 0; }
.link-btn:hover { text-decoration: underline; }
.link-btn.close { grid-column: 1 / -1; justify-self: start; margin-top: 2px; }

.profil-editor { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--line); }
@media (max-width: 560px) { .profil-editor { grid-template-columns: 1fr; } }
.pedit { }
.pedit .p-nom { margin-bottom: 12px; font-size: 1.15rem; }
.pedit .p-row { margin-bottom: 10px; }
.pedit .p-row label { width: 130px; }

/* Composer le repas */
.compose { margin-top: 16px; border-top: 1px dashed var(--line); padding-top: 14px; }
.compose-title { font-weight: 600; font-size: .95rem; margin-bottom: 12px; }
.compose-title span { font-weight: 400; color: var(--muted); font-size: .82rem; }
.compose-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.compose-col { min-width: 0; }
.compose-nom { font-family: "Fraunces", serif; font-weight: 600; font-size: 1.1rem; margin-bottom: 6px; }
.compose-sub2 { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 12px 0 6px; }
.opt-list { display: flex; flex-direction: column; }
.opt-row { display: flex; align-items: center; gap: 9px; padding: 6px 2px; font-size: .93rem; cursor: pointer; }
.opt-row input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; flex-shrink: 0; }
.opt-row .opt-lbl { flex: 1; min-width: 0; }
.opt-row .opt-k { color: var(--muted); font-size: .82em; flex-shrink: 0; }
.compose-col .ct-line { margin-top: 14px; }
.ct-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; font-size: .92rem; background: var(--bg); border-radius: 8px; padding: 9px 12px; }
.ct-tot { font-weight: 600; }
.ct-break { color: var(--muted); font-size: .84rem; }
.ct-budget { font-size: .82rem; margin-left: auto; }
.ct-budget.ok { color: var(--gildas); }
.ct-budget.over { color: var(--accent); }
@media (max-width: 560px) { .compose-grid { grid-template-columns: 1fr; } .ct-budget { margin-left: 0; width: 100%; } }

/* Boissons : case à cocher + détail */
.drinks-zone { margin-top: 16px; border-top: 1px dashed var(--line); padding-top: 14px; }
.drinks-check { display: inline-flex; align-items: center; gap: 9px; font-size: .95rem; cursor: pointer; user-select: none; }
.drinks-check input { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }
.muted-inline { color: var(--muted); font-size: .85rem; }
.rec-drinks { margin-top: 14px; }
.rec-drinks-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 22px; }
.rec-drinks-nom { font-weight: 600; font-size: .95rem; margin-bottom: 4px; }
.rec-drinks-nom span { font-weight: 400; color: var(--muted); font-size: .8rem; }
@media (max-width: 520px) { .rec-drinks-grid { grid-template-columns: 1fr; } }


/* Page profils */
.pcards { display: grid; grid-template-columns: 1fr; gap: 18px; margin: 8px 0 28px; }
@media (min-width: 680px) { .pcards { grid-template-columns: 1fr 1fr; } }
.pcard { border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; background: var(--surface); }
.p-nom { width: 100%; font-family: "Fraunces", serif; font-size: 1.3rem; font-weight: 600; border: none; border-bottom: 2px solid var(--line); background: transparent; padding: 4px 0 8px; margin-bottom: 14px; color: var(--ink); }
.p-nom:focus { outline: none; border-bottom-color: var(--accent); }
.p-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.p-row label { font-size: .9rem; color: var(--muted); width: 120px; flex-shrink: 0; }
.p-num { width: 90px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; font-family: inherit; font-size: 1rem; color: var(--ink); background: var(--bg); }
.p-num:focus { outline: none; border-color: var(--accent); }
.unit { color: var(--muted); font-size: .9rem; }
.p-preset, .p-act { flex: 1; min-width: 140px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; font-family: inherit; font-size: .92rem; background: var(--bg); color: var(--ink); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: none; background: var(--bg); color: var(--muted); font-family: inherit; font-size: .9rem; padding: 7px 14px; cursor: pointer; }
.seg button.on { background: var(--accent); color: #fff; }
.drinks { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 14px; }
.drinks-title { font-weight: 600; font-size: .95rem; margin-bottom: 10px; }
.drink-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 5px 0; }
.drink-lbl { font-size: .92rem; }
.drink-lbl em { color: var(--muted); font-style: normal; font-size: .82rem; }
.stepper { display: inline-flex; align-items: center; gap: 12px; }
.stepper button { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); font-size: 1.1rem; line-height: 1; cursor: pointer; color: var(--ink); }
.stepper button:hover { border-color: var(--accent); color: var(--accent); }
.drink-n { min-width: 16px; text-align: center; font-weight: 600; }
.drinks-sum { margin-top: 12px; font-size: .9rem; color: var(--muted); background: var(--bg); border-radius: 8px; padding: 10px 12px; }
.drinks-sum b { color: var(--ink); }
.p-calc { font-size: .88rem; color: #4a423c; background: var(--accent-soft); border-radius: 8px; padding: 9px 12px; margin: 6px 0 2px; }
.p-calc b { color: var(--accent); font-weight: 600; }
.p-calc .warn { color: var(--accent); font-weight: 600; }

/* Besoins */
.besoins { margin-top: 36px; padding-top: 28px; border-top: 1px solid var(--line); }
.besoins h2 { font-family: "Fraunces", serif; font-weight: 600; font-size: 1.5rem; margin: 0 0 14px; }
.besoins h3 { font-family: "Fraunces", serif; font-weight: 600; font-size: 1.15rem; margin: 26px 0 8px; }
.besoins p { max-width: 70ch; margin: 0 0 14px; }
.besoins ul { padding-left: 20px; max-width: 72ch; }
.besoins li { margin-bottom: 8px; }
.besoins .disclaimer { font-size: .88rem; color: var(--muted); font-style: italic; border-left: 3px solid var(--line); padding-left: 14px; }
.table-scroll { overflow-x: auto; margin: 0 -4px; }
