:root {
  --bg:#fff6f9;
  --surface:#ffffff;
  --surface-2:#fdebf2;
  --text:#3b2330;
  --muted:#94707f;
  --line:#f5d9e5;
  --accent:#e0457b;
  --accent-soft:#fde2ec;
  --on-accent: #ffffff;
  --gold: #d9a520;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(58, 42, 34, .06), 0 6px 18px rgba(58, 42, 34, .06);

  /* Отступы от вырезов экрана: iPhone (чёлка, полоска «домой») и Android (жесты) */
  --safe-top: max(env(safe-area-inset-top, 0px), var(--tg-safe-area-inset-top, 0px));
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
  --content-top: var(--tg-content-safe-area-inset-top, 0px);
  --tabbar-h: 62px;
}

:root[data-theme="dark"] {
  --bg:#1a1015;
  --surface:#26171f;
  --surface-2:#321f29;
  --text:#fbeaf1;
  --muted:#c09aab;
  --line:#44293a;
  --accent:#ff7aa8;
  --accent-soft:#45202f;
  --on-accent: #1a0c12;
  --gold: #f2c94c;
  --shadow: none;
}

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

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 Montserrat, -apple-system, BlinkMacSystemFont, "SF Pro Text", Roboto, "Segoe UI", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.view {
  padding: calc(var(--safe-top) + var(--content-top) + 12px) 16px calc(var(--tabbar-h) + var(--safe-bottom) + 24px);
  max-width: 720px;
  margin: 0 auto;
  min-height: 100vh;
}

/* ---------- шапка ---------- */
.brand { display: flex; align-items: center; gap: 12px; margin: 4px 0 16px; }
.brand img { width: 44px; height: 44px; flex: none; }
.brand h1 { margin: 0; font-size: 20px; letter-spacing: .2px; }
.brand p { margin: 0; color: var(--muted); font-size: 13px; }

.page-title { font-size: 24px; margin: 8px 0 14px; line-height: 1.2; }
.section-title { font-size: 17px; margin: 22px 0 10px; }

/* ---------- плашки ---------- */
.banner {
  background: var(--accent-soft);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 14px;
  display: flex; gap: 12px; align-items: center; justify-content: space-between;
}
.banner p { margin: 0; font-size: 14px; }

.btn {
  border: 0; border-radius: 14px; padding: 12px 18px;
  background: var(--accent); color: var(--on-accent); font-weight: 600;
  white-space: nowrap;
}
.btn.ghost { background: var(--surface-2); color: var(--text); }
.btn.block { display: block; width: 100%; text-align: center; margin-top: 12px; }

