/* ==========================================================================
   Foodbox · 2026 light premium · food editorial
   Inspired by modern food brand looks (Erewhon, Cucina, Tasted), not 2010.
   ========================================================================== */

:root {
  /* Surfaces — warm cream */
  --bg: #faf6ed;               /* page bg, warm cream */
  --bg-soft: #f3eedf;          /* subtle alternate */
  --bg-card: #ffffff;          /* elevated white */

  /* Lines */
  --line: rgba(31,29,26,0.08);
  --line-strong: rgba(31,29,26,0.15);

  /* Text */
  --ink: #1f1d1a;              /* warm near-black */
  --ink-soft: #4a4744;
  --ink-dim: #7a7670;
  --ink-mute: #b7b3ac;

  /* Accents */
  --accent: #d94e2a;           /* terracotta — premium pastry red */
  --accent-hover: #b8401f;
  --accent-soft: rgba(217,78,42,0.10);
  --olive: #6b7d3f;            /* fresh herb green for "completed" */
  --olive-soft: rgba(107,125,63,0.14);
  --warn: #b8801c;

  /* Effects */
  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 22px;
  --shadow-sm: 0 1px 2px rgba(31,29,26,0.04), 0 2px 6px rgba(31,29,26,0.04);
  --shadow-md: 0 4px 12px -4px rgba(31,29,26,0.10), 0 14px 32px -10px rgba(31,29,26,0.08);
  --shadow-accent: 0 8px 24px -8px rgba(217,78,42,0.45);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'ss01', 'cv11';
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; transition: opacity 0.15s; }
a:hover { opacity: 0.75; }
img, video { max-width: 100%; display: block; }

/* ============== NAV ============== */
.nav {
  position: sticky; top: 0; z-index: 30;
  /* Near-solid cream — under scroll, partially-transparent navbars let dark
     content bleed through and the row "shimmers" as you scroll past cards. */
  background: rgba(250,246,237,0.97);
  backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.nav-inner {
  max-width: 1180px; margin: 0 auto;
  padding: 14px 22px;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
}
.brand {
  display: flex; align-items: center;
  font-weight: 800; font-size: 18px; letter-spacing: -0.02em;
  color: var(--ink);
}
.brand-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  display: inline-block; margin-left: 4px;
}
.nav-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Credits pill — uses a FIXED brand colour so it's the same on every page,
   independent of any per-kind --accent override active on /build. Otherwise
   credits look pink in the constructor but terracotta in cabinet/credits. */
.credits-pill {
  background: rgba(217,78,42,0.10);
  color: #d94e2a;
  padding: 0 12px;
  height: 38px;
  border-radius: 999px;
  font-size: 13px; font-weight: 700;
  border: 1px solid rgba(217,78,42,0.18);
  text-decoration: none !important;
  display: inline-flex; align-items: center; gap: 4px;
  transition: background 0.15s;
}
.credits-pill:hover { background: rgba(217,78,42,0.18); }
.credits-pill.low { background: rgba(184,128,28,0.15); color: var(--warn); border-color: rgba(184,128,28,0.25); }

/* Lang switch — matches nav-icon-btn height (38px) so the navbar row is
   visually aligned. Previously it sat shorter and looked dropped. */
.lang-switch {
  display: inline-flex; gap: 2px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px;
  height: 38px;
  align-items: center;
}
.lang-btn {
  padding: 0 11px; border: none; background: transparent;
  font-size: 11px; font-weight: 700; letter-spacing: 0.05em;
  color: var(--ink-dim); cursor: pointer; border-radius: 999px;
  font-family: inherit;
  height: 30px;
  display: inline-flex; align-items: center;
  transition: all 0.15s;
}
.lang-btn.active { background: var(--ink); color: var(--bg); }
.lang-btn:not(.active):hover { color: var(--ink); }

/* Icon-only nav button (cabinet + sign-out). Compact on mobile, sized for
   touch (38×38 minimum). Inherits ink color, hover lifts to accent. */
.nav-icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  cursor: pointer;
  padding: 0;
  transition: all 0.15s ease;
  text-decoration: none;
}
.nav-icon-btn:hover {
  background: var(--bg-card);
  border-color: var(--line-strong);
  color: var(--accent);
}
.nav-icon-btn svg { display: block; }

/* Credits pill — explicit currency glyph + plus. The plus is hidden on
   very small screens so the pill stays compact. */
.credits-pill .cur { opacity: 0.7; }
.credits-pill .plus {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px;
  border-radius: 999px; background: var(--accent); color: #fff;
  font-size: 12px; line-height: 1; font-weight: 800;
  margin-left: 2px;
  /* Slight optical lift — the "+" glyph sits low on its baseline so it
     looked off-centre even with flex centring. */
  padding-bottom: 1px;
}

/* TG MiniApp variant: no brand mark, tighter padding. We keep a solid
   cream background (NOT transparent) — otherwise scrolling cards bleed
   through the sticky nav and the row looks broken. TG's own header is
   above our nav so a subtle bottom border is fine. */
.nav-inner.in-tg {
  padding: 8px 12px;
  justify-content: flex-end;
  gap: 8px;
}
.inside-tg .nav {
  background: rgb(250,246,237);
  backdrop-filter: none;
  border-bottom: 1px solid var(--line);
}

/* ============== BUTTONS ============== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 20px; border: none; border-radius: var(--r-sm);
  font-family: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: transform .12s ease, opacity .15s ease, background 0.15s, box-shadow 0.2s;
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary {
  background: var(--accent); color: #fff;
  box-shadow: var(--shadow-accent);
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.45; cursor: default; transform: none; box-shadow: none; }
.btn-ghost {
  background: transparent; color: var(--ink);
  border: 1px solid var(--line-strong);
}
.btn-ghost:hover { background: var(--bg-card); border-color: var(--ink-dim); }
.btn-dark { background: var(--ink); color: var(--bg); }
.btn-dark:hover { background: var(--ink-soft); }
/* «В галерею» и прочие тёплые действия — медово-янтарный вместо болотного
   (звезда + золото читаются на любом акценте конструктора). */
