:root {
  /* запасные цвета — для открытия вне Telegram; внутри берутся цвета темы Telegram */
  --fb-bg: #f1f2f6;
  --fb-card: #ffffff;
  --fb-text: #101217;
  --fb-hint: #878c96;
  --fb-accent: #2f7cf6;
  --fb-accent-text: #ffffff;
  --fb-danger: #e5484d;

  --bg: var(--tg-theme-secondary-bg-color, var(--fb-bg));
  --card: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, var(--fb-card)));
  --text: var(--tg-theme-text-color, var(--fb-text));
  --hint: var(--tg-theme-hint-color, var(--fb-hint));
  --accent: var(--tg-theme-button-color, var(--fb-accent));
  --accent-text: var(--tg-theme-button-text-color, var(--fb-accent-text));
  --danger: var(--tg-theme-destructive-text-color, var(--fb-danger));

  --sep: rgba(128, 128, 128, 0.18);
  --soft: rgba(128, 128, 128, 0.1);
  --accent-soft: rgba(47, 124, 246, 0.12);

  --protein: #4c8dff;
  --fat: #f2a33a;
  --carbs: #2fbf88;
  --over: #ff5b5b;

  --radius: 20px;
  --radius-s: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 6px 20px rgba(0, 0, 0, 0.05);
  --nav-h: 66px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@supports (color: color-mix(in srgb, red, blue)) {
  :root {
    --sep: color-mix(in srgb, var(--hint) 22%, transparent);
    --soft: color-mix(in srgb, var(--hint) 12%, transparent);
    --accent-soft: color-mix(in srgb, var(--accent) 14%, transparent);
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --fb-bg: #0d0e11;
    --fb-card: #1a1c21;
    --fb-text: #f2f3f5;
    --fb-hint: #8b919c;
    --fb-accent: #4c8dff;
    --shadow: none;
  }
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body.locked {
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: 0;
  background: none;
  padding: 0;
}

input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
}

svg.icon {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.tnum {
  font-variant-numeric: tabular-nums;
}

.hint {
  color: var(--hint);
}

/* ---------- каркас ---------- */

.screen {
  max-width: 560px;
  margin: 0 auto;
  padding: 10px 16px calc(var(--nav-h) + var(--safe-b) + 28px);
  animation: fade 0.18s ease;
}

.screen-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 6px 4px 14px;
}

.screen-title h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.card-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
}

.section-label {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--hint);
  margin: 18px 4px 8px;
}

/* ---------- нижняя навигация ---------- */

.nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  padding-bottom: var(--safe-b);
  background: var(--card);
  border-top: 1px solid var(--sep);
}

.nav-inner {
  max-width: 560px;
  margin: 0 auto;
  height: var(--nav-h);
  display: grid;
  grid-template-columns: 1fr 1fr 76px 1fr 1fr;
  align-items: center;
}

.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 550;
  color: var(--hint);
  height: 100%;
  justify-content: center;
  transition: color 0.15s;
}

.nav-btn.active {
  color: var(--accent);
}

.nav-fab {
  justify-self: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  display: grid;
  place-items: center;
  margin-top: -26px;
  box-shadow: 0 6px 18px rgba(47, 124, 246, 0.35);
  border: 4px solid var(--card);
  transition: transform 0.15s;
}

.nav-fab:active {
  transform: scale(0.93);
}

.nav-fab svg.icon {
  width: 26px;
  height: 26px;
  stroke-width: 2.4;
}

