/* =====================================================
   COULEURS ET POLICES
   ===================================================== */
:root {
  --fond: #F3F5F1;
  --papier: #FFFFFF;
  --encre: #1E2B23;
  --doux: #5D6B62;
  --trait: #D5DDD1;
  --sauge: #DCE6D6;
  --vert: #2F4A3A;
  --sur-vert: #FFFFFF;
  --cassis: #8A2846;
  --moutarde: #E0A526;
  --titre: 'Young Serif', Georgia, 'Times New Roman', serif;
  --texte: 'Figtree', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #131915;
    --papier: #1B231E;
    --encre: #E6ECE4;
    --doux: #A2AFA5;
    --trait: #2E3A32;
    --sauge: #26352C;
    --vert: #9CC9A9;
    --sur-vert: #0F1E15;
    --cassis: #E28AA5;
    --moutarde: #E9B949;
  }
}

/* =====================================================
   BASE
   ===================================================== */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--fond); color: var(--encre); font-family: var(--texte); font-size: 17px; line-height: 1.5; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--moutarde); outline-offset: 2px; border-radius: 6px; }
.chargement { padding: 60px 20px; text-align: center; color: var(--doux); }
[hidden] { display: none !important; }
.contenu { max-width: 960px; margin: 0 auto; padding: 20px 20px calc(110px + env(safe-area-inset-bottom)); }
.page-titre { font-family: var(--titre); font-weight: 400; font-size: 2rem; margin: 0 0 18px; }

/* =====================================================
   EN-TÊTE
   ===================================================== */
.entete { position: sticky; top: 0; z-index: 10; background: var(--vert); color: var(--sur-vert);
  padding: calc(env(safe-area-inset-top) + 12px) 20px 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.logo { font-family: var(--titre); font-weight: 400; font-size: 1.5rem; margin: 0; text-decoration: none; color: inherit; }
.entete-droite { display: flex; align-items: center; gap: 10px; font-size: .95rem; }
.lien-discret { background: none; border: 1px solid currentColor; color: inherit; border-radius: 999px; padding: 6px 14px; font: inherit; font-size: .9rem; cursor: pointer; text-decoration: none; white-space: nowrap; }
.badge { background: var(--moutarde); border-color: var(--moutarde); color: #1E2B23; font-weight: 700; }
.lien-icone { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; padding: 5px 12px; }
.lien-icone svg { display: block; }
@media (max-width: 520px) { .prenom-entete { display: none; } }

/* =====================================================
   LISTE, RECHERCHE, CATÉGORIES
   ===================================================== */
.recherche input { width: 100%; font: inherit; font-size: 1.1rem; padding: 14px 18px; border: 2px solid var(--trait); border-radius: 14px; background: var(--papier); color: var(--encre); }
.recherche input:focus { border-color: var(--vert); outline: none; }

/* Sur téléphone : les catégories défilent avec le doigt */
.cats { display: flex; gap: 8px; overflow-x: auto; padding: 14px 0 6px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.cats::-webkit-scrollbar { display: none; }
/* Sur PC (souris) : les catégories passent à la ligne, tout est visible */
@media (hover: hover) and (pointer: fine) {
  .cats { flex-wrap: wrap; overflow-x: visible; }
}
.cat { flex: none; font: inherit; font-size: .95rem; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--trait); background: var(--papier); color: var(--encre); cursor: pointer; white-space: nowrap; }
.cat.active { background: var(--encre); color: var(--fond); border-color: var(--encre); }

.compteur { color: var(--doux); font-size: .9rem; margin: 10px 0; }
.liste { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr; gap: 0 32px; }
@media (min-width: 760px) { .liste { grid-template-columns: 1fr 1fr; } }
.fiche { display: flex; gap: 14px; align-items: center; padding: 14px 4px; border-bottom: 1px solid var(--trait); text-decoration: none; }
.fiche:hover .fiche-titre { text-decoration: underline; text-decoration-color: var(--moutarde); text-decoration-thickness: 2px; }
.fiche-emoji { flex: none; width: 52px; height: 52px; border-radius: 50%; background: var(--sauge); display: grid; place-items: center; font-size: 1.6rem; }
.fiche-photo { flex: none; width: 52px; height: 52px; border-radius: 50%; object-fit: cover; background: var(--sauge); }
.fiche-titre { display: block; font-family: var(--titre); font-size: 1.2rem; line-height: 1.25; }
.fiche-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--doux); font-size: .88rem; margin-top: 3px; }
.vide { padding: 40px 0; color: var(--doux); text-align: center; list-style: none; }
.btn-ajout { position: fixed; right: 20px; bottom: calc(20px + env(safe-area-inset-bottom)); background: var(--moutarde); color: #1E2B23;
  font-weight: 700; text-decoration: none; padding: 14px 22px; border-radius: 999px; box-shadow: 0 6px 18px rgba(30,43,35,.25); }

