:root {
  --bg: #f7f3ea;
  --surface: #fffdf8;
  --surface-2: #f2ede2;
  --ink: #1f2a24;
  --muted: #5f6b63;
  --line: #e4dccb;
  --brand: #1e6b52;
  --brand-strong: #154d3b;
  --brand-ink: #ffffff;
  --brand-soft: #e1efe8;
  --accent: #e3a33b;
  --accent-soft: #fbefd6;
  --danger: #b4442f;
  --danger-soft: #fbe6e1;
  --shadow: 0 1px 2px rgb(31 42 36 / 6%), 0 8px 24px rgb(31 42 36 / 6%);

  --meal-breakfast: #fbefd6;
  --meal-lunch: #e1efe8;
  --meal-snack: #f6e3ec;
  --meal-dinner: #e4e6f6;
  --meal-pleasure: #fde2da;

  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Fraunces", Georgia, serif;
  --radius: 16px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121815;
    --surface: #1a221e;
    --surface-2: #212b26;
    --ink: #ecefe9;
    --muted: #a5b1a9;
    --line: #2e3a33;
    --brand: #5cc49b;
    --brand-strong: #7dd6b1;
    --brand-ink: #0e1a14;
    --brand-soft: #1c3329;
    --accent: #f0b65a;
    --accent-soft: #3a2f1a;
    --danger: #f08a73;
    --danger-soft: #3b211b;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 8px 24px rgb(0 0 0 / 25%);
    --meal-breakfast: #3a2f1a;
    --meal-lunch: #1c3329;
    --meal-snack: #3a2130;
    --meal-dinner: #23263d;
    --meal-pleasure: #3d2620;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #121815;
  --surface: #1a221e;
  --surface-2: #212b26;
  --ink: #ecefe9;
  --muted: #a5b1a9;
  --line: #2e3a33;
  --brand: #5cc49b;
  --brand-strong: #7dd6b1;
  --brand-ink: #0e1a14;
  --brand-soft: #1c3329;
  --accent: #f0b65a;
  --accent-soft: #3a2f1a;
  --danger: #f08a73;
  --danger-soft: #3b211b;
  --meal-breakfast: #3a2f1a;
  --meal-lunch: #1c3329;
  --meal-snack: #3a2130;
  --meal-dinner: #23263d;
  --meal-pleasure: #3d2620;
  color-scheme: dark;
}

