/* ============================================================
   Vibe Fit — дизайн-система
   Светлая тема, салатовые акценты, градиенты, мобильный форм-фактор
   ============================================================ */

:root {
  --bg: #f3f7ee;
  --surface: #fbfdf8;
  --card: #ffffff;
  --card-2: #eef3e3;
  --line: #e3ead5;
  --text: #1c2615;
  --muted: #5f7155;
  --faint: #97a68c;
  --accent: #5fb50c;
  --accent-bright: #a3e635;
  --accent-dim: #4c9a05;
  --accent-soft: rgba(132, 204, 22, 0.15);
  --violet: #8b5cf6;
  --violet-soft: rgba(139, 92, 246, 0.11);
  --blue: #2596dd;
  --blue-soft: rgba(37, 150, 221, 0.11);
  --orange: #e8920f;
  --orange-soft: rgba(232, 146, 15, 0.13);
  --red: #e05252;
  --red-soft: rgba(224, 82, 82, 0.10);
  --grad: linear-gradient(135deg, #a8e63a 0%, #2fce86 100%);
  --grad-deep: linear-gradient(135deg, #84cc16 0%, #0d9488 100%);
  --on-grad: #15290a;
  --r-lg: 22px;
  --r-md: 16px;
  --r-sm: 12px;
  --shadow: 0 10px 30px rgba(82, 125, 44, 0.13);
  --shadow-sm: 0 3px 12px rgba(82, 125, 44, 0.09);
  --tabbar-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

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

html, body {
  height: 100%;
  background: linear-gradient(160deg, #e6f1d8 0%, #d8e9cf 50%, #cfe4d0 100%);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
  overscroll-behavior: none;
}

/* ---------- «Телефон» ---------- */
#phone {
  position: relative;
  margin: 0 auto;
  max-width: 480px;
  height: 100dvh;
  background:
    radial-gradient(120% 46% at 50% -6%, rgba(168, 230, 58, 0.22) 0%, rgba(168, 230, 58, 0) 70%),
    var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

@media (min-width: 540px) {
  body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px 0; }
  #phone {
    height: min(900px, calc(100vh - 40px));
    border-radius: 40px;
    border: 1px solid rgba(124, 160, 90, 0.25);
    box-shadow: 0 30px 80px rgba(72, 110, 45, 0.28);
  }
}

/* ---------- Экран ---------- */
.screen {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: calc(16px + var(--safe-top)) 16px calc(var(--tabbar-h) + var(--safe-bottom) + 24px);
  scrollbar-width: none;
}
.screen::-webkit-scrollbar { display: none; }
.screen.no-tabbar { padding-bottom: calc(24px + var(--safe-bottom)); }

.hidden { display: none !important; }

/* ---------- Таб-бар ---------- */
.tabbar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex;
  background: rgba(251, 253, 248, 0.88);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
  z-index: 50;
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--faint);
  font-family: inherit;
  cursor: pointer;
  transition: color 0.15s, transform 0.15s;
}
.tab-icon { font-size: 21px; line-height: 1; }
.tab-label { font-size: 10.5px; font-weight: 650; letter-spacing: 0.02em; }
.tab.active { color: var(--accent-dim); }
.tab.active .tab-icon { transform: translateY(-1px) scale(1.08); }
.tab:active { transform: scale(0.94); }

/* ---------- Типографика ---------- */
h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
h2 { font-size: 20px; font-weight: 750; letter-spacing: -0.01em; }
h3 { font-size: 16px; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 11.5px; }
.bold { font-weight: 700; }
.accent { color: var(--accent-dim); }

.section-title {
  display: flex; align-items: center; justify-content: space-between;
  margin: 22px 2px 10px;
}
.section-title h2 { font-size: 17px; }
.section-title .link { font-size: 13px; color: var(--accent-dim); background: none; border: none; font-family: inherit; font-weight: 700; cursor: pointer; }

/* ---------- Шапка ---------- */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.app-header .greeting { font-size: 13px; color: var(--muted); }
.app-header .title { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--grad);
  color: var(--on-grad);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 17px;
  border: none; cursor: pointer;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

