/* ============================================================
   Recettes — Design system premium+++
   Palette : crème chaude · safran · sauge · charbon doux
   Typo    : Fraunces (display) + Inter (texte)
   Esprit  : papier mat, ombres douces, micro-anims spring
   ============================================================ */

:root {
  /* Couleurs */
  --bg: #fbf7f2;
  --bg-card: #ffffff;
  --bg-elev: #fffdf9;
  --ink: #1f1a14;
  --ink-soft: #514a3f;
  --ink-mute: #8a8275;
  --line: #ece4d7;
  --line-soft: #f4ede1;

  --saffron: #c87b2a;
  --saffron-deep: #a86018;
  --saffron-soft: #fdeacd;

  --sage: #6f8b66;
  --sage-deep: #4f6a49;
  --sage-soft: #e5ecdc;

  --tomato: #c2452b;
  --tomato-soft: #fbe1d8;

  --gold: #b9892a;
  --plum: #6e3b5c;

  /* Ombres (multi-couche) */
  --shadow-xs: 0 1px 2px rgba(46, 32, 14, 0.04);
  --shadow-sm: 0 2px 8px rgba(46, 32, 14, 0.06), 0 1px 2px rgba(46, 32, 14, 0.04);
  --shadow-md: 0 6px 24px rgba(46, 32, 14, 0.08), 0 2px 6px rgba(46, 32, 14, 0.05);
  --shadow-lg: 0 18px 60px rgba(46, 32, 14, 0.14), 0 6px 18px rgba(46, 32, 14, 0.06);
  --shadow-inset: inset 0 0 0 1px rgba(46, 32, 14, 0.04);

  /* Rayons */
  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 22px;
  --r-pill: 999px;

  /* Easing premium (Material expressive / iOS spring) */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-soft: cubic-bezier(0.4, 0, 0.2, 1);
  --t-fast: 140ms;
  --t-med: 240ms;
  --t-slow: 420ms;

  /* Layout */
  --maxw: 880px;
  --pad: clamp(16px, 4vw, 28px);

  /* Typo */
  --font-display: 'Fraunces', 'Cormorant Garamond', Georgia, serif;
  --font-text: 'Inter', 'SF Pro Text', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14110d;
    --bg-card: #1d1914;
    --bg-elev: #221d17;
    --ink: #f4eee2;
    --ink-soft: #c8bfae;
    --ink-mute: #8f8674;
    --line: #2a241c;
    --line-soft: #221d17;
    --saffron-soft: #3a2a14;
    --sage-soft: #1e2918;
    --tomato-soft: #341a13;
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 6px 24px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 18px 60px rgba(0, 0, 0, 0.55), 0 6px 18px rgba(0, 0, 0, 0.35);
  }
}

/* ===== Reset léger ===== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-text);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 80% -10%, var(--saffron-soft) 0%, transparent 55%),
    radial-gradient(900px 500px at -10% 110%, var(--sage-soft) 0%, transparent 50%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: contain;
}
img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; }
input, textarea, select { font: inherit; color: inherit; }

/* ===== Typography ===== */
h1, h2, h3, .display {
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0;
  line-height: 1.15;
}
h1 { font-size: clamp(2.1rem, 4.6vw, 3rem); font-variation-settings: 'opsz' 144, 'SOFT' 50; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.1rem; }
.subtitle { color: var(--ink-mute); font-size: 0.95rem; }

/* ===== Layout ===== */
.app {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: var(--pad) var(--pad) 120px;
}

/* ===== Header sticky ===== */
.header {
  position: sticky;
  top: 0;
  z-index: 30;
  margin: calc(-1 * var(--pad)) calc(-1 * var(--pad)) 24px;
  padding: 18px var(--pad) 14px;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  display: flex;
  align-items: center;
  gap: 12px;
}
.header .brand {
  display: flex; align-items: baseline; gap: 8px;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: -0.015em;
}
.header .brand .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--saffron);
  box-shadow: 0 0 0 4px var(--saffron-soft);
  display: inline-block;
  transform: translateY(-2px);
}
.header .spacer { flex: 1; }

/* ===== Search ===== */
.search {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-card);
  padding: 10px 14px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--t-med) var(--ease-out), border-color var(--t-fast);
  width: 100%; max-width: 360px;
}
.search:focus-within {
  box-shadow: var(--shadow-md), 0 0 0 3px var(--saffron-soft);
  border-color: var(--saffron);
}
.search input { border: 0; outline: 0; background: transparent; flex: 1; min-width: 0; }
.search svg { width: 18px; height: 18px; color: var(--ink-mute); flex: none; }

/* ===== Boutons ===== */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 18px;
  border: 1px solid var(--line);
  background: var(--bg-card);
  border-radius: var(--r-pill);
  cursor: pointer;
  font-weight: 500;
  font-size: 0.94rem;
  transition: transform var(--t-fast) var(--ease-spring),
              box-shadow var(--t-med) var(--ease-out),
              background var(--t-fast),
              border-color var(--t-fast);
  box-shadow: var(--shadow-xs);
  user-select: none;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0) scale(0.98); }
