/* FrigoMiam — styles hors Tailwind
 * Palette : givre #EDF3F4 · aubergine #2B1A33 · citron #F5D93A · basilic #1E7A4E · tomate #D93A3A
 * (les mêmes valeurs sont déclarées dans la config Tailwind de index.php)
 */

:root {
  --dock-height: 15rem;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html {
  background: #EDF3F4;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  overscroll-behavior-y: none;
  text-rendering: optimizeLegibility;
}

/* L'attribut hidden doit gagner sur les classes d'affichage de Tailwind */
[hidden] {
  display: none !important;
}

/* Zones sûres (encoche, barre d'accueil) */
.pt-safe {
  padding-top: var(--safe-top);
}

.hero {
  min-height: 100dvh;
  padding-bottom: calc(var(--dock-height) + var(--safe-bottom));
}

/* L'espace sous l'accueil est porté par le pied de page (.after-hero-foot) */
.after-hero {
  padding-bottom: 0;
}

.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  padding-top: 1.75rem;
  padding-bottom: calc(0.75rem + var(--safe-bottom));
  background: linear-gradient(to bottom, rgba(237, 243, 244, 0) 0, #EDF3F4 1.75rem);
}

/* Tablette et grand écran : deux colonnes, l'action rejoint le texte */
@media (min-width: 768px) {
  .hero {
    min-height: min(100dvh, 56rem);
    padding-bottom: 2.5rem;
  }

  .after-hero {
    padding-bottom: 0;
  }

  .dock {
    position: static;
    margin-top: 2rem;
    padding: 0;
    background: none;
  }
}

/* Souris ou trackpad : pas d'appareil photo à déclencher, un seul bouton
   « Choisir une photo ». Écran tactile : scanner + importer. */
@media (hover: none), (pointer: coarse) {
  .pointer-only {
    display: none !important;
  }
}

@media (hover: hover) and (pointer: fine) {
  .touch-only {
    display: none !important;
  }
}

/* Focus clavier visible partout */
:focus-visible {
  outline: 3px solid #2B1A33;
  outline-offset: 3px;
}

/* Titres qui reçoivent le focus par script (lecteurs d'écran) : pas de cadre */
h1[tabindex="-1"]:focus,
h2[tabindex="-1"]:focus {
  outline: none;
}

/* Bouton en attente : il reste net et tourne */
.btn.is-loading[disabled],
.btn[aria-busy="true"][disabled] {
  opacity: 1;
}

.btn.is-loading::before {
  content: "";
  flex: none;
  width: 1rem;
  height: 1rem;
  margin-right: 0.5rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 999px;
  animation: fm-spin 0.8s linear infinite;
}

@keyframes fm-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn.is-loading::before {
    animation-duration: 2.4s;
  }
}

/* Boutons : retour tactile immédiat */
.btn {
  cursor: pointer;
  transition:
    transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1),
    box-shadow 180ms ease,
    background-color 120ms ease;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.btn[disabled] {
  opacity: 0.6;
  pointer-events: none;
}

/* Le frigo ------------------------------------------------------------- */

.fridge {
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 24px 48px -28px rgba(43, 26, 51, 0.35);
}

/* Lumière froide qui tombe du haut, comme à l'ouverture de la porte */
.fridge::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 45%;
  background: linear-gradient(to bottom, rgba(237, 243, 244, 0.9), rgba(237, 243, 244, 0));
  pointer-events: none;
}

/* Les clayettes : chaque aliment est posé dessus, son étiquette juste en dessous.
   La taille des dessins suit la hauteur du frigo : --u vaut 1 % de cette
   hauteur, tenu à jour par app.js (valeur de repli pour un frigo de 22rem). */
.shelf {
  flex: 1 1 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  gap: 0.25rem;
  padding: 0.25rem 0.75rem 0.5rem;
}

.shelf-top {
  flex-basis: 1.25rem;          /* la place du thermostat, en haut */
  padding-top: 1.5rem;
}

.shelf-drawer {
  flex-basis: 4.75rem;          /* la place de la recette, en bas */
  padding-bottom: 5.25rem;
}

.food {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}

.food svg {
  display: block;
  width: auto;
  height: calc(var(--h, 10) * var(--u, 0.22rem));
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3125rem;
  margin-top: 0.375rem;
  padding: 0.3125rem 0.5rem;
  border-radius: 999px;
  background: #EDF3F4;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
}

.tag-light {
  background: #FFFFFF;
  box-shadow: 0 0 0 1px rgba(43, 26, 51, 0.06);
}

.tag .dot {
  width: 0.375rem;
  height: 0.375rem;
  border-radius: 999px;
}

@media (min-width: 1024px) {
  .tag {
    font-size: 0.8125rem;
    padding: 0.375rem 0.625rem;
  }
}

.scanline {
  position: absolute;
  left: 0;
  right: 0;
  top: -5rem;
  height: 5rem;
  background: linear-gradient(to bottom, rgba(245, 217, 58, 0), rgba(245, 217, 58, 0.38));
  border-bottom: 2px solid #F5D93A;
  pointer-events: none;
  opacity: 0;
}