/* Script-specific fonts */
:root:lang(ar) { --font-body: "Tajawal", system-ui, sans-serif; --font-display: "Tajawal", system-ui, sans-serif; }
:root:lang(am) { --font-body: "Noto Sans Ethiopic", "Inter", system-ui, sans-serif; --font-display: "Noto Sans Ethiopic", Georgia, serif; }
:root:lang(hi) { --font-body: "Noto Sans Devanagari", "Inter", system-ui, sans-serif; --font-display: "Noto Sans Devanagari", Georgia, serif; }
:root:lang(si) { --font-body: "Noto Sans Sinhala", "Inter", system-ui, sans-serif; --font-display: "Noto Sans Sinhala", Georgia, serif; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.2; margin: 0; }
h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); }
h2 { font-size: clamp(1.35rem, 3vw, 1.75rem); }
h3 { font-size: 1.1rem; }
p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 8px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.container { width: 100%; max-width: 1080px; margin: 0 auto; padding-inline: 16px; }
.hint { color: var(--muted); font-size: 0.9rem; }
.sub { color: var(--muted); margin-top: 6px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 12px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; min-width: 0; }
.logo { width: 38px; height: 38px; flex: none; }
.brand-name { display: block; font-family: var(--font-display); font-weight: 700; font-size: 1.3rem; line-height: 1.1; }
.brand-tagline { display: block; color: var(--muted); font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lang-picker {
  display: flex; align-items: center; gap: 6px; flex: none;
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px;
  background: var(--surface);
}
.lang-picker svg { width: 18px; height: 18px; color: var(--muted); }
.lang-picker select { border: 0; background: transparent; padding: 4px 0; cursor: pointer; }
.lang-picker select:focus-visible { outline: none; }
.lang-picker:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- Buttons & chips ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 999px; padding: 10px 20px; min-height: 44px;
  border: 1px solid transparent; font-weight: 600; text-decoration: none;
  transition: background 0.15s, transform 0.1s, border-color 0.15s;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { background: var(--brand-strong); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { padding: 6px 14px; min-height: 36px; font-size: 0.9rem; }
.btn svg { width: 18px; height: 18px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: 8px 14px; min-height: 40px;
  transition: background 0.15s, border-color 0.15s;
}
.chip:hover { border-color: var(--brand); }
.chip[aria-pressed="true"] { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-strong); font-weight: 600; }
.chip[aria-pressed="true"]::before { content: "✓"; font-weight: 700; }
.chip.avoid[aria-pressed="true"] { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.chip.avoid[aria-pressed="true"]::before { content: "✕"; }
.chip.removable { padding-inline-end: 6px; }
.chip.small { min-height: 34px; padding: 6px 12px; font-size: 0.9rem; }
.chip-icon { font-size: 1.05rem; line-height: 1; }
.chip[aria-pressed="true"]:has(.chip-icon)::before { content: none; }
.chip.removable button {
  border: 0; background: transparent; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; font-size: 1.1rem; line-height: 1; color: inherit;
}
.chip.removable button:hover { background: var(--surface-2); }

/* ---------- Wizard ---------- */
.view { padding-block: 24px 48px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel { padding: clamp(20px, 4vw, 36px); }
.panel h3 { margin-top: 24px; margin-bottom: 10px; }

.stepper { list-style: none; padding: 0; margin: 0 0 16px; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.stepper::-webkit-scrollbar { display: none; }
.stepper li { flex: 1; min-width: max-content; }
.stepper button {
  width: 100%; display: flex; align-items: center; gap: 8px;
  background: transparent; border: 0; padding: 8px 10px; border-radius: 12px;
  color: var(--muted); font-weight: 500; font-size: 0.9rem;
  border-bottom: 3px solid var(--line);
}
.stepper button:not([disabled]):hover { background: var(--surface-2); }
.stepper button[disabled] { cursor: default; opacity: 0.6; }
.stepper .num {
  width: 24px; height: 24px; flex: none; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-2); font-size: 0.8rem; font-weight: 700;
}
.stepper .done { border-bottom-color: var(--brand); }
.stepper .done .num { background: var(--brand-soft); color: var(--brand-strong); }
.stepper .current { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.stepper .current .num { background: var(--accent); color: #1f2a24; }

.wizard-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 16px; }
.wizard-nav .btn.primary { margin-inline-start: auto; min-width: 140px; }

.meal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-top: 20px; }
.meal-card {
  position: relative; text-align: start;
  display: flex; flex-direction: column; gap: 4px;
  padding: 18px; border-radius: 14px; border: 2px solid var(--line); background: var(--surface);
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.meal-card:hover { border-color: var(--brand); }
.meal-card[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); }
.meal-icon { font-size: 2rem; line-height: 1; margin-bottom: 6px; }
.meal-name { font-weight: 700; font-size: 1.05rem; }
.meal-hint { color: var(--muted); font-size: 0.85rem; }
.meal-card .check {
  position: absolute; top: 12px; inset-inline-end: 12px; width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid var(--line); display: grid; place-items: center; font-size: 0.8rem; color: var(--brand-ink);
}
.meal-card[aria-pressed="true"] .check { background: var(--brand); border-color: var(--brand); }
.meal-card[aria-pressed="true"] .check::after { content: "✓"; font-weight: 700; }

.error { color: var(--danger); font-weight: 600; margin-top: 14px; min-height: 1.5em; }

.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 24px; margin-top: 20px; }
.field { display: flex; flex-direction: column; gap: 10px; }
.field-label { font-weight: 600; }
.number-input { display: flex; align-items: center; gap: 8px; }
.number-input button {
  width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface);
  font-size: 1.4rem; line-height: 1;
}
.number-input button:hover { border-color: var(--brand); }
.number-input output { min-width: 64px; text-align: center; font-family: var(--font-display); font-size: 2rem; font-weight: 700; }
.segmented { display: inline-flex; align-self: flex-start; border: 1px solid var(--line); border-radius: 999px; padding: 4px; background: var(--surface-2); flex-wrap: wrap; }
.segmented button { border: 0; background: transparent; border-radius: 999px; padding: 8px 16px; min-height: 40px; }
.segmented button[aria-pressed="true"] { background: var(--surface); box-shadow: var(--shadow); font-weight: 600; }
.pleasure-field { margin-top: 24px; }

.custom-add { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.custom-add input {
  flex: 1; min-width: 180px; min-height: 44px; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
}
.custom-chips { margin-top: 10px; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; margin-top: 20px; font-weight: 600; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 46px; height: 26px; border-radius: 999px; background: var(--line); position: relative; transition: background 0.15s; flex: none; }
.switch .track::after {
  content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; transition: inset-inline-start 0.15s; box-shadow: 0 1px 3px rgb(0 0 0 / 25%);
}
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { inset-inline-start: 23px; }
.switch input:focus-visible + .track { outline: 3px solid var(--accent); outline-offset: 2px; }

.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin: 20px 0 0; }
.summary div { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; }
.summary dt { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }
.summary dd { margin: 4px 0 0; font-weight: 600; }

.engine { border: 0; padding: 0; margin: 24px 0 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.engine legend { font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; margin-bottom: 10px; padding: 0; }
.engine-card {
  display: flex; flex-direction: column; gap: 4px; padding: 16px; cursor: pointer;
  border: 2px solid var(--line); border-radius: 14px; background: var(--surface); position: relative;
}
.engine-card:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.engine-card:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.engine-card.disabled { opacity: 0.55; cursor: not-allowed; }
.engine-card input { position: absolute; opacity: 0; }
.engine-title { font-weight: 700; }
.engine-desc { color: var(--muted); font-size: 0.9rem; }

/* ---------- Weekdays, tiles, kitchen, stores ---------- */
.weekday-row { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; margin-top: 20px; max-width: 560px; }
.weekday {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 0 10px;
  border: 2px solid var(--line); border-radius: 14px; background: var(--surface); font-weight: 600; font-size: 0.9rem;
}
.weekday .dot { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--line); }
.weekday[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-strong); }
.weekday[aria-pressed="true"] .dot { background: var(--brand); border-color: var(--brand); }
.presets { margin-top: 12px; }