/* ---------- общие элементы ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 50px;
  padding: 0 20px;
  border-radius: 14px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 650;
  font-size: 16px;
  transition: transform 0.12s, opacity 0.15s;
  user-select: none;
}

.btn:active {
  transform: scale(0.98);
}

.btn[disabled] {
  opacity: 0.45;
  pointer-events: none;
}

.btn.block {
  width: 100%;
}

.btn.soft {
  background: var(--accent-soft);
  color: var(--accent);
}

.btn.ghost {
  background: var(--soft);
  color: var(--text);
}

.btn.small {
  height: 38px;
  font-size: 14px;
  padding: 0 14px;
  border-radius: 11px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--text);
  background: var(--soft);
  transition: transform 0.12s;
}

.icon-btn:active {
  transform: scale(0.94);
}

.icon-btn.plain {
  background: none;
}

.icon-btn:disabled {
  opacity: 0.25;
  pointer-events: none;
}

.link-btn {
  color: var(--accent);
  font-weight: 600;
  font-size: 14px;
}

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px 16px;
  margin: 0 -16px 12px;
}

.chips::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: none;
  height: 36px;
  padding: 0 14px;
  border-radius: 18px;
  background: var(--card);
  color: var(--text);
  font-weight: 550;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: var(--shadow);
  transition: background 0.15s, color 0.15s;
}

.chip.active {
  background: var(--accent);
  color: var(--accent-text);
}

.chip.on-card {
  background: var(--soft);
  box-shadow: none;
}

.chip.on-card.active {
  background: var(--accent);
}

.field {
  display: block;
  margin-bottom: 12px;
}

.field > span {
  display: block;
  font-size: 13px;
  color: var(--hint);
  margin: 0 4px 6px;
}

.input {
  width: 100%;
  height: 48px;
  border-radius: 13px;
  border: 1.5px solid transparent;
  background: var(--soft);
  padding: 0 14px;
  font-size: 16px;
  outline: none;
  transition: border-color 0.15s;
}

.input:focus {
  border-color: var(--accent);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.segmented {
  display: flex;
  background: var(--soft);
  border-radius: 12px;
  padding: 3px;
  gap: 3px;
}

.segmented button {
  flex: 1;
  height: 36px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  color: var(--hint);
  transition: background 0.15s, color 0.15s;
}

.segmented button.active {
  background: var(--card);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.spinner {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 3px solid var(--soft);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

.splash {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.center-msg {
  min-height: 70vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  gap: 8px;
}

.center-msg .big-emoji {
  font-size: 56px;
  margin-bottom: 8px;
}

.center-msg h2 {
  margin: 0;
  font-size: 22px;
}

.empty {
  text-align: center;
  padding: 22px 12px 10px;
}

.empty .big-emoji {
  font-size: 42px;
  margin-bottom: 6px;
}

.empty p {
  margin: 0 0 14px;
  color: var(--hint);
}

.skeleton {
  height: 58px;
  border-radius: 14px;
  background: linear-gradient(90deg, var(--soft) 25%, transparent 50%, var(--soft) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  margin-bottom: 8px;
}

/* ---------- дневник ---------- */

.date-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin: 4px 0 14px;
}

.date-nav .date {
  min-width: 150px;
}

.date-nav .date {
  text-align: center;
}

