:root {
  --bg: #FAF6F4;
  --card: #ffffff;
  --ink: #211A1D;
  --muted: #8A7F83;
  --muted2: #B7AEB1;
  --berry: #E84E6B;      /* акцент / белки */
  --amber: #F0A742;      /* углеводы */
  --mint: #5BC7A9;       /* жиры */
  --track: #F3ECEE;
  --c: var(--amber);     /* углеводы */
  --p: var(--berry);     /* белки */
  --f: var(--mint);      /* жиры */
  --sh-card: 0 12px 30px -20px rgba(40,20,30,.45);
  --sh-soft: 0 6px 16px -12px rgba(40,20,30,.4);
  --sh-meal: 0 10px 26px -22px rgba(40,20,30,.5);
}

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

body {
  margin: 0;
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
}

#app { max-width: 520px; margin: 0 auto; padding: 14px 18px 100px; }

.hidden { display: none !important; }
.center { display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; min-height: 78vh; gap: 12px; }
.muted { color: var(--muted); }

h1 { font-size: 26px; font-weight: 900; margin: 4px 0; letter-spacing: -0.02em; }
.emoji { font-size: 60px; }

/* Кнопки */
.btn {
  border: none; border-radius: 16px; padding: 16px 18px; font-size: 17px; font-weight: 900;
  cursor: pointer; width: 100%; transition: filter .15s, transform .05s; letter-spacing: -0.01em;
  font-family: inherit;
}
.btn:active { transform: scale(0.99); }
.btn-primary { background: var(--berry); color: #fff; box-shadow: 0 14px 30px -12px rgba(232,78,107,.6); }
.btn-primary:active { filter: brightness(0.96); }
.btn-primary:disabled { opacity: .5; box-shadow: none; }
.link { background: none; border: none; color: var(--berry); font-size: 15px; font-weight: 800;
  cursor: pointer; padding: 0; font-family: inherit; }

/* Верхняя строка дашборда (стрик + календарь) */
.dash-top { display: flex; align-items: center; justify-content: space-between; padding: 4px 2px 0; }
.streak { display: flex; align-items: center; gap: 7px; background: var(--card); border-radius: 999px;
  padding: 8px 14px; box-shadow: var(--sh-soft); font-size: 17px; font-weight: 900; }
.dash-cal { width: 44px; height: 44px; border-radius: 14px; background: var(--card);
  display: flex; align-items: center; justify-content: center; box-shadow: var(--sh-soft); font-size: 20px; }

/* Заголовок */
.topbar { display: flex; align-items: center; gap: 12px; margin: 14px 2px 16px; }
.topbar-title { font-size: 42px; font-weight: 900; letter-spacing: -0.03em; line-height: 1; }
.topbar-title.sm { font-size: 24px; }
.topbar-sub { font-size: 16px; font-weight: 700; margin-top: 4px; }

/* Карточка */
.card { background: var(--card); border-radius: 26px; padding: 20px; box-shadow: var(--sh-card); }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.card-title { font-size: 19px; font-weight: 900; letter-spacing: -0.02em; }

/* Кольцо калорий (полное) */
.gauge-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin: 4px 0; }
.gauge { position: relative; width: 172px; height: 172px; flex: 0 0 auto; }
.gauge svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: var(--track); stroke-width: 13; }
.ring-fg { fill: none; stroke: var(--berry); stroke-width: 13; stroke-linecap: round;
  stroke-dasharray: 395.84; stroke-dashoffset: 395.84; transition: stroke-dashoffset .7s ease; }
.gauge-center { position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; }
.gauge-num { font-size: 40px; font-weight: 900; letter-spacing: -0.03em; line-height: 1; }
.gauge-label { font-size: 13px; font-weight: 800; margin-top: 4px; }
.side-stat { text-align: center; min-width: 66px; }
.side-num { font-size: 23px; font-weight: 900; letter-spacing: -0.02em; }
.side-label { font-size: 13px; font-weight: 700; margin-top: 2px; }

/* Бары БЖУ */
.macros { display: flex; gap: 16px; margin-top: 18px; }
.macro { flex: 1; }
.macro-name { font-size: 13px; font-weight: 800; margin-bottom: 6px; }
.bar { height: 7px; background: var(--track); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; border-radius: 99px; transition: width .7s ease; }
.bar-fill.p { background: var(--p); }
.bar-fill.f { background: var(--f); }
.bar-fill.c { background: var(--c); }
.macro-val { font-size: 12.5px; font-weight: 700; margin-top: 6px; }