.btn.primary {
  background: linear-gradient(180deg, var(--saffron) 0%, var(--saffron-deep) 100%);
  color: #fff;
  border-color: transparent;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,0.18);
}
.btn.primary:hover {
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255,255,255,0.22);
}
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; padding: 9px 14px; }
.btn.ghost:hover { background: var(--line-soft); }
.btn.icon { padding: 10px; aspect-ratio: 1; border-radius: 50%; }
.btn svg { width: 16px; height: 16px; }

/* ===== Tabs filtre catégorie ===== */
.tabs {
  display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 12px;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 8px 14px;
  border-radius: var(--r-pill);
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink-soft);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.tab:hover { background: var(--line-soft); }
.tab.active {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

/* ===== Grille recettes ===== */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}

/* Carte recette */
.card {
  background: var(--bg-card);
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  padding: 18px;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: transform var(--t-med) var(--ease-spring),
              box-shadow var(--t-med) var(--ease-out),
              border-color var(--t-fast);
  position: relative;
  overflow: hidden;
  display: flex; flex-direction: column; gap: 10px;
  min-height: 168px;
}
.card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--saffron), var(--gold));
  opacity: 0;
  transition: opacity var(--t-med);
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: color-mix(in srgb, var(--saffron) 30%, var(--line));
}
.card:hover::before { opacity: 1; }
.card[data-cat="dessert"]::before { background: linear-gradient(90deg, var(--plum), var(--tomato)); }
.card[data-cat="entree"]::before  { background: linear-gradient(90deg, var(--sage), var(--sage-deep)); }
.card[data-cat="plat"]::before    { background: linear-gradient(90deg, var(--saffron), var(--tomato)); }

.card .cat {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--saffron-deep);
}
.card[data-cat="dessert"] .cat { color: var(--plum); }
.card[data-cat="entree"] .cat  { color: var(--sage-deep); }
.card[data-cat="boisson"] .cat { color: var(--gold); }
.card[data-cat="sauce"] .cat   { color: var(--tomato); }

.card .titre {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.18;
}
.card .meta {
  margin-top: auto;
  display: flex; gap: 12px; align-items: center;
  color: var(--ink-mute);
  font-size: 0.84rem;
}
.card .meta span { display: inline-flex; align-items: center; gap: 4px; }
.card .meta svg { width: 13px; height: 13px; }

.card .tags { display: flex; gap: 6px; flex-wrap: wrap; }

/* Card avec image (board) */
.card.with-image {
  padding: 0;
  overflow: hidden;
}
.card.with-image::before { display: none; }
.card.with-image .card-img {
  position: relative;
  height: 144px;
  background: linear-gradient(135deg, var(--saffron-soft), var(--sage-soft));
  overflow: hidden;
}
.card.with-image .card-img img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform 520ms var(--ease-out);
}
.card.with-image:hover .card-img img { transform: scale(1.06); }
.card.with-image .card-img .cat {
  position: absolute; top: 10px; left: 10px;
  background: rgba(20, 14, 8, 0.62);
  color: #fff;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  font-size: 0.68rem;
}
.card.with-image .card-body {
  padding: 14px 16px 16px;
  display: flex; flex-direction: column; gap: 8px;
  flex: 1;
}
.tag {
  display: inline-block;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  background: var(--line-soft);
  color: var(--ink-soft);
  font-size: 0.75rem;
  font-weight: 500;
}

/* Empty state */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--ink-mute);
}
.empty .display { font-size: 1.6rem; margin-bottom: 8px; }
.empty p { max-width: 360px; margin: 0 auto 18px; }

/* ===== FAB Add ===== */
.fab {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0) + 22px);
  right: 22px;
  z-index: 40;
  width: 60px; height: 60px;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--saffron), var(--saffron-deep));
  color: #fff;
  border: 0;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  display: grid; place-items: center;
  font-size: 28px;
  transition: transform var(--t-med) var(--ease-spring), box-shadow var(--t-med);
}
.fab:hover { transform: scale(1.05); }
.fab:active { transform: scale(0.95); }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: color-mix(in srgb, var(--ink) 50%, transparent);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 100;
  display: grid; place-items: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-med) var(--ease-out);
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--bg-card);
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 540px;
  max-height: 88vh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--line);
  transform: translateY(20px) scale(0.96);
  transition: transform var(--t-slow) var(--ease-spring);
  overflow: hidden;
}
.modal-overlay.open .modal { transform: translateY(0) scale(1); }
.modal-head {
  padding: 18px 22px 14px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--line-soft);
}
.modal-head .title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 500;
  flex: 1;
}
.modal-body { padding: 18px 22px; overflow-y: auto; }
.modal-foot {
  padding: 14px 22px;
  border-top: 1px solid var(--line-soft);
  display: flex; gap: 8px; justify-content: flex-end;
  background: var(--bg-elev);
}

