@font-face {
  font-family: "Vazirmatn";
  src: url("vazirmatn.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

/* Browser look (-0 values) comes from the food itself: sumac red, herb green, flour white.
   Inside Telegram, its theme variables win. */
:root {
  --bg-0: #fbfaf7; --fg-0: #1f1a18; --hint-0: #6d6460; --card-0: #f2eee8; --section-0: #ffffff;
  --accent-0: #8e2c3a; --accent-fg-0: #ffffff; --link-0: #8e2c3a; --have-0: #3f6b4a; --danger-0: #b3261e;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg-0: #151312; --fg-0: #efe9e4; --hint-0: #a59c96; --card-0: #221e1c; --section-0: #1c1918;
    --accent-0: #e0899a; --accent-fg-0: #1a1314; --link-0: #e8a0ad; --have-0: #86b892; --danger-0: #f2867e;
  }
}
:root {
  --bg: var(--tg-theme-bg-color, var(--bg-0));
  --fg: var(--tg-theme-text-color, var(--fg-0));
  --hint: var(--tg-theme-hint-color, var(--hint-0));
  --card: var(--tg-theme-secondary-bg-color, var(--card-0));
  --section: var(--tg-theme-section-bg-color, var(--section-0));
  --line: var(--tg-theme-section-separator-color, color-mix(in srgb, var(--fg) 12%, transparent));
  --accent: var(--tg-theme-button-color, var(--accent-0));
  --accent-fg: var(--tg-theme-button-text-color, var(--accent-fg-0));
  --link: var(--tg-theme-link-color, var(--link-0));
  --accent-text: var(--tg-theme-accent-text-color, var(--accent-0));
  --danger: var(--tg-theme-destructive-text-color, var(--danger-0));
  --have: var(--have-0);
  --r: 12px; --r-s: 8px;
  --ease: cubic-bezier(.23, 1, .32, 1);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; color-scheme: light dark; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 400 1rem/1.6 "Vazirmatn", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
}
[dir="rtl"] body { font-size: 1.0625rem; line-height: 1.8; }
a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 3px; }
h1 { font-size: 1.625rem; line-height: 1.35; margin: 8px 0; font-weight: 700; display: flex; align-items: center; gap: 8px; }
h2 { font-size: 1.1875rem; line-height: 1.4; margin: 32px 0 12px; font-weight: 600; }
p { margin: 8px 0; }
small { font-size: .8125rem; }
.hint { color: var(--hint); font-weight: 400; }
.sub { color: var(--hint); margin-top: 0; }
.center { text-align: center; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
main { max-width: 44rem; margin: 0 auto; padding: 8px 16px calc(48px + var(--tg-content-safe-area-inset-bottom, 0px)); }

/* icons from the sprite */
.i { width: 20px; height: 20px; flex: none; vertical-align: -4px; }
.meta .i { width: 20px; height: 20px; vertical-align: -5px; }
[dir="rtl"] .i.dir { transform: scaleX(-1); }

/* header */
.top {
  display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: center;
  max-width: 44rem; margin: 0 auto; padding: 12px 16px 4px;
}
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.125rem; color: var(--fg); text-decoration: none; min-height: 44px; }
.brand-i { width: 24px; height: 24px; color: var(--accent-text); }
.langs { display: flex; }
.langs a {
  display: grid; place-items: center; min-width: 44px; min-height: 44px; border-radius: var(--r-s);
  font-size: .875rem; text-decoration: none; color: var(--hint);
}
.langs a[aria-current] { color: var(--fg); font-weight: 700; background: var(--card); }
.search { grid-column: 1 / -1; position: relative; }
.search .i { position: absolute; inset-inline-start: 12px; top: 12px; color: var(--hint); }
.search input, .filter-input, .avoid input, select {
  width: 100%; min-height: 44px; padding: 8px 12px; font: inherit; color: var(--fg);
  background: var(--card); border: 1px solid transparent; border-radius: var(--r-s);
}
.search input { padding-inline-start: 40px; }
input:focus-visible, select:focus-visible, a:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent-text); outline-offset: 2px;
}

