:root {
  --bg: #07080c;
  --surface: rgba(255, 255, 255, 0.06);
  --surface-strong: rgba(255, 255, 255, 0.1);
  --surface-dark: rgba(0, 0, 0, 0.24);

  --border: rgba(255, 255, 255, 0.13);
  --border-strong: rgba(255, 255, 255, 0.22);

  --text: #f8fafc;
  --muted: #b7bdca;
  --muted-2: #818898;

  --accent: #ff9f1c;
  --accent-2: #ffbf69;
  --success: #3ddc97;
  --danger: #ef476f;

  --shadow: 0 28px 80px rgba(0, 0, 0, 0.5);

  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 159, 28, 0.22), transparent 34rem),
    radial-gradient(circle at top right, rgba(61, 220, 151, 0.14), transparent 30rem),
    radial-gradient(circle at bottom right, rgba(239, 71, 111, 0.1), transparent 28rem),
    linear-gradient(135deg, #07080c 0%, #111827 52%, #050507 100%);
}

body.modal-open {
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 48px 0;
}

/* Header */

.hero {
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-2);
  font-size: 0.76rem;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: 0.13em;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2.6rem, 6vw, 5.2rem);
  line-height: 0.95;
  letter-spacing: -0.06em;
}

.subtitle {
  max-width: 720px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 1.1rem;
}

/* Shells */

.form-card,
.results-shell,
.empty-state,
.recipe-detail-card {
  background:
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.06), transparent 24rem),
    var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.form-card {
  padding: 24px;
}

main {
  margin-top: 28px;
}

/* Form */

.form-group {
  margin-bottom: 18px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.section-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

label {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 800;
}

.small-muted,
.input-help {
  color: var(--muted-2);
  font-size: 0.9rem;
}

.input-help {
  margin: 8px 0 0;
}

input,
select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  padding: 0 14px;
  outline: none;
}

select option {
  background: #11131b;
  color: var(--text);
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(255, 159, 28, 0.16);
}

/* Typeahead */

.typeahead-wrapper {
  position: relative;
}

.typeahead-results {
  position: absolute;
  z-index: 30;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #11131b;
  box-shadow: var(--shadow);
}

.typeahead-section-title {
  padding: 10px 14px 6px;
  color: var(--accent-2);
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.typeahead-item {
  width: 100%;
  display: block;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 12px 14px;
}

.typeahead-item:hover,
.typeahead-item.active {
  background: rgba(255, 255, 255, 0.08);
}

.typeahead-item-main {
  display: block;
  font-weight: 800;
}

.typeahead-item-sub {
  display: block;
  margin-top: 2px;
  color: var(--muted-2);
  font-size: 0.82rem;
}

/* Selected ingredients */

.selected-box {
  min-height: 54px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  border: 1px dashed var(--border-strong);
  border-radius: 18px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.22);
}

.selected-placeholder {
  color: var(--muted-2);
}

.selected-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(255, 159, 28, 0.28);
  border-radius: 999px;
  background: rgba(255, 159, 28, 0.12);
  color: var(--accent-2);
  padding: 8px 12px;
  font-size: 0.9rem;
  font-weight: 750;
}

.chip-remove {
  width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  color: var(--accent-2);
  background: rgba(255, 255, 255, 0.08);
  line-height: 1;
}

/* Buttons */

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
}

