:root {
  --green: #0f8a5f;
  --green-dark: #0b5e42;
  --green-soft: #e9f7f1;
  --green-ink: #0b5e42;
  --gold: #c9a45c;
  --ink: #1b2a24;
  --muted: #5f6f68;
  --line: #dfe9e4;
  --bg: #f6faf8;
  --card: #ffffff;
  --danger: #b3261e;
  --surface: #ffffff;
  --chip-dark: #1b2a24;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(15, 60, 40, 0.08);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}
main { max-width: 960px; margin: 0 auto; padding: 16px; }
[hidden] { display: none !important; }

.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(120deg, var(--green-dark), var(--green));
  color: #fff;
}
.topbar__logo { width: 44px; height: 44px; border-radius: 12px; }
.topbar__brand { margin: 0; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; opacity: .85; }
.topbar__text { flex: 1; min-width: 0; }
.topbar__title { margin: 0; font-family: "Playfair Display", serif; font-size: 20px; font-weight: 700; }

.banner { background: #fff6e0; color: #6b4e00; text-align: center; font-size: 14px; padding: 8px 16px; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 18px; }
.center { text-align: center; }
.h1 { font-family: "Playfair Display", serif; font-size: clamp(26px, 5vw, 36px); line-height: 1.15; margin: 0 0 8px; }
.h1 .accent { color: var(--green); }
.h2 { font-family: "Playfair Display", serif; font-size: 24px; margin: 0 0 4px; }
.muted { color: var(--muted); margin: 0 0 12px; }

.field { margin: 18px 0 0; border: 0; padding: 0; min-width: 0; }
.field legend, .field > label { display: block; font-weight: 600; font-size: 15px; margin-bottom: 8px; }
.field input:not([type=radio]):not([type=checkbox]), .field select {
  width: 100%; font: inherit; padding: 12px 14px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink);
}
.field input:focus, .field select:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(15,138,95,.15); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-block; padding: 9px 14px; border-radius: 999px; cursor: pointer;
  border: 1.5px solid var(--line); background: var(--surface); font-size: 14px; font-weight: 500;
  transition: all .15s;
}
.chip input:checked + span { background: var(--green); border-color: var(--green); color: #fff; }
.chip input:focus-visible + span { box-shadow: 0 0 0 3px rgba(15,138,95,.25); }

.btn {
  font: inherit; font-weight: 600; font-size: 15px; cursor: pointer;
  padding: 11px 16px; border-radius: 12px; border: 1.5px solid var(--line);
  background: var(--surface); color: var(--ink);
}
.btn:hover { border-color: var(--green); }
.btn--primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn--primary:hover { background: var(--green-dark); }
.btn--ghost { background: transparent; }
.btn--block { width: 100%; margin-top: 22px; padding: 15px; font-size: 16px; border-radius: 14px; }
.btn:disabled { opacity: .6; cursor: wait; }
.btn--sm { padding: 7px 11px; font-size: 13px; border-radius: 10px; }

.error { color: var(--danger); font-weight: 500; margin: 14px 0 0; }

.spinner {
  width: 48px; height: 48px; margin: 12px auto 16px; border-radius: 50%;
  border: 4px solid var(--green-soft); border-top-color: var(--green);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.menu-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; align-items: flex-end; margin: 4px 0 14px; }
.menu-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.days { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; margin-bottom: 8px; scrollbar-width: none; }
.days button {
  flex: 0 0 auto; font: inherit; font-weight: 600; font-size: 14px; cursor: pointer;
  padding: 8px 14px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink);
}
.days button[aria-current="true"] { background: var(--green); border-color: var(--green); color: #fff; }

.day { margin-bottom: 22px; scroll-margin-top: 12px; }
.day__title { font-family: "Playfair Display", serif; font-size: 20px; margin: 0 0 10px; }
.meals { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.meal {
  background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); padding: 14px 16px;
  display: flex; flex-direction: column; gap: 6px; border-left: 4px solid var(--green);
}
.meal__type { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--green); }
.meal__name { font-weight: 700; font-size: 16px; margin: 0; }
.meal__desc { color: var(--muted); font-size: 14px; margin: 0; }
.meal__meta { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; color: var(--muted); }
.pill { background: var(--green-soft); color: var(--green-ink); border-radius: 999px; padding: 2px 9px; font-weight: 600; }
.meal__actions { display: flex; gap: 8px; margin-top: 6px; }