.btn-warm { background: #c58a1a; color: #fff; }
.btn-warm:hover { background: #a87413; }
.btn-lg { padding: 16px 32px; font-size: 16px; border-radius: var(--r-md); }
.btn-sm { padding: 7px 14px; font-size: 12px; }
.btn-block { width: 100%; }

/* ============== INPUTS ============== */
.input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  color: var(--ink); font-size: 14px;
  outline: none;
  transition: border-color .15s ease, background 0.15s, box-shadow 0.15s;
  font-family: inherit;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder { color: var(--ink-mute); }
.label { display: block; font-size: 12px; color: var(--ink-dim); margin-bottom: 6px; font-weight: 500; letter-spacing: 0.02em; }

/* ============== LAYOUT ============== */
.container { max-width: 1180px; margin: 0 auto; padding: 22px 22px; }
.section { padding: 50px 0; }
.center { text-align: center; }
.card {
  background: var(--bg-card);
  border-radius: var(--r-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.h1 {
  font-size: clamp(34px, 6.5vw, 68px);
  font-weight: 700;
  line-height: 1.04;
  letter-spacing: -0.035em;
  margin: 0 0 18px;
  color: var(--ink);
}
.h1 .grad { color: var(--accent); }
.h2 { font-size: clamp(22px, 3vw, 32px); font-weight: 700; letter-spacing: -0.02em; margin: 0 0 12px; color: var(--ink); }
.h3 { font-size: 17px; font-weight: 700; margin: 0 0 6px; color: var(--ink); }
.lead { color: var(--ink-soft); font-size: clamp(15px, 1.6vw, 18px); max-width: 56ch; margin: 0 auto; line-height: 1.55; }
.muted { color: var(--ink-mute); font-size: 13px; }
.eyebrow {
  display: inline-block;
  background: var(--bg-card);
  border: 1px solid var(--line);
  color: var(--ink-dim);
  padding: 5px 14px; border-radius: 999px;
  font-size: 12px; letter-spacing: 0.08em; font-weight: 600; text-transform: uppercase;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.eyebrow .dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--olive);
  display: inline-block; margin-right: 6px; animation: pulse 1.6s ease infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ============== HERO PHOTO WALL (landing) ==============
   Full-bleed chaotic grid of generated desserts. The wall is the page —
   the text overlay is a compact pill at the top-third, NOT a giant card
   that eats every pixel. A radial mask fades the wall into the cream
   background at the edges. */
.hero-wall {
  position: relative;
  /* Make room for plenty of wall ABOVE and BELOW the overlay. On mobile we
     accept the section being taller than the viewport — scrolling reveals
     more of the wall, which is the whole point. */
  min-height: 100vh;
  padding: 0;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(circle at 20% 0%, #fff7ec 0%, transparent 55%),
    radial-gradient(circle at 90% 80%, #ffe9d6 0%, transparent 55%),
    linear-gradient(180deg, var(--bg) 0%, #fdf3e3 100%);
}
.hero-wall-bg {
  position: absolute; inset: 0;
  /* Packed mosaic via CSS grid with dense auto-flow: every tile snaps to
     a base 60×60 cell; per-tile JS assigns varied col/row spans (1×1 up
     to 3×3 hero blocks). Dense flow back-fills any gaps with later tiles
     so the wall ends up GAP-FREE while still looking chaotic. */
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  grid-auto-rows: 70px;
  grid-auto-flow: dense;
  gap: 4px;
  padding: 6px;
  z-index: 0;
  /* Vignette: dense in centre, fades on edges. */
  -webkit-mask-image:
    radial-gradient(ellipse 95% 95% at 50% 50%,
      rgba(0,0,0,1) 0%,
      rgba(0,0,0,1) 55%,
      rgba(0,0,0,0.55) 82%,
      transparent 100%);
  mask-image:
    radial-gradient(ellipse 95% 95% at 50% 50%,
      rgba(0,0,0,1) 0%,
      rgba(0,0,0,1) 55%,
      rgba(0,0,0,0.55) 82%,
      transparent 100%);
}
.wall-tile {
  display: block;
  border-radius: 10px;
  overflow: hidden;
  background: rgba(255,255,255,0.4);
  box-shadow: 0 6px 18px -10px rgba(31,29,26,0.18);
  /* JS sets --cs / --rs per tile (column-span / row-span). Defaults to
     1×1 if the variable isn't applied. */
  grid-column: span var(--cs, 1);
  grid-row: span var(--rs, 1);
  animation: wallFade 0.6s ease backwards;
  transform: translateZ(0);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.wall-tile:hover { transform: translateY(-2px) scale(1.02); box-shadow: 0 14px 32px -10px rgba(31,29,26,0.28); }
.wall-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.wall-tile:nth-child(4n)    { animation-delay: 0.05s; }
.wall-tile:nth-child(4n+1)  { animation-delay: 0.10s; }
.wall-tile:nth-child(4n+2)  { animation-delay: 0.15s; }
.wall-tile:nth-child(4n+3)  { animation-delay: 0.20s; }

@keyframes wallFade {
  from { opacity: 0; transform: scale(0.94) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* Text overlay — a full-bleed band stretched edge-to-edge horizontally so
   the radial halo's outer rim aligns with the screen edges (no visible
   "cut" on the sides). The radial mask gives the soft aureole in every
   direction; content is centred both horizontally and vertically with
   flexbox so the text never drifts to the top/bottom. */
.hero-wall-overlay {
  position: absolute;
  left: 0; right: 0;
  top: 0;
  height: 100vh;
  z-index: 1;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
}
/* The frosted-glass aurora lives on a ::before so the mask is applied to
   the BACKGROUND only — text and button below stay fully opaque without
   getting clipped at the gradient edges. */
.hero-wall-overlay::before {
  content: "";
  position: absolute; inset: 0;
  background: rgba(250,246,237,0.88);
  backdrop-filter: blur(32px) saturate(180%);
  -webkit-backdrop-filter: blur(32px) saturate(180%);
  /* Stronger, slower-falling aurora than before: bigger ellipse (65×60),
     denser stops in the inner zones (longer "fully opaque" plateau and
     higher mid-tones) — the glow extends further before dissolving. */
  -webkit-mask-image: radial-gradient(ellipse 65% 60% at 50% 50%,
    rgba(0,0,0,1) 0%,
    rgba(0,0,0,1) 26%,
    rgba(0,0,0,0.92) 45%,
    rgba(0,0,0,0.65) 65%,
    rgba(0,0,0,0.30) 85%,
    transparent 100%);
  mask-image: radial-gradient(ellipse 65% 60% at 50% 50%,
    rgba(0,0,0,1) 0%,
    rgba(0,0,0,1) 26%,
    rgba(0,0,0,0.92) 45%,
    rgba(0,0,0,0.65) 65%,
    rgba(0,0,0,0.30) 85%,
    transparent 100%);
  pointer-events: none;
  z-index: -1;
}
/* Inner container constrains the text to a comfortable reading width
   without breaking the full-bleed frosted band behind it. */
.hero-wall-inner {
  position: relative;
  z-index: 2;
  max-width: 460px;
  width: 100%;
  pointer-events: auto;
}
.hero-wall-title {
  font-size: clamp(28px, 5.5vw, 48px);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.05;
  margin: 0 0 26px;
  color: var(--ink);
}
.hero-wall-title .grad { color: var(--accent); }
.hero-wall-cta {
  display: inline-flex; justify-content: center;
}
.hero-wall-cta .btn-lg { padding: 16px 30px; font-size: 16px; }

/* Old auxiliary blocks are now hidden — keep the rules so any cached
   old HTML still degrades gracefully. */
.hero-wall-overlay .eyebrow,
.hero-wall-lead,
.hero-wall-kinds,
.hero-wall-overlay .muted { display: none; }

@media (max-width: 600px) {
  .hero-wall { min-height: 130vh; }
  .hero-wall-overlay {
    padding: 0 16px;
  }
  .hero-wall-bg {
    grid-template-columns: repeat(auto-fill, minmax(62px, 1fr));
    grid-auto-rows: 62px;
    gap: 3px;
    padding: 4px;
  }
  .hero-wall-title { font-size: 30px; }
}

/* ============== GALLERY TILES ============== */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-top: 32px;
}
.tile {
  position: relative;
  aspect-ratio: 3/4;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
  transition: transform .25s cubic-bezier(.4,0,.2,1), box-shadow .25s;
  cursor: pointer;
}
.tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile-overlay {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: linear-gradient(0deg, rgba(0,0,0,0.85), transparent 80%);
  color: #fff;
  padding: 30px 14px 14px;
  font-size: 13px;
}
.tile-title { font-weight: 700; line-height: 1.2; }
.tile-author { font-size: 11px; opacity: 0.75; margin-top: 4px; }
.tile-likes {
  position: absolute; top: 10px; right: 10px;
  background: rgba(0,0,0,0.55); backdrop-filter: blur(8px);
  color: #fff;
  padding: 4px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; gap: 3px;
}
.tile-placeholder {
  background: var(--bg-soft);
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-mute); font-size: 12px;
  border: 1px dashed var(--line);
  box-shadow: none;
}

/* ============== STEPS PROGRESS ============== */
.steps {
  display: flex; gap: 6px; justify-content: center;
  margin: 18px auto 22px;
  padding: 10px 12px;
  flex-wrap: wrap;
  /* Soft inset card so the row reads as a contained panel instead of
     pills floating in mid-air. */
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  max-width: 100%;
}
.step-pill {
  position: relative;
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--bg-card);
  color: var(--ink-dim);
  border: 1px solid var(--line);
  cursor: pointer; user-select: none;
  transition: all 0.15s;
}
.step-pill:hover { color: var(--ink); border-color: var(--line-strong); }
.step-pill.done { background: var(--olive-soft); color: var(--olive); border-color: rgba(107,125,63,0.25); }
.step-pill.active { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: var(--shadow-accent); }
/* Future / unreachable steps — visibly disabled so users don't click and
   wonder why nothing happens. Click handler also no-ops these. */
.step-pill.locked {
  opacity: 0.45;
  cursor: not-allowed;
  color: var(--ink-mute);
}
.step-pill.locked:hover { color: var(--ink-mute); border-color: var(--line); }
.step-pill.locked .step-no { background: var(--bg-soft); color: var(--ink-mute); }
.step-pill .step-no {
  display: inline-block; width: 18px; height: 18px; border-radius: 50%;
  background: var(--bg-soft); color: var(--ink-dim);
  font-size: 10px; line-height: 18px; text-align: center; font-weight: 700;
}
.step-pill.done .step-no { background: var(--olive); color: #fff; }
.step-pill.active .step-no { background: rgba(255,255,255,0.28); color: #fff; }
.step-pill .step-count {
  background: var(--accent); color: #fff;
  font-size: 10px; font-weight: 800;
  padding: 1px 7px; border-radius: 999px;
  min-width: 18px; text-align: center;
}
.step-pill.active .step-count { background: rgba(255,255,255,0.28); color: #fff; }
.step-pill.done .step-count { background: var(--olive); color: #fff; }

.step-head { margin: 0 0 24px; }
.step-head h2 { font-size: clamp(22px, 3vw, 30px); font-weight: 700; margin: 0 0 6px; letter-spacing: -0.02em; }
.step-head p { color: var(--ink-soft); font-size: 14px; margin: 0; }

/* ============== BUILD LAYOUT ============== */
.build-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 30px;
}
@media (max-width: 880px) { .build-layout { grid-template-columns: 1fr; } }

.summary {
  position: sticky;
  top: 78px;
  background: var(--bg-card);
  border-radius: var(--r-md);
  padding: 18px;
  align-self: start;
  max-height: calc(100vh - 100px);
  overflow: auto;
  box-shadow: var(--shadow-sm);
}
.summary h3 {
  margin: 0 0 12px;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--ink-dim);
}
.summary-empty {
  color: var(--ink-mute); font-size: 13px; padding: 24px 0; text-align: center;
}
.summary-row {
  display: flex; gap: 12px; align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.summary-row:last-child { border-bottom: 0; }
.summary-row .sum-pic {
  width: 42px; height: 42px; border-radius: 10px;
  background: var(--bg-soft);
  flex: 0 0 42px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.summary-row .sum-pic img { max-width: 100%; max-height: 100%; object-fit: contain; }
.summary-row .sum-meta { flex: 1; min-width: 0; }
.summary-row .sum-cat {
  font-size: 10px; color: var(--ink-mute);
  text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600;
}
.summary-row .sum-name {
  font-size: 13px; font-weight: 600; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.summary-row .sum-remove {
  background: transparent; border: none; color: var(--ink-mute);
  font-size: 16px; padding: 4px 8px; cursor: pointer; border-radius: 6px;
}
.summary-row .sum-remove:hover { background: var(--bg-soft); color: var(--accent); }

.summary-meter {
  margin: 16px 0 0; padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 11px; color: var(--ink-dim);
  display: flex; align-items: center; gap: 8px;
  font-weight: 600; letter-spacing: 0.03em;
  text-transform: uppercase;
}
.summary-meter-bar { flex: 1; height: 4px; background: var(--bg-soft); border-radius: 999px; overflow: hidden; }
.summary-meter-bar > div {
  height: 100%; background: var(--accent);
  transition: width .25s ease, background .25s ease;
}
.summary-meter.full .summary-meter-bar > div { background: var(--warn); }
.summary-meter.full { color: var(--warn); }

/* ============== PICKER GRID ============== */
.picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.picker-item {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(.4,0,.2,1);
  /* Flex column so .name fills any extra vertical space when one cell in
     a row gets stretched (e.g. a neighbour has a 2-line title). Without
     this, shorter labels leave an empty strip at the bottom. */
  display: flex;
  flex-direction: column;
}
.picker-item:hover { border-color: var(--line-strong); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
/* Rejection bounce — fires when the user taps an unselected tile while
   already at the items limit. Combined with a haptic "error" buzz this
   makes it obvious that the cap was hit, instead of the previous silent
   no-op. */
@keyframes limitBounce {
  0%   { transform: translateY(0)    scale(1); }
  18%  { transform: translateY(-7px) scale(1.04); }
  36%  { transform: translateY(3px)  scale(0.97); }
  54%  { transform: translateY(-3px) scale(1.02); }
  72%  { transform: translateY(1px)  scale(0.99); }
  100% { transform: translateY(0)    scale(1); }
}
.picker-item.limit-bounce {
  animation: limitBounce 0.55s cubic-bezier(.34, 1.56, .64, 1);
  box-shadow: 0 0 0 2px rgba(184,64,31,0.55), 0 8px 18px -6px rgba(184,64,31,0.25);
}
.picker-item.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), var(--shadow-accent);
  transform: translateY(-2px);
}
.picker-item.selected::after {
  content: "✓"; position: absolute; top: 8px; right: 8px;
  background: var(--accent); color: #fff;
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px;
  box-shadow: 0 2px 8px rgba(217,78,42,0.4);
}
.picker-item .pic {
  aspect-ratio: 1/1;
  /* White canvas = same as the card, so the white edge-vignette (::after)
     blends the picture seamlessly into the card. */
  background: #ffffff;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.picker-item .pic img {
  /* cover — every sprite fills the cell edge-to-edge → identical visual
     bowl size regardless of the source screenshot's aspect ratio.
     Anchored slightly high so the bowl base + shadow stay in frame. */
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: center 42%;
  transition: opacity 0.18s ease;
  opacity: 0;                  /* hidden until loaded */
}
/* White edge-frame painted ON TOP of the image. Four linear gradients —
   one fading in from each side — whiten all four rectangular edges
   evenly, so the picture's tinted background + hard square border melt
   into the white card. The centre stays fully transparent (bowl shows
   through crisp). This is the "gradient frame fading to white" look. */
.picker-item .pic::after {
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  z-index: 2;
  background:
    linear-gradient(to top,    #ffffff 0%, rgba(255,255,255,0) 22%),
    linear-gradient(to bottom, #ffffff 0%, rgba(255,255,255,0) 22%),
    linear-gradient(to left,   #ffffff 0%, rgba(255,255,255,0) 22%),
    linear-gradient(to right,  #ffffff 0%, rgba(255,255,255,0) 22%);
}
.picker-item .pic img.loaded { opacity: 1; }
/* Shimmer skeleton — only visible while img hasn't loaded.
   Disappears the moment img.loaded sits next to it (via :has). */
.picker-item .pic::before {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(90deg,
    var(--bg-soft) 0%,
    rgba(255,255,255,0.55) 50%,
    var(--bg-soft) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  pointer-events: none;
}
.picker-item .pic:has(img.loaded)::before { display: none; }
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Same treatment for summary-row pics */
.summary-row .sum-pic { position: relative; }
.summary-row .sum-pic img { opacity: 0; transition: opacity 0.18s ease; }
.summary-row .sum-pic img.loaded { opacity: 1; }
.summary-row .sum-pic::before {
  content: ""; position: absolute; inset: 0;
  background: var(--bg-soft);
  pointer-events: none;
}
.summary-row .sum-pic:has(img.loaded)::before { display: none; }
.picker-item .name {
  padding: 10px 12px;
  font-size: 13px; font-weight: 600; color: var(--ink);
  line-height: 1.3;
  /* Reserve room for 2-line title + 2-line EN subtitle (the maximum we
     see in real catalogs). Card .picker-item ALSO gets a min-height
     below so even a single-line label keeps the whole card matched in
     height to its 2+2 line neighbours. */
  min-height: 64px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex-grow: 1;
}
/* Whole-card min-height matches "tall content" cells so the grid rows
   stay perfectly even no matter how many lines each label wraps to.
   Container in build.html is `<div class="picker">` — match both. */
.picker .picker-item,
.picker-grid .picker-item {
  min-height: 220px;
}
.picker-item .name small {
  display: block; color: var(--ink-mute); font-weight: 400; font-size: 11px; margin-top: 2px;
}

.subgroup-tabs {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-bottom: 22px;
}
.subgroup-tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 999px;
  background: var(--bg-card); color: var(--ink-dim);
  border: 1px solid var(--line);
  font-size: 13px; font-weight: 500; cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.subgroup-tab:hover { color: var(--ink); }
.subgroup-tab.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.subgroup-tab .sub-count {
  background: var(--accent); color: #fff;
  font-size: 10px; font-weight: 800;
  min-width: 17px; height: 17px; line-height: 17px; text-align: center;
  padding: 0 4px;
  border-radius: 999px;
}
.subgroup-tab.active .sub-count { background: var(--bg); color: var(--accent); }

.skip-btn { font-size: 13px; color: var(--ink-mute); padding: 7px 14px; cursor: pointer; background: none; border: none; font-family: inherit; }
.skip-btn:hover { color: var(--ink); }

/* ============== STEP NAVIGATION (sticky bottom bar) ============== */
.step-nav {
  position: sticky; bottom: 18px;
  z-index: 20;                 /* above picker-item vignettes (z-index:2) so
                                  tiles never paint over the Back/Next bar */
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  padding: 11px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  margin: 32px auto 0;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  max-width: 480px;
  box-shadow: var(--shadow-md);
}
/* Make both step-nav buttons identically sized — back was rendering with
   .btn-sm padding which made it visibly smaller than next. They should
   read as a matched pair. */
.step-nav .btn {
  padding: 12px 22px;
  font-size: 14px;
  min-height: 42px;
}

/* ============== RESULT VIEW ============== */
.result-wrap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}
@media (max-width: 760px) { .result-wrap { grid-template-columns: 1fr; } }
.result-img-box {
  background: var(--bg-card);
  border-radius: var(--r-md);
  padding: 12px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.result-img-box img { width: 100%; border-radius: 12px; display: block; }
.result-img-box.loading { min-height: 380px; display: flex; align-items: center; justify-content: center; color: var(--ink-dim); }
.result-img-box.loading::before {
  content: ""; width: 32px; height: 32px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  margin-right: 14px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.result-summary .layer-row {
  display: flex; gap: 10px; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.result-summary .layer-row:last-child { border-bottom: 0; }
.layer-label {
  color: var(--ink-mute); font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.08em; flex: 0 0 100px; font-weight: 600;
}
.layer-value { font-weight: 600; flex: 1; font-size: 14px; color: var(--ink); }

/* ============== MODAL ============== */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(31,29,26,0.55);
  backdrop-filter: blur(6px);
  display: none; align-items: center; justify-content: center;
  z-index: 100;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-bg.show { display: flex; }
.modal {
  background: var(--bg-card);
  border-radius: var(--r-md);
  max-width: 440px; width: 100%;
  padding: 28px;
  position: relative;
  box-shadow: 0 30px 60px -20px rgba(31,29,26,0.3);
  /* Длинные рецепты: модалка не выше экрана, контент скроллится внутри. */
  max-height: 84vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.modal-close {
  position: absolute; top: 14px; right: 14px;
  background: var(--bg-soft); border: none;
  width: 30px; height: 30px; border-radius: 50%;
  font-size: 18px; cursor: pointer; color: var(--ink-dim);
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { color: var(--ink); background: var(--line); }
.modal h3 { margin: 0 0 8px; font-size: 18px; font-weight: 700; }
.modal .lead { font-size: 14px; margin-bottom: 18px; max-width: none; }

/* ============== CREDITS PAGE ============== */
.tariff-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin: 22px 0 40px;
}
.tariff {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 24px 18px 18px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(.4,0,.2,1);
  box-shadow: var(--shadow-sm);
}
.tariff:hover { border-color: var(--line-strong); transform: translateY(-3px); box-shadow: var(--shadow-md); }
.tariff.best {
  border-color: var(--accent);
  background: linear-gradient(180deg, #fff8f4, var(--bg-card));
}
.tariff .badge {
  position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: #fff;
  font-size: 10px; font-weight: 700; letter-spacing: 0.08em;
  padding: 4px 12px; border-radius: 999px;
  text-transform: uppercase;
  box-shadow: var(--shadow-accent);
}
.tariff .credits-num {
  font-size: 44px; font-weight: 800;
  color: var(--accent);
  line-height: 1;
  letter-spacing: -0.04em;
}
.tariff .credits-name { font-size: 12px; color: var(--ink-mute); margin: 6px 0 18px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.tariff .price { font-size: 24px; font-weight: 700; color: var(--ink); margin-bottom: 4px; }
.tariff .price small { color: var(--ink-mute); font-weight: 500; font-size: 12px; display: block; margin-top: 4px; }

.bonus-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  margin: 14px 0 40px;
}
.bonus {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 20px;
  display: flex; gap: 16px;
  align-items: flex-start;
  transition: all 0.15s;
  box-shadow: var(--shadow-sm);
}
.bonus:hover { border-color: var(--line-strong); }
.bonus.claimed { opacity: 0.6; background: var(--bg-soft); box-shadow: none; }
.bonus-icon {
  flex: 0 0 48px; height: 48px; border-radius: 14px;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}
.bonus.tg .bonus-icon { background: rgba(45,160,228,0.12); color: #2da0e4; }
.bonus-body { flex: 1; }
.bonus h4 { margin: 0 0 6px; font-size: 15px; font-weight: 700; color: var(--ink); }
.bonus p { margin: 0 0 12px; color: var(--ink-soft); font-size: 13px; line-height: 1.5; }
.bonus-reward {
  display: inline-block;
  background: var(--accent-soft); color: var(--accent);
  font-size: 11px; font-weight: 700;
  padding: 4px 10px; border-radius: 999px;
  margin-bottom: 12px;
}

/* ============== CABINET — Dashboard ============== */
.cab-hero {
  background: linear-gradient(135deg, #fff 0%, #fff8f3 60%, #f6e9d6 100%);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 28px 28px 24px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.cab-hero::before {
  content: ""; position: absolute;
  inset: -60px -60px auto auto;
  width: 240px; height: 240px; border-radius: 50%;
  background: radial-gradient(circle at center, rgba(217,78,42,0.18), transparent 70%);
  pointer-events: none;
}
.cab-hero-row {
  display: flex; align-items: center; gap: 18px;
  flex-wrap: wrap;
}
.cab-avatar {
  width: 64px; height: 64px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, #e8862a 100%);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 26px; letter-spacing: -0.02em;
  box-shadow: 0 6px 18px -6px rgba(217,78,42,0.5);
  flex: 0 0 64px;
}
.cab-hero h1 {
  margin: 0 0 4px;
  font-size: clamp(24px, 3.5vw, 32px);
  font-weight: 800; letter-spacing: -0.025em;
  color: var(--ink);
  line-height: 1.1;
}
.cab-hero .sub { color: var(--ink-dim); font-size: 14px; }

.cab-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 22px;
}
.cab-stat {
  background: rgba(255,255,255,0.7);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px 8px;
  /* Три РАВНЫЕ карточки: контент по центру, подписи не переносятся —
     «В ГАЛЕРЕЕ» ломала сетку на узких экранах. */
  text-align: center;
  min-width: 0;
}
.cab-stat .v {
  font-size: 26px; font-weight: 800;
  color: var(--ink); letter-spacing: -0.025em;
  line-height: 1; font-variant-numeric: tabular-nums;
}
.cab-stat .l {
  font-size: 10px; color: var(--ink-dim);
  text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600;
  margin-top: 6px;
  white-space: nowrap;
}
.cab-stat.credits:active { transform: scale(0.97); }
.cab-stat.credits .v { color: var(--accent); }
.cab-stat .top {
  display: flex; justify-content: space-between; align-items: center;
  gap: 8px;
}
.cab-stat .top a {
  display: inline-flex; align-items: center;
  background: var(--accent-soft); color: var(--accent);
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em;
  padding: 4px 8px; border-radius: 999px;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s;
}
.cab-stat .top a:hover { background: rgba(217,78,42,0.18); }

.cab-actions {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  margin: 18px 0 4px;
}
.cab-actions .full { grid-column: 1 / -1; }
.cab-actions .btn { width: 100%; }

.section-h {
  display: flex; align-items: center; justify-content: space-between;
  margin: 36px 0 16px;
  gap: 12px;
}
.section-h h2 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.section-h .sub { color: var(--ink-dim); font-size: 13px; }

.empty-state {
  text-align: center;
  background: var(--bg-card);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-md);
  padding: 36px 24px;
  color: var(--ink-dim);
}
.empty-state .icon {
  font-size: 36px; margin-bottom: 8px;
}
.empty-state h3 { color: var(--ink); margin: 0 0 6px; font-size: 17px; }
.empty-state p { margin: 0 0 14px; font-size: 14px; }

/* ============== CREDITS PAGE 2.0 ============== */
.credits-hero {
  background: linear-gradient(135deg, #fff 0%, #fff8f3 60%, #fae4cd 100%);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 26px 28px;
  margin-bottom: 24px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 24px; flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
}
.credits-hero .left h1 { margin: 0 0 4px; font-size: 24px; font-weight: 800; letter-spacing: -0.025em; }
.credits-hero .left p  { margin: 0; color: var(--ink-dim); font-size: 14px; }
.credits-hero .balance {
  text-align: right;
}
.credits-hero .balance .v {
  font-size: 44px; font-weight: 800; color: var(--accent);
  letter-spacing: -0.04em; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.credits-hero .balance .l {
  font-size: 11px; color: var(--ink-dim);
  text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600;
  margin-top: 6px;
}

/* Tariff cards 2.0 — clean, per-gen visible, savings badge */
.tariff-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin: 8px 0 40px;
}
.tariff {
  position: relative;
  background: var(--bg-card);
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  padding: 26px 18px 18px;
  text-align: center;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(.4,0,.2,1);
  box-shadow: var(--shadow-sm);
}
.tariff:hover {
  border-color: var(--line-strong);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}
.tariff.best {
  border-color: var(--accent);
  background: linear-gradient(180deg, #fff8f4, var(--bg-card));
  box-shadow: 0 4px 14px -4px rgba(217,78,42,0.25), var(--shadow-md);
}
.tariff .badge {
  position: absolute; top: -11px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: #fff;
  font-size: 10px; font-weight: 800; letter-spacing: 0.08em;
  padding: 5px 12px; border-radius: 999px;
  text-transform: uppercase;
  box-shadow: 0 4px 12px -4px rgba(217,78,42,0.5);
  white-space: nowrap;
}
.tariff .savings {
  position: absolute; top: 10px; right: 10px;
  background: var(--olive-soft); color: var(--olive);
  font-size: 10px; font-weight: 800;
  padding: 3px 8px; border-radius: 999px;
}
.tariff .credits-num {
  font-size: 44px; font-weight: 800;
  color: var(--accent);
  line-height: 1;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}
.tariff .credits-name {
  font-size: 12px; color: var(--ink-mute);
  margin: 4px 0 14px;
  text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600;
}
.tariff .price {
  font-size: 22px; font-weight: 800; color: var(--ink);
  margin-bottom: 4px; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.tariff .per-gen {
  color: var(--ink-dim); font-weight: 500; font-size: 12px;
  margin-top: 4px;
}
.tariff .btn { margin-top: 12px; width: 100%; }

/* ============== BUILD RESULT ============== */
.result-stack {
  display: flex; flex-direction: column; gap: 18px;
  max-width: 880px; margin: 0 auto;
}
.result-stack .result-img-box {
  aspect-ratio: 3/4;
  max-height: 560px;
  width: 100%;
  padding: 0;
}
.result-stack .result-img-box img {
  border-radius: var(--r-md);
}
.result-actions {
  display: flex; gap: 8px; flex-wrap: wrap;
}

.recipe {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
  font-size: 14.5px;
}
.recipe h3 {
  font-size: 22px; font-weight: 800; letter-spacing: -0.02em;
  margin: 0 0 16px;
}
.recipe-section + .recipe-section { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.recipe-section h4 {
  font-size: 13px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--accent);
  margin: 0 0 8px;
}
.recipe-section .body {
  color: var(--ink-soft);
  line-height: 1.6;
  white-space: pre-wrap;
}
.recipe-section .body strong { color: var(--ink); font-weight: 700; }

/* ============== DARK MODE (Telegram MiniApp colorScheme=dark) ==============
   Activated by `body.tg-dark` (see tg.js). Overrides ALL surface + text
   tokens so every card, label and gradient adapts. Brand accents stay
   vibrant; gradients flip to dark-warm so the hero hero blocks don't burn
   into the page background. */
body.tg-dark {
  --bg:           #14171a;
  --bg-soft:      #1c2024;
  --bg-card:      #232930;
  --line:         rgba(255,255,255,0.08);
  --line-strong:  rgba(255,255,255,0.18);
  --ink:          #f1efe8;
  --ink-soft:     #c8c5be;
  --ink-dim:      #8a8780;
  --ink-mute:     #6b6862;
  --accent-soft:  rgba(217,78,42,0.22);
  --olive-soft:   rgba(107,125,63,0.28);
  --warn:         #ecb44b;
  /* Shadows — much lighter glow on dark, but keep them so cards still pop. */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3), 0 2px 8px rgba(0,0,0,0.25);
  --shadow-md: 0 6px 18px rgba(0,0,0,0.35), 0 18px 40px -16px rgba(0,0,0,0.4);
  --shadow-accent: 0 8px 24px -8px rgba(217,78,42,0.6);
}
/* Per-kind dark variants — same hue, slightly brightened for legibility */
body.tg-dark[data-kind="icecream"] {
  --accent: #f57e9c; --accent-hover: #e96283;
  --accent-soft: rgba(245,126,156,0.20);
}
body.tg-dark[data-kind="pizza"] {
  --accent: #e85a36; --accent-hover: #cf4626;
  --accent-soft: rgba(232,90,54,0.22);
}
body.tg-dark[data-kind="trifle"] {
  --accent: #b070dd; --accent-hover: #9354c2;
  --accent-soft: rgba(176,112,221,0.22);
}

/* Cab-hero and credits-hero gradients — rewritten so they don't bake in
   white. Hero stays warm but reads in either theme. */
body.tg-dark .cab-hero,
body.tg-dark .credits-hero {
  background: linear-gradient(135deg, var(--bg-card) 0%, #2a2d2f 60%, #36251c 100%) !important;
  border-color: var(--line);
}
body.tg-dark .cab-hero::before {
  background: radial-gradient(circle at center, rgba(245,126,156,0.18), transparent 70%);
}

/* TG-injected blue accent everywhere — kill it. Some pages (login widget,
   TG's own link styles) try to bleed through; our brand wins. */
body.tg-dark a { color: var(--accent); }
body.tg-dark .credits-pill .plus { background: var(--accent); }

/* Hero text on landing — gradient h1 must work on dark too */
body.tg-dark .h1 .grad {
  background: linear-gradient(90deg, var(--accent), #ffb073 60%, #f0d18a);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

/* Empty state, recipe body, anything using inline gradients — sanitize */
body.tg-dark .gift {
  background: linear-gradient(180deg, rgba(107,125,63,0.18), rgba(107,125,63,0.10));
  border-color: rgba(107,125,63,0.40);
  color: var(--ink);
}
body.tg-dark .gift strong { color: #c4d68f; }
body.tg-dark .lock {
  background: var(--bg-card);
  border-color: rgba(217,78,42,0.45);
  color: var(--ink);
}
body.tg-dark .lock strong { color: var(--accent); }

/* Kind switcher dropdown — make it readable on dark */
body.tg-dark .kind-trigger { background: var(--bg-card); color: var(--ink); }
body.tg-dark .kind-trigger:hover { background: #2d3340; }
body.tg-dark .kind-menu { background: var(--bg-card); border-color: var(--line); }
body.tg-dark .kind-opt { color: var(--ink); }
body.tg-dark .kind-opt:hover:not(.disabled) { background: var(--accent-soft); color: var(--accent); }
body.tg-dark .kind-opt.disabled { color: var(--ink-mute); }
body.tg-dark .kind-opt .soon { background: var(--bg-soft); color: var(--ink-mute); }

/* Inputs — dark backgrounds */
body.tg-dark .input { background: var(--bg-card); color: var(--ink); border-color: var(--line-strong); }

/* Step pills in builder */
body.tg-dark .step-pill { background: var(--bg-card); color: var(--ink-soft); border-color: var(--line); }
body.tg-dark .step-pill.done { background: rgba(107,125,63,0.22); color: #c4d68f; border-color: rgba(107,125,63,0.40); }

/* Picker chips — light card on dark page */
body.tg-dark .picker-item { background: var(--bg-card); border-color: var(--line); }
body.tg-dark .picker-item .pic { background: var(--bg-soft); }
body.tg-dark .picker-item .name { color: var(--ink); }
body.tg-dark .picker-item .name small { color: var(--ink-mute); }
body.tg-dark .picker-item:hover { border-color: var(--line-strong); }
body.tg-dark .subgroup-tab { background: var(--bg-card); color: var(--ink-soft); border-color: var(--line); }
body.tg-dark .subgroup-tab.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* Tariff cards / bonus cards on /credits */
body.tg-dark .tariff { background: var(--bg-card); border-color: var(--line); }
body.tg-dark .tariff.best { background: linear-gradient(180deg, #2a2225 0%, var(--bg-card) 100%); }
body.tg-dark .bonus { background: var(--bg-card); border-color: var(--line); }
body.tg-dark .bonus.claimed { background: var(--bg-soft); opacity: 0.5; }
body.tg-dark .bonus-icon { background: var(--accent-soft); color: var(--accent); }

/* Tile grid (gallery/cabinet) */
body.tg-dark .tile { background: var(--bg-card); }
body.tg-dark .tile-placeholder { background: var(--bg-soft); border-color: var(--line); color: var(--ink-mute); }

/* Cab-stat tiles */
body.tg-dark .cab-stat { background: rgba(255,255,255,0.04); border-color: var(--line); }
body.tg-dark .cab-stat .v { color: var(--ink); }
body.tg-dark .cab-stat.credits .v { color: var(--accent); }

/* Result view + recipe block */
body.tg-dark .result-img-box { background: var(--bg-card); }
body.tg-dark .recipe { background: var(--bg-card); border-color: var(--line); }
body.tg-dark .recipe-section .body { color: var(--ink-soft); }
body.tg-dark .recipe-section .body strong { color: var(--ink); }

/* Cart drawer */
body.tg-dark .cart-drawer { background: var(--bg-card); }
body.tg-dark .cart-drawer-handle { background: var(--line-strong); }

/* Hover/focus for floating cart on dark */
body.tg-dark .cart-fab .cart-count { background: var(--bg); border-color: var(--bg-card); color: var(--ink); }

/* Nav (icon buttons / lang switch) */
body.tg-dark .nav-icon-btn { background: var(--bg-card); border-color: var(--line); color: var(--ink); }
body.tg-dark .lang-switch { background: var(--bg-card); border-color: var(--line); }
body.tg-dark .lang-btn { color: var(--ink-dim); }
body.tg-dark .lang-btn.active { background: var(--ink); color: var(--bg); }

/* ============== PER-CONSTRUCTOR ACCENTS ============== */
/* Body gets data-kind="icecream"|"pizza"|"trifle" on /build pages.
   Each kind owns a brand-distinct accent that propagates via --accent. */
body[data-kind="icecream"] {
  --accent: #e4708a;            /* berry-pink — fruit + cream */
  --accent-hover: #c75670;
  --accent-soft: rgba(228,112,138,0.10);
  --shadow-accent: 0 8px 24px -8px rgba(228,112,138,0.45);
}
body[data-kind="pizza"] {
  --accent: #c93f1e;            /* tomato red — pizza classic */
  --accent-hover: #a83216;
  --accent-soft: rgba(201,63,30,0.10);
  --shadow-accent: 0 8px 24px -8px rgba(201,63,30,0.45);
}
body[data-kind="trifle"] {
  --accent: #7b3aa3;            /* berry-purple — trifle layers */
  --accent-hover: #5e2b80;
  --accent-soft: rgba(123,58,163,0.10);
  --shadow-accent: 0 8px 24px -8px rgba(123,58,163,0.45);
}
body[data-kind="muffin"] {
  --accent: #8b5a2b;            /* тёплый шоколадно-коричневый — выпечка */
  --accent-hover: #71481f;
  --accent-soft: rgba(139,90,43,0.10);
  --shadow-accent: 0 8px 24px -8px rgba(139,90,43,0.45);
}
body[data-kind="kumpir"] {
  --accent: #9c6a12;            /* «печёная картошка» — тёмная золотистая охра, белый текст читается */
  --accent-hover: #7f5407;
  --accent-soft: rgba(156,106,18,0.10);
  --shadow-accent: 0 8px 24px -8px rgba(156,106,18,0.45);
}
body[data-kind="nalivnye"] {
  --accent: #9b2c3f;            /* красный бархат */
  --accent-hover: #7f2130;
  --accent-soft: rgba(155,44,63,0.10);
  --shadow-accent: 0 8px 24px -8px rgba(155,44,63,0.45);
}

/* ============== KIND SWITCHER (navbar dropdown) ============== */
.kind-switcher {
  position: relative;
  margin-right: auto;            /* push everything else to the right */
}
.kind-trigger {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  font-family: inherit; font-size: 13px; font-weight: 700;
  color: var(--ink); cursor: pointer;
  transition: all 0.15s ease;
}
.kind-trigger:hover { border-color: var(--line-strong); background: #fff; }
.kind-switcher.open .kind-trigger { border-color: var(--accent); color: var(--accent); }
/* Only rotate the chevron (the trailing SVG), NOT the leading grid icon. */
.kind-switcher.open .kind-trigger svg:last-of-type { transform: rotate(180deg); }
.kind-trigger svg:last-of-type { transition: transform 0.2s ease; }
.kind-trigger .kind-trigger-icon { opacity: 0.75; flex-shrink: 0; }
.kind-trigger-label { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.kind-menu {
  position: absolute; top: calc(100% + 6px); left: 0;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  min-width: 220px;
  padding: 6px;
  display: none;
  z-index: 50;
}
.kind-switcher.open .kind-menu { display: block; }
.kind-opt {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 12px; border-radius: 10px;
  font-size: 14px; font-weight: 600; color: var(--ink);
  text-decoration: none !important;
}
.kind-opt:hover:not(.disabled) { background: var(--accent-soft); color: var(--accent); }
.kind-opt.active { background: var(--accent-soft); color: var(--accent); }
.kind-opt.disabled { color: var(--ink-mute); cursor: default; }
.kind-opt .soon {
  font-size: 10px; font-weight: 800; letter-spacing: 0.06em;
  background: var(--bg-soft); color: var(--ink-mute);
  padding: 2px 8px; border-radius: 99px; text-transform: uppercase;
}

/* ============== CARD POLISH (stronger separation) ============== */
.card {
  /* Stronger 1.5px border + multi-layer shadow so cards stop melting into
     the cream background, especially inside MiniApp on a pure-white scheme. */
  border: 1.5px solid var(--line);
  box-shadow:
    0 1px 2px rgba(31,29,26,0.05),
    0 4px 14px -4px rgba(31,29,26,0.06),
    0 12px 32px -10px rgba(31,29,26,0.08);
}

/* ============== FLOATING CART (build summary) ============== */
.cart-fab {
  position: fixed;
  /* Respect TG safe-area + the legacy step-nav (≈64px when visible). When
     inside TG MiniApp we add a chunkier bottom offset because TG's bottom
     bar steals ~84pt on iPhone. */
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  right: calc(18px + env(safe-area-inset-right, 0px));
  z-index: 80;
  width: 60px; height: 60px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 14px 28px -8px rgba(31,29,26,0.35), 0 4px 10px rgba(31,29,26,0.15);
  cursor: pointer;
  transition: transform 0.18s cubic-bezier(.34, 1.56, .64, 1), box-shadow 0.2s;
  border: none;
}
/* Inside TG MiniApp we still show our own sticky .step-nav — the TG
   MainButton sits in TG's dark bottom chrome which feels visually
   "outside" the cream app. Our in-page nav reads as a continuation. */
body.inside-tg .step-nav {
  /* Add bottom safe-area so the buttons clear iPhone's home-indicator
     and the TG bottom-handle region. */
  padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
}
body.inside-tg .cart-fab {
  /* FAB sits above the step-nav (which is ~70px tall) plus safe-area. */
  bottom: calc(96px + env(safe-area-inset-bottom, 0px));
}
.cart-fab:hover { transform: translateY(-2px) scale(1.05); }
.cart-fab svg { width: 26px; height: 26px; }
.cart-fab .cart-count {
  position: absolute; top: -4px; right: -4px;
  min-width: 24px; height: 24px; line-height: 22px; padding: 0 7px;
  border-radius: 999px;
  background: var(--ink); color: #fff;
  font-size: 12px; font-weight: 800;
  border: 2px solid var(--bg);
}
.cart-fab.pulse { animation: cartPulse 0.55s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes cartPulse {
  0%, 100% { transform: scale(1); }
  40%      { transform: scale(1.18); }
}

/* Drawer that slides up when the user taps the cart. */
.cart-drawer {
  position: fixed; bottom: 0; left: 0; right: 0;
  z-index: 90;
  background: var(--bg-card);
  border-top-left-radius: 22px; border-top-right-radius: 22px;
  box-shadow: 0 -16px 40px -12px rgba(31,29,26,0.22);
  /* Bottom padding includes safe-area so close-button stays inside the
     drawer instead of bleeding into TG's bottom chrome. */
  padding: 22px 22px calc(28px + env(safe-area-inset-bottom, 0px));
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(.4, 0, .2, 1);
  max-height: 70vh;
  overflow-y: auto;
  /* iOS Safari/TG WebView: allow inner scroll without forwarding to the
     viewport (which TG would interpret as "drag to close"). */
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}
.cart-drawer.open { transform: translateY(0); }
/* While the drawer is on-screen, body scrolling is locked entirely so a
   downward swipe never falls through to TG's window-dismiss gesture. */
body:has(.cart-drawer.open) { overflow: hidden !important; }
.cart-drawer-handle {
  /* Full-width 28px-tall transparent grab strip. Visible "pill" is drawn
     as a ::before so the touch target is generous (whole top of drawer)
     while the line stays a tasteful 4px tall. Critical: `touch-action:
     none` so the browser hands us every touchmove instead of treating
     the gesture as a viewport scroll (which TG would convert into a
     "swipe to dismiss MiniApp"). */
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 28px;
  margin: -14px 0 6px;
  cursor: grab;
  touch-action: none;
  -webkit-user-select: none; user-select: none;
}
.cart-drawer-handle::before {
  content: "";
  display: block;
  width: 56px; height: 4px; border-radius: 99px;
  background: var(--line-strong);
}
.cart-drawer-handle:active { cursor: grabbing; }
.cart-drawer-handle:active::before { background: var(--ink-dim); }
.cart-drawer h3 {
  font-size: 13px; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--ink-dim); margin: 0 0 14px;
}
.cart-drawer .summary-row { background: transparent; padding: 12px 0; }
.cart-drawer .meter-row {
  margin-top: 14px; padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
  font-size: 12px; color: var(--ink-dim);
}

/* Fly-to-cart ghost — small circle that animates from a chip's centre
   into the FAB at bottom-right when an item is added. Pure CSS transform. */
.fly-ghost {
  position: fixed;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 800;
  z-index: 100;
  pointer-events: none;
  box-shadow: 0 8px 18px rgba(31,29,26,0.3);
  transition: transform 0.55s cubic-bezier(.34, 1.05, .58, 1), opacity 0.5s ease 0.05s;
}

/* Backdrop to dim the page while the drawer is open. */
.cart-backdrop {
  position: fixed; inset: 0;
  background: rgba(31,29,26,0.4);
  z-index: 85;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.cart-backdrop.show { opacity: 1; pointer-events: auto; }

/* On /build we HIDE the legacy sidebar summary. The floating cart is the
   only way to view it now — frees vertical real-estate so the picker grid
   doesn't get pushed off-screen on mobile. */
body[data-kind] .build-layout { grid-template-columns: 1fr !important; }
body[data-kind] .build-layout > aside.summary { display: none; }

/* ============== MOBILE TWEAKS ============== */
@media (max-width: 600px) {
  .container { padding: 14px 14px; }
  .h1 { font-size: 32px; }
  .picker { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
  .picker-item .name { font-size: 12px; padding: 8px 10px; }
  .step-pill { font-size: 10px; padding: 6px 12px; }
  .step-pill .step-no { display: none; }
  .tile-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
  .summary { position: relative; top: 0; max-height: none; }
  .cab-hero { padding: 22px 20px; border-radius: var(--r-md); }
  .cab-stats { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .cab-stat { padding: 12px 10px; }
  .cab-stat .v { font-size: 22px; }
  .cab-stat .l { font-size: 10px; }
  .credits-hero {
    padding: 22px 20px;
    /* On mobile, stack hero + balance vertically — when they're side-by-
       side via flex-wrap the balance ends up alone on a full-width row
       and looks oddly off-centre. */
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
  }
  .credits-hero .balance { text-align: left; }
  .credits-hero .balance .v {
    font-size: 32px;
    display: inline-block;
    margin-right: 8px;
  }
  .credits-hero .balance .l {
    display: inline-block;
    margin-top: 0;
    vertical-align: middle;
  }
  .credits-hero .left h1 { font-size: 22px; }
  .credits-hero .left p { font-size: 13px; }
  .recipe { padding: 18px 18px; }
  .recipe h3 { font-size: 18px; }
  .nav-inner { padding: 10px 12px; }
  .nav-actions { gap: 6px; }
  .brand { font-size: 15px; }
  .credits-pill { font-size: 12px; padding: 0 9px; height: 34px; }
  .lang-switch { height: 34px; }
  .lang-btn { height: 26px; padding: 0 8px; font-size: 10px; }
  .credits-pill .plus { width: 14px; height: 14px; font-size: 11px; line-height: 14px; }
  .lang-btn { padding: 3px 8px; font-size: 10px; }
  .nav-icon-btn { width: 34px; height: 34px; }
  .nav-icon-btn svg { width: 17px; height: 17px; }
}

@media (max-width: 380px) {
  .cab-stats { grid-template-columns: 1fr 1fr; }
  .cab-stats .cab-stat:nth-child(3) { grid-column: 1 / -1; }
  /* On the tiniest phones hide the lang switch — most users won't switch
     mid-session, and freeing the row keeps Telegram from wrapping the bar. */
  .nav-inner.in-tg .lang-switch { display: none; }
}

/* ============== BOTTOM TAB BAR (MiniApp) ============== */
.fb-bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
  display: flex; justify-content: space-around; align-items: stretch;
  background: var(--bg-card);
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 20px -12px rgba(31,29,26,0.18);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.fb-tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 4px 8px; text-decoration: none;
  color: var(--ink-mute); font-size: 11px; font-weight: 600;
  transition: color .15s;
}
.fb-tab svg { opacity: .85; }
.fb-tab.active { color: var(--accent); }
.fb-tab.active svg { opacity: 1; }
.fb-tab:active { transform: scale(0.94); }
/* Keep page content clear of the fixed bar. */
/* The bottom tab bar's own height grows by the home-indicator safe area —
   page padding and the step-nav offset must grow with it, or the pill
   slides UNDER the menu on notched iPhones. */
body.has-bottomnav { padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)); }
body.has-bottomnav .step-nav { bottom: calc(74px + env(safe-area-inset-bottom, 0px)); }
/* The bottomnav already absorbs the safe area — the floating pill must NOT
   add it again (34px of extra bottom padding pushed the buttons off-center
   inside the pill on iPhone). Keep padding symmetric. */
body.inside-tg.has-bottomnav .step-nav { padding-bottom: 11px; }
/* FAB must clear BOTH the bottom tab bar (64px) and the floating step-nav
   pill (~66px tall at bottom:74px) — otherwise it lands right on the
   «Далее/Сгенерировать» buttons. Declared after the base .cart-fab and
   inside-tg rules so this wins the cascade. */
body.has-bottomnav .cart-fab,
body.inside-tg.has-bottomnav .cart-fab {
  bottom: calc(156px + env(safe-area-inset-bottom, 0px));
}
/* Required step with nothing picked — «Далее» reads inactive (click still
   fires and shows the explainer toast). */
.step-nav .btn.btn-locked { opacity: 0.5; filter: saturate(0.4); }
/* iOS ignores user-scalable=no — cut pinch/double-tap zoom at the
   touch-action level (vertical pan only on the page itself; scrollable
   sub-rows opt back in below). JS gesture + multi-touch guards in
   shared.js back this up inside TG's WKWebView. */
html, body { touch-action: pan-y; }
/* Horizontal-scroll rows keep their own horizontal panning. */
.g-pills, .subgroup-tabs { touch-action: pan-x pan-y; }
/* Hard stop: the page itself can never scroll sideways, whatever
   overflows. `clip` (unlike hidden) doesn't create a scroll container,
   so position:sticky (.step-nav) keeps working. */
html, body { overflow-x: clip; }
/* WebKit: grid items default to min-width:auto and refuse to shrink below
   their content's min-content width — on the toppings step this inflated
   the build column (and .picker with it) to 467px on a 390px phone.
   Chromium shrank it; WebKit needs the explicit 0. */
.build-layout > * { min-width: 0; }
/* Narrow phones: let the step-nav buttons compress instead of pushing the
   pill wider than the viewport. */
@media (max-width: 430px) {
  .step-nav { width: 100%; padding: 9px 10px; gap: 8px; }
  .step-nav .btn { padding: 12px 14px; font-size: 13px; min-width: 0; }
  /* Keep the pill's padding symmetric in TG on narrow phones too. */
  body.inside-tg.has-bottomnav .step-nav { padding-bottom: 9px; }
}
/* Desktop: keep the bar (it's harmless) but cap its width centered. */
@media (min-width: 900px) {
  .fb-bottomnav { max-width: 480px; margin: 0 auto; border-radius: 18px 18px 0 0; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}

/* ── Result actions: ровный грид 2 колонки, широкие — на всю ширину ── */
.result-actions-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.result-actions-grid .btn { width: 100%; min-width: 0; white-space: nowrap; }
.result-actions-grid .btn.full { grid-column: 1 / -1; }
.btn .ic { flex-shrink: 0; }

/* ── Кабинет: «Что собрать» — мини-плитки с фото ── */
.cab-builders {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
}
.cb-tile {
  position: relative; display: block; aspect-ratio: 1/1;
  border-radius: 14px; overflow: hidden; text-decoration: none;
  border: 1px solid var(--line); background: #f0ede6; color: #fff;
  box-shadow: 0 4px 12px -8px rgba(31,29,26,.25);
  transition: transform .15s;
}
.cb-tile:active { transform: scale(.96); }
.cb-tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cb-nm {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 18px 8px 8px; font-size: 12px; font-weight: 800; letter-spacing: -.01em;
  background: linear-gradient(transparent, rgba(0,0,0,.6)); text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Узкие экраны: шапка не должна выталкивать кредит-пилюлю за край. */
@media (max-width: 400px) {
  .nav-actions { gap: 6px; min-width: 0; }
  .nav-actions .btn-sm { padding: 8px 10px; }
  .nav { padding-left: 12px; padding-right: 12px; }
}