.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: start; padding: 14px;
  border: 2px solid var(--line); border-radius: 14px; background: var(--surface);
}
.tile:hover { border-color: var(--brand); }
.tile[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); }
.tile-icon { font-size: 1.6rem; line-height: 1; margin-bottom: 6px; }
.tile-name { font-weight: 700; }
.tile-hint { color: var(--muted); font-size: 0.8rem; }

.kitchen-tools { display: flex; flex-direction: column; gap: 10px; margin: 18px 0 14px; }
.kitchen-tools input {
  min-height: 44px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
}
.pantry-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.pantry-tile {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 6px;
  border: 2px solid var(--line); border-radius: 14px; background: var(--surface); text-align: center;
}
.pantry-tile:hover { border-color: var(--brand); }
.pantry-tile[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); }
.pantry-tile[aria-pressed="true"]::after {
  content: "✓"; position: absolute; top: 6px; inset-inline-end: 6px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-size: 0.7rem; font-weight: 700;
}
.pantry-icon { font-size: 1.9rem; line-height: 1; }
.pantry-name { font-size: 0.82rem; font-weight: 600; line-height: 1.25; }
.kitchen-count { display: flex; align-items: center; gap: 12px; margin-top: 14px; color: var(--muted); font-weight: 600; }

.store-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; margin: 16px 0 8px; }
.store-tile {
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 8px;
  border: 2px solid var(--line); border-radius: 14px; background: var(--surface); font-weight: 600; font-size: 0.9rem;
}
.store-tile:hover { border-color: var(--brand); }
.store-tile[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); }
.store-logo {
  width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; flex: none;
  background: var(--store); color: #fff; font-weight: 800; font-size: 1.05rem; letter-spacing: 0.02em;
}
.store-logo.small { width: 40px; height: 40px; font-size: 0.9rem; }
.review-heading { margin-top: 28px; }