.primary-button,
.secondary-button {
  min-height: 48px;
  border-radius: var(--radius-md);
  padding: 0 18px;
  font-weight: 900;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.primary-button {
  border: 0;
  color: #1a1000;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.secondary-button {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
}

.primary-button:hover,
.secondary-button:hover {
  transform: translateY(-1px);
}

/* Results */

.results-shell {
  padding: 24px;
}

.results-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.results-header h2 {
  margin: 0;
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  letter-spacing: -0.04em;
}

.result-counts,
.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.result-counts span,
.active-filters span {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.86rem;
  font-weight: 750;
}

.active-filters {
  margin-bottom: 24px;
}

/* Recipe cards */

.recipe-group {
  margin-top: 28px;
}

.recipe-group-header h3 {
  margin: 0;
  font-size: 1.3rem;
}

.recipe-group-header p {
  margin: 6px 0 14px;
  color: var(--muted);
}

.recipe-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.recipe-card {
  border: 1px solid var(--border);
  border-radius: 24px;
  background:
    radial-gradient(circle at top right, rgba(255, 159, 28, 0.1), transparent 16rem),
    radial-gradient(circle at bottom left, rgba(61, 220, 151, 0.08), transparent 14rem),
    linear-gradient(180deg, rgba(255,255,255,0.085), rgba(255,255,255,0.035));
  padding: 18px;
  overflow: hidden;
}

.compact-recipe-card {
  display: flex;
  flex-direction: column;
  min-height: 340px;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.compact-recipe-card:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 159, 28, 0.45);
}

.card-topline {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.time-pill,
.difficulty-pill {
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 0.78rem;
  font-weight: 900;
  color: var(--text);
  background: rgba(255,255,255,0.1);
}

.recipe-card h4 {
  margin: 0 0 14px;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
}

.why-text {
  color: var(--muted);
  line-height: 1.5;
  min-height: 64px;
  margin-bottom: 18px;
}

.compact-card-section {
  margin-top: 14px;
}

.compact-card-section + .compact-card-section {
  margin-top: 16px;
}

.compact-label-row strong {
  display: block;
  margin-bottom: 8px;
  font-size: 0.88rem;
}

.mini-chip-row,
.missing-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.missing-actions {
  margin-bottom: 4px;
}

.mini-chip,
.missing-chip {
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 0.82rem;
  font-weight: 750;
}

.mini-chip {
  color: var(--success);
  background: rgba(61, 220, 151, 0.12);
  border: 1px solid rgba(61, 220, 151, 0.27);
}

.missing-chip {
  color: var(--accent-2);
  background: rgba(255, 159, 28, 0.11);
  border: 1px solid rgba(255, 159, 28, 0.3);
}

.muted-text {
  color: var(--muted-2);
}

.cook-mode-button {
  width: 100%;
  min-height: 44px;
  margin-top: 22px;
  border: 0;
  border-radius: 14px;
  color: #1a1000;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-weight: 950;
  box-shadow: 0 12px 30px rgba(255, 159, 28, 0.14);
}

.cook-mode-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 36px rgba(255, 159, 28, 0.2);
}

/* Cook modal */

.cook-modal {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: grid;
  place-items: center;
  padding: 24px;
}

.cook-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 6, 12, 0.78);
  backdrop-filter: blur(12px);
}

.cook-modal-panel {
  position: relative;
  z-index: 1;
  width: min(880px, 100%);
  max-height: 86vh;
  overflow: auto;
  border: 1px solid var(--border-strong);
  border-radius: 26px;
  background:
    radial-gradient(circle at top left, rgba(255, 159, 28, 0.16), transparent 26rem),
    radial-gradient(circle at top right, rgba(61, 220, 151, 0.12), transparent 24rem),
    linear-gradient(145deg, #161a22, #0d1118);
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.68);
}

.cook-modal-close {
  position: sticky;
  top: 18px;
  float: right;
  z-index: 3;
  width: 42px;
  height: 42px;
  margin: 18px 18px 0 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  background: rgba(0, 0, 0, 0.38);
  font-size: 1.5rem;
  line-height: 1;
}

.cook-modal-hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 28px 18px;
  border-bottom: 1px solid var(--border);
}

.cook-modal-hero h2 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.3rem);
  line-height: 0.98;
  letter-spacing: -0.065em;
}

.cook-modal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.cook-modal-meta span {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  font-size: 0.78rem;
  font-weight: 800;
}

.cook-readiness {
  align-self: flex-start;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 0.76rem;
  font-weight: 950;
  white-space: nowrap;
}

.cook-readiness.ready {
  color: #07130e;
  background: var(--success);
}