/* ---------- Карточки ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}
.card.flat { background: var(--card-2); box-shadow: none; }
.card.grad-card {
  background: linear-gradient(135deg, rgba(168, 230, 58, 0.20), rgba(47, 206, 134, 0.10)), var(--card);
  border-color: rgba(132, 204, 22, 0.3);
}
.card-row { display: flex; gap: 12px; margin-bottom: 12px; }
.card-row .card { flex: 1; margin-bottom: 0; }

.tappable { cursor: pointer; transition: transform 0.12s, background 0.15s, box-shadow 0.15s; }
.tappable:active { transform: scale(0.98); background: var(--card-2); }

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  padding: 15px 20px;
  border-radius: var(--r-md);
  border: none;
  font-family: inherit;
  font-size: 16px; font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s, opacity 0.15s, box-shadow 0.15s;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; pointer-events: none; }
.btn-primary { background: var(--grad); color: var(--on-grad); box-shadow: 0 6px 20px rgba(110, 190, 60, 0.35); }
.btn-ghost { background: var(--card); color: var(--text); border: 1.5px solid var(--line); }
.btn-danger { background: var(--red-soft); color: var(--red); }
.btn-violet { background: linear-gradient(135deg, #a78bfa, #7c3aed); color: #fff; box-shadow: 0 6px 20px rgba(139, 92, 246, 0.35); }
.btn-sm { width: auto; padding: 9px 16px; font-size: 14px; border-radius: 12px; }

.icon-btn {
  width: 38px; height: 38px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  font-size: 17px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-family: inherit;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.icon-btn:active { transform: scale(0.92); }

/* ---------- Поля ввода ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 650; color: var(--muted); margin-bottom: 7px; }
.input {
  width: 100%;
  padding: 14px 16px;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  -moz-appearance: textfield;
}
.input::-webkit-outer-spin-button, .input::-webkit-inner-spin-button { -webkit-appearance: none; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder { color: var(--faint); }

.search-bar {
  display: flex; align-items: center; gap: 10px;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  padding: 0 14px;
  margin-bottom: 12px;
}
.search-bar:focus-within { border-color: var(--accent); }
.search-bar input {
  flex: 1; border: none; background: none; outline: none;
  color: var(--text); font-family: inherit; font-size: 16px;
  padding: 13px 0;
}
.search-bar input::placeholder { color: var(--faint); }

/* ---------- Чипы ---------- */
.chip-row {
  display: flex; gap: 8px;
  overflow-x: auto;
  padding: 2px 0 10px;
  scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13.5px; font-weight: 650;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-dim); }
.chip:active { transform: scale(0.95); }

