/* Проект: FATCLUB — приложение-диетолог (не ZVUMO/RUNXIN). Этап 1 (MVP). */

:root {
  --bg: #fff7f2;          /* тёплый фон страницы */
  --card: #ffffff;
  --ink: #2c2420;         /* тёмно-коричневый текст */
  --ink-soft: #8a7d74;
  --accent: #ff7a59;      /* тёплый коралл */
  --accent-2: #ffb24d;    /* тёплый жёлто-оранжевый */
  --protein: #6cc6a9;
  --fat: #ffb24d;
  --carb: #7aa8ff;
  --line: #f0e4db;        /* мягкая рамка в тон */
  --shadow: 0 10px 30px rgba(255, 122, 89, .12);
  --radius: 20px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.4;
}

body {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 0 16px calc(120px + env(safe-area-inset-bottom));
}

/* ------- экраны ------- */
.screen { display: none; }
.screen.is-active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ------- шапка ------- */
.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top)) 2px 10px;
}
.top__brand { font-weight: 800; letter-spacing: .04em; color: var(--accent); }
.icon-btn {
  width: 40px; height: 40px; border: none; background: var(--card);
  border-radius: 14px; font-size: 18px; color: var(--ink); box-shadow: var(--shadow);
  cursor: pointer;
}

/* ------- кольцо ------- */
.ring-card {
  background: var(--card); border-radius: var(--radius); padding: 22px 18px 16px;
  box-shadow: var(--shadow); text-align: center;
}
.ring-wrap { position: relative; width: 220px; height: 220px; margin: 0 auto; }
.ring { width: 220px; height: 220px; transform: rotate(-90deg); }
.ring__bg { fill: none; stroke: #f3e7de; stroke-width: 16; }
.ring__fill {
  fill: none; stroke: url(#g); stroke: var(--accent); stroke-width: 16;
  stroke-linecap: round; stroke-dasharray: 603; stroke-dashoffset: 603;
  transition: stroke-dashoffset .6s ease;
}
.ring-center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.ring-center__big { font-size: 46px; font-weight: 800; line-height: 1; }
.ring-center__sub { color: var(--ink-soft); font-size: 14px; margin-top: 4px; }
.ring-legend {
  display: flex; justify-content: center; gap: 36px; margin-top: 10px;
}
.ring-legend div { display: flex; flex-direction: column; }
.ring-legend span { font-weight: 700; font-size: 18px; }
.ring-legend small { color: var(--ink-soft); font-size: 12px; }

/* ------- макросы ------- */
.macros { margin-top: 14px; display: grid; gap: 10px; }
.macro { background: var(--card); border-radius: 16px; padding: 12px 14px; box-shadow: var(--shadow); }
.macro__head { display: flex; justify-content: space-between; font-size: 14px; }
.macro__head b { font-weight: 700; }
.macro__bar { margin-top: 8px; height: 8px; background: #f3e7de; border-radius: 6px; overflow: hidden; }
.macro__bar i { display: block; height: 100%; border-radius: 6px; transition: width .5s ease; }
.macro[data-macro="protein"] .macro__bar i { background: var(--protein); }
.macro[data-macro="fat"] .macro__bar i { background: var(--fat); }
.macro[data-macro="carb"] .macro__bar i { background: var(--carb); }

/* ------- лента ------- */
.feed { margin-top: 18px; }
.feed__title { font-size: 16px; margin: 0 0 10px; }
.feed__list { display: grid; gap: 8px; }
.feed__empty { color: var(--ink-soft); text-align: center; padding: 10px 0; font-size: 14px; }
.meal-item {
  background: var(--card); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 12px;
}
.meal-item__emoji { font-size: 22px; }
.meal-item__main { flex: 1; min-width: 0; }
.meal-item__dish { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meal-item__sub { color: var(--ink-soft); font-size: 13px; }
.meal-item__kcal { font-weight: 700; white-space: nowrap; }
.meal-item__del {
  border: none; background: transparent; color: var(--ink-soft); font-size: 18px; cursor: pointer;
  padding: 4px;
}

/* ------- нижние действия ------- */
.actions {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(16px + env(safe-area-inset-bottom)); width: 100%; max-width: 480px;
  display: flex; align-items: flex-end; justify-content: center; gap: 22px;
  padding: 0 24px; pointer-events: none;
}
.action { pointer-events: auto; cursor: pointer; border: none; font-family: inherit; }
.action--ghost {
  background: var(--card); color: var(--ink); width: 64px; height: 64px; border-radius: 20px;
  box-shadow: var(--shadow); font-size: 22px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px;
}
.action--ghost small { font-size: 10px; color: var(--ink-soft); }
.action--camera {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  width: 84px; height: 84px; border-radius: 28px; color: #fff; font-size: 34px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 14px 30px rgba(255, 122, 89, .4);
}
.action--camera:active { transform: scale(.96); }

/* ------- экран добавления ------- */
.add-loading { text-align: center; padding: 70px 0; color: var(--ink-soft); }
.spinner {
  width: 52px; height: 52px; margin: 0 auto 18px; border-radius: 50%;
  border: 5px solid #f3e7de; border-top-color: var(--accent); animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.dish-card { background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.dish-name { font-size: 20px; font-weight: 700; text-align: center; }
.kcal-block { text-align: center; margin: 14px 0 6px; }
.kcal-main { font-size: 38px; font-weight: 800; }
.kcal-main span { color: var(--accent); }
.kcal-range { color: var(--ink-soft); font-size: 13px; margin-top: 2px; }

.macro-mini { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 16px 0; }
.macro-mini > div {
  background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 10px 4px;
  text-align: center;
}
.macro-mini b { display: block; font-size: 18px; }
.macro-mini small { color: var(--ink-soft); font-size: 11px; }

.portion { margin-top: 6px; }
.portion__label { display: block; font-size: 13px; color: var(--ink-soft); margin: 10px 0 8px; }
.seg { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 16px; padding: 4px; gap: 4px; }
.seg__btn {
  flex: 1; border: none; background: transparent; padding: 12px 0; border-radius: 12px;
  font-size: 18px; font-weight: 700; color: var(--ink-soft); cursor: pointer; font-family: inherit;
}
.seg__btn.is-on { background: var(--accent); color: #fff; box-shadow: var(--shadow); }

.calib-hint {
  width: 100%; margin-top: 14px; border: 1px dashed var(--line); background: var(--bg);
  color: var(--ink-soft); border-radius: 14px; padding: 11px; font-size: 13px; cursor: pointer;
  font-family: inherit;
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  border-radius: 14px; padding: 10px 16px; font-size: 14px; cursor: pointer; font-family: inherit;
}
.chip.is-on { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ------- кнопки ------- */
.btn-primary {
  width: 100%; margin-top: 18px; border: none; border-radius: 18px; padding: 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  font-size: 17px; font-weight: 700; cursor: pointer; font-family: inherit;
  box-shadow: 0 10px 24px rgba(255, 122, 89, .35);
}
.btn-primary:disabled { opacity: .6; cursor: default; }
.btn-primary--sm { width: auto; margin: 0; padding: 12px 22px; font-size: 15px; }
.btn-ghost {
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 16px; padding: 12px 20px; font-size: 15px; cursor: pointer; font-family: inherit;
}

/* ------- поля ввода (правило 1.6: не серые дефолтные) ------- */
.field {
  width: 100%; border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  border-radius: 14px; padding: 13px 14px; font-size: 16px; font-family: inherit;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255, 122, 89, .18); }

/* ------- нижний лист (голос/текст) ------- */
.sheet {
  position: fixed; inset: 0; background: rgba(44, 36, 32, .4); z-index: 40;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet__card {
  background: var(--card); width: 100%; max-width: 480px; border-radius: 24px 24px 0 0;
  padding: 22px 18px calc(22px + env(safe-area-inset-bottom)); animation: up .25s ease;
}
@keyframes up { from { transform: translateY(100%); } to { transform: none; } }
.sheet__card h3 { margin: 0 0 4px; }
.sheet__hint { color: var(--ink-soft); font-size: 13px; margin: 0 0 14px; }
.voice-live { min-height: 24px; color: var(--accent); font-weight: 600; margin-bottom: 12px; }
.sheet__row { display: flex; justify-content: space-between; gap: 12px; margin-top: 14px; }
.sheet__row .btn-ghost, .sheet__row .btn-primary { flex: 1; }

.sheet__card--tall { max-height: 80vh; overflow-y: auto; }
.policy-text { color: var(--ink); font-size: 14px; }
.policy-text p { margin: 0 0 10px; }

/* меню настроек */
.menu { display: grid; gap: 8px; margin: 12px 0 4px; }
.menu__item {
  display: flex; align-items: center; justify-content: space-between;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  border-radius: 14px; padding: 14px 16px; font-size: 15px; cursor: pointer;
  font-family: inherit; text-align: left; width: 100%;
}
.menu__item small { color: var(--ink-soft); font-size: 12px; }
.menu__item--danger { color: #e0574b; }

/* ------- тост ------- */
.toast {
  position: fixed; left: 50%; bottom: 110px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 14px; font-size: 14px;
  z-index: 60; box-shadow: var(--shadow); max-width: 90%;
}