/* Séquence d'ouverture, jouée une seule fois :
   la ligne balaie le frigo, les ingrédients apparaissent à son passage,
   puis la recette arrive. */
@media (prefers-reduced-motion: no-preference) {
  .fridge.is-intro .scanline {
    animation: sweep 2s cubic-bezier(0.45, 0, 0.3, 1) 0.35s 1 both;
  }

  .fridge.is-intro .tag,
  .fridge.is-intro .recipe {
    animation: appear 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) var(--d, 0s) both;
  }

  /* Pendant l'analyse d'une vraie photo, la ligne tourne en boucle */
  .fridge.is-scanning .scanline {
    animation: sweep 1.6s cubic-bezier(0.45, 0, 0.3, 1) infinite both;
  }
}

@keyframes sweep {
  0%   { top: -5rem; opacity: 1; }
  92%  { opacity: 1; }
  100% { top: 100%; opacity: 0; }
}

@keyframes appear {
  from { opacity: 0; transform: translateY(6px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}

/* Relief et interactions ---------------------------------------------- */

/* Ombres au repos : teintées, jamais grises */
.btn-primary {
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.55) inset,
    0 12px 22px -14px rgba(160, 130, 0, 0.9);
}

.btn svg {
  transition: transform 220ms cubic-bezier(0.3, 1.5, 0.5, 1);
}

.card {
  box-shadow: 0 20px 40px -30px rgba(43, 26, 51, 0.35);
}

.food svg {
  filter: drop-shadow(0 3px 2px rgba(43, 26, 51, 0.14));
  transform-origin: 50% 100%;
  transition: transform 260ms cubic-bezier(0.3, 1.6, 0.5, 1), filter 260ms ease;
}

.tag {
  transition: background-color 160ms ease, color 160ms ease;
}

.recipe {
  box-shadow: 0 14px 24px -16px rgba(43, 26, 51, 0.7);
  transition: translate 200ms cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 200ms ease;
}

.recipe svg {
  transition: transform 300ms cubic-bezier(0.3, 1.6, 0.5, 1);
}

.step-num {
  transition: background-color 160ms ease, transform 220ms cubic-bezier(0.3, 1.6, 0.5, 1);
}

.price-row {
  transition: background-color 160ms ease;
}

.price-row dd {
  transition: translate 200ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.badge {
  transition: box-shadow 180ms ease, translate 180ms ease;
}

/* Pastille qui demande une action : elle se lit comme un bouton */
.badge[data-need="login"],
.badge[data-need="register"],
.badge[data-need="verify"] {
  background: #F5D93A;
  font-weight: 600;
}

.badge[data-need]:not([data-need=""])::after {
  content: "›";
  margin-left: 0.3rem;
  font-weight: 700;
}

/* Le frigo s'incline légèrement vers le pointeur (angles posés par app.js) */
.fridge {
  transform: perspective(60rem) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: transform 350ms cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 350ms ease;
}

/* Survol : uniquement là où il existe (souris, trackpad) */
@media (hover: hover) {
  .btn-primary:hover {
    background-color: #F8DF52;
    transform: translateY(-2px);
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.55) inset,
      0 20px 28px -16px rgba(160, 130, 0, 0.95);
  }

  .btn-primary:hover svg {
    transform: rotate(-8deg) scale(1.12);
  }

  .btn-ghost:hover {
    background-color: rgba(43, 26, 51, 0.06);
  }

  .brand:hover {
    opacity: 0.7;
  }

  .badge:hover {
    translate: 0 -1px;
    box-shadow: 0 8px 16px -10px rgba(43, 26, 51, 0.4);
  }

  .fridge:hover {
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.9) inset,
      0 34px 60px -30px rgba(43, 26, 51, 0.45);
  }

  /* Un aliment survolé se soulève et son étiquette s'allume */
  .food:hover svg {
    transform: translateY(-8%) rotate(-4deg) scale(1.1);
    filter: drop-shadow(0 8px 5px rgba(43, 26, 51, 0.18));
  }

  .food:hover .tag {
    background-color: #2B1A33;
    color: #FFFFFF;
  }

  .recipe:hover {
    translate: 0 -2px;
    box-shadow: 0 20px 28px -16px rgba(43, 26, 51, 0.8);
  }

  .recipe:hover svg {
    transform: rotate(-12deg) scale(1.1);
  }

  .step:hover .step-num {
    background-color: #F5D93A;
    transform: scale(1.12);
  }

  .price-row:hover {
    background-color: rgba(245, 217, 58, 0.16);
  }

  .price-row:hover dd {
    translate: -4px 0;
  }
}

/* L'appui l'emporte toujours sur le survol */
.btn:active {
  transform: scale(0.98);
}

/* Au survol du frigo, la ligne de scan repasse une fois */
@keyframes sweep-again {
  0%   { top: -5rem; opacity: 1; }
  92%  { opacity: 1; }
  100% { top: 100%; opacity: 0; }
}

