:root {
  --bg: #0E0F0C;
  --bg-soft: #1A1C16;
  --card: #181A14;
  --card-2: #20231B;
  --ink: #F2F4EC;
  --ink-2: #A6AC98;
  --ink-3: #6C7260;
  --line: #2A2D23;
  --accent: #C8F135;
  --accent-dim: #9DBF25;
  --accent-soft: rgba(200, 241, 53, 0.12);
  --accent-ink: #10120A;
  --like: #FF5A3C;
  --like-soft: rgba(255, 90, 60, 0.14);
  --warn: #FFB43C;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.35);
  --radius: 24px;
  --tabbar-h: calc(64px + env(safe-area-inset-bottom));
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(200, 241, 53, 0.08), transparent 60%),
    var(--bg);
  color: var(--ink);
  min-height: 100dvh;
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
[hidden] { display: none !important; }

.caps {
  text-transform: uppercase; letter-spacing: 0.08em; font-weight: 800;
}

/* ---------- Топбар ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(14, 15, 12, 0.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px 10px;
  max-width: 560px; margin: 0 auto;
}
.brand {
  font-size: 19px; font-weight: 850; letter-spacing: -0.01em;
  text-transform: uppercase; font-style: italic;
}
.date-chip {
  font-size: 12px; font-weight: 700; color: var(--accent);
  background: var(--accent-soft); border: 1px solid rgba(200, 241, 53, 0.25);
  border-radius: 999px; padding: 6px 12px;
  text-transform: uppercase; letter-spacing: 0.05em;
}

/* ---------- Экраны ---------- */
#main { max-width: 560px; margin: 0 auto; padding: 0 16px calc(var(--tabbar-h) + 16px); }
.screen { display: none; animation: fade .25s ease; }
.screen.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.window-hint {
  text-align: center; font-size: 12px; font-weight: 700;
  color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.1em;
  margin: 6px 0 14px;
}
.window-hint b { color: var(--accent); font-weight: 800; }

/* ---------- Колода карточек ---------- */
.deck-wrap { position: relative; }
.deck { position: relative; height: clamp(460px, calc(100dvh - 310px), 580px); }
.card {
  position: absolute; inset: 0;
  background: linear-gradient(160deg, var(--card-2), var(--card) 55%);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 20px 16px;
  display: flex; flex-direction: column;
  touch-action: pan-y;
  will-change: transform;
  user-select: none;
  -webkit-user-select: none;
  border: 1px solid var(--line);
  overflow: hidden;
}
.card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--accent), transparent 70%);
}
.card.behind { transform: scale(.95) translateY(14px); opacity: .6; pointer-events: none; }
.card.leaving { transition: transform .35s ease, opacity .35s ease; opacity: 0; pointer-events: none; }
.card.snap-back { transition: transform .3s cubic-bezier(.2,.9,.3,1.2); }

.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.card-title {
  font-size: 12px; font-weight: 850; color: var(--accent);
  text-transform: uppercase; letter-spacing: .12em; font-style: italic;
}
.card-kcal {
  font-size: 12px; font-weight: 800; color: var(--ink);
  background: var(--bg-soft); border: 1px solid var(--line);
  padding: 5px 10px; border-radius: 999px;
}

