*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --cream:      #faf6f0;
  --cream-dark: #f0e8dc;
  --ink:        #1a1208;
  --ink-muted:  #6b5a47;
  --terra:      #c0622f;
  --terra-pale: #f5e0d4;
  --gold:       #d4a843;
  --gold-pale:  #fdf3dc;
  --green:      #4a7c5a;
  --border:     #e0d4c4;
  --nav-h:      64px;
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body:    'DM Sans', system-ui, sans-serif;
}

html { font-size: 16px; }
body {
  font-family: var(--font-body);
  background: var(--cream);
  color: var(--ink);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* HEADER */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--cream);
  border-bottom: 1px solid var(--border);
  padding: 16px 20px 0;
}
.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.header-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.1;
}
.header-title span { color: var(--terra); }

.btn-fav {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 6px 14px;
  font-family: var(--font-body);
  font-size: .8rem;
  font-weight: 500;
  color: var(--ink-muted);
  cursor: pointer;
  transition: all .2s;
}
.btn-fav.active { background: var(--gold-pale); border-color: var(--gold); color: var(--ink); }
.btn-fav svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.btn-fav.active svg { fill: var(--gold); stroke: var(--gold); }

/* TABS */
.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 14px;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex-shrink: 0;
  padding: 7px 16px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: white;
  font-family: var(--font-body);
  font-size: .82rem;
  font-weight: 500;
  color: var(--ink-muted);
  cursor: pointer;
  transition: all .2s;
}
.tab:hover { border-color: var(--terra); color: var(--terra); }
.tab.active { background: var(--terra); border-color: var(--terra); color: white; font-weight: 600; }

/* SEARCH BAR */
.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  padding: 0 20px 12px;
}
.search-icon {
  position: absolute;
  left: 32px;
  width: 15px; height: 15px;
  fill: none; stroke: var(--ink-muted); stroke-width: 2;
  pointer-events: none;
  z-index: 1;
}
.search-input {
  width: 100%;
  padding: 9px 36px 9px 36px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  background: white;
  font-family: var(--font-body);
  font-size: .88rem;
  color: var(--ink);
  outline: none;
  transition: border-color .15s;
  -webkit-appearance: none;
}
.search-input:focus  { border-color: var(--terra); }
.search-input::placeholder { color: var(--ink-muted); opacity: 1; }
.search-input::-webkit-search-cancel-button { display: none; }
.search-clear {
  position: absolute;
  right: 28px;
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  background: var(--cream-dark);
  border: none; border-radius: 50%;
  cursor: pointer;
  transition: background .15s;
  flex-shrink: 0;
}
.search-clear:hover { background: var(--border); }
.search-clear svg { width: 11px; height: 11px; stroke: var(--ink-muted); fill: none; stroke-width: 2.5; }
.search-clear[hidden] { display: none; }

/* MAIN */
main {
  padding: 20px 16px calc(var(--nav-h) + 24px);
  max-width: 600px;
  margin: 0 auto;
}

