/* =========================================
   kueche — Design System
   Editorial Culinary · iPhone-first
   ========================================= */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,500;0,600;1,300;1,400;1,500;1,600&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;1,9..40,300&display=swap');

/* === Design Tokens === */
:root {
  --cream:            #F3EDE1;
  --parchment:        #EAE1D1;
  --ink:              #1E1509;
  --ink-mid:          #5A4C38;
  --ink-muted:        rgba(30, 21, 9, 0.45);
  --ink-ghost:        rgba(30, 21, 9, 0.1);
  --ink-whisper:      rgba(30, 21, 9, 0.055);
  --terra:            #B5532A;
  --terra-dark:       #973F1A;
  --terra-pale:       #EED8CA;
  --terra-pale-mid:   #E4C5B0;
  --card:             rgba(252, 248, 241, 0.97);
  --white:            #FDFAF3;

  --font-serif:       'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --font-sans:        'DM Sans', system-ui, -apple-system, sans-serif;

  --nav-h:            56px;

  --r-sm:  8px;
  --r-md:  16px;
  --r-lg:  22px;
  --r-xl:  28px;

  --sh-sm: 0 1px 4px rgba(30, 21, 9, 0.07), 0 1px 2px rgba(30, 21, 9, 0.05);
  --sh-md: 0 4px 16px rgba(30, 21, 9, 0.09), 0 2px 4px rgba(30, 21, 9, 0.06);
  --sh-lg: 0 8px 36px rgba(30, 21, 9, 0.13), 0 3px 8px rgba(30, 21, 9, 0.07);

  --ease:        cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --ease-out:    cubic-bezier(0.0, 0.0, 0.2, 1);
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background-color: var(--cream);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

/* Subtle grain texture */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  opacity: 0.032;
  pointer-events: none;
  z-index: 9999;
  mix-blend-mode: multiply;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
}

button, input, select, textarea {
  font-family: var(--font-sans);
  -webkit-appearance: none;
  appearance: none;
}


/* ===========================
   NAVIGATION
   =========================== */

.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: calc(var(--nav-h) + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  background: rgba(243, 237, 225, 0.86);
  -webkit-backdrop-filter: blur(24px) saturate(1.8);
  backdrop-filter: blur(24px) saturate(1.8);
  border-bottom: 1px solid var(--ink-ghost);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--nav-h);
  padding: 0 20px;
  max-width: 900px;
  margin: 0 auto;
}

.nav-logo {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  font-size: 1.5rem;
  letter-spacing: 0.01em;
  color: var(--ink);
  line-height: 1;
}

.nav-add {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--terra);
  color: #fff;
  padding: 8px 16px;
  border-radius: 100px;
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: background 0.15s, transform 0.15s var(--ease);
  touch-action: manipulation;
  white-space: nowrap;
}

.nav-add-icon {
  font-size: 1.1rem;
  font-weight: 300;
  line-height: 1;
  margin-top: -1px;
}

.nav-add:active {
  background: var(--terra-dark);
  transform: scale(0.96);
}

@media (hover: hover) {
  .nav-add:hover {
    background: var(--terra-dark);
  }
}


/* ===========================
   MAIN LAYOUT
   =========================== */

.main {
  padding-top: calc(var(--nav-h) + env(safe-area-inset-top));
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
  min-height: 100vh;
  min-height: 100dvh;
}


/* ===========================
   GALLERY PAGE
   =========================== */

.gallery {
  max-width: 900px;
  margin: 0 auto;
  padding: 32px 20px;
}

.gallery-header {
  margin-bottom: 28px;
  animation: fade-up 0.55s var(--ease-out) both;
}

.gallery-title {
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: 2rem;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.1;
}

.gallery-count {
  font-size: 0.8125rem;
  color: var(--ink-muted);
  margin-top: 6px;
  font-weight: 300;
}

/* Featured card */
.recipe-featured {
  display: block;
  border-radius: var(--r-xl);
  overflow: hidden;
  background: var(--card);
  box-shadow: var(--sh-md);
  margin-bottom: 16px;
  touch-action: manipulation;
  transition: transform 0.22s var(--ease), box-shadow 0.22s var(--ease);
  animation: fade-up 0.55s var(--ease-out) 0.08s both;
}

.recipe-featured:active {
  transform: scale(0.99);
}

@media (hover: hover) {
  .recipe-featured:hover {
    transform: translateY(-3px);
    box-shadow: var(--sh-lg);
  }
}

.recipe-featured-image {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
}