.modal.large { max-width: 760px; }

/* ===== Form fields ===== */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-mute);
}
.field input, .field textarea, .field select {
  padding: 11px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--bg-elev);
  outline: 0;
  transition: border-color var(--t-fast), box-shadow var(--t-med);
}
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--saffron);
  box-shadow: 0 0 0 3px var(--saffron-soft);
}
.field textarea { min-height: 150px; resize: vertical; font-family: var(--font-text); line-height: 1.5; }
.row { display: grid; gap: 12px; }
.row.cols-2 { grid-template-columns: 1fr 1fr; }
.row.cols-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 520px) {
  .row.cols-3 { grid-template-columns: 1fr 1fr; }
}

.seg {
  display: flex;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--bg-elev);
  padding: 4px;
  gap: 2px;
}
.seg button {
  flex: 1;
  padding: 8px 12px;
  border: 0;
  background: transparent;
  cursor: pointer;
  border-radius: var(--r-pill);
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--ink-soft);
  transition: background var(--t-fast), color var(--t-fast);
}
.seg button.on {
  background: var(--ink);
  color: var(--bg);
}

/* ===== Vue détail recette ===== */
.detail {
  background: var(--bg-card);
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  padding: 28px;
  box-shadow: var(--shadow-md);
  margin-top: 8px;
}
.detail-top { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 18px; }
.detail-top .titres { flex: 1; min-width: 200px; }
.detail-top h1 { font-size: clamp(1.8rem, 4.4vw, 2.6rem); }
.detail-top .desc { color: var(--ink-soft); margin-top: 8px; max-width: 56ch; }

/* Hero (image gauche + titre droite) */
.detail-top .hero-row {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  flex: 1;
  min-width: 0;
}
.detail-top .hero-row .titres { flex: 1; min-width: 0; }
.detail-top .hero-img {
  width: 180px; height: 180px;
  flex: none;
  border-radius: var(--r-md);
  object-fit: cover;
  box-shadow: var(--shadow-md);
  cursor: zoom-in;
  background: var(--line-soft);
  transition: transform var(--t-med) var(--ease-out);
}
.detail-top .hero-img:hover { transform: scale(1.02); }

@media (max-width: 640px) {
  .detail-top .hero-row { gap: 12px; }
  .detail-top .hero-img { width: 108px; height: 108px; border-radius: 14px; }
}
.detail-meta {
  display: flex; gap: 16px; flex-wrap: wrap;
  color: var(--ink-mute);
  font-size: 0.9rem;
  padding: 14px 0;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 22px;
}
.detail-meta span { display: inline-flex; gap: 6px; align-items: center; }
.detail-meta svg { width: 15px; height: 15px; }

/* Portion control — la star du show */
.portion-control {
  background: linear-gradient(180deg, var(--saffron-soft), color-mix(in srgb, var(--saffron-soft) 60%, var(--bg-elev)));
  border-radius: var(--r-lg);
  padding: 18px 20px;
  margin-bottom: 24px;
  display: flex; flex-direction: column; gap: 14px;
  border: 1px solid color-mix(in srgb, var(--saffron) 18%, transparent);
}
.portion-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.portion-row .label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--saffron-deep);
}
.portion-stepper {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--bg-card);
  padding: 4px;
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-xs);
}
.portion-stepper button {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 0;
  background: var(--bg-elev);
  cursor: pointer;
  font-size: 18px;
  display: grid; place-items: center;
  transition: background var(--t-fast), transform var(--t-fast) var(--ease-spring);
  color: var(--saffron-deep);
}
.portion-stepper button:hover { background: var(--saffron-soft); }
.portion-stepper button:active { transform: scale(0.9); }
.portion-stepper .value {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 500;
  min-width: 44px;
  text-align: center;
  color: var(--saffron-deep);
  font-variant-numeric: tabular-nums;
}
.portion-unit {
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.portion-aside {
  font-size: 0.82rem; color: var(--ink-soft);
}
.portion-aside .reset {
  background: transparent; border: 0; color: var(--saffron-deep);
  cursor: pointer; padding: 4px 8px; border-radius: var(--r-sm);
  font-weight: 600;
}
.portion-aside .reset:hover { background: var(--bg-card); }

.scale-by {
  display: flex; align-items: center; gap: 10px;
  font-size: 0.88rem; color: var(--ink-soft);
}
.scale-by select, .scale-by input {
  background: var(--bg-card);
  border: 1px solid color-mix(in srgb, var(--saffron) 18%, var(--line));
  padding: 7px 10px;
  border-radius: var(--r-sm);
  font: inherit; color: inherit; outline: 0;
}
.scale-by input { width: 80px; text-align: right; font-variant-numeric: tabular-nums; }
.scale-by .target-suffix { color: var(--ink-mute); }

/* Liste ingrédients */
.section-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 500;
  margin-bottom: 12px;
  display: flex; align-items: center; gap: 10px;
}
.section-title::before {
  content: ''; width: 28px; height: 2px;
  background: var(--saffron);
  border-radius: 2px;
}
.ingredients { list-style: none; padding: 0; margin: 0 0 28px; }
.ingredients .grp-title {
  font-family: var(--font-display);
  font-size: 1.02rem;
  color: var(--saffron-deep);
  margin: 14px 0 6px;
  font-weight: 500;
}
.ingredient {
  display: flex; align-items: baseline; gap: 12px;
  padding: 10px 4px;
  border-bottom: 1px dashed var(--line-soft);
  transition: background var(--t-fast);
}
.ingredient:hover { background: var(--line-soft); border-radius: var(--r-sm); border-bottom-color: transparent; padding-left: 8px; }
.ingredient.checked {
  opacity: 0.45;
  text-decoration: line-through;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--ink-mute);
}
.ingredient .qty {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.06rem;
  color: var(--saffron-deep);
  font-variant-numeric: tabular-nums;
  min-width: 80px;
  text-align: right;
}
.ingredient .nom { flex: 1; }
.ingredient .nom .note { color: var(--ink-mute); font-size: 0.85rem; margin-left: 4px; }