.date-nav .date b {
  display: block;
  font-size: 22px;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.date-nav .date small {
  color: var(--hint);
  font-size: 13px;
}

.person-chip .pct {
  font-size: 12px;
  opacity: 0.75;
  font-variant-numeric: tabular-nums;
}

.summary {
  display: flex;
  align-items: center;
  gap: 18px;
}

.ring {
  position: relative;
  flex: none;
}

.ring svg {
  display: block;
  width: 100%;
  height: 100%;
}

.ring-track {
  stroke: var(--soft);
  fill: none;
}

.ring-bar {
  stroke: var(--accent);
  fill: none;
  transition: stroke-dashoffset 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.ring-bar.over {
  stroke: var(--over);
}

.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.ring-center b {
  font-size: 28px;
  font-weight: 750;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.ring-center small {
  font-size: 12px;
  color: var(--hint);
}

.ring-center.over b {
  color: var(--over);
}

.summary-stats {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.stat-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stat-row .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
}

.stat-row .lbl {
  color: var(--hint);
  font-size: 13px;
}

.stat-row .val {
  font-weight: 700;
  font-size: 17px;
  margin-left: auto;
}

.macros {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--sep);
}

.macro .name {
  font-size: 12px;
  color: var(--hint);
}

.macro .nums {
  font-weight: 650;
  font-size: 15px;
  margin: 1px 0 6px;
}

.macro .nums small {
  font-weight: 500;
  color: var(--hint);
  font-size: 12px;
}

.bar {
  height: 6px;
  border-radius: 3px;
  background: var(--soft);
  overflow: hidden;
}

.bar > i {
  display: block;
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.list {
  margin: 0 -16px -8px;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  width: 100%;
  text-align: left;
  position: relative;
  transition: background 0.12s;
}

.row:active {
  background: var(--soft);
}

.row + .row::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 68px;
  border-top: 1px solid var(--sep);
}

.row.no-avatar + .row.no-avatar::before {
  left: 16px;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 19px;
  flex: none;
  background: var(--soft);
  font-weight: 650;
}

.row .main {
  flex: 1;
  min-width: 0;
}

.row .title {
  font-weight: 560;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row .sub {
  font-size: 13px;
  color: var(--hint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row .end {
  text-align: right;
  flex: none;
}

.row .end b {
  font-weight: 700;
  display: block;
}

.row .end small {
  font-size: 12px;
  color: var(--hint);
}

.badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 650;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  margin-left: 6px;
  vertical-align: 1px;
}

/* ---------- полноэкранные страницы и шторки ---------- */

.page {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: var(--bg);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: slide-in 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.page-inner {
  max-width: 560px;
  margin: 0 auto;
  padding: 10px 16px calc(var(--safe-b) + 110px);
}

.page-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 2px 0 14px;
  min-height: 44px;
}

.page-head h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 720;
  flex: 1;
  letter-spacing: -0.01em;
}

.sticky-bottom {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 12px 16px calc(12px + var(--safe-b));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
  z-index: 31;
}

.sticky-bottom > * {
  max-width: 528px;
  margin: 0 auto;
  display: flex;
}

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.42);
  animation: fade 0.2s ease;
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 41;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--card);
  border-radius: 24px 24px 0 0;
  padding: 8px 16px calc(16px + var(--safe-b));
  animation: sheet-up 0.26s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.sheet-inner {
  max-width: 528px;
  margin: 0 auto;
}

.sheet .grabber {
  width: 38px;
  height: 5px;
  border-radius: 3px;
  background: var(--sep);
  margin: 0 auto 12px;
}

.sheet h2 {
  margin: 0 0 4px;
  font-size: 21px;
  font-weight: 720;
  letter-spacing: -0.01em;
}

.sheet .sheet-sub {
  color: var(--hint);
  font-size: 14px;
  margin-bottom: 14px;
}

.sheet .field > span,
.sheet .label,
.page .label {
  font-size: 13px;
  color: var(--hint);
  margin: 14px 2px 8px;
  display: block;
}

.nutri-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 10px;
  background: var(--soft);
}

.pill i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.amount {
  display: flex;
  align-items: center;
  gap: 10px;
}

.amount .input {
  font-size: 22px;
  font-weight: 700;
  height: 56px;
  text-align: center;
}

.amount .unit {
  color: var(--hint);
  font-weight: 600;
  min-width: 34px;
}

.stepper {
  display: flex;
  align-items: center;
  gap: 14px;
  justify-content: center;
}

.stepper b {
  font-size: 30px;
  min-width: 70px;
  text-align: center;
  font-weight: 750;
}

.stepper .icon-btn {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  font-size: 24px;
  font-weight: 600;
}

.split-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.split-row .who-name {
  flex: 1;
  font-weight: 600;
}

.split-row .input {
  width: 110px;
  height: 44px;
  text-align: center;
  font-weight: 650;
}

.result-box {
  margin: 16px 0 14px;
  padding: 14px;
  border-radius: 16px;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.result-box b {
  font-size: 24px;
  font-weight: 750;
  color: var(--accent);
}

.result-box small {
  color: var(--hint);
  font-size: 13px;
}

/* ---------- добавление еды ---------- */

.search {
  position: relative;
  margin-bottom: 12px;
}

.search svg.icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--hint);
  width: 20px;
  height: 20px;
  pointer-events: none;
}

.search .input {
  padding-left: 44px;
  padding-right: 44px;
  background: var(--card);
  height: 50px;
  box-shadow: var(--shadow);
}

.search .clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  color: var(--hint);
}

.tiles {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 10px;
  margin-bottom: 4px;
}

.tile {
  border-radius: var(--radius);
  padding: 16px;
  min-height: 104px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: left;
  background: var(--card);
  box-shadow: var(--shadow);
  transition: transform 0.12s;
}

.tile:active {
  transform: scale(0.98);
}

.tile.primary {
  background: var(--accent);
  color: var(--accent-text);
}

.tile .tile-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.2);
}

.tile:not(.primary) .tile-icon {
  background: var(--accent-soft);
  color: var(--accent);
}

