/* DAYDISH — дизайн-система.
   Тёплый нейтральный фон, один акцент цвета жара и еда на фото. Никакого
   чистого чёрного: кухня — тёплое место, и приложение про неё не должно
   выглядеть как терминал.

   Два правила, из которых растёт остальное:

   1. Цвета текста и иконок — непрозрачные. Полупрозрачный currentColor на
      иконке из нескольких контуров даёт двойную плотность там, где контуры
      пересекаются, — иконка выглядит грязной. Прозрачность здесь только у
      подложек, и только там, где под ними заведомо ничего нет.
   2. Скроллбары не показываем нигде. Мини-апп живёт внутри чужого окна, и
      вторая полоса прокрутки рядом с телеграмовской читается как поломка. */

:root {
  color-scheme: dark;

  --bg:            #14120e;
  --surface-1:     #1d1a15;
  --surface-2:     #26221b;
  --surface-3:     #322d24;
  --border:        #2e2921;
  --border-strong: #4a4237;

  --text-primary:   #f6f1e8;
  --text-secondary: #b5aa99;
  --text-muted:     #82786a;

  --accent:      #f0a341;   /* жар: таймеры и полосы процессов */
  --accent-soft: #33260f;
  --on-accent:   #1a1409;

  --ok:        #86c98d;
  --ok-soft:   #1d2a1e;
  --warn:      #f0705c;
  --warn-soft: #331b17;

  --shadow: none;

  --r-l: 22px;
  --r:   16px;
  --r-s: 11px;
  --line: 1px;

  --pad: 17px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tabs-h: 62px;

  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Inter', 'Segoe UI', Roboto, sans-serif;
}

/* Системная тема — только пока человек не выбрал свою. :not([data-theme])
   держит приоритет за явным выбором, не полагаясь на порядок правил. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) { color-scheme: light; }
  :root:not([data-theme]) {
    --bg:            #fbf7f0;
    --surface-1:     #ffffff;
    --surface-2:     #f4eee3;
    --surface-3:     #eae1d3;
    --border:        #e8e0d2;
    --border-strong: #c6b9a4;

    --text-primary:   #1b1712;
    --text-secondary: #6d6353;
    --text-muted:     #9a8f7e;

    --accent:      #c2761a;
    --accent-soft: #fbeed8;
    --on-accent:   #fffaf1;

    --ok:        #3d8850;
    --ok-soft:   #e4f0e4;
    --warn:      #c03f29;
    --warn-soft: #fbe5e0;

    --shadow: 0 1px 2px rgba(60, 44, 20, .05), 0 8px 24px -12px rgba(60, 44, 20, .16);
  }
}

:root[data-theme='light'] {
  color-scheme: light;

  --bg:            #fbf7f0;
  --surface-1:     #ffffff;
  --surface-2:     #f4eee3;
  --surface-3:     #eae1d3;
  --border:        #e8e0d2;
  --border-strong: #c6b9a4;

  --text-primary:   #1b1712;
  --text-secondary: #6d6353;
  --text-muted:     #9a8f7e;

  --accent:      #c2761a;
  --accent-soft: #fbeed8;
  --on-accent:   #fffaf1;

  --ok:        #3d8850;
  --ok-soft:   #e4f0e4;
  --warn:      #c03f29;
  --warn-soft: #fbe5e0;

  --shadow: 0 1px 2px rgba(60, 44, 20, .05), 0 8px 24px -12px rgba(60, 44, 20, .16);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

/* Полос прокрутки нет нигде — см. правило 2 в шапке файла. */
* { scrollbar-width: none; -ms-overflow-style: none; }
*::-webkit-scrollbar { width: 0; height: 0; display: none; }

html, body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 15.5px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body { min-height: 100dvh; }

button, input, select, textarea { font: inherit; color: inherit; background: none; border: 0; }
button { cursor: pointer; }
svg { display: block; }

.ic {
  width: 21px; height: 21px;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}
.ic--s { width: 16px; height: 16px; stroke-width: 1.9; }
.ic--l { width: 26px; height: 26px; stroke-width: 1.6; }

/* ── каркас ─────────────────────────────────────────────────────────────── */

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 10px) var(--pad) calc(var(--tabs-h) + var(--safe-bottom) + 24px);
}
/* Экраны, которые сами держат свой каркас во весь рост: готовка, онбординг. */
.app--flat { padding: 0; max-width: none; }

