/* ФудКомпас — стили мини-приложения. Цвета задаются темами в themes.css. */
*,
*::before,
*::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }
body {
  font-family: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
  overflow-x: hidden;
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: var(--accent); text-decoration: none; }
img { max-width: 100%; display: block; }

/* ---------- фон с мягкими пятнами ---------- */
.backdrop { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.backdrop i {
  position: absolute; border-radius: 50%; filter: blur(70px); opacity: var(--blob-opacity);
  animation: drift 22s ease-in-out infinite alternate;
}
.backdrop i:nth-child(1) { width: 60vw; height: 60vw; background: var(--blob-1); top: -18vw; left: -15vw; }
.backdrop i:nth-child(2) { width: 55vw; height: 55vw; background: var(--blob-2); top: 30vh; right: -20vw; animation-delay: -7s; }
.backdrop i:nth-child(3) { width: 50vw; height: 50vw; background: var(--blob-3); bottom: -20vw; left: 10vw; animation-delay: -14s; }
@keyframes drift { to { transform: translate3d(6vw, 4vh, 0) scale(1.12); } }

/* ---------- каркас ---------- */
.app {
  max-width: 560px; margin: 0 auto; min-height: 100vh;
  padding: calc(var(--safe-top) + 12px) 16px calc(var(--safe-bottom) + 96px);
}
.view { animation: viewIn .32s cubic-bezier(.2, .8, .2, 1); }
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 16px; }
.topbar h1 { font-size: 26px; line-height: 1.15; margin: 0; letter-spacing: -.02em; font-weight: 800; }
.topbar .sub { color: var(--text-2); font-size: 14px; margin-top: 2px; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; flex: none;
  background: var(--surface); border: 1px solid var(--border); font-size: 20px;
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); transition: transform .15s;
}
.icon-btn:active { transform: scale(.92); }

.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 22px 2px 10px; }
.section-title h2 { font-size: 18px; margin: 0; font-weight: 800; letter-spacing: -.01em; }
.section-title a, .section-title button { font-size: 14px; color: var(--accent); font-weight: 600; }

