/*
 * NotMeal — дизайн-система (тёмная тема, mobile-first PWA).
 * База: вариант B «Минимал» прототипа + glass-карточки варианта A.
 * Токены — в :root, компоненты — классами ниже. Без инлайн-стилей во вьюхах
 * (исключение: CSS custom property --pct для прогресс-баров).
 */

:root {
  --bg: #05070A;
  --text: #F7F9FB;
  --dim: #BCC5D0;
  --faint: #9AA4B0;
  --mint: #8BEAC2;
  --mint-ink: #06231A;
  --coral: #FF9A8F;
  --border: rgba(255, 255, 255, 0.14);
  --line: rgba(255, 255, 255, 0.10);
  --track: rgba(255, 255, 255, 0.12);
  --card-bg: rgba(10, 13, 17, 0.6);
  --glass-strong: rgba(8, 11, 15, 0.74);
  --input-bg: rgba(255, 255, 255, 0.06);
  --font: "Inter", -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  --radius: 22px;
  --radius-card: 20px;
  --radius-input: 14px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
h1, h2, p { margin: 0; }

/* Цифры — моноширинным */
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ── Каркас страницы ───────────────────────────────────────── */

.shell {
  max-width: 430px;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 20px calc(176px + env(safe-area-inset-bottom));
}

/* Центрирование (страница входа) */
body.centered .shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-bottom: 48px;
}

/* ── Flash ──────────────────────────────────────────────────── */

.flash-stack {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  width: min(390px, calc(100% - 32px));
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 50;
}

.flash {
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  background: var(--glass-strong);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 12px 16px;
  font-size: 14px;
  color: var(--dim);
}

.flash--alert { border-color: rgba(255, 154, 143, 0.5); color: var(--coral); }
.flash--notice { border-color: rgba(139, 234, 194, 0.5); color: var(--mint); }

/* ── Glass-карточка ─────────────────────────────────────────── */

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  backdrop-filter: blur(20px) saturate(1.6);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 12px 40px rgba(0, 0, 0, 0.45);
  padding: 18px 20px;
}

/* ── Заголовки секций / страниц ─────────────────────────────── */

.section-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
  margin: 22px 4px 10px;
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 6px 4px 14px;
}

.page-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 0 14px;
}

.page-head h1 { font-size: 17px; font-weight: 600; }

.back-btn {
  width: 44px;
  height: 44px;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ── Кнопки ─────────────────────────────────────────────────── */

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 120ms ease;
}

.btn:active { transform: scale(0.98); }

.btn--mint { background: var(--mint); color: var(--mint-ink); }

.btn--big { width: 100%; height: 54px; font-size: 16px; }

.btn--ghost {
  background: var(--input-bg);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: var(--text);
}

.btn-form { width: 100%; }

/* ── Переключатель биодней ──────────────────────────────────── */

.day-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 0 16px;
}

.day-nav__arrow {
  width: 44px;
  height: 44px;
  border-radius: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--dim);
}

.day-nav__arrow--off { opacity: 0.25; pointer-events: none; }

.day-nav__center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.day-nav__label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}

.day-nav__date { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }

/* ── Блок сна ───────────────────────────────────────────────── */

.sleep {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 18px;
}

.sleep__meta {
  font-size: 13px;
  color: var(--dim);
  text-align: center;
}

.badge-est {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--coral);
  cursor: help;
}

/* ── Калории крупно ─────────────────────────────────────────── */

.kcal-hero {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 6px 0 22px;
}