.boot {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  padding: 32px;
  background: var(--bg);
  z-index: 50;
}
.boot__mark {
  font-size: 13px; letter-spacing: .24em; font-weight: 600;
  color: var(--text-muted);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: .35 } 50% { opacity: .9 } }

.boot__fail {
  max-width: 340px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.boot__fail .ic { color: var(--warn); }

/* ── нижние вкладки ─────────────────────────────────────────────────────── */
/*
   Только иконки. Подпись под иконкой холодильника ничего не добавляет к
   иконке холодильника, а строку занимает — и делает панель выше на треть.
   Активное состояние показано формой (подложка), а не оттенком серого:
   оттенок на маленькой иконке не читается. */

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: center; gap: 6px;
  padding: 8px 10px calc(var(--safe-bottom) + 8px);
  background: var(--bg);
  border-top: var(--line) solid var(--border);
  z-index: 20;
}
.tab {
  position: relative;
  flex: 1; max-width: 96px;
  display: flex; align-items: center; justify-content: center;
  height: 42px;
  border-radius: 14px;
  color: var(--text-muted);
  transition: color .16s, background .16s;
}
.tab[aria-current='true'] {
  color: var(--text-primary);
  background: var(--surface-2);
}
.tab:active { background: var(--surface-3); }
.tab__dot {
  position: absolute; top: 7px; right: 50%; translate: 15px 0;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
  box-sizing: content-box;
}

/* ── типографика ────────────────────────────────────────────────────────── */

.h1 { font-size: 30px; line-height: 1.12; font-weight: 680; letter-spacing: -.03em; }
.h2 { font-size: 21px; line-height: 1.22; font-weight: 650; letter-spacing: -.02em; }
.lead { font-size: 18px; font-weight: 600; line-height: 1.32; letter-spacing: -.015em; }
.sub { font-size: 13.5px; color: var(--text-secondary); }
.muted { font-size: 12.5px; color: var(--text-muted); }
.eyebrow {
  font-size: 11px; letter-spacing: .13em; text-transform: uppercase;
  color: var(--text-muted); font-weight: 620;
}
.stack > * + * { margin-top: 12px; }
.stack-l > * + * { margin-top: 24px; }
.row { display: flex; align-items: center; gap: 10px; }
.row--between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.center { text-align: center; }

/* ── кнопки ─────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 18px;
  border-radius: var(--r);
  font-size: 15.5px; font-weight: 560;
  border: var(--line) solid var(--border);
  color: var(--text-primary);
  background: var(--surface-2);
  transition: opacity .15s, background .15s, scale .1s;
}
.btn:active { scale: .985; opacity: .75; }
.btn:disabled { opacity: .3; pointer-events: none; }
.btn--primary {
  background: var(--text-primary); color: var(--bg);
  border-color: transparent; font-weight: 640;
}
.btn--accent { background: var(--accent); color: var(--on-accent); border-color: transparent; font-weight: 640; }
.btn--ghost { background: none; border-color: transparent; color: var(--text-secondary); }
.btn--full { width: 100%; }
.btn--s { padding: 9px 13px; font-size: 13.5px; border-radius: var(--r-s); gap: 6px; }
.btn--l { padding: 17px 20px; font-size: 16.5px; border-radius: var(--r); }

.link {
  color: var(--accent); font-size: 13.5px; font-weight: 560;
}

/* ── карточки и поверхности ─────────────────────────────────────────────── */

.card {
  background: var(--surface-1);
  border: var(--line) solid var(--border);
  border-radius: var(--r-l);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card__body { padding: 15px 16px 16px; }
.panel {
  background: var(--surface-1);
  border: var(--line) solid var(--border);
  border-radius: var(--r);
  padding: 14px 15px;
}
.panel--flush { padding: 4px 15px; }
.panel--accent { background: var(--accent-soft); border-color: transparent; }
.panel--warn { background: var(--warn-soft); border-color: transparent; }
.sep { height: var(--line); background: var(--border); border: 0; }

/* ── чипсы ──────────────────────────────────────────────────────────────── */

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 13px;
  border-radius: 999px;
  border: var(--line) solid var(--border);
  background: var(--surface-1);
  font-size: 13.5px; font-weight: 520; color: var(--text-primary);
  transition: background .15s, border-color .15s, color .15s;
}
.chip:active { scale: .97; }
.chip[aria-pressed='true'] {
  background: var(--text-primary);
  border-color: transparent;
  color: var(--bg);
}
.chip--done {
  color: var(--text-muted);
  text-decoration: line-through;
  background: none;
}
.chip--miss { border-color: var(--warn); color: var(--warn); }
.chip--opt { border-style: dashed; }
.chip__tag {
  font-size: 10.5px; letter-spacing: .03em;
  color: var(--text-muted); text-transform: lowercase;
}
.chip[aria-pressed='true'] .chip__tag { color: var(--bg); opacity: .7; }

