:root {
  --bg: #f6f4ef;
  --shell: #fffdf9;
  --panel: rgba(255, 255, 255, 0.86);
  --ink: #1f2937;
  --muted: #6b7280;
  --primary: #e76f51;
  --primary-dark: #d95d3a;
  --accent: #2a9d8f;
  --shadow: rgba(17, 24, 39, 0.1);
  --border: rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Inter', sans-serif;
  background: linear-gradient(135deg, #fef7ed, #edf6f5);
  color: var(--ink);
}

.page-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 20px 60px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  color: var(--accent);
  font-weight: 700;
}

h1 {
  margin: 8px 0 0;
  font-size: clamp(2rem, 4vw, 3.25rem);
}

.status-pill {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(42, 157, 143, 0.12);
  color: var(--accent);
  font-weight: 700;
  border: 1px solid rgba(42, 157, 143, 0.18);
}

.layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 24px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: 0 18px 45px var(--shadow);
  backdrop-filter: blur(12px);
  padding: 24px;
}

.form-panel h2,
.output-panel h2 {
  margin-top: 0;
  font-size: 1.45rem;
}

form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--ink);
  font-weight: 600;
  font-size: 0.98rem;
}

textarea,
select,
button {
  font: inherit;
}

textarea,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.74);
  padding: 12px 14px;
  color: var(--ink);
}

textarea:focus,
select:focus {
  outline: 2px solid rgba(231, 111, 81, 0.2);
  border-color: rgba(231, 111, 81, 0.45);
}

.row {
  display: grid;
  gap: 18px;
}

.two-up {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

button {
  border: none;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border-radius: 14px;
  padding: 14px 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 10px 24px rgba(231, 111, 81, 0.25);
}

button:hover {
  transform: translateY(-1px);
}

.secondary-button {
  background: rgba(15, 23, 42, 0.05);
  color: var(--ink);
  border: 1px solid var(--border);
  box-shadow: none;
}

.health-conditions {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  margin: 18px 0 0;
  background: rgba(42, 157, 143, 0.04);
}

.health-conditions legend {
  font-weight: 700;
  color: var(--ink);
  padding: 0 8px;
  margin: -8px 0 12px;
}

.health-conditions label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-weight: 500;
  font-size: 0.95rem;
  flex-direction: row;
}

.health-conditions input[type="checkbox"] {
  width: auto;
  margin: 0;
  cursor: pointer;
}

#loading {
  margin-bottom: 16px;
  color: var(--muted);
  font-weight: 600;
}

.hidden {
  display: none;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}

.recipe-card {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,0.82), rgba(249,250,251,0.9));
  padding: 18px;
}

.recipe-card header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: start;
  margin-bottom: 10px;
}

.recipe-card h3 {
  margin: 0;
  font-size: 1.2rem;
}

.match-badge {
  background: rgba(42, 157, 143, 0.12);
  color: var(--accent);
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 6px 8px;
}

.recipe-card p {
  margin: 8px 0;
  color: var(--muted);
  line-height: 1.6;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 10px;
}

.meta span,
.tag {
  display: inline-block;
  padding: 6px 10px;
  background: rgba(15, 23, 42, 0.04);
  border-radius: 999px;
  font-size: 0.76rem;
  color: var(--ink);
  margin: 4px 6px 4px 0;
}

.recipe-card ol {
  padding-left: 18px;
  margin: 14px 0 0;
  color: var(--ink);
  line-height: 1.65;
}

.recipe-card li + li {
  margin-top: 6px;
}

.catalog-panel {
  margin-top: 28px;
  border-top: 1px solid var(--border);
  padding-top: 20px;
}

.catalog-panel h3 {
  margin-top: 0;
}

.catalog-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.catalog-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: rgba(255,255,255,0.55);
}

.catalog-item strong {
  display: block;
  margin-bottom: 6px;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 14px;
  padding: 26px;
  background: rgba(255,255,255,0.35);
}

