/* ============================================================
   food-assist — "Marktplatz" design system v2
   Warm editorial × functional kitchen tool
   ============================================================ */

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

/* --- Design tokens ----------------------------------------- */
:root {
  --cream:         #F7F3EA;
  --cream-dark:    #EDE8DC;
  --cream-deeper:  #E3DCCC;
  --forest:        #2C3E2D;
  --forest-light:  #3D5540;
  --forest-muted:  #4E6B52;
  --rust:          #C4512A;
  --rust-light:    #D96B3F;
  --amber:         #D4841A;
  --amber-light:   #E8A84A;
  --warm-black:    #1A1510;
  --warm-text:     #2E2820;
  --muted:         #7A7062;
  --border:        #D4CEBC;
  --border-dark:   #B8B0A0;
  --shadow-card:   0 2px 12px rgba(44,62,45,0.08), 0 1px 3px rgba(44,62,45,0.05);
  --shadow-lift:   0 6px 20px rgba(44,62,45,0.12), 0 2px 6px rgba(44,62,45,0.08);
  --radius:        3px;
  --radius-lg:     6px;
  --font-display:  'EB Garamond', Georgia, serif;
  --font-body:     'DM Sans', system-ui, sans-serif;
}

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

/* --- Grain texture overlay ---------------------------------- */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  opacity: 0.022;
  pointer-events: none;
  z-index: 9998;
}

/* --- Base --------------------------------------------------- */
html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--warm-text);
  background-color: var(--cream);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ============================================================
   NAVIGATION
   ============================================================ */
nav {
  background-color: var(--forest);
  display: flex;
  align-items: stretch;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 2px solid var(--amber);
  flex-shrink: 0;
}

.nav-brand {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--cream);
  text-decoration: none;
  border-bottom: none;
  padding: 0.85rem 1.5rem;
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  border-right: 1px solid rgba(247,243,234,0.12);
  white-space: nowrap;
  flex-shrink: 0;
  transition: color 0.15s;
}

.nav-brand::before {
  content: '◆';
  color: var(--amber);
  font-size: 0.65em;
}

.nav-brand:hover { color: var(--cream); border-bottom: none; }

.nav-links {
  display: flex;
  align-items: stretch;
  overflow-x: auto;
}

.nav-links a {
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: rgba(247,243,234,0.7);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  margin-bottom: -2px;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.nav-links a:hover {
  color: var(--cream);
  background: rgba(247,243,234,0.05);
  border-bottom-color: var(--amber);
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
main {
  flex: 1;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 5rem;
  animation: fade-up 0.28s ease both;
}

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

/* ============================================================
   TYPOGRAPHY
   ============================================================ */
h1 {
  font-family: var(--font-display);
  font-size: 2.4rem;
  font-weight: 600;
  line-height: 1.12;
  color: var(--forest);
  margin-bottom: 0.35rem;
  letter-spacing: -0.01em;
}

h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 500;
  line-height: 1.25;
  color: var(--forest);
  margin-top: 1.75rem;
  margin-bottom: 0.65rem;
}

h3 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 500;
  color: var(--warm-black);
  margin-top: 0.75rem;
  margin-bottom: 0.35rem;
}

p { margin-bottom: 0.8rem; line-height: 1.7; }

small { font-size: 0.82rem; color: var(--muted); line-height: 1.5; }

a {
  color: var(--rust);
  text-decoration: none;
  border-bottom: 1px solid rgba(196,81,42,0.25);
  transition: color 0.12s, border-color 0.12s;
}

a:hover { color: var(--rust-light); border-bottom-color: var(--rust-light); }

ul, ol { padding-left: 1.4em; }
li { margin-bottom: 0.2rem; }

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
  margin-bottom: 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-end;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.page-header h1 { margin-bottom: 0; flex: 1; min-width: 200px; }

.page-subtitle {
  color: var(--muted);
  font-size: 0.95rem;
  margin-bottom: 0;
  margin-top: 0.2rem;
}

/* Stand-alone back link */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted);
  border-bottom: none;
  margin-bottom: 0.75rem;
  letter-spacing: 0.01em;
  transition: color 0.12s;
}

.back-link:hover { color: var(--forest); border-bottom: none; }

/* ============================================================
   BUTTONS
   ============================================================ */