/* ---------- Сегментированный контрол ---------- */
.seg {
  display: flex;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 4px;
  gap: 4px;
  margin-bottom: 14px;
}
.seg button {
  flex: 1;
  padding: 9px 6px;
  border: none; border-radius: 11px;
  background: none;
  color: var(--muted);
  font-family: inherit; font-size: 13.5px; font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.seg button.active { background: var(--card); color: var(--text); box-shadow: var(--shadow-sm); }

/* ---------- Кольцо калорий ---------- */
.ring-card { display: flex; align-items: center; gap: 18px; }
.ring-wrap { position: relative; width: 132px; height: 132px; flex-shrink: 0; }
.ring-wrap svg { transform: rotate(-90deg); }
.ring-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.ring-center .val { font-size: 26px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; }
.ring-center .lbl { font-size: 11px; color: var(--muted); }
.ring-stats { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.ring-stat { display: flex; align-items: center; gap: 10px; }
.ring-stat .dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.ring-stat .name { font-size: 13px; color: var(--muted); flex: 1; }
.ring-stat .num { font-size: 14px; font-weight: 750; }

/* ---------- Полосы БЖУ ---------- */
.macros { display: flex; gap: 10px; margin-top: 16px; }
.macro { flex: 1; }
.macro .m-head { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 5px; }
.macro .m-name { color: var(--muted); font-weight: 650; }
.macro .m-val { font-weight: 750; }
.macro .m-track { height: 6px; border-radius: 99px; background: var(--card-2); overflow: hidden; }
.macro .m-fill { height: 100%; border-radius: 99px; transition: width 0.5s ease; }

/* ---------- Список (еда, упражнения) ---------- */
.li {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
}
.li .emoji {
  width: 42px; height: 42px;
  border-radius: 13px;
  background: var(--card-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 21px;
  flex-shrink: 0;
}
.li .li-body { flex: 1; min-width: 0; }
.li .li-title { font-size: 14.5px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li .li-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }
.li .li-end { text-align: right; flex-shrink: 0; }
.li .li-kcal { font-size: 14.5px; font-weight: 750; }
.li .li-unit { font-size: 11px; color: var(--faint); }
.li.tappable:active { background: var(--card-2); }
.li .del {
  border: none; background: none; color: var(--faint);
  font-size: 17px; cursor: pointer; padding: 6px; font-family: inherit;
  flex-shrink: 0;
}
.li .del:active { color: var(--red); }
.li .info {
  border: none; background: none; color: var(--faint);
  font-size: 16px; cursor: pointer; padding: 6px; font-family: inherit;
  flex-shrink: 0;
}
.li .info:active { color: var(--accent-dim, var(--accent)); }

/* ---------- Приёмы пищи ---------- */
.meal { margin-bottom: 16px; }
.meal-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px; padding: 0 2px;
}
.meal-head .meal-name { font-size: 16px; font-weight: 750; display: flex; align-items: center; gap: 8px; }
.meal-head .meal-kcal { font-size: 13px; color: var(--muted); font-weight: 650; }
.meal-add {
  width: 100%;
  padding: 12px;
  border: 1.5px dashed rgba(132, 204, 22, 0.45);
  border-radius: var(--r-md);
  background: none;
  color: var(--accent-dim);
  font-family: inherit; font-size: 14px; font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}
.meal-add:active { background: var(--accent-soft); }

/* ---------- Селектор даты ---------- */
.date-nav {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.date-nav .date-label { font-size: 16px; font-weight: 750; text-align: center; flex: 1; }
.date-nav .date-label .small { display: block; font-weight: 600; color: var(--muted); font-size: 12px; }

/* ---------- Вода ---------- */
.water-row { display: flex; align-items: center; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
.water-glass {
  width: 34px; height: 42px;
  border-radius: 8px 8px 11px 11px;
  border: 1.5px solid var(--line);
  background: var(--card-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s;
}
.water-glass.full {
  background: linear-gradient(180deg, rgba(37, 150, 221, 0.12), rgba(37, 150, 221, 0.22));
  border-color: var(--blue);
  animation: popIn 0.3s ease;
}
@keyframes popIn { 0% { transform: scale(0.6); } 70% { transform: scale(1.1); } 100% { transform: scale(1); } }

/* ---------- Stepper ---------- */
.stepper {
  display: flex; align-items: center; justify-content: center; gap: 18px;
}
.stepper .st-btn {
  width: 48px; height: 48px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--text);
  font-size: 22px; font-weight: 700;
  cursor: pointer; font-family: inherit;
  box-shadow: var(--shadow-sm);
}
.stepper .st-btn:active { background: var(--card-2); transform: scale(0.93); }
.stepper .st-val { font-size: 38px; font-weight: 800; min-width: 110px; text-align: center; letter-spacing: -0.02em; }
/* поле степпера редактируется с клавиатуры, но выглядит как крупная цифра */
input.st-val {
  width: 130px; max-width: 130px; font-family: inherit; color: var(--text);
  background: transparent; border: none; border-bottom: 2px dashed var(--line);
  padding: 0 0 2px; border-radius: 0; outline: none;
}
input.st-val:focus { border-bottom-color: var(--accent); }
.stepper .st-unit { font-size: 16px; color: var(--muted); font-weight: 600; }
/* числовое поле в карточках онбординга (возраст, рост, вес) */
.num-input {
  width: 78px; font-size: 24px; font-weight: 800; color: var(--text);
  background: transparent; border: none; border-bottom: 2px dashed var(--line);
  padding: 0 0 1px; outline: none; font-family: inherit; letter-spacing: -0.01em;
}
.num-input:focus { border-bottom-color: var(--accent); }

/* ---------- Обучающий тур ---------- */
.tut-root { position: fixed; inset: 0; z-index: 1000; }
.tut-spot {
  position: fixed; border-radius: 14px; pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(20, 30, 12, 0.62);
  outline: 2px solid var(--accent-bright); outline-offset: 2px;
  transition: left 0.28s, top 0.28s, width 0.28s, height 0.28s;
}
.tut-card {
  position: fixed; width: min(300px, calc(100% - 32px));
  background: var(--card); border-radius: 18px; padding: 16px 16px 14px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.35); pointer-events: auto;
}
.tut-step { font-size: 11px; font-weight: 700; color: var(--accent-dim); letter-spacing: 0.05em; }
.tut-title { font-size: 17px; font-weight: 800; margin: 3px 0 5px; }
.tut-text { font-size: 14px; color: var(--muted); line-height: 1.4; }
.tut-actions { display: flex; gap: 8px; align-items: center; margin-top: 14px; }
.tut-skip {
  border: 0; background: transparent; color: var(--faint); font: inherit;
  font-size: 14px; padding: 9px 10px; cursor: pointer; margin-right: auto;
}
.tut-next {
  border: 0; border-radius: 12px; background: var(--grad); color: var(--on-grad);
  font: inherit; font-weight: 700; font-size: 14px; padding: 10px 18px; cursor: pointer;
}
.tut-next:active { transform: scale(0.97); }

/* ---------- Онбординг ---------- */
.ob-progress {
  height: 4px; border-radius: 99px;
  background: var(--card-2);
  margin-bottom: 28px;
  overflow: hidden;
}
.ob-progress .fill { height: 100%; background: var(--grad); border-radius: 99px; transition: width 0.35s ease; }
.ob-step { animation: slideIn 0.3s ease; display: flex; flex-direction: column; min-height: calc(100dvh - 140px); }
.ob-step h1 { margin-bottom: 8px; }
.ob-step .sub { color: var(--muted); margin-bottom: 26px; font-size: 15px; }
.ob-body { flex: 1; }
.ob-foot { padding-top: 18px; }

.opt-card {
  display: flex; align-items: center; gap: 14px;
  width: 100%;
  padding: 16px;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  margin-bottom: 10px;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  text-align: left;
  transition: border-color 0.15s, background 0.15s, transform 0.12s;
  box-shadow: var(--shadow-sm);
}
.opt-card:active { transform: scale(0.98); }
.opt-card .o-emoji { font-size: 26px; flex-shrink: 0; }
.opt-card .o-title { font-size: 15.5px; font-weight: 700; }
.opt-card .o-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.opt-card.selected { border-color: var(--accent); background: var(--accent-soft); }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ---------- Логотип / сплэш ---------- */
.logo-mark {
  width: 88px; height: 88px;
  border-radius: 26px;
  background: var(--grad);
  display: flex; align-items: center; justify-content: center;
  font-size: 44px;
  margin: 0 auto 22px;
  box-shadow: 0 14px 40px rgba(110, 190, 60, 0.4);
}
.splash {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  min-height: calc(100dvh - 80px);
}
.splash .brand { font-size: 34px; font-weight: 850; letter-spacing: -0.03em; }
.splash .brand .fit { background: var(--grad-deep); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- Компаньон «Вайби» ---------- */
.companion {
  position: absolute;
  right: 14px;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 18px);
  width: 58px; height: 58px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  z-index: 60;
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.85) 0%, rgba(255, 255, 255, 0) 34%),
    radial-gradient(circle at 68% 75%, rgba(13, 148, 136, 0.85) 0%, rgba(13, 148, 136, 0) 55%),
    radial-gradient(circle at 50% 50%, #a8e63a 0%, #4ec956 55%, #1aa37a 100%);
  box-shadow:
    0 10px 28px rgba(46, 168, 110, 0.45),
    inset 0 -7px 16px rgba(8, 80, 60, 0.25),
    inset 0 5px 12px rgba(255, 255, 255, 0.5);
  animation: orbFloat 3.6s ease-in-out infinite;
  transition: transform 0.2s;
}
.companion:active { transform: scale(0.88); }
.companion::after {
  content: "";
  position: absolute;
  inset: -7px;
  border-radius: 50%;
  border: 2px solid rgba(110, 200, 90, 0.35);
  animation: orbRipple 2.8s ease-out infinite;
}
.companion .companion-face {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 23px;
  filter: drop-shadow(0 1px 2px rgba(0, 60, 30, 0.4));
}
@keyframes orbFloat {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-7px) scale(1.03); }
}
@keyframes orbRipple {
  0% { transform: scale(0.92); opacity: 0.9; }
  70%, 100% { transform: scale(1.35); opacity: 0; }
}