.recipe-featured-placeholder {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, var(--parchment) 0%, var(--terra-pale) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.5rem;
  opacity: 0.45;
}

.recipe-featured-body {
  padding: 18px 22px 22px;
}

.recipe-featured-eyebrow {
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--terra);
  margin-bottom: 7px;
}

.recipe-featured-title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 1.55rem;
  line-height: 1.2;
  letter-spacing: -0.015em;
  color: var(--ink);
  margin-bottom: 6px;
}

.recipe-featured-author {
  font-size: 0.8125rem;
  color: var(--ink-muted);
  font-weight: 300;
}

/* Recipe grid */
.recipe-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.recipe-card {
  display: block;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--card);
  box-shadow: var(--sh-sm);
  touch-action: manipulation;
  transition: transform 0.22s var(--ease), box-shadow 0.22s var(--ease);
}

.recipe-card:active {
  transform: scale(0.975);
}

@media (hover: hover) {
  .recipe-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--sh-md);
  }
}

.recipe-card:nth-child(1) { animation: fade-up 0.5s var(--ease-out) 0.14s both; }
.recipe-card:nth-child(2) { animation: fade-up 0.5s var(--ease-out) 0.18s both; }
.recipe-card:nth-child(3) { animation: fade-up 0.5s var(--ease-out) 0.22s both; }
.recipe-card:nth-child(4) { animation: fade-up 0.5s var(--ease-out) 0.26s both; }
.recipe-card:nth-child(5) { animation: fade-up 0.5s var(--ease-out) 0.30s both; }
.recipe-card:nth-child(6) { animation: fade-up 0.5s var(--ease-out) 0.34s both; }
.recipe-card:nth-child(7) { animation: fade-up 0.5s var(--ease-out) 0.38s both; }
.recipe-card:nth-child(8) { animation: fade-up 0.5s var(--ease-out) 0.42s both; }

.recipe-card-image {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
}

.recipe-card-placeholder {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: linear-gradient(135deg, var(--parchment) 0%, var(--terra-pale) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  opacity: 0.4;
}

.recipe-card-body {
  padding: 11px 14px 14px;
}

.recipe-card-title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 1.025rem;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.recipe-card-author {
  font-size: 0.74rem;
  color: var(--ink-muted);
  font-weight: 300;
}

/* Empty state */
.gallery-empty {
  text-align: center;
  padding: 72px 20px;
  animation: fade-up 0.5s var(--ease-out) both;
}

.gallery-empty-icon {
  font-size: 4rem;
  margin-bottom: 24px;
  opacity: 0.28;
  display: block;
}

.gallery-empty-title {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.6rem;
  font-weight: 400;
  color: var(--ink);
  margin-bottom: 12px;
}

.gallery-empty-text {
  font-size: 0.9375rem;
  color: var(--ink-muted);
  font-weight: 300;
  max-width: 270px;
  margin: 0 auto 32px;
  line-height: 1.65;
}


/* ===========================
   BUTTONS
   =========================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 100px;
  padding: 12px 24px;
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s, transform 0.15s var(--ease);
  text-decoration: none;
  white-space: nowrap;
}

.btn-terra {
  background: var(--terra);
  color: #fff;
}

.btn-terra:active {
  background: var(--terra-dark);
  transform: scale(0.97);
}

@media (hover: hover) {
  .btn-terra:hover {
    background: var(--terra-dark);
  }
}

.btn-terra:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}


/* ===========================
   EXTRACT PAGE
   =========================== */

.extract-page {
  max-width: 560px;
  margin: 0 auto;
  padding: 40px 20px;
}

.extract-header {
  margin-bottom: 36px;
  animation: fade-up 0.5s var(--ease-out) both;
}

.extract-eyebrow {
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--terra);
  margin-bottom: 10px;
}

.extract-title {
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: 2.25rem;
  line-height: 1.1;
  letter-spacing: -0.025em;
  color: var(--ink);
  margin-bottom: 12px;
}

.extract-subtitle {
  font-size: 0.9375rem;
  color: var(--ink-muted);
  font-weight: 300;
  line-height: 1.65;
}

.extract-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: fade-up 0.5s var(--ease-out) 0.1s both;
}

.input-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-mid);
  margin-bottom: 8px;
}

.input-field {
  width: 100%;
  background: var(--card);
  border: 1.5px solid var(--ink-ghost);
  border-radius: var(--r-md);
  padding: 15px 18px;
  font-size: 16px; /* min 16px prevents iOS auto-zoom */
  color: var(--ink);
  outline: none;
  line-height: 1.5;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
}