button, .btn-primary, .btn-secondary {
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 0.55rem 1.2rem;
  border-radius: var(--radius);
  border: 1.5px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: background 0.15s, border-color 0.15s, color 0.15s,
              transform 0.1s, box-shadow 0.15s;
  text-decoration: none;
  border-bottom: none;
}

/* Default button → primary style */
button, .btn-primary {
  background: var(--rust);
  color: #fff;
  box-shadow: 0 1px 4px rgba(196,81,42,0.28);
}

button:hover, .btn-primary:hover {
  background: var(--rust-light);
  box-shadow: 0 3px 10px rgba(196,81,42,0.35);
  transform: translateY(-1px);
  border-bottom: none;
}

button:active, .btn-primary:active {
  transform: translateY(0);
  box-shadow: none;
}

.btn-secondary {
  background: transparent;
  border-color: var(--border-dark);
  color: var(--warm-text);
  box-shadow: none;
}

.btn-secondary:hover {
  background: var(--cream-dark);
  border-color: var(--forest-muted);
  color: var(--forest);
  box-shadow: none;
  transform: none;
}

.btn-large {
  font-size: 1rem;
  padding: 0.75rem 1.75rem;
}

/* Link-style buttons */
.btn-link {
  display: inline-flex;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--rust);
  border-bottom: 1px solid rgba(196,81,42,0.25);
  text-decoration: none;
  padding: 0;
  background: none;
  box-shadow: none;
  border-radius: 0;
  transition: color 0.12s, border-color 0.12s;
}

.btn-link:hover {
  color: var(--rust-light);
  border-bottom-color: var(--rust-light);
  transform: none;
  box-shadow: none;
  background: none;
}

.btn-link--primary {
  color: var(--forest);
  border-bottom-color: rgba(44,62,45,0.3);
  font-weight: 600;
}

.btn-link--primary:hover {
  color: var(--forest-light);
  border-bottom-color: var(--forest-light);
}

.btn-link--accent {
  color: var(--amber);
  border-bottom-color: rgba(212,132,26,0.3);
}

.btn-link--accent:hover {
  color: var(--amber-light);
  border-bottom-color: var(--amber-light);
}

/* Google sign-in button */
.btn-google {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  background: #fff;
  border: 1.5px solid var(--border-dark);
  border-radius: var(--radius);
  border-bottom: 1.5px solid var(--border-dark);
  padding: 0.7rem 1.4rem;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--warm-text);
  text-decoration: none;
  box-shadow: 0 1px 4px rgba(44,62,45,0.1);
  transition: box-shadow 0.15s, border-color 0.15s, transform 0.1s;
}

.btn-google:hover {
  box-shadow: var(--shadow-lift);
  border-color: var(--forest-muted);
  border-bottom-color: var(--forest-muted);
  color: var(--forest);
  transform: translateY(-1px);
}

/* ============================================================
   FORMS
   ============================================================ */
form { margin: 0; }

.form-stacked { display: flex; flex-direction: column; gap: 0; }

/* Django as_p output: <p><label>...</label><input></p> */
.form-stacked p,
form p:has(label),
form p:has(input),
form p:has(select) {
  margin-bottom: 0;
}

/* Labels (standalone and inside as_p) */
label,
.form-stacked p > label {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  display: block;
  margin-top: 1.1rem;
  margin-bottom: 0.35rem;
}

.label-optional {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.78rem;
  color: var(--muted);
  opacity: 0.75;
}

/* All text-like inputs */
input[type=text],
input[type=password],
input[type=number],
input[type=email],
select,
textarea {
  width: 100%;
  max-width: 440px;
  padding: 0.6rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--warm-text);
  background: #fff;
  display: block;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
  margin-top: 0.35rem;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--forest);
  box-shadow: 0 0 0 3px rgba(44,62,45,0.1);
}

.form-section {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.75rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-card);
}

.form-section h2 {
  margin-top: 0;
  font-size: 1rem;
  font-family: var(--font-body);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  border-bottom: 1px solid var(--cream-dark);
  padding-bottom: 0.6rem;
  margin-bottom: 0.5rem;
}