/* DATA BADGE */
.data-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: .7rem;
  color: var(--ink-muted);
  background: var(--cream-dark);
  border-radius: 10px;
  padding: 3px 10px;
  margin-bottom: 12px;
}
.data-badge.live   { color: var(--green); background: #e8f4e8; }
.data-badge.cached { color: #7c5200;    background: var(--gold-pale); }

.results-count {
  font-size: .78rem;
  color: var(--ink-muted);
  margin-bottom: 14px;
}

/* GRID */
.recipe-grid { display: flex; flex-direction: column; gap: 10px; }

/* CARD */
.recipe-card {
  background: white;
  border-radius: 14px;
  border: 1px solid var(--border);
  padding: 16px;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  position: relative;
  box-shadow: 0 2px 10px rgba(26,18,8,.06);
  transition: transform .18s, box-shadow .18s;
  animation: fadeUp .25s ease both;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.recipe-card:active { transform: scale(.985); }
@media (hover: hover) {
  .recipe-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(192,98,47,.14); }
}

/* CARD ICON — emoji centré, pas de font-rendering parasite */
.card-icon {
  width: 46px; height: 46px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  line-height: 1;
  flex-shrink: 0;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}
.card-icon.classic   { background: #fdeedd; }
.card-icon.cocktail  { background: #e8f4e8; }
.card-icon.thermomix { background: #e8eef8; }

.card-body { flex: 1; min-width: 0; }
.card-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 7px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 28px;
}
.card-meta { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }

.badge {
  font-size: .7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.badge.classic   { background: #fdeedd; color: #a0520a; }
.badge.cocktail  { background: #e8f4e8; color: #2d6a3f; }
.badge.thermomix { background: #e8eef8; color: #2d4a8a; }

.chip {
  display: flex; align-items: center; gap: 3px;
  font-size: .75rem; color: var(--ink-muted);
}
.chip svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2; }

.btn-star {
  position: absolute; top: 14px; right: 14px;
  background: none; border: none; cursor: pointer;
  padding: 4px; line-height: 1;
  transition: transform .15s;
}
.btn-star:active { transform: scale(1.3); }
.btn-star svg { width: 18px; height: 18px; fill: none; stroke: #d0c4b4; stroke-width: 1.8; }
.btn-star.on svg { fill: var(--gold); stroke: var(--gold); }

/* EMPTY */
.empty {
  text-align: center; padding: 60px 20px; color: var(--ink-muted);
}
.empty .icon { font-size: 2.5rem; margin-bottom: 12px; opacity: .4; }
.empty p { font-family: var(--font-display); font-size: 1.05rem; }

/* LOADING */
.loading { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 80px 20px; color: var(--ink-muted); }
.spinner { width: 30px; height: 30px; border: 3px solid var(--border); border-top-color: var(--terra); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* BOTTOM NAV */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: white;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  padding: 0 12px;
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 200;
}
.nav-btn {
  flex: 1; max-width: 100px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 4px;
  border: none; background: none; cursor: pointer;
  border-radius: 10px;
  color: var(--ink-muted);
  font-family: var(--font-body);
  font-size: .68rem; font-weight: 500;
  transition: color .15s;
}
.nav-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.nav-btn.active { color: var(--terra); }

/* SLIDE PANELS (detail + add) */
.slide-panel {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: var(--cream);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
}
.slide-panel.open { transform: translateX(0); }

.panel-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(12px, env(safe-area-inset-top)) 16px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--cream);
  flex-shrink: 0;
}
.btn-back {
  display: flex; align-items: center; gap: 5px;
  background: none; border: none; cursor: pointer;
  font-family: var(--font-body); font-size: .9rem; font-weight: 500;
  color: var(--terra); padding: 6px 0;
}
.btn-back svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; }

/* Detail header right-side group */
.detail-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* "Liste" button */
.btn-list {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-body);
  font-size: .82rem;
  font-weight: 700;
  color: var(--terra);
  background: var(--terra-pale);
  border: 1.5px solid transparent;
  border-radius: 20px;
  padding: 7px 13px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  white-space: nowrap;
}
.btn-list:hover  { border-color: var(--terra); }
.btn-list:active { transform: scale(.95); }
.btn-list svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; flex-shrink: 0; }

/* "Cuisiner" button */
.btn-cook {
  font-family: var(--font-body);
  font-size: .82rem;
  font-weight: 700;
  color: white;
  background: var(--terra);
  border: none;
  border-radius: 20px;
  padding: 7px 16px;
  cursor: pointer;
  transition: background .15s, transform .1s;
  white-space: nowrap;
}
.btn-cook:hover  { background: #a8521f; }
.btn-cook:active { transform: scale(.95); }

.btn-detail-star {
  background: none; border: none; cursor: pointer;
  padding: 6px; line-height: 1;
  transition: transform .15s;
}
.btn-detail-star:active { transform: scale(1.3); }
.btn-detail-star svg { width: 22px; height: 22px; fill: none; stroke: #d0c4b4; stroke-width: 1.8; display: block; }
.btn-detail-star.on svg { fill: var(--gold); stroke: var(--gold); }

.btn-delete-recipe {
  background: none; border: none; cursor: pointer;
  padding: 6px; line-height: 1;
  transition: transform .15s, opacity .15s;
  opacity: .45;
}
.btn-delete-recipe:hover  { opacity: 1; }
.btn-delete-recipe:active { transform: scale(.9); }
.btn-delete-recipe:disabled { opacity: .2; cursor: not-allowed; }
.btn-delete-recipe svg { width: 20px; height: 20px; fill: none; stroke: #c0392b; stroke-width: 1.8; display: block; }

.detail-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px 16px calc(48px + env(safe-area-inset-bottom));
}

.detail-hero {
  display: flex; align-items: flex-start; gap: 14px;
  margin-bottom: 20px;
}
.card-icon.large { width: 60px; height: 60px; font-size: 2rem; flex-shrink: 0; }
.detail-hero-text { flex: 1; min-width: 0; }
.detail-title {
  font-family: var(--font-display);
  font-size: 1.5rem; font-weight: 700;
  line-height: 1.2; margin-bottom: 8px;
}
.detail-meta { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }

.portions-row {
  display: flex; align-items: center; justify-content: space-between;
  background: white; border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 16px;
  margin-bottom: 24px;
}
.portions-label { font-size: .9rem; font-weight: 500; }
.stepper { display: flex; align-items: center; gap: 14px; }
.stepper-btn {
  width: 34px; height: 34px; border-radius: 50%;
  border: 1.5px solid var(--border); background: none; cursor: pointer;
  font-size: 1.3rem; line-height: 1; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  color: var(--terra); transition: background .15s, border-color .15s;
}
.stepper-btn:active { background: var(--terra-pale); border-color: var(--terra); }
.stepper-btn:disabled { opacity: .35; cursor: default; }
.stepper-value { font-size: 1.15rem; font-weight: 700; min-width: 28px; text-align: center; }

.detail-body { display: flex; flex-direction: column; gap: 28px; }

.section-title {
  font-family: var(--font-display);
  font-size: 1.1rem; font-weight: 700;
  margin-bottom: 14px; padding-bottom: 8px;
  border-bottom: 2px solid var(--terra-pale);
}

.ingredients-list { list-style: none; display: flex; flex-direction: column; }
.ingredient-item {
  display: flex; align-items: baseline; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid var(--border);
}
.ingredient-item:last-child { border-bottom: none; }
.ing-qty {
  font-weight: 600; font-size: .88rem; color: var(--terra);
  min-width: 56px; flex-shrink: 0;
}
.ing-name { font-size: .93rem; }
.ingredient-item.pantry .ing-name { color: var(--ink-muted); }

/* Steps toggle header */
.steps-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.steps-section-header .section-title { margin-bottom: 0; border-bottom: none; padding-bottom: 0; }
.steps-toggle {
  flex-shrink: 0;
  font-family: var(--font-body);
  font-size: .75rem;
  font-weight: 600;
  color: var(--terra);
  background: var(--terra-pale);
  border: 1.5px solid var(--terra-pale);
  border-radius: 20px;
  padding: 5px 13px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.steps-toggle:hover { background: #f0c9b8; border-color: #e0a090; }

/* All-steps list */
.steps-list { list-style: none; display: flex; flex-direction: column; gap: 18px; }
.step-item { display: flex; gap: 14px; }
.step-num {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--terra); color: white;
  font-size: .78rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 1px;
}
.step-body p { font-size: .92rem; line-height: 1.55; }
.step-timer {
  display: inline-flex; align-items: center; gap: 3px;
  margin-top: 6px; font-size: .75rem; font-weight: 600;
  color: var(--ink-muted); background: var(--cream-dark);
  padding: 2px 9px; border-radius: 10px;
}

/* Thermomix parameter cards */
.tmx-params {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.tmx-card {
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: white;
  border: 1px solid #d4daf0;
  border-radius: 10px;
  padding: 8px 12px;
  min-width: 70px;
}
.tmx-card-label {
  font-family: var(--font-body);
  font-size: .6rem;
  font-weight: 700;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  line-height: 1;
}
.tmx-card-value {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: #2d4a8a;
  line-height: 1.1;
}
/* Larger cards in cooking mode */
.cook-step-text .tmx-params { margin-top: 20px; gap: 10px; }
.cook-step-text .tmx-card   { padding: 10px 16px; min-width: 80px; border-radius: 12px; }
.cook-step-text .tmx-card-label { font-size: .62rem; }
.cook-step-text .tmx-card-value { font-size: 1.2rem; }

/* Step-by-step solo view */
.step-solo { display: flex; flex-direction: column; gap: 20px; }

.step-solo-indicator {
  font-size: .78rem; font-weight: 700;
  color: var(--terra);
  text-transform: uppercase; letter-spacing: .07em;
}

.step-solo-text p {
  font-size: 1.12rem;
  line-height: 1.65;
  color: var(--ink);
}

/* Timer block */
.step-timer-block {
  display: flex;
  align-items: center;
  gap: 16px;
  background: white;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 14px 18px;
  transition: border-color .3s, background .3s;
}
.step-timer-block.timer-done {
  border-color: var(--terra);
  background: var(--terra-pale);
  animation: timerPulse .5s ease 3;
}
@keyframes timerPulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.02); }
}
.timer-display {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--ink);
  min-width: 80px;
}
.step-timer-block.timer-done .timer-display { color: var(--terra); }
.timer-play-btn {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--terra); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s, background .15s;
  flex-shrink: 0;
}
.timer-play-btn:active { transform: scale(.92); }
.timer-play-btn svg { width: 18px; height: 18px; fill: white; stroke: none; }

/* Step navigation */
.step-solo-nav {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding-top: 4px;
}
.step-nav-btn {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--font-body); font-size: .88rem; font-weight: 600;
  color: var(--terra);
  background: white;
  border: 1.5px solid var(--border);
  border-radius: 22px;
  padding: 9px 16px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  flex: 1; justify-content: center;
}
.step-nav-btn:hover { border-color: var(--terra); background: var(--terra-pale); }
.step-nav-btn:disabled { opacity: .35; cursor: default; pointer-events: none; }
.step-nav-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; }