.tile b {
  font-size: 15px;
  font-weight: 650;
}

.tile small {
  display: block;
  font-size: 12px;
  opacity: 0.75;
}

/* ---------- сканер ---------- */

.scanner {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: #000;
  color: #fff;
  animation: fade 0.2s ease;
}

.scanner video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scan-frame {
  position: absolute;
  left: 50%;
  top: 42%;
  width: min(78vw, 360px);
  height: min(46vw, 210px);
  transform: translate(-50%, -50%);
  border-radius: 22px;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.55);
}

.scan-frame::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 22px;
  border: 3px solid rgba(255, 255, 255, 0.9);
}

.scan-line {
  position: absolute;
  left: 8%;
  right: 8%;
  height: 2px;
  background: linear-gradient(90deg, transparent, #5ea0ff, transparent);
  box-shadow: 0 0 12px #5ea0ff;
  animation: scan 2s ease-in-out infinite;
}

.scanner .top,
.scanner .bottom {
  position: absolute;
  left: 0;
  right: 0;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.scanner .top {
  top: 0;
  padding-top: calc(16px + env(safe-area-inset-top, 0px));
}

.scanner .bottom {
  bottom: 0;
  padding-bottom: calc(24px + var(--safe-b));
  flex-direction: column;
}

.scanner .hint-text {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(42% + min(23vw, 105px) + 22px);
  text-align: center;
  font-size: 15px;
  font-weight: 550;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.glass-btn {
  height: 46px;
  min-width: 46px;
  padding: 0 16px;
  border-radius: 23px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #fff;
  font-weight: 600;
}

.glass-btn.on {
  background: #fff;
  color: #000;
}

.scanner .actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.scanner .code-form {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 420px;
}

.scanner .code-form .input {
  background: rgba(255, 255, 255, 0.95);
  color: #000;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.scanner .state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px;
  gap: 10px;
}

.scanner .state .spinner {
  border-color: rgba(255, 255, 255, 0.2);
  border-top-color: #fff;
}

.found-code {
  font-size: 13px;
  opacity: 0.75;
  letter-spacing: 0.08em;
}

/* ---------- рецепты ---------- */

.recipe-card {
  display: flex;
  gap: 14px;
  align-items: center;
  width: 100%;
  text-align: left;
  padding: 12px;
  margin-bottom: 10px;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  transition: transform 0.12s;
}

.recipe-card:active {
  transform: scale(0.985);
}

.recipe-emoji {
  width: 68px;
  height: 68px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 34px;
  flex: none;
}

.recipe-card .main {
  flex: 1;
  min-width: 0;
}

.recipe-card .title {
  font-weight: 650;
  font-size: 16px;
  margin-bottom: 5px;
  line-height: 1.25;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: 13px;
  color: var(--hint);
  align-items: center;
}

.meta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.meta svg.icon {
  width: 14px;
  height: 14px;
}

.diff {
  display: inline-flex;
  gap: 3px;
  align-items: center;
}

.diff i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--sep);
}

.diff i.on {
  background: var(--diff-color, var(--accent));
}

.recipe-hero {
  border-radius: 26px;
  height: 170px;
  display: grid;
  place-items: center;
  font-size: 84px;
  margin-bottom: 16px;
}

.recipe-title {
  font-size: 26px;
  font-weight: 760;
  letter-spacing: -0.02em;
  margin: 0 4px 14px;
  line-height: 1.15;
}

.facts {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.fact {
  background: var(--card);
  border-radius: 16px;
  padding: 12px 6px;
  text-align: center;
  box-shadow: var(--shadow);
}

.fact b {
  display: block;
  font-size: 17px;
  font-weight: 720;
}

.fact small {
  font-size: 11px;
  color: var(--hint);
}

.ingredients .ing {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--sep);
}

.ingredients .ing:last-child {
  border-bottom: 0;
}

.ingredients .ing span:last-child {
  color: var(--hint);
  white-space: nowrap;
}

.steps .step {
  display: flex;
  gap: 12px;
  padding: 8px 0;
}

.steps .num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
  flex: none;
}

.steps .step p {
  margin: 3px 0 0;
}

.note {
  font-size: 13px;
  color: var(--hint);
  margin: 8px 4px 0;
}

