:root {
  --bg: #FAF8F5;
  --cream: #FFF6D8;
  --line: #EFE6D3;
  --sun: #FAD338;
  --sun-deep: #E8B90C;
  --sun-soft: #FDEBA8;
  --gold-ink: #7A5B00;
  --ink: #231F1A;
  --ink-soft: #625A50;
  --white: #FFFFFF;
  --photo-bg: #F5F0E8;
  --error: #B23A25;
  --font-display: "Montserrat", "Manrope", sans-serif;
  --font-body: "Manrope", system-ui, sans-serif;
  --font-script: "Cormorant Garamond", Georgia, serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --r-card: 24px;
  --r-field: 14px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.55 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px max(16px, env(safe-area-inset-left)) 8px;
  max-width: 760px; margin: 0 auto;
}
.brand {
  display: inline-flex; align-items: center; min-height: 44px;
  font: 900 15px/1 var(--font-display); letter-spacing: 0.04em;
  color: var(--ink); text-decoration: none;
}
.script { font-family: var(--font-script); font-style: italic; font-weight: 600; text-transform: none; letter-spacing: 0; }
.brand .script { font-size: 20px; color: var(--gold-ink); margin-right: 7px; }
.link {
  background: none; border: 0; color: var(--ink-soft); cursor: pointer; min-height: 44px; padding: 0 8px;
  text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; font-weight: 600;
}
a { color: inherit; text-underline-offset: 3px; }

main { max-width: 760px; margin: 0 auto; padding: 8px 16px 64px; }
.screen { animation: rise .5s var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }

::selection { background: var(--sun-soft); color: var(--ink); }
input { caret-color: var(--gold-ink); }
.status { margin: -6px 0 20px; font-weight: 600; color: var(--ink-soft); }
h1 {
  margin: 20px 0 16px; font: 900 clamp(32px, 9vw, 56px)/1.02 var(--font-display);
  text-transform: uppercase; letter-spacing: -0.01em;
}
h1 .script { display: block; text-transform: none; font-size: 1.05em; color: var(--gold-ink); }
h2 { margin: 0 0 10px; font: 800 18px/1.2 var(--font-display); text-transform: uppercase; letter-spacing: .02em; }
.lead { font-size: 17px; color: var(--ink-soft); max-width: 58ch; margin: 0 0 24px; }

.card {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--r-card);
  padding: 22px; margin: 0 0 14px;
}
.card-soft { background: var(--cream); border-color: transparent; }
.card p { margin: 0 0 16px; color: var(--ink-soft); }

.field { display: block; margin: 0 0 14px; }
.field > span, legend { display: block; font-weight: 700; font-size: 14px; margin: 0 0 6px; }
input[type=number], input:not([type]), input[type=text] {
  width: 100%; height: 52px; padding: 0 16px; border-radius: var(--r-field);
  border: 1.5px solid var(--line); background: var(--white); font-size: 17px;
  transition: border-color .2s;
}
input:focus-visible { outline: none; border-color: var(--sun-deep); box-shadow: 0 0 0 3px var(--sun-soft); }
#code { text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.grid3 input { padding: 0 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 54px; padding: 0 26px; border-radius: 999px; border: 0;
  background: var(--sun); color: var(--ink); cursor: pointer;
  font: 800 15px/1 var(--font-display); text-transform: uppercase; letter-spacing: .04em;
  transition: background .2s, transform .15s var(--ease);
  width: 100%; text-decoration: none;
}
.btn-big { min-height: 62px; font-size: 16px; }
.btn:hover { background: var(--sun-deep); }
.btn:active { transform: scale(.98); }
.btn:focus-visible, .seg-btn:focus-visible, .tab:focus-visible, .chips label:focus-within, .meal button:focus-visible {
  outline: 3px solid var(--ink); outline-offset: 2px;
}
.btn[disabled] { opacity: .6; cursor: progress; }
.btn-ghost { background: transparent; border: 1.5px solid var(--ink); }
.btn-ghost:hover { background: var(--ink); color: var(--bg); }
.btn-small { min-height: 44px; padding: 0 16px; font-size: 12px; width: auto; white-space: nowrap; }

.error { color: var(--error); font-weight: 600; margin: 12px 0 0; }
.hint { color: var(--ink-soft); font-size: 14px; margin: 0 0 14px; }
.disclaimer { font-size: 13px; color: var(--ink-soft); margin: 18px 0; }

.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--white); border: 1px solid var(--line); border-radius: 999px; padding: 4px; margin: 0 0 20px; }
.seg-btn { border: 0; background: none; border-radius: 999px; min-height: 44px; font-weight: 700; cursor: pointer; }
.seg-btn[aria-pressed=true] { background: var(--ink); color: var(--bg); }