@media (prefers-reduced-motion: no-preference) {
  .fridge.is-rescan .scanline {
    animation: sweep-again 1.3s cubic-bezier(0.45, 0, 0.3, 1) 1 both;
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn, .btn svg, .food svg, .recipe, .recipe svg, .step-num, .price-row dd, .badge, .fridge {
    transition: none;
  }

  .fridge {
    transform: none;
  }
}

/* Résultats ------------------------------------------------------------ */

.results {
  padding-bottom: calc(2rem + var(--safe-bottom));
}

.results-foot {
  padding-top: 2.5rem;
}

/* « Scanner un autre frigo » : dans la colonne de gauche dès la tablette, en bas sur téléphone */
.aside-new-scan {
  display: none;
}

@media (min-width: 768px) {
  .aside-new-scan {
    display: flex;
  }

  .results-foot {
    display: none;
  }
}

/* Lien dans une phrase : zone de toucher agrandie sans changer la mise en page */
.touch-link {
  display: inline-block;
  padding: 0.75rem 0.25rem;
  margin: -0.75rem -0.25rem;
}

/* Téléphones peu hauts : titre plus compact, la photo du frigo reste visible */
@media (max-width: 767px) and (max-height: 700px) {
  .hero h1 {
    font-size: 1.875rem;
  }

  .hero h1 + p {
    margin-top: 0.5rem;
    font-size: 1rem;
  }

  .fridge {
    margin-top: 1rem;
  }
}

@media (min-width: 768px) {
  .results {
    padding-bottom: 4rem;
  }

  /* La liste reste visible pendant qu'on parcourt les recettes */
  .results-aside {
    position: sticky;
    top: 1.5rem;
  }
}

/* Aliment repéré : pastille avec bouton pour le retirer */
.ing {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  min-height: 2.75rem;
  padding: 0 0.25rem 0 0.875rem;
  border-radius: 999px;
  background: #FFFFFF;
  box-shadow: 0 0 0 1px rgba(43, 26, 51, 0.1);
  font-size: 0.9375rem;
  font-weight: 500;
}

.ing-dot {
  width: 0.4375rem;
  height: 0.4375rem;
  border-radius: 999px;
  background: #1E7A4E;
}

.ing.is-urgent {
  box-shadow: 0 0 0 1.5px rgba(217, 58, 58, 0.45);
}

.ing.is-urgent .ing-dot {
  background: #D93A3A;
}

.ing-qty {
  color: rgba(43, 26, 51, 0.75);
  font-variant-numeric: tabular-nums;
}

.ing-soon {
  padding: 0.1875rem 0.4375rem;
  border-radius: 999px;
  background: #D93A3A;
  color: #FFFFFF;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
}

/* Conseils de prise de vue : avant la photo, puis après un scan difficile à lire */
.photo-tips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem 0.5rem;
  margin: 0 0 0.625rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: rgba(43, 26, 51, 0.8);
}

.photo-tips li {
  display: inline-flex;
  align-items: center;
  gap: 0.3125rem;
  white-space: nowrap;
}

.photo-tips li::before {
  content: "";
  width: 0.375rem;
  height: 0.375rem;
  border-radius: 999px;
  background: #1E7A4E;
}

.photo-check {
  margin: 0 0 0.625rem;
  text-align: center;
  font-size: 0.8125rem;
  font-weight: 500;
  color: rgba(43, 26, 51, 0.8);
}

@media (max-width: 767px) and (max-height: 700px) {
  .photo-tips,
  .photo-check {
    display: none;
  }
}

.photo-tip {
  margin-top: 1rem;
  padding: 0.875rem 1rem;
  border-radius: 1.125rem;
  background: #FFFBE0;
  box-shadow: 0 0 0 1px rgba(160, 130, 0, 0.3);
  font-size: 0.9375rem;
  line-height: 1.4;
}

.photo-tip[hidden] {
  display: none;
}

.photo-tip-title {
  margin-bottom: 0.25rem;
  font-weight: 600;
}

/* Aliment « à vérifier » : contour en pointillés, pastille citron à toucher pour confirmer */
.ing.is-check {
  box-shadow: none;
  outline: 1.5px dashed rgba(43, 26, 51, 0.4);
  outline-offset: -1.5px;
}

.ing.is-check .ing-dot {
  background: #F5D93A;
  box-shadow: 0 0 0 1px rgba(43, 26, 51, 0.35);
}

.ing-check {
  position: relative;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  background: #F5D93A;
  color: #2B1A33;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  flex: none;
  cursor: pointer;
}

.ing.is-check .ing-qty {
  white-space: nowrap;
}

.ing-check::before {
  content: "";
  position: absolute;
  inset: -0.75rem -0.25rem;
}

.ing-check[hidden] {
  display: none;
}

.ing-remove {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 999px;
  color: rgba(43, 26, 51, 0.55);
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease;
}

/* Zone de toucher de 44 px autour de la croix */
.ing-remove {
  position: relative;
}

.ing-remove::before {
  content: "";
  position: absolute;
  inset: -0.25rem;
}

/* Pastille de l'en-tête : 44 px de haut au doigt, dessin inchangé */
.badge {
  position: relative;
}

.badge::before {
  content: "";
  position: absolute;
  inset: -0.375rem 0;
}

