:root {
  --bg: #f7f5ef;
  --surface: #fff;
  --ink: #1d2a22;
  --muted: #66726a;
  --line: #e3e0d5;
  --green: #2e6a4d;
  --green-soft: #e1efe6;
  --red: #df3f2a;
  --sun: #ffd05a;
  --shadow: 0 1px 2px rgba(29, 42, 34, .06), 0 8px 24px rgba(29, 42, 34, .07);
  --r: 18px;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14201a;
    --surface: #1c2c24;
    --ink: #f1f3ec;
    --muted: #9fb0a5;
    --line: #2f4237;
    --green: #6fcf9b;
    --green-soft: #23382d;
    --red: #ff6a52;
    --sun: #ffd05a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  }
}

:root[data-theme="dark"] {
  --bg: #14201a;
  --surface: #1c2c24;
  --ink: #f1f3ec;
  --muted: #9fb0a5;
  --line: #2f4237;
  --green: #6fcf9b;
  --green-soft: #23382d;
  --red: #ff6a52;
  --sun: #ffd05a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; }
html { height: 100%; scroll-padding-top: env(safe-area-inset-top, 0px); }
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 Figtree, system-ui, sans-serif;
  display: flex;
  flex-direction: column;
}
main.wrap { flex: 1; width: 100%; }
h1, h2, h3 { font-family: Fraunces, Georgia, serif; line-height: 1.1; margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--red); outline-offset: 2px; }
.hidden { display: none !important; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; }

header.top {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 5;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.bar { display: flex; align-items: center; gap: 14px; padding: 12px 0; }
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: Fraunces, serif;
  font-weight: 700;
  font-size: 22px;
  background: none;
  border: 0;
  padding: 0;
}
.logo i {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: var(--red);
  display: grid;
  place-items: center;
  font-style: normal;
  font-size: 19px;
}

.search { flex: 1; position: relative; max-width: 520px; }
.search input {
  width: 100%;
  height: 44px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 0 18px 0 44px;
  font: inherit;
}
.search span { position: absolute; left: 16px; top: 10px; }