/* ---------- Loading ---------- */
.loading { text-align: center; padding-block: 80px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.build-art { position: relative; width: 150px; height: 150px; display: grid; place-items: center; margin-bottom: 8px; }
.build-art .logo { width: 72px; height: 72px; }
.build-art span {
  position: absolute; font-size: 1.5rem; animation: orbit 6s linear infinite;
  offset-path: circle(64px at 50% 50%);
}
.build-art span:nth-child(2) { animation-delay: -1s; }
.build-art span:nth-child(3) { animation-delay: -2s; }
.build-art span:nth-child(4) { animation-delay: -3s; }
.build-art span:nth-child(5) { animation-delay: -4s; }
.build-art span:nth-child(6) { animation-delay: -5s; }
@keyframes orbit { from { offset-distance: 0%; } to { offset-distance: 100%; } }
.build-steps { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-direction: column; gap: 6px; width: min(360px, 100%); text-align: start; }
.build-steps li {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line); color: var(--muted); transition: color 0.2s, border-color 0.2s;
}
.build-steps .mark { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line); flex: none; display: grid; place-items: center; font-size: 0.7rem; }
.build-steps .active { color: var(--ink); border-color: var(--accent); }
.build-steps .active .mark { border-color: var(--accent); border-top-color: transparent; animation: spin 0.8s linear infinite; }
.build-steps .done { color: var(--ink); }
.build-steps .done .mark { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.build-steps .done .mark::after { content: "✓"; font-weight: 700; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .build-art span, .build-steps .active .mark { animation: none; } }

/* ---------- Results ---------- */
.results-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.results-head .sub { margin-top: 6px; }
.source-badge {
  display: inline-flex; align-items: center; gap: 6px; margin-bottom: 8px;
  background: var(--accent-soft); color: var(--ink); border-radius: 999px; padding: 4px 12px; font-size: 0.8rem; font-weight: 600;
}
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.notice {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--accent-soft); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; font-size: 0.95rem;
}
.notice.warn { background: var(--danger-soft); }
.notes { background: var(--brand-soft); border-radius: 12px; padding: 14px 16px; margin-bottom: 16px; }
.notes h3 { font-size: 1rem; margin-bottom: 4px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tabs button {
  border: 0; background: transparent; padding: 12px 16px; font-weight: 600; color: var(--muted);
  border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--brand); }
.tab-count { display: inline-block; background: var(--surface-2); border-radius: 999px; padding: 0 8px; font-size: 0.8rem; margin-inline-start: 6px; }

