:root {
  --paper: #fffdf9;
  --cream: #faf6f2;
  --tomato: #de392a;
  --tomato-dark: #b9291f;
  --herb: #6ea24b;
  --sun: #fdc978;
  --ink: #2f1e1e;
  --soft-ink: #5a4744;
  --card: #ffffff;
  --border: #e8ddd1;
  --shadow: 0 18px 44px rgba(47, 30, 30, 0.13);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: 'Nunito', 'Segoe UI', sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1000px 400px at 12% 0%, #ffd9b5 0%, rgba(255, 217, 181, 0) 55%),
    radial-gradient(900px 320px at 90% 8%, #f7e09f 0%, rgba(247, 224, 159, 0) 58%),
    linear-gradient(180deg, var(--cream) 0%, var(--paper) 50%, #fff7ed 100%);
}

.app-shell {
  width: min(1080px, 100% - 2rem);
  margin: 1.75rem auto 2.5rem;
}

.site-footer {
  margin-top: 1.2rem;
  padding: 0.2rem 0 0.35rem;
  text-align: center;
  color: var(--soft-ink);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.45;
}

.hero-panel,
.recipe-panel,
.result-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.hero-panel {
  padding: 1.35rem 1.2rem 1.4rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero-panel::before,
.hero-panel::after {
  content: '';
  position: absolute;
  width: 170px;
  height: 170px;
  border-radius: 999px;
  filter: blur(1px);
  z-index: 0;
}

.hero-panel::before {
  background: rgba(222, 57, 42, 0.11);
  top: -78px;
  left: -58px;
}

.hero-panel::after {
  background: rgba(110, 162, 75, 0.12);
  bottom: -92px;
  right: -64px;
}

.hero-panel > * {
  position: relative;
  z-index: 1;
}

.brand-logo {
  width: min(320px, 62vw);
  display: block;
  margin: 0.25rem auto 0.8rem;
  filter: drop-shadow(0 10px 22px rgba(47, 30, 30, 0.18));
}

h1,
h2,
h3 {
  font-family: 'Bree Serif', Georgia, serif;
  letter-spacing: 0.2px;
  margin: 0;
}

h1 {
  font-size: clamp(1.6rem, 2.8vw, 2.4rem);
}

.hero-panel p {
  margin: 0.55rem 0 0;
  color: var(--soft-ink);
  font-size: 1.05rem;
}

.search-form {
  margin: 1rem auto 0;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.6rem;
  width: min(740px, 100%);
}

.search-form input,
.controls input,
.controls select {
  width: 100%;
  border: 1px solid #d9cbb9;
  background: #fff;
  color: var(--ink);
  border-radius: 14px;
  padding: 0.8rem 0.9rem;
  font: inherit;
  transition: border-color 0.18s, box-shadow 0.18s;
}

.search-form input:focus,
.controls input:focus,
.controls select:focus {
  outline: none;
  border-color: var(--tomato);
  box-shadow: 0 0 0 3px rgba(222, 57, 42, 0.2);
}

button {
  font: inherit;
  font-weight: 800;
  border: 0;
  border-radius: 14px;
  padding: 0.8rem 1rem;
  cursor: pointer;
  background: linear-gradient(135deg, var(--tomato), var(--tomato-dark));
  color: #fff;
  transition: transform 0.08s ease, filter 0.2s ease;
}

button:hover {
  filter: brightness(1.05);
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.status {
  margin-top: 0.75rem;
  min-height: 1.2rem;
  color: var(--soft-ink);
  font-size: 0.95rem;
}

.did-you-mean {
  margin-top: 0.6rem;
  min-height: 1.1rem;
  color: #6f4d24;
  font-size: 0.9rem;
  font-weight: 700;
}

.did-you-mean-btn {
  appearance: none;
  border: 1px solid #efcfab;
  border-radius: 999px;
  background: #fff7ed;
  color: #8d3a11;
  font: inherit;
  font-weight: 800;
  line-height: 1.1;
  padding: 0.12rem 0.48rem;
  cursor: pointer;
  margin-left: 0.2rem;
}

.did-you-mean-btn:hover {
  background: #fff0df;
}

.results {
  margin-top: 1rem;
  display: grid;
  gap: 0.8rem;
}

.results-actions {
  display: flex;
  justify-content: center;
  margin: 1rem 0 0;
}

.more-results-btn {
  min-width: 180px;
}

.result-card {
  position: relative;
  isolation: isolate;
  padding: 0.95rem 1rem;
  transition: opacity 0.28s ease, transform 0.28s ease, max-height 0.34s ease, margin 0.34s ease, padding 0.34s ease, border-width 0.34s ease, box-shadow 0.34s ease, border-color 0.34s ease;
  max-height: 420px;
  overflow: hidden;
}

.result-card.is-ready {
  border-color: #cfe4bf;
  box-shadow: 0 14px 28px rgba(91, 136, 65, 0.18);
  cursor: pointer;
}

.result-card.is-ready:hover {
  transform: translateY(-3px);
}

.result-card.is-ready:focus-visible {
  outline: none;
  border-color: #de8a35;
  box-shadow:
    0 0 0 3px rgba(240, 176, 115, 0.22),
    0 18px 34px rgba(176, 89, 29, 0.18);
}

.result-card.is-ready-new {
  animation: ready-pop 0.95s ease;
}

.result-card.is-open {
  border-color: #f0b073;
  box-shadow:
    0 16px 32px rgba(176, 89, 29, 0.2),
    14px 0 24px -18px rgba(176, 89, 29, 0.42);
  transform: translate(-18px, -1px);
  overflow: visible;
}

.result-card.is-open::before {
  content: '';
  position: absolute;
  top: 12px;
  bottom: 12px;
  right: -16px;
  width: 12px;
  border-radius: 0 10px 10px 0;
  background: linear-gradient(180deg, #f5bf86 0%, #de8a35 100%);
  box-shadow: 0 10px 20px rgba(176, 89, 29, 0.26);
}

.result-card.is-open .result-state {
  border-color: #f0b073;
  background: #fff3e2;
  color: #8a3b0d;
}

.result-card.is-extracting {
  pointer-events: none;
}

.result-card.is-extracting > * {
  opacity: 0.18;
}

.result-card.is-extracting::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 3;
  background:
    linear-gradient(115deg, rgba(253, 201, 120, 0.17) 0%, rgba(255, 255, 255, 0.46) 44%, rgba(110, 162, 75, 0.2) 100%);
  animation: extracting-sweep 1.1s linear infinite;
}

.result-card.is-extracting::after {
  content: 'Chef is thinking...';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 4;
  border: 1px solid #efcfab;
  border-radius: 999px;
  background: rgba(255, 251, 245, 0.96);
  color: #8d3a11;
  font-size: 0.83rem;
  font-weight: 800;
  letter-spacing: 0.2px;
  padding: 0.3rem 0.7rem;
  box-shadow: 0 8px 18px rgba(98, 52, 20, 0.15);
}

.result-card.is-fading-out {
  opacity: 0;
  transform: translateY(-6px) scale(0.99);
  max-height: 0;
  margin-top: 0;
  margin-bottom: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-width: 0;
  pointer-events: none;
}

@keyframes extracting-sweep {
  0% {
    transform: translateX(-62%);
  }
  100% {
    transform: translateX(62%);
  }
}

@keyframes ready-pop {
  0% {
    transform: scale(0.99);
  }
  45% {
    transform: scale(1.01);
  }
  100% {
    transform: scale(1);
  }
}

.result-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.8rem;
  width: 100%;
}

.result-state {
  flex: none;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.2px;
  border: 1px solid #efdcc7;
  border-radius: 999px;
  background: #fffaf3;
  color: #8d3a11;
  padding: 0.2rem 0.5rem;
  white-space: nowrap;
}

.result-card.is-ready .result-state {
  border-color: #cfe4bf;
  background: #f1faeb;
  color: #346b1a;
}

.result-card h3 {
  font-size: 1.1rem;
  line-height: 1.25;
}

.result-domain {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--herb);
  margin-top: 0.3rem;
}

.result-snippet {
  margin: 0.55rem 0 0;
  color: var(--soft-ink);
}

.result-card-note {
  margin: 0.42rem 0 0;
  color: #4f6f2e;
  font-size: 0.81rem;
  font-weight: 700;
}

.recipe-panel {
  margin-top: 1rem;
  padding: 1rem;
  opacity: 0;
  transform: translateY(26px) scale(0.985);
  transform-origin: top center;
  filter: blur(14px) saturate(0.92);
  max-height: 0;
  overflow: clip;
  pointer-events: none;
  transition:
    opacity 0.42s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.58s cubic-bezier(0.22, 1, 0.36, 1),
    filter 0.5s ease,
    max-height 0.58s cubic-bezier(0.22, 1, 0.36, 1),
    margin 0.36s ease,
    padding 0.36s ease;
}

.recipe-panel.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  filter: blur(0) saturate(1);
  max-height: 2400px;
  pointer-events: auto;
}

.recipe-panel.is-leaving {
  opacity: 0;
  transform: translateY(-18px) scale(0.975);
  filter: blur(12px) saturate(0.9);
  max-height: 0;
  pointer-events: none;
}

.recipe-panel > * {
  opacity: 0;
  transform: translateY(18px);
  transition:
    opacity 0.32s ease,
    transform 0.44s cubic-bezier(0.22, 1, 0.36, 1);
}

.recipe-panel.is-visible > * {
  opacity: 1;
  transform: translateY(0);
}

.recipe-panel.is-visible > :nth-child(1) {
  transition-delay: 0.04s;
}

.recipe-panel.is-visible > :nth-child(2) {
  transition-delay: 0.1s;
}

.recipe-panel.is-visible > :nth-child(3) {
  transition-delay: 0.16s;
}

.recipe-panel.is-visible > :nth-child(4) {
  transition-delay: 0.22s;
}

.recipe-panel.is-visible > :nth-child(5) {
  transition-delay: 0.28s;
}

.recipe-panel.is-leaving > * {
  opacity: 0;
  transform: translateY(-10px);
}

.hidden {
  display: none !important;
}

.recipe-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.recipe-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.ghost-btn {
  background: #fff8ef;
  color: #8d3a11;
  border: 1px solid #efcfab;
  border-radius: 999px;
  padding: 0.34rem 0.62rem;
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.2;
}

.ghost-btn:hover {
  filter: none;
  background: #fff0df;
}

.ghost-btn.is-active {
  background: #f1faeb;
  border-color: #cfe4bf;
  color: #346b1a;
}

.recipe-head a {
  color: var(--tomato);
  font-weight: 800;
  text-decoration: none;
}

.recipe-head a:hover {
  text-decoration: underline;
}

.controls {
  margin-top: 0.9rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(140px, 220px));
  gap: 0.75rem;
}