/* Étapes */
.etapes { list-style: none; counter-reset: step; padding: 0; margin: 0; }
.etape {
  counter-increment: step;
  display: flex; gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line-soft);
  position: relative;
}
.etape:last-child { border-bottom: 0; }
.etape::before {
  content: counter(step);
  flex: none;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--bg);
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.05rem;
}
.etape.done { opacity: 0.55; }
.etape.done::before { background: var(--sage); }
.etape .txt { padding-top: 6px; line-height: 1.55; flex: 1; cursor: pointer; }

/* Back link */
.back {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--ink-soft);
  font-weight: 500;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: var(--r-pill);
  background: transparent;
  border: 0;
  margin-bottom: 8px;
  transition: background var(--t-fast);
}
.back:hover { background: var(--line-soft); }
.back svg { width: 14px; height: 14px; }

/* Détail actions header */
.detail-actions { display: flex; gap: 6px; }

/* ===== Toast ===== */
.toast-zone {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--ink);
  color: var(--bg);
  padding: 11px 18px;
  border-radius: var(--r-pill);
  font-size: 0.9rem;
  box-shadow: var(--shadow-lg);
  animation: toast-in 320ms var(--ease-spring), toast-out 280ms var(--ease-out) 2.4s forwards;
  max-width: 86vw;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(10px) scale(0.96); }
}