.pill {
  height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-weight: 600;
  white-space: nowrap;
}
.pill:hover { border-color: var(--green); }
.pill.sun { background: var(--sun); border-color: var(--sun); color: #3a2b00; }
.pill.active { background: var(--green); border-color: var(--green); color: #fff; }
.nav { display: flex; gap: 8px; margin-left: auto; align-items: center; }

/* Hero */
.hero {
  padding: 44px 0 24px;
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  gap: 32px;
  align-items: center;
}
.hero h1 { font-size: clamp(36px, 6vw, 64px); letter-spacing: -.02em; }
.hero p { color: var(--muted); max-width: 44ch; margin: 16px 0 0; font-size: 18px; }
.stack { position: relative; height: 250px; }
.stack b {
  position: absolute;
  display: grid;
  place-items: center;
  font-size: 64px;
  border-radius: 26px;
  box-shadow: var(--shadow);
  width: 150px;
  height: 170px;
}
.stack b:nth-child(1) { left: 6%; top: 36px; background: #ffd05a; transform: rotate(-8deg); }
.stack b:nth-child(2) { left: 32%; top: 0; background: #ff8f70; transform: rotate(4deg); z-index: 1; }
.stack b:nth-child(3) { left: 58%; top: 50px; background: #9fd8b5; transform: rotate(11deg); }

/* Categories */
.cats {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 8px 20px 14px;
  margin: 0 -20px;
  scrollbar-width: none;
}
.cat {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 46px;
  padding: 0 18px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-weight: 600;
}
.cat small { color: var(--muted); font-weight: 500; }
.cat[aria-pressed=true] { background: var(--green); border-color: var(--green); color: #fff; }
.cat[aria-pressed=true] small { color: #d6eadd; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .cat[aria-pressed=true] { color: #0e2218; }
  :root:not([data-theme="light"]) .cat[aria-pressed=true] small { color: #27523b; }
}
:root[data-theme="dark"] .cat[aria-pressed=true] { color: #0e2218; }
:root[data-theme="dark"] .cat[aria-pressed=true] small { color: #27523b; }

.count { color: var(--muted); margin: 10px 0 16px; font-size: 14px; }

/* Grid & Cards */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 18px;
  padding-bottom: 28px;
}
.card {
  display: flex;
  flex-direction: column;
  text-align: left;
  padding: 0;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--r);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform .18s;
  height: 100%;
  cursor: pointer;
}
.card:hover { transform: translateY(-3px); }
.thumb {
  position: relative;
  height: 150px;
  display: grid;
  place-items: center;
  font-size: 56px;
  overflow: hidden;
}
.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.tag {
  position: absolute;
  left: 12px;
  bottom: 12px;
  background: rgba(255, 255, 255, .92);
  color: #1d2a22;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
}
.fav {
  position: absolute;
  right: 10px;
  top: 10px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, .92);
  color: #aab;
  font-size: 17px;
  display: grid;
  place-items: center;
}
.fav.on { color: var(--red); }
.card .body { padding: 14px 16px 16px; display: flex; flex-direction: column; flex: 1; }
.card h3 { font-size: 20px; }
.card p {
  color: var(--muted);
  font-size: 14px;
  margin: 6px 0 12px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.meta {
  margin-top: auto;
  display: flex;
  gap: 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--green);
}
.empty { grid-column: 1/-1; text-align: center; padding: 60px 0; color: var(--muted); }
.load-wrap { text-align: center; padding: 8px 0 56px; }

/* Recipe Page */
.crumb { display: flex; align-items: center; gap: 10px; padding: 22px 0 14px; flex-wrap: wrap; }
.crumb .pill { height: 38px; }
.crumb .sp { margin-left: auto; display: flex; gap: 8px; }
.banner {
  height: 260px;
  border-radius: 26px;
  display: grid;
  place-items: center;
  font-size: 110px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.banner img { width: 100%; height: 100%; object-fit: cover; display: block; }
.recipe { padding: 26px 0 8px; }
.recipe h1 { font-size: clamp(34px, 5vw, 56px); letter-spacing: -.02em; margin: 10px 0 6px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  background: var(--green-soft);
  color: var(--green);
  padding: 4px 12px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13px;
}
.cols { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); gap: 28px; margin-top: 26px; }
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 22px;
  box-shadow: var(--shadow);
}
.panel h2 { font-size: 26px; margin-bottom: 14px; }
.ing {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 11px 0;
  border-bottom: 1px dashed var(--line);
  cursor: pointer;
}
.ing input { width: 20px; height: 20px; accent-color: var(--green); flex-shrink: 0; }
.ing:has(input:checked) span { text-decoration: line-through; color: var(--muted); }
ol.steps { list-style: none; margin: 0; padding: 0; counter-reset: s; }
ol.steps li { counter-increment: s; display: flex; gap: 14px; padding: 12px 0; }
ol.steps li::before {
  content: counter(s);
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  font-weight: 700;
  display: grid;
  place-items: center;
}
.more { padding: 36px 0 14px; }
.more h2 { font-size: 28px; margin-bottom: 16px; }

/* Tabela TACO */
.taco-head { padding: 30px 0 16px; }
.taco-head h1 { font-size: clamp(30px, 4.5vw, 48px); margin-bottom: 8px; }
.taco-head p { color: var(--muted); margin: 0; }
.taco-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 24px;
  align-items: start;
  padding-bottom: 56px;
}
.taco-list { display: flex; flex-direction: column; gap: 10px; }
.taco-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
}
.taco-cat { font-size: 12px; font-weight: 700; color: var(--green); }
.taco-name { font-weight: 700; margin: 2px 0 6px; }
.taco-macros { display: flex; flex-wrap: wrap; gap: 6px; font-size: 13px; color: var(--muted); }
.taco-macros span { background: var(--green-soft); color: var(--green); padding: 2px 9px; border-radius: 999px; font-weight: 600; }
.meal-panel { position: sticky; top: 82px; }
.meal-totals { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 14px 0; }
.macro-box { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 8px 6px; text-align: center; }
.macro-box strong { display: block; color: var(--red); font-size: 16px; }
.macro-box span { font-size: 12px; color: var(--muted); }
.meal-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; max-height: 340px; overflow-y: auto; }
.meal-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 10px; background: var(--bg); border-radius: 12px; font-size: 14px; }
.meal-grams { width: 62px; padding: 4px 6px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-align: right; }

/* Toast & Footer */
.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--surface);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  z-index: 100;
}
footer { border-top: 1px solid var(--line); padding: 22px 0; color: var(--muted); font-size: 14px; }
.footer-inner { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }

@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; }
  .stack { display: none; }
  .cols, .taco-grid { grid-template-columns: 1fr; }
  .meal-panel { position: static; }
  .bar { flex-wrap: wrap; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .pill.t { display: none; }
}
@media print { header.top, .crumb, .more, footer { display: none; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