.input-field::placeholder {
  color: var(--ink-muted);
  font-weight: 300;
}

.input-field:focus {
  border-color: var(--terra);
  box-shadow: 0 0 0 3px rgba(181, 83, 42, 0.13);
}

.btn-extract {
  width: 100%;
  background: var(--terra);
  color: #fff;
  border: none;
  border-radius: var(--r-md);
  padding: 15px 24px;
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s, transform 0.15s var(--ease);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  -webkit-appearance: none;
}

.btn-extract:active {
  background: var(--terra-dark);
  transform: scale(0.99);
}

@media (hover: hover) {
  .btn-extract:hover {
    background: var(--terra-dark);
  }
}

.btn-extract:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

/* Button loading state */
.btn-extract-spinner {
  display: none;
  align-items: center;
  gap: 10px;
}

.btn-extract.is-loading .btn-extract-label { display: none; }
.btn-extract.is-loading .btn-extract-spinner { display: flex; }

.btn-extract.is-loading {
  background: var(--ink-mid);
  opacity: 1;
  cursor: wait;
}

.btn-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

.extract-hint {
  font-size: 0.78rem;
  color: var(--ink-muted);
  font-weight: 300;
  text-align: center;
  margin-top: -4px;
}

/* Error box */
.error-box {
  background: rgba(181, 83, 42, 0.07);
  border: 1.5px solid rgba(181, 83, 42, 0.2);
  border-radius: var(--r-md);
  padding: 14px 18px;
  margin-bottom: 20px;
}

.error-box p {
  font-size: 0.9rem;
  color: var(--terra-dark);
  font-weight: 400;
  line-height: 1.5;
}

/* Form → Loading crossfade */
#form-section {
  transition: opacity 0.4s var(--ease), transform 0.4s var(--ease);
}

.extract-page.is-loading #form-section {
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  position: absolute;
  visibility: hidden;
}

/* Loading state */
.loading-state {
  display: none;
  text-align: center;
  padding: 48px 20px;
}

.extract-page.is-loading .loading-state {
  display: block;
}

.loading-ring {
  width: 48px;
  height: 48px;
  border: 2.5px solid var(--ink-ghost);
  border-top-color: var(--terra);
  border-radius: 50%;
  margin: 0 auto 28px;
  animation: spin 0.8s linear infinite;
}

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

.loading-title {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.4rem;
  font-weight: 400;
  color: var(--ink);
  margin-bottom: 28px;
  transition: opacity 0.3s var(--ease);
}

/* Step indicators */
.loading-steps {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 28px;
}

.loading-step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--ink-muted);
  letter-spacing: 0.01em;
  transition: color 0.4s var(--ease);
}

.loading-step.is-active {
  color: var(--terra);
  font-weight: 500;
}

.loading-step.is-done {
  color: var(--ink-mid);
}

.loading-step-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink-ghost);
  flex-shrink: 0;
  transition: background 0.4s var(--ease), transform 0.4s var(--ease);
}

.loading-step.is-active .loading-step-dot {
  background: var(--terra);
  transform: scale(1.2);
  animation: pulse-dot 1.5s var(--ease) infinite;
}

.loading-step.is-done .loading-step-dot {
  background: var(--terra-pale-mid);
}

@keyframes pulse-dot {
  0%, 100% { transform: scale(1.2); opacity: 1; }
  50%      { transform: scale(0.9); opacity: 0.6; }
}

.loading-sub {
  font-size: 0.8125rem;
  color: var(--ink-muted);
  font-weight: 300;
  line-height: 1.6;
  max-width: 240px;
  margin: 0 auto;
}


/* ===========================
   DETAIL PAGE
   =========================== */

.detail-page {
  max-width: 680px;
  margin: 0 auto;
  padding: 24px 20px;
}

.detail-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  color: var(--ink-muted);
  font-weight: 400;
  margin-bottom: 20px;
  touch-action: manipulation;
  transition: color 0.15s;
  animation: fade-up 0.4s var(--ease-out) both;
}

.detail-back:active,
@media (hover: hover) {
  .detail-back:hover {
    color: var(--terra);
  }
}

.detail-hero {
  border-radius: var(--r-xl);
  overflow: hidden;
  margin-bottom: 24px;
  background: linear-gradient(135deg, var(--parchment) 0%, var(--terra-pale) 100%);
  animation: fade-up 0.45s var(--ease-out) 0.05s both;
}

.detail-hero-image {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
}

.detail-hero-placeholder {
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  opacity: 0.3;
}

.detail-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  animation: fade-up 0.45s var(--ease-out) 0.1s both;
}