/* « Mes recettes » : dans l'en-tête dès la tablette, sous le pouce sur téléphone */
.head-fav:not([hidden]) {
  display: none;
}

@media (min-width: 48rem) {
  .head-fav:not([hidden]) {
    display: flex;
  }
}

.dock-fav svg {
  color: #D93A3A;
}

.badge {
  white-space: nowrap;
}

/* Petits téléphones : logo un peu plus petit, libellés courts, tout sur une ligne */
@media (max-width: 23.5rem) {
  .brand img {
    height: 1.75rem;
  }

  .badge {
    padding-left: 0.625rem;
    padding-right: 0.625rem;
  }

  .dock-row:has(.dock-fav:not([hidden])) .import-more {
    display: none;
  }
}

/* Afficher le mot de passe */
.password-wrap {
  position: relative;
}

.password-toggle {
  position: absolute;
  top: 0.125rem;
  right: 0.125rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 999px;
  color: rgba(43, 26, 51, 0.7);
}

.password-toggle svg {
  width: 1.25rem;
  height: 1.25rem;
}

.password-toggle[aria-pressed="false"] .pw-hide,
.password-toggle[aria-pressed="true"] .pw-show {
  display: none;
}

/* Partager : bouton rond, icône seule */
.share-btn {
  flex: none;
  justify-content: center;
  width: 2.75rem;
  padding: 0;
}

.share-btn svg {
  flex: none;
  width: 1.125rem;
  height: 1.125rem;
}

.ing-remove svg {
  width: 1rem;
  height: 1rem;
}

.field {
  outline: none;
  transition: box-shadow 150ms ease;
}

.field::placeholder {
  color: rgba(43, 26, 51, 0.45);
}

.field:focus-visible {
  box-shadow: 0 0 0 2px #2B1A33;
}

/* Recettes */
.recipe-card {
  box-shadow: 0 20px 40px -32px rgba(43, 26, 51, 0.4);
}

.meta {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.3125rem 0.625rem;
  border-radius: 999px;
  background: #EDF3F4;
  font-size: 0.8125rem;
  font-weight: 500;
}

.meta svg {
  width: 0.875rem;
  height: 0.875rem;
}

.use {
  padding: 0.3125rem 0.625rem;
  border-radius: 999px;
  background: rgba(30, 122, 78, 0.1);
  color: #17603D;
  font-size: 0.8125rem;
  font-weight: 500;
}

.use.is-urgent {
  background: rgba(217, 58, 58, 0.1);
  color: #B42828;
}

.steps summary {
  list-style: none;
}

.steps summary::-webkit-details-marker {
  display: none;
}

.steps-chevron {
  transition: transform 200ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.steps[open] .steps-chevron {
  transform: rotate(90deg);
}

/* Étapes numérotées : c'est une vraie séquence */
.r-steps {
  counter-reset: step;
}

.r-steps li {
  position: relative;
  padding-left: 2.125rem;
  line-height: 1.5;
  counter-increment: step;
}

.r-steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0.0625rem;
  display: grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 999px;
  background: #F5D93A;
  font-size: 0.8125rem;
  font-weight: 600;
}

.recipe-list.is-loading {
  opacity: 0.45;
  pointer-events: none;
  transition: opacity 200ms ease;
}

@media (hover: hover) {
  .ing-remove:hover {
    background: rgba(217, 58, 58, 0.1);
    color: #B42828;
  }

  .steps summary:hover {
    opacity: 0.75;
  }
}

@media (prefers-reduced-motion: no-preference) {
  /* Les résultats arrivent en cascade */
  .results:not([hidden]) .recipe-card {
    animation: appear 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  }

  .results:not([hidden]) .recipe-card:nth-child(2) { animation-delay: 80ms; }
  .results:not([hidden]) .recipe-card:nth-child(3) { animation-delay: 160ms; }
}

/* Options avancées ----------------------------------------------------- */

/* Couverts toujours visibles, panneau des filtres derrière « Options » */
.opts-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.stepper {
  display: flex;
  align-items: center;
  height: 2.75rem;
  border-radius: 999px;
  background: #FFFFFF;
  box-shadow: 0 0 0 1px rgba(43, 26, 51, 0.1);
}

.stepper-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 999px;
  color: #2B1A33;
}

.stepper-btn svg {
  width: 1rem;
  height: 1rem;
}

.stepper-btn:active {
  background: rgba(43, 26, 51, 0.07);
}

.stepper-btn[disabled] {
  opacity: 0.3;
}

.stepper-value {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  min-width: 4.75rem;
  font-size: 0.9375rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.stepper-value svg {
  width: 0.9375rem;
  height: 0.9375rem;
  color: rgba(43, 26, 51, 0.5);
}

.opts-btn {
  display: flex;
  flex: 1 1 7rem;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  height: 2.75rem;
  padding: 0 0.75rem;
  white-space: nowrap;
  border-radius: 999px;
  background: #FFFFFF;
  box-shadow: 0 0 0 1px rgba(43, 26, 51, 0.1);
  font-size: 0.9375rem;
  font-weight: 600;
}

.opts-btn svg {
  width: 1rem;
  height: 1rem;
}

.opts-btn:active {
  background: #F5F9F9;
}

/* Un filtre tourne : le bouton le dit (pastille, nombre, contour) */
.opts-btn.is-active {
  box-shadow: 0 0 0 2px #2B1A33;
}

.opts-count {
  font-variant-numeric: tabular-nums;
}

.opts-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  background: #F5D93A;
  box-shadow: 0 0 0 1.5px #2B1A33;
}

