:root {
  --bg: #f7f3ec;
  --surface: #fffdf9;
  --surface-2: #efe9df;
  --line: #e2d9cc;
  --text: #26211c;
  --muted: #6f655a;
  --accent: #b4532f;
  --accent-text: #fff;
  --accent-soft: #f4e2d8;
  --ok: #3f6b45;
  --ok-soft: #e1ecdf;
  --warn: #8a5a00;
  --warn-soft: #f6ead0;
  --shadow: 0 1px 2px rgb(60 40 20 / .06), 0 4px 16px rgb(60 40 20 / .06);
  --r: 14px;
  --r-sm: 10px;
  --gap: 16px;
  --top-h: 56px;
  --tabs-h: 64px;
  --fs-xs: 12px;
  --fs-s: 14px;
  --fs-m: 16px;
  --fs-l: 20px;
  --fs-xl: 26px;
  --fs-xxl: 32px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c1916; --surface: #25211d; --surface-2: #2e2924; --line: #3b352e;
    --text: #efe8de; --muted: #a99d8f; --accent: #e07a52; --accent-text: #1c1916;
    --accent-soft: #3d2a21; --ok: #8fc192; --ok-soft: #26352a; --warn: #e4b55a; --warn-soft: #3a3020;
    --shadow: 0 1px 2px rgb(0 0 0 / .3); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1c1916; --surface: #25211d; --surface-2: #2e2924; --line: #3b352e;
  --text: #efe8de; --muted: #a99d8f; --accent: #e07a52; --accent-text: #1c1916;
  --accent-soft: #3d2a21; --ok: #8fc192; --ok-soft: #26352a; --warn: #e4b55a; --warn-soft: #3a3020;
  --shadow: 0 1px 2px rgb(0 0 0 / .3); color-scheme: dark;
}

:root[data-theme="warm"] {
  --bg: #221a14; --surface: #2c221a; --surface-2: #372a20; --line: #46362a;
  --text: #f3e4d0; --muted: #c0a88e; --accent: #f0a05f; --accent-text: #221a14;
  --accent-soft: #4a3020; --ok: #b7cf8a; --ok-soft: #33391f; --warn: #f2c46b; --warn-soft: #43351c;
  --shadow: 0 1px 2px rgb(0 0 0 / .35); color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 var(--fs-m)/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow-x: hidden;
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom));
}
h1, h2, h3 { line-height: 1.2; margin: 0; text-wrap: balance; font-weight: 700; }
h1, h2 { font-family: "Unbounded", system-ui, sans-serif; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: clamp(24px, 5.5vw, 32px); }
h2 { font-size: clamp(19px, 4.2vw, 26px); }
h1 { font-size: var(--fs-xxl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-l); }
p { margin: 0; }
a { color: var(--accent); }
img { max-width: 100%; display: block; }
button, input, select { font: inherit; color: inherit; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-s); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Шапка */
.top {
  position: sticky; top: 0; z-index: 20; height: var(--top-h);
  display: flex; align-items: center; gap: 12px; padding: 0 16px;
  padding-top: env(safe-area-inset-top); height: calc(var(--top-h) + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 700; font-size: 18px; margin-right: auto; min-width: 0; }
.logo img { border-radius: 8px; }
.logo span { white-space: nowrap; }
.city-btn {
  display: flex; align-items: center; gap: 6px; min-width: 0; max-width: 46vw;
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px 6px 9px; cursor: pointer;
}
.city-btn svg { width: 18px; height: 18px; color: var(--accent); }
.city-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-s); }
.lang-btn { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 10px; font-size: var(--fs-xs); font-weight: 700; cursor: pointer; color: var(--muted); }
.lang-btn:hover { color: var(--accent); border-color: var(--accent); }
.install-btn { border: 0; background: var(--accent); color: var(--accent-text); border-radius: 999px; padding: 7px 14px; font-weight: 600; cursor: pointer; font-size: var(--fs-s); }