.controls label {
  font-size: 0.85rem;
  color: var(--soft-ink);
  font-weight: 700;
  display: grid;
  gap: 0.35rem;
}

.recipe-meta {
  margin: 0.8rem 0 0;
  color: var(--soft-ink);
  font-weight: 700;
}

.recipe-columns {
  margin-top: 0.8rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

#ingredient-list,
#step-list,
#note-list {
  margin: 0.7rem 0 0;
  padding-left: 0;
  list-style: none;
}

#ingredient-list {
  display: grid;
  gap: 0.34rem;
}

.ingredient-item {
  margin: 0;
  border: 1px solid transparent;
  border-radius: 12px;
  background: #fffdfb;
  padding: 0.4rem 0.5rem;
  overflow: hidden;
  transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.ingredient-item:focus {
  outline: none;
}

.ingredient-item:hover,
.ingredient-item:focus,
.ingredient-item:focus-within,
.ingredient-item.is-active {
  background: #fff6eb;
  border-color: #efcfab;
  box-shadow: 0 6px 14px rgba(98, 52, 20, 0.11);
  transform: translateY(-1px);
}

.ingredient-item.has-subs {
  cursor: pointer;
}

.ingredient-line {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  flex-wrap: wrap;
  line-height: 1.43;
}

.ingredient-qty {
  background: #fff0df;
  border: 1px solid #f2d3b2;
  color: #8d3a11;
  border-radius: 999px;
  padding: 0.12rem 0.5rem;
  font-size: 0.86rem;
  font-weight: 800;
  letter-spacing: 0.1px;
}

.ingredient-text {
  flex: 1;
  min-width: 150px;
}

.ingredient-subs {
  display: flex;
  margin-top: 0;
  gap: 0.32rem;
  flex-wrap: wrap;
  align-items: center;
  padding-top: 0;
  border-top: 1px dashed #ead8bf;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transform: translateY(-4px);
  pointer-events: none;
  transition: max-height 0.24s ease, opacity 0.2s ease, margin-top 0.24s ease, padding-top 0.24s ease, transform 0.24s ease;
}

.ingredient-item.has-subs:hover .ingredient-subs,
.ingredient-item.has-subs:focus .ingredient-subs,
.ingredient-item.has-subs:focus-within .ingredient-subs,
.ingredient-item.has-subs.is-active .ingredient-subs {
  max-height: 96px;
  opacity: 1;
  margin-top: 0.42rem;
  padding-top: 0.34rem;
  transform: translateY(0);
  pointer-events: auto;
}

.subs-label {
  font-size: 0.78rem;
  font-weight: 800;
  color: #8d3a11;
  letter-spacing: 0.15px;
}

.subs-chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid #efd7ba;
  background: #fff;
  color: #5b3a2a;
  border-radius: 999px;
  padding: 0.12rem 0.48rem;
  font-size: 0.77rem;
  line-height: 1.2;
}