.days { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.day-card { padding: 16px; }
.day-card h3 { margin-bottom: 10px; }
.day-card ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.meal-slot { display: flex; gap: 6px; align-items: stretch; }
.swap-btn {
  flex: none; width: 44px; border: 1px solid var(--line); background: var(--surface);
  border-radius: 12px; font-size: 1.1rem; color: var(--muted);
}
.swap-btn:hover { border-color: var(--accent); color: var(--ink); background: var(--accent-soft); }
.option-list { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.option-card { padding: 14px 16px; display: flex; gap: 12px; align-items: center; justify-content: space-between; box-shadow: none; }
.option-card h3 { font-size: 1.05rem; }
.option-card .meta { color: var(--muted); font-size: 0.85rem; margin-top: 2px; }
.option-card .desc { font-size: 0.92rem; margin-top: 4px; }
.option-card .source-badge { margin: 8px 0 0; }
.option-card .btn { flex: none; }
@media (max-width: 640px) { .option-card { flex-direction: column; align-items: stretch; } }
.meal-row {
  flex: 1; min-width: 0;
  width: 100%; text-align: start; display: grid; grid-template-columns: 1fr auto; gap: 2px 8px;
  border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 10px 12px;
}
.meal-row:hover { border-color: var(--brand); }
.meal-row .meal-tag { grid-column: 1 / -1; }
.meal-title { font-weight: 600; }
.meal-meta { color: var(--muted); font-size: 0.85rem; align-self: end; white-space: nowrap; }
.meal-tag {
  display: inline-flex; align-items: center; gap: 4px; width: fit-content;
  font-size: 0.75rem; font-weight: 600; border-radius: 999px; padding: 2px 10px; color: var(--ink);
}
.meal-tag.breakfast { background: var(--meal-breakfast); }
.meal-tag.lunch { background: var(--meal-lunch); }
.meal-tag.snack { background: var(--meal-snack); }
.meal-tag.dinner { background: var(--meal-dinner); }
.meal-tag.pleasure { background: var(--meal-pleasure); }

.list-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 14px; }
.progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress .bar { height: 100%; background: var(--brand); transition: width 0.2s; }
.progress-label { margin: 6px 0 16px; color: var(--muted); font-size: 0.9rem; }
.list-columns { columns: 280px; column-gap: 16px; }
.list-group { break-inside: avoid; padding: 16px; margin-bottom: 16px; }
.list-group h3 { font-size: 1rem; margin-bottom: 8px; color: var(--brand-strong); }
.list-group ul { list-style: none; margin: 0; padding: 0; }
.check-item { display: flex; align-items: flex-start; gap: 10px; padding: 6px 0; cursor: pointer; }
.check-item input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--brand); flex: none; }
.check-item input:checked + span { text-decoration: line-through; color: var(--muted); }
.item-line, .ingredients li, .have-item { display: flex; align-items: flex-start; gap: 8px; }
.item-line { flex: 1; }
.item-cost { color: var(--muted); font-size: 0.8rem; white-space: nowrap; padding-top: 2px; }
.ing-icon { width: 1.4em; flex: none; text-align: center; }
.basket { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; padding: 16px; margin-bottom: 16px; box-shadow: none; }
.basket-store { display: flex; align-items: center; gap: 12px; }
.basket-total { display: flex; flex-direction: column; align-items: flex-end; }
.basket-total strong { font-family: var(--font-display); font-size: 1.6rem; color: var(--brand-strong); }
.basket-note { flex-basis: 100%; font-size: 0.8rem; }
.have-group { opacity: 0.8; }
.have-group ul { list-style: none; padding: 0; margin: 8px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 16px; }
.have-item { padding: 4px 0; color: var(--muted); }
.qty { font-weight: 600; }