.city-confirm {
  margin: 12px 16px 0; padding: 14px 16px; border-radius: var(--r); background: var(--accent-soft);
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
}
.city-confirm p { font-weight: 600; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Нижнее меню */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--line);
}
.tabs a {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; color: var(--muted); font-size: var(--fs-xs); font-weight: 600; min-width: 0; white-space: nowrap;
}
.tabs a.on { color: var(--accent); }
.badge { position: absolute; top: 6px; left: calc(50% + 6px); background: var(--accent); color: var(--accent-text); font-size: 11px; border-radius: 999px; min-width: 18px; height: 18px; line-height: 18px; text-align: center; padding: 0 5px; }

main { outline: none; }
.page { padding: 16px; display: grid; gap: var(--gap); max-width: 1400px; margin: 0 auto; }

/* Кнопки и поля */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 8px 16px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; font-weight: 600; text-decoration: none; color: var(--text);
  transition: background-color .15s, border-color .15s, color .15s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.08); color: var(--accent-text); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { min-height: 34px; padding: 4px 12px; font-size: var(--fs-s); }
.btn svg { width: 18px; height: 18px; }
.input {
  width: 100%; min-height: 48px; padding: 10px 14px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface); font-size: var(--fs-m);
}
.input:focus { border-color: var(--accent); outline: none; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: grid; gap: 12px; }

/* Подбор */
.find { display: grid; gap: var(--gap); }
.ask { display: grid; gap: 10px; }
.ask-row { display: flex; gap: 8px; }
.ask-row .input { flex: 1; min-width: 0; }
.hint-examples { display: flex; gap: 6px; flex-wrap: wrap; }
.hint-examples button { border: 0; background: var(--surface-2); color: var(--muted); border-radius: 999px; padding: 4px 10px; font-size: var(--fs-xs); cursor: pointer; }
.hint-examples button:hover { color: var(--accent); }

.filters { display: grid; gap: 4px; align-content: start; }
.fgroup { border-bottom: 1px solid var(--line); }
.fgroup:last-child { border-bottom: 0; }
.fgroup > summary {
  list-style: none; cursor: pointer; padding: 12px 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 700;
}
.fgroup > summary::-webkit-details-marker { display: none; }
.fgroup > summary::after { content: ""; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); margin-right: 4px; transition: transform .2s; }
.fgroup[open] > summary::after { transform: rotate(-135deg); }
.fgroup .sum { font-weight: 400; color: var(--accent); font-size: var(--fs-s); margin-left: auto; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 55%; }
.fbody { padding: 0 0 14px; display: grid; gap: 10px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px; cursor: pointer; font-size: var(--fs-s);
  transition: background-color .15s, border-color .15s; display: inline-flex; align-items: center; gap: 6px; line-height: 1.3;
}
.chip:hover { border-color: var(--accent); }
.chip.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.chip.x::after { content: "×"; font-size: 16px; line-height: 1; opacity: .8; }
.chip.have { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.chip.ex { background: var(--warn-soft); border-color: transparent; color: var(--warn); }

.tagbox { display: grid; gap: 8px; }
.tagbox .ac { position: relative; }
.ac-list {
  position: absolute; z-index: 15; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-sm); box-shadow: var(--shadow); max-height: 260px; overflow: auto; padding: 4px;
}
.ac-list button { display: flex; width: 100%; justify-content: space-between; gap: 8px; text-align: left; border: 0; background: none; padding: 9px 10px; border-radius: 8px; cursor: pointer; }
.ac-list button:hover, .ac-list button.sel { background: var(--surface-2); }
.ac-list .muted { font-size: var(--fs-xs); }

.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--surface); }
.stepper button { width: 42px; height: 42px; border: 0; background: none; font-size: 22px; cursor: pointer; color: var(--accent); }
.stepper output { min-width: 44px; text-align: center; font-weight: 700; font-size: var(--fs-l); }
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: var(--fs-s); }
.switch input { width: 20px; height: 20px; accent-color: var(--accent); }

.results-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.results-head h2 { font-size: var(--fs-l); }
.sort { display: flex; gap: 6px; align-items: center; font-size: var(--fs-s); }
.sort select { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 6px 8px; }
.notice { padding: 12px 14px; border-radius: var(--r-sm); background: var(--surface-2); font-size: var(--fs-s); display: grid; gap: 8px; }
.notice.warn { background: var(--warn-soft); }
.notice.ok { background: var(--ok-soft); }

