:root {
  --bg: #ffffff;
  --card: #f6f6f8;
  --text: #1c1c1e;
  --muted: #8a8a8e;
  --accent: #e8763a;
  --accent-soft: #fdeee5;
  --ok: #34a853;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1c1e;
    --card: #2c2c2e;
    --text: #f2f2f7;
    --muted: #98989d;
    --accent: #ff8c52;
    --accent-soft: #3a2a20;
  }
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased;
}
#app { max-width: 480px; margin: 0 auto; padding: 16px 14px 90px; }
.screen.hidden { display: none; }
h1 { font-size: 24px; font-weight: 800; margin: 6px 0 14px; }
.sub-header { margin-bottom: 10px; }
.back-btn {
  background: none; border: none; color: var(--accent);
  font-size: 16px; font-weight: 600; padding: 6px 0; cursor: pointer;
}

/* Экран 1 */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; -webkit-overflow-scrolling: touch; }
.chip {
  flex: 0 0 auto; padding: 8px 16px; border-radius: 20px;
  background: var(--card); color: var(--text); border: none;
  font-size: 14px; font-weight: 600; cursor: pointer;
}
.chip.active { background: var(--accent); color: #fff; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 16px; }
.filter {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 12px;
  background: var(--card); font-size: 13px; border: none; color: var(--text); cursor: pointer;
}
.filter.on { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.card {
  background: var(--card); border-radius: var(--radius); overflow: hidden;
  cursor: pointer; transition: transform .12s;
}
.card:active { transform: scale(.97); }
.card img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.card .info { padding: 10px 12px 12px; }
.card .title { font-size: 15px; font-weight: 700; line-height: 1.25; }
.card .meta { font-size: 12px; color: var(--muted); margin-top: 4px; }
.empty { color: var(--muted); font-size: 14px; padding: 30px 10px; text-align: center; }

/* Экран 2 */
.hero { width: 100%; border-radius: var(--radius); aspect-ratio: 4/3; object-fit: cover; display: block; }
.dish-title { font-size: 22px; font-weight: 800; margin-top: 12px; }
.kbju { display: flex; gap: 8px; margin: 12px 0; }
.kbju div {
  flex: 1; background: var(--card); border-radius: 12px; padding: 10px 6px; text-align: center;
}
.kbju b { display: block; font-size: 16px; }
.kbju span { font-size: 11px; color: var(--muted); }
.ingr-list { margin-top: 6px; }
.ingr {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border-radius: 12px; padding: 9px 10px; margin-bottom: 8px;
}
.ingr img { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; }
.ingr .grow { flex: 1; min-width: 0; }
.ingr .name { font-size: 14px; font-weight: 600; }
.ingr .amount { font-size: 12px; color: var(--muted); margin-top: 2px; }
.ingr .note { font-size: 11px; color: var(--muted); margin-top: 2px; }
.swap-btn {
  background: var(--accent-soft); color: var(--accent); border: none;
  border-radius: 10px; padding: 7px 10px; font-size: 12px; font-weight: 700; cursor: pointer;
}
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 10;
  display: flex; align-items: flex-end;
}
.sheet {
  background: var(--bg); width: 100%; max-width: 480px; margin: 0 auto;
  border-radius: 18px 18px 0 0; padding: 18px 16px 26px; max-height: 70vh; overflow-y: auto;
}
.sheet h3 { font-size: 17px; font-weight: 800; margin-bottom: 12px; }
.sheet .opt {
  display: block; width: 100%; text-align: left; background: var(--card);
  border: none; border-radius: 12px; padding: 13px 14px; font-size: 14px;
  color: var(--text); margin-bottom: 8px; cursor: pointer; font-weight: 600;
}
.sheet .cancel {
  background: none; color: var(--muted); width: 100%; border: none;
  font-size: 14px; padding: 10px; cursor: pointer;
}

/* Кнопки */
.cta {
  position: fixed; bottom: 0; left: 0; right: 0; max-width: 480px; margin: 0 auto;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--bg) 30%);
}
.cta button {
  width: 100%; padding: 15px; border: none; border-radius: 14px;
  background: var(--accent); color: #fff; font-size: 16px; font-weight: 800; cursor: pointer;
}
.btn-row { display: flex; gap: 8px; margin-top: 14px; }
.btn-row button {
  flex: 1; padding: 13px 6px; border-radius: 12px; border: none;
  font-size: 13px; font-weight: 700; cursor: pointer;
  background: var(--card); color: var(--text);
}
.btn-row button.primary { background: var(--accent); color: #fff; }

/* Экран 3 */
.res-steps { counter-reset: step; margin-top: 4px; }
.res-step {
  display: flex; gap: 12px; background: var(--card); border-radius: 12px;
  padding: 12px; margin-bottom: 8px;
}
.res-step::before {
  counter-increment: step; content: counter(step);
  flex: 0 0 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: #fff; font-weight: 800; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
}
.res-step .t { font-weight: 700; font-size: 14px; }
.res-step .x { font-size: 13px; color: var(--muted); margin-top: 3px; line-height: 1.4; }
.saved-note { text-align: center; color: var(--ok); font-size: 13px; margin-top: 10px; min-height: 18px; }
.section-label { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; margin: 16px 0 8px; }