/* ── БЖУ ────────────────────────────────────────────────────────────────── */
/*
   Число крупное, подпись мелкая: на этот блок смотрят одним взглядом и ищут
   в нём ровно одну цифру. */

.macros {
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface-1);
  border: var(--line) solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}
.macros > div {
  text-align: center; padding: 12px 4px 11px;
  border-right: var(--line) solid var(--border);
}
.macros > div:last-child { border-right: 0; }
.macros b {
  display: block; font-size: 19px; font-weight: 660;
  font-variant-numeric: tabular-nums; letter-spacing: -.03em;
  line-height: 1.15;
}
.macros span { font-size: 10.5px; color: var(--text-muted); letter-spacing: .01em; }
.macros--lead > div:first-child b { color: var(--accent); }

/* ── экран «что приготовить» ────────────────────────────────────────────── */

.slots { display: flex; gap: 7px; overflow-x: auto; }
.slot {
  flex: none; padding: 8px 15px; border-radius: 999px;
  font-size: 13.5px; font-weight: 540; color: var(--text-secondary);
  border: var(--line) solid transparent;
  background: var(--surface-2);
}
.slot[aria-current='true'] {
  color: var(--on-accent);
  background: var(--accent);
}

.dish { position: relative; }
.dish__photo {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--surface-2);
  overflow: hidden;
}
.dish__photo img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  /* Фото у рецептов разного происхождения и разной обработки. Общий тёплый
     тон и лёгкая подтяжка контраста делают ленту одностильной, не трогая
     сами картинки. */
  filter: saturate(1.06) contrast(1.04);
}
/* Затемнение снизу — под подписи и чтобы низ карточки не спорил с фоном. */
.dish__photo::after {
  content: ''; position: absolute; inset: auto 0 0 0; height: 42%;
  background: linear-gradient(to bottom, transparent, rgba(20, 14, 6, .34));
  pointer-events: none;
}
.dish__photo--empty {
  display: grid; place-items: center;
  color: var(--text-muted); font-size: 11px; letter-spacing: .22em; font-weight: 600;
  background:
    radial-gradient(120% 90% at 50% 0%, var(--surface-3), var(--surface-2));
}
.dish__photo--empty::after { display: none; }
.dish__flag {
  position: absolute; top: 11px; right: 11px;
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--bg);
  color: var(--warn);
}
.dish__meta {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 12.5px; color: var(--text-muted);
}
.dish__dot { width: 3px; height: 3px; border-radius: 50%; background: currentColor; flex: none; }

.status { display: inline-flex; align-items: center; gap: 7px; font-size: 13.5px; font-weight: 540; }
.status--ready { color: var(--ok); }
.status--swap  { color: var(--accent); }
.status--buy   { color: var(--text-secondary); }