.grid { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); }
.rcard {
  display: grid; grid-template-rows: auto 1fr; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  overflow: hidden; text-decoration: none; color: var(--text); transition: border-color .15s, transform .15s;
}
.rcard:hover { border-color: var(--accent); transform: translateY(-2px); }
.rcard .ph { aspect-ratio: 4 / 3; background: var(--surface-2); position: relative; overflow: hidden; }
.rcard .ph img { position: relative; z-index: 1; width: 100%; height: 100%; object-fit: cover; }
.rcard .ph .fallback { position: absolute; inset: 0; display: grid; place-items: center; font-size: 46px; color: var(--muted); }
.rcard .pill { z-index: 2; position: absolute; left: 8px; top: 8px; background: rgb(0 0 0 / .62); color: #fff; font-size: var(--fs-xs); padding: 3px 8px; border-radius: 999px; }
.rcard .pill.ok { background: var(--ok); }
.rcard .body { padding: 12px 14px 14px; display: grid; gap: 6px; align-content: start; }
.rcard h3 { font-size: var(--fs-m); }
.meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: var(--fs-xs); color: var(--muted); }
.need { font-size: var(--fs-xs); color: var(--warn); }
.need.ok { color: var(--ok); }

/* Рецепт */
.recipe { display: grid; gap: var(--gap); }
.r-hero { display: grid; gap: var(--gap); }
.r-photo { border-radius: var(--r); overflow: hidden; background: var(--surface-2); aspect-ratio: 16 / 10; position: relative; }
.r-photo img { width: 100%; height: 100%; object-fit: cover; }
.r-photo .credit { position: absolute; right: 8px; bottom: 8px; background: rgb(0 0 0 / .55); color: #fff; font-size: 11px; padding: 2px 8px; border-radius: 6px; text-decoration: none; max-width: 80%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.r-head { display: grid; gap: 10px; align-content: start; }
.r-head .lead { color: var(--muted); }
.facts { display: flex; flex-wrap: wrap; gap: 8px; }
.fact { background: var(--surface-2); border-radius: 999px; padding: 5px 12px; font-size: var(--fs-s); }
.fact.ok { background: var(--ok-soft); color: var(--ok); }
.fact.warn { background: var(--warn-soft); color: var(--warn); }
.r-cols { display: grid; gap: var(--gap); }
.nutr { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.nutr div { background: var(--surface-2); border-radius: var(--r-sm); padding: 10px 6px; text-align: center; }
.nutr b { display: block; font-size: var(--fs-l); }
.nutr span { font-size: var(--fs-xs); color: var(--muted); }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; border-radius: 999px; padding: 5px 12px; font-size: var(--fs-s); cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.ings { list-style: none; margin: 0; padding: 0; display: grid; }
.ings li { display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: start; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.ings li:last-child { border-bottom: 0; }
.ings .st { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; margin-top: 1px; }
.ings .st.have { background: var(--ok-soft); color: var(--ok); }
.ings .st.miss { background: var(--warn-soft); color: var(--warn); }
.ings .st.basic { background: var(--surface-2); color: var(--muted); }
.ings .nm { display: grid; gap: 2px; }
.ings .sub { font-size: var(--fs-xs); color: var(--muted); }
.ings .sub.warn { color: var(--warn); }
.ings .qty { font-weight: 600; white-space: nowrap; text-align: right; }
.ings .buy { font-size: var(--fs-xs); border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0; text-align: left; text-decoration: underline; text-underline-offset: 2px; }
.ings li.optional .nm > span:first-child::after { content: " · по желанию"; color: var(--muted); font-size: var(--fs-xs); }
.ings li.off { opacity: .45; }

.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; counter-reset: s; }
.steps li { display: grid; grid-template-columns: 34px 1fr; gap: 12px; padding: 12px; border-radius: var(--r-sm); background: var(--surface-2); cursor: pointer; counter-increment: s; }
.steps li::before { content: counter(s); width: 30px; height: 30px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-weight: 700; color: var(--accent); }
.steps li.done { opacity: .5; }
.steps li.done::before { content: "✓"; background: var(--ok-soft); color: var(--ok); }
.steps .tm { margin-top: 8px; }
.tip { padding: 14px 16px; border-radius: var(--r-sm); background: var(--accent-soft); }

.links { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr)); }
.links a { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: var(--r-sm); border: 1px solid var(--line); text-decoration: none; color: var(--text); background: var(--surface); }
.links a:hover { border-color: var(--accent); }
.links a span { font-size: var(--fs-xs); color: var(--muted); }
.gallery { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scroll-snap-type: x mandatory; }
.gallery a { flex: 0 0 auto; width: 150px; aspect-ratio: 1; border-radius: var(--r-sm); overflow: hidden; background: var(--surface-2); scroll-snap-align: start; }
.gallery img { width: 100%; height: 100%; object-fit: cover; }

