:root {
  --bg: #f4eee4;
  --paper: #fbf8f2;
  --ink: #1c1916;
  --muted: #8a7f70;
  --line: #e2d8c8;
  --soft: #ece3d4;
  --terra: #b85c38;
  --terra-ink: #9a4a2c;
  --olive: #5e6b45;
  --plum: #48252f;
  --vv: #2a8a3e;
  --radius: 22px;
  --shadow: 0 1px 0 rgba(28, 25, 22, 0.04), 0 18px 40px -26px rgba(28, 25, 22, 0.35);
  --head: 'Unbounded', system-ui, sans-serif;
  --body: 'Manrope', system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 500 16px/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
}

body.locked {
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--terra);
  outline-offset: 3px;
}

h1,
h2,
h3 {
  font-family: var(--head);
  margin: 0;
  letter-spacing: -0.01em;
}

.top,
main,
.foot {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- шапка ---------- */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 18px;
  padding-bottom: 18px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 14px;
  color: inherit;
  text-decoration: none;
}

.mark {
  font: 400 48px/1 'Ephesis', cursive;
  color: var(--ink);
}

.tag {
  font: 600 11px/1 var(--head);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.pill {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 14px;
  color: var(--muted);
}

.pill b {
  color: var(--ink);
}

.pill-edit {
  color: var(--terra);
  font-weight: 700;
  margin-left: 4px;
}

/* ---------- кнопки и переключатели ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 22px;
  border-radius: 999px;
  border: 1px solid var(--ink);
  background: transparent;
  font-weight: 700;
  font-size: 15px;
  text-decoration: none;
  color: var(--ink);
  transition: background 0.15s, color 0.15s, transform 0.15s;
}

.btn:hover {
  background: var(--ink);
  color: var(--paper);
}

.btn.primary {
  background: var(--ink);
  color: var(--paper);
}

.btn.primary:hover {
  background: var(--terra);
  border-color: var(--terra);
}

.btn.big {
  min-height: 56px;
  padding: 0 28px;
  font-size: 16px;
}

.btn.vv {
  background: var(--vv);
  border-color: var(--vv);
  color: #fff;
}

.btn.vv:hover {
  background: #1f6e30;
  border-color: #1f6e30;
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.link {
  background: none;
  border: 0;
  padding: 6px 0;
  color: var(--muted);
  text-decoration: underline dotted;
  text-underline-offset: 4px;
  font-weight: 600;
}

.link:hover {
  color: var(--terra);
}

.seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  background: var(--soft);
  border-radius: 999px;
}

.seg button {
  border: 0;
  background: transparent;
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 700;
  font-size: 14px;
  color: var(--muted);
}

.seg button[aria-pressed='true'] {
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(28, 25, 22, 0.12);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
}

.chip[aria-pressed='true'] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

.badge {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--terra);
  color: #fff;
  font-size: 12px;
}

/* ---------- первый экран ---------- */

.hero {
  padding: 48px 0 32px;
  max-width: 900px;
}

.eyebrow {
  font: 600 12px/1.2 var(--head);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--terra);
  margin: 0 0 14px;
}

.hero h1 {
  font-size: clamp(36px, 6.4vw, 78px);
  line-height: 1.02;
  font-weight: 700;
}

.outline {
  color: transparent;
  -webkit-text-stroke: 1.6px var(--terra);
  paint-order: stroke fill;
}

.lead {
  font-size: clamp(17px, 1.6vw, 20px);
  color: #4a433b;
  max-width: 640px;
  margin: 22px 0 0;
}

.norm-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 28px;
  box-shadow: var(--shadow);
  max-width: 900px;
  margin-top: 8px;
}

.norm-card h2 {
  font-size: 20px;
  margin-bottom: 18px;
}

.fields {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.fields.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.input {
  display: flex;
  align-items: baseline;
  gap: 6px;
  border-bottom: 2px solid var(--line);
  transition: border-color 0.15s;
}

.input:focus-within {
  border-color: var(--terra);
}

.input input {
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 6px 0 8px;
  font: 600 28px/1.1 var(--head);
  color: var(--ink);
  -moz-appearance: textfield;
}

.input input::-webkit-outer-spin-button,
.input input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.input input:focus {
  outline: none;
}

.input input::placeholder {
  color: #cfc4b2;
}

.input em {
  font-style: normal;
  font-size: 14px;
  color: var(--muted);
}

.norm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 24px 0 10px;
}