/* ---------- карточки ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 22px; padding: 16px;
  box-shadow: var(--shadow); backdrop-filter: blur(22px) saturate(1.3); -webkit-backdrop-filter: blur(22px) saturate(1.3);
}
.card + .card { margin-top: 12px; }
.card.tight { padding: 12px 14px; }
.card.hero {
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-ink);
  border: 0; position: relative; overflow: hidden;
}
.card.hero::after {
  content: ""; position: absolute; width: 220px; height: 220px; border-radius: 50%;
  background: rgba(255, 255, 255, .14); right: -70px; top: -90px;
}
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 10px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.grid-2 > *, .grid-3 > * { min-width: 0; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.center { text-align: center; }
.hidden { display: none !important; }

/* ---------- огонёк серии ---------- */
.streak { display: flex; align-items: center; gap: 14px; position: relative; z-index: 1; }
.flame { position: relative; width: 64px; height: 72px; flex: none; }
.flame span {
  position: absolute; left: 50%; bottom: 0; border-radius: 50% 50% 45% 45% / 60% 60% 40% 40%;
  transform-origin: 50% 100%; animation: flicker 1.6s ease-in-out infinite;
}
.flame .f1 { width: 52px; height: 66px; margin-left: -26px; background: radial-gradient(circle at 50% 75%, #ffd76a, #ff8a3d 55%, #ff4d4d); }
.flame .f2 { width: 34px; height: 46px; margin-left: -17px; background: radial-gradient(circle at 50% 80%, #fff6c9, #ffc93d 60%, #ff9a3d); animation-delay: -.4s; }
.flame .f3 { width: 16px; height: 22px; margin-left: -8px; background: #fffbe8; animation-delay: -.8s; opacity: .9; }
.flame.off span { filter: grayscale(1) brightness(1.1); opacity: .35; animation: none; }
@keyframes flicker {
  0%, 100% { transform: scale(1) rotate(-2deg); }
  25% { transform: scale(1.04, .97) rotate(2deg); }
  50% { transform: scale(.97, 1.05) rotate(-1deg); }
  75% { transform: scale(1.03, .98) rotate(1.5deg); }
}
.streak .num { font-size: 40px; font-weight: 800; line-height: 1; letter-spacing: -.03em; }
.streak .label { font-size: 14px; opacity: .9; }
.week { display: flex; gap: 6px; margin-top: 14px; position: relative; z-index: 1; }
.week div {
  flex: 1; text-align: center; font-size: 11px; padding: 6px 0; border-radius: 10px;
  background: rgba(255, 255, 255, .16); font-weight: 600;
}
.week div.on { background: rgba(255, 255, 255, .92); color: var(--accent-dark); }

/* ---------- кольцо калорий и шкалы БЖУ ---------- */
.ring { position: relative; width: 112px; height: 112px; flex: none; }
.ring svg { transform: rotate(-90deg); }
.ring .track { stroke: var(--surface-2); }
.ring .value { stroke: url(#ringGradient); stroke-linecap: round; transition: stroke-dashoffset .9s cubic-bezier(.2, .8, .2, 1); }
.ring .inner { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.ring .inner b { font-size: 22px; display: block; letter-spacing: -.02em; }
.ring .inner small { color: var(--text-2); font-size: 11px; }
.macro { margin-top: 8px; }
.macro .top { display: flex; justify-content: space-between; font-size: 13px; }
.macro .top b { font-weight: 700; }
.bar { height: 8px; border-radius: 8px; background: var(--surface-2); overflow: hidden; margin-top: 4px; }
.bar i { display: block; height: 100%; border-radius: 8px; width: 0; transition: width .9s cubic-bezier(.2, .8, .2, 1); }
.bar.p i { background: var(--c-protein); }
.bar.f i { background: var(--c-fat); }
.bar.c i { background: var(--c-carbs); }
.bar.load i { background: linear-gradient(90deg, var(--green), var(--yellow), var(--red)); }

/* ---------- светофор ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; white-space: nowrap; background: var(--surface-2);
  max-width: 100%; overflow: hidden; text-overflow: ellipsis;
}
.chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.chip.green { color: var(--green); background: var(--green-soft); }
.chip.yellow { color: var(--yellow); background: var(--yellow-soft); }
.chip.red { color: var(--red); background: var(--red-soft); }
.chip.grey { color: var(--text-2); }
.chip.plain::before { display: none; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot.green { background: var(--green); } .dot.yellow { background: var(--yellow); }
.dot.red { background: var(--red); } .dot.grey { background: var(--text-3); }
.tag { display: inline-block; padding: 3px 9px; border-radius: 8px; background: var(--surface-2); font-size: 12px; margin: 0 4px 4px 0; }
.personal { font-size: 12px; font-weight: 700; color: var(--accent); }

/* ---------- списки ---------- */
.list { display: flex; flex-direction: column; }
.item {
  display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--border);
  text-align: left; width: 100%;
}
.item:last-child { border-bottom: 0; }
.item .emoji {
  width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; font-size: 24px;
  background: var(--surface-2); flex: none; overflow: hidden;
}
.item .emoji img { width: 100%; height: 100%; object-fit: cover; }
.item .title { font-weight: 700; font-size: 15px; }
.item .meta { color: var(--text-2); font-size: 13px; }
.item:active { opacity: .7; }

/* ---------- поля ---------- */
.search {
  display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; padding: 0 8px 0 14px; height: 52px; backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
}
.search input { flex: 1; border: 0; outline: 0; background: transparent; font-size: 16px; min-width: 0; }
.field { display: block; margin-top: 12px; }
.field > span { display: block; font-size: 13px; color: var(--text-2); margin: 0 0 6px 4px; font-weight: 600; }
.input, select.input, textarea.input {
  width: 100%; height: 48px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface-2);
  padding: 0 14px; outline: 0; font-size: 16px; transition: border-color .2s; min-width: 0;
}
textarea.input { height: 92px; padding: 12px 14px; resize: none; }
.input:focus { border-color: var(--accent); }

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 50px; padding: 0 20px;
  border-radius: 16px; font-weight: 700; font-size: 16px; transition: transform .15s, opacity .2s;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-ink);
  box-shadow: 0 8px 24px -10px var(--accent);
}
.btn:active { transform: scale(.97); }
.btn.block { width: 100%; }
.btn.ghost { background: var(--surface-2); color: var(--text); box-shadow: none; }
.btn.danger { background: var(--red-soft); color: var(--red); box-shadow: none; }
.btn.sm { height: 38px; padding: 0 14px; font-size: 14px; border-radius: 12px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.pills { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: none; }
.pills::-webkit-scrollbar { display: none; }
.pill {
  flex: none; padding: 8px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border);
  font-size: 14px; font-weight: 600; transition: all .2s;
}
.pill.on { background: var(--text); color: var(--bg-solid); border-color: transparent; }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice {
  padding: 10px 14px; border-radius: 14px; background: var(--surface-2); border: 2px solid transparent;
  font-size: 14px; font-weight: 600; transition: all .18s; text-align: left;
}
.choice.on { border-color: var(--accent); background: var(--accent-soft); padding-right: 30px; position: relative; }
.choice.on::after {
  content: "✓"; position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font-weight: 800; color: var(--accent);
}
.choice small { display: block; font-weight: 500; color: var(--text-2); font-size: 12px; }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tile {
  padding: 14px; border-radius: 18px; background: var(--surface); border: 1px solid var(--border); text-align: left;
  display: flex; flex-direction: column; gap: 6px; min-height: 92px;
}
.tile .big { font-size: 28px; }
.tile b { font-size: 14px; }
.tile:active { transform: scale(.98); }

/* ---------- приёмы пищи ---------- */
.meal-head { display: flex; align-items: center; gap: 10px; }
.meal-head .em { font-size: 26px; }
.meal-head h3 { margin: 0; font-size: 17px; }
.add-line {
  display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; padding: 12px;
  margin-top: 8px; border-radius: 14px; border: 1.5px dashed var(--border-strong); color: var(--accent); font-weight: 700;
}
.feel-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.feel {
  min-width: 0; padding: 10px 4px; border-radius: 14px; background: var(--surface-2); font-size: 12px; font-weight: 600;
  line-height: 1.2; text-align: center; overflow-wrap: anywhere;
  display: flex; flex-direction: column; align-items: center; gap: 4px; transition: all .18s; border: 2px solid transparent;
}
.feel span { font-size: 24px; }
.feel.on { border-color: var(--accent); background: var(--accent-soft); }

.daynav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.daynav b { font-size: 16px; }
.water { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.glass {
  width: 30px; height: 38px; border-radius: 6px 6px 10px 10px; border: 2px solid var(--c-water);
  position: relative; overflow: hidden; transition: transform .15s;
}
.glass::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: var(--c-water); transition: height .4s; }
.glass.full::after { height: 78%; }
.glass:active { transform: scale(.9); }

/* ---------- карточка продукта ---------- */
.food-hero { text-align: center; padding: 22px 16px; }
.food-hero .big-emoji { font-size: 64px; line-height: 1; }
.food-hero img.photo { width: 120px; height: 120px; object-fit: contain; margin: 0 auto; border-radius: 18px; background: #fff; }
.food-hero h1 { font-size: 24px; margin: 12px 0 4px; letter-spacing: -.02em; }
.verdict {
  border-radius: 20px; padding: 16px; margin-top: 12px; color: var(--text); text-align: left;
  background: var(--surface-2); border: 1px solid var(--border);
}
.verdict.green { background: var(--green-soft); }
.verdict.yellow { background: var(--yellow-soft); }
.verdict.red { background: var(--red-soft); }
.verdict h2 { margin: 0 0 6px; font-size: 22px; display: flex; align-items: center; gap: 8px; }
.verdict ul { margin: 0; padding-left: 18px; }
.slider { width: 100%; margin: 14px 0 6px; accent-color: var(--accent); height: 28px; }
.grams { font-size: 30px; font-weight: 800; letter-spacing: -.02em; }
.portion-scale { position: relative; height: 10px; border-radius: 10px; margin-top: 8px; overflow: hidden; background: var(--surface-2); }
.portion-scale i { position: absolute; top: 0; bottom: 0; }
.nutri { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; }
.nutri div { background: var(--surface-2); border-radius: 14px; padding: 10px 4px; }
.nutri b { display: block; font-size: 17px; }
.nutri small { color: var(--text-2); font-size: 11px; }
.groups { display: flex; flex-wrap: wrap; gap: 6px; }
.group { padding: 8px 10px; border-radius: 12px; background: var(--surface-2); font-size: 13px; }
.group.rel { background: var(--red-soft); color: var(--red); font-weight: 700; }

/* ---------- графики ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--text-2); font-size: 10px; font-family: inherit; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); margin-top: 8px; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; background: var(--c); vertical-align: -1px; }
.stat { text-align: center; padding: 14px 6px; }
.stat b { font-size: 24px; display: block; letter-spacing: -.02em; }
.stat small { color: var(--text-2); font-size: 12px; }

/* ---------- достижения ---------- */
.badges { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.badge { text-align: center; font-size: 11px; color: var(--text-2); }
.badge .b {
  width: 56px; height: 56px; margin: 0 auto 4px; border-radius: 18px; display: grid; place-items: center;
  font-size: 28px; background: var(--surface-2); filter: grayscale(1); opacity: .45;
}
.badge.on .b { filter: none; opacity: 1; background: linear-gradient(135deg, var(--accent-soft), var(--surface-2)); }
.badge.on { color: var(--text); font-weight: 600; }

/* ---------- темы ---------- */
.themes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.theme-swatch {
  border-radius: 18px; padding: 10px; border: 2px solid transparent; text-align: center; font-size: 12px; font-weight: 700;
  background: var(--surface-2);
}
.theme-swatch.on { border-color: var(--accent); }
.theme-swatch .sw { height: 46px; border-radius: 12px; margin-bottom: 6px; display: flex; overflow: hidden; }
.theme-swatch .sw i { flex: 1; }

/* ---------- нижняя навигация ---------- */
.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--safe-bottom) + 10px);
  width: calc(100% - 24px); max-width: 536px; height: 66px; border-radius: 24px; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr); padding: 6px;
  background: var(--tabbar); border: 1px solid var(--border); box-shadow: var(--shadow-strong);
  backdrop-filter: blur(26px) saturate(1.5); -webkit-backdrop-filter: blur(26px) saturate(1.5);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border-radius: 18px;
  font-size: 10.5px; font-weight: 700; color: var(--text-2); transition: all .2s;
}
.tab .ic { font-size: 21px; transition: transform .25s cubic-bezier(.3, 1.6, .5, 1); filter: grayscale(.7); }
.tab.on { color: var(--text); background: var(--surface-2); }
.tab.on .ic { transform: translateY(-2px) scale(1.12); filter: none; }
.fab {
  position: fixed; right: max(16px, calc(50% - 264px)); bottom: calc(var(--safe-bottom) + 88px); z-index: 19;
  width: 58px; height: 58px; border-radius: 20px; font-size: 28px; color: var(--accent-ink);
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 12px 28px -8px var(--accent);
  display: grid; place-items: center; transition: transform .2s;
}
.fab:active { transform: scale(.9) rotate(90deg); }

/* ---------- шторка и тосты ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet-wrap .shade { position: absolute; inset: 0; background: rgba(0, 0, 0, .38); animation: fade .25s; }
.sheet {
  position: relative; width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto; background: var(--bg-solid);
  border-radius: 28px 28px 0 0; padding: 10px 18px calc(var(--safe-bottom) + 20px); animation: up .32s cubic-bezier(.2, .8, .2, 1);
}
.sheet .grab { width: 42px; height: 5px; border-radius: 5px; background: var(--border-strong); margin: 0 auto 12px; }
.sheet h2 { margin: 0 0 12px; font-size: 20px; }
@keyframes up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fade { from { opacity: 0; } }
.toast {
  position: fixed; left: 50%; top: calc(var(--safe-top) + 14px); transform: translateX(-50%); z-index: 80;
  background: var(--text); color: var(--bg-solid); padding: 12px 18px; border-radius: 16px; font-weight: 600; font-size: 14px;
  box-shadow: var(--shadow-strong); animation: toast 2.6s ease forwards; max-width: 90vw; text-align: center;
}
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, -12px); } 10%, 85% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } }

/* ---------- загрузка и пустые состояния ---------- */
.skeleton { border-radius: 18px; background: linear-gradient(90deg, var(--surface-2), var(--surface), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.empty { text-align: center; padding: 30px 10px; color: var(--text-2); }
.empty .big { font-size: 46px; margin-bottom: 6px; }
.splash { min-height: 80vh; display: grid; place-items: center; text-align: center; }
.splash .logo { font-size: 64px; animation: spin 2.4s ease-in-out infinite; }
@keyframes spin { 50% { transform: rotate(18deg) scale(1.06); } }

/* ---------- онбординг ---------- */
.steps { display: flex; gap: 6px; margin: 4px 0 18px; }
.steps i { flex: 1; height: 5px; border-radius: 5px; background: var(--surface-2); transition: background .3s; }
.steps i.on { background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.onb-emoji { font-size: 56px; margin: 6px 0; }
.sticky-bottom {
  position: sticky; bottom: 0; margin: 20px -16px 0; padding: 16px 16px calc(var(--safe-bottom) + 10px);
  background: linear-gradient(to top, var(--bg-solid) 65%, transparent);
}

/* ---------- сканер ---------- */
.scanner { position: relative; border-radius: 24px; overflow: hidden; background: #000; aspect-ratio: 3 / 4; }
.scanner video { width: 100%; height: 100%; object-fit: cover; }
.scanner .frame {
  position: absolute; left: 12%; right: 12%; top: 36%; height: 26%; border-radius: 18px;
  box-shadow: 0 0 0 2000px rgba(0, 0, 0, .45); border: 3px solid rgba(255, 255, 255, .9);
}
.scanner .laser { position: absolute; left: 14%; right: 14%; top: 49%; height: 2px; background: var(--red); box-shadow: 0 0 12px var(--red); animation: laser 1.8s ease-in-out infinite; }
@keyframes laser { 50% { transform: translateY(-40px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

input.input[type="time"] { padding: 0 6px; font-size: 15px; }
.is-busy { opacity: .55; pointer-events: none; }
