/* Livre de recettes — couleurs en haut du fichier */
:root {
  --encre: #1a241c;
  --papier: #f6f1e7;
  --papier-2: #efe7d8;
  --carte: #fffdf9;
  --discret: #6b6252;
  --trait: #ded2ba;
  --vert: #3f5b43;
  --rouille: #9c4b2e;
  --or: #b8921c;
  --prune: #7a4a6b;
  --tuile: #b5523a;          /* tuiles « à acheter » (le rouge de Bring, en terre cuite) */
  --ombre: 0 1px 2px rgba(40, 30, 10, .06), 0 4px 16px rgba(40, 30, 10, .06);
  --rayon: 12px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --encre: #f2ead6; --papier: #171c16; --papier-2: #222920; --carte: #1e241d;
    --discret: #a79f8c; --trait: #353d30; --vert: #8fb394; --rouille: #e08a68; --or: #d9b54a; --prune: #c99bbb;
    --tuile: #a9503a; --ombre: 0 1px 2px rgba(0, 0, 0, .3); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --encre: #f2ead6; --papier: #171c16; --papier-2: #222920; --carte: #1e241d;
  --discret: #a79f8c; --trait: #353d30; --vert: #8fb394; --rouille: #e08a68; --or: #d9b54a; --prune: #c99bbb;
  --tuile: #a9503a; --ombre: 0 1px 2px rgba(0, 0, 0, .3); color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--papier); color: var(--encre);
  font: 16px/1.5 var(--sans);
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; text-wrap: balance; margin: 0; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; max-width: 100%; }
:focus-visible { outline: 2px solid var(--vert); outline-offset: 2px; }
[hidden] { display: none !important; }
#vue { max-width: 1080px; margin: 0 auto; padding: 16px; outline: none; }

/* Barre du haut + onglets (en bas sur téléphone) */
.barre {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--papier) 90%, transparent); border-bottom: 1px solid var(--trait);
}
/* (le flou crée un repère pour position: fixed : seulement sur grand écran, où les onglets restent dans la barre) */
@media (min-width: 641px) { .barre { backdrop-filter: blur(10px); } }
.marque { font-family: var(--serif); font-size: 20px; font-weight: 600; text-decoration: none; }
.onglets { display: flex; gap: 4px; }
.onglets a {
  display: flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px;
  text-decoration: none; color: var(--discret); font-weight: 600; font-size: 15px;
}
.onglets a.actif { background: var(--vert); color: var(--papier); }
.compteur {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--tuile);
  color: #fff; font-size: 12px; line-height: 20px; text-align: center;
}
@media (max-width: 640px) {
  .onglets {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; justify-content: space-around;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: var(--carte); border-top: 1px solid var(--trait);
  }
  .onglets a { flex: 1; justify-content: center; padding: 10px; }
}
@media (min-width: 641px) { body { padding-bottom: 0; } }