/* ---------- статистика ---------- */

.chart svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

.chart text {
  fill: var(--hint);
  font-size: 11px;
  font-family: var(--font);
}

.chart text.strong {
  fill: var(--text);
  font-weight: 700;
}

.kpis {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.kpi {
  background: var(--soft);
  border-radius: 14px;
  padding: 10px 12px;
}

.kpi b {
  display: block;
  font-size: 18px;
  font-weight: 720;
}

.kpi small {
  color: var(--hint);
  font-size: 12px;
}

.weight-now {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
}

.weight-now b {
  font-size: 32px;
  font-weight: 760;
  letter-spacing: -0.02em;
}

.delta {
  font-weight: 650;
  font-size: 14px;
  padding: 2px 8px;
  border-radius: 8px;
  background: var(--soft);
}

.weight-form {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.weight-form .input {
  flex: 1;
}

/* ---------- профиль ---------- */

.me-card {
  display: flex;
  align-items: center;
  gap: 14px;
}

.me-card .avatar {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  font-size: 24px;
  color: #fff;
}

.me-card h2 {
  margin: 0;
  font-size: 20px;
}

.calc-result {
  text-align: center;
  padding: 16px;
  border-radius: 18px;
  background: var(--accent-soft);
  margin: 16px 0 12px;
}

.calc-result b {
  display: block;
  font-size: 34px;
  font-weight: 780;
  color: var(--accent);
  letter-spacing: -0.02em;
}

.calc-result small {
  color: var(--hint);
}

.option-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  border-radius: 13px;
  background: var(--soft);
  text-align: left;
  border: 1.5px solid transparent;
}

.option.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.option small {
  color: var(--hint);
}

/* ---------- тосты ---------- */

.toasts {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--nav-h) + var(--safe-b) + 14px);
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  padding: 0 16px;
}

.toast {
  background: rgba(20, 22, 26, 0.92);
  color: #fff;
  padding: 11px 16px;
  border-radius: 14px;
  font-weight: 560;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  animation: toast-in 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
  max-width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast.error {
  background: var(--over);
}

/* ---------- анимации ---------- */

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

@keyframes slide-in {
  from {
    transform: translateX(24px);
    opacity: 0;
  }
}

@keyframes sheet-up {
  from {
    transform: translateY(100%);
  }
}

@keyframes toast-in {
  from {
    transform: translateY(12px);
    opacity: 0;
  }
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

@keyframes scan {
  0%,
  100% {
    top: 12%;
  }
  50% {
    top: 86%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- добавлено: тренировки, шаблоны, фото, напоминания ---------- */

.tiles.three {
  grid-template-columns: repeat(3, 1fr);
}

.tiles.three .tile {
  min-height: 112px;
  padding: 14px 12px;
}

.tiles.three .tile small {
  font-size: 11px;
}

.head-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
}

.fav-mark {
  color: #f5b400;
  margin-left: 6px;
  vertical-align: -1px;
}

.sheet-title {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.sheet-title h2 {
  flex: 1;
}

.fav-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--hint);
  background: var(--soft);
  flex: none;
  transition: transform 0.15s, color 0.15s;
}

.fav-btn.on {
  color: #f5b400;
  background: rgba(245, 180, 0, 0.14);
}

.fav-btn:active {
  transform: scale(0.9);
}

.activity-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.activity-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 4px;
  border-radius: 14px;
  background: var(--soft);
  font-size: 12px;
  font-weight: 560;
  border: 1.5px solid transparent;
  transition: background 0.15s, border-color 0.15s;
}

.activity-tile span {
  font-size: 24px;
  line-height: 1.1;
}

.activity-tile.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.check-list {
  display: flex;
  flex-direction: column;
  margin: 0 -4px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 4px;
  text-align: left;
  border-bottom: 1px solid var(--sep);
}

.check-row:last-child {
  border-bottom: 0;
}

.check-row .main {
  flex: 1;
  min-width: 0;
  font-weight: 540;
}

.check-row .main small {
  color: var(--hint);
  font-weight: 400;
}

.check {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  border: 2px solid var(--sep);
  display: grid;
  place-items: center;
  flex: none;
  color: var(--accent-text);
  transition: background 0.15s, border-color 0.15s;
}

.check.on {
  background: var(--accent);
  border-color: var(--accent);
}

.check svg.icon {
  stroke-width: 3;
}

.emoji-chip {
  font-size: 20px;
  padding: 0 10px;
}

.tpl-cards {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px 16px 6px;
  margin: 0 -16px;
}

.tpl-cards::-webkit-scrollbar {
  display: none;
}

.tpl-card {
  flex: none;
  width: 148px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: transform 0.12s;
}

.tpl-card:active {
  transform: scale(0.97);
}

.tpl-emoji {
  font-size: 28px;
  margin-bottom: 4px;
}

.tpl-card b {
  font-size: 15px;
  line-height: 1.25;
}

.tpl-card small {
  color: var(--hint);
  font-size: 12px;
}

.photo-pick {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 36px 16px;
  text-align: center;
  border: 2px dashed var(--sep);
  box-shadow: none;
}

.photo-pick .big-emoji {
  font-size: 48px;
}

.photo-preview {
  position: relative;
  display: block;
  width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 12px;
  background: #000;
}

.photo-preview img {
  display: block;
  width: 100%;
  max-height: 46vh;
  object-fit: cover;
}

.photo-scan {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: #fff;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.45);
}

.photo-scan .spinner {
  border-color: rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
}

.photo-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--sep);
}