.dialog { border: 0; padding: 0; border-radius: 22px; width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 32px); box-shadow: 0 30px 80px rgba(0,0,0,.25); }
.dialog::backdrop { background: rgba(10, 30, 20, .55); }
.dialog__inner { padding: 22px 20px 26px; position: relative; overflow-y: auto; max-height: calc(100vh - 32px); }
.dialog__close { position: absolute; top: 10px; right: 12px; font-size: 28px; line-height: 1; background: none; border: 0; cursor: pointer; color: var(--muted); }
.recipe__meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 16px; }
.recipe h4 { margin: 18px 0 8px; font-size: 16px; }
.recipe ul { padding-left: 20px; margin: 0; }
.recipe li { margin: 4px 0; }
.steps { list-style: none; padding: 0; margin: 0; counter-reset: step; }
.steps li { counter-increment: step; position: relative; padding: 10px 0 10px 40px; border-bottom: 1px solid var(--line); }
.steps li::before {
  content: counter(step); position: absolute; left: 0; top: 10px; width: 28px; height: 28px; border-radius: 50%;
  background: var(--green); color: #fff; font-weight: 700; font-size: 14px; display: grid; place-items: center;
}
.bimby { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.bimby span { background: var(--chip-dark); color: #fff; border-radius: 8px; padding: 2px 8px; font-size: 12px; font-weight: 600; }
.recipe__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.hint { font-size: 13px; color: var(--muted); background: var(--green-soft); border-radius: 12px; padding: 10px 12px; margin-top: 14px; }

.shop h4 { margin: 16px 0 6px; color: var(--green-ink); }
.shop label { display: flex; gap: 10px; align-items: baseline; padding: 6px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.shop input:checked + span { text-decoration: line-through; color: var(--muted); }
.shop .qty { margin-left: auto; color: var(--muted); font-size: 14px; white-space: nowrap; }

.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); max-width: calc(100vw - 32px); text-align: center;
  background: var(--chip-dark); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 14px; z-index: 30;
  box-shadow: var(--shadow);
}

.footer { text-align: center; font-size: 12px; color: var(--muted); padding: 24px 16px 40px; max-width: 700px; margin: 0 auto; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.lang select {
  font: inherit; font-size: 13px; font-weight: 600; color: #fff; cursor: pointer;
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.35); border-radius: 10px; padding: 6px 8px;
}
.lang select option { color: #1b2a24; }

.linkbtn { display: block; margin: 16px auto 0; background: none; border: 0; font: inherit; font-size: 14px; font-weight: 600; color: var(--green); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.linkbtn--left { margin: 0 0 8px; text-decoration: none; color: var(--muted); }

.install { text-align: center; max-width: 480px; margin: 0 auto; }
.install__icon { width: 76px; height: 76px; border-radius: 20px; margin: 4px auto 12px; display: block; box-shadow: var(--shadow); }
.install__badge { display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--green); margin: 0 0 8px; }
.install__choices { display: grid; gap: 10px; margin-top: 18px; }
.btn--block-sm { width: 100%; padding: 14px; border-radius: 14px; }
.install__list { list-style: none; padding: 0; margin: 18px 0 6px; text-align: left; display: grid; gap: 14px; }
.install__list li { display: flex; gap: 12px; align-items: flex-start; }
.install__num { flex: 0 0 28px; height: 28px; border-radius: 50%; background: var(--green); color: #fff; font-weight: 700; font-size: 14px; display: grid; place-items: center; }
.install__step { font-weight: 700; margin: 2px 0 2px; }
.install__list .muted { margin: 0; font-size: 14px; }

.totop {
  position: fixed; right: 16px; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); z-index: 9;
  width: 48px; height: 48px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--green); color: #fff; font-size: 22px; font-weight: 700;
  box-shadow: 0 8px 24px rgba(15, 60, 40, .3);
}
.totop:hover { background: var(--green-dark); }
.totop:focus-visible { outline: 3px solid rgba(15,138,95,.35); outline-offset: 3px; }

@media (max-width: 480px) {
  .grid-2 { grid-template-columns: 1fr; }
  .menu-actions .btn { flex: 1 1 calc(50% - 8px); }
}

@media print {
  .topbar, .banner, .totop, .no-print, .footer, .meal__actions, #step-form { display: none !important; }
  body { background: #ffffff; }
  .meal { box-shadow: none; border: 1px solid var(--line); break-inside: avoid; }
  .day { break-inside: avoid; }
}

/* ---------- tools bar ---------- */
.tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin: 0 0 14px; }
.tool {
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; text-align: left;
  padding: 11px 12px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink);
}
.tool:hover { border-color: var(--green); }
.tool--primary { background: var(--green); border-color: var(--green); color: #fff; }
.tool--ghost { background: transparent; }

/* ---------- photos and macros ---------- */
.meal__photo { width: calc(100% + 32px); margin: -14px -16px 6px; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 16px 16px 0 0; display: block; max-width: none; }
.meal { overflow: hidden; }
.macros { display: flex; flex-wrap: wrap; gap: 10px; margin: 2px 0 0; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.macros b { color: var(--ink); }
.day__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; margin-bottom: 10px; }
.day__head .day__title { margin: 0; }
.day__totals { margin: 0; font-size: 12px; font-weight: 600; color: var(--green-ink); font-variant-numeric: tabular-nums; }
.recipe__photo { width: calc(100% + 40px); max-width: none; margin: -22px -20px 14px; aspect-ratio: 16 / 10; object-fit: cover; display: block; }

/* ---------- offers ---------- */
.offer {
  display: flex; gap: 14px; align-items: center; text-decoration: none; color: var(--ink);
  background: linear-gradient(120deg, var(--green-soft), var(--surface)); border: 1.5px solid var(--green);
  border-radius: 16px; padding: 12px; margin: 0 0 22px;
}
.offer img { width: 84px; height: 84px; border-radius: 12px; object-fit: cover; flex: 0 0 auto; }
.offer__body { display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.offer__body b { font-size: 16px; }
.offer__tag { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--green-ink); }
.offer__cta { font-weight: 700; color: var(--green-ink); margin-top: 4px; }
.offer--compact { margin: 18px 0 0; }
.offer--compact img { width: 64px; height: 64px; }

/* ---------- lists (favourites, history) ---------- */
.list { display: grid; gap: 8px; margin-top: 12px; }
.list__item {
  display: flex; gap: 12px; align-items: center; text-align: left; font: inherit; color: var(--ink); cursor: pointer;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 14px; padding: 8px;
}
.list__item:hover { border-color: var(--green); }
.list__item img, .list__ph { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; flex: 0 0 auto; display: grid; place-items: center; background: var(--green-soft); font-size: 24px; }
.list__item span { display: flex; flex-direction: column; min-width: 0; }
.list__item small { color: var(--muted); }
.list__go { margin-left: auto; color: var(--green-ink); font-weight: 700; white-space: nowrap; }
.field textarea { width: 100%; font: inherit; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); resize: vertical; }
.prep .steps li { line-height: 1.45; }