.recipe-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.recipe-card { padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.recipe-card h3 { font-size: 1.1rem; }
.recipe-card .desc { color: var(--muted); font-size: 0.92rem; flex: 1; }
.recipe-card .meta { font-size: 0.85rem; color: var(--muted); }
.recipe-card .actions { margin-top: 6px; }

/* ---------- Recipe detail ---------- */
.recipe-head { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.recipe-head .eyebrow { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; color: var(--muted); font-size: 0.85rem; }
.recipe-head .desc { color: var(--muted); }
.meta-list { list-style: none; padding: 0; margin: 4px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
.meta-list li { background: var(--surface-2); border-radius: 999px; padding: 4px 12px; font-size: 0.85rem; }
.recipe-title { font-size: clamp(1.7rem, 4.5vw, 2.5rem); }
.macros { margin-bottom: 20px; }
.macros h3 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--brand-strong); margin-bottom: 8px; font-family: var(--font-body); }
.macro-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.macro { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; }
.macro strong { font-family: var(--font-display); font-size: 1.4rem; line-height: 1.1; }
.macro span { color: var(--muted); font-size: 0.8rem; }
.macro.protein strong { color: #c2410c; }
.macro.carbs strong { color: #b45309; }
.macro.fat strong { color: #15803d; }
:root[data-theme="dark"] .macro.protein strong, :root[data-theme="dark"] .macro.carbs strong, :root[data-theme="dark"] .macro.fat strong { filter: brightness(1.6); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .macro strong { filter: brightness(1.6); } }
.recipe-tabs { display: none; }
.pane-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.pane-head h3 { margin: 0; }
.number-input.small { gap: 6px; }
.number-input.small button { width: 34px; height: 34px; font-size: 1.1rem; }
.number-input.small output { min-width: 28px; font-size: 1.2rem; }
.recipe-cols { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 28px; }
.recipe-cols h3 { margin-bottom: 10px; }
.ingredients { list-style: none; padding: 0; margin: 0; }
.ingredients li { padding: 7px 0; border-bottom: 1px dashed var(--line); }
.steps { margin: 0; padding-inline-start: 0; list-style: none; counter-reset: step; }
.steps li { counter-increment: step; position: relative; padding-inline-start: 44px; margin-bottom: 18px; font-size: 1.05rem; line-height: 1.6; }
.steps li::before {
  content: counter(step); position: absolute; inset-inline-start: 0; top: 0;
  width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: var(--brand-ink);
  display: grid; place-items: center; font-weight: 700; font-size: 0.85rem;
}

/* ---------- Dialogs ---------- */
dialog.sheet {
  width: min(860px, calc(100vw - 24px)); max-height: calc(100vh - 32px);
  border: 1px solid var(--line); border-radius: 20px; padding: 0;
  background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgb(0 0 0 / 30%);
}
dialog.sheet.small { width: min(480px, calc(100vw - 24px)); }
dialog::backdrop { background: rgb(18 24 21 / 55%); backdrop-filter: blur(2px); }
.dialog-bar {
  position: sticky; top: 0; z-index: 1; display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.dialog-body { padding: 20px clamp(16px, 4vw, 32px) 28px; }
.share-url {
  width: 100%; min-height: 44px; padding: 10px 12px; margin: 14px 0;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); font-size: 0.85rem;
  direction: ltr;
}
.share-lang-label { margin-top: 16px; font-size: 0.9rem; }
.share-langs { margin: 8px 0 4px; }
.share-langs .chip[disabled] { opacity: 0.4; cursor: not-allowed; }
.share-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.share-buttons .btn { width: 100%; }
.btn.whatsapp { background: #25d366; color: #0b2e18; }
.btn.whatsapp:hover { background: #1fb959; }

/* ---------- Shared recipe page ---------- */
.shared-view { max-width: 860px; margin: 0 auto; }
.shared-view .card { padding: clamp(20px, 4vw, 36px); margin-top: 12px; }
.shared-view .actions { margin-top: 16px; justify-content: center; }

.footer { border-top: 1px solid var(--line); padding-block: 20px; color: var(--muted); font-size: 0.85rem; text-align: center; }

@media (max-width: 640px) {
  .brand-tagline { display: none; }
  .recipe-cols { grid-template-columns: 1fr; }
  .recipe-tabs { display: flex; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
  .recipe-tabs button {
    flex: 1; border: 0; background: transparent; padding: 12px; font-weight: 600; color: var(--muted);
    border-bottom: 3px solid transparent; margin-bottom: -1px;
  }
  .recipe-tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--brand); }
  .recipe-cols[data-tab="ingredients"] .pane-method, .recipe-cols[data-tab="method"] .pane-ingredients { display: none; }
  .macro-row { grid-template-columns: repeat(2, 1fr); }
  .weekday-row { gap: 4px; }
  .weekday { font-size: 0.75rem; padding: 10px 0 8px; }
  .results-head .actions { width: 100%; }
  .wizard-nav .btn.primary { min-width: 0; flex: 1; }
  .meal-grid { grid-template-columns: repeat(2, 1fr); }
  .share-buttons { grid-template-columns: 1fr; }
}

/* ---------- Print ---------- */
@media print {
  :root { --bg: #fff; --surface: #fff; --shadow: none; }
  .topbar, .footer, .tabs, .actions, .wizard-nav, .dialog-bar, .notice, .stepper, .recipe-tabs, .number-input button { display: none !important; }
  .recipe-cols .pane-method, .recipe-cols .pane-ingredients { display: block !important; }
  .card { border: 0; box-shadow: none; }
  .check-item input { appearance: none; width: 14px; height: 14px; border: 1px solid #000; border-radius: 3px; }
  body.print-dialog main { display: none; }
  body.print-dialog dialog[open] { position: static; border: 0; box-shadow: none; max-height: none; width: 100%; }
  dialog::backdrop { display: none; }
}