.companion-bubble {
  position: absolute;
  right: 82px;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 24px);
  max-width: 230px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px 16px 4px 16px;
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
  box-shadow: var(--shadow);
  z-index: 60;
  animation: bubbleIn 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.4);
  cursor: pointer;
}
@keyframes bubbleIn {
  from { opacity: 0; transform: translateX(14px) scale(0.85); }
  to { opacity: 1; transform: none; }
}
.companion-bubble.out { opacity: 0; transform: translateX(10px); transition: all 0.3s; }

/* мини-сфера (аватар в чате и шторках) */
.orb-mini {
  width: 42px; height: 42px;
  border-radius: 50%;
  flex-shrink: 0;
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.85) 0%, rgba(255, 255, 255, 0) 34%),
    radial-gradient(circle at 50% 50%, #a8e63a 0%, #4ec956 55%, #1aa37a 100%);
  box-shadow: inset 0 -4px 9px rgba(8, 80, 60, 0.25), 0 4px 12px rgba(46, 168, 110, 0.35);
  display: flex; align-items: center; justify-content: center;
  font-size: 17px;
}

/* ---------- AI-генерация (лоадер) ---------- */
.ai-loader { text-align: center; padding: 60px 0; }
.ai-orb {
  width: 92px; height: 92px;
  margin: 0 auto 26px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0) 36%),
    radial-gradient(circle at 50% 50%, #a8e63a 0%, #4ec956 55%, #1aa37a 100%);
  animation: pulse 1.6s ease-in-out infinite;
  display: flex; align-items: center; justify-content: center;
  font-size: 40px;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(110, 200, 90, 0.4); }
  50% { transform: scale(1.07); box-shadow: 0 0 0 28px rgba(110, 200, 90, 0); }
}
.ai-status { color: var(--muted); font-size: 14.5px; min-height: 22px; transition: opacity 0.3s; }

