/* ===== Обща страница ===== */
.page { display: flex; flex-direction: column; gap: 14px; max-width: 1080px; margin: 0 auto; padding: 6px 16px 32px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.page-head .btn { margin-left: auto; }
.page-title { font-size: clamp(1.9rem, 4vw, 2.4rem); font-weight: 900; letter-spacing: -.03em; line-height: 1.05; }
.section { display: flex; flex-direction: column; gap: 10px; }
.section-title { display: flex; align-items: center; font-size: 1.1rem; font-weight: 800; letter-spacing: -.01em; margin-top: 6px; }

/* ===== Рецепта ===== */
body[data-view="recipe"] .appbar { display: none; }
.recipe { display: flex; flex-direction: column; gap: 14px; padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
.recipe-side, .recipe-main { display: flex; flex-direction: column; gap: 14px; }
.recipe-hero { position: relative; display: grid; place-items: center; height: min(40vh, 330px); min-height: 230px; padding-top: env(safe-area-inset-top); }
.hero-back { position: absolute; top: calc(12px + env(safe-area-inset-top)); left: 12px; }
.recipe-hero .fav-btn { top: calc(10px + env(safe-area-inset-top)); }
.recipe-summary { position: relative; z-index: 2; display: flex; flex-direction: column; align-items: flex-start; gap: 12px; margin: -42px 16px 0; box-shadow: var(--shadow-2); }
.recipe-title { font-size: clamp(1.7rem, 7.4vw, 2.3rem); font-weight: 900; line-height: 1.04; letter-spacing: -.03em; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; width: 100%; }
.stats div { padding: 8px 4px; border-radius: 12px; background: var(--surface-2); text-align: center; }
.stats dt { color: var(--muted); font-size: .64rem; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; }
.stats dd { font-size: .92rem; font-weight: 800; line-height: 1.25; }
.recipe-side > .panel:not(.recipe-summary), .recipe-main > .panel { margin: 0 16px; }
.recipe .panel-title + .muted { margin-top: 2px; }

.checklist { margin-top: 8px; padding: 0; list-style: none; }
.check-row {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 2px; text-align: left;
  border: 0; border-top: 1px solid var(--line); background: none; font-size: 1rem; font-weight: 600; cursor: pointer;
}
.checklist li:first-child .check-row { border-top: 0; }
.check-row small { display: inline; margin-left: 4px; color: var(--muted); font-size: .78rem; font-weight: 600; }
.box {
  display: grid; place-items: center; width: 24px; height: 24px; flex: 0 0 auto; border-radius: 8px;
  border: 2px solid var(--line-2); color: transparent; transition: background-color .15s, border-color .15s;
}
.box .i { width: 15px; height: 15px; stroke-width: 3.2; }
.check-row.done .box { border-color: var(--good); background: var(--good); color: #fff; }
.check-row.done .grow { color: var(--muted); text-decoration: line-through; }

.steps { display: flex; flex-direction: column; gap: 16px; margin-top: 14px; padding: 0; list-style: none; }
.steps li { display: flex; align-items: flex-start; gap: 14px; }
.step-n { display: grid; place-items: center; width: 32px; height: 32px; flex: 0 0 auto; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 900; }
.steps p { padding-top: 3px; font-size: 1.03rem; line-height: 1.55; }
.ext { display: inline-flex; align-items: center; gap: 8px; margin-top: 18px; color: var(--accent); font-weight: 800; text-decoration: none; }
.ext .i { width: 18px; height: 18px; }
.recipe-actions {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  padding: 18px 16px calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--bg) 72%, transparent);
}
body[data-view="recipe"] .toast { bottom: calc(96px + env(safe-area-inset-bottom)); }
.recipe-actions .wide { grid-column: 1 / -1; }
.back-link { align-self: flex-start; margin: -6px 0 -4px; color: var(--ink-2); }
@media (max-width: 959.98px) {
  .recipe, .recipe-actions { max-width: 640px; margin-left: auto; margin-right: auto; }
}
.recipe-actions .btn { padding: 0 12px; white-space: nowrap; }

/* ===== Плочки и списъци ===== */
.tile-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.tile {
  display: flex; flex-direction: column; overflow: hidden; padding: 0; text-align: left;
  border-radius: 20px; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow-1);
  cursor: pointer; transition: transform .15s, box-shadow .15s;
}
.tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); }
.tile-hero { display: grid; place-items: center; height: 116px; }
.tile-hero .plate { --size: 76px; }
.tile-body { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px 12px; }
.tile-body b { font-size: .96rem; line-height: 1.2; }
.tile-body small { color: var(--muted); font-size: .8rem; font-weight: 600; }