.error {
  color: #a23b2a;
  font-weight: 600;
  margin: 14px 0 0;
}

.calc {
  margin-top: 16px;
  padding-top: 20px;
  border-top: 1px dashed var(--line);
  display: grid;
  gap: 16px;
  justify-items: start;
}

.calc .fields {
  width: 100%;
}

.calc-intro,
.calc-res {
  margin: 0;
  color: #4a433b;
}

.calc-res {
  background: var(--soft);
  border-radius: 14px;
  padding: 12px 16px;
}

.select {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  width: min(100%, 420px);
}

.select select {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg);
  padding: 12px 14px;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}

.how {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin: 48px 0 20px;
}

.how b {
  font: 600 13px/1 var(--head);
  color: var(--terra);
}

.how h3 {
  font-size: 18px;
  margin: 10px 0 6px;
}

.how p {
  margin: 0;
  color: #5b5249;
}

.facts {
  color: var(--muted);
  font-size: 14px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
  margin: 24px 0 0;
}

/* ---------- день ---------- */

.day {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-top: 8px;
}

.day-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.day-head h2 {
  font-size: 18px;
}

.day-head p {
  margin: 0;
  color: var(--muted);
}

.day-head b {
  font-family: var(--head);
  color: var(--ink);
}

.meter,
.macro i,
.vs-tile i {
  display: block;
  height: 10px;
  border-radius: 999px;
  background: var(--soft);
  overflow: hidden;
  margin-top: 12px;
}

.meter s,
.macro s,
.vs-tile s {
  display: block;
  height: 100%;
  background: var(--terra);
  border-radius: inherit;
  transition: width 0.4s;
}

.macros {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-top: 16px;
}

.macro span {
  font-size: 13px;
  color: var(--muted);
  font-weight: 700;
}

.macro b {
  display: block;
  font-family: var(--head);
  font-size: 18px;
}

.macro small {
  font-family: var(--body);
  font-size: 13px;
  color: var(--muted);
}

.macro i {
  height: 6px;
  margin-top: 6px;
}

.macro.p s,
.vs-tile.p s {
  background: var(--terra);
}

.macro.f s,
.vs-tile.f s {
  background: var(--plum);
}

.macro.c s,
.vs-tile.c s {
  background: var(--olive);
}

.eaten {
  list-style: none;
  padding: 0;
  margin: 16px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.eaten li {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--soft);
  border-radius: 999px;
  padding: 6px 6px 6px 14px;
  font-size: 14px;
  font-weight: 600;
}

.eaten span {
  color: var(--terra);
}

.eaten em {
  font-style: normal;
  color: var(--muted);
}

.eaten button {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 0;
  background: var(--paper);
  font-size: 18px;
  line-height: 1;
}

.day-empty {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 14px;
}

/* ---------- фильтры ---------- */

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 22px 0 6px;
}

.filters {
  flex-basis: 100%;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  display: grid;
  gap: 18px;
  justify-items: start;
}

.fgroup h3 {
  font-size: 13px;
  margin-bottom: 8px;
}

.fgroup p {
  margin: -4px 0 10px;
  font-size: 13px;
  color: var(--muted);
}

.fgroup.row {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
}

.target {
  margin: 18px 0 14px;
  font-size: 15px;
  color: #4a433b;
}

.target b {
  font-family: var(--head);
}

.muted {
  color: var(--muted);
}