.form-hint {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.form-error {
  background: #FEF2F2;
  border: 1px solid #FECACA;
  color: #B91C1C;
  border-radius: var(--radius);
  padding: 0.55rem 0.85rem;
  font-size: 0.88rem;
  font-weight: 500;
  margin-bottom: 1rem;
}

.form-actions {
  margin-top: 1.5rem;
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

/* Helptext Django adds after inputs */
.helptext, span.helptext {
  font-size: 0.8rem;
  color: var(--muted);
  display: block;
  margin-top: 0.3rem;
}

/* Error list Django adds */
ul.errorlist {
  list-style: none;
  padding: 0;
  margin: 0.3rem 0 0;
}
ul.errorlist li {
  font-size: 0.82rem;
  color: #B91C1C;
  margin-bottom: 0;
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.page-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cream);
}

.page-login main {
  max-width: 460px;
  padding: 2rem 1.5rem;
  animation: fade-up 0.35s ease both;
}

.login-card {
  text-align: center;
}

.login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.login-diamond {
  color: var(--amber);
  font-size: 1.4rem;
  line-height: 1;
}

.login-brand h1 {
  font-size: clamp(2rem, 6vw, 3rem);
  margin-bottom: 0;
  letter-spacing: -0.02em;
}

.login-tagline {
  font-size: 1.05rem;
  color: var(--muted);
  margin-bottom: 2.5rem;
}

/* ============================================================
   DASHBOARD — PLAN LIST
   ============================================================ */
.plan-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.plan-item {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.5rem;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
  box-shadow: var(--shadow-card);
  transition: box-shadow 0.15s, border-color 0.15s;
}

.plan-item:hover {
  box-shadow: var(--shadow-lift);
  border-color: var(--border-dark);
}

.plan-item__info {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex: 1;
  min-width: 180px;
}

.plan-item__week {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--warm-black);
}

.plan-item__status {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.2rem 0.55rem;
  border-radius: 20px;
}

.status--finalized { background: rgba(44,62,45,0.1); color: var(--forest); }
.status--options_ready { background: rgba(212,132,26,0.15); color: var(--amber); }
.status--generating { background: rgba(212,132,26,0.1); color: var(--amber); }
.status--error { background: #FEF2F2; color: #B91C1C; }
.status--pending { background: var(--cream-dark); color: var(--muted); }

.plan-item__actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.plan-item__generating {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.plan-item--empty {
  color: var(--muted);
  font-size: 0.95rem;
  justify-content: center;
  background: var(--cream-dark);
  border-style: dashed;
}

.plan-item--empty p { margin: 0; }

/* Status error in plan list */
.status-error {
  font-size: 0.85rem;
  color: #B91C1C;
  font-weight: 500;
}

/* ============================================================
   MEAL PLAN OPTIONS / SLOTS
   ============================================================ */
.slot-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-card);
}

.slot-label {
  font-size: 0.75rem;
  font-family: var(--font-body);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--cream-dark);
  padding-bottom: 0.6rem;
  margin-top: 0;
  margin-bottom: 0.9rem;
}

.slot-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.slot-option {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.option-btn {
  background: var(--cream);
  color: var(--warm-text);
  border: 1.5px solid var(--border);
  box-shadow: none;
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.88rem;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.option-btn:hover {
  background: var(--cream-dark);
  border-color: var(--forest-muted);
  color: var(--forest);
  transform: none;
  box-shadow: none;
}

.option-btn--selected {
  background: var(--forest);
  border-color: var(--forest);
  color: var(--cream);
  box-shadow: none;
}

.option-btn--selected:hover {
  background: var(--forest-light);
  border-color: var(--forest-light);
  color: var(--cream);
}

.option-name { font-weight: 500; }

.option-kcal {
  font-size: 0.78rem;
  opacity: 0.65;
  font-weight: 400;
}

.option-check {
  color: var(--amber-light);
  font-size: 0.85em;
  margin-left: 0.1rem;
}

.recipe-details {
  margin-top: 0.25rem;
  border: none;
  background: none;
  padding: 0;
}

.recipe-details summary {
  font-size: 0.78rem;
  color: var(--forest-muted);
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  transition: color 0.12s;
}

.recipe-details summary::before {
  content: '▸';
  font-size: 0.65em;
  color: var(--amber);
  transition: transform 0.15s;
}

.recipe-details[open] summary::before { transform: rotate(90deg); }
.recipe-details summary:hover { color: var(--forest); }

.recipe-body {
  padding: 0.75rem;
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 0.35rem;
  font-size: 0.88rem;
}

.recipe-body p { margin-bottom: 0.5rem; }

.ingredient-list {
  padding-left: 1.2em;
  margin: 0;
}
.ingredient-list li { margin-bottom: 0.15rem; font-size: 0.85rem; }

/* Finalize bar */
.finalize-bar {
  position: sticky;
  bottom: 1.5rem;
  text-align: right;
  padding: 1rem 0;
  margin-top: 1.5rem;
}

.finalize-bar form { display: inline; }

/* ============================================================
   MEAL PLAN DETAIL
   ============================================================ */
article {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-card);
  transition: box-shadow 0.15s;
}

article:hover { box-shadow: var(--shadow-lift); }

article h2 {
  font-size: 0.75rem;
  font-family: var(--font-body);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 0;
  margin-bottom: 0.9rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--cream-dark);
}