.photo-item:last-child {
  border-bottom: 0;
}

.photo-item .main {
  flex: 1;
  min-width: 0;
}

.photo-item .title {
  font-weight: 560;
}

.photo-item .sub {
  font-size: 12px;
  color: var(--hint);
}

.grams-input {
  width: 74px;
  height: 40px;
  text-align: center;
  font-weight: 650;
  padding: 0 6px;
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 8px 0;
}

.switch-text {
  flex: 1;
  min-width: 0;
}

.switch-text b {
  display: block;
  font-weight: 600;
}

.switch-text small {
  display: block;
  color: var(--hint);
  font-size: 12px;
  line-height: 1.35;
}

.switch {
  width: 50px;
  height: 30px;
  border-radius: 15px;
  background: var(--sep);
  position: relative;
  flex: none;
  transition: background 0.2s;
}

.switch i {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.switch.on {
  background: var(--accent);
}

.switch.on i {
  transform: translateX(20px);
}

.reminder {
  border-bottom: 1px solid var(--sep);
  padding: 4px 0 10px;
}

.reminder:last-of-type {
  border-bottom: 0;
}

.reminder-opts {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.time-input {
  width: 110px;
  height: 40px;
  text-align: center;
  text-align-last: center;
  font-weight: 650;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.days {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.day {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--soft);
  font-size: 12px;
  font-weight: 600;
  color: var(--hint);
}

.day.on {
  background: var(--accent);
  color: var(--accent-text);
}

.kpi.wide {
  grid-column: 1 / -1;
}

/* ---------- приёмы пищи и приглашения ---------- */

.meals {
  display: flex;
  flex-direction: column;
  margin: 0 -16px -8px;
}

.meal {
  border-top: 1px solid var(--sep);
}

.meal:first-child {
  border-top: 0;
}

.meal-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 10px 10px 16px;
}

.meal-title {
  font-weight: 650;
  font-size: 15px;
}

.meal-kcal {
  margin-left: auto;
  color: var(--hint);
  font-size: 14px;
  font-weight: 600;
}

.meal-add {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  color: var(--accent);
  background: var(--accent-soft);
  transition: transform 0.12s;
}

.meal-add:active {
  transform: scale(0.92);
}

.meal .list {
  margin: -4px 0 4px;
}

.meal-seg button {
  height: auto;
  padding: 6px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  font-size: 12px;
}

.meal-seg button span {
  font-size: 18px;
}

.invite-hint {
  display: flex;
  align-items: center;
  gap: 12px;
}

.invite-hint .invite-emoji {
  font-size: 30px;
}

.invite-hint .main {
  flex: 1;
  min-width: 0;
}

.invite-hint small {
  display: block;
  color: var(--hint);
  font-size: 12px;
  line-height: 1.35;
}

.invite-link {
  padding: 12px 14px;
  border-radius: 13px;
  background: var(--soft);
  font-size: 13px;
  word-break: break-all;
  margin-bottom: 12px;
  user-select: all;
}