.kcal-hero__top {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.kcal-hero__value {
  font-size: 56px;
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1;
}

.kcal-hero__side {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.kcal-hero__goal { font-size: 13px; color: var(--dim); }

.kcal-hero__rest { font-size: 13px; font-weight: 500; }
.kcal-hero__rest--ok { color: var(--mint); }
.kcal-hero__rest--over { color: var(--coral); }

/* ── Прогресс-бар (тонкий) ──────────────────────────────────── */

.bar {
  height: 4px;
  border-radius: 2px;
  background: var(--track);
  overflow: hidden;
}

.bar__fill {
  height: 100%;
  border-radius: 2px;
  width: var(--pct, 0%);
  background: var(--text);
  transition: width 600ms cubic-bezier(0.4, 0, 0.2, 1);
}

.bar__fill--ok { background: var(--mint); }
.bar__fill--over { background: var(--coral); }

/* ── Грид Б/Ж/У ─────────────────────────────────────────────── */

.macros {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.macro {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.macro__label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
}

.macro__value { font-size: 18px; font-weight: 600; }

.macro__goal { font-size: 12px; font-weight: 400; color: var(--faint); }

/* ── Hairline-строки ────────────────────────────────────────── */

.rows { border-bottom: 1px solid var(--line); }

.row {
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--line);
}

.row__label { font-size: 13px; font-weight: 500; color: var(--dim); }

.row__value { font-size: 13px; }
.row__value--over { color: var(--coral); }

.row__suffix { color: var(--faint); }

/* Траты: раскрывающийся список */
.spend summary { cursor: pointer; list-style: none; }
.spend summary::-webkit-details-marker { display: none; }
.spend[open] summary .row__label::after { content: " ▴"; color: var(--faint); }
.spend summary .row__label::after { content: " ▾"; color: var(--faint); }

.tx-list {
  list-style: none;
  margin: 0;
  padding: 0 0 14px;
}

.tx {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 7px 0;
  font-size: 13px;
}

.tx__time { font-size: 12px; color: var(--faint); flex-shrink: 0; }

.tx__label {
  flex: 1;
  min-width: 0;
  color: var(--dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tx__amount { flex-shrink: 0; }
.tx--income .tx__amount { color: var(--mint); }

/* ── Карточки приёмов пищи ──────────────────────────────────── */

.meals {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.meal-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--card-bg);
  backdrop-filter: blur(20px) saturate(1.6);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.meal-card--draft {
  border-color: rgba(255, 154, 143, 0.55);
  background: rgba(255, 123, 110, 0.08);
}

.meal-card--cancelled { opacity: 0.55; }
.meal-card--cancelled .meal-card__title { text-decoration: line-through; }

.meal-card__top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.meal-card__time { font-size: 12px; color: var(--faint); }

.meal-card__price { margin-left: auto; font-size: 12px; color: var(--faint); }

.meal-card__title { font-size: 14px; font-weight: 500; line-height: 1.3; }

.meal-card__nutr { font-size: 12px; color: var(--dim); }

/* Бейджи */
.tag {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 3px 7px;
  color: var(--dim);
  white-space: nowrap;
}

.tag--mint { color: var(--mint); border-color: rgba(139, 234, 194, 0.5); }
.tag--coral { color: var(--coral); border-color: rgba(255, 154, 143, 0.5); }

/* ── Intakes-лента ──────────────────────────────────────────── */

.intakes { margin-top: 4px; }

.intake {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 13px;
  color: var(--dim);
}

.intake:first-child { border-top: none; }

.intake__qty { color: var(--faint); }

.intake__time { font-size: 12px; color: var(--faint); }

/* ── Пустые состояния ───────────────────────────────────────── */

.empty {
  border: 1px dashed rgba(255, 255, 255, 0.25);
  border-radius: 18px;
  padding: 18px;
  text-align: center;
  font-size: 13px;
  color: var(--faint);
}

/* ── Quick-log панель ───────────────────────────────────────── */

.quicklog {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(94px + env(safe-area-inset-bottom));
  width: min(430px, 100%);
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 30;
}

.quicklog__chips {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px;
  scrollbar-width: none;
}

.quicklog__chips::-webkit-scrollbar { display: none; }

.chip-form { flex-shrink: 0; }

.chip {
  height: 40px;
  padding: 0 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--glass-strong);
  backdrop-filter: blur(20px) saturate(1.6);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 120ms ease;
}

.chip:active { transform: scale(0.96); }

.fab {
  width: 54px;
  height: 54px;
  border-radius: 27px;
  background: var(--mint);
  color: var(--mint-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 12px 30px rgba(139, 234, 194, 0.35), 0 4px 12px rgba(0, 0, 0, 0.4);
  transition: transform 120ms ease;
}

.fab:active { transform: scale(0.92); }

/* ── Нижняя навигация ───────────────────────────────────────── */

.nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(14px + env(safe-area-inset-bottom));
  width: min(406px, calc(100% - 24px));
  height: 66px;
  border-radius: 33px;
  border: 1px solid var(--border);
  background: var(--glass-strong);
  backdrop-filter: blur(24px) saturate(1.6);
  -webkit-backdrop-filter: blur(24px) saturate(1.6);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 12px 40px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: stretch;
  padding: 0 10px;
  z-index: 31;
}

.nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--faint);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.nav__item--active { color: var(--text); }

.nav__plus {
  align-self: center;
  width: 46px;
  height: 46px;
  border-radius: 23px;
  margin: 0 6px;
  background: var(--mint);
  color: var(--mint-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ── Формы ──────────────────────────────────────────────────── */

.form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.label { font-size: 12px; font-weight: 500; color: var(--dim); }

.input {
  width: 100%;
  height: 50px;
  border-radius: var(--radius-input);
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  padding: 0 14px;
}

.input::placeholder { color: #7C8794; }

.input:focus {
  outline: none;
  border-color: rgba(139, 234, 194, 0.5);
}

.input--num {
  font-family: var(--mono);
  font-weight: 600;
}

textarea.input {
  height: auto;
  padding: 12px 14px;
  resize: none;
  line-height: 1.45;
}

.hint {
  font-size: 12px;
  color: var(--faint);
  line-height: 1.5;
  padding: 0 4px;
}

/* Заглушка «фото — скоро» */
.photo-stub {
  border: 1px dashed rgba(255, 255, 255, 0.3);
  border-radius: var(--radius);
  background: rgba(10, 13, 17, 0.55);
  padding: 26px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
  opacity: 0.65;
}

.photo-stub__title { font-size: 14px; font-weight: 600; }

.photo-stub__hint { font-size: 12px; color: var(--faint); }

/* ── Цель ───────────────────────────────────────────────────── */

.goal-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.goal-card__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.goal-card__label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
}

.goal-card__status { font-size: 11px; font-weight: 600; color: var(--mint); }

.goal-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.goal-grid__cell {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.goal-grid__num {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.goal-grid__cap { font-size: 11px; color: var(--faint); }

/* Список (история целей) */
.list { padding: 6px 20px; }

.list-row {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.list-row:first-child { border-top: none; }

.list-row__main {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.list-row__title { font-size: 13px; font-weight: 500; color: var(--dim); }

.list-row__sub { font-size: 11px; color: var(--faint); }
.list-row__sub--active { color: var(--mint); }

.list-row__value { font-size: 12px; color: var(--faint); }

.list-row--active .list-row__title { color: var(--text); }
.list-row--active .list-row__value { color: var(--dim); }

/* ── Вход ───────────────────────────────────────────────────── */

.auth {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth__head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding-bottom: 8px;
}

.auth__logo { font-size: 34px; font-weight: 700; letter-spacing: -0.03em; }

.auth__tagline { font-size: 14px; color: var(--dim); }

.auth__card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth__link {
  text-align: center;
  font-size: 14px;
  color: var(--dim);
  padding: 10px;
}

.auth__link:hover { color: var(--text); }

/* ── Чат биодня ─────────────────────────────────────────── */
.chat { display: flex; flex-direction: column; gap: 10px; padding-bottom: 140px; }
.msg { position: relative; max-width: 86%; border-radius: 18px; padding: 10px 14px 18px; }
.msg--user { align-self: flex-end; background: rgba(139, 234, 194, 0.12); border: 1px solid rgba(139, 234, 194, 0.3); }
.msg--assistant { align-self: flex-start; background: rgba(10, 13, 17, 0.6); border: 1px solid var(--glass-border); }
.msg--failed { border-color: rgba(255, 154, 143, 0.5); }
.msg__text { margin: 0; font-size: 14px; line-height: 1.45; }
.msg__photos { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.msg__photo { width: 96px; height: 96px; border-radius: 12px; object-fit: cover; }
.msg__actions { list-style: none; margin: 8px 0 0; padding: 8px 0 0; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; }
.msg__action { font-size: 12px; color: var(--dim); }
.msg__time { position: absolute; right: 12px; bottom: 4px; font-size: 9px; color: var(--faint); }
.chat-form { position: fixed; left: 50%; transform: translateX(-50%); bottom: 92px; width: min(100% - 24px, 406px); display: flex; gap: 8px; align-items: flex-end; padding: 8px; border-radius: 20px; border: 1px solid var(--glass-border); background: rgba(8, 11, 15, 0.85); backdrop-filter: blur(24px) saturate(1.6); z-index: 25; }
.chat-form__input { flex: 1; min-height: 40px; max-height: 120px; border: none; background: none; color: var(--text); font: 15px/1.4 inherit; font-family: inherit; resize: none; padding: 9px 4px; }
.chat-form__send { width: 40px; height: 40px; border-radius: 14px; border: none; background: var(--mint); color: #06231A; font-size: 18px; font-weight: 700; cursor: pointer; flex-shrink: 0; }
.chat-form__photo { width: 40px; height: 40px; border-radius: 14px; border: 1px solid var(--glass-border); color: var(--dim); display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; }
.chat-form__file { display: none; }

/* ── Glass-линза (liquid glass) ─────────────────────────── */
.glass-lens { position: relative; overflow: hidden; }
.glass-lens__backdrop { position: absolute; inset: 0; border-radius: inherit; overflow: hidden; }
.glass-lens__layer { position: absolute; inset: 0; transform: scale(1.16); filter: blur(2.5px) saturate(1.55) brightness(1.1); transition: opacity 2000ms ease-in-out; will-change: background-position, opacity; }
.glass-lens__tint { position: absolute; inset: 0; background: rgba(8, 11, 15, 0.64); }
.glass-lens__tint::after { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 45%; background: linear-gradient(180deg, rgba(255,255,255,0.07), transparent); }
.glass-lens > *:not(.glass-lens__backdrop) { position: relative; }

/* ── Голосовой ввод ─────────────────────────────────────── */
.chat-form__voice { position: relative; width: 40px; height: 40px; border-radius: 14px; border: 1px solid var(--glass-border); background: none; color: var(--dim); display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; }
.chat-form__voice--rec { color: var(--coral); border-color: rgba(255, 154, 143, 0.6); animation: voice-pulse 1.4s ease-in-out infinite; }
.chat-form__voice--rec::before { content: ""; position: absolute; inset: -5px; border-radius: 18px; border: 1.5px solid rgba(255, 154, 143, 0.5); animation: voice-ring 1.4s ease-out infinite; }
@keyframes voice-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }
@keyframes voice-ring { 0% { transform: scale(0.9); opacity: 1; } 100% { transform: scale(1.25); opacity: 0; } }