/* Покупки */
.shop-list { list-style: none; margin: 0; padding: 0; display: grid; }
.shop-list li { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.shop-list input { width: 22px; height: 22px; accent-color: var(--ok); }
.shop-list li.got .nm { text-decoration: line-through; color: var(--muted); }
.shop-list .nm small { display: block; color: var(--muted); font-size: var(--fs-xs); }

/* Шпаргалки */
.help-grid { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); align-items: start; }
.tbl-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: var(--fs-s); }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }

/* Таймер */
.timer-bar {
  position: fixed; z-index: 40; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 10px);
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: calc(100vw - 24px);
}
.timer { display: flex; align-items: center; gap: 10px; background: var(--text); color: var(--bg); border-radius: 999px; padding: 6px 6px 6px 16px; box-shadow: var(--shadow); font-weight: 700; }
.timer.ring { background: var(--accent); color: var(--accent-text); animation: pulse 1s infinite; }
.timer button { border: 0; background: rgb(255 255 255 / .18); color: inherit; border-radius: 999px; width: 30px; height: 30px; cursor: pointer; }
@keyframes pulse { 50% { transform: scale(1.05); } }

/* Нижняя шторка */
.sheet { border: 0; padding: 0; background: transparent; max-width: 640px; width: 100%; margin: auto auto 0; max-height: 88vh; color: var(--text); }
.sheet::backdrop { background: rgb(20 15 10 / .45); }
.sheet-body { background: var(--surface); border-radius: 20px 20px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); display: grid; gap: 14px; max-height: 88vh; overflow: auto; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.close { border: 0; background: var(--surface-2); border-radius: 50%; width: 36px; height: 36px; cursor: pointer; font-size: 20px; flex: none; }
.city-list { display: grid; gap: 2px; max-height: 46vh; overflow: auto; }
.city-list button { display: flex; justify-content: space-between; gap: 8px; text-align: left; border: 0; background: none; padding: 11px 10px; border-radius: 8px; cursor: pointer; }
.city-list button:hover { background: var(--surface-2); }
.shop-links { display: grid; gap: 8px; }
.shop-links a { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--r-sm); border: 1px solid var(--line); text-decoration: none; color: var(--text); }
.shop-links a:hover { border-color: var(--accent); }
.shop-links a span { font-size: var(--fs-xs); color: var(--muted); text-align: right; }

.empty { text-align: center; padding: 40px 16px; display: grid; gap: 12px; justify-items: center; color: var(--muted); }

/* Первый экран */
.hero { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; overflow: hidden; }
.hero-text { display: grid; gap: 12px; min-width: 0; }
.hero .lead { color: var(--muted); max-width: 62ch; }
.ill { fill: none; stroke: var(--accent); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; width: 120px; height: 90px; }
.hero-ill { width: 170px; height: 128px; }
.ill .steam { animation: steam 2.8s ease-in-out infinite; }
@keyframes steam { 0%, 100% { opacity: .35; transform: translateY(2px); } 50% { opacity: 1; transform: translateY(-3px); } }
.hero { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); }
.hero-media { position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; background: var(--surface-2); align-self: center; }
.hero-media img, .hero-media video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.hero-media video { opacity: 0; transition: opacity .6s; }
.hero-media.live video { opacity: 1; }
@media (max-width: 860px) { .hero { grid-template-columns: 1fr; } .hero-media { order: -1; min-height: 0; aspect-ratio: 16 / 9; } }
@media (max-width: 640px) { .hero { padding: 12px 12px 16px; } .hero-media { aspect-ratio: 16 / 9; } }
@media (orientation: landscape) and (max-height: 520px) { .hero { grid-template-columns: minmax(0, 1fr) 38%; } .hero-media { order: 0; } }
.btn.mic { width: 48px; padding: 0; flex: none; }
.btn.mic.rec { background: var(--accent); color: var(--accent-text); border-color: var(--accent); animation: pulse 1s infinite; }