/* Секции */
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 22px 4px 12px; }
.section-title { font-size: 22px; font-weight: 900; letter-spacing: -0.02em; }

/* Приёмы */
.meals-list { display: flex; flex-direction: column; gap: 12px; }
.meal { background: var(--card); border-radius: 22px; padding: 14px 16px; box-shadow: var(--sh-meal);
  display: flex; align-items: center; gap: 14px; }
.meal-ic { width: 48px; height: 48px; border-radius: 50%; flex: 0 0 auto;
  background: #FCE9ED; display: flex; align-items: center; justify-content: center; font-size: 22px; }
.meal-body { flex: 1; min-width: 0; }
.meal-desc { font-size: 16px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meal-sub { font-size: 13px; color: var(--muted); font-weight: 700; margin-top: 2px; }
.meal-kcal { font-weight: 900; white-space: nowrap; font-size: 16px; }
.empty { color: var(--muted); font-size: 14px; font-weight: 700; text-align: center; padding: 22px; }

/* Добавление */
.phrase { width: 100%; border: none; border-radius: 18px; padding: 16px; font-size: 16px;
  font-family: inherit; font-weight: 700; resize: none; margin-bottom: 12px; background: var(--card); color: var(--ink);
  box-shadow: var(--sh-card); }
.phrase:focus { outline: 2px solid var(--berry); }
.draft { margin-top: 18px; }
.draft-items { display: flex; flex-direction: column; gap: 10px; }
.draft-item { background: var(--card); border-radius: 18px; padding: 14px 16px; box-shadow: var(--sh-meal); }
.draft-item-top { display: flex; justify-content: space-between; align-items: center; font-weight: 900; gap: 8px; }
.draft-item-sub { font-size: 13px; color: var(--muted); font-weight: 700; margin-top: 3px; }
.tag { font-size: 10px; padding: 2px 6px; border-radius: 6px; margin-left: 6px; font-weight: 900; vertical-align: middle; color: #fff; }
.tag.db { background: var(--mint); }
.tag.ai { background: #7B61FF; }
.draft-total { display: flex; justify-content: space-between; align-items: center; font-weight: 900;
  font-size: 17px; margin: 12px 0 16px; padding: 18px 20px; }

/* Нижняя навигация */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: space-around; align-items: center;
  max-width: 520px; margin: 0 auto; padding: 12px 12px calc(18px + env(safe-area-inset-bottom));
  background: var(--card); border-top: 1px solid #F0EAEB; }
.tab { background: none; border: none; cursor: pointer; flex: 1; font-family: inherit;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 800; color: var(--muted2); padding: 2px 0; }
.tab.active { color: var(--berry); }
.tab-ic { font-size: 21px; filter: grayscale(1); opacity: .5; }
.tab.active .tab-ic { filter: none; opacity: 1; }

/* График калорий */
.chart { display: flex; flex-direction: column; gap: 8px; }
.chart-plot { position: relative; height: 140px; display: flex; align-items: flex-end;
  justify-content: space-between; gap: 8px; }
.chart-bar { flex: 1; border-radius: 7px 7px 3px 3px; background: var(--berry);
  min-height: 3px; transition: height .5s ease; }
.chart-bar.over { background: var(--amber); }
.chart-labels { display: flex; justify-content: space-between; gap: 8px; }
.chart-labels > div { flex: 1; text-align: center; font-size: 11px; font-weight: 700; color: var(--muted); }
.chart-normline { position: absolute; left: 0; right: 0; border-top: 1.5px dashed #D8CFD1; pointer-events: none; }
.chart-normcap { position: absolute; right: 0; transform: translateY(-100%);
  font-size: 10px; font-weight: 700; color: var(--muted); background: var(--card); padding: 0 4px; }

/* Средние */
.avg-big { font-size: 36px; font-weight: 900; letter-spacing: -0.03em; margin: 4px 0 10px; }
.avg-macros { display: flex; justify-content: space-between; font-size: 14px; font-weight: 700; gap: 8px; flex-wrap: wrap; }
.avg-macros b { font-weight: 900; }

/* Профиль */
.profile-head { display: flex; align-items: center; gap: 16px; padding: 4px 4px 16px; }
.prof-avatar { width: 66px; height: 66px; border-radius: 50%; flex: 0 0 auto;
  background: linear-gradient(135deg, var(--berry), var(--amber)); display: flex; align-items: center;
  justify-content: center; font-size: 26px; font-weight: 900; color: #fff; }
.prof-name { font-size: 24px; font-weight: 900; letter-spacing: -0.02em; }
.prow { display: flex; justify-content: space-between; align-items: center; padding: 13px 0;
  border-bottom: 1px solid var(--track); font-size: 15px; font-weight: 700; }
.prow:first-child { padding-top: 2px; }
.prow:last-child { border-bottom: none; padding-bottom: 2px; }
.prow .k { color: var(--muted); }
.prow .v { font-weight: 900; }
.prow-edit { cursor: pointer; }
.prow-edit .v::after { content: ' ›'; color: var(--muted2); font-weight: 900; }
.prow-edit:active { opacity: .6; }

/* Тёмная карточка нормы */
.norm-card { background: var(--ink); color: #fff; border-radius: 24px; padding: 20px 22px; margin-top: 14px;
  display: flex; align-items: center; justify-content: space-between; }
.norm-lbl { font-size: 14px; font-weight: 800; color: rgba(255,255,255,.6); }
.norm-big { font-size: 34px; font-weight: 900; letter-spacing: -0.03em; margin-top: 2px; }
.norm-unit { font-size: 16px; font-weight: 800; color: rgba(255,255,255,.6); }
.norm-macros { text-align: right; font-size: 13px; font-weight: 700; line-height: 1.9; color: rgba(255,255,255,.75); }
.norm-macros b { color: #fff; }

/* Запись веса */
.weight-form { display: flex; gap: 10px; }
.weight-input { flex: 1; border: none; border-radius: 14px; padding: 15px; font-size: 16px; font-weight: 700;
  font-family: inherit; background: var(--bg); color: var(--ink); }
.weight-input:focus { outline: 2px solid var(--berry); }

/* Онбординг */
.onb-head { display: flex; align-items: center; gap: 14px; padding: 10px 2px 20px; }
.onb-progress { flex: 1; height: 8px; background: var(--track); border-radius: 99px; overflow: hidden; }
#onb-bar { height: 100%; width: 0; background: var(--berry); border-radius: 99px; transition: width .3s ease; }
.onb-title { font-size: 30px; font-weight: 900; letter-spacing: -0.02em; margin: 8px 2px 24px; line-height: 1.15; }
.onb-body { display: flex; flex-direction: column; gap: 12px; }
.onb-choice { background: var(--card); border: none; border-radius: 18px; padding: 20px 18px; font-size: 17px;
  font-weight: 800; text-align: left; cursor: pointer; box-shadow: var(--sh-meal); color: var(--ink);
  font-family: inherit; transition: transform .05s; }
.onb-choice:active { transform: scale(0.99); }
.onb-input { width: 100%; border: none; border-radius: 18px; padding: 22px; font-size: 30px; font-weight: 900;
  text-align: center; background: var(--card); color: var(--ink); box-shadow: var(--sh-card); font-family: inherit; }
.onb-input:focus { outline: 2px solid var(--berry); }
#onb-controls { margin-top: 16px; }

/* «Составляем твой план» */
.plan-ring { position: relative; width: 220px; height: 220px; }
.plan-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.plan-track { fill: none; stroke: var(--track); stroke-width: 18; }
.plan-fg { fill: none; stroke: var(--berry); stroke-width: 18; stroke-linecap: round;
  stroke-dasharray: 640.9; stroke-dashoffset: 640.9; }
.plan-pct { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 56px; font-weight: 900; letter-spacing: -0.03em; }
.plan-title { font-size: 32px; font-weight: 900; text-align: center; line-height: 1.15; margin-top: 12px; }
.plan-list { display: flex; flex-direction: column; gap: 20px; margin-top: 36px; width: 100%; max-width: 320px; }
.plan-item { display: flex; align-items: center; gap: 16px; font-size: 19px; font-weight: 800; color: var(--muted2);
  transition: color .3s; }
.plan-item.done { color: var(--ink); }
.plan-check { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--track); flex: none;
  display: flex; align-items: center; justify-content: center; transition: background .3s, border-color .3s; }
.plan-item.done .plan-check { background: var(--berry); border-color: var(--berry); }
.plan-item.done .plan-check::after { content: '✓'; color: #fff; font-size: 15px; font-weight: 900; }

/* Тренд веса */
.wt-empty { color: var(--muted); font-size: 14px; font-weight: 700; padding: 8px 2px; }
.wt-svg { width: 100%; height: 90px; display: block; }
.wt-line { fill: none; stroke: var(--berry); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.wt-dot { fill: var(--berry); }
.wt-cur { font-size: 16px; font-weight: 900; margin-bottom: 6px; }