/* ---------- Результат плана ---------- */
.target-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.target-cell {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.target-cell .t-val { font-size: 21px; font-weight: 800; letter-spacing: -0.02em; }
.target-cell .t-lbl { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------- Bottom sheet ---------- */
.sheet-backdrop {
  position: absolute; inset: 0;
  background: rgba(40, 60, 25, 0.35);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 90;
  animation: fadeIn 0.2s ease;
}
.sheet {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  max-height: 88%;
  background: var(--surface);
  border-radius: 26px 26px 0 0;
  border-top: 1px solid var(--line);
  z-index: 100;
  display: flex; flex-direction: column;
  animation: sheetUp 0.32s cubic-bezier(0.2, 0.9, 0.3, 1);
  padding-bottom: var(--safe-bottom);
  box-shadow: 0 -10px 40px rgba(60, 100, 35, 0.18);
}
.sheet.full { height: 94%; }
.sheet-grip {
  width: 40px; height: 4px;
  border-radius: 99px;
  background: var(--line);
  margin: 10px auto 4px;
  flex-shrink: 0;
}
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 18px 12px;
  flex-shrink: 0;
}
.sheet-head h2 { font-size: 18px; }
.sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 18px 22px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.sheet-body::-webkit-scrollbar { display: none; }
@keyframes sheetUp { from { transform: translateY(60%); opacity: 0.4; } to { transform: translateY(0); opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Тост ---------- */
#toast-root {
  position: absolute;
  left: 0; right: 0;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  z-index: 200;
  pointer-events: none;
}
.toast {
  background: #243318;
  color: #f0f7e6;
  padding: 11px 18px;
  border-radius: 14px;
  font-size: 14px; font-weight: 650;
  box-shadow: var(--shadow);
  animation: toastIn 0.25s ease;
  max-width: 85%;
  text-align: center;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(10px) scale(0.95); } to { opacity: 1; transform: none; } }

/* ---------- Конфетти ---------- */
.confetti-bit {
  position: absolute;
  width: 8px; height: 12px;
  border-radius: 2px;
  z-index: 300;
  pointer-events: none;
  animation: confettiFly 1s ease-out forwards;
}
@keyframes confettiFly {
  0% { transform: translate(0, 0) rotate(0deg) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) scale(0.7); opacity: 0; }
}