.deck { position: relative; }
.deck__nav { display: flex; justify-content: space-between; align-items: center; }
.deck__count { font-size: 12.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* Раскрывающееся описание: по тапу, а не всегда — на карточке важнее фото. */
.more { overflow: hidden; }
.more__body { color: var(--text-secondary); font-size: 14px; line-height: 1.5; }
.more__toggle {
  display: inline-flex; align-items: center; gap: 5px;
  color: var(--accent); font-size: 13px; font-weight: 560;
  padding: 4px 0;
}
.more__toggle .ic { transition: rotate .18s; }
.more__toggle[aria-expanded='true'] .ic { rotate: 180deg; }

/* ── холодильник ────────────────────────────────────────────────────────── */

.search {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  background: var(--surface-1);
  border: var(--line) solid var(--border);
  border-radius: var(--r);
  color: var(--text-muted);
}
.search input { flex: 1; outline: none; color: var(--text-primary); min-width: 0; }
.search input::placeholder { color: var(--text-muted); }

.item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0;
  border-bottom: var(--line) solid var(--border);
  text-align: left; width: 100%;
}
.item:last-child { border-bottom: 0; }
.item__qty {
  font-size: 13.5px; color: var(--text-secondary);
  font-variant-numeric: tabular-nums; flex: none;
}
.item__x { color: var(--text-muted); padding: 6px; margin: -6px -6px -6px 0; flex: none; }
/* Подсказка «строку можно нажать» — не кнопка, вся строка и есть кнопка. */
.item__hint { color: var(--text-muted); flex: none; display: block; }
.item__life {
  font-size: 11px; font-weight: 560;
  padding: 2px 7px; border-radius: 999px;
  background: var(--surface-3); color: var(--text-muted);
  flex: none;
}
.item__life--soon { background: var(--warn-soft); color: var(--warn); }
.item__life--ok { background: var(--ok-soft); color: var(--ok); }
.item--soon .item__qty { color: var(--warn); }

.group + .group { margin-top: 20px; }
.group__head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 6px;
}

/* ── шторка снизу ───────────────────────────────────────────────────────── */
/*
   Редактор продукта и правка чека. Модальное окно, а не отдельный экран:
   человек правит одно число и остаётся там, где был. */

.sheet__veil {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(10, 7, 3, .55);
  animation: fade .18s ease;
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 61;
  max-width: 480px; margin: 0 auto;
  max-height: 88dvh; overflow-y: auto;
  background: var(--surface-1);
  border-top-left-radius: var(--r-l); border-top-right-radius: var(--r-l);
  border-top: var(--line) solid var(--border);
  padding: 10px var(--pad) calc(var(--safe-bottom) + 18px);
  animation: sheet-up .24s cubic-bezier(.22,.9,.3,1);
}
.sheet__grip {
  width: 38px; height: 4px; border-radius: 2px;
  background: var(--border-strong);
  margin: 0 auto 14px;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes sheet-up { from { translate: 0 24px; opacity: .4 } to { translate: 0; opacity: 1 } }

/* Ввод количества: крупные шаги по бокам, число посередине и редактируемое. */
.stepper {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-2);
  border-radius: var(--r);
  padding: 7px;
}
.stepper__btn {
  width: 46px; height: 46px; flex: none;
  display: grid; place-items: center;
  border-radius: var(--r-s);
  background: var(--surface-1);
  border: var(--line) solid var(--border);
  color: var(--text-primary);
}
.stepper__btn:active { background: var(--surface-3); }
.stepper__val {
  flex: 1; min-width: 0; text-align: center;
  font-size: 24px; font-weight: 660; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  outline: none; color: var(--text-primary);
}
.stepper__unit { font-size: 13px; color: var(--text-muted); flex: none; padding-right: 8px; }