/* ===== Loader spinner premium ===== */
.spin {
  width: 22px; height: 22px;
  border: 2.5px solid var(--saffron-soft);
  border-top-color: var(--saffron);
  border-radius: 50%;
  animation: spin 720ms linear infinite;
  display: inline-block;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Skeleton */
.skel {
  background: linear-gradient(
    90deg,
    var(--line-soft) 0%,
    color-mix(in srgb, var(--line-soft) 50%, var(--bg-card)) 50%,
    var(--line-soft) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer { to { background-position: -200% 0; } }
.skel-card { height: 168px; border-radius: var(--r-lg); }

/* ===== Anims d'apparition ===== */
.fade-in { animation: fade-in 380ms var(--ease-out) both; }
@keyframes fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.stagger > * { animation: fade-in 380ms var(--ease-out) both; }
.stagger > *:nth-child(1) { animation-delay: 0ms; }
.stagger > *:nth-child(2) { animation-delay: 40ms; }
.stagger > *:nth-child(3) { animation-delay: 80ms; }
.stagger > *:nth-child(4) { animation-delay: 120ms; }
.stagger > *:nth-child(5) { animation-delay: 160ms; }
.stagger > *:nth-child(6) { animation-delay: 200ms; }
.stagger > *:nth-child(7) { animation-delay: 240ms; }
.stagger > *:nth-child(8) { animation-delay: 280ms; }
.stagger > *:nth-child(n+9) { animation-delay: 320ms; }

/* Quantity pulse on portion change */
.qty.pulse { animation: qty-pulse 320ms var(--ease-spring); }
@keyframes qty-pulse {
  0% { transform: scale(1); color: var(--saffron-deep); }
  50% { transform: scale(1.12); color: var(--saffron); }
  100% { transform: scale(1); color: var(--saffron-deep); }
}

/* Difficulté chevrons */
.diff { display: inline-flex; gap: 2px; }
.diff i {
  width: 6px; height: 8px;
  background: var(--ink-mute); opacity: 0.3;
  border-radius: 1.5px;
  display: inline-block;
}
.diff i.on { opacity: 1; background: var(--saffron); }

/* ============================================================
   ===== Minuteurs ============================================
   ============================================================ */

.timer-link {
  display: inline-flex; align-items: center; gap: 4px;
  margin: 0 1px;
  padding: 1px 9px 2px;
  border-radius: var(--r-pill);
  background: var(--sage-soft);
  color: var(--sage-deep);
  font-weight: 600;
  font-size: 0.94em;
  border: 1px solid color-mix(in srgb, var(--sage) 28%, transparent);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast), box-shadow var(--t-med);
  font-family: var(--font-text);
  vertical-align: baseline;
}
.timer-link:hover { background: var(--sage); color: white; }
.timer-link:active { transform: scale(0.95); }
.timer-link.running {
  background: var(--saffron); color: white;
  border-color: var(--saffron-deep);
}
.timer-link.finished {
  background: var(--tomato); color: white; border-color: var(--tomato);
  animation: timer-flash 700ms ease-in-out infinite alternate;
}
@keyframes timer-flash {
  from { box-shadow: 0 0 0 0 color-mix(in srgb, var(--tomato) 35%, transparent); }
  to { box-shadow: 0 0 0 7px color-mix(in srgb, var(--tomato) 18%, transparent); }
}

/* Dock minuteurs */
.timer-dock {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0) + 22px);
  left: 20px;
  z-index: 35;
  display: flex; flex-direction: column-reverse; gap: 8px;
  pointer-events: none;
  max-width: min(72vw, 320px);
}
.timer-card {
  pointer-events: auto;
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  padding: 6px 6px 6px 6px;
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-md);
  font-size: 0.86rem;
  animation: fade-in 320ms var(--ease-spring);
  min-width: 0;
  width: 100%;
}
.timer-card.finished {
  background: var(--tomato); color: white; border-color: var(--tomato);
  animation: timer-flash 700ms ease-in-out infinite alternate, fade-in 320ms var(--ease-spring);
}
.timer-card.paused { opacity: 0.55; }
.timer-card .ring {
  width: 34px; height: 34px;
  flex: none;
}
.timer-card .ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer-card .ring circle { fill: none; stroke-width: 3; }
.timer-card .ring .bg { stroke: var(--line); }
.timer-card .ring .fg {
  stroke: var(--saffron);
  transition: stroke-dashoffset 500ms linear;
}
.timer-card.finished .ring .bg,
.timer-card.finished .ring .fg { stroke: rgba(255,255,255,0.85); }
.timer-card .info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.timer-card .countdown {
  font-family: var(--font-display);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-size: 1.02rem; line-height: 1.1;
}
.timer-card .lbl {
  color: var(--ink-mute);
  font-size: 0.72rem; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.timer-card.finished .lbl { color: rgba(255, 255, 255, 0.85); }
.timer-card button.t-act {
  background: transparent; border: 0; padding: 5px; cursor: pointer; color: inherit; opacity: 0.7;
  border-radius: 50%; flex: none;
  display: grid; place-items: center;
}
.timer-card button.t-act:hover { opacity: 1; background: color-mix(in srgb, currentColor 12%, transparent); }
.timer-card button.t-act svg { width: 16px; height: 16px; }

/* ============================================================
   ===== Mode cuisine (plein écran) ===========================
   ============================================================ */

.cook-overlay {
  position: fixed; inset: 0;
  background: var(--bg);
  z-index: 90;
  display: none;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
}
.cook-overlay.open { display: flex; }

.cook-header {
  display: flex; align-items: center; gap: 14px;
  padding: 18px 22px 10px;
}
.cook-close {
  width: 42px; height: 42px;
  border-radius: 50%; border: 0;
  background: var(--bg-elev);
  font-size: 24px; cursor: pointer;
  flex: none;
  color: var(--ink-soft);
  transition: background var(--t-fast), color var(--t-fast);
}
.cook-close:hover { background: var(--line-soft); color: var(--ink); }

.cook-progress { flex: 1; min-width: 0; }
.cook-progress-text {
  font-size: 0.78rem; color: var(--ink-mute);
  margin-bottom: 6px; font-weight: 600;
  letter-spacing: 0.04em;
}
.cook-bar {
  height: 6px; background: var(--line-soft); border-radius: 3px; overflow: hidden;
}
.cook-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--saffron), var(--saffron-deep));
  width: 0%;
  transition: width 420ms var(--ease-out);
}

.cook-content {
  flex: 1; overflow-y: auto;
  padding: 24px 28px 32px;
  display: flex; flex-direction: column; gap: 26px;
  max-width: 760px; width: 100%;
  margin: 0 auto;
}
.cook-step-text {
  font-family: var(--font-display);
  font-size: clamp(1.55rem, 4.6vw, 2.3rem);
  line-height: 1.32;
  color: var(--ink);
  animation: cook-step-in 420ms var(--ease-spring);
}
@keyframes cook-step-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.cook-step-text .timer-link { font-size: 0.78em; padding: 3px 12px; }

