:root {
  --fond: #faf7f2;
  --surface: #ffffff;
  --texte: #1f1a17;
  --doux: #6b625b;
  --ligne: #e8e1d8;
  --accent: #c2410c;
  --accent-texte: #ffffff;
  --accent-pale: #fdebe1;
  --ok: #15803d;
  --erreur: #b91c1c;
  --ombre: 0 1px 2px rgb(0 0 0 / .06), 0 4px 14px rgb(0 0 0 / .06);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #171412;
    --surface: #221e1b;
    --texte: #f3eee9;
    --doux: #a89e95;
    --ligne: #3a332e;
    --accent: #fb923c;
    --accent-texte: #1f1206;
    --accent-pale: #3a2417;
    --ok: #4ade80;
    --erreur: #f87171;
    --ombre: none;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--fond);
  color: var(--texte);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  padding-bottom: 96px;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }

.barre {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  background: var(--fond);
  border-bottom: 1px solid var(--ligne);
}
.barre h1 { font-size: 20px; margin: 0; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.retour { border: 0; background: none; padding: 6px; margin-left: -6px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; }

main { max-width: 720px; margin: 0 auto; padding: 16px; }

/* Recherche */
.recherche {
  width: 100%; padding: 12px 14px 12px 42px;
  border: 1px solid var(--ligne); border-radius: 12px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='20' height='20' fill='none' stroke='%238a817a' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E") no-repeat 14px center;
  outline: none;
}
.recherche:focus { border-color: var(--accent); }
.filtres { display: flex; gap: 8px; overflow-x: auto; padding: 12px 0 4px; scrollbar-width: none; }
.filtres::-webkit-scrollbar { display: none; }
.puce {
  flex: none; border: 1px solid var(--ligne); background: var(--surface);
  border-radius: 999px; padding: 6px 12px; font-size: 14px; cursor: pointer;
}
.puce.active { background: var(--accent); border-color: var(--accent); color: var(--accent-texte); }

/* Liste */
.compte { color: var(--doux); font-size: 14px; margin: 12px 2px 8px; }
.liste { display: grid; gap: 12px; }
.carte {
  display: flex; gap: 12px; align-items: stretch;
  background: var(--surface); border: 1px solid var(--ligne); border-radius: 14px;
  box-shadow: var(--ombre); overflow: hidden; cursor: pointer; text-align: left;
  padding: 0; width: 100%;
}
.carte .image { flex: none; width: 88px; min-height: 88px; background: var(--accent-pale) center/cover; display: grid; place-items: center; font-size: 32px; }
.carte .corps { padding: 10px 12px 10px 0; min-width: 0; }
.carte h2 { font-size: 16px; margin: 0 0 2px; line-height: 1.3; }
.carte .meta { color: var(--doux); font-size: 13px; }
.carte .tags { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px; }
.tag { font-size: 12px; background: var(--accent-pale); color: var(--texte); border-radius: 6px; padding: 1px 7px; }
.vide { text-align: center; color: var(--doux); padding: 48px 16px; }

/* Détail */
.entete-recette { border-radius: 16px; overflow: hidden; background: var(--accent-pale) center/cover; aspect-ratio: 16/10; margin-bottom: 16px; display: grid; place-items: center; font-size: 64px; }
.recette h2 { font-size: 24px; line-height: 1.25; margin: 0 0 4px; }
.infos { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.info { background: var(--surface); border: 1px solid var(--ligne); border-radius: 10px; padding: 6px 10px; font-size: 14px; }
.info b { display: block; font-size: 12px; color: var(--doux); font-weight: 500; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0; }
.bouton {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--ligne); background: var(--surface); border-radius: 10px;
  padding: 10px 14px; text-decoration: none; color: var(--texte); cursor: pointer; font-weight: 600; font-size: 15px;
}
.bouton.principal { background: var(--accent); border-color: var(--accent); color: var(--accent-texte); }
.bouton.danger { color: var(--erreur); }
.bouton:disabled { opacity: .6; }
.recette h3 { font-size: 18px; margin: 24px 0 8px; }
.ingredients { list-style: none; padding: 0; margin: 0; }
.ingredients label { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--ligne); cursor: pointer; }
.ingredients input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.ingredients input:checked + span { text-decoration: line-through; color: var(--doux); }
.quantite { font-weight: 600; }
.etapes { padding: 0; margin: 0; list-style: none; counter-reset: etape; }
.etapes li { counter-increment: etape; position: relative; padding: 0 0 16px 40px; }
.etapes li::before {
  content: counter(etape); position: absolute; left: 0; top: 0;
  width: 28px; height: 28px; border-radius: 50%; background: var(--accent-pale);
  display: grid; place-items: center; font-weight: 700; font-size: 14px;
}
.astuces { padding-left: 20px; margin: 0; }
.remarque { color: var(--doux); font-size: 14px; font-style: italic; margin-top: 20px; }
.source { color: var(--doux); font-size: 13px; margin-top: 8px; }

/* Ajout */
.panneau { background: var(--surface); border: 1px solid var(--ligne); border-radius: 16px; padding: 16px; box-shadow: var(--ombre); }
.panneau p { margin: 0 0 12px; }
.champ { width: 100%; padding: 12px 14px; border: 1px solid var(--ligne); border-radius: 10px; background: var(--fond); outline: none; margin-bottom: 12px; }
.champ:focus { border-color: var(--accent); }
.aide { color: var(--doux); font-size: 14px; margin-top: 16px; }
.attente { text-align: center; padding: 32px 8px; }
.roue { width: 44px; height: 44px; border: 4px solid var(--accent-pale); border-top-color: var(--accent); border-radius: 50%; margin: 0 auto 16px; animation: tourne 1s linear infinite; }
@keyframes tourne { to { transform: rotate(360deg); } }
.message-erreur { color: var(--erreur); }

.bouton-ajout {
  position: fixed; right: 20px; bottom: calc(env(safe-area-inset-bottom) + 20px); z-index: 6;
  width: 60px; height: 60px; border-radius: 18px; border: 0;
  background: var(--accent); color: var(--accent-texte);
  box-shadow: 0 6px 18px rgb(0 0 0 / .25); display: grid; place-items: center; cursor: pointer;
}
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 96px); transform: translateX(-50%);
  background: var(--texte); color: var(--fond); padding: 10px 16px; border-radius: 10px; z-index: 10;
  max-width: calc(100% - 32px); font-size: 15px;
}