/* ---------- Чат ---------- */
.chat-wrap { display: flex; flex-direction: column; height: 100%; }
.chat-scroll {
  flex: 1; overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px;
  padding: 4px 0 14px;
  scrollbar-width: none;
}
.chat-scroll::-webkit-scrollbar { display: none; }
.msg {
  max-width: 84%;
  padding: 11px 15px;
  border-radius: 18px;
  font-size: 14.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
  animation: toastIn 0.2s ease;
}
.msg.ai { align-self: flex-start; background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 6px; box-shadow: var(--shadow-sm); }
.msg.user { align-self: flex-end; background: var(--accent-soft); border: 1px solid rgba(132, 204, 22, 0.35); border-bottom-right-radius: 6px; }
.msg b { color: var(--accent-dim); font-weight: 750; }
.typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted);
  animation: blink 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 70%, 100% { opacity: 0.25; } 35% { opacity: 1; } }

.chat-suggest { display: flex; gap: 8px; overflow-x: auto; padding: 8px 0; scrollbar-width: none; flex-shrink: 0; }
.chat-suggest::-webkit-scrollbar { display: none; }
.chat-input-row {
  display: flex; gap: 8px; align-items: flex-end;
  padding-top: 8px;
  flex-shrink: 0;
}
.chat-input-row .input { flex: 1; border-radius: 22px; padding: 12px 18px; }
.send-btn {
  width: 46px; height: 46px;
  border-radius: 50%;
  border: none;
  background: var(--grad);
  color: var(--on-grad);
  font-size: 19px;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(110, 190, 60, 0.4);
}
.send-btn:active { transform: scale(0.92); }
.send-btn:disabled { opacity: 0.4; }

/* ---------- AI-совет ---------- */
.tip-card {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.10), rgba(37, 150, 221, 0.08)), var(--card);
  border: 1px solid rgba(139, 92, 246, 0.25);
  border-radius: var(--r-lg);
  padding: 15px 16px;
  margin-bottom: 12px;
  display: flex; gap: 12px;
  align-items: flex-start;
  box-shadow: var(--shadow-sm);
}
.tip-card .tip-title { font-size: 12px; font-weight: 750; color: var(--violet); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 3px; }
.tip-card .tip-text { font-size: 14px; line-height: 1.5; }

/* ---------- Стрик ---------- */
.streak-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: linear-gradient(135deg, rgba(232, 146, 15, 0.15), rgba(224, 82, 82, 0.10));
  border: 1px solid rgba(232, 146, 15, 0.35);
  color: #b06b07;
  font-size: 13px; font-weight: 800;
  padding: 7px 13px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
}