/* ---------- карточки ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  transition: transform 0.18s, border-color 0.18s, box-shadow 0.18s;
}

.card:hover {
  transform: translateY(-3px);
  border-color: var(--terra);
  box-shadow: var(--shadow);
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.num {
  font: 500 12px/1 var(--head);
  color: var(--muted);
}

.match {
  font-weight: 800;
  font-size: 12px;
  padding: 4px 9px;
  border-radius: 999px;
}

.match.hi {
  background: var(--olive);
  color: #fff;
}

.match.mid {
  background: #ead9b6;
  color: var(--ink);
}

.match.lo {
  background: var(--soft);
  color: var(--muted);
}

.card h3 {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.28;
  min-height: 2.56em;
}

.meta {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.kbju {
  margin: auto 0 0;
  font-size: 13px;
  color: var(--muted);
}

.kbju b {
  font: 700 24px/1 var(--head);
  color: var(--ink);
}

.kbju span {
  display: block;
  margin-top: 4px;
}

.bar {
  display: flex;
  gap: 2px;
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
}

.bar .p {
  background: var(--terra);
}

.bar .f {
  background: var(--plum);
}

.bar .c {
  background: var(--olive);
}

.need {
  margin: 0;
  font-size: 13px;
  color: #5b5249;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.more {
  display: flex;
  justify-content: center;
  margin: 26px 0 8px;
}

.empty {
  background: var(--paper);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  color: var(--muted);
}

/* ---------- окно рецепта ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(28, 25, 22, 0.45);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 24px;
}

.overlay[hidden] {
  display: none;
}

.sheet {
  position: relative;
  background: var(--paper);
  border-radius: 28px;
  width: min(680px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 30px 30px 26px;
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.5);
  overscroll-behavior: contain;
}

.sheet h2 {
  font-size: clamp(22px, 3vw, 28px);
  line-height: 1.15;
  padding-right: 40px;
}

.sheet h3 {
  font-size: 15px;
  margin: 24px 0 10px;
}

.close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 0;
  background: var(--soft);
  font-size: 24px;
  line-height: 1;
}

.match-line {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.vs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.vs-tile {
  background: var(--bg);
  border-radius: 16px;
  padding: 12px;
}

.vs-tile span {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.vs-tile b {
  display: block;
  font: 700 20px/1.2 var(--head);
  margin-top: 4px;
}

.vs-tile small {
  font: 600 12px var(--body);
  color: var(--muted);
}

.vs-tile em {
  font-style: normal;
  font-size: 12px;
  color: var(--muted);
}

.vs-tile i {
  height: 5px;
  margin-top: 8px;
}

.vs-tile.k s {
  background: var(--ink);
}

.note {
  background: #f6e7dc;
  border-radius: 14px;
  padding: 12px 14px;
  margin: 14px 0 0;
  font-size: 14px;
}

.ing {
  list-style: none;
  padding: 0;
  margin: 0;
}

.ing li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 0;
  border-bottom: 1px dashed var(--line);
}

.ing b {
  white-space: nowrap;
  font-weight: 700;
}

.steps {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
  display: grid;
  gap: 12px;
}

.steps li {
  counter-increment: step;
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 12px;
}

.steps li::before {
  content: counter(step);
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--terra);
  color: #fff;
  font: 600 13px/1 var(--head);
}

.small {
  font-size: 13px;
  color: var(--muted);
  margin: 14px 0 0;
}

.sheet-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
  position: sticky;
  bottom: -26px;
  background: linear-gradient(transparent, var(--paper) 22%);
  padding: 18px 0 4px;
}

.story-img {
  display: block;
  width: auto;
  height: min(60vh, 640px);
  aspect-ratio: 9 / 16;
  margin: 18px auto 0;
  border-radius: 18px;
  box-shadow: var(--shadow);
}

/* ---------- заказ во ВкусВилле ---------- */

.portions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.portions span {
  font-weight: 700;
  font-size: 14px;
  color: var(--muted);
}

.basket {
  list-style: none;
  padding: 0;
  margin: 14px 0 0;
}

.vv-eyebrow {
  color: var(--vv);
}

.basket li {
  display: grid;
  grid-template-columns: 24px 44px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px dashed var(--line);
}

.basket img,
.basket .noimg,
.vv-found img {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  object-fit: cover;
  background: #fff;
}

.vv-found img {
  width: 40px;
  height: 40px;
}

.basket .qty em {
  font-style: normal;
  min-width: 64px;
  text-align: right;
}

.basket .link {
  padding: 0;
  font-size: 13px;
}

.basket input[type='checkbox'] {
  width: 22px;
  height: 22px;
  accent-color: var(--vv);
}

.basket .what {
  min-width: 0;
}