.cook-ing {
  border-top: 1px solid var(--line-soft);
  padding-top: 18px;
}
.cook-ing h3 {
  font-size: 0.76rem; color: var(--ink-mute);
  text-transform: uppercase; letter-spacing: 0.08em;
  font-weight: 600; margin-bottom: 12px;
  font-family: var(--font-text);
}
.cook-ing ul { list-style: none; padding: 0; margin: 0; columns: 2; column-gap: 24px; }
.cook-ing li {
  padding: 6px 0;
  font-size: 0.96rem;
  break-inside: avoid;
  display: flex; align-items: baseline; gap: 8px;
}
.cook-ing li .qty {
  color: var(--saffron-deep);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-display);
  flex: none;
}

.cook-nav {
  display: flex; gap: 10px;
  padding: 14px 22px calc(env(safe-area-inset-bottom, 0) + 14px);
  border-top: 1px solid var(--line-soft);
  background: var(--bg-elev);
}
.cook-btn {
  flex: 1; padding: 14px 18px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--bg-card);
  font-size: 0.96rem; font-weight: 600;
  cursor: pointer;
  color: var(--ink);
  transition: transform var(--t-fast) var(--ease-spring), box-shadow var(--t-med), background var(--t-fast);
  box-shadow: var(--shadow-xs);
}
.cook-btn:hover { box-shadow: var(--shadow-sm); }
.cook-btn:active { transform: scale(0.97); }
.cook-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }
.cook-btn.next {
  flex: 2;
  background: linear-gradient(180deg, var(--saffron), var(--saffron-deep));
  color: #fff; border-color: transparent;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,0.18);
}
.cook-btn.finish {
  background: linear-gradient(180deg, var(--sage), var(--sage-deep));
  color: #fff; border-color: transparent;
}

/* Bouton "Mode cuisine" dans la vue détail */
.cook-launch {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px;
  border-radius: var(--r-pill);
  border: 0;
  background: linear-gradient(135deg, var(--sage), var(--sage-deep));
  color: white;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform var(--t-fast) var(--ease-spring), box-shadow var(--t-med);
}
.cook-launch:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.cook-launch:active { transform: scale(0.97); }
.cook-launch .ic { font-size: 1.1em; }

.section-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.section-row .section-title { margin-bottom: 0; }

@media (max-width: 640px) {
  .cook-content { padding: 18px 18px 24px; gap: 20px; }
  .cook-ing ul { columns: 1; }
  .cook-header { padding: 14px 16px 8px; }
  .cook-nav { padding: 12px 16px calc(env(safe-area-inset-bottom, 0) + 12px); }
  .cook-btn { padding: 13px 14px; }
}

/* ============================================================
   ===== Galerie photos recette ===============================
   ============================================================ */

.recipe-images {
  display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  margin-bottom: 22px;
}
.recipe-images .img-card {
  aspect-ratio: 1;
  border-radius: var(--r-md);
  background: var(--line-soft);
  position: relative;
  overflow: hidden;
  cursor: zoom-in;
  box-shadow: var(--shadow-xs);
  transition: transform var(--t-med) var(--ease-spring), box-shadow var(--t-med);
}
.recipe-images .img-card.first {
  grid-column: 1 / -1;
  aspect-ratio: 16 / 9;
}
.recipe-images .img-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.recipe-images .img-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.recipe-images .img-card .del-img {
  position: absolute; top: 8px; right: 8px;
  width: 28px; height: 28px;
  background: rgba(0,0,0,0.55); color: white;
  border: 0; border-radius: 50%;
  display: grid; place-items: center;
  cursor: pointer; opacity: 0;
  font-size: 16px;
  transition: opacity var(--t-fast);
}
.recipe-images .img-card:hover .del-img,
.recipe-images .img-card:focus-within .del-img { opacity: 1; }
.recipe-images .add-img-btn {
  aspect-ratio: 1;
  border-radius: var(--r-md);
  border: 1.5px dashed var(--line);
  background: var(--bg-elev);
  display: grid; place-items: center;
  align-content: center;
  color: var(--ink-mute);
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast), color var(--t-fast);
  font-size: 0.84rem;
  gap: 4px;
  text-align: center;
  padding: 8px;
}
.recipe-images .add-img-btn:hover {
  border-color: var(--saffron); background: var(--saffron-soft); color: var(--saffron-deep);
}
.recipe-images .add-img-btn .ic { font-size: 22px; }
.recipe-images .add-img-btn.gen {
  border-color: color-mix(in srgb, var(--plum) 35%, var(--line));
  color: var(--plum);
}
.recipe-images .add-img-btn.gen:hover {
  background: color-mix(in srgb, var(--plum) 8%, var(--bg-elev));
  border-color: var(--plum);
}
.recipe-images .add-img-btn.busy {
  pointer-events: none;
  opacity: 0.7;
}