#step-list {
  display: grid;
  gap: 0.5rem;
}

#step-list li {
  margin: 0;
  display: grid;
  grid-template-columns: 1.75rem 1fr;
  gap: 0.55rem;
  align-items: flex-start;
  border: 1px solid #e8ddd1;
  border-radius: 12px;
  background: #fffcf8;
  padding: 0.48rem 0.55rem 0.5rem;
}

.step-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.45rem;
  height: 1.45rem;
  border-radius: 999px;
  background: #f9e8d6;
  color: #8d3a11;
  font-weight: 800;
  font-size: 0.82rem;
}

.step-text {
  line-height: 1.45;
}

#note-list li {
  margin: 0.42rem 0;
  line-height: 1.43;
}

.note-wrap {
  margin-top: 0.8rem;
  border-top: 1px dashed #ddcfbe;
  padding-top: 0.75rem;
}

@media (max-width: 860px) {
  .search-form {
    grid-template-columns: 1fr;
  }

  .recipe-columns {
    grid-template-columns: 1fr;
  }

  .controls {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: calc(100% - 1rem);
    margin: 0.65rem auto 1rem;
  }

  .hero-panel,
  .recipe-panel,
  .result-card {
    border-radius: 18px;
  }

  .controls {
    grid-template-columns: 1fr;
  }
}