/* Подборки */
.colls { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; min-width: 0; }
.coll { flex: none; display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--surface); border-radius: 14px; padding: 10px 14px; cursor: pointer; font-weight: 600; transition: border-color .15s, background-color .15s, transform .15s; }
.coll:hover { border-color: var(--accent); }
.coll:active { transform: scale(.97); }
.coll.now { border-color: var(--accent); }
.coll.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.coll small { font-weight: 500; font-size: 11px; background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 1px 7px; }
.coll.on small { background: rgb(255 255 255 / .25); color: inherit; }

/* Карточки списком */
.grid.as-list { grid-template-columns: 1fr; gap: 8px; }
.grid.as-list .rcard { grid-template-columns: 120px 1fr; grid-template-rows: auto; }
.grid.as-list .rcard .ph { aspect-ratio: auto; min-height: 92px; }
.grid.as-list .rcard .pill { font-size: 10px; }
.stars { color: var(--accent); letter-spacing: 1px; }
.need.save { color: var(--accent); font-weight: 600; }
.chip:active, .btn:active { transform: scale(.97); }
.btn.on-fav { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.r-photo .fallback { position: absolute; inset: 0; display: grid; place-items: center; font-size: 72px; }
.r-photo img { position: relative; z-index: 1; }
.r-photo .credit { z-index: 2; }

/* Сроки годности */
.dates { display: grid; gap: 6px; }
.dates label { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: var(--fs-s); }
.dates input { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 4px 6px; }

/* Заметки */
.mynote { display: grid; gap: 10px; padding: 14px; border-radius: var(--r-sm); border: 1px dashed var(--line); }
.rate { display: inline-flex; }
.rate button { border: 0; background: none; font-size: 26px; line-height: 1; color: var(--line); cursor: pointer; padding: 0 2px; transition: color .15s, transform .15s; }
.rate button.on { color: var(--accent); }
.rate button:hover { transform: scale(1.15); }
textarea.input { resize: vertical; font: inherit; }

/* Режим готовки */
body.cooking { overflow: hidden; }
.cook { position: fixed; inset: 0; z-index: 80; background: var(--bg); display: grid; grid-template-rows: auto auto 1fr auto; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.cook-top { display: flex; align-items: center; gap: 12px; padding: 12px 16px; }
.cook-title { flex: 1; min-width: 0; display: grid; }
.cook-title b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cook-title span { color: var(--muted); font-size: var(--fs-s); }
.cook-bar { height: 4px; background: var(--surface-2); margin: 0 16px; border-radius: 4px; overflow: hidden; }
.cook-bar span { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.cook-step { padding: 24px 20px; overflow: auto; display: grid; gap: 20px; align-content: start; max-width: 900px; width: 100%; margin: 0 auto; }
.cook-step p { font-size: clamp(22px, 4.2vw, 34px); line-height: 1.35; }
.cook-ings { padding: 8px 20px; overflow: auto; max-width: 700px; width: 100%; margin: 0 auto; font-size: var(--fs-l); }
.cook-nav { display: grid; grid-template-columns: 1fr 1.4fr; gap: 12px; padding: 12px 16px 16px; max-width: 900px; width: 100%; margin: 0 auto; }
.cook-nav .btn { min-height: 60px; font-size: var(--fs-l); }
.cook-nav .btn:disabled { opacity: .4; }
body.cooking .timer-bar { z-index: 90; bottom: 96px; }
@media (orientation: landscape) and (max-height: 520px) { .cook-step { padding: 8px 20px; } .cook-step p { font-size: 22px; } .cook-nav .btn { min-height: 46px; } }

.fly { position: fixed; z-index: 95; width: 16px; height: 16px; border-radius: 50%; background: var(--accent); pointer-events: none; }
#toast { position: fixed; left: 50%; top: calc(var(--top-h) + 12px); transform: translateX(-50%); z-index: 100; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: calc(100vw - 32px); box-shadow: var(--shadow); }

/* Меню на неделю */
.plan-days { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); align-items: start; }
.plan-day h3 { font-size: var(--fs-m); }
.plan-day h3::first-letter { text-transform: uppercase; }
.slot { display: grid; grid-template-columns: 64px 1fr auto; gap: 8px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.slot-name { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; }
.slot-r { display: flex; gap: 10px; align-items: center; text-decoration: none; color: var(--text); min-width: 0; }
.slot-r .thumb { width: 48px; height: 48px; border-radius: 10px; overflow: hidden; background: var(--surface-2); flex: none; display: grid; place-items: center; font-size: 22px; }
.slot-r .thumb img { width: 100%; height: 100%; object-fit: cover; }
.slot-r b { display: block; font-size: var(--fs-s); line-height: 1.3; }
.slot-r small { color: var(--muted); font-size: var(--fs-xs); }
.slot-r:hover b { color: var(--accent); }
h3.dept { font-size: var(--fs-s); color: var(--muted); margin-top: 8px; }

/* Свой рецепт */
.my-form { display: grid; gap: 14px; max-width: 760px; }
.my-form label { display: grid; gap: 6px; font-size: var(--fs-s); color: var(--muted); }
.my-form .row label { flex: 1; min-width: 110px; }
.input.num { max-width: 120px; }
.ing-row { display: grid; grid-template-columns: 1fr 90px 100px 36px; gap: 6px; align-items: center; margin-bottom: 6px; }
.ing-row .input { min-height: 42px; padding: 8px 10px; }
@media (max-width: 520px) { .ing-row { grid-template-columns: 1fr 64px 84px 32px; } }
.empty .ill { width: 140px; height: 105px; }
.in-tg .install-btn { display: none !important; }

/* ИИ-повар и серверные функции */
.ai-row .btn { font-size: var(--fs-s); }
.photo-btn { justify-self: start; }
.chat { display: grid; gap: 8px; max-height: 52vh; overflow: auto; padding: 4px 0; }
.msg { padding: 10px 14px; border-radius: 16px; max-width: 88%; line-height: 1.45; }
.msg.me { justify-self: end; background: var(--accent); color: var(--accent-text); border-bottom-right-radius: 4px; }
.msg.bot { justify-self: start; background: var(--surface-2); border-bottom-left-radius: 4px; }
.chat-recs { display: grid; gap: 4px; margin-top: 8px; }
.chat-recs a { font-weight: 600; text-decoration: none; }
.dots::after { content: '…'; display: inline-block; animation: dots 1.2s steps(4) infinite; width: 1.2em; overflow: hidden; vertical-align: bottom; }
@keyframes dots { from { width: 0; } to { width: 1.2em; } }
.code { font-family: ui-monospace, Consolas, monospace; letter-spacing: .08em; font-size: 1.1em; }
.ai-note { display: grid; gap: 8px; }
.family { display: grid; gap: 8px; }

/* Иконки подборок */
.ci { width: 22px; height: 22px; fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.coll.on .ci { stroke: currentColor; }
.ci .spark { fill: var(--accent); stroke: none; }
.coll.on .ci .spark { fill: currentColor; }
@media (prefers-reduced-motion: no-preference) {
  .coll.now .ci, .coll:hover .ci { animation-duration: 2.4s; animation-iteration-count: infinite; animation-timing-function: ease-in-out; transform-origin: 50% 60%; }
  .coll.now .ci-twinkle .spark, .coll:hover .ci-twinkle .spark { animation: twinkle 1.6s infinite; }
  .coll.now .ci-steam .st, .coll:hover .ci-steam .st { animation: steam 2.2s infinite; }
  .coll.now .ci-wobble, .coll:hover .ci-wobble { animation-name: wobble; }
  .coll.now .ci-sway, .coll:hover .ci-sway { animation-name: sway; }
  .coll.now .ci-glow .spark, .coll:hover .ci-glow .spark { animation: twinkle 2s infinite; }
  .coll.now .ci-tilt, .coll:hover .ci-tilt { animation-name: sway; }
  .coll.now .ci-float, .coll:hover .ci-float { animation-name: float; }
  .coll.now .ci-bounce, .coll:hover .ci-bounce { animation-name: float; }
  .coll.now .ci-spin, .coll:hover .ci-spin { animation: spin 3s linear infinite; }
}
@keyframes twinkle { 50% { opacity: .2; transform: scale(.6); } }
@keyframes wobble { 25% { transform: rotate(-9deg); } 75% { transform: rotate(9deg); } }
@keyframes sway { 50% { transform: rotate(-12deg); } }
@keyframes float { 50% { transform: translateY(-3px); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* Аллергены, напитки, похожие, профиль */
.alg { display: flex; gap: 2px; font-size: 13px; }
.alg-full { font-size: var(--fs-s); }
.drinks { padding: 12px 14px; border-radius: var(--r-sm); background: var(--surface-2); font-size: var(--fs-s); }
.similar { display: grid; gap: var(--gap); }
.fits { display: flex; flex-wrap: wrap; gap: 6px; }
.fit { font-size: var(--fs-xs); padding: 3px 10px; border-radius: 999px; background: var(--surface-2); }
.fit.ok { background: var(--ok-soft); color: var(--ok); }
.fit.no { background: var(--warn-soft); color: var(--warn); }
.fit.warn { background: var(--surface-2); color: var(--muted); }
.one-more { display: grid; gap: 8px; }
.fam .row .input:first-child { flex: 1; min-width: 140px; }
.fam .row select { max-width: 160px; }
/* Дневник */
.bar { display: grid; gap: 4px; }
.bar-top { display: flex; justify-content: space-between; font-size: var(--fs-s); }
.bar-track { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar-track span { display: block; height: 100%; background: var(--ok); border-radius: 999px; transition: width .4s; }
.bar-track span.over, .wk-bar span.over { background: var(--accent); }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end; }
.wk { display: grid; gap: 4px; justify-items: center; font-size: var(--fs-xs); }
.wk-bar { height: 120px; width: 100%; max-width: 36px; background: var(--surface-2); border-radius: 8px; display: flex; align-items: flex-end; overflow: hidden; }
.wk-bar span { display: block; width: 100%; background: var(--ok); }
.wk small { color: var(--muted); }
/* Фото к шагам */
.step-media { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 4px; }
.step-media figure { margin: 0; flex: 0 0 200px; scroll-snap-align: start; }
.step-media img, .step-media video { width: 200px; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--r-sm); background: var(--surface-2); display: block; }
.step-media figcaption { font-size: var(--fs-xs); color: var(--muted); margin-top: 4px; }

.step-img { width: 100%; max-width: 420px; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--r-sm); margin-top: 10px; display: block; background: var(--surface); }
.cook-img { width: 100%; max-height: 42vh; object-fit: cover; border-radius: var(--r); }
.step-video { width: 100%; max-width: 640px; aspect-ratio: 4 / 3; border-radius: var(--r-sm); background: #000; }
@media print { .step-img { max-width: 34mm; float: right; margin: 0 0 4px 8px; } .step-video { display: none; } }

/* Таймер в Telegram, форма, отзывы, крупный шрифт */
.tg-timer { text-decoration: none; font-size: 18px; line-height: 1; padding: 2px 4px; }
.pan { display: grid; gap: 6px; }
.comments .cm { display: grid; gap: 4px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.comments .cm img { max-width: 260px; border-radius: var(--r-sm); }
.comments details > summary { list-style: none; width: max-content; }
.comments details > summary::-webkit-details-marker { display: none; }
.cm-form { display: grid; gap: 10px; margin-top: 10px; max-width: 560px; }
.qty-in { width: 80px; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 4px 6px; }
.dates .row { gap: 6px; flex-wrap: nowrap; }
html.big body { font-size: 19px; }
html.big .steps li p, html.big .ings li { font-size: 20px; }
html.big .cook-step p { font-size: clamp(26px, 5vw, 40px); }
html.big .btn { min-height: 48px; }

/* Планшет и компьютер */
@media (min-width: 720px) {
  .page { padding: 24px; }
  .r-hero { grid-template-columns: 1.1fr 1fr; align-items: start; }
  .r-cols { grid-template-columns: minmax(300px, 1fr) 1.4fr; align-items: start; }
  .r-cols > .card:first-child { position: sticky; top: calc(var(--top-h) + 16px); }
}
@media (min-width: 1000px) {
  body { padding-bottom: 0; padding-left: 88px; }
  .tabs {
    top: var(--top-h); bottom: 0; right: auto; width: 88px; height: auto; padding: 12px 0;
    grid-template-columns: 1fr; grid-auto-rows: 76px; align-content: start; border-top: 0; border-right: 1px solid var(--line); background: var(--bg);
  }
  .top { margin-left: -88px; }
  .find { grid-template-columns: 340px 1fr; align-items: start; }
  .find .side { position: sticky; top: calc(var(--top-h) + 16px); max-height: calc(100vh - var(--top-h) - 32px); overflow: auto; }
  .find .hero, .find .colls { grid-column: 1 / -1; }
  .timer-bar { bottom: 20px; }
}
/* Телефон боком: меню сбоку, шапка тоньше */
@media (orientation: landscape) and (max-height: 520px) {
  :root { --top-h: 46px; }
  body { padding-bottom: 0; padding-left: calc(72px + env(safe-area-inset-left)); }
  .tabs {
    top: 0; bottom: 0; right: auto; width: calc(72px + env(safe-area-inset-left)); height: auto; padding: 8px 0 8px env(safe-area-inset-left);
    grid-template-columns: 1fr; grid-auto-rows: 1fr; border-top: 0; border-right: 1px solid var(--line);
  }
  .top { margin-left: calc(-72px - env(safe-area-inset-left)); padding-left: calc(84px + env(safe-area-inset-left)); }
  .r-photo { aspect-ratio: 21 / 9; }
  .timer-bar { bottom: 10px; }
  .sheet, .sheet-body { max-height: 96vh; }
}
@media (max-width: 380px) {
  .logo span { display: none; }
  .nutr b { font-size: var(--fs-m); }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
/* Печать рецепта: один лист А4, как страница из кулинарной книги */
@page { size: A4; margin: 14mm 14mm 16mm; }
@media print {
  .top, .tabs, .timer-bar, .no-print, .city-confirm, .similar, .gallery, .links, .mynote, .seg, .stepper, .buy, .r-photo .credit, .step-media, .fits, #toast,
  .recipe h3:has(+ .gallery) { display: none !important; }
  :root { --bg: #fff; --surface: #fff; --surface-2: #f4efe8; --line: #d9cfc2; --text: #1b1612; --muted: #5b5148; --accent: #9a4426; }
  body { padding: 0 !important; background: #fff; color: #1b1612; font-size: 10.5pt; line-height: 1.4; }
  .page { padding: 0; gap: 10px; max-width: none; }
  .r-hero { grid-template-columns: 62mm 1fr !important; gap: 8mm; align-items: start; }
  .r-photo { aspect-ratio: 4 / 3; border-radius: 4mm; }
  .r-head h1 { font-size: 22pt; }
  .r-head .lead { font-size: 10.5pt; }
  .facts { gap: 4px; }
  .fact { font-size: 8.5pt; padding: 2px 8px; }
  .r-cols { grid-template-columns: 62mm 1fr !important; gap: 8mm; }
  .r-cols > .card:first-child { position: static; }
  .card { border: 0; padding: 0; gap: 6px; }
  .card h2 { font-size: 13pt; }
  .ings li { padding: 3px 0; grid-template-columns: 14px 1fr auto; gap: 6px; }
  .ings .st { width: 12px; height: 12px; font-size: 8px; }
  .nutr div { padding: 4px; }
  .nutr b { font-size: 11pt; }
  .steps { gap: 4px; }
  .steps li { padding: 5px 8px; break-inside: avoid; background: none; border-bottom: 1px solid var(--line); border-radius: 0; }
  .steps li::before { width: 20px; height: 20px; font-size: 9pt; }
  .steps .tm { display: none; }
  .tip, .drinks { padding: 6px 10px; break-inside: avoid; }
  .r-head::after { content: "Что приготовить · vladislavbropiton.github.io/povar"; font-size: 8pt; color: var(--muted); }
}