/* 2 colonnes — iPad paysage et desktop */
@media (min-width: 768px) and (orientation: landscape), (min-width: 960px) {
  .detail-scroll { padding: 28px 40px 48px; }
  .detail-body { flex-direction: row; align-items: flex-start; gap: 40px; }
  .detail-ingredients { flex: 0 0 280px; position: sticky; top: 0; }
  .detail-steps { flex: 1; }
}
@media (min-width: 960px) {
  .detail-scroll { max-width: 960px; margin: 0 auto; }
}

/* ══════════════════════════════════════════════════════════════
   SHOPPING LIST MODAL  (Sprint 5)
══════════════════════════════════════════════════════════════ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(26, 18, 8, .52);
  display: flex;
  align-items: flex-end; /* sheet from bottom on mobile */
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--cream);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(24px);
  transition: transform .22s cubic-bezier(.4, 0, .2, 1);
}
.modal-backdrop.open .modal { transform: translateY(0); }

/* Centered card on tablet/desktop */
@media (min-width: 600px) {
  .modal-backdrop { align-items: center; }
  .modal {
    border-radius: 20px;
    width: 460px;
    max-height: 82dvh;
    transform: scale(.96) translateY(10px);
    box-shadow: 0 24px 60px rgba(26, 18, 8, .22);
  }
  .modal-backdrop.open .modal { transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
}
.modal-close {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  background: var(--cream-dark);
  border: none; border-radius: 50%;
  cursor: pointer;
  transition: background .15s;
  flex-shrink: 0;
}
.modal-close:hover { background: var(--border); }
.modal-close svg { width: 14px; height: 14px; stroke: var(--ink); fill: none; stroke-width: 2.5; }

.modal-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Ingredient checklist */
.shop-ing-list { list-style: none; padding: 4px 20px 0; }

.shop-ing-item { border-bottom: 1px solid var(--border); }
.shop-ing-item:last-child { border-bottom: none; }

.shop-ing-label {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 0;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.shop-cb {
  width: 18px; height: 18px;
  accent-color: var(--terra);
  flex-shrink: 0;
  cursor: pointer;
}
.shop-ing-qty {
  font-weight: 700;
  font-size: .84rem;
  color: var(--terra);
  min-width: 48px;
  flex-shrink: 0;
}
.shop-ing-name { font-size: .93rem; flex: 1; line-height: 1.3; }
.shop-ing-item.pantry .shop-ing-name { color: var(--ink-muted); }
.shop-ing-item:not(.checked) .shop-cb { opacity: .75; }

.shop-pantry-tag {
  font-size: .65rem;
  font-weight: 700;
  color: var(--ink-muted);
  background: var(--cream-dark);
  border-radius: 8px;
  padding: 2px 7px;
  text-transform: uppercase;
  letter-spacing: .05em;
  flex-shrink: 0;
}

/* Grand Frais toggle row */
.shop-gf-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px 16px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}
.shop-gf-label { font-size: .9rem; font-weight: 500; line-height: 1.3; }

.shop-toggle {
  flex-shrink: 0;
  font-family: var(--font-body);
  font-size: .82rem;
  font-weight: 700;
  padding: 7px 18px;
  border-radius: 20px;
  border: 2px solid var(--border);
  background: none;
  color: var(--ink-muted);
  cursor: pointer;
  transition: all .15s;
}
.shop-toggle.on {
  background: var(--green);
  border-color: var(--green);
  color: white;
}

/* Footer + confirm button */
.modal-footer {
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.btn-add-list {
  width: 100%;
  padding: 14px;
  background: var(--terra);
  color: white;
  border: none;
  border-radius: 12px;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s;
}
.btn-add-list:hover    { background: #a8521f; }
.btn-add-list:disabled { opacity: .45; cursor: default; }

/* TOAST */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 12px);
  left: 50%; transform: translateX(-50%) translateY(8px);
  background: var(--ink); color: white;
  padding: 9px 18px; border-radius: 20px;
  font-size: .82rem; font-weight: 500;
  opacity: 0; transition: opacity .2s, transform .2s;
  pointer-events: none; white-space: nowrap; z-index: 999;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ══════════════════════════════════════════════════════════════
   COOKING MODE  (Sprint 4)
══════════════════════════════════════════════════════════════ */

/* Full-height wrapper inside panel-content */
.cook-wrap {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--cream);
}

/* ── Header ─────────────────────────────────────────────────── */
.cook-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: max(12px, env(safe-area-inset-top)) 20px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--cream);
  flex-shrink: 0;
}