.list { overflow: hidden; padding: 0; list-style: none; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); }
.list.flat { margin-top: 8px; border: 0; border-radius: 0; background: none; }
.list-row {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 14px; text-align: left;
  border: 0; border-top: 1px solid var(--line); background: none; cursor: pointer;
}
.list.flat .list-row { padding: 9px 0; cursor: default; }
.list > li:first-child > .list-row, .list > .list-row:first-child { border-top: 0; }
.list-row b { display: block; font-weight: 800; }
.list-row > .i { color: var(--muted); }

.empty-note {
  display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; padding: 22px 18px; text-align: center;
  border-radius: var(--radius); border: 1.5px dashed var(--line-2); background: transparent; color: var(--muted); cursor: pointer;
}
.empty-note.static { cursor: default; }
.empty-note b { color: var(--ink); font-size: 1rem; }
.empty-note span:last-child { font-size: .88rem; }
.empty-ico { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; background: var(--accent-soft); color: var(--accent); }
button.empty-note:hover { border-color: var(--accent); }

/* ===== Настройки ===== */
.settings-grid { display: flex; flex-direction: column; gap: 14px; }
.settings-grid .panel > * + * { margin-top: 12px; }
.settings-grid .panel > .panel-title + .muted { margin-top: 4px; }
.diet-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
.diet-tile {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; cursor: pointer;
  border-radius: 16px; border: 1px solid var(--line); background: var(--surface-2); transition: border-color .15s, background-color .15s;
}
.diet-tile:has(.switch:checked) { border-color: color-mix(in srgb, var(--accent) 55%, transparent); background: var(--accent-soft); }
.diet-emoji { font-size: 26px; line-height: 1; }
.diet-tile b { font-weight: 800; }
.token-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.tchip {
  display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 14px; cursor: pointer;
  border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); font-weight: 700; font-size: .9rem;
  transition: background-color .15s, color .15s, border-color .15s;
}
.tchip .i { display: none; width: 15px; height: 15px; }
.tchip.on { border-color: var(--ink); background: var(--ink); color: var(--bg); }
.tchip.on .i { display: block; }
.switch-row { display: flex; align-items: center; gap: 12px; padding-top: 14px; border-top: 1px solid var(--line); cursor: pointer; }
.switch-row b { font-weight: 800; }
.range { width: 100%; accent-color: var(--accent); }
.range-labels { display: flex; justify-content: space-between; color: var(--muted); font-size: .82rem; font-weight: 700; }
.row-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* ===== Първо пускане ===== */
.welcome { display: flex; flex-direction: column; gap: 16px; max-width: 760px; margin: 0 auto; padding: 8px 16px 0; }
.welcome-hero { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 18px 4px 4px; text-align: center; }
.hero-plates { position: relative; display: grid; place-items: center; width: 100%; height: 196px; }
.hero-plates::before { content: ''; position: absolute; width: 340px; height: 190px; border-radius: 50%; background: radial-gradient(closest-side, var(--accent-soft), transparent); }
.hero-plates .plate { position: absolute; }
.hero-plates .p1 { --size: 168px; z-index: 2; }
.hero-plates .p2 { --size: 104px; transform: translate(-112px, 34px) rotate(-10deg); }
.hero-plates .p3 { --size: 104px; transform: translate(112px, 30px) rotate(10deg); }
.welcome h1 { font-size: clamp(2.2rem, 10vw, 3.4rem); font-weight: 900; line-height: 1; letter-spacing: -.04em; }
.lead { max-width: 32ch; color: var(--ink-2); font-size: 1.1rem; }
.how { display: grid; gap: 10px; padding: 0; list-style: none; }
.how li {
  display: grid; grid-template-columns: 44px 1fr; column-gap: 14px; align-items: center; padding: 14px;
  border-radius: 18px; border: 1px solid var(--line); background: var(--surface);
}
.how-icon { grid-row: span 2; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; background: var(--accent-soft); color: var(--accent); }
.how b { font-weight: 800; }
.how li > span:last-child { color: var(--muted); font-size: .88rem; }
.welcome .panel > * + * { margin-top: 12px; }
.welcome .panel > .panel-title + .muted { margin-top: 2px; }
.fold summary { display: flex; align-items: center; gap: 12px; list-style: none; cursor: pointer; }
.fold summary::-webkit-details-marker { display: none; }
.fold summary > .i { color: var(--muted); transition: transform .2s; }
.fold[open] summary > .i { transform: rotate(180deg); }
.fold[open] summary { margin-bottom: 14px; }
.welcome-cta { position: sticky; bottom: 0; z-index: 5; padding: 12px 0 calc(14px + env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--bg) 72%, transparent); }