/* ---------- Достижения ---------- */
.ach-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ach-cell {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px;
  text-align: center;
  transition: transform 0.15s;
}
.ach-cell .a-emoji { font-size: 30px; margin-bottom: 6px; }
.ach-cell .a-title { font-size: 13.5px; font-weight: 750; }
.ach-cell .a-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.ach-cell.done {
  background: linear-gradient(135deg, rgba(168, 230, 58, 0.18), rgba(47, 206, 134, 0.10)), var(--card);
  border-color: rgba(132, 204, 22, 0.4);
}
.ach-cell.locked { opacity: 0.55; }
.ach-cell.locked .a-emoji { filter: grayscale(1); }

/* ---------- Pro ---------- */
.pro-card {
  background: linear-gradient(135deg, #2d1f5e 0%, #4c1d95 55%, #7c3aed 100%);
  border-radius: var(--r-lg);
  padding: 18px;
  margin-bottom: 12px;
  color: #fff;
  position: relative;
  overflow: hidden;
  box-shadow: 0 12px 32px rgba(76, 29, 149, 0.35);
}
.pro-card::after {
  content: "";
  position: absolute;
  top: -40px; right: -40px;
  width: 140px; height: 140px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(168, 230, 58, 0.45), transparent 70%);
}
.pro-badge {
  display: inline-block;
  background: var(--grad);
  color: var(--on-grad);
  font-size: 10.5px; font-weight: 850;
  letter-spacing: 0.08em;
  padding: 3px 9px;
  border-radius: 99px;
  text-transform: uppercase;
}
.pro-feature { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: 14px; }
.pro-feature .pf-icon { width: 28px; text-align: center; font-size: 17px; flex-shrink: 0; }