.cook-readiness.almost {
  color: #1a1000;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.cook-modal-body {
  display: grid;
  gap: 12px;
  padding: 18px 28px 26px;
}

.cook-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.cook-summary-card,
.cook-modal-section {
  border: 1px solid var(--border);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.055);
}

.cook-summary-card {
  padding: 14px;
  border-radius: 18px;
}

.cook-summary-card span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted-2);
  font-size: 0.68rem;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.cook-summary-card strong {
  display: block;
  color: var(--text);
  font-size: 0.96rem;
}

.cook-summary-card p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.cook-modal-section {
  padding: 16px;
}

.cook-section-title {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
}

.cook-section-title > span {
  min-width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  border-radius: 12px;
  color: #1a1000;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-size: 0.9rem;
  font-weight: 950;
}

.cook-section-title p {
  margin: 0 0 2px;
  color: var(--accent-2);
  font-size: 0.66rem;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.cook-section-title h3 {
  margin: 0;
  font-size: 1.12rem;
  letter-spacing: -0.04em;
}

.cook-ingredient-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.cook-ingredient-grid span {
  display: inline-flex;
  align-items: center;
  min-height: 31px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
  font-size: 0.78rem;
  font-weight: 760;
}

.cook-two-column {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.cook-two-column strong {
  display: block;
  margin-bottom: 10px;
}

.cook-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.shopping-callout {
  background:
    radial-gradient(circle at top right, rgba(239, 71, 111, 0.16), transparent 16rem),
    rgba(255, 255, 255, 0.055);
}

.shopping-list-premium {
  display: grid;
  gap: 8px;
}

.shopping-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid rgba(255, 159, 28, 0.24);
  border-radius: 14px;
  padding: 10px 12px;
  background: rgba(255, 159, 28, 0.09);
}

.shopping-item span,
.shopping-item small {
  font-size: 0.86rem;
}

.shopping-item span {
  color: var(--accent-2);
  font-weight: 850;
}

.shopping-item small {
  color: var(--muted);
  font-weight: 850;
}

.method-callout {
  background:
    radial-gradient(circle at top right, rgba(61, 220, 151, 0.12), transparent 16rem),
    rgba(255, 255, 255, 0.055);
}

.cook-method-list {
  display: grid;
  gap: 8px;
}

.cook-method-step {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 10px;
  align-items: flex-start;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.22);
}

.cook-method-step span {
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  border-radius: 10px;
  color: var(--success);
  background: rgba(61, 220, 151, 0.13);
  font-size: 0.72rem;
  font-weight: 950;
}

.cook-method-step p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.42;
}

/* Compact direct dish lookup */

.dish-cook-view {
  border: 1px solid var(--border-strong);
  border-radius: 32px;
  overflow: hidden;
  background:
    radial-gradient(circle at top left, rgba(255, 159, 28, 0.16), transparent 26rem),
    radial-gradient(circle at top right, rgba(61, 220, 151, 0.12), transparent 24rem),
    linear-gradient(145deg, #161a22, #0d1118);
  box-shadow: var(--shadow);
}

.compact-dish-view {
  max-width: 900px;
  margin: 0 auto;
  border-radius: 26px;
}

.dish-cook-hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 28px 18px;
  border-bottom: 1px solid var(--border);
}

.compact-dish-hero {
  padding: 22px 26px 16px;
}

.dish-cook-hero h2 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 0.96;
  letter-spacing: -0.065em;
}

.dish-cook-body {
  display: grid;
  gap: 12px;
  padding: 18px 28px 26px;
}

.compact-dish-body {
  gap: 12px;
  padding: 16px 26px 24px;
}

.compact-section {
  padding: 14px;
  border-radius: 18px;
}

.compact-ingredient-grid {
  gap: 7px;
}

.compact-ingredient-grid span {
  min-height: 30px;
  padding: 6px 10px;
  font-size: 0.78rem;
}

.compact-method-list {
  gap: 7px;
}

.compact-method-step {
  grid-template-columns: 36px 1fr;
  gap: 9px;
  padding: 9px 11px;
  border-radius: 13px;
}

