:root {
  --bg: #f7f5f4;
  --surface: #ffffff;
  --ink: #191718;
  --muted: #777173;
  --line: #e8e2e1;
  --red: #c91f2c;
  --red-dark: #a91520;
  --red-soft: #fcebed;
  --black: #211d1e;
  --shadow: 0 14px 35px rgba(37, 25, 27, 0.09);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button, input { font: inherit; }
button { cursor: pointer; }

#app {
  width: 100%;
  min-height: 100dvh;
  max-width: 620px;
  margin: auto;
  background: var(--bg);
}

.splash {
  min-height: 100dvh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  color: var(--black);
}

.splash-mark, .brand-mark {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  color: white;
  border-radius: 18px;
  background: var(--red);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 28px;
  font-weight: 700;
  box-shadow: 0 10px 25px rgba(201, 31, 44, 0.25);
}

.splash p { margin: 10px 0 0; font-size: 12px; font-weight: 800; letter-spacing: 0.11em; }
.splash span { color: var(--muted); font-size: 14px; }

.app-shell { min-height: 100dvh; padding: calc(12px + var(--safe-top)) 16px calc(90px + var(--safe-bottom)); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.topbar-brand { display: flex; gap: 10px; align-items: center; }
.topbar-brand .brand-mark { width: 38px; height: 38px; border-radius: 13px; font-size: 22px; }
.topbar-name { display: block; font-size: 11px; font-weight: 800; letter-spacing: .08em; }
.topbar-sub { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }

.avatar {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  background: #262122;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.page { animation: enter .22s ease-out; }
@keyframes enter { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

.eyebrow { margin: 0 0 5px; color: var(--red); font-size: 11px; font-weight: 800; letter-spacing: .1em; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-family: Georgia, "Times New Roman", serif; font-size: 29px; letter-spacing: -.045em; line-height: 1.04; }
h2 { margin: 0; font-size: 19px; letter-spacing: -.04em; }
h3 { margin: 0; font-size: 15px; letter-spacing: -.02em; }
.subtle { color: var(--muted); font-size: 14px; line-height: 1.45; }

.hero {
  position: relative;
  overflow: hidden;
  min-height: 178px;
  margin: 18px 0 20px;
  padding: 22px;
  border-radius: 26px;
  color: #fff;
  background: linear-gradient(143deg, #2b2224 0%, #601a24 55%, #c91f2c 145%);
  box-shadow: 0 18px 34px rgba(87, 20, 29, .23);
}
.hero::after { content: ""; position: absolute; width: 200px; height: 200px; right: -70px; bottom: -100px; border: 1px solid rgba(255,255,255,.25); border-radius: 50%; box-shadow: 0 0 0 20px rgba(255,255,255,.07), 0 0 0 45px rgba(255,255,255,.04); }
.hero h2 { position: relative; z-index: 1; max-width: 220px; font-family: Georgia, "Times New Roman", serif; font-size: 27px; line-height: 1.08; }
.hero p { position: relative; z-index: 1; max-width: 220px; margin: 9px 0 0; color: rgba(255,255,255,.75); font-size: 13px; line-height: 1.4; }
.access-pill { display: inline-flex; gap: 7px; align-items: center; position: relative; z-index: 1; padding: 6px 9px; margin-bottom: 13px; border-radius: 100px; background: rgba(255,255,255,.14); color: rgba(255,255,255,.96); font-size: 11px; font-weight: 700; }
.hero-kcal { position: absolute; z-index: 1; right: 22px; top: 26px; text-align: right; }
.hero-kcal b { display: block; font-size: 25px; letter-spacing: -.05em; }
.hero-kcal span { color: rgba(255,255,255,.7); font-size: 11px; }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 26px 0 12px; }
.section-head button { padding: 0; border: 0; background: transparent; color: var(--red); font-size: 13px; font-weight: 800; }
.head-actions { display: flex; align-items: center; justify-content: end; gap: 11px; }
.section-head .favorite-filter { padding: 6px 9px; border: 1px solid #ecd3d6; border-radius: 99px; background: #fff; color: var(--red-dark); font-size: 11px; }
.section-head .favorite-filter.active { border-color: var(--red); background: var(--red); color: #fff; }
.section-label { color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }

.action-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.action {
  min-height: 94px;
  padding: 13px 10px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 5px 14px rgba(39,25,27,.03);
}
.action strong { display: block; margin-top: 13px; font-size: 12px; line-height: 1.12; }
.action span { color: var(--red); font-size: 24px; line-height: 1; }

.today-card, .info-card, .settings-card, .shopping-group, .recipe-card {
  border: 1px solid var(--line);
  border-radius: 21px;
  background: var(--surface);
  box-shadow: 0 5px 14px rgba(39,25,27,.025);
}
.today-card { padding: 16px; }
.today-meta { display: flex; align-items: center; justify-content: space-between; margin-bottom: 13px; }
.today-meta span { color: var(--muted); font-size: 12px; }
.nutrition-row { display: flex; gap: 8px; flex-wrap: wrap; }
.nutrition-chip { padding: 7px 9px; border-radius: 10px; background: #f6f3f2; color: #4a4243; font-size: 11px; font-weight: 700; }
.meal-list { display: grid; gap: 8px; }
.meal-row { border-top: 1px solid var(--line); }
.meal-row:first-child { border-top: 0; }
.meal-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 0; border: 0; border-top: 1px solid var(--line); background: transparent; color: var(--ink); text-align: left; }
.meal-row .meal-item { border-top: 0; }
.meal-time { display: grid; flex: 0 0 36px; width: 36px; height: 36px; place-items: center; border-radius: 12px; background: var(--red-soft); font-size: 17px; }
.meal-copy { min-width: 0; flex: 1; }
.meal-copy small { display: block; color: var(--muted); font-size: 11px; }
.meal-copy strong { display: block; overflow: hidden; margin-top: 2px; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.meal-kcal { color: var(--muted); font-size: 11px; font-weight: 700; }
.replace-meal { margin: -1px 0 9px 48px; padding: 5px 0; border: 0; background: transparent; color: var(--red); font-size: 11px; font-weight: 800; }
.replace-meal:disabled { color: var(--muted); }
.plan-link { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; text-align: left; }
.plan-link span { color: var(--red); font-size: 18px; }
.plan-days { display: flex; gap: 7px; overflow-x: auto; padding: 16px 0 12px; scrollbar-width: none; }
.plan-days::-webkit-scrollbar { display: none; }
.plan-day { display: grid; min-width: 48px; place-items: center; gap: 2px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 14px; background: #fff; color: var(--muted); }
.plan-day small { font-size: 10px; font-weight: 700; text-transform: capitalize; }
.plan-day strong { color: var(--ink); font-size: 16px; }
.plan-day.active { border-color: var(--red); background: var(--red); color: rgba(255,255,255,.78); }
.plan-day.active strong { color: #fff; }
.plan-note { margin: 12px 3px 16px; }

.empty { padding: 25px 18px; text-align: center; border: 1px dashed #d7cecf; border-radius: 22px; background: #fbfafa; }
.empty .empty-icon { display: grid; width: 48px; height: 48px; place-items: center; margin: 0 auto 12px; border-radius: 16px; background: var(--red-soft); font-size: 23px; }
.empty h3 { margin-bottom: 6px; }
.empty p { margin: 0 0 14px; color: var(--muted); font-size: 13px; line-height: 1.4; }

.primary, .secondary, .ghost, .outline {
  min-height: 46px;
  padding: 0 16px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 800;
  transition: transform .15s ease, background .15s ease;
}
.primary:active, .secondary:active, .ghost:active, .outline:active { transform: scale(.98); }
.primary { border: 1px solid var(--red); background: var(--red); color: #fff; }
.primary:hover { background: var(--red-dark); }
.secondary { border: 1px solid #efe0e1; background: var(--red-soft); color: var(--red-dark); }
.outline { border: 1px solid var(--line); background: #fff; color: var(--ink); }
.ghost { border: 0; background: transparent; color: var(--red); }
.full { width: 100%; }

.nav {
  position: fixed;
  z-index: 20;
  bottom: 0;
  left: 50%;
  display: flex;
  width: min(100%, 620px);
  min-height: calc(68px + var(--safe-bottom));
  padding: 8px 8px calc(8px + var(--safe-bottom));
  transform: translateX(-50%);
  border-top: 1px solid rgba(220,211,211,.9);
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(18px);
}
.nav button { flex: 1; display: grid; gap: 4px; place-items: center; padding: 5px 1px; border: 0; background: transparent; color: #8c8586; font-size: 10px; font-weight: 700; }
.nav button span { font-size: 19px; line-height: 1; }
.nav button.active { color: var(--red); }

.filters { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 4px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filter-chip { flex: 0 0 auto; min-height: 34px; padding: 0 12px; border: 1px solid var(--line); border-radius: 100px; background: #fff; color: #5d5657; font-size: 12px; font-weight: 700; }
.filter-chip.active { border-color: var(--red); background: var(--red); color: #fff; }
.search { position: relative; margin: 14px 0 11px; }
.search input { width: 100%; height: 47px; padding: 0 16px 0 40px; border: 1px solid var(--line); border-radius: 15px; outline: none; background: #fff; color: var(--ink); font-size: 14px; }
.search input:focus { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.search::before { content: "⌕"; position: absolute; z-index: 1; top: 9px; left: 14px; color: #807879; font-size: 26px; line-height: 1; }

.recipe-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.recipe-card { overflow: hidden; text-align: left; }
.recipe-card:active { transform: scale(.985); }
.recipe-photo { position: relative; display: grid; min-height: 132px; place-items: end start; overflow: hidden; padding: 11px; background: linear-gradient(135deg, #f8dfe1, #e6b3b9); }
.recipe-photo::before { content: ""; position: absolute; width: 150px; height: 150px; right: -70px; top: -60px; border-radius: 50%; border: 1px solid rgba(123, 26, 37, .23); box-shadow: 0 0 0 14px rgba(255,255,255,.14), 0 0 0 35px rgba(255,255,255,.12); }
.recipe-photo.plum { background: linear-gradient(135deg,#e9dce8,#c7a8c6); }
.recipe-photo.berry { background: linear-gradient(135deg,#f7e2e5,#dbb4bd); }
.recipe-photo.wine { background: linear-gradient(135deg,#eddde1,#b88490); }
.recipe-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.recipe-photo.photo-loaded .photo-placeholder { display: none; }
.photo-placeholder { position: relative; z-index: 1; max-width: 110px; color: rgba(62,23,29,.75); font-size: 9px; font-weight: 800; letter-spacing: .085em; line-height: 1.3; }
.recipe-card-body { padding: 11px; }
.recipe-card-title { display: -webkit-box; min-height: 33px; overflow: hidden; margin: 0 0 8px; color: var(--ink); font-size: 13px; font-weight: 800; line-height: 1.25; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.recipe-card-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; }
.recipe-card-meta b { color: var(--ink); }

.sheet { position: fixed; z-index: 50; inset: 0; display: flex; align-items: end; background: rgba(20,16,17,.48); }
.sheet-panel { width: min(100%, 620px); max-height: 94dvh; margin: auto; overflow: auto; padding: 14px 16px calc(20px + var(--safe-bottom)); border-radius: 27px 27px 0 0; background: var(--bg); animation: sheet-in .24s ease-out; }
@keyframes sheet-in { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-grabber { width: 38px; height: 4px; margin: 0 auto 14px; border-radius: 99px; background: #d5cecf; }
.sheet-top { display: flex; justify-content: space-between; align-items: start; gap: 10px; }
.icon-button { display: grid; width: 38px; height: 38px; place-items: center; flex: 0 0 auto; border: 1px solid var(--line); border-radius: 50%; background: #fff; color: var(--ink); font-size: 18px; }
.detail-photo { position: relative; min-height: 235px; margin: 16px 0; overflow: hidden; border-radius: 22px; background: linear-gradient(135deg,#f8dfe1,#cf9ca5); }
.detail-photo::after { content: "ФОТО БЛЮДА"; position: absolute; left: 17px; bottom: 16px; color: rgba(62,23,29,.7); font-size: 10px; font-weight: 800; letter-spacing: .12em; }
.detail-photo.photo-loaded::after { display: none; }
.detail-photo img { width: 100%; height: 235px; object-fit: cover; }
.detail-photo.photo-loaded img + .photo-placeholder { display: none; }
.detail-photo .photo-placeholder { position: absolute; top: 22px; left: 18px; max-width: 160px; font-size: 11px; }
.detail-title { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 27px; letter-spacing: -.05em; line-height: 1.02; }
.detail-desc { margin: 9px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.stats { display: grid; grid-template-columns: 1.2fr repeat(3, 1fr); gap: 7px; margin: 15px 0; }
.stat { padding: 10px 8px; border-radius: 13px; background: #fff; text-align: center; }
.stat b { display: block; font-size: 14px; letter-spacing: -.03em; }
.stat span { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.people-selector { display: flex; align-items: center; justify-content: space-between; gap: 9px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 16px; background: #fff; }
.people-selector div { text-align: center; }
.people-selector b { display: block; font-size: 15px; }
.people-selector small { color: var(--muted); font-size: 10px; }
.round { display: grid; width: 34px; height: 34px; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--red); font-size: 22px; }
.detail-section { margin-top: 23px; }
.detail-section h3 { margin-bottom: 10px; }
.ingredient-list, .steps { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.ingredient-list li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.ingredient-list li span:last-child { flex: 0 0 auto; color: var(--muted); text-align: right; }
.steps { counter-reset: step; }
.steps li { position: relative; min-height: 36px; padding: 2px 0 3px 39px; color: #443e3f; font-size: 13px; line-height: 1.43; }
.steps li::before { content: counter(step); counter-increment: step; position: absolute; left: 0; top: 0; display: grid; width: 26px; height: 26px; place-items: center; border-radius: 9px; background: var(--red-soft); color: var(--red-dark); font-size: 11px; font-weight: 800; }

.plan-chooser { display: grid; gap: 14px; }
.choice-row { display: flex; gap: 8px; flex-wrap: wrap; }
.choice { min-width: 56px; height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); font-size: 12px; font-weight: 800; }
.choice.active { border-color: var(--red); background: var(--red); color: #fff; }
.small-note { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.4; }

.shopping-group { padding: 14px; margin-bottom: 10px; }
.shopping-group h3 { margin-bottom: 8px; font-size: 13px; }
.shopping-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.shopping-item:first-of-type { border-top: 0; }
.check { position: relative; width: 22px; height: 22px; flex: 0 0 auto; border: 1.5px solid #c6bdbf; border-radius: 7px; background: #fff; }
.check.done { border-color: var(--red); background: var(--red); }
.check.done::after { content: "✓"; position: absolute; left: 5px; top: 1px; color: #fff; font-size: 14px; font-weight: 800; }
.shopping-copy { min-width: 0; flex: 1; }
.shopping-copy b { display: block; font-size: 13px; }
.shopping-copy span { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.shopping-item.done .shopping-copy { opacity: .46; text-decoration: line-through; }

.settings-card { padding: 16px; margin-bottom: 10px; }
.settings-card h3 { margin-bottom: 6px; }
.settings-card p { margin: 0 0 13px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.access-card { padding: 17px; border-radius: 21px; background: var(--black); color: #fff; }
.access-card p { margin: 6px 0 15px; color: rgba(255,255,255,.67); font-size: 13px; line-height: 1.4; }
.access-card .secondary { background: #fff; color: var(--black); }
.access-card .primary { border-color: #fff; }

.toast { position: fixed; z-index: 90; bottom: calc(80px + var(--safe-bottom)); left: 50%; max-width: calc(100% - 32px); padding: 11px 14px; transform: translateX(-50%); border-radius: 13px; background: #272223; color: #fff; box-shadow: var(--shadow); font-size: 13px; font-weight: 600; }
.error-screen { min-height: 100dvh; display: grid; place-content: center; padding: 24px; text-align: center; }
.error-screen .brand-mark { margin: 0 auto 18px; }
.error-screen h1 { font-size: 25px; }
.error-screen p { color: var(--muted); font-size: 14px; line-height: 1.45; }

@media (min-width: 680px) {
  body { background: radial-gradient(circle at 30% 8%, rgba(201,31,44,.1), transparent 33rem), #eae5e5; }
  #app { min-height: 100dvh; box-shadow: 0 0 60px rgba(25,20,20,.12); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