/* Lightbox */
.lightbox {
  position: fixed; inset: 0;
  background: rgba(15, 12, 8, 0.92);
  z-index: 200;
  display: grid; place-items: center;
  padding: 20px;
  opacity: 0; pointer-events: none;
  transition: opacity var(--t-med);
}
.lightbox.open { opacity: 1; pointer-events: auto; }
.lightbox img {
  max-width: 100%; max-height: 90vh; object-fit: contain;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  background: var(--bg-card);
}
.lightbox .close-lb {
  position: absolute; top: 16px; right: 16px;
  width: 42px; height: 42px; border-radius: 50%;
  background: rgba(255,255,255,0.15); border: 0; color: white;
  font-size: 22px; cursor: pointer;
  display: grid; place-items: center;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* Picker dans Add modal */
.image-picker {
  margin-top: 8px;
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
}
.image-picker .pick-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 14px;
  border-radius: var(--r-pill);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  cursor: pointer;
  font-size: 0.88rem;
  color: var(--ink-soft);
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.image-picker .pick-btn:hover {
  background: var(--saffron-soft); border-color: var(--saffron); color: var(--saffron-deep);
}
.image-picker .preview {
  width: 64px; height: 64px;
  border-radius: var(--r-sm);
  background-size: cover; background-position: center;
  border: 1px solid var(--line);
  position: relative;
}
.image-picker .preview .x {
  position: absolute; top: -6px; right: -6px;
  width: 22px; height: 22px;
  background: var(--ink); color: white;
  border-radius: 50%; border: 2px solid var(--bg-card);
  cursor: pointer;
  font-size: 13px; line-height: 1;
  display: grid; place-items: center;
}

/* ===== Suggest chips (Retravailler) ===== */
.suggest-chips {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 6px;
}
.suggest-chips .chip {
  padding: 7px 12px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--bg-elev);
  font-size: 0.82rem;
  cursor: pointer;
  color: var(--ink-soft);
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}
.suggest-chips .chip:hover {
  background: var(--saffron-soft);
  border-color: var(--saffron);
  color: var(--saffron-deep);
}
.suggest-chips .chip:active { transform: scale(0.96); }

/* Bouton ✨ retravailler dans la vue détail */
.btn-refine {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 15px;
  border-radius: var(--r-pill);
  border: 1px solid color-mix(in srgb, var(--saffron) 30%, var(--line));
  background: linear-gradient(180deg, var(--saffron-soft), var(--bg-card));
  color: var(--saffron-deep);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.86rem;
  box-shadow: var(--shadow-xs);
  transition: transform var(--t-fast) var(--ease-spring), box-shadow var(--t-med);
}
.btn-refine:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
  border-color: var(--saffron);
}
.btn-refine:active { transform: translateY(0) scale(0.97); }

/* ===== Settings (config endpoint Worker + token) ===== */
.settings-grid { display: grid; gap: 14px; }
.code {
  font-family: ui-monospace, SFMono-Regular, 'SF Mono', Consolas, monospace;
  background: var(--line-soft);
  padding: 2px 6px; border-radius: 6px;
  font-size: 0.86rem;
}

/* ===== Mode sombre — ajustements card gradients ===== */
@media (prefers-color-scheme: dark) {
  .portion-control {
    background: linear-gradient(180deg, color-mix(in srgb, var(--saffron) 22%, var(--bg-card)), var(--bg-card));
  }
}

/* ===== Tablette / desktop ===== */
@media (min-width: 720px) {
  .detail { padding: 36px 40px; }
}

/* ============================================================
   ===== MOBILE FIRST — refonte écrans étroits ================
   ============================================================ */

html { -webkit-text-size-adjust: 100%; }
body { overflow-x: hidden; }

button { touch-action: manipulation; }

/* Empêcher le zoom iOS quand un input prend le focus (font ≥ 16px) */
.field input, .field textarea, .field select,
.search input, .scale-by input, .scale-by select {
  font-size: 16px;
}