.cook-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--ink);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cook-quit-btn {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 7px;
  padding: 8px 16px;
  background: var(--cream-dark);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  font-family: var(--font-body);
  font-size: .85rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.cook-quit-btn:hover { background: #e8d4c8; border-color: #c8a898; }
.cook-quit-btn svg { width: 15px; height: 15px; stroke: var(--ink-muted); fill: none; stroke-width: 2.2; }

/* ── Body layout ─────────────────────────────────────────────── */
.cook-body {
  flex: 1;
  display: flex;
  flex-direction: column; /* mobile default */
  overflow: hidden;
  min-height: 0;
}

/* iPad landscape and desktop → side by side */
@media (min-width: 768px) and (orientation: landscape),
       (min-width: 960px) {
  .cook-body         { flex-direction: row; }
  .cook-mobile-portions { display: none !important; }
  .cook-side         { display: flex !important; }
}

/* Mobile / portrait → hide sidebar */
@media not ((min-width: 768px) and (orientation: landscape)) {
  @media (max-width: 959px) {
    .cook-side { display: none; }
  }
}

/* ── Sidebar (ingredients + portions, desktop/landscape) ──────── */
.cook-side {
  width: 280px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: white;
}

@media (min-width: 960px) {
  .cook-side { width: 300px; }
}

.cook-side-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--cream);
}