.cuisine-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.cuisine-chip {
  background: rgba(15, 23, 42, 0.05);
  color: var(--ink);
  border: 1px solid var(--border);
  box-shadow: none;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
}

.cuisine-chip.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border-color: transparent;
}

.layout + .layout {
  margin-top: 24px;
}

.weekly-plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.day-card {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,0.82), rgba(249,250,251,0.9));
  padding: 16px;
}

.day-card h3 {
  margin: 0 0 12px;
  font-size: 1.05rem;
  color: var(--accent);
}

.meal-slot {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 4px;
  border: none;
  border-top: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  box-shadow: none;
  font: inherit;
  cursor: default;
}

.meal-slot.has-recipe {
  cursor: pointer;
  transition: background 0.15s ease;
}

.meal-slot.has-recipe:hover {
  background: rgba(231, 111, 81, 0.08);
  transform: none;
}

.meal-slot:first-of-type {
  border-top: none;
}

.meal-label {
  display: block;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.68rem;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 4px;
}

.meal-slot strong {
  display: block;
  font-size: 0.92rem;
}

/* ---- User gate ---- */
.user-gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
}

.user-gate.hidden {
  display: none;
}

.user-gate-card {
  background: var(--shell);
  border-radius: 22px;
  padding: 36px;
  max-width: 380px;
  width: 90%;
  box-shadow: 0 30px 60px rgba(17, 24, 39, 0.3);
}

.user-gate-card h2 {
  margin: 8px 0 6px;
}

.user-gate-copy {
  color: var(--muted);
  margin: 0 0 20px;
}

.user-gate-card form {
  gap: 14px;
}

/* ---- Topbar / tabs ---- */
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-greeting {
  font-weight: 700;
  color: var(--ink);
}

.tab-nav {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.tab-button {
  background: transparent;
  box-shadow: none;
  color: var(--muted);
  border: none;
  border-radius: 12px 12px 0 0;
  padding: 12px 20px;
  font-weight: 700;
}

.tab-button.active {
  color: var(--primary-dark);
  background: rgba(231, 111, 81, 0.1);
}

.tab-panel.hidden {
  display: none;
}

/* ---- AI summary banner ---- */
.ai-summary {
  background: rgba(42, 157, 143, 0.08);
  border: 1px solid rgba(42, 157, 143, 0.2);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 18px;
  color: var(--ink);
  font-weight: 500;
  line-height: 1.5;
}

.ai-badge {
  background: rgba(42, 157, 143, 0.15) !important;
  color: var(--accent) !important;
  font-weight: 700;
}

/* ---- Modal ---- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--shell);
  border-radius: 22px;
  padding: 32px;
  max-width: 720px;
  width: 92%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 30px 60px rgba(17, 24, 39, 0.3);
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(15, 23, 42, 0.06);
  color: var(--ink);
  box-shadow: none;
  border-radius: 999px;
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 1.3rem;
  line-height: 1;
}

.modal-body h2 {
  margin: 0 0 8px;
  padding-right: 40px;
}

.modal-description {
  color: var(--muted);
  line-height: 1.6;
}

.modal-tags {
  margin: 12px 0 18px;
}

.condition-tag {
  background: rgba(42, 157, 143, 0.12) !important;
  color: var(--accent) !important;
}

.modal-columns {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 24px;
}

.ingredient-list {
  padding-left: 18px;
  margin: 0;
  line-height: 1.8;
}

.step-list {
  padding-left: 18px;
  margin: 0;
  line-height: 1.8;
}

.step-list li + li {
  margin-top: 8px;
}

.catalog-item {
  cursor: pointer;
  transition: transform 0.15s ease;
}

.catalog-item:hover {
  transform: translateY(-2px);
}

@media (max-width: 820px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .topbar,
  .section-header {
    flex-direction: column;
    align-items: flex-start;
  }

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