.detail-author {
  font-size: 0.8125rem;
  color: var(--terra);
  font-weight: 500;
  letter-spacing: 0.02em;
}

.detail-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--ink-ghost);
  flex-shrink: 0;
}

.detail-source {
  font-size: 0.8125rem;
  color: var(--ink-muted);
  font-weight: 300;
  text-decoration: underline;
  text-decoration-color: var(--ink-ghost);
  text-underline-offset: 2px;
  transition: color 0.15s;
}

.detail-source:hover {
  color: var(--terra);
}

.detail-title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 1.9rem;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin-bottom: 16px;
  animation: fade-up 0.45s var(--ease-out) 0.12s both;
}

.detail-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--terra-pale);
  color: var(--terra-dark);
  padding: 5px 13px;
  border-radius: 100px;
  font-size: 0.8125rem;
  font-weight: 500;
  margin-bottom: 28px;
  animation: fade-up 0.45s var(--ease-out) 0.15s both;
}

.detail-divider {
  border: none;
  border-top: 1px solid var(--ink-ghost);
  margin: 28px 0;
}

/* Sections */
.detail-section {
  margin-bottom: 32px;
  animation: fade-up 0.45s var(--ease-out) 0.2s both;
}

.detail-section + .detail-section {
  animation-delay: 0.25s;
}

.detail-section-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.detail-section-title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 1.3rem;
  letter-spacing: -0.01em;
  color: var(--ink);
  white-space: nowrap;
}

.detail-section-rule {
  flex: 1;
  height: 1px;
  background: var(--ink-ghost);
}

/* Ingredients */
.ingredients-list {
  list-style: none;
}

.ingredient-item {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--ink-whisper);
  align-items: baseline;
  position: relative;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.3s var(--ease);
}

.ingredient-item:last-child {
  border-bottom: none;
}

.ingredient-qty {
  font-variant-numeric: tabular-nums;
  font-size: 0.875rem;
  color: var(--ink-muted);
  font-weight: 400;
  text-align: right;
  white-space: nowrap;
  padding-right: 4px;
}

.ingredient-name {
  font-size: 0.9375rem;
  color: var(--ink);
  font-weight: 400;
  line-height: 1.4;
}

.ingredient-prep {
  font-size: 0.8125rem;
  color: var(--ink-muted);
  font-weight: 300;
  font-style: italic;
  display: block;
  margin-top: 2px;
}

/* Ingredient cross-off */
.ingredient-item::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: var(--ink-muted);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.3s var(--ease);
  pointer-events: none;
}

.ingredient-item.checked::after {
  transform: scaleX(1);
}

.ingredient-item.checked .ingredient-qty,
.ingredient-item.checked .ingredient-name {
  opacity: 0.35;
  transition: opacity 0.3s var(--ease);
}

.ingredient-item:focus-visible {
  outline: 2px solid var(--terra);
  outline-offset: 4px;
  border-radius: 4px;
}

/* Instructions */
.instructions-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.instruction-item {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 14px;
  align-items: start;
}

.instruction-num {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--terra-pale);
  color: var(--terra-dark);
  font-size: 0.78rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.instruction-text {
  font-size: 0.9375rem;
  line-height: 1.7;
  color: var(--ink);
  font-weight: 300;
}

/* Notes */
.notes-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.note-item {
  display: flex;
  gap: 12px;
  align-items: start;
  font-size: 0.9375rem;
  line-height: 1.65;
  color: var(--ink-mid);
  font-weight: 300;
}

.note-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--terra-pale-mid);
  flex-shrink: 0;
  margin-top: 8px;
}


/* ===========================
   ANIMATIONS
   =========================== */

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}


/* ===========================
   RESPONSIVE
   =========================== */

@media (min-width: 480px) {
  .gallery-title {
    font-size: 2.25rem;
  }

  .recipe-featured-title {
    font-size: 1.75rem;
  }

  .extract-title {
    font-size: 2.75rem;
  }

  .detail-title {
    font-size: 2.25rem;
  }

  .detail-hero-image {
    aspect-ratio: 16 / 9;
  }

  .detail-hero-placeholder {
    aspect-ratio: 16 / 9;
  }
}

@media (min-width: 640px) {
  .recipe-grid {
    gap: 16px;
  }

  .gallery {
    padding: 40px 24px;
  }

  .detail-page {
    padding: 32px 24px;
  }
}


/* ===========================
   AI ASSISTANT
   =========================== */