.compact-method-step span {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  font-size: 0.7rem;
}

.compact-method-step p {
  font-size: 0.86rem;
  line-height: 1.38;
}

/* Collapsed secondary dish sections */

.dish-accordion {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.045);
  overflow: hidden;
}

.dish-accordion summary {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  list-style: none;
  padding: 13px 15px;
  color: var(--accent-2);
  font-weight: 950;
}

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

.dish-accordion summary::before {
  content: "▸";
  transition: transform 160ms ease;
}

.dish-accordion[open] summary::before {
  transform: rotate(90deg);
}

.dish-logic-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.compact-logic-grid {
  padding: 0 14px 14px;
  gap: 10px;
}

.dish-logic-grid > div {
  border: 1px solid var(--border);
  border-radius: 15px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.16);
}

.compact-logic-grid > div {
  padding: 10px;
  border-radius: 13px;
}

.dish-logic-grid strong {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 0.86rem;
}

.dish-notes-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.compact-notes-grid {
  padding: 0 14px 14px;
  gap: 10px;
}

.dish-note-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.18);
}

.dish-note-card strong {
  display: block;
  margin-bottom: 7px;
  color: var(--text);
  font-size: 0.9rem;
}

.dish-note-card ul {
  margin: 0;
  padding-left: 17px;
  color: var(--muted);
}

.dish-note-card li {
  margin: 5px 0;
  font-size: 0.82rem;
  line-height: 1.36;
}

/* Empty state */

.empty-state {
  padding: 24px;
  color: var(--muted);
}

.empty-state h2,
.empty-state h3 {
  color: var(--text);
  margin-top: 0;
}

/* Responsive */

@media (max-width: 900px) {
  .dish-cook-hero {
    flex-direction: column;
    padding: 22px 20px 16px;
  }

  .dish-cook-body {
    padding: 16px 20px 22px;
  }

  .compact-dish-view {
    max-width: 100%;
  }

  .dish-logic-grid,
  .dish-notes-grid,
  .compact-notes-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .form-row,
  .recipe-grid,
  .cook-summary-grid,
  .cook-two-column {
    grid-template-columns: 1fr;
  }

  .results-header,
  .cook-modal-hero {
    flex-direction: column;
  }

  .app {
    width: min(100% - 20px, 1180px);
    padding: 24px 0;
  }

  .form-card,
  .results-shell {
    border-radius: 22px;
    padding: 18px;
  }

  .hero h1 {
    letter-spacing: -0.05em;
  }

  .cook-modal {
    padding: 10px;
  }

  .cook-modal-panel {
    max-height: 92vh;
    border-radius: 24px;
  }

  .cook-modal-hero,
  .cook-modal-body {
    padding-left: 20px;
    padding-right: 20px;
  }

  .cook-method-step {
    grid-template-columns: 40px 1fr;
  }
}

/* Missing ingredient actions */

.missing-chip-actionable {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}

.missing-chip-actionable::after {
  content: "＋";
  font-size: 0.72rem;
  opacity: 0.85;
}

.missing-chip-actionable:hover,
.missing-chip-actionable.is-open {
  border-color: rgba(255, 191, 105, 0.65);
  background: rgba(255, 159, 28, 0.18);
}

.missing-chip-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 80;
  display: flex;
  gap: 7px;
  min-width: 230px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 16px;
  background: #11131b;
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.missing-chip-actionable.is-open .missing-chip-menu {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.missing-action-btn {
  border: 0;
  border-radius: 999px;
  padding: 8px 11px;
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.have-btn {
  color: #07130e;
  background: var(--success);
}

.blinkit-btn {
  color: #1a1000;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.have-btn:hover,
.blinkit-btn:hover {
  transform: translateY(-1px);
}

@media (max-width: 820px) {
  .missing-chip-menu {
    left: auto;
    right: 0;
    min-width: 220px;
    flex-direction: column;
  }

  .missing-action-btn {
    width: 100%;
  }
}