article h3 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--forest);
  margin-top: 0;
}

article ul { margin-top: 0.5rem; font-size: 0.9rem; }

/* ============================================================
   SHOPPING LIST
   ============================================================ */
.table-wrapper {
  overflow-x: auto;
  margin: 0 -0.5rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

thead tr { background: var(--forest); }

th {
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 0.85rem 1rem;
  text-align: left;
  color: rgba(247,243,234,0.88);
  border: none;
}

td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--cream-dark);
  vertical-align: top;
  color: var(--warm-text);
  line-height: 1.4;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:nth-child(even) { background: var(--cream); }
tbody tr:hover { background: var(--cream-dark); transition: background 0.1s; }

tfoot tr { background: var(--cream-deeper); }
tfoot td {
  font-weight: 700;
  font-size: 0.92rem;
  border-top: 2px solid var(--border);
  border-bottom: none;
  padding: 0.85rem 1rem;
}

.ingredient-name { font-weight: 500; }
.amount-cell { white-space: nowrap; color: var(--muted); font-size: 0.88rem; }
.product-name { display: block; font-weight: 500; font-size: 0.88rem; }
.product-detail { display: block; font-size: 0.78rem; color: var(--muted); }
.product-total { display: block; color: var(--forest); font-size: 0.92rem; }
.no-price { color: var(--muted); }

/* Best combo box */
.best-combo-box {
  background: var(--forest);
  color: var(--cream);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.75rem;
  margin-top: 2rem;
  box-shadow: var(--shadow-lift);
}

.best-combo-header {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(247,243,234,0.15);
}

.best-combo-label {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(247,243,234,0.6);
}

.best-combo-price {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 600;
  color: var(--amber-light);
  letter-spacing: -0.02em;
}

.best-combo-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.best-combo-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  margin-bottom: 0;
}

.combo-ingredient { color: rgba(247,243,234,0.88); flex: 1; }
.combo-arrow { color: var(--amber); opacity: 0.6; font-size: 0.85em; }
.combo-market { color: var(--amber-light); font-weight: 500; }

/* ============================================================
   CHAT / PREFERENCE PAGE
   ============================================================ */
.prefs-summary {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.prefs-chip-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.prefs-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  min-width: 110px;
}

.pref-chip {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  background: rgba(44,62,45,0.09);
  color: var(--forest);
  border: 1px solid rgba(44,62,45,0.15);
}

.pref-chip--intolerance {
  background: rgba(196,81,42,0.08);
  color: var(--rust);
  border-color: rgba(196,81,42,0.2);
}

.pref-chip--cuisine {
  background: rgba(212,132,26,0.1);
  color: var(--amber);
  border-color: rgba(212,132,26,0.2);
}

.pref-empty { font-size: 0.85rem; color: var(--muted); font-style: italic; }

/* Chat messages container */
#chat-messages {
  background: var(--cream-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  max-height: 420px;
  overflow-y: auto;
  margin-bottom: 0.75rem;
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.message--user,
.message--assistant {
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-lg);
  font-size: 0.92rem;
  line-height: 1.55;
}

.message--user {
  background: var(--forest);
  color: var(--cream);
  margin-left: 2.5rem;
  align-self: flex-end;
  border-bottom-right-radius: var(--radius);
}

.message--assistant {
  background: #fff;
  color: var(--warm-text);
  margin-right: 2.5rem;
  align-self: flex-start;
  box-shadow: 0 1px 4px rgba(44,62,45,0.07);
  border-bottom-left-radius: var(--radius);
}

.message--user strong,
.message--assistant strong {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.6;
  display: block;
  margin-bottom: 0.2rem;
}