.meal-row { display: flex; gap: 14px; padding: 11px 0; align-items: flex-start; }
.meal-row + .meal-row { border-top: 1px solid var(--line); }
.meal-emoji {
  flex: 0 0 46px; height: 46px; border-radius: 14px;
  background: var(--bg-soft); border: 1px solid var(--line);
  display: grid; place-items: center;
  font-size: 24px;
}
.meal-info { flex: 1; min-width: 0; }
.meal-time {
  font-size: 11px; font-weight: 850; color: var(--accent);
  letter-spacing: .1em;
}
.meal-name { font-size: 16px; font-weight: 700; line-height: 1.22; margin-top: 2px; }
.meal-desc {
  font-size: 12.5px; color: var(--ink-2); line-height: 1.35; margin-top: 3px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.meal-kcal { font-size: 11.5px; font-weight: 600; color: var(--ink-3); margin-top: 4px; }

.card-foot {
  margin-top: auto; padding-top: 10px;
  display: flex; justify-content: space-between; align-items: center;
}
.swipe-hint {
  font-size: 10.5px; font-weight: 700; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: .08em;
}

/* Штампы при свайпе */
.stamp {
  position: absolute; top: 26px; padding: 8px 16px; z-index: 5;
  border: 3px solid; border-radius: 10px;
  font-size: 24px; font-weight: 900; letter-spacing: .06em; font-style: italic;
  opacity: 0; transform: rotate(-12deg); pointer-events: none;
  text-transform: uppercase;
}
.stamp-like { left: 18px; color: var(--accent); border-color: var(--accent); background: rgba(200,241,53,.08); }
.stamp-skip { right: 18px; color: var(--like); border-color: var(--like); transform: rotate(12deg); background: rgba(255,90,60,.08); }

/* Кнопки под колодой */
.deck-actions { display: flex; justify-content: center; gap: 34px; margin-top: 20px; }
.fab {
  width: 62px; height: 62px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--card-2); box-shadow: var(--shadow);
  border: 1px solid var(--line);
  transition: transform .12s ease;
}
.fab:active { transform: scale(.88); }
.fab-skip { color: var(--ink-2); }
.fab-like {
  color: var(--accent-ink); width: 74px; height: 74px;
  background: var(--accent);
  border: none;
  box-shadow: 0 8px 28px rgba(200, 241, 53, 0.35);
}

/* ---------- Выбранное меню (после лайка) ---------- */
.chosen-view { animation: fade .3s ease; }
.chosen-banner {
  display: flex; align-items: center; gap: 10px;
  background: var(--accent); color: var(--accent-ink);
  border-radius: 16px; padding: 13px 16px;
  font-size: 13px; font-weight: 850; margin-bottom: 14px;
  text-transform: uppercase; letter-spacing: .06em; font-style: italic;
}
.chosen-card {
  background: linear-gradient(160deg, var(--card-2), var(--card) 55%);
  border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; margin-bottom: 14px;
}
.chosen-meal + .chosen-meal { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 16px; }
.chosen-meal-head { display: flex; align-items: center; gap: 12px; }
.chosen-meal-head .meal-emoji { flex-basis: 42px; height: 42px; font-size: 22px; }
.chosen-ings { margin-top: 10px; }
.ing-row {
  display: flex; justify-content: space-between; gap: 12px;
  font-size: 14px; padding: 5px 0; color: var(--ink-2);
}
.ing-row span:first-child { color: var(--ink); }
.ing-row span:last-child { white-space: nowrap; font-weight: 600; }
.chosen-total {
  text-align: center; font-size: 12px; font-weight: 800; color: var(--ink-2);
  padding: 4px 0 12px; text-transform: uppercase; letter-spacing: .08em;
}
.btn-secondary {
  display: block; width: 100%; text-align: center;
  padding: 15px; border-radius: 16px;
  background: var(--bg-soft); color: var(--ink-2);
  border: 1px solid var(--line);
  font-weight: 800; font-size: 13px;
  text-transform: uppercase; letter-spacing: .06em;
}