@media (max-width: 640px) {
  :root {
    --pad: 14px;
    --r-lg: 18px;
  }

  body {
    /* Adoucit les gradients sur mobile pour ne pas saturer le fond */
    background:
      radial-gradient(600px 360px at 90% -10%, var(--saffron-soft) 0%, transparent 60%),
      radial-gradient(500px 320px at -10% 110%, var(--sage-soft) 0%, transparent 55%),
      var(--bg);
    background-attachment: scroll;
  }

  .app { padding: 12px 14px 110px; }

  /* ===== Header : on stack la recherche en dessous ===== */
  .header {
    margin: -12px -14px 14px;
    padding: 14px 14px 12px;
    flex-wrap: wrap;
    gap: 8px 10px;
    border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
  }
  .header .brand { font-size: 1.25rem; }
  .header .brand .dot { width: 8px; height: 8px; box-shadow: 0 0 0 3px var(--saffron-soft); }
  .header .spacer { display: none; }
  .header .search {
    order: 3;
    flex: 1 1 100%;
    max-width: 100%;
    padding: 9px 13px;
  }
  .header #btn-settings { margin-left: auto; }

  /* ===== Tabs catégories : plus compactes ===== */
  .tabs { gap: 5px; padding: 2px 0 10px; margin: 0 -14px; padding-left: 14px; padding-right: 14px; }
  .tab { padding: 7px 12px; font-size: 0.82rem; }

  /* ===== Grille recettes : 1 col confortable ===== */
  .grid { gap: 12px; }
  .card { min-height: 134px; padding: 16px; }
  .card .titre { font-size: 1.22rem; }
  .card .meta { font-size: 0.78rem; gap: 10px; }

  /* ===== Vue détail ===== */
  .back { padding: 6px 10px; font-size: 0.88rem; }
  .detail { padding: 20px 16px 26px; border-radius: 14px; }
  .detail-top h1 { font-size: 1.7rem; line-height: 1.12; }
  .detail-top .desc { font-size: 0.94rem; }
  .detail-meta {
    gap: 10px 14px;
    font-size: 0.84rem;
    padding: 12px 0;
    margin-bottom: 18px;
  }
  .detail-actions { width: 100%; justify-content: flex-end; margin-top: 4px; }

  /* ===== Portion control : compacte et fluide ===== */
  .portion-control {
    padding: 14px 14px 16px;
    gap: 12px;
    border-radius: 16px;
    margin-bottom: 20px;
  }
  .portion-row { gap: 10px; }
  .portion-row .label { font-size: 0.74rem; }
  .portion-stepper { padding: 3px; }
  .portion-stepper button { width: 34px; height: 34px; font-size: 17px; }
  .portion-stepper .value { font-size: 1.42rem; min-width: 38px; }
  .portion-unit { font-size: 0.88rem; }
  .portion-aside { width: 100%; font-size: 0.78rem; }

  /* Scale-by : empile sur 2 lignes */
  .scale-by {
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.85rem;
    width: 100%;
  }
  .scale-by select { flex: 1 1 100%; min-width: 0; }
  .scale-by input { flex: 0 0 90px; }
  .scale-by .btn { flex: 1; padding: 9px 14px; }

  /* ===== Ingrédients ===== */
  .section-title { font-size: 1.16rem; margin-bottom: 8px; }
  .ingredients { margin-bottom: 22px; }
  .ingredient { padding: 9px 2px; gap: 10px; }
  .ingredient .qty { min-width: 70px; font-size: 0.98rem; }
  .ingredient .nom { font-size: 0.95rem; line-height: 1.4; }
  .ingredient .nom .note { display: block; margin-left: 0; font-size: 0.8rem; }

  /* ===== Étapes ===== */
  .etape { padding: 12px 0; gap: 12px; }
  .etape::before { width: 30px; height: 30px; font-size: 0.95rem; }
  .etape .txt { font-size: 0.94rem; padding-top: 4px; }

  /* ===== Modales ===== */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal {
    max-width: 100%;
    max-height: 94vh;
    border-radius: 22px 22px 0 0;
    transform: translateY(40px);
  }
  .modal-overlay.open .modal { transform: translateY(0); }
  .modal-head { padding: 16px 18px 12px; }
  .modal-head .title { font-size: 1.2rem; }
  .modal-body { padding: 16px 18px 22px; }
  .modal-foot { padding: 12px 18px calc(env(safe-area-inset-bottom, 0) + 12px); }

  .field { margin-bottom: 12px; }
  .field label { font-size: 0.74rem; }
  .field textarea { min-height: 130px; }
  .row.cols-2 { grid-template-columns: 1fr; gap: 8px; }
  .row.cols-3 { grid-template-columns: 1fr 1fr; }

  .seg { padding: 3px; gap: 0; }
  .seg button { padding: 8px 6px; font-size: 0.78rem; }

  /* ===== FAB ===== */
  .fab {
    width: 56px; height: 56px;
    font-size: 26px;
    right: 18px;
    bottom: calc(env(safe-area-inset-bottom, 0) + 18px);
  }

  /* ===== Toast ===== */
  .toast { font-size: 0.84rem; padding: 9px 14px; }
  .toast-zone { bottom: 96px; }

  /* ===== Empty state ===== */
  .empty { padding: 44px 14px; }
  .empty .display { font-size: 1.4rem; }

  /* ===== Boutons ===== */
  .btn { padding: 10px 16px; font-size: 0.9rem; }
}

/* Très petits écrans (iPhone SE etc.) — encore un cran */
@media (max-width: 380px) {
  .header .brand { font-size: 1.15rem; }
  .detail-top h1 { font-size: 1.55rem; }
  .portion-stepper .value { font-size: 1.3rem; }
  .seg button { padding: 7px 4px; font-size: 0.72rem; }
}

/* Mode paysage téléphone (clavier prend de la place verticale) */
@media (max-height: 480px) and (orientation: landscape) {
  .modal { max-height: 96vh; }
  .modal-body { max-height: 70vh; }
}