.basket .what b {
  display: block;
  font-size: 15px;
  overflow-wrap: anywhere;
}

.basket .what small {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.basket .qty {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  font-weight: 700;
}

.basket .qty button {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--bg);
  font-weight: 800;
}

.basket li.off .what,
.basket li.off .qty {
  opacity: 0.45;
}

.basket .home {
  color: var(--olive);
  font-weight: 700;
}

.vv-search {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.vv-search input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  padding: 12px 16px;
}

.vv-found {
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
  display: grid;
  gap: 8px;
}

.vv-found li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg);
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 14px;
}

.vv-found li span {
  flex: 1;
  min-width: 0;
}

.vv-found li b {
  white-space: nowrap;
}

.vv-found button {
  border: 0;
  border-radius: 999px;
  background: var(--vv);
  color: #fff;
  font-weight: 700;
  padding: 8px 14px;
}

.total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 18px;
  font-size: 15px;
}

.total b {
  font: 700 24px/1 var(--head);
}

/* ---------- уведомление и подвал ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 30;
  transform: translate(-50%, 140%);
  max-width: min(560px, calc(100vw - 32px));
  background: var(--ink);
  color: var(--paper);
  border-radius: 18px;
  padding: 14px 20px;
  font-weight: 600;
  font-size: 15px;
  box-shadow: 0 20px 40px -20px rgba(0, 0, 0, 0.6);
  transition: transform 0.3s;
}

.toast.show {
  transform: translate(-50%, 0);
}

.foot {
  margin-top: 56px;
  padding-bottom: 40px;
}

.foot p {
  max-width: 760px;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 16px;
  margin: 0;
}

/* ---------- адаптив ---------- */

@media (max-width: 1100px) {
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .top,
  main,
  .foot {
    padding: 0 16px;
  }

  .top {
    padding-top: 12px;
    padding-bottom: 12px;
    flex-wrap: wrap;
  }

  .mark {
    font-size: 40px;
  }

  .tag,
  .m-hide {
    display: none;
  }

  .pill {
    padding: 8px 12px;
    font-size: 13px;
  }

  .hero {
    padding: 22px 0 22px;
  }

  .norm-card {
    padding: 22px 18px;
    border-radius: 24px;
  }

  .fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    row-gap: 18px;
  }

  .fields.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .input input {
    font-size: 26px;
  }

  .norm-actions .btn,
  .more .btn,
  .sheet-actions .btn {
    flex: 1 1 100%;
    min-height: 60px;
  }

  .how {
    grid-template-columns: 1fr;
    gap: 22px;
    margin-top: 32px;
  }

  .controls {
    gap: 10px;
  }

  .seg.meals {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    width: 100%;
  }

  .seg.meals button {
    padding: 14px 4px;
    font-size: 14px;
  }

  .filters-btn {
    width: 100%;
    min-height: 52px;
  }

  .grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .card {
    padding: 18px;
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      'top top'
      'name kcal'
      'need need'
      'bar bar';
    column-gap: 14px;
  }

  .card-top {
    grid-area: top;
  }

  .card h3 {
    grid-area: name;
    font-size: 17px;
    min-height: 0;
  }

  .card .meta {
    display: none;
  }

  .kbju {
    grid-area: kcal;
    margin: 0;
    text-align: right;
  }

  .kbju b {
    display: block;
    font-size: 26px;
  }

  .need {
    grid-area: need;
  }

  .bar {
    grid-area: bar;
  }

  .overlay {
    padding: 0;
    place-items: end stretch;
  }

  .sheet {
    width: 100%;
    max-height: 92vh;
    border-radius: 24px 24px 0 0;
    padding: 24px 18px 18px;
  }

  .sheet-actions {
    bottom: -18px;
  }

  .vs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .story-img {
    height: min(56vh, 560px);
  }

  .basket li {
    grid-template-columns: 24px 44px minmax(0, 1fr);
    row-gap: 8px;
  }

  .basket .qty {
    grid-column: 2 / -1;
    justify-content: flex-end;
  }

  .basket .qty button {
    width: 38px;
    height: 38px;
  }

  .vv-found li {
    flex-wrap: wrap;
  }
}