/* Le panneau : feuille qui monte du bas sur mobile, fenêtre centrée dès la tablette */
dialog.sheet {
  width: 100%;
  max-width: 34rem;
  max-height: min(88dvh, 44rem);
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: 1.75rem 1.75rem 0 0;
  background: #FFFFFF;
  color: #2B1A33;
  overflow: hidden;
  box-shadow: 0 -20px 60px -20px rgba(43, 26, 51, 0.5);
}

dialog.sheet::backdrop {
  background: rgba(43, 26, 51, 0.5);
}

body:has(dialog.sheet[open]) {
  overflow: hidden;
}

.sheet-body {
  max-height: min(88dvh, 44rem);
  padding: 0 1.25rem;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sheet-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0 0.25rem;
  background: #FFFFFF;
}

.sheet-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  margin-right: -0.625rem;
  border-radius: 999px;
}

.sheet-close svg {
  width: 1.25rem;
  height: 1.25rem;
}

.sheet-note {
  font-size: 0.875rem;
  line-height: 1.4;
  color: rgba(43, 26, 51, 0.75);
}

.sheet-foot {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 0.5rem;
  margin-top: 1.25rem;
  padding: 0.75rem 0 calc(0.75rem + var(--safe-bottom));
  background: #FFFFFF;
  border-top: 1px solid rgba(43, 26, 51, 0.08);
}

.opt-group {
  min-width: 0;
  margin: 1.25rem 0 0;
  padding: 0;
  border: 0;
}

.opt-group legend {
  margin-bottom: 0.625rem;
  padding: 0;
  font-size: 0.9375rem;
  font-weight: 600;
}

.opt-sub {
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  color: rgba(43, 26, 51, 0.7);
}

.opt-help {
  margin-top: 0.625rem;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: rgba(43, 26, 51, 0.75);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip {
  position: relative;
  display: inline-flex;
}

/* La vraie case reste là (clavier, lecteurs d'écran), invisible sous la pastille */
.chip-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.chip-face {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0 1rem;
  border-radius: 999px;
  background: #EDF3F4;
  font-size: 0.9375rem;
  font-weight: 500;
  transition: background-color 140ms ease, color 140ms ease;
}

.chip-input:checked + .chip-face {
  background: #2B1A33;
  color: #FFFFFF;
}

/* Les cases à cocher montrent aussi un coche : pas la couleur seule */
.chip-input[type="checkbox"]:checked + .chip-face::before {
  content: "";
  width: 0.5rem;
  height: 0.3125rem;
  margin: -0.125rem 0.5rem 0 0;
  border-bottom: 2px solid currentColor;
  border-left: 2px solid currentColor;
  transform: rotate(-45deg);
}

.chip-input:focus-visible + .chip-face {
  outline: 3px solid #2B1A33;
  outline-offset: 2px;
}

@media (hover: hover) {
  .chip-input:not(:checked) + .chip-face:hover {
    background: #DDE8EA;
  }

  .opts-btn:hover {
    background: #F5F9F9;
  }

  .stepper-btn:hover {
    background: rgba(43, 26, 51, 0.06);
  }
}

@media (min-width: 768px) {
  dialog.sheet {
    margin: auto;
    border-radius: 1.75rem;
    box-shadow: 0 30px 80px -30px rgba(43, 26, 51, 0.6);
  }

  .sheet-body {
    padding: 0 1.75rem;
  }
}

@media (prefers-reduced-motion: no-preference) {
  dialog.sheet[open] {
    animation: sheet-in 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  }

  dialog.sheet[open]::backdrop {
    animation: fade-in 0.25s ease;
  }
}

@keyframes sheet-in {
  from {
    opacity: 0;
    transform: translateY(1.5rem);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

/* Rappel, au-dessus des recettes, de ce qui a servi à les écrire */
.recap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.875rem;
  color: rgba(43, 26, 51, 0.75);
}

.recap-chip {
  padding: 0.25rem 0.625rem;
  border-radius: 999px;
  background: rgba(245, 217, 58, 0.4);
  color: #2B1A33;
  font-size: 0.8125rem;
  font-weight: 500;
}

/* Aliment écarté par une option */
.ing-skip {
  padding: 0.125rem 0.4375rem;
  border-radius: 999px;
  background: rgba(43, 26, 51, 0.08);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.3;
}

.ing.is-excluded .ing-name {
  text-decoration: line-through;
  text-decoration-color: rgba(43, 26, 51, 0.45);
}

.ing.is-excluded {
  opacity: 0.8;
}

/* Compte ------------------------------------------------------------- */

.account-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 999px;
  background: #FFFFFF;
  box-shadow: 0 0 0 1px rgba(43, 26, 51, 0.1);
}

.account-btn svg {
  width: 1.125rem;
  height: 1.125rem;
}

/* Connecté : une pastille verte sur l'icône */
.account-dot {
  position: absolute;
  right: 0.375rem;
  top: 0.375rem;
  width: 0.5625rem;
  height: 0.5625rem;
  border-radius: 999px;
  background: #1E7A4E;
  box-shadow: 0 0 0 2px #FFFFFF;
}

.form-error {
  padding: 0.625rem 0.875rem;
  border-radius: 1rem;
  background: rgba(217, 58, 58, 0.1);
  color: #9E2222;
  font-size: 0.9375rem;
  line-height: 1.35;
}

#account-dialog .sheet-body {
  padding-bottom: var(--safe-bottom);
}