fieldset { border: 0; margin: 0 0 16px; padding: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips legend { width: 100%; margin-bottom: 8px; }
.chips label { position: relative; cursor: pointer; }
.chips input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chips span {
  display: inline-block; padding: 10px 14px; border-radius: 999px;
  background: var(--white); border: 1.5px solid var(--line); font-weight: 600; font-size: 14px;
  transition: background .15s, border-color .15s;
}
.chips input:checked + span { background: var(--sun-soft); border-color: var(--sun-deep); }
#excl input:checked + span { background: var(--ink); color: var(--bg); border-color: var(--ink); text-decoration: line-through; text-decoration-thickness: 1.5px; }

.check { display: flex; gap: 10px; align-items: center; min-height: 44px; margin: -4px 0 12px; font-size: 14px; color: var(--ink-soft); cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--ink); }
input[aria-invalid=true] { border-color: var(--error); box-shadow: 0 0 0 3px #F6D5CE; }

/* Вхід */
.start { margin: 4px 0 28px; }
.start .hint { margin: 10px 0 0; text-align: center; }
.coach {
  display: grid; grid-template-columns: 92px 1fr; gap: 16px; align-items: center;
  margin: 0 0 22px; padding: 14px; background: var(--cream); border-radius: var(--r-card);
}
.coach img { width: 92px; height: 115px; object-fit: cover; border-radius: 16px; }
.coach blockquote { margin: 0; }
.coach blockquote p { margin: 0 0 8px; font: italic 600 21px/1.32 var(--font-script); color: var(--ink); }
.coach figcaption { font-size: 13px; color: var(--ink-soft); }
.have-code { border-top: 1px solid var(--line); padding-top: 6px; }
.have-code summary {
  cursor: pointer; min-height: 48px; display: flex; align-items: center; font-weight: 700;
  list-style: none; text-decoration: underline; text-underline-offset: 3px;
}
.have-code summary::-webkit-details-marker { display: none; }
.have-code[open] summary { text-decoration: none; }
.have-code form { padding: 6px 0 12px; }

.norm {
  display: grid; grid-template-columns: auto 1fr; align-items: baseline; column-gap: 12px;
  background: var(--sun); border-radius: var(--r-card); padding: 18px 22px; margin: 6px 0 22px;
}
.norm-label { grid-column: 1 / -1; font: 700 12px/1 var(--font-display); text-transform: uppercase; letter-spacing: .1em; }
.norm-num { font: 900 clamp(44px, 12vw, 64px)/1 var(--font-display); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.norm-unit { font-weight: 700; }
.norm .hint { grid-column: 1 / -1; margin: 8px 0 0; color: var(--ink); }

/* Меню */
.menu-head { display: flex; justify-content: space-between; align-items: end; gap: 12px; flex-wrap: wrap; }
.h-menu { margin-bottom: 8px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.tabs {
  display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 12px; margin: 0 -16px; padding-inline: 16px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto; min-width: 54px; min-height: 54px; padding: 6px 12px; border-radius: 18px;
  border: 1.5px solid var(--line); background: var(--white); cursor: pointer;
  font: 800 13px/1.1 var(--font-display); text-transform: uppercase;
}
.tab small { display: block; font: 600 11px/1.2 var(--font-body); text-transform: none; color: var(--ink-soft); }
.tab[aria-current=true] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.tab[aria-current=true] small { color: var(--sun-soft); }
.tab.locked { background: transparent; border-style: dashed; color: var(--ink-soft); }
.ico { width: 14px; height: 14px; display: inline-block; vertical-align: -2px; }


.day-total {
  display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: baseline;
  padding: 14px 0; border-bottom: 1px solid var(--line); margin-bottom: 14px; font-variant-numeric: tabular-nums;
}
.day-total strong { font: 900 26px/1 var(--font-display); }
.legend { flex-basis: 100%; font-size: 12px; color: var(--ink-soft); }
.macro { color: var(--ink-soft); font-weight: 600; font-size: 14px; }

.meal {
  display: grid; grid-template-columns: 104px 1fr; gap: 14px;
  background: var(--white); border: 1px solid var(--line); border-radius: var(--r-card);
  padding: 12px; margin-bottom: 12px; transition: opacity .25s;
}
.meal.loading { opacity: .4; }
.meal.swapped { border-color: var(--sun-deep); box-shadow: 0 0 0 3px var(--sun-soft), 0 8px 24px rgba(122, 91, 0, .12); }
.meal-photo { width: 104px; height: 104px; border-radius: 16px; object-fit: contain; background: var(--photo-bg); }
.meal-photo.none { display: grid; place-items: center; font: italic 600 15px/1.2 var(--font-script); color: var(--gold-ink); text-align: center; padding: 8px; }
.meal-slot { font: 700 11px/1 var(--font-display); text-transform: uppercase; letter-spacing: .1em; color: var(--gold-ink); margin: 4px 0 6px; }
.meal-title { font: 800 15px/1.25 var(--font-display); text-transform: uppercase; margin: 0 0 6px; }
.meal-kcal { font-weight: 700; font-variant-numeric: tabular-nums; }
.meal-portion { font-size: 13px; color: var(--ink-soft); }
.meal-btns { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.meal-btns button[disabled] { opacity: .55; cursor: not-allowed; }
.meal-btns button {
  min-height: 44px; padding: 0 14px; border-radius: 999px; border: 1.5px solid var(--line);
  background: var(--bg); font-weight: 700; font-size: 13px; cursor: pointer;
}
.meal-btns button:hover { border-color: var(--ink); }
.recipe { grid-column: 1 / -1; border-top: 1px dashed var(--line); padding-top: 12px; }
.recipe h3 { font: 800 13px/1 var(--font-display); text-transform: uppercase; letter-spacing: .06em; margin: 12px 0 8px; }
.recipe ul, .recipe ol { margin: 0; padding-left: 20px; }
.recipe li { margin-bottom: 4px; }
.recipe .sub { list-style: none; margin-left: -20px; font-weight: 700; margin-top: 6px; }
.recipe-close {
  margin-top: 14px; min-height: 44px; width: 100%; border-radius: 999px; border: 1.5px solid var(--line);
  background: var(--bg); font-weight: 700; cursor: pointer;
}
.recipe .tip { background: var(--cream); padding: 10px 14px; border-radius: 14px; font-size: 14px; }
.recipe-photo { border-radius: 18px; margin-bottom: 4px; width: 100%; max-height: 240px; object-fit: contain; background: var(--photo-bg); }

.warn { background: var(--cream); border: 1px solid var(--sun-soft); padding: 12px 14px; border-radius: 14px; font-size: 14px; margin: 0 0 14px; }

.foot { text-align: center; padding: 8px 16px 96px; font-size: 13px; }
.foot a { color: var(--ink-soft); }

/* Покупки */
.shop-group { background: var(--white); border: 1px solid var(--line); border-radius: var(--r-card); padding: 6px 18px; margin-bottom: 12px; }
.shop-item { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.shop-item:last-child { border-bottom: 0; }
.shop-item input { width: 22px; height: 22px; accent-color: var(--ink); flex: none; }
.shop-item .name { flex: 1; }
.shop-item .qty { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.shop-item:has(input:checked) .name, .shop-item:has(input:checked) .qty { text-decoration: line-through; color: var(--ink-soft); }
.shop-tools { display: flex; gap: 8px; margin: 4px 0 14px; }

.upsell {
  display: grid; grid-template-columns: 96px 1fr; gap: 16px; align-items: start;
  background: var(--cream); border-radius: var(--r-card); padding: 18px; margin: 22px 0 8px;
}
.upsell-photo { width: 96px; height: 120px; object-fit: cover; border-radius: 16px; }
.upsell h2 { margin-bottom: 8px; }
.upsell p { margin: 0 0 14px; color: var(--ink-soft); }
.upsell .link { display: block; margin: 6px auto 0; }
.upsell-coach { font-size: 14px; margin: 10px 0 0 !important; text-align: center; }
.upsell-coach a { font-weight: 700; color: var(--ink); }
@media (max-width: 420px) {
  .upsell { grid-template-columns: 1fr; }
  .upsell-photo { width: 100%; height: 168px; object-position: 50% 30%; }
}

/* Дії в зоні великого пальця */
.actions {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; gap: 8px; justify-content: center;
  margin: 16px -16px 0; padding: 12px 16px max(12px, env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, rgba(250, 248, 245, 0));
}
.actions .btn-ghost { background: var(--bg); }
.actions .btn-ghost:hover { background: var(--ink); color: var(--bg); }

.toast {
  position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  width: max-content; max-width: calc(100vw - 32px); text-align: center;
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 18px; font-weight: 600;
  box-shadow: 0 8px 24px rgba(35, 31, 26, .18); animation: rise .3s var(--ease); z-index: 10;
}

@media (min-width: 640px) {
  main { padding-top: 24px; }
  .btn { width: auto; }
  .meal { grid-template-columns: 150px 1fr; padding: 14px; }
  .meal-photo { width: 150px; height: 150px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print {
  .top, .actions, .tabs, .upsell, .shop-tools, #day, .status { display: none !important; }
  #shop { display: block !important; }
  body { background: #fff; }
  .shop-group { border: 0; padding: 0; }
}