.field {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-2);
  border: var(--line) solid var(--border);
  border-radius: var(--r);
  padding: 12px 14px;
}
.field input {
  flex: 1; min-width: 0; outline: none; color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.field input::-webkit-calendar-picker-indicator { filter: invert(var(--cal-invert, 1)); opacity: .5; }
:root[data-theme='light'] .field input::-webkit-calendar-picker-indicator { --cal-invert: 0; }

/* ── экран готовки ──────────────────────────────────────────────────────── */
/*
   Каркас на всю высоту, низ липкий. Раньше низ был обычным блоком в потоке:
   стоило шагу оказаться длинным — кнопка уезжала за нижнюю кромку, и её
   приходилось искать прокруткой посреди готовки. */

.cook {
  min-height: 100dvh;
  display: flex; flex-direction: column;
  max-width: 480px; margin: 0 auto;
}
.cook__top {
  padding: calc(var(--safe-top) + 12px) var(--pad) 0;
  background: var(--bg);
  position: sticky; top: 0; z-index: 5;
}
.cook__body {
  flex: 1;
  padding: 20px var(--pad) 24px;
  display: flex; flex-direction: column;
}
.cook__foot {
  position: sticky; bottom: 0;
  padding: 14px var(--pad) calc(var(--safe-bottom) + 14px);
  border-top: var(--line) solid var(--border);
  background: var(--bg);
}

.progress { height: 4px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.progress__fill {
  height: 100%; background: var(--accent);
  border-radius: 3px; transition: width .5s ease;
}

.lane {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 0;
}
.lane__name {
  font-size: 12px; font-weight: 550; color: var(--text-secondary);
  min-width: 64px; flex: none;
}
.lane__bar {
  flex: 1; height: 8px; border-radius: 4px;
  background: var(--surface-3); overflow: hidden;
}
.lane__fill {
  height: 100%; border-radius: 4px;
  background: var(--accent);
  transition: width 1s linear;
}
.lane--done .lane__fill { background: var(--ok); }
.lane__time {
  font-size: 12px; font-weight: 560; color: var(--text-secondary);
  min-width: 54px; text-align: right;
  font-variant-numeric: tabular-nums;
}
.lane--done .lane__time { color: var(--ok); }

.step__text { font-size: 22px; font-weight: 580; line-height: 1.3; letter-spacing: -.02em; }
.step__detail {
  margin-top: 12px; font-size: 14.5px; line-height: 1.5;
  color: var(--text-secondary);
}

.wait { text-align: center; padding: 40px 0; margin: auto 0; }
.wait__label { font-size: 13.5px; color: var(--text-secondary); }
.wait__time {
  font-size: 62px; font-weight: 680; letter-spacing: -.05em;
  font-variant-numeric: tabular-nums; margin: 8px 0 16px;
  color: var(--accent); line-height: 1;
}

/* ── чек ────────────────────────────────────────────────────────────────── */

.receipt__line {
  display: flex; align-items: baseline; gap: 8px;
  padding: 11px 0;
  border-bottom: var(--line) solid var(--border);
  font-size: 14.5px;
  width: 100%; text-align: left;
}
.receipt__line:last-child { border-bottom: 0; }
.receipt__dots {
  flex: 1; height: 1px; align-self: center; min-width: 12px;
  background: repeating-linear-gradient(90deg, var(--border-strong) 0 2px, transparent 2px 6px);
}
.receipt__rest { color: var(--text-muted); font-size: 12.5px; font-variant-numeric: tabular-nums; flex: none; }
.receipt__rest--out { color: var(--warn); }
.receipt__line--edited .item__qty { color: var(--accent); }

/* ── онбординг ──────────────────────────────────────────────────────────── */

.onb {
  min-height: 100dvh;
  display: flex; flex-direction: column;
  padding: calc(var(--safe-top) + 30px) var(--pad) calc(var(--safe-bottom) + 20px);
  max-width: 480px; margin: 0 auto;
}
.onb__body { flex: 1; }
.dots { display: flex; gap: 6px; margin-bottom: 28px; }
.dots i { height: 3px; flex: 1; border-radius: 2px; background: var(--surface-3); }
.dots i.on { background: var(--accent); }

/* ── переключатель ──────────────────────────────────────────────────────── */

.seg {
  display: flex; gap: 4px; padding: 4px;
  background: var(--surface-2);
  border-radius: var(--r);
}
.seg button {
  flex: 1; padding: 9px 10px;
  border-radius: var(--r-s);
  font-size: 13.5px; font-weight: 560;
  color: var(--text-secondary);
}
.seg button[aria-pressed='true'] {
  background: var(--surface-1);
  color: var(--text-primary);
  box-shadow: var(--shadow);
}

/* ── мелочи ─────────────────────────────────────────────────────────────── */

.empty {
  text-align: center; padding: 44px 20px;
  color: var(--text-muted); font-size: 14.5px; line-height: 1.5;
}
.toast {
  position: fixed; left: 50%; translate: -50% 0;
  bottom: calc(var(--tabs-h) + var(--safe-bottom) + 16px);
  max-width: 340px; padding: 12px 17px;
  background: var(--text-primary);
  color: var(--bg);
  border-radius: var(--r);
  font-size: 13.5px; font-weight: 540; text-align: center;
  z-index: 70;
  animation: rise .22s ease;
}
@keyframes rise { from { opacity: 0; translate: -50% 8px } to { opacity: 1; translate: -50% 0 } }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 300% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--r);
}
@keyframes shimmer { from { background-position: 100% 0 } to { background-position: -100% 0 } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