.cook-side-label {
  font-size: .82rem;
  font-weight: 700;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.cook-ing-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  list-style: none;
  padding: 8px 20px 20px;
}

.cook-ing-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}
.cook-ing-item:last-child { border-bottom: none; }

.cook-ing-qty {
  font-weight: 700;
  font-size: .9rem;
  color: var(--terra);
  min-width: 56px;
  flex-shrink: 0;
}
.cook-ing-name { font-size: .92rem; line-height: 1.4; }
.cook-ing-item.pantry .cook-ing-name { color: var(--ink-muted); }

/* ── Main step area ──────────────────────────────────────────── */
.cook-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* Portions bar — mobile only */
.cook-mobile-portions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--cream);
  flex-shrink: 0;
}

/* Step content scroll area */
.cook-step-wrap {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 36px 48px 40px;
}
@media (max-width: 700px) {
  .cook-step-wrap { padding: 28px 22px 32px; gap: 24px; }
}

/* Step indicator */
.cook-step-indicator {
  font-size: .8rem;
  font-weight: 700;
  color: var(--terra);
  text-transform: uppercase;
  letter-spacing: .08em;
}

/* Step text — large and readable at arm's length */
.cook-step-text p {
  font-size: 1.45rem;
  line-height: 1.65;
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 400;
}
@media (max-width: 700px) {
  .cook-step-text p { font-size: 1.18rem; line-height: 1.6; }
}
@media (min-width: 960px) {
  .cook-step-text p { font-size: 1.6rem; }
}