/* chips */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px; margin: 8px -2px; scrollbar-width: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 6px 14px; flex: none;
  border: 1px solid var(--line); border-radius: 999px; background: var(--section);
  color: var(--fg); text-decoration: none; font-size: .9375rem; cursor: pointer; position: relative;
}
.chip small { color: var(--hint); }
.chip.sm { min-height: 36px; padding: 4px 12px; font-size: .875rem; }
.chip.on, .chip:has(input:checked) { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.chip.on small, .chip:has(input:checked) small { color: inherit; opacity: .8; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip.off { opacity: .45; cursor: not-allowed; }
.chip:has(input:focus-visible) { outline: 2px solid var(--accent-text); outline-offset: 2px; }
.more-chips summary { cursor: pointer; color: var(--link); min-height: 44px; display: flex; align-items: center; }

/* home */
.wizcard { margin: 12px 0 8px; }
.wizcard-main {
  display: block; padding: 16px; border-radius: var(--r);
  background: var(--accent); color: var(--accent-fg); text-decoration: none;
}
.wizcard-main strong { display: block; font-size: 1.375rem; font-weight: 700; }
.wizcard-main span { opacity: .85; }
.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-top: 32px; }
.sec-head h2 { margin: 0 0 8px; }
.sec-head a { min-height: 44px; display: inline-flex; align-items: center; text-decoration: none; }
.rail {
  display: grid; grid-auto-flow: column; grid-auto-columns: 148px; gap: 12px;
  overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding-inline: 16px;
  margin-inline: -16px; padding: 4px 16px 8px; scrollbar-width: none;
}
.featured .rail { grid-auto-columns: 240px; }
.ptile { scroll-snap-align: start; color: var(--fg); text-decoration: none; display: grid; gap: 4px; align-content: start; }
.ptile strong { font-weight: 600; line-height: 1.35; }
.ptile .meta { color: var(--hint); font-size: .8125rem; }
.thumb { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--r); background: var(--card); display: block; }
.thumb.ph { display: grid; place-items: center; color: color-mix(in srgb, var(--hint) 60%, transparent); }
.thumb.ph .i { width: 32px; height: 32px; }
.menu { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mtile {
  display: grid; justify-items: center; align-content: center; gap: 2px; min-height: 88px; padding: 8px 4px;
  border-radius: var(--r); background: var(--card); color: var(--fg); text-decoration: none; text-align: center;
  font-size: .875rem; font-weight: 600; line-height: 1.3;
}
.mtile .i { width: 24px; height: 24px; color: var(--accent-text); }
.mtile small { color: var(--hint); font-weight: 400; }
.row-link {
  display: flex; align-items: center; gap: 12px; min-height: 56px; margin-top: 32px; padding: 8px 16px;
  border-radius: var(--r); background: var(--card); color: var(--fg); text-decoration: none; font-weight: 600;
}
.row-link span { flex: 1; }

/* lists */
.filters { position: sticky; top: 0; z-index: 2; display: flex; gap: 8px; overflow-x: auto; padding: 8px 16px; margin: 0 -16px; background: var(--bg); scrollbar-width: none; }
.filters select { width: auto; flex: none; }
.tgl { position: relative; flex: none; display: inline-flex; }
.tgl span { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--section); white-space: nowrap; }
.tgl input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.tgl input:checked + span { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.count { color: var(--hint); margin: 4px 0 8px; }
.cards, .results { display: grid; gap: 8px; content-visibility: auto; }
.card {
  display: flex; gap: 12px; align-items: center; padding: 8px; min-height: 88px;
  background: var(--section); border: 1px solid var(--line); border-radius: var(--r); color: var(--fg); text-decoration: none;
}
.card .thumb { width: 72px; height: 72px; aspect-ratio: auto; border-radius: var(--r-s); flex: none; }
.card-body { display: grid; gap: 2px; min-width: 0; }
.card strong { font-size: 1.0625rem; font-weight: 600; line-height: 1.35; }
.meta { color: var(--hint); font-size: .875rem; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.sep { opacity: .6; }
.veg { color: var(--have); display: inline-flex; gap: 2px; align-items: center; }
.rows { list-style: none; padding: 0; margin: 0; }
.rows a { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 6px 0; border-bottom: 1px solid var(--line); color: var(--fg); text-decoration: none; }
.rows a span { flex: 1; }
.rows .hint { font-size: .875rem; }
.mini { width: 40px; height: 40px; border-radius: var(--r-s); object-fit: cover; background: var(--card); flex: none; }
.sticky-search { position: sticky; top: 0; z-index: 2; background: var(--bg); padding: 8px 0; }
.sticky-h { position: sticky; top: 60px; background: var(--bg); padding: 8px 0; margin-bottom: 0; z-index: 1; }
.empty { color: var(--hint); padding: 24px 0; }

/* meal */
.hero { margin: 8px -16px 0; }
.hero img { width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
.hero figcaption, .credit { font-size: .8125rem; color: var(--hint); padding: 4px 16px; }
.credit { padding: 0; }
.hero figcaption a, .credit a { color: inherit; }
.crumb { margin: 12px 0 0; font-size: .9375rem; color: var(--hint); }
.crumb a { color: var(--hint); text-decoration: none; }
.alt { color: var(--hint); margin: 0; display: flex; flex-wrap: wrap; gap: 4px 16px; }
.lead { font-size: 1.0625rem; }
.facts { list-style: none; padding: 0; margin: 16px 0 8px; display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.facts li { display: flex; gap: 8px; align-items: center; padding: 8px 12px; background: var(--card); border-radius: var(--r-s); }
.facts span { display: grid; line-height: 1.3; font-weight: 600; }
.facts small { color: var(--hint); font-weight: 400; }
.facts .i { color: var(--accent-text); }
.ings { list-style: none; padding: 0; margin: 0; }
.ings li { display: flex; align-items: center; border-bottom: 1px solid var(--line); }
.ings li.grp { border: 0; padding-top: 16px; font-weight: 600; color: var(--accent-text); }
.ing-row { flex: 1; display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 6px 0; }
.ing-name { flex: 1; }
.qty { color: var(--hint); white-space: nowrap; }
.ing-link { display: grid; place-items: center; min-width: 44px; min-height: 44px; color: var(--hint); }
.steps { padding-inline-start: 28px; margin: 0; }
.steps li { margin-bottom: 12px; padding-inline-start: 4px; }
.steps li::marker { color: var(--accent-text); font-weight: 700; }
.note-box { display: flex; gap: 12px; margin-top: 16px; padding: 12px 16px; background: var(--card); border-radius: var(--r); }
.note-box .i { color: var(--accent-text); margin-top: 4px; }
.note-box p { margin: 4px 0 0; }
.sources { margin-top: 24px; color: var(--hint); font-size: .875rem; }
.sources summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; }
.sources a { color: var(--hint); word-break: break-all; }

/* ingredient */
.ing-head { display: flex; gap: 16px; align-items: center; margin-top: 8px; }
.ing-photo { width: 112px; height: 112px; border-radius: var(--r); object-fit: cover; flex: none; background: var(--card); }
.ing-photo.ph { display: grid; place-items: center; color: var(--hint); }
.ing-photo.ph .i { width: 32px; height: 32px; }
.shelfname { display: grid; margin: 16px 0; padding: 12px 16px; border-radius: var(--r); border: 1px dashed color-mix(in srgb, var(--accent-text) 50%, transparent); background: var(--section); }
.shelfname span { color: var(--hint); font-size: .875rem; }
.shelfname strong { font-size: 1.25rem; font-weight: 700; }
.jump { margin-top: 0; }
.info h2 { margin-top: 24px; }
.stores { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.stores > li { padding: 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--section); }
.store-head { display: flex; align-items: center; gap: 12px; min-height: 32px; }
.store-name { font-weight: 600; }
.logo { display: grid; place-items: center; height: 32px; min-width: 64px; max-width: 96px; padding: 4px 8px; background: #fff; border: 1px solid var(--line); border-radius: var(--r-s); }
.logo img { max-height: 24px; max-width: 80px; object-fit: contain; }
.logo.word { color: #1f1a18; font-weight: 800; font-size: .8125rem; letter-spacing: .02em; }
.packs { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 8px; }
.packs li { display: flex; gap: 12px; align-items: center; }
.packs img { width: 64px; height: 64px; object-fit: contain; background: #fff; border-radius: var(--r-s); border: 1px solid var(--line); flex: none; }
.packs span { display: grid; line-height: 1.35; }

/* buttons */
button, .primary, .ghost, .tonal {
  font: inherit; font-weight: 600; cursor: pointer; border: 0; border-radius: var(--r);
  min-height: 48px; padding: 0 20px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
}
.primary { background: var(--accent); color: var(--accent-fg); }
.ghost { background: transparent; color: var(--link); padding: 0 12px; }
.tonal { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent-text); min-height: 40px; padding: 0 14px; font-size: .9375rem; }
button:disabled { opacity: .6; }
.add > .primary { width: 100%; margin-top: 16px; }
.status { min-height: 1.2em; margin: 4px 0 0; color: var(--have); font-weight: 600; }
.status.err { color: var(--danger); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 22px; height: 22px; margin: 0; flex: none; }

/* add-to-list only works inside Telegram, where app.js sets .in-tg */
.tg { display: none !important; }
.in-tg .tg { display: revert !important; }
.in-tg .add > .tg.primary { display: flex !important; }
.in-tg .no-tg { display: none; }
.no-tg { color: var(--hint); font-size: .875rem; }
.in-tg .js-main.has-main { display: none !important; }
.js .js-hide { display: none; }

/* wizard */
.presets { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
.preset {
  display: flex; align-items: center; min-height: 72px; padding: 12px 16px; border-radius: var(--r);
  background: var(--card); color: var(--fg); text-decoration: none; font-weight: 600; line-height: 1.35;
}
.preset:last-child { grid-column: 1 / -1; justify-content: center; background: transparent; border: 1px solid var(--line); }
.progress { width: 100%; height: 4px; appearance: none; border: 0; border-radius: 2px; background: var(--card); margin-top: 8px; }
.progress::-webkit-progress-bar { background: var(--card); border-radius: 2px; }
.progress::-webkit-progress-value { background: var(--accent); border-radius: 2px; }
.progress::-moz-progress-bar { background: var(--accent); border-radius: 2px; }
fieldset { border: 0; padding: 0; margin: 24px 0 0; min-width: 0; }
legend { font-weight: 600; font-size: 1.0625rem; margin-bottom: 8px; }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg label { position: relative; flex: 1 1 auto; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.seg span {
  display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; padding: 6px 12px;
  border: 1px solid var(--line); border-radius: var(--r-s); background: var(--section); cursor: pointer; text-align: center;
}
.seg input:checked + span { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); font-weight: 600; }
.seg input:focus-visible + span { outline: 2px solid var(--accent-text); outline-offset: 2px; }
.catgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.cat { position: relative; }
.cat input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.cat span {
  display: grid; justify-items: center; gap: 2px; min-height: 84px; padding: 8px 4px; text-align: center;
  border: 1px solid var(--line); border-radius: var(--r); background: var(--section); cursor: pointer; font-size: .875rem; line-height: 1.3;
}
.cat b { font-weight: 600; }
.cat small { color: var(--hint); }
.cat .i { width: 24px; height: 24px; color: var(--accent-text); }
.cat input:checked + span { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.cat input:checked + span .i, .cat input:checked + span small { color: inherit; }
.cat.off { opacity: .45; }
.avoid { margin-top: 24px; }
.avoid summary, .shelf summary { min-height: 48px; display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; }
.shelf { border-bottom: 1px solid var(--line); }
.pantry { list-style: none; padding: 0; margin: 0; }
.pantry li { display: flex; align-items: center; border-bottom: 1px solid var(--line); }
.pantry li:last-child { border-bottom: 0; }
.p-have { flex: 1; display: flex; align-items: center; gap: 12px; min-height: 48px; cursor: pointer; }
.p-must { display: none; place-items: center; min-width: 44px; min-height: 44px; position: relative; color: var(--hint); cursor: pointer; }
.p-must input { position: absolute; opacity: 0; inset: 0; margin: 0; }
li:has(.p-have input:checked) .p-must { display: grid; }
.p-must:has(input:checked) { color: var(--accent-text); }
.nav {
  position: sticky; bottom: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin-top: 24px; padding: 12px 0 calc(12px + var(--tg-content-safe-area-inset-bottom, 0px)); background: var(--bg);
}
.nav .primary { flex: 1; }
.res-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.answers .chip .i { width: 20px; height: 20px; }
.result { display: grid; gap: 4px; padding-bottom: 8px; }
.result .card { border-bottom-left-radius: var(--r); }
.match { display: flex; align-items: center; gap: 8px; padding-inline: 8px; color: var(--hint); }
meter { flex: 1; height: 6px; max-width: 160px; }
meter::-webkit-meter-bar { background: var(--card); border: 0; border-radius: 3px; height: 6px; }
meter::-webkit-meter-optimum-value, meter::-webkit-meter-suboptimum-value, meter::-webkit-meter-even-less-good-value { background: var(--have); border-radius: 3px; }
meter::-moz-meter-bar { background: var(--have); border-radius: 3px; }
.swap { color: var(--hint); font-size: .875rem; padding-inline: 8px; display: flex; gap: 6px; align-items: flex-start; margin: 0; }
.miss { padding-inline: 8px; }
.miss p { margin: 4px 0; }

/* press feedback */
@media (prefers-reduced-motion: no-preference) {
  .card, .ptile, .mtile, .preset, .chip, .seg span, .cat span, button { transition: transform 160ms var(--ease), background-color 150ms ease; }
  .card:active, .ptile:active, .mtile:active, .preset:active, .chip:active, .seg span:active, .cat span:active, button:active { transform: scale(.97); }
}
[dir="rtl"] ol { list-style-type: persian; }