/* ---------- cooking mode ---------- */
.cook {
  position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column;
  background: var(--bg); color: var(--ink);
  padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px);
}
.cook__top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; }
.cook__btn { font: inherit; font-weight: 600; font-size: 14px; background: var(--surface); color: var(--ink); border: 1.5px solid var(--line); border-radius: 10px; padding: 8px 12px; cursor: pointer; }
.cook__count { margin: 0; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.cook__progress { height: 5px; background: var(--line); margin: 0 16px; border-radius: 999px; overflow: hidden; }
.cook__progress span { display: block; height: 100%; background: var(--green); transition: width .3s; }
.cook__body { flex: 1; overflow-y: auto; padding: 24px 20px; max-width: 720px; width: 100%; margin: 0 auto; }
.cook__title { font-size: 14px; font-weight: 700; color: var(--green-ink); text-transform: uppercase; letter-spacing: .06em; margin: 0 0 12px; }
.cook__text { font-size: clamp(22px, 5.5vw, 30px); line-height: 1.35; font-weight: 600; margin: 0 0 18px; text-wrap: pretty; }
.cook__bimby { display: flex; flex-wrap: wrap; gap: 8px; }
.cook__bimby span { background: var(--chip-dark); color: #fff; border-radius: 12px; padding: 8px 14px; font-size: 18px; font-weight: 700; }
.cook__timer { margin-top: 20px; font: inherit; font-size: 20px; font-weight: 700; padding: 14px 20px; border-radius: 14px; border: 0; cursor: pointer; background: var(--green); color: #fff; font-variant-numeric: tabular-nums; }
.cook__timer.is-running { background: var(--chip-dark); }
.cook__timer.is-done { background: #c0392b; animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.04); } }
.cook__ingr { margin: 20px 0 0; padding: 14px 18px 14px 34px; background: var(--surface); border-radius: 14px; border: 1.5px solid var(--line); font-size: 17px; }
.cook__nav { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; padding: 12px 16px 16px; }
.cook__nav .btn { padding: 16px; font-size: 17px; border-radius: 14px; }

@media (prefers-reduced-motion: reduce) { .cook__timer.is-done { animation: none; } }

/* ---------- dark mode ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ink: #e8f1ec; --muted: #a9bdb4; --line: #2e4038; --bg: #0e1814; --card: #15221d;
    --surface: #1b2b25; --green-soft: #1d3a2f; --green-ink: #9fe3c6; --chip-dark: #0b5e42;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e8f1ec; --muted: #a9bdb4; --line: #2e4038; --bg: #0e1814; --card: #15221d;
  --surface: #1b2b25; --green-soft: #1d3a2f; --green-ink: #9fe3c6; --chip-dark: #0b5e42;
}
.meal, .btn, .days button, .chip span, .field input, .field select { background: var(--surface); color: var(--ink); }
.btn--primary, .chip input:checked + span { background: var(--green); border-color: var(--green); color: #fff; }
.btn--primary:hover { background: var(--green-dark); }
.days button[aria-current="true"] { background: var(--green); border-color: var(--green); color: #fff; }
.dialog { background: var(--card); color: var(--ink); }
.banner { background: #fff6e0; color: #5a4100; }
.meal__type { color: var(--green-ink); }
.linkbtn { color: var(--green-ink); }