/* ── Cook timer — bigger version ─────────────────────────────── */
.cook-timer-block {
  display: flex;
  align-items: center;
  gap: 20px;
  background: white;
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 18px 24px;
  transition: border-color .3s, background .3s;
  width: fit-content;
  max-width: 100%;
}
.cook-timer-block.timer-done {
  border-color: var(--terra);
  background: var(--terra-pale);
  animation: timerPulse .5s ease 3;
}
.cook-timer-display {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 700;
  letter-spacing: .03em;
  color: var(--ink);
  min-width: 110px;
}
@media (max-width: 700px) {
  .cook-timer-display { font-size: 2.2rem; min-width: 88px; }
}
.cook-timer-block.timer-done .cook-timer-display { color: var(--terra); }

.cook-timer-btn {
  width: 58px; height: 58px;
  border-radius: 50%;
  background: var(--terra);
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s, background .15s;
  flex-shrink: 0;
}
.cook-timer-btn:hover  { background: #a8521f; }
.cook-timer-btn:active { transform: scale(.9); }
.cook-timer-btn svg    { width: 22px; height: 22px; fill: white; stroke: none; }
@media (max-width: 700px) {
  .cook-timer-btn { width: 50px; height: 50px; }
  .cook-timer-btn svg { width: 18px; height: 18px; }
}

/* ── Navigation buttons — very large tap targets ─────────────── */
.cook-nav {
  display: flex;
  gap: 12px;
  margin-top: auto; /* push nav to bottom when step is short */
  padding-top: 8px;
}

.cook-nav-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
  color: var(--terra);
  background: white;
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 18px 16px;
  min-height: 62px;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.cook-nav-btn:hover   { border-color: var(--terra); background: var(--terra-pale); }
.cook-nav-btn:active  { transform: scale(.97); }
.cook-nav-btn:disabled { opacity: .3; cursor: default; pointer-events: none; }
.cook-nav-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.5; flex-shrink: 0; }
@media (min-width: 768px) {
  .cook-nav-btn { font-size: 1.05rem; padding: 20px 20px; min-height: 68px; }
}

/* ══════════════════════════════════════════════════════════════
   ADD PANEL  (Sprint 3)
══════════════════════════════════════════════════════════════ */

/* Shared header title (add panel) */
.add-header-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
}