/* Chat form */
.chat-form {
  display: flex;
  gap: 0;
  align-items: stretch;
}

.chat-form input[type=text] {
  flex: 1;
  max-width: none;
  border-radius: var(--radius) 0 0 var(--radius);
  border-right: none;
  margin-top: 0;
}

.chat-form button {
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 0.6rem 1.1rem;
  white-space: nowrap;
}

/* ============================================================
   ONBOARDING
   ============================================================ */
.onboarding-layout {
  max-width: 520px;
}

.onboarding-progress {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 2rem;
}

.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}

.step span {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 700;
  transition: background 0.2s;
}

.step small {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.step--done span {
  background: var(--forest);
  color: var(--cream);
}
.step--done small { color: var(--forest); }

.step--complete span {
  background: var(--amber);
  color: #fff;
}
.step--complete small { color: var(--amber); }

.step--inactive span {
  background: var(--cream-deeper);
  color: var(--muted);
}
.step--inactive small { color: var(--muted); }

.step-line {
  flex: 1;
  height: 2px;
  background: var(--cream-deeper);
  margin: 0 0.5rem;
  margin-bottom: 1.35rem;
}

.step-line--done { background: var(--amber); }

/* ============================================================
   GENERATING PAGE
   ============================================================ */
@keyframes spin-ring {
  to { transform: rotate(360deg); }
}

@keyframes pulse-dot {
  0%, 80%, 100% { transform: scale(0.5); opacity: 0.35; }
  40% { transform: scale(1); opacity: 1; }
}

.spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--cream-deeper);
  border-top-color: var(--forest);
  border-radius: 50%;
  animation: spin-ring 0.85s linear infinite;
  margin: 2rem 0 1.25rem;
}

.loading-dots {
  display: inline-flex;
  gap: 6px;
  margin-top: 1rem;
}

.loading-dots span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--amber);
  animation: pulse-dot 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

/* Inline dot animation (used in plan list) */
.dot-anim {
  display: inline-flex;
  gap: 3px;
  align-items: center;
}

.dot-anim span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--amber);
  animation: pulse-dot 1.4s ease-in-out infinite;
}

.dot-anim span:nth-child(2) { animation-delay: 0.2s; }
.dot-anim span:nth-child(3) { animation-delay: 0.4s; }

/* ============================================================
   GENERATING PAGE — DAY CHECKLIST
   ============================================================ */
.day-checklist {
  list-style: none;
  padding: 0;
  margin: 1.75rem 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  max-width: 320px;
}

.day-check {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.65rem 1rem;
  background: var(--cream-dark);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  color: var(--muted);
}

@media (prefers-reduced-motion: no-preference) {
  .day-check {
    transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease;
  }
}

.day-check::before {
  content: '○';
  font-size: 1rem;
  width: 1.1rem;
  text-align: center;
  color: var(--border-dark);
  flex-shrink: 0;
  transition: color 0.2s ease;
}

.day-check--done {
  background: rgba(212, 132, 26, 0.08);
  color: var(--warm-text);
  border-color: var(--amber);
}

.day-check--done::before {
  content: '✓';
  color: var(--amber);
  font-weight: 700;
}

.generating-status {
  font-size: 0.88rem;
  color: var(--warm-text);
  opacity: 0.7;
  margin-top: 0.25rem;
}

.generating-status--error {
  color: #B91C1C;
  font-weight: 500;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 640px) {
  main { padding: 1.5rem 1rem 3rem; }

  h1 { font-size: 1.85rem; }
  h2 { font-size: 1.25rem; }

  .page-header { flex-direction: column; align-items: flex-start; gap: 0.75rem; }

  nav { flex-wrap: wrap; }
  .nav-links { flex-wrap: wrap; }
  .nav-links a { padding: 0.5rem 0.65rem; font-size: 0.7rem; }

  table { font-size: 0.8rem; }
  th, td { padding: 0.55rem 0.65rem; }

  .slot-options { flex-direction: column; }
  .option-btn { white-space: normal; }

  .finalize-bar { position: static; text-align: left; }

  .message--user { margin-left: 0.5rem; }
  .message--assistant { margin-right: 0.5rem; }

  .best-combo-header { flex-direction: column; gap: 0.25rem; }
  .best-combo-price { font-size: 1.5rem; }

  .onboarding-progress { gap: 0; }
  .step small { display: none; }

  .chat-form { flex-direction: column; }
  .chat-form input[type=text] { border-radius: var(--radius); border-right: 1.5px solid var(--border); max-width: 100%; }
  .chat-form button { border-radius: var(--radius); margin-top: 0.5rem; }

  .prefs-label { min-width: auto; }
}