.ask-fab {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  right: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: #B5532A;
  color: #F3EDE1;
  border: none;
  border-radius: 22px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(30, 21, 9, 0.18), 0 2px 4px rgba(30, 21, 9, 0.1);
  z-index: 10000;
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1),
              box-shadow 0.2s ease,
              opacity 0.2s ease;
}

.ask-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(30, 21, 9, 0.22), 0 3px 6px rgba(30, 21, 9, 0.12);
}

.ask-fab:active {
  transform: translateY(0);
}

.ask-fab svg {
  flex-shrink: 0;
}

.ask-overlay {
  position: fixed;
  inset: 0;
  background: rgba(30, 21, 9, 0.3);
  z-index: 10001;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

.ask-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.ask-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 65vh;
  height: 65dvh;
  max-height: 600px;
  background: #F3EDE1;
  border-radius: 22px 22px 0 0;
  z-index: 10002;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 -8px 36px rgba(30, 21, 9, 0.12), 0 -3px 8px rgba(30, 21, 9, 0.06);
}

.ask-panel.open {
  transform: translateY(0);
}

.ask-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(30, 21, 9, 0.1);
  flex-shrink: 0;
}

.ask-panel-title {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 1.2rem;
  font-weight: 500;
  color: #1E1509;
  margin: 0;
}

.ask-panel-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: rgba(30, 21, 9, 0.45);
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  transition: color 0.15s ease;
}

.ask-panel-close:hover {
  color: #1E1509;
}

.ask-panel-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  -webkit-overflow-scrolling: touch;
}

.ask-msg {
  max-width: 85%;
  line-height: 1.55;
  font-size: 0.92rem;
  animation: askFadeIn 0.25s ease;
}

.ask-msg-user {
  align-self: flex-end;
  background: #B5532A;
  color: #F3EDE1;
  padding: 10px 16px;
  border-radius: 16px 16px 4px 16px;
  font-family: 'DM Sans', sans-serif;
}

.ask-msg-assistant {
  align-self: flex-start;
  color: #1E1509;
  padding: 4px 0;
  font-family: 'DM Sans', sans-serif;
}

.ask-msg-assistant p { margin: 0 0 0.5em; }
.ask-msg-assistant p:last-child { margin-bottom: 0; }
.ask-msg-assistant h1,
.ask-msg-assistant h2,
.ask-msg-assistant h3,
.ask-msg-assistant h4 {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 600;
  margin: 0.8em 0 0.3em;
  line-height: 1.3;
}
.ask-msg-assistant h1:first-child,
.ask-msg-assistant h2:first-child,
.ask-msg-assistant h3:first-child { margin-top: 0; }
.ask-msg-assistant h3 { font-size: 1rem; }
.ask-msg-assistant h4 { font-size: 0.92rem; }
.ask-msg-assistant ul,
.ask-msg-assistant ol {
  margin: 0.3em 0 0.6em;
  padding-left: 1.4em;
}
.ask-msg-assistant li { margin-bottom: 0.25em; }
.ask-msg-assistant li:last-child { margin-bottom: 0; }
.ask-msg-assistant strong { font-weight: 600; }
.ask-msg-assistant hr {
  border: none;
  border-top: 1px solid rgba(30, 21, 9, 0.12);
  margin: 0.6em 0;
}

.ask-msg-error {
  color: #B5532A;
  font-style: italic;
}

.ask-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 0;
}

.ask-chip {
  background: rgba(30, 21, 9, 0.055);
  border: 1px solid rgba(30, 21, 9, 0.1);
  border-radius: 16px;
  padding: 8px 16px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  color: #5A4C38;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.ask-chip:hover {
  background: rgba(30, 21, 9, 0.1);
  border-color: rgba(30, 21, 9, 0.2);
}

.ask-panel-input {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid rgba(30, 21, 9, 0.1);
  flex-shrink: 0;
}

.ask-input {
  flex: 1;
  background: rgba(30, 21, 9, 0.055);
  border: 1px solid rgba(30, 21, 9, 0.1);
  border-radius: 16px;
  padding: 10px 16px;
  font-family: 'DM Sans', sans-serif;
  font-size: 16px;
  color: #1E1509;
  outline: none;
  transition: border-color 0.15s ease;
}

.ask-input::placeholder {
  color: rgba(30, 21, 9, 0.35);
}

.ask-input:focus {
  border-color: #B5532A;
}

.ask-send {
  background: #B5532A;
  color: #F3EDE1;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.ask-send:disabled {
  opacity: 0.4;
  cursor: default;
}

.ask-send:not(:disabled):hover {
  transform: scale(1.05);
}

@keyframes askFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