@media (hover: hover) {
  .account-btn:hover {
    background: #F5F9F9;
  }
}

/* Adresse à confirmer */
.verify-box {
  display: flex;
  gap: 0.875rem;
  padding: 1rem 1rem 0.5rem;
  border-radius: 1.25rem;
  background: rgba(245, 217, 58, 0.28);
}

.verify-icon {
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  margin-top: 0.125rem;
}

.link-btn {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.form-note {
  padding: 0.625rem 0.875rem;
  border-radius: 1rem;
  background: rgba(30, 122, 78, 0.1);
  color: #17603D;
  font-size: 0.9375rem;
  line-height: 1.35;
}

/* Offres : l'annuel en avant, le Pass en retrait */
.offer {
  position: relative;
  border-radius: 1.5rem;
  padding: 1.25rem;
}

.offer-main {
  background: #FFFFFF;
  box-shadow: 0 0 0 2px #2B1A33, 0 20px 40px -30px rgba(43, 26, 51, 0.45);
}

.offer-flag {
  position: absolute;
  top: -0.75rem;
  right: 1rem;
  padding: 0.25rem 0.625rem;
  border-radius: 999px;
  background: #2B1A33;
  color: #FFFFFF;
  font-size: 0.75rem;
  font-weight: 600;
}

.offer-points li {
  position: relative;
  padding-left: 1.375rem;
  font-size: 0.9375rem;
  line-height: 1.6;
}

.offer-points li::before {
  content: "";
  position: absolute;
  left: 0.125rem;
  top: 0.5em;
  width: 0.625rem;
  height: 0.375rem;
  border-bottom: 2px solid #1E7A4E;
  border-left: 2px solid #1E7A4E;
  transform: rotate(-45deg);
}

.offer-alt {
  background: #EDF3F4;
  color: rgba(43, 26, 51, 0.72);
}

/* Bouton du Pass : fond blanc, texte et contour aubergine, nettement cliquable */
.offer-alt .btn {
  background: #FFFFFF;
  color: #2B1A33;
  font-weight: 600;
  box-shadow:
    0 0 0 2px #2B1A33,
    0 10px 18px -14px rgba(43, 26, 51, 0.7);
}

@media (hover: hover) {
  .offer-alt .btn:hover {
    background: #FBF7DD;
  }
}

/* Installer l'application ------------------------------------------------ */
.install {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-bottom: 0.5rem;
}

.install[hidden] {
  display: none;
}

@media (min-width: 768px) {
  .install {
    grid-column: span 2;
    max-width: 30rem;
  }
}

.install-main {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  min-height: 3.5rem;
  padding: 0.5rem 0.625rem 0.5rem 0.5rem;
  border-radius: 1.125rem;
  background: #FFFFFF;
  color: #2B1A33;
  text-align: left;
  box-shadow:
    0 0 0 1px rgba(43, 26, 51, 0.1),
    0 12px 24px -18px rgba(43, 26, 51, 0.6);
}

.install-ico {
  flex: none;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.75rem;
}

.install-text {
  flex: 1;
  min-width: 0;
}

.install-text strong {
  display: block;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.2;
}

.install-text small {
  display: block;
  margin-top: 0.125rem;
  font-size: 0.75rem;
  line-height: 1.25;
  color: rgba(43, 26, 51, 0.75);
}

.install-cta {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 0.375rem;
  padding: 0.4375rem 0.75rem;
  border-radius: 999px;
  background: #F5D93A;
  font-size: 0.8125rem;
  font-weight: 700;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.55) inset;
}

.install-cta svg {
  width: 0.9375rem;
  height: 0.9375rem;
}

/* Petits écrans : le mot suffit, on garde la place pour le titre */
@media (max-width: 25rem) {
  .install-cta svg {
    display: none;
  }
}

/* Très petits écrans : une seule ligne, le frigo reste visible */
@media (max-width: 23.5rem) {
  .install-main {
    min-height: 3rem;
    gap: 0.625rem;
  }

  .install-ico {
    width: 2rem;
    height: 2rem;
    border-radius: 0.625rem;
  }

  .install-text strong {
    white-space: nowrap;
  }

  .install-text small {
    display: none;
  }
}

.install-hide {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 999px;
  color: rgba(43, 26, 51, 0.55);
}

.install-hide svg {
  width: 1.125rem;
  height: 1.125rem;
}