/* =====================================================
   BOUTONS
   ===================================================== */
.btn { font: inherit; font-weight: 600; padding: 12px 20px; border-radius: 12px; border: 2px solid var(--vert); background: transparent; color: var(--vert); cursor: pointer; text-decoration: none; display: inline-block; }
.btn-principal { background: var(--vert); color: var(--sur-vert); }
.btn-danger { border-color: var(--cassis); color: var(--cassis); }
.btn:disabled { opacity: .6; cursor: wait; }

/* =====================================================
   FICHE RECETTE
   ===================================================== */
.retour { display: inline-flex; align-items: center; gap: 10px; margin-bottom: 16px; padding: 8px 16px 8px 14px;
  color: var(--encre); font-weight: 600; text-decoration: none; background: var(--papier); border: 1px solid var(--trait); border-radius: 999px; }
.retour::before { content: ''; width: 8px; height: 8px; border-left: 2.5px solid currentColor; border-bottom: 2.5px solid currentColor; transform: rotate(45deg); }
.retour:hover { border-color: var(--vert); }
.recette-photo { display: block; width: 100%; max-height: 440px; object-fit: cover; border-radius: 18px; margin: 0 0 20px; background: var(--sauge); }
.recette-titre { font-family: var(--titre); font-weight: 400; font-size: clamp(2rem, 6vw, 3.2rem); line-height: 1.1; margin: 0 0 12px; }
.recette-desc { font-size: 1.1rem; color: var(--doux); max-width: 65ch; margin: 0 0 18px; }
.infos { display: flex; flex-wrap: wrap; gap: 10px 28px; margin: 0 0 18px; padding: 0; }
.infos div { display: flex; flex-direction: column; }
.infos dt { font-size: .85rem; color: var(--doux); }
.infos dd { margin: 0; font-weight: 600; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.tag { background: var(--sauge); padding: 3px 10px; border-radius: 999px; font-size: .85rem; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 24px; }
.note-delai { color: var(--doux); font-size: .9rem; }
.colonnes { display: grid; gap: 24px; }
@media (min-width: 760px) { .colonnes { grid-template-columns: minmax(260px, 1fr) 2fr; align-items: start; } }
.bloc { background: var(--papier); border-radius: 16px; padding: 20px; }
.bloc h2 { font-family: var(--titre); font-weight: 400; font-size: 1.4rem; margin: 0 0 14px; }
.portions { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.portions button { width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--vert); background: none; color: var(--vert); font-size: 1.3rem; cursor: pointer; line-height: 1; }
.ingredients { list-style: none; margin: 0; padding: 0; }
.ingredients li { padding: 8px 0; border-bottom: 1px dashed var(--trait); }
.ingredients li:last-child { border-bottom: none; }
.etapes { margin: 0; padding: 0; list-style: none; counter-reset: etape; }
.etapes li { counter-increment: etape; display: grid; grid-template-columns: 36px 1fr; gap: 10px; padding: 10px 0; line-height: 1.6; max-width: 70ch; }
.etapes li::before { content: counter(etape); font-family: var(--titre); font-size: 1.3rem; color: var(--vert); }
.pied { color: var(--doux); font-size: .9rem; margin-top: 24px; }

/* =====================================================
   FORMULAIRE RECETTE
   ===================================================== */
.form { display: grid; gap: 16px; max-width: 760px; }
.form h1 { font-family: var(--titre); font-weight: 400; font-size: 2rem; margin: 0; }
.form label { display: grid; gap: 6px; font-weight: 600; }
.form .aide { font-weight: 400; color: var(--doux); font-size: .88rem; }
.form input, .form select, .form textarea { font: inherit; font-size: 16px; font-weight: 400; padding: 12px 14px; border: 2px solid var(--trait); border-radius: 12px; background: var(--papier); color: var(--encre); width: 100%; }
.form textarea { min-height: 150px; resize: vertical; line-height: 1.5; }
.form input:focus, .form select:focus, .form textarea:focus { border-color: var(--vert); outline: none; }
.ligne { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; align-items: end; }
@media (min-width: 760px) { .ligne { grid-template-columns: repeat(5, 1fr); } }
.champ-photo { display: grid; gap: 8px; }
.label-photo { font-weight: 600; }
.apercu-photo { border: 2px dashed var(--trait); border-radius: 14px; min-height: 120px; display: grid; place-items: center; color: var(--doux); overflow: hidden; background: var(--papier); }
.apercu-photo img { display: block; width: 100%; max-height: 320px; object-fit: cover; }
.actions-photo { display: flex; flex-wrap: wrap; gap: 10px; }
.form label.btn { display: inline-block; }
/* Le bouton « Prendre une photo » n'apparaît que sur téléphone / tablette */
@media (hover: hover) and (pointer: fine) { #btnCamera { display: none; } }

/* Fenêtre de recadrage */
.recadrage { position: fixed; inset: 0; z-index: 100; background: rgba(10, 15, 12, .94); display: grid; place-items: center;
  padding: calc(env(safe-area-inset-top) + 12px) 12px calc(env(safe-area-inset-bottom) + 12px); }
.recadrage-boite { width: min(900px, 100%); display: grid; gap: 14px; }
.recadrage-zone { height: min(62vh, 560px); background: #000; border-radius: 12px; overflow: hidden; }
.recadrage-zone img { display: block; max-width: 100%; }
.recadrage-outils { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 24px; }
.recadrage-groupe { display: flex; gap: 6px; }
.outil { font: inherit; font-weight: 600; min-width: 48px; height: 44px; padding: 0 14px; border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .35); background: transparent; color: #FFFFFF; cursor: pointer; }
.outil-rotation { font-size: 1.4rem; line-height: 1; }
.outil.actif { background: #FFFFFF; color: #1E2B23; }
.recadrage-actions { display: flex; justify-content: center; gap: 12px; }
.recadrage .btn { border-color: #FFFFFF; color: #FFFFFF; }
.recadrage .btn-principal { background: var(--moutarde); border-color: var(--moutarde); color: #1E2B23; }
.erreur { color: var(--cassis); font-weight: 600; min-height: 1.2em; margin: 0; }

/* =====================================================
   CONNEXION / INSCRIPTION / ATTENTE
   ===================================================== */
.connexion { min-height: 100vh; display: grid; place-content: center; justify-items: center; padding: 24px; text-align: center; }
.connexion .logo { font-size: 2.6rem; color: var(--vert); }
.connexion > p { margin: 6px 0 0; color: var(--doux); max-width: 36ch; }
.onglets { display: flex; gap: 4px; margin-top: 22px; background: var(--papier); padding: 5px; border-radius: 999px; }
.onglet { font: inherit; font-weight: 600; border: none; background: none; color: var(--doux); padding: 9px 18px; border-radius: 999px; cursor: pointer; }
.onglet.actif { background: var(--vert); color: var(--sur-vert); }
.carte-connexion { background: var(--papier); padding: 24px; border-radius: 18px; display: grid; gap: 14px; text-align: left; width: min(360px, 90vw); margin-top: 14px; }
.carte-connexion label { display: grid; gap: 6px; font-weight: 600; }
.carte-connexion input { font: inherit; font-size: 16px; padding: 12px 14px; border: 2px solid var(--trait); border-radius: 12px; background: var(--fond); color: var(--encre); }
.carte-connexion .aide { font-weight: 400; color: var(--doux); font-size: .85rem; }
.carte-connexion .message { margin: 0; line-height: 1.5; }
.lien-texte { justify-self: center; background: none; border: none; padding: 6px; font: inherit; font-size: .95rem; font-weight: 600;
  color: var(--vert); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.boutons-attente { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 18px; }

/* =====================================================
   MODE CUISINE
   ===================================================== */
.cuisine { position: fixed; inset: 0; z-index: 90; background: var(--fond); color: var(--encre);
  display: grid; grid-template-rows: auto auto 1fr auto auto;
  padding: calc(env(safe-area-inset-top) + 14px) 20px calc(env(safe-area-inset-bottom) + 14px); }
.cuisine-haut, .cuisine-progression, .cuisine-contenu, .cuisine-minuteurs, .cuisine-bas { width: 100%; max-width: 860px; margin-left: auto; margin-right: auto; }
.cuisine-haut { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.cuisine-titre { font-family: var(--titre); font-size: 1.25rem; line-height: 1.2; margin: 0; }
.cuisine-ecran { margin: 4px 0 0; font-size: .85rem; color: var(--doux); }
.cuisine-quitter { font: inherit; font-weight: 600; background: none; border: 2px solid var(--trait); color: var(--encre); border-radius: 999px; padding: 8px 16px; cursor: pointer; }
.cuisine-progression { height: 6px; background: var(--sauge); border-radius: 999px; margin-top: 14px; overflow: hidden; }
.cuisine-barre { height: 100%; width: 0; background: var(--moutarde); transition: width .25s ease; }
.cuisine-contenu { overflow-y: auto; padding: 28px 0 12px; }
.cuisine-num { color: var(--vert); font-weight: 700; font-size: 1.05rem; margin: 0 0 12px; }
.cuisine-h2 { font-family: var(--titre); font-weight: 400; font-size: clamp(1.6rem, 5vw, 2.2rem); margin: 0 0 16px; }
.cuisine-texte { font-size: clamp(1.45rem, 4.8vw, 2.3rem); line-height: 1.45; margin: 0; max-width: 32ch; }
.cuisine-lancer { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.cuisine-ingredients { list-style: none; margin: 0; padding: 0; }
.cuisine-coche { width: 100%; display: flex; align-items: center; gap: 14px; text-align: left; font: inherit; font-size: 1.2rem;
  background: none; border: none; border-bottom: 1px solid var(--trait); color: var(--encre); padding: 14px 4px; cursor: pointer; }
.cuisine-coche .case { flex: none; width: 28px; height: 28px; border: 2px solid var(--vert); border-radius: 8px; display: grid; place-items: center; }
.cuisine-coche.coche .case { background: var(--vert); }
.cuisine-coche.coche .case::after { content: '✓'; color: var(--sur-vert); font-weight: 700; }
.cuisine-coche.coche > span:last-child { text-decoration: line-through; color: var(--doux); }
.cuisine-aide { color: var(--doux); font-size: .95rem; margin-top: 16px; }
.cuisine-rappel { background: var(--sauge); border-radius: 12px; padding: 12px 16px; margin: 20px 0 0; font-weight: 600; font-size: 1.05rem; max-width: 40ch; }
.cuisine-minuteurs { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; padding-bottom: 10px; }

/* Minuteurs (dans le mode cuisine et en bas de toutes les pages) */
.minuteur { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; background: var(--vert); color: var(--sur-vert);
  border-radius: 999px; padding: 4px 4px 4px 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.minuteur-texte { color: inherit; text-decoration: none; padding: 6px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.minuteur-texte strong { margin-right: 4px; }
.minuteur-recette { font-weight: 500; opacity: .85; }
.minuteur-arret { flex: none; font: inherit; font-weight: 700; background: rgba(255, 255, 255, .2); color: inherit; border: none;
  border-radius: 999px; min-width: 38px; height: 38px; padding: 0 12px; cursor: pointer; }
.minuteur.termine { background: var(--cassis); color: var(--fond); animation: clignote 1s steps(2) infinite; }
@keyframes clignote { 50% { opacity: .55; } }
.minuteurs-flottants { position: fixed; left: 12px; right: 12px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 20;
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px; pointer-events: none; }
.minuteurs-flottants .minuteur { pointer-events: auto; box-shadow: 0 6px 18px rgba(30, 43, 35, .3); }
.cuisine-bas { display: flex; justify-content: space-between; gap: 12px; }
.cuisine-bas .btn { flex: 1; max-width: 260px; padding: 16px; font-size: 1.1rem; }
@media (prefers-reduced-motion: reduce) {
  .minuteur.termine { animation: none; }
  .cuisine-barre { transition: none; }
}

/* =====================================================
   FAVORIS, LISTE DE COURSES, MESSAGES
   ===================================================== */
.fiche-favori { color: var(--moutarde); font-size: .95em; }
.btn-favori.actif { background: var(--moutarde); border-color: var(--moutarde); color: #1E2B23; }

.ajout-article { display: flex; gap: 10px; margin-bottom: 18px; }
.ajout-article input { flex: 1; min-width: 0; font: inherit; font-size: 16px; padding: 12px 14px; border: 2px solid var(--trait); border-radius: 12px; background: var(--papier); color: var(--encre); }
.ajout-article input:focus { border-color: var(--vert); outline: none; }
.articles { list-style: none; margin: 0 0 8px; padding: 0; background: var(--papier); border-radius: 16px; overflow: hidden; }
.article { display: flex; align-items: center; border-bottom: 1px solid var(--trait); }
.article:last-child { border-bottom: none; }
.article-case { flex: 1; min-width: 0; display: flex; align-items: center; gap: 14px; text-align: left; font: inherit; font-size: 1.05rem;
  background: none; border: none; color: var(--encre); padding: 14px 16px; cursor: pointer; }
.article-case .case { flex: none; width: 26px; height: 26px; border: 2px solid var(--vert); border-radius: 8px; display: grid; place-items: center; }
.article.coche .case { background: var(--vert); }
.article.coche .case::after { content: '✓'; color: var(--sur-vert); font-weight: 700; }
.article-texte { min-width: 0; }
.article-texte small { display: block; color: var(--doux); font-size: .82rem; margin-top: 2px; }
.article.coche .article-texte { text-decoration: line-through; color: var(--doux); }
.article-suppr { flex: none; width: 48px; height: 48px; background: none; border: none; color: var(--doux); font-size: 1.1rem; cursor: pointer; }
.article-suppr:hover { color: var(--cassis); }
.sous-titre { font-family: var(--titre); font-weight: 400; font-size: 1.3rem; margin: 26px 0 10px; }
.actions-courses { margin-top: 20px; }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 120; transform: translate(-50%, 20px);
  max-width: min(92vw, 480px); background: var(--encre); color: var(--fond); padding: 12px 18px; border-radius: 12px;
  font-weight: 600; text-align: center; opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

/* =====================================================
   SAUVEGARDE
   ===================================================== */
.pied-liste { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 28px; text-align: center; margin: 32px 0 0; font-size: .95rem; color: var(--doux); }
.pied-liste a { color: var(--vert); font-weight: 600; }
.rappel-sauvegarde { flex-basis: 100%; color: var(--cassis); font-weight: 600; }
.form-compte .sous-titre { margin: 8px 0 0; }
.texte-page { max-width: 65ch; margin: 0 0 8px; }
.blocs-sauvegarde { display: grid; gap: 16px; margin-top: 20px; }
@media (min-width: 760px) { .blocs-sauvegarde { grid-template-columns: 1fr 1fr; } }
.blocs-sauvegarde .bloc { display: grid; gap: 12px; align-content: start; }
.blocs-sauvegarde .bloc h2 { margin: 0; }
.blocs-sauvegarde .bloc p { margin: 0; color: var(--doux); }
.blocs-sauvegarde .btn { justify-self: start; }
.case-option { display: flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; }
.case-option input { width: 20px; height: 20px; accent-color: var(--vert); }
.etat-sauvegarde { margin-top: 18px; font-weight: 600; min-height: 1.5em; }
.bloc-restauration { grid-column: 1 / -1; border: 2px dashed var(--trait); }
.bloc-restauration .case-option { font-weight: 500; }
.desactive { opacity: .5; pointer-events: none; }

/* =====================================================
   BANDEAU D'INSTALLATION
   ===================================================== */
.bandeau-install { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px;
  background: var(--moutarde); color: #1E2B23; padding: calc(env(safe-area-inset-top) + 10px) 20px 10px; }
.bandeau-install p { margin: 0; font-weight: 600; max-width: 60ch; }
.bandeau-boutons { display: flex; gap: 8px; align-items: center; }
.bandeau-install .btn-principal { background: #1E2B23; color: #FFFFFF; border-color: #1E2B23; padding: 8px 18px; }
.lien-fermer { background: none; border: none; font: inherit; color: #1E2B23; text-decoration: underline; cursor: pointer; padding: 8px; }

/* =====================================================
   DEMANDES D'ACCÈS (admin)
   ===================================================== */
.demandes { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.demande { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; }
.demande strong { display: block; font-size: 1.1rem; }
.demande .actions { margin: 0; }