/* ===== Форма за ястие ===== */
.edit-grid, .edit-col { display: flex; flex-direction: column; gap: 14px; }
.edit .panel > * + * { margin-top: 12px; }
.edit .panel > .label + * { margin-top: 6px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field small { text-transform: none; letter-spacing: 0; font-weight: 600; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.input {
  width: 100%; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line-2); background: var(--surface-2);
  font-size: 1rem; font-weight: 600; transition: border-color .15s, background-color .15s;
}
.input:focus { outline: none; border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { resize: vertical; min-height: 110px; line-height: 1.5; }
.hint { color: var(--muted); font-size: .82rem; }
.opt-grid { display: grid; grid-template-columns: repeat(var(--cols, 3), 1fr); gap: 6px; }
.opt { position: relative; }
.opt input, .emoji-opt input { position: absolute; opacity: 0; pointer-events: none; }
.opt > span {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 46px; height: 100%; padding: 8px 4px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); text-align: center; font-weight: 700; font-size: .86rem; cursor: pointer;
}
.opt-emoji { font-size: 22px; line-height: 1.1; }
.opt input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); box-shadow: inset 0 0 0 1px var(--accent); }
.opt input:focus-visible + span, .emoji-opt input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--accent) 65%, transparent); outline-offset: 2px; }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }
.emoji-opt > span { display: grid; place-items: center; aspect-ratio: 1; border-radius: 12px; border: 1px solid transparent; background: var(--surface-2); font-size: 24px; cursor: pointer; }
.emoji-opt input:checked + span { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.token-preview { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.tok { padding: 2px 10px; border-radius: 999px; background: var(--good-soft); color: var(--good); font-size: .82rem; font-weight: 800; }
.edit-actions {
  position: sticky; bottom: 0; z-index: 5; display: flex; justify-content: flex-end; gap: 8px; margin: 0 -16px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--bg) 72%, transparent);
}
.edit-actions .primary { flex: 1; max-width: 260px; }

/* ===== Компютър ===== */
@media (min-width: 640px) {
  /* minmax(0, …): иначе по-дългият текст разширява едната колона */
  .diet-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 1fr; }
  .tile-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
  .how { grid-template-columns: repeat(3, 1fr); }
  .how li { grid-template-columns: 1fr; align-content: start; row-gap: 4px; }
  .how-icon { grid-row: auto; margin-bottom: 6px; }
}
@media (min-width: 960px) {
  .page { gap: 20px; padding: 36px 32px 64px; }
  /* Редове с еднаква височина: режим | нови предложения, после "Не ям" на цяла ширина, после скрити | копие */
  .settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-flow: row dense; gap: 20px; align-items: stretch; }
  .settings-grid > .panel:nth-child(2) { grid-column: 1 / -1; }
  .recipe { display: grid; grid-template-columns: 400px minmax(0, 1fr); align-items: start; gap: 28px; max-width: 1140px; margin: 0 auto; padding: 32px 32px 64px; }
  .recipe-side { position: sticky; top: 102px; }
  .recipe-hero { height: 250px; min-height: 0; padding-top: 0; border-radius: var(--radius-l); overflow: hidden; box-shadow: var(--shadow-1); }
  .recipe-summary { margin: -48px 16px 0; }
  .recipe-side > .panel:not(.recipe-summary), .recipe-main > .panel { margin: 0; }
  .recipe-main .panel { padding: 26px 28px; }
  .steps p { font-size: 1.08rem; }
  .recipe-actions { position: static; padding: 0; background: none; }
  body[data-view="recipe"] .appbar { display: block; }
  body[data-view="recipe"] .toast { bottom: 28px; }
  .welcome { padding-top: 24px; gap: 20px; }
  .welcome-cta { position: static; padding: 4px 0 48px; display: flex; justify-content: center; }
  .welcome-cta .btn { max-width: 360px; }
  .edit-grid { display: grid; grid-template-columns: 1fr 1fr; align-items: start; gap: 20px; }
  .edit-actions { margin: 0; padding: 4px 0 0; position: static; background: none; }
}