@media (hover: hover) {
  .install-main:hover {
    background: #FBFDFD;
    transform: translateY(-1px);
  }

  .install-hide:hover {
    color: #2B1A33;
  }
}

/* Fenêtre d'explication iPhone */
.install-steps {
  display: grid;
  gap: 0.875rem;
  margin: 1.25rem 0 0;
  padding: 0;
  list-style: none;
}

.install-steps li {
  display: flex;
  align-items: flex-start;
  gap: 0.875rem;
}

.install-steps p {
  margin: 0;
  padding-top: 0.25rem;
  line-height: 1.45;
}

.install-steps p svg {
  display: inline-block;
  width: 1.125rem;
  height: 1.125rem;
  margin: 0 0.125rem;
  vertical-align: -0.2rem;
}

.install-num {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  background: #F5D93A;
  font-weight: 700;
}

/* Pied de page : liens légaux */
.site-foot {
  padding-top: 2.5rem;
  color: rgba(43, 26, 51, 0.65);
  font-size: 0.875rem;
}

.site-foot nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.25rem;
}

.site-foot a {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Sur mobile, la barre d'action fixe ne doit pas cacher le pied */
.after-hero-foot {
  padding-bottom: calc(var(--dock-height) + var(--safe-bottom) + 1rem);
}

@media (min-width: 768px) {
  .after-hero-foot {
    padding-bottom: 3rem;
  }
}

/* Interrupteur (rappel du lundi) */
.switch {
  position: relative;
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 3rem;
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.switch-text {
  flex: 1;
}

.switch-track {
  position: relative;
  flex-shrink: 0;
  width: 3rem;
  height: 1.75rem;
  border-radius: 999px;
  background: rgba(43, 26, 51, 0.2);
  transition: background-color 160ms ease;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 0.1875rem;
  left: 0.1875rem;
  width: 1.375rem;
  height: 1.375rem;
  border-radius: 999px;
  background: #FFFFFF;
  box-shadow: 0 1px 3px rgba(43, 26, 51, 0.3);
  transition: transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.switch input:checked ~ .switch-track {
  background: #1E7A4E;
}

.switch input:checked ~ .switch-track::after {
  transform: translateX(1.25rem);
}

.switch input:focus-visible ~ .switch-track {
  outline: 3px solid #2B1A33;
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .switch-track,
  .switch-track::after {
    transition: none;
  }
}

/* Cœur : vide = pas gardée, plein = gardée */
.fav-btn {
  position: absolute;
  top: 0.625rem;
  right: 0.625rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 999px;
  color: #2B1A33;
}

.fav-btn svg {
  width: 1.375rem;
  height: 1.375rem;
  fill: transparent;
  transition: fill 160ms ease, color 160ms ease, transform 220ms cubic-bezier(0.3, 1.6, 0.5, 1);
}

.fav-btn[aria-pressed="true"] {
  color: #D93A3A;
}

.fav-btn[aria-pressed="true"] svg {
  fill: currentColor;
}

.fav-btn:active svg {
  transform: scale(0.85);
}

@media (prefers-reduced-motion: no-preference) {
  .fav-btn.is-popping svg {
    animation: heart-pop 0.35s cubic-bezier(0.3, 1.6, 0.5, 1);
  }
}

@keyframes heart-pop {
  50% {
    transform: scale(1.3);
  }
}

@media (hover: hover) {
  .fav-btn:hover {
    background: rgba(217, 58, 58, 0.08);
  }
}

/* Recette retirée de « Mes recettes », le temps de pouvoir annuler */
.recipe-card.is-leaving {
  opacity: 0.45;
}

/* Message bref en bas de l'écran */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(1rem + var(--safe-bottom));
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: max-content;
  max-width: calc(100vw - 2rem);
  min-height: 3rem;
  padding: 0.375rem 0.375rem 0.375rem 1.125rem;
  border-radius: 1rem;
  background: #2B1A33;
  color: #FFFFFF;
  font-size: 0.9375rem;
  transform: translateX(-50%);
  box-shadow: 0 16px 40px -16px rgba(43, 26, 51, 0.6);
}

.toast-action {
  min-height: 2.5rem;
  padding: 0 0.875rem;
  border-radius: 0.75rem;
  color: #F5D93A;
  font-weight: 600;
}

.toast-action:active {
  background: rgba(255, 255, 255, 0.1);
}

@media (prefers-reduced-motion: no-preference) {
  .toast:not([hidden]) {
    animation: toast-in 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 0.75rem);
  }
}

/* Sur mobile, le message passe au-dessus de la barre d'action de l'accueil */
@media (max-width: 767px) {
  body:has(.hero:not([hidden])) .toast {
    bottom: calc(var(--dock-height) + var(--safe-bottom) - 2rem);
  }
}

/* Avis sur une recette */
.rate {
  padding-top: 1rem;
  border-top: 1px solid rgba(43, 26, 51, 0.08);
}

.rate-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4375rem;
  min-height: 2.75rem;
  padding: 0 1rem;
  border-radius: 999px;
  background: #EDF3F4;
  font-size: 0.9375rem;
  font-weight: 500;
}