/* ---------- Календарь ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin: 8px 4px 14px; }
.cal-title { font-size: 16px; font-weight: 850; text-transform: uppercase; font-style: italic; letter-spacing: .03em; }
.cal-nav {
  width: 40px; height: 40px; border-radius: 12px; font-size: 22px;
  background: var(--bg-soft); border: 1px solid var(--line); color: var(--ink-2);
}
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-weekdays { margin-bottom: 6px; }
.cal-weekdays span { text-align: center; font-size: 11px; color: var(--ink-3); font-weight: 800; text-transform: uppercase; }
.cal-day {
  aspect-ratio: 1; border-radius: 14px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 15px; font-weight: 650;
  background: var(--card); border: 1px solid var(--line);
  position: relative; color: var(--ink-2);
}
.cal-day.empty { background: none; border: none; }
.cal-day.today { border-color: var(--ink-2); color: var(--ink); }
.cal-day.has-menu { background: var(--accent-soft); border-color: rgba(200,241,53,.3); color: var(--accent); font-weight: 800; }
.cal-day.selected { outline: 2px solid var(--accent); color: var(--accent); }
.cal-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.cal-detail { margin-top: 18px; }
.cal-empty { text-align: center; font-size: 13px; color: var(--ink-3); padding: 12px; }
.cal-menu-card {
  background: linear-gradient(160deg, var(--card-2), var(--card) 55%);
  border: 1px solid var(--line);
  border-radius: 20px; box-shadow: var(--shadow); padding: 18px;
}
.cal-menu-date { font-weight: 850; font-size: 14px; margin-bottom: 10px; text-transform: uppercase; font-style: italic; letter-spacing: .03em; }
.cal-menu-row { display: flex; gap: 10px; padding: 7px 0; font-size: 14px; align-items: baseline; }
.cal-menu-row .t { color: var(--accent); font-weight: 850; font-size: 11px; flex: 0 0 44px; letter-spacing: .05em; }
.btn-danger {
  margin-top: 12px; width: 100%; padding: 13px; border-radius: 14px;
  background: var(--like-soft); color: var(--like); font-weight: 800; font-size: 12px;
  text-transform: uppercase; letter-spacing: .06em;
  border: 1px solid rgba(255, 90, 60, 0.25);
}

/* ---------- Баланс ---------- */
.balance-hero { text-align: center; padding: 18px 0 8px; }
.score-ring { position: relative; width: 160px; height: 160px; margin: 0 auto; }
.score-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--bg-soft); stroke-width: 11; }
.ring-fg {
  fill: none; stroke: var(--accent); stroke-width: 11; stroke-linecap: round;
  stroke-dasharray: 326.7; stroke-dashoffset: 326.7;
  transition: stroke-dashoffset .8s cubic-bezier(.2,.8,.3,1);
  filter: drop-shadow(0 0 10px rgba(200, 241, 53, 0.45));
}
.score-num {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.score-num span { font-size: 44px; font-weight: 900; letter-spacing: -0.03em; font-style: italic; }
.score-num small { font-size: 11px; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: .08em; }
.balance-caption { font-size: 13px; color: var(--ink-2); margin-top: 12px; }
.balance-list { margin-top: 18px; display: flex; flex-direction: column; gap: 10px; }
.bal-row {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 18px; padding: 14px 16px;
}
.bal-top { display: flex; justify-content: space-between; font-size: 14px; font-weight: 750; }
.bal-top .v { color: var(--ink-2); font-weight: 600; font-size: 12.5px; }
.bal-bar { height: 7px; border-radius: 4px; background: var(--bg-soft); margin-top: 9px; overflow: hidden; }
.bal-fill { height: 100%; border-radius: 4px; background: var(--accent); transition: width .6s ease; box-shadow: 0 0 8px rgba(200,241,53,.4); }
.bal-row.warn .bal-fill { background: var(--warn); box-shadow: 0 0 8px rgba(255,180,60,.35); }
.bal-row.over .bal-fill { background: var(--like); box-shadow: 0 0 8px rgba(255,90,60,.35); }
.bal-hint { font-size: 12px; color: var(--ink-3); margin-top: 7px; }
.balance-note {
  margin: 18px 6px; font-size: 12.5px; color: var(--ink-3);
  text-align: center; line-height: 1.5;
}

/* ---------- Покупки ---------- */
.shop-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 2px 14px; }
.shop-sub { font-size: 12px; font-weight: 700; color: var(--ink-2); text-transform: uppercase; letter-spacing: .05em; }
.shop-group { margin-bottom: 18px; }
.shop-group h3 {
  font-size: 11px; font-weight: 850; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: .1em; margin: 0 4px 8px; font-style: italic;
}
.shop-items { background: var(--card); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; }
.shop-item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px; width: 100%; text-align: left;
}
.shop-item + .shop-item { border-top: 1px solid var(--line); }
.shop-check {
  flex: 0 0 24px; height: 24px; border-radius: 8px;
  border: 2px solid var(--ink-3); display: grid; place-items: center;
  color: transparent; transition: all .15s ease;
}
.shop-item.done .shop-check { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.shop-name { flex: 1; font-size: 15px; }
.shop-item.done .shop-name { color: var(--ink-3); text-decoration: line-through; }
.shop-qty { font-size: 12.5px; font-weight: 650; color: var(--ink-2); white-space: nowrap; }

/* ---------- Сезонность ---------- */
.season-strip {
  font-size: 11.5px; font-weight: 700; color: var(--accent);
  background: var(--accent-soft); border: 1px solid rgba(200, 241, 53, 0.22);
  border-radius: 999px; padding: 5px 12px; margin-bottom: 8px;
  align-self: flex-start; max-width: 100%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.leaf { font-style: normal; margin-left: 5px; font-size: 11px; }

.season-block {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 18px; padding: 14px 16px; margin-bottom: 14px;
}
.season-block.soon { border-color: rgba(200, 241, 53, 0.35); background: var(--accent-soft); }
.season-block.ending { border-color: rgba(255, 180, 60, 0.3); }
.season-block h3 {
  font-size: 11.5px; font-weight: 850; letter-spacing: .08em;
  text-transform: uppercase; font-style: italic; margin-bottom: 10px;
}
.season-block.soon h3 { color: var(--accent); }
.season-block.ending h3 { color: var(--warn); }
.season-block.now h3 { color: var(--ink-2); }
.season-rows { display: flex; flex-direction: column; gap: 7px; }
.season-row { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.s-name { font-size: 14.5px; font-weight: 650; }
.s-when { font-size: 11.5px; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.tag {
  font-style: normal; font-size: 9.5px; font-weight: 800; letter-spacing: .04em;
  text-transform: uppercase; color: var(--ink-3);
  border: 1px solid var(--line); border-radius: 6px; padding: 2px 5px; margin-left: 6px;
  vertical-align: 1px;
}
.season-note { font-size: 11.5px; color: var(--ink-3); line-height: 1.4; margin-top: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: 12.5px; font-weight: 650; padding: 5px 11px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  border: 1px solid rgba(200, 241, 53, 0.25);
}
.chip.import { background: var(--bg-soft); color: var(--ink-2); border-color: var(--line); }
.chip.stored { background: transparent; color: var(--ink-2); border-color: var(--ink-3); border-style: dashed; }
.season-block h3.sub { margin-top: 14px; color: var(--ink-3); }

.range-toggle { display: flex; gap: 4px; background: var(--bg-soft); padding: 3px; border-radius: 999px; }
.range-toggle { flex: 0 0 auto; }
.range-btn {
  font-size: 12px; font-weight: 800; color: var(--ink-3);
  padding: 7px 14px; border-radius: 999px; white-space: nowrap;
  text-transform: uppercase; letter-spacing: .04em;
}
.range-btn.active { background: var(--accent); color: var(--accent-ink); }
#shop-refresh { margin-bottom: 18px; }

/* ---------- Таббар ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; justify-content: space-around;
  background: rgba(20, 22, 16, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--ink-3); font-size: 10px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .04em;
  padding: 4px 12px; border-radius: 14px;
  transition: color .15s ease;
}
.tab.active { color: var(--accent); }
.tab.active svg { filter: drop-shadow(0 0 6px rgba(200, 241, 53, 0.5)); }
