:root {
  --fond: #0A1322;
  --surface: #131D2E;
  --surface2: #1A2639;
  --surface3: #223048;
  --trait: #2A3A55;
  --texte: #F3F5F9;
  --texte2: #9CA8BC;
  --texte3: #6B7891;
  --accent: #FF8A3D;
  --accent-fond: rgba(255, 138, 61, .16);
  --ok: #3DDC97;
  --alerte: #FFC14D;
  --rayon: 18px;
  --onglets: 64px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--fond); color: var(--texte); }
body { font-size: 16px; line-height: 1.45; overscroll-behavior-y: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }

#appli { min-height: 100vh; padding-bottom: calc(var(--onglets) + env(safe-area-inset-bottom)); }
.barre {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: rgba(10, 19, 34, .92);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--trait);
}
.barre h1 { font-size: 20px; font-weight: 600; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.retour { background: none; border: 0; padding: 6px; margin-left: -8px; border-radius: 50%; display: flex; }
.retour:active { background: var(--surface2); }
.etat { font-size: 12px; color: var(--alerte); border: 1px solid var(--alerte); border-radius: 10px; padding: 1px 8px; }
main { padding: 12px 16px 24px; max-width: 980px; margin: 0 auto; outline: none; }

.onglets {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; background: rgba(19, 29, 46, .96);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--trait);
  padding-bottom: env(safe-area-inset-bottom);
}
.onglets a {
  flex: 1; height: var(--onglets); display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--texte2); text-decoration: none; font-size: 11.5px; position: relative;
}
.onglets a.actif { color: var(--accent); }
.onglets a.actif svg { stroke-width: 2.2; }
.pastille {
  position: absolute; top: 7px; left: calc(50% + 6px); min-width: 18px; height: 18px; border-radius: 9px; padding: 0 5px;
  background: var(--accent); color: #1B0F05; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}

/* recherche et filtres */
.recherche { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--trait); border-radius: 26px; padding: 0 8px 0 16px; height: 48px; }
.recherche svg { color: var(--texte2); flex: none; }
.recherche input { flex: 1; min-width: 0; background: none; border: 0; outline: none; font-size: 16px; }
.recherche input::placeholder { color: var(--texte3); }
.recherche .effacer { background: none; border: 0; color: var(--texte2); padding: 8px; display: flex; }
.puces { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0 4px; scrollbar-width: none; margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
.puces::-webkit-scrollbar { display: none; }
.puce {
  flex: none; border: 1px solid var(--trait); background: var(--surface); color: var(--texte); border-radius: 18px;
  height: 36px; padding: 0 14px; font-size: 14px; white-space: nowrap;
}
.puce.choisie { background: var(--accent); border-color: var(--accent); color: #1B0F05; font-weight: 600; }
.puce.groupe { color: var(--texte2); }
.puce.groupe.choisie { background: var(--surface3); border-color: var(--texte2); color: var(--texte); }
.compte { color: var(--texte2); font-size: 13.5px; margin: 8px 0 10px; }

/* grille de recettes */
.grille { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 640px) { .grille { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 900px) { .grille { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.carte { background: var(--surface); border-radius: var(--rayon); overflow: hidden; text-decoration: none; color: inherit; display: flex; flex-direction: column; position: relative; }
.carte:active { transform: scale(.985); }
.carte .photo { aspect-ratio: 4/3; background: var(--surface2); position: relative; overflow: hidden; }
.carte .photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.carte .initiales { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 34px; font-weight: 200; color: rgba(255,255,255,.35); }
.carte .fav { position: absolute; top: 8px; right: 8px; color: var(--accent); filter: drop-shadow(0 1px 2px rgba(0,0,0,.6)); }
.carte .fav svg { fill: var(--accent); width: 20px; height: 20px; }
.carte .marque { position: absolute; left: 8px; top: 8px; background: rgba(10,19,34,.82); color: var(--accent); font-size: 11px; font-weight: 600; border-radius: 9px; padding: 2px 8px; }
.carte .corps { padding: 9px 11px 11px; }
.carte h3 { font-size: 14.5px; font-weight: 600; margin: 0; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.carte .meta { font-size: 12.5px; color: var(--texte2); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plus { display: block; margin: 18px auto 0; background: var(--surface2); border: 1px solid var(--trait); border-radius: 22px; height: 44px; padding: 0 22px; }
.vide { text-align: center; color: var(--texte2); padding: 48px 16px; }
.vide svg { width: 48px; height: 48px; color: var(--texte3); }

/* recette */
.entete-photo { margin: -12px -16px 0; aspect-ratio: 16/10; max-height: 46vh; background: var(--surface2); position: relative; overflow: hidden; }
.entete-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
@media (min-width: 900px) { .entete-photo { margin: 0; border-radius: var(--rayon); } }
.recette h2 { font-size: 24px; line-height: 1.25; margin: 16px 0 6px; }
.infos { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--texte2); font-size: 14px; }
.infos b { color: var(--texte); font-weight: 600; }
.etiquettes { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.etiquette { font-size: 12.5px; border-radius: 10px; padding: 2px 9px; background: var(--surface2); color: var(--texte2); }
.etiquette.chaude { background: var(--accent-fond); color: var(--accent); }
.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0 6px; }
.action { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px; background: var(--surface); border: 1px solid var(--trait); border-radius: 14px; font-size: 13px; }
.action.active { border-color: var(--accent); color: var(--accent); background: var(--accent-fond); }
.action.active svg.plein { fill: var(--accent); }
.bloc { background: var(--surface); border-radius: var(--rayon); padding: 14px 16px; margin-top: 14px; }
.bloc h4 { margin: 0 0 10px; font-size: 17px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.portions { display: flex; align-items: center; gap: 4px; font-size: 15px; font-weight: 500; }
.portions button { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--trait); background: var(--surface2); font-size: 20px; line-height: 1; display: flex; align-items: center; justify-content: center; }
.portions span { min-width: 92px; text-align: center; }
.ingredients { list-style: none; margin: 0; padding: 0; }
.ingredients li { display: flex; gap: 12px; padding: 8px 0; border-top: 1px solid var(--surface3); }
.ingredients li:first-child { border-top: 0; }
.ingredients .q { flex: 0 0 34%; color: var(--accent); font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.ingredients .groupe-ing { color: var(--texte2); font-size: 13px; text-transform: uppercase; letter-spacing: .04em; padding-top: 14px; border-top: 0; }
.etapes { list-style: none; margin: 0; padding: 0; counter-reset: e; }
.etapes li { position: relative; padding: 12px 0 12px 40px; border-top: 1px solid var(--surface3); counter-increment: e; white-space: pre-line; }
.etapes li:first-child { border-top: 0; }
.etapes li::before { content: counter(e); position: absolute; left: 0; top: 11px; width: 28px; height: 28px; border-radius: 50%; background: var(--surface3); color: var(--texte2); font-size: 13px; font-weight: 600; display: flex; align-items: center; justify-content: center; }
.etapes .qte { color: var(--accent); font-weight: 600; }
.reglage { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; padding: 5px 11px; border-radius: 12px; background: var(--accent-fond); color: var(--accent); font-size: 13.5px; font-weight: 600; white-space: normal; }
.reglage svg { width: 16px; height: 16px; }
.reglage .verif { color: var(--alerte); font-weight: 500; }
.pesee { display: inline-block; margin-top: 8px; padding: 4px 10px; border-radius: 12px; background: var(--surface2); color: var(--texte2); font-size: 13.5px; }
.note { color: var(--texte2); white-space: pre-line; font-size: 14.5px; }
.source { color: var(--texte3); font-size: 13px; margin-top: 18px; text-align: center; }
.source a { color: var(--texte2); }

/* listes (à cuisiner, courses) */
.ligne { display: flex; align-items: center; gap: 12px; background: var(--surface); border-radius: 16px; padding: 10px; margin-bottom: 10px; text-decoration: none; color: inherit; }
.ligne .vignette { width: 72px; height: 56px; border-radius: 12px; background: var(--surface2); overflow: hidden; flex: none; }
.ligne .vignette img { width: 100%; height: 100%; object-fit: cover; }
.ligne .txt { flex: 1; min-width: 0; }
.ligne .txt b { display: block; font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ligne .txt small { color: var(--texte2); font-size: 13px; }
.ligne .ote { background: none; border: 0; color: var(--texte3); padding: 10px; display: flex; }
.case { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-top: 1px solid var(--surface3); cursor: pointer; }
.case:first-child { border-top: 0; }
.case input { appearance: none; -webkit-appearance: none; width: 24px; height: 24px; border-radius: 7px; border: 2px solid var(--texte3); flex: none; display: grid; place-content: center; margin: 0; }
.case input:checked { background: var(--accent); border-color: var(--accent); }
.case input:checked::after { content: ""; width: 10px; height: 6px; border: solid #1B0F05; border-width: 0 0 2.5px 2.5px; transform: rotate(-45deg) translate(1px, -1px); }
.case.fait span { color: var(--texte3); text-decoration: line-through; }
.ajout { display: flex; gap: 8px; margin-bottom: 12px; }
.ajout input { flex: 1; min-width: 0; height: 46px; border-radius: 23px; border: 1px solid var(--trait); background: var(--surface); padding: 0 16px; outline: none; }
.bouton { height: 46px; border-radius: 23px; border: 0; padding: 0 20px; background: var(--accent); color: #1B0F05; font-weight: 600; font-size: 15px; }
.bouton.second { background: var(--surface2); color: var(--texte); border: 1px solid var(--trait); }
.bouton:disabled { opacity: .5; }
.titre-section { font-size: 13px; color: var(--texte2); text-transform: uppercase; letter-spacing: .05em; margin: 20px 0 8px; }

/* feuille (bas d'écran) */
.feuille { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .55); display: flex; align-items: flex-end; justify-content: center; }
.feuille .panneau { width: 100%; max-width: 620px; max-height: 88vh; overflow: auto; background: var(--surface); border-radius: 22px 22px 0 0; padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); animation: monte .18s ease-out; }
@keyframes monte { from { transform: translateY(30px); opacity: .4; } }
.feuille h3 { margin: 0 0 4px; font-size: 19px; }
.feuille p.aide { margin: 0 0 10px; color: var(--texte2); font-size: 14px; }
.feuille .pied { display: flex; gap: 10px; margin-top: 14px; position: sticky; bottom: 0; }
.feuille .pied .bouton { flex: 1; }

/* connexion */
.connexion { max-width: 380px; margin: 12vh auto 0; text-align: center; }
.connexion .logo { width: 84px; height: 84px; border-radius: 26px; background: var(--accent-fond); display: inline-flex; align-items: center; justify-content: center; color: var(--accent); }
.connexion .logo svg { width: 46px; height: 46px; }
.connexion h2 { margin: 16px 0 6px; }
.connexion p { color: var(--texte2); margin: 0 0 20px; }
.connexion input { width: 100%; height: 50px; border-radius: 25px; border: 1px solid var(--trait); background: var(--surface); padding: 0 18px; outline: none; margin-bottom: 12px; font-size: 16px; }
.connexion .bouton { width: 100%; }
.erreur { color: #FF6B6B; font-size: 14px; min-height: 20px; margin-top: 8px; }

.toast { position: fixed; left: 50%; bottom: calc(var(--onglets) + 16px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); background: var(--surface3); color: var(--texte); padding: 10px 18px; border-radius: 22px; font-size: 14.5px; opacity: 0; transition: .2s; pointer-events: none; z-index: 30; max-width: calc(100% - 32px); text-align: center; box-shadow: 0 6px 24px rgba(0,0,0,.4); }
.toast.visible { opacity: 1; transform: translateX(-50%); }
.squelette { background: linear-gradient(90deg, var(--surface) 0, var(--surface2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: brille 1.2s infinite; border-radius: var(--rayon); }
@keyframes brille { to { background-position: -200% 0; } }