/* ---------- поиск и фильтры ---------- */
.search {
  width: 100%; border: 1px solid var(--line); background: var(--surface);
  border-radius: 14px; padding: 12px 14px; outline: none; font-size: 16px; /* 16px — чтобы iPhone не зумил поле */
}
.search:focus { border-color: var(--accent); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 12px 0 4px; margin: 0 -16px; padding-inline: 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: 8px 14px; font-size: 14px;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* ---------- карточки ---------- */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.card {
  background: var(--surface); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); display: flex; flex-direction: column; position: relative;
}
.card .cover { aspect-ratio: 4 / 3; font-size: 44px; }
.card .body { padding: 10px 12px 12px; }
.card h3 { font-size: 14.5px; margin: 0 0 4px; line-height: 1.25; }
.card .meta { font-size: 12px; color: var(--muted); }
.badge {
  position: absolute; top: 8px; left: 8px; font-size: 11px; font-weight: 700;
  background: rgba(255, 255, 255, .92); color: #3a2a22; padding: 3px 8px; border-radius: 999px;
}
.badge.free { background: var(--gold); color: #3a2a22; }

.cover { display: grid; place-items: center; background-size: cover; background-position: center; }
.tone-berry { background-image: linear-gradient(135deg, #fcd5e0, #e98aa5); }
.tone-cream { background-image: linear-gradient(135deg, #fdf0dc, #f0cf9f); }
.tone-choco { background-image: linear-gradient(135deg, #e3c7b4, #8d5b45); }
.tone-mint  { background-image: linear-gradient(135deg, #d6f2e7, #86cfb3); }
.tone-sky   { background-image: linear-gradient(135deg, #dcebfb, #94bfeb); }
.tone-gold  { background-image: linear-gradient(135deg, #fcebbb, #e2b84e); }

.hscroll { display: flex; gap: 12px; overflow-x: auto; margin: 0 -16px; padding: 0 16px 4px; scrollbar-width: none; scroll-snap-type: x mandatory; }
.hscroll::-webkit-scrollbar { display: none; }
.course-card {
  flex: none; width: 78%; max-width: 320px; scroll-snap-align: start;
  border-radius: var(--radius); padding: 16px; min-height: 120px;
  display: flex; flex-direction: column; justify-content: flex-end; color: #3a2a22;
}
.course-card .emoji { font-size: 34px; margin-bottom: auto; }
.course-card h3 { margin: 8px 0 2px; font-size: 18px; }
.course-card p { margin: 0; font-size: 13px; opacity: .8; }

.list { display: flex; flex-direction: column; gap: 10px; }
.row {
  display: flex; gap: 12px; align-items: center; background: var(--surface);
  border-radius: var(--radius); padding: 10px; box-shadow: var(--shadow);
}
.row .cover { width: 64px; height: 64px; border-radius: 14px; font-size: 28px; flex: none; }
.row h3 { font-size: 15px; margin: 0 0 2px; }
.row .meta { font-size: 12.5px; color: var(--muted); }
.row .num {
  width: 28px; height: 28px; border-radius: 50%; background: var(--surface-2);
  display: grid; place-items: center; font-size: 13px; font-weight: 700; flex: none;
}
.row .num.done { background: var(--accent); color: var(--on-accent); }

.empty { text-align: center; color: var(--muted); padding: 40px 12px; }

/* ---------- страница рецепта ---------- */
.hero { margin: 0 -16px 16px; aspect-ratio: 16 / 9; font-size: 72px; }
.hero.photo { aspect-ratio: 4 / 5; }
.cover.photo { background-position: center 45%; }
@media (min-width: 720px) { .hero { margin: 0 0 16px; border-radius: var(--radius); } }
.item-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.item-head h1 { margin: 0 0 6px; font-size: 23px; line-height: 1.2; }
.fav-btn { border: 0; background: var(--surface-2); border-radius: 50%; width: 44px; height: 44px; font-size: 20px; flex: none; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 4px; }
.pill { font-size: 12.5px; background: var(--surface-2); padding: 4px 10px; border-radius: 999px; color: var(--muted); }

.panel { background: var(--surface); border-radius: var(--radius); padding: 14px 16px; margin-top: 14px; box-shadow: var(--shadow); }
.panel h2 { font-size: 17px; margin: 0 0 10px; }

.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 3px; margin-bottom: 12px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 8px 4px; border-radius: 10px; font-size: 13.5px; }
.seg button.on { background: var(--surface); box-shadow: var(--shadow); font-weight: 600; }

.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.field input, .field select, textarea {
  width: 100%; border: 1px solid var(--line); background: var(--bg);
  border-radius: 12px; padding: 10px 12px; font-size: 16px; outline: none;
}
.field input:focus, .field select:focus, textarea:focus { border-color: var(--accent); }
.factor { margin-top: 10px; font-size: 14px; color: var(--muted); }
.factor b { color: var(--accent); font-size: 16px; }

.ing-group { font-size: 12.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 12px 0 4px; }
.ing { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.ing:last-child { border-bottom: 0; }
.ing .q { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ing .q.changed { color: var(--accent); }

.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; }
.steps li { counter-increment: s; position: relative; padding: 0 0 12px 38px; }
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: 0; width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 13px; display: grid; place-items: center;
}
.tip { background: var(--accent-soft); border-radius: 14px; padding: 12px 14px; font-size: 14.5px; margin-top: 10px; }

.locked { text-align: center; padding: 22px 16px; }
.locked .lock { font-size: 36px; }

/* ---------- таббар ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: space-around;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + var(--safe-bottom));
}
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); padding: 4px 0; }
.tabbar .ti { font-size: 21px; line-height: 1; filter: grayscale(1); opacity: .7; }
.tabbar a.on { color: var(--accent); font-weight: 600; }
.tabbar a.on .ti { filter: none; opacity: 1; }
body.hide-tabbar .tabbar { display: none; }

.loader { text-align: center; padding: 80px 0; color: var(--muted); }

/* ---------- оформление в духе Secret Chat: капс-заголовки, раскрывашки, серые карточки ---------- */
.brand h1, .page-title, .item-title, .card h3, .course-card h3 { font-weight: 800; }
.section-title { font-weight: 800; text-transform: uppercase; font-size: 15px; letter-spacing: .4px; }

.item-card { background: var(--surface); border-radius: 22px 22px var(--radius) var(--radius); margin: -34px -4px 6px; padding: 18px 16px 16px; position: relative; box-shadow: var(--shadow); }
.item-title { font-size: 22px; line-height: 1.2; margin: 0 0 8px; text-transform: uppercase; letter-spacing: .2px; }
.actions { display: flex; gap: 10px; margin: 12px 0 4px; }
.actions .btn { flex: 1; padding: 11px 12px; font-size: 14.5px; }
.btn.outline { background: transparent; color: var(--accent); box-shadow: inset 0 0 0 1.5px var(--accent); }
.desc { margin: 10px 0 0; font-size: 14.5px; }

details.acc { margin-top: 18px; }
details.acc > summary {
  list-style: none; display: flex; align-items: center; justify-content: space-between;
  font-weight: 800; text-transform: uppercase; font-size: 15px; letter-spacing: .4px; padding: 4px 2px 8px; cursor: pointer;
}
details.acc > summary::-webkit-details-marker { display: none; }
details.acc > summary::after { content: "▼"; font-size: 12px; transition: transform .2s; }
details.acc:not([open]) > summary::after { transform: rotate(-90deg); }

.gcard { background: var(--surface-2); border-radius: 16px; padding: 12px 14px; margin-top: 8px; }
.gcard .steps { margin-top: 4px; }
.gcard .steps li:last-child { padding-bottom: 0; }
.bul { list-style: none; margin: 0; padding: 0; }
.bul li { padding: 5px 0; font-size: 14.5px; }
.bul li::before { content: "• "; color: var(--muted); }
.bul .q { font-variant-numeric: tabular-nums; }
.bul .q.changed { color: var(--accent); }
.ing-group { text-transform: none; letter-spacing: 0; font-size: 15px; font-weight: 700; color: var(--text); margin: 14px 2px 0; }

.info { background: var(--accent-soft); border-radius: 16px; padding: 14px 16px; margin-top: 14px; font-size: 14.5px; }
.video-btn { width: 100%; border: 0; border-radius: 14px; background: var(--accent-soft); color: var(--accent); font-weight: 700; padding: 12px; margin: 2px 0 10px; }
.gcard.locked { text-align: center; padding: 22px 16px; margin-top: 16px; }
#scaler .seg { margin-top: 4px; }
.bul li.inv { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.shop-btn { flex: none; border: 0; border-radius: 999px; background: var(--surface); color: var(--accent); font-weight: 700; font-size: 13px; padding: 6px 12px; }
.bul li.inv > span { flex: 1; min-width: 0; }
.bul li.inv::before { flex: none; margin-right: -6px; }
.link-row { display: block; margin-top: 8px; color: var(--accent); font-weight: 700; font-size: 14px; }
.gcard b { font-weight: 700; }
.gcard + .gcard { margin-top: 10px; }
.brand img.avatar { border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent); }
.seg.aud { margin-bottom: 10px; }
.seg.aud button { font-size: 13px; }
.cut { position: relative; margin: 0 0 16px; border-radius: var(--radius); overflow: hidden; }
.cut img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.cut span { position: absolute; left: 10px; bottom: 10px; padding: 4px 10px; border-radius: 999px; background: rgba(0,0,0,.55); color: #fff; font-size: 13px; font-weight: 600; }