/* ---------- Графики ---------- */
.chart-card svg { display: block; width: 100%; height: auto; }
.legend { display: flex; gap: 16px; margin-top: 10px; flex-wrap: wrap; }
.legend .lg { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.legend .lg .dot { width: 9px; height: 9px; border-radius: 3px; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.stat-cell {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px;
  box-shadow: var(--shadow-sm);
}
.stat-cell .s-icon { font-size: 20px; margin-bottom: 8px; }
.stat-cell .s-val { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.stat-cell .s-val .unit { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat-cell .s-lbl { font-size: 12px; color: var(--muted); margin-top: 1px; }
.stat-cell .s-delta { font-size: 11.5px; font-weight: 700; margin-top: 4px; }
.s-delta.up { color: var(--accent-dim); }
.s-delta.down { color: var(--red); }

/* ---------- Пустые состояния ---------- */
.empty {
  text-align: center;
  padding: 36px 24px;
  color: var(--muted);
}
.empty .e-icon { font-size: 42px; margin-bottom: 10px; }
.empty .e-text { font-size: 14px; }

/* ---------- Сканер ---------- */
.scan-view {
  position: relative;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: #11160d;
  aspect-ratio: 3 / 4;
  margin-bottom: 14px;
}
.scan-view .empty { color: #aebfa0; }
.scan-view video { width: 100%; height: 100%; object-fit: cover; }
/* рамка-прицел живого OCR: позиция и размер задаются шагом сканирования */
.scan-view .ocr-frame {
  position: absolute;
  border: 2.5px solid var(--accent-bright);
  border-radius: 14px;
  box-shadow: 0 0 0 999px rgba(10, 16, 6, 0.5);
  pointer-events: none;
  transition: top 0.35s ease, height 0.35s ease, left 0.35s ease, width 0.35s ease;
  overflow: hidden;
}
/* оверлей слов: кадр обрезан ровно по рамке, пропорции совпадают */
.scan-view .ocr-overlay {
  width: 100%; height: 100%;
  display: block;
}
.scan-frame {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.scan-frame .frame {
  width: 75%; height: 34%;
  border: 2.5px solid var(--accent-bright);
  border-radius: 16px;
  box-shadow: 0 0 0 999px rgba(10, 16, 6, 0.45);
  position: relative;
  overflow: hidden;
}
.scan-frame .laser {
  position: absolute; left: 6%; right: 6%;
  height: 2px;
  background: var(--red);
  box-shadow: 0 0 8px var(--red);
  animation: laser 1.8s ease-in-out infinite;
}
@keyframes laser { 0%, 100% { top: 12%; } 50% { top: 84%; } }

/* ---------- Фото AI ---------- */
.photo-drop {
  border: 2px dashed rgba(132, 204, 22, 0.45);
  border-radius: var(--r-lg);
  padding: 44px 20px;
  text-align: center;
  cursor: pointer;
  color: var(--muted);
  background: var(--card);
}
.photo-drop:active { background: var(--accent-soft); }
.photo-drop .p-icon { font-size: 40px; margin-bottom: 10px; }
.photo-preview {
  width: 100%;
  border-radius: var(--r-lg);
  max-height: 280px;
  object-fit: cover;
  margin-bottom: 14px;
}
.scan-line-wrap { position: relative; overflow: hidden; border-radius: var(--r-lg); margin-bottom: 14px; }
.scan-line-wrap img { display: block; width: 100%; max-height: 280px; object-fit: cover; }
.scan-line-wrap .scanline {
  position: absolute; left: 0; right: 0; height: 3px;
  background: var(--accent-bright);
  box-shadow: 0 0 16px var(--accent-bright);
  animation: laser 2s ease-in-out infinite;
}

/* ---------- План тренировок ---------- */
.plan-day {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
}
.plan-day.today { border-color: var(--accent); background: linear-gradient(135deg, rgba(168, 230, 58, 0.10), rgba(47, 206, 134, 0.05)), var(--card); }
.plan-day .pd-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.plan-day .pd-name { font-weight: 750; font-size: 14.5px; }
.plan-day .pd-badge {
  font-size: 10.5px; font-weight: 800;
  padding: 3px 9px; border-radius: 99px;
  background: var(--accent-soft); color: var(--accent-dim);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.plan-day .pd-ex { font-size: 13px; color: var(--muted); line-height: 1.6; }

/* ---------- Бейджи ---------- */
.badge {
  display: inline-block;
  font-size: 11px; font-weight: 750;
  padding: 3px 9px;
  border-radius: 99px;
}
.badge.green { background: var(--accent-soft); color: var(--accent-dim); }
.badge.violet { background: var(--violet-soft); color: var(--violet); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.orange { background: var(--orange-soft); color: var(--orange); }

/* ---------- Прогресс к цели веса ---------- */
.goal-progress { margin-top: 12px; }
.goal-progress .gp-track {
  height: 10px;
  border-radius: 99px;
  background: var(--card-2);
  overflow: hidden;
  position: relative;
}
.goal-progress .gp-fill {
  height: 100%;
  background: var(--grad);
  border-radius: 99px;
  transition: width 0.8s cubic-bezier(0.2, 0.8, 0.3, 1);
}
.goal-progress .gp-labels {
  display: flex; justify-content: space-between;
  margin-top: 6px;
  font-size: 11.5px; color: var(--muted);
}

/* ---------- Разное ---------- */
.row { display: flex; align-items: center; gap: 10px; }
.row .grow { flex: 1; }
.divider { height: 1px; background: var(--line); margin: 14px 0; }
.mb0 { margin-bottom: 0; }
.mt8 { margin-top: 8px; }
.mt16 { margin-top: 16px; }
.center { text-align: center; }

.fade-in { animation: fadeUp 0.3s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* каскадное появление карточек при входе на экран */
.screen.entering > * { animation: fadeUp 0.34s ease backwards; }
.screen.entering > *:nth-child(1) { animation-delay: 0.02s; }
.screen.entering > *:nth-child(2) { animation-delay: 0.06s; }
.screen.entering > *:nth-child(3) { animation-delay: 0.10s; }
.screen.entering > *:nth-child(4) { animation-delay: 0.14s; }
.screen.entering > *:nth-child(5) { animation-delay: 0.18s; }
.screen.entering > *:nth-child(6) { animation-delay: 0.22s; }
.screen.entering > *:nth-child(n+7) { animation-delay: 0.26s; }

.install-banner {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.10), rgba(37, 150, 221, 0.08)), var(--card);
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: var(--r-lg);
  padding: 13px 15px;
  margin-bottom: 12px;
}