/* --- WIP Banner -------------------------------------------- */
.wip-banner {
  background: var(--amber);
  color: var(--warm-black);
  padding: 0.55rem 1.25rem;
  font-size: 0.875rem;
  position: relative;
  z-index: 100;
}

.wip-banner__inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.wip-banner__text {
  flex: 1;
  min-width: 200px;
  font-family: var(--font-body);
  font-weight: 500;
}

.wip-banner__form form {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.wip-banner__input {
  border: 1.5px solid var(--warm-black);
  border-radius: var(--radius);
  padding: 0.3rem 0.65rem;
  font-size: 0.8125rem;
  font-family: var(--font-body);
  background: rgba(255, 255, 255, 0.45);
  width: 220px;
}

.wip-banner__input:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.7);
}

.wip-banner__btn {
  background: var(--warm-black);
  color: var(--cream);
  border: none;
  border-radius: var(--radius);
  padding: 0.3rem 0.85rem;
  font-size: 0.8125rem;
  font-family: var(--font-body);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.wip-banner__btn:hover {
  background: var(--forest);
}

.wip-banner__success {
  font-weight: 600;
  font-family: var(--font-body);
}

.wip-banner__close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  opacity: 0.55;
  padding: 0.15rem 0.3rem;
  line-height: 1;
  flex-shrink: 0;
}

.wip-banner__close:hover {
  opacity: 1;
}

/* ============================================================
   PREFERENCE TABS
   ============================================================ */
.pref-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.5rem;
}

.pref-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  padding: 0.6rem 1.2rem;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.pref-tab:hover {
  color: var(--forest);
}

.pref-tab--active {
  color: var(--forest);
  border-bottom-color: var(--rust);
  font-weight: 600;
}

/* ============================================================
   INGREDIENT PICKER
   ============================================================ */
.picker-filter {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  padding: 0.75rem 1rem;
  background: var(--cream-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.picker-filter-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  white-space: nowrap;
}

.picker-select {
  font-family: var(--font-body);
  font-size: 0.9rem;
  padding: 0.35rem 0.6rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: white;
  color: var(--warm-text);
  cursor: pointer;
}

.picker-select:focus {
  outline: none;
  border-color: var(--forest);
  box-shadow: 0 0 0 3px rgba(44,62,45,0.12);
}

.ingredient-category {
  margin-bottom: 1.5rem;
}

.ingredient-category-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--forest);
  padding-bottom: 0.4rem;
  border-bottom: 1.5px solid var(--border);
  margin-bottom: 0.75rem;
}

.ingredient-subgroup {
  margin-bottom: 1rem;
}

.ingredient-subgroup-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.ingredient-row-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.ingredient-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius);
  transition: background 0.1s;
}

.ingredient-row:hover {
  background: var(--cream-dark);
}

.ingredient-row-name {
  font-size: 0.9rem;
  color: var(--warm-text);
  flex: 1;
}

.ingredient-row-actions {
  display: flex;
  gap: 0.2rem;
}

.ingredient-row-actions form {
  display: inline;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.8rem;
  height: 1.8rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: white;
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.icon-btn:hover {
  border-color: var(--forest-muted);
  color: var(--forest);
}

.icon-btn--active {
  border-color: transparent;
  font-weight: 700;
}

.icon-btn--liked.icon-btn--active {
  background: rgba(196,81,42,0.12);
  color: var(--rust);
  border-color: rgba(196,81,42,0.3);
}

.icon-btn--excluded.icon-btn--active {
  background: rgba(44,62,45,0.1);
  color: var(--forest);
  border-color: rgba(44,62,45,0.25);
}

.icon-btn--intolerance.icon-btn--active {
  background: rgba(212,132,26,0.12);
  color: var(--amber);
  border-color: rgba(212,132,26,0.3);
}

@media (max-width: 640px) {
  .picker-filter { flex-direction: column; align-items: flex-start; }
  .picker-select { width: 100%; }
  .ingredient-row-name { font-size: 0.85rem; }
}