.rate-btn svg {
  width: 1.0625rem;
  height: 1.0625rem;
}

.rate-btn[data-vote="1"][aria-pressed="true"] {
  background: #1E7A4E;
  color: #FFFFFF;
}

.rate-btn[data-vote="-1"][aria-pressed="true"] {
  background: #2B1A33;
  color: #FFFFFF;
}

.reason-btn {
  min-height: 2.75rem;
  padding: 0 0.875rem;
  border-radius: 999px;
  background: #FFFFFF;
  box-shadow: 0 0 0 1px rgba(43, 26, 51, 0.15);
  font-size: 0.875rem;
}

.reason-btn[aria-pressed="true"] {
  background: #2B1A33;
  color: #FFFFFF;
  box-shadow: none;
}

@media (hover: hover) {
  .rate-btn[aria-pressed="false"]:hover {
    background: #DDE8EA;
  }

  .reason-btn[aria-pressed="false"]:hover {
    background: #F5F9F9;
  }
}

/* Plusieurs photos : miniatures et ajout, en bas de l'aperçu */
.photo-strip {
  position: absolute;
  inset: auto 0.75rem 0.75rem;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  border-radius: 1.25rem;
  background: rgba(43, 26, 51, 0.72);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.thumb {
  position: relative;
}

.thumb-view {
  display: block;
  width: 3.25rem;
  height: 3.25rem;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0.75rem;
  background: #FFFFFF;
  box-shadow: 0 0 0 2px transparent;
}

.thumb-view[aria-current="true"] {
  box-shadow: 0 0 0 2px #F5D93A;
}

.thumb-view img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb-remove {
  position: absolute;
  top: -0.5rem;
  right: -0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 999px;
  background: #FFFFFF;
  color: #2B1A33;
  box-shadow: 0 1px 4px rgba(43, 26, 51, 0.35);
}

/* Zone de toucher de 44 px autour de la petite croix */
.thumb-remove::before {
  content: "";
  position: absolute;
  inset: -0.5rem;
}

.thumb-remove svg {
  width: 0.875rem;
  height: 0.875rem;
}

.add-photo {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 0.5rem;
  min-height: 3.25rem;
  padding: 0 0.75rem;
  border-radius: 0.75rem;
  border: 1.5px dashed rgba(255, 255, 255, 0.55);
  color: #FFFFFF;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.15;
  text-align: left;
}

.add-photo small {
  display: block;
  font-size: 0.75rem;
  font-weight: 400;
  opacity: 0.75;
}

.add-photo svg {
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
}

.fridge.is-scanning .photo-strip {
  opacity: 0.6;
  pointer-events: none;
}

/* Aliment trouvé dans le placard */
.ing-place {
  padding: 0.125rem 0.4375rem;
  border-radius: 999px;
  background: rgba(245, 217, 58, 0.45);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.3;
}

/* Compteur anti-gaspi */
.impact {
  padding: 0.875rem 1rem;
  border-radius: 1rem;
  background: #E3F1E9;
  color: #165C3B;
}

.impact-num {
  font-weight: 700;
}

.cook-btn[aria-pressed="true"] {
  background: #1E7A4E;
  color: #FFFFFF;
}

/* Cadenas d'accès à l'administration : volontairement presque invisible */
.foot-lock {
  display: inline-flex;
  align-items: center;
  margin-left: 0.35rem;
  padding: 0.5rem;
  vertical-align: middle;
  opacity: 0.18;
  text-decoration: none;
}
.foot-lock:hover,
.foot-lock:focus-visible {
  opacity: 0.7;
}

/* Accueil : bloc « Recettes anti-gaspi » (liens vers le blog /recettes/) */
.home-blog-intro {
  margin-top: 0.5rem;
  line-height: 1.375;
  color: rgba(43, 26, 51, 0.7);
}
.home-blog-list {
  display: grid;
  gap: 0.75rem;
  margin: 1.25rem 0 0;
  padding: 0;
  list-style: none;
}
.home-blog-card {
  position: relative;
  padding: 1rem 1.125rem;
  border-radius: 1.5rem;
  background: #FFFFFF;
  box-shadow: 0 0 0 1px rgba(43, 26, 51, 0.1);
}
.home-blog-card a {
  font-weight: 600;
  line-height: 1.3;
  text-decoration: none;
  color: inherit;
}
.home-blog-card a::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 1.5rem;
}
.home-blog-card:focus-within {
  outline: 3px solid #2B1A33;
  outline-offset: 3px;
}
.home-blog-card a:focus-visible {
  outline: none;
}
.home-blog-card p {
  margin: 0.375rem 0 0;
  font-size: 0.9375rem;
  line-height: 1.45;
  color: rgba(43, 26, 51, 0.7);
}
.home-blog-all {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  min-height: 2.75rem;
  margin-top: 0.75rem;
  font-weight: 600;
  color: inherit;
  text-underline-offset: 3px;
}
@media (hover: hover) {
  .home-blog-card:hover {
    box-shadow: 0 0 0 2px #2B1A33;
  }
}
@media (min-width: 768px) {
  .home-blog-list {
    grid-template-columns: repeat(3, 1fr);
  }
}