/* Champs, puces, boutons */
.champ {
  width: 100%; padding: 12px 14px 12px 40px; border: 1px solid var(--trait); border-radius: 10px;
  background: var(--carte) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='none' stroke='%236b6252' stroke-width='2'%3E%3Ccircle cx='8' cy='8' r='6'/%3E%3Cpath d='m13 13 4 4'/%3E%3C/svg%3E") 13px 50% no-repeat;
  font-size: 16px;
}
.champ.plus { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='none' stroke='%236b6252' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M9 3v12M3 9h12'/%3E%3C/svg%3E"); }
.puces { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
.puce {
  flex: none; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--trait);
  background: var(--carte); font-size: 14px; font-weight: 600; color: var(--discret);
}
.puce[aria-pressed="true"] { background: var(--encre); border-color: var(--encre); color: var(--papier); }
.bouton {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 18px;
  border-radius: 10px; border: 0; background: var(--vert); color: var(--papier); font-weight: 700; text-decoration: none;
}
.bouton.large { width: 100%; margin-top: 12px; }
.bouton.large + .bouton.large { margin-top: 8px; }
.bouton.discret { background: var(--papier-2); color: var(--encre); }
.bouton.danger { background: none; color: var(--rouille); border: 1px solid currentColor; }
.bouton:disabled { opacity: .5; cursor: default; }
.lien { border: 0; background: none; padding: 4px 0; color: var(--vert); font-weight: 700; font-size: 14px; }
.bascule { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.bascule input { width: 18px; height: 18px; accent-color: var(--vert); }
.aide { font-size: 13px; color: var(--discret); margin: 10px 0 0; }
.muted { color: var(--discret); font-style: italic; }
.vide { text-align: center; color: var(--discret); padding: 48px 16px; }

/* Liste des recettes */
.recherche { display: flex; flex-direction: column; gap: 12px; margin: 8px 0 16px; }
.resultat { display: flex; justify-content: space-between; align-items: center; color: var(--discret); font-size: 14px; margin: 0 0 10px; }
.grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
@media (max-width: 520px) { .grille { grid-template-columns: 1fr 1fr; gap: 12px; } }
.vignette {
  display: flex; flex-direction: column; background: var(--carte); border-radius: var(--rayon);
  overflow: hidden; text-decoration: none; box-shadow: var(--ombre); border: 1px solid var(--trait); transition: transform .15s;
}
.vignette:hover { transform: translateY(-2px); }
.vignette .photo { aspect-ratio: 4 / 3; background: var(--papier-2); position: relative; }
.vignette .photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.vignette .cat, .menu-badge {
  position: absolute; left: 8px; top: 8px; padding: 2px 9px; border-radius: 999px; font-size: 11px;
  font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: #fff; background: var(--accent);
}
.menu-badge { left: auto; right: 8px; background: var(--vert); color: var(--papier); }
.vignette .infos { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.vignette h2 { font-size: 17px; }
.vignette .meta { font-size: 13px; color: var(--discret); margin-top: auto; }
.vignette .a-completer { color: var(--rouille); }
@media (max-width: 520px) { .vignette h2 { font-size: 15px; } .vignette .meta { font-size: 12px; } }

/* Fiche recette */
.retour { display: inline-flex; gap: 6px; text-decoration: none; color: var(--discret); font-weight: 600; margin: 4px 0 12px; }
.fiche-tete { display: grid; gap: 20px; margin-bottom: 24px; }
@media (min-width: 760px) { .fiche-tete { grid-template-columns: 1fr 1fr; align-items: center; } }
.fiche-photo { position: relative; border-radius: var(--rayon); overflow: hidden; aspect-ratio: 16 / 10; max-height: 42vh; background: var(--papier-2); }
@media (min-width: 760px) { .fiche-photo { aspect-ratio: 4 / 3; max-height: none; } }
.fiche-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.fiche-tete .cat { color: var(--accent); font-size: 12px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; }
.au-menu { color: var(--vert); }
.fiche-tete h1 { font-size: clamp(26px, 5vw, 38px); margin: 6px 0 14px; }
.chiffres { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chiffres span { padding: 4px 11px; background: var(--papier-2); border-radius: 999px; font-size: 14px; }
.source { font-size: 14px; color: var(--discret); }

.fiche-corps { display: grid; gap: 28px; }
@media (min-width: 760px) {
  .fiche-corps { grid-template-columns: minmax(280px, 380px) 1fr; align-items: start; }
  .bloc-ingredients { position: sticky; top: 76px; }
}
.bloc { background: var(--carte); border: 1px solid var(--trait); border-radius: var(--rayon); padding: 18px; }
.bloc-titre { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.bloc-titre h2 { font-size: 22px; }
.portions { display: inline-flex; align-items: center; border: 1px solid var(--trait); border-radius: 999px; }
.portions button { width: 36px; height: 36px; border: 0; background: none; font-size: 20px; border-radius: 999px; }
.portions button:hover { background: var(--papier-2); }
.portions output { min-width: 64px; text-align: center; font-weight: 600; font-size: 14px; }

.sous-titre { font-size: 13px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: 1px; margin: 14px 0 4px; }
.ingredients { list-style: none; margin: 0; padding: 0; }
.ing {
  display: flex; gap: 10px; align-items: flex-start; width: 100%; padding: 9px 2px; text-align: left;
  border: 0; border-bottom: 1px dashed var(--trait); background: none;
}
.ing .case {
  flex: none; width: 20px; height: 20px; margin-top: 2px; border: 2px solid var(--trait); border-radius: 6px;
  display: grid; place-items: center; font-size: 13px; color: #fff;
}
.ing[aria-checked="true"] .case { background: var(--vert); border-color: var(--vert); }
.ing[aria-checked="true"] .case::after { content: "✓"; }
.ing[aria-checked="true"] .txt { color: var(--discret); text-decoration: line-through; }
.ing .txt { flex: 1; }
.ing .q { font-weight: 700; color: var(--accent); }
.ing .prec { color: var(--discret); }
.dans-liste { font-size: 13px; opacity: .8; }

.note { background: var(--papier-2); border-left: 3px solid var(--accent); padding: 10px 12px; border-radius: 0 8px 8px 0; font-size: 14.5px; margin-bottom: 14px; }
.etapes { list-style: none; margin: 0; padding: 0; counter-reset: etape; }
.etape {
  display: flex; gap: 14px; padding: 12px 8px; margin: 0 -8px; border-radius: 8px;
  font-size: 16px; line-height: 1.55; counter-increment: etape; cursor: pointer;
}
.etape:hover { background: var(--papier-2); }
.etape::before {
  content: counter(etape); flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 14px;
}
.etape[aria-checked="true"] { color: var(--discret); }
.etape[aria-checked="true"]::before { content: "✓"; background: var(--trait); color: var(--discret); }
.cuisine .etape { font-size: 20px; padding: 18px 10px; }
.cuisine .etape.suivante { background: var(--papier-2); outline: 2px solid var(--accent); }
.minut {
  display: inline; padding: 1px 8px; margin: 0 1px; border-radius: 999px; border: 1px solid var(--accent);
  background: var(--carte); color: inherit; font-size: .92em; font-weight: 600; white-space: nowrap;
}
.minut:hover { background: var(--accent); color: #fff; }

/* Minuteurs (au-dessus des onglets) */
.minuteurs {
  position: fixed; z-index: 15; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 6px; max-width: calc(100% - 24px);
}
@media (min-width: 641px) { .minuteurs { bottom: 16px; } }
.minuteur {
  display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 14px; border-radius: 999px;
  background: var(--encre); color: var(--papier); box-shadow: var(--ombre); font-size: 14px;
}
.minuteur .nom { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46vw; opacity: .8; }
.minuteur b { font-variant-numeric: tabular-nums; font-size: 17px; }
.minuteur button { width: 30px; height: 30px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .15); color: inherit; }
.minuteur.fini { background: var(--tuile); animation: clignote 1s infinite; }
@keyframes clignote { 50% { opacity: .65; } }

/* Liste de courses */
.courses { max-width: 760px; margin: 0 auto; }
.ajout-barre { position: sticky; top: 61px; z-index: 5; display: flex; gap: 8px; padding: 8px 0 10px; background: var(--papier); }
.resume { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; color: var(--discret); margin: 0 0 6px; font-size: 14px; }
.sync { font-size: 13px; }
.sync.ok { color: var(--vert); }
.sync.hors-ligne { color: var(--rouille); }
.titre-rayon { font-family: var(--sans); font-size: 14px; font-weight: 700; color: var(--discret); margin: 20px 0 8px; }
.tuiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.tuile {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  aspect-ratio: 1; padding: 8px 6px; border: 0; border-radius: 10px; text-align: center;
  background: var(--papier-2); color: var(--encre); transition: transform .18s, opacity .18s; touch-action: manipulation;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.tuile:active { transform: scale(.95); }
.tuile .emoji { font-size: 30px; line-height: 1.1; }
.tuile .nom { font-size: 13px; font-weight: 600; line-height: 1.2; overflow-wrap: anywhere; }
.tuile .sous { font-size: 11.5px; opacity: .85; line-height: 1.2; }
.tuile.a-acheter { background: var(--tuile); color: #fff; }
.tuile.recent { background: var(--papier-2); color: var(--discret); }
.tuile.nouveau { background: var(--carte); border: 2px dashed var(--tuile); color: var(--tuile); }
.tuile .pastille { position: absolute; top: 7px; right: 7px; width: 7px; height: 7px; border-radius: 50%; background: #fff; opacity: .8; }
.tuile.part { transform: scale(.6); opacity: 0; }
.menu-bande { display: flex; gap: 10px; overflow-x: auto; margin: 0 -16px; padding: 0 16px 4px; scrollbar-width: none; }
.menu-carte { position: relative; flex: none; width: 150px; background: var(--carte); border: 1px solid var(--trait); border-radius: 10px; overflow: hidden; }
.menu-carte a { display: block; text-decoration: none; }
.menu-carte img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; }
.menu-carte span { display: block; padding: 6px 8px 8px; font-size: 13px; font-weight: 600; line-height: 1.25; }
.menu-carte small { display: block; color: var(--discret); font-weight: 400; }
.menu-carte button { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border: 0; border-radius: 50%; background: rgba(0, 0, 0, .55); color: #fff; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; }

.fiche-article { border: 0; border-radius: 16px; padding: 20px; width: min(420px, calc(100% - 32px)); background: var(--carte); color: var(--encre); box-shadow: var(--ombre); }
.fiche-article::backdrop { background: rgba(0, 0, 0, .4); }
.fiche-article h2 { font-size: 22px; margin-bottom: 14px; }
.fiche-article label:not(.bascule) { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 700; color: var(--discret); margin-bottom: 12px; }
.fiche-article input:not([type=checkbox]), .fiche-article select {
  padding: 10px 12px; border: 1px solid var(--trait); border-radius: 8px; background: var(--papier); font-size: 16px; font-weight: 400; color: var(--encre);
}
.fiche-article .court { width: 90px; }
.detail-q { background: var(--papier-2); border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; font-size: 14px; }
.detail-q div { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; }
.detail-q .bascule { margin-top: 6px; font-weight: 400; }
.fiche-article .actions { margin-top: 8px; }

.connexion { max-width: 360px; margin: 40px auto; text-align: center; }
.connexion h2 { font-size: 24px; margin-bottom: 8px; }
.connexion p { color: var(--discret); }
.connexion .champ { padding-left: 14px; background-image: none; }
.erreur { color: var(--rouille); font-weight: 600; }

.toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 20; display: flex; gap: 16px; align-items: center; max-width: calc(100% - 32px); white-space: nowrap;
  padding: 12px 16px; border-radius: 10px; background: var(--encre); color: var(--papier); box-shadow: var(--ombre); font-size: 15px;
}
.toast a, .toast button { color: var(--or); font-weight: 700; background: none; border: 0; padding: 0; text-decoration: none; }
@media (min-width: 641px) { .toast { bottom: 24px; } }