/* Scroll area with desktop centring */
.add-scroll { padding-top: 0; }
.add-inner {
  max-width: 800px;
  margin: 0 auto;
  padding: 28px 24px calc(48px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 32px;
}
@media (max-width: 600px) {
  .add-inner { padding: 20px 16px calc(40px + env(safe-area-inset-bottom)); gap: 24px; }
}

/* ── Input section ────────────────────────────────────────────── */
.add-input-section { display: flex; flex-direction: column; gap: 14px; }

.add-tabs {
  display: flex;
  gap: 8px;
  background: var(--cream-dark);
  border-radius: 22px;
  padding: 4px;
  width: fit-content;
}
.add-tab {
  flex-shrink: 0;
  padding: 7px 18px;
  border-radius: 18px;
  border: none;
  background: none;
  font-family: var(--font-body);
  font-size: .82rem;
  font-weight: 500;
  color: var(--ink-muted);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.add-tab.active {
  background: white;
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0,0,0,.1);
}

.add-textarea {
  width: 100%;
  min-height: 200px;
  max-height: 420px;
  resize: vertical;
  padding: 14px 16px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: white;
  font-family: var(--font-body);
  font-size: .92rem;
  line-height: 1.6;
  color: var(--ink);
  transition: border-color .15s;
  outline: none;
}
.add-textarea:focus { border-color: var(--terra); }

.add-url-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.add-url-icon {
  position: absolute;
  left: 14px;
  width: 16px; height: 16px;
  fill: none; stroke: var(--ink-muted); stroke-width: 2;
  pointer-events: none;
  flex-shrink: 0;
}
.add-url-input {
  width: 100%;
  padding: 13px 14px 13px 40px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: white;
  font-family: var(--font-body);
  font-size: .92rem;
  color: var(--ink);
  outline: none;
  transition: border-color .15s;
}
.add-url-input:focus { border-color: var(--terra); }

.btn-analyze {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 20px;
  background: var(--terra);
  color: white;
  border: none;
  border-radius: 12px;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.btn-analyze:hover  { background: #a8521f; }
.btn-analyze:active { transform: scale(.98); }
.btn-analyze:disabled { opacity: .6; cursor: default; }

.spinner-sm {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}

.add-error {
  background: #fef0ee;
  border: 1.5px solid #f5c5bb;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: .85rem;
  color: #8b2a1a;
  line-height: 1.5;
}

/* ── Preview section ─────────────────────────────────────────── */
.add-preview {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding-top: 4px;
  border-top: 2px solid var(--terra-pale);
}

.add-preview-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
}
.add-preview-title svg { stroke: var(--green); fill: none; stroke-width: 2.5; flex-shrink: 0; }

/* Meta fields grid */
.add-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.add-fields .add-field:first-child { grid-column: 1 / -1; } /* Title full-width */
@media (max-width: 500px) {
  .add-fields { grid-template-columns: 1fr; }
  .add-fields .add-field:first-child { grid-column: 1; }
}

.add-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.add-label {
  font-size: .75rem;
  font-weight: 600;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.add-input-field {
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: white;
  font-family: var(--font-body);
  font-size: .9rem;
  color: var(--ink);
  outline: none;
  transition: border-color .15s;
  width: 100%;
}
.add-input-field:focus { border-color: var(--terra); }
.add-select { cursor: pointer; }

/* Sub-sections (ingredients, steps) */
.add-section { display: flex; flex-direction: column; gap: 12px; }

.add-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.add-section-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
  padding-bottom: 6px;
  border-bottom: 2px solid var(--terra-pale);
  flex: 1;
  margin-right: 14px;
}

.btn-add-row {
  flex-shrink: 0;
  font-family: var(--font-body);
  font-size: .78rem;
  font-weight: 600;
  color: var(--terra);
  background: var(--terra-pale);
  border: 1.5px solid transparent;
  border-radius: 16px;
  padding: 5px 12px;
  cursor: pointer;
  transition: border-color .15s;
}
.btn-add-row:hover { border-color: var(--terra); }

.add-empty-hint {
  font-size: .85rem;
  color: var(--ink-muted);
  font-style: italic;
  padding: 8px 0;
}

/* Ingredient edit rows */
.ing-edit-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.ing-edit-row:last-child { border-bottom: none; }

.ing-edit-qty  { width: 72px;  flex-shrink: 0; }
.ing-edit-unit { width: 68px;  flex-shrink: 0; }
.ing-edit-name { flex: 1;      min-width: 0; }

.ing-edit-qty,
.ing-edit-unit,
.ing-edit-name {
  padding: 7px 10px;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  background: white;
  font-family: var(--font-body);
  font-size: .88rem;
  color: var(--ink);
  outline: none;
  transition: border-color .15s;
}
.ing-edit-qty:focus,
.ing-edit-unit:focus,
.ing-edit-name:focus { border-color: var(--terra); }

/* Step edit rows */
.step-edit-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.step-edit-row:last-child { border-bottom: none; }

.step-edit-num {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--terra); color: white;
  font-size: .75rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 8px;
}
.step-edit-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.step-edit-text {
  width: 100%;
  min-height: 80px;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: white;
  font-family: var(--font-body);
  font-size: .9rem;
  line-height: 1.55;
  color: var(--ink);
  resize: vertical;
  outline: none;
  transition: border-color .15s;
}
.step-edit-text:focus { border-color: var(--terra); }

.step-timer-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .78rem;
  color: var(--ink-muted);
  font-weight: 500;
  flex-wrap: wrap;
}
.step-timer-label svg { stroke: var(--ink-muted); fill: none; stroke-width: 2; flex-shrink: 0; }
.step-edit-timer {
  width: 100px;
  padding: 5px 8px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: white;
  font-family: var(--font-body);
  font-size: .82rem;
  color: var(--ink);
  outline: none;
  transition: border-color .15s;
}
.step-edit-timer:focus { border-color: var(--terra); }

/* Delete row button */
.btn-del-row {
  flex-shrink: 0;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  color: var(--ink-muted);
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
  align-self: center;
}
.btn-del-row:hover { border-color: #d04040; color: #d04040; background: #fff0f0; }
.btn-del-row svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; }

/* Save button */
.add-save-row { padding-top: 8px; }
.btn-save {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 15px 20px;
  background: var(--green);
  color: white;
  border: none;
  border-radius: 12px;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.btn-save:hover  { background: #3a6648; }
.btn-save:active { transform: scale(.98); }
.btn-save:disabled { opacity: .6; cursor: default; }
.btn-save svg { width: 18px; height: 18px; stroke: white; fill: none; stroke-width: 2; flex-shrink: 0; }
