/* Palette: warm kitchen cream + herb green accent (from the approved wireframe). Amber only for warnings. */
:root {
  --bg: #fbf6ee;
  --surface: #ffffff;
  --ink: #1f2a22;
  --muted: #586459;
  --line: #e4d9c6;
  --accent: #2c6a43;
  --accent-ink: #ffffff;
  --accent-soft: #e3efe5;
  --warn: #7a4300;
  --warn-soft: #fff1dc;
  --radius: 12px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
#app { max-width: 560px; margin: 0 auto; padding: var(--s5) var(--s4) calc(88px + env(safe-area-inset-bottom)); outline: none; }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0 0 var(--s1); letter-spacing: -0.01em; }
h2 { font-size: 1rem; margin: var(--s5) 0 var(--s2); }
p { margin: 0 0 var(--s2); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.screen-head { margin-bottom: var(--s4); }
.target { color: var(--ink); }
.target strong { color: var(--accent); }
.hint, .meta { color: var(--muted); font-size: 0.9rem; }
.empty { color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); padding: var(--s4); }
.fineprint { color: var(--muted); font-size: 0.8rem; margin-top: var(--s4); }
.warn { display: block; color: var(--warn); background: var(--warn-soft); border-radius: 8px; padding: var(--s2) var(--s3); font-size: 0.9rem; margin-top: var(--s2); }

/* Buttons */
.btn { font: inherit; font-weight: 600; min-height: 48px; padding: 0 var(--s5); border-radius: var(--radius); border: 1px solid transparent; cursor: pointer; }
.btn-primary { background: var(--accent); color: var(--accent-ink); width: 100%; font-size: 1.05rem; }
.btn-primary:disabled { background: #b8c7bc; cursor: not-allowed; }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.link { font: inherit; background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; }
.back { text-decoration: none; font-weight: 600; min-height: 44px; margin-bottom: var(--s2); }

/* Add pantry */
.add-row { display: flex; gap: var(--s2); margin-bottom: var(--s3); }
input[type="text"], input[type="number"], input[type="password"] {
  font: inherit; flex: 1; min-width: 0; min-height: 48px; padding: 0 var(--s3);
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink);
}
input:focus-visible { border-color: var(--accent); }

/* Chips: pill shape only here, where it marks a toggleable tag */
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); list-style: none; margin: 0; padding: 0; }
.chip { display: inline-flex; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; min-height: 44px; }
.chip label, .chip-method { display: inline-flex; align-items: center; gap: var(--s2); padding: 0 var(--s3); min-height: 44px; cursor: pointer; }
.chip input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.chip:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); }
.chip:has(input:not(:checked)) span { color: var(--muted); text-decoration: line-through; }
.chip-x { font: inherit; font-size: 1.3rem; line-height: 1; border: 0; background: none; color: var(--muted); min-width: 44px; min-height: 44px; cursor: pointer; border-radius: 999px; }
.chip-method:has(input:not(:checked)) span { text-decoration: none; }

.cta { margin-top: var(--s6); }
.cta .hint { margin-top: var(--s2); text-align: center; }

/* Result cards */
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s3); }
.card {
  display: grid; gap: var(--s1); width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s4);
}
.card:hover { border-color: var(--accent); }
.card-title { font-weight: 700; font-size: 1.1rem; }
.badges { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); margin: var(--s1) 0; }
.badge { background: #efe8dc; border-radius: 6px; padding: 2px var(--s2); font-size: 0.9rem; font-weight: 600; }
.badge-protein { background: var(--accent); color: var(--accent-ink); }
.badge-note { color: var(--muted); font-size: 0.8rem; }

/* Detail */
.ingredients, .steps { margin: 0; padding: 0; }
.ingredients { list-style: none; display: grid; gap: var(--s2); }
.ingredients li { display: flex; gap: var(--s3); align-items: baseline; }
.mark { flex: none; width: 1.5rem; height: 1.5rem; display: inline-grid; place-items: center; border-radius: 6px; font-weight: 700; font-size: 0.9rem; }
.have .mark { background: var(--accent-soft); color: var(--accent); }
.need .mark { background: var(--warn-soft); color: var(--warn); }
.grams { color: var(--muted); font-size: 0.85rem; }
.steps { padding-left: 1.4rem; display: grid; gap: var(--s3); }

/* States */
.state { text-align: center; padding: var(--s6) 0; display: grid; gap: var(--s3); justify-items: center; }
.state .btn { width: 100%; }
.spinner { width: 36px; height: 36px; border: 4px solid var(--accent-soft); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

/* Tab bar */
.tabbar {
  position: fixed; inset: auto 0 0 0; display: flex; background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button { flex: 1; min-height: 56px; border: 0; background: none; font: inherit; font-size: 0.9rem; color: var(--muted); cursor: pointer; }
.tabbar button[aria-current="page"] { color: var(--accent); font-weight: 700; box-shadow: inset 0 3px 0 var(--accent); }

/* Profile & saved */
.stack { display: grid; gap: var(--s2); }
.stack label { font-weight: 600; margin-top: var(--s2); }
.field-error { color: #a12a1a; font-size: 0.9rem; margin: 0; }
.field-error:empty { display: none; }
input[aria-invalid="true"] { border-color: #a12a1a; }
.targets { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); margin: var(--s4) 0 0; }
.targets div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s3); }
.targets dt { color: var(--muted); font-size: 0.85rem; }
.targets dd { margin: 0; font-size: 1.3rem; font-weight: 700; color: var(--accent); }
.remove { min-height: 44px; padding: 0 var(--s2); margin-top: var(--s1); }
.empty .btn { margin-top: var(--s3); }
a { color: var(--accent); }
.add-row .btn { white-space: nowrap; padding: 0 var(--s4); }
.add-row .btn-primary { flex: 1; }
