/* Трекер питания. Тёмная спокойная тема: приложение открывают несколько раз
   в день, поэтому ничего не мигает, не кричит и не красит перебор красным. */

:root {
  --bg: #12140f;
  --bg-soft: #171a13;
  --card: #1b1f18;
  --card-2: #232821;
  --line: #2e342a;
  --text: #f1efe4;
  --muted: #98a38b;
  --accent: #adc98a;
  --accent-ink: #16200c;
  --sand: #d8b877;
  --brick: #b8776a;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --nav-h: 66px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

/* ---------- шапка ---------- */

.header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: linear-gradient(to bottom, var(--bg) 70%, rgba(18, 20, 15, .82));
  backdrop-filter: blur(8px);
}

.header__brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  background: none;
  border: 0;
  padding: 4px 0;
  font-family: var(--serif);
  font-size: 20px;
  letter-spacing: .2px;
}

.header__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(173, 201, 138, .14);
}

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

.header__icon {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  transition: color .15s, border-color .15s;
}
.header__icon:hover { color: var(--text); border-color: #3d4436; }

.badge {
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--sand);
}

/* ---------- каркас ---------- */

.screen {
  max-width: 560px;
  margin: 0 auto;
  padding: 6px 14px calc(var(--nav-h) + env(safe-area-inset-bottom) + 32px);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.card__title {
  margin: 0 0 12px;
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
}

.muted { color: var(--muted); font-size: 14px; margin: 6px 0 0; }
.note {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-left: 2px solid var(--line);
  background: var(--bg-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 14px;
  color: var(--muted);
}
.note--warn { border-left-color: var(--sand); color: #e2d7bd; }
.note ul { margin: 6px 0 0; padding-left: 18px; }
.note li { margin: 2px 0; }

/* ---------- главный экран ---------- */

.daynav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 4px;
}
.daynav__label { font-size: 14px; color: var(--muted); }
.daynav__btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
}
.daynav__btn:disabled { opacity: .35; cursor: default; }

.card--hero { text-align: center; padding: 22px 16px 18px; }
.hero__label { margin: 0; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.hero__value {
  margin: 4px 0 0;
  font-family: var(--serif);
  font-size: 64px;
  line-height: 1;
  letter-spacing: -1px;
}
.hero__value--muted { font-size: 34px; color: var(--muted); }
.hero__unit { margin: 2px 0 0; font-size: 14px; color: var(--muted); }
.hero__hint { margin: 12px 0 0; font-size: 13px; color: var(--muted); }
.hero__note { margin: 8px 0 0; font-size: 13px; color: var(--sand); }

.bar { margin-bottom: 14px; }
.bar:last-child { margin-bottom: 0; }
.bar__head { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 6px; }
.bar__label { color: var(--muted); }
.bar__track { height: 7px; border-radius: 999px; background: var(--card-2); overflow: hidden; }
.bar__fill { height: 100%; border-radius: 999px; background: var(--accent); transition: width .25s ease; }

.card--pending { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card--pending p { margin: 0; font-size: 14px; color: var(--sand); }

.steps__row { display: flex; gap: 12px; }
.steps__row .field { flex: 1; }

/* ---------- лента еды ---------- */

.meals { list-style: none; margin: 0; padding: 0; }
.mealrow {
  display: grid;
  grid-template-columns: 62px 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 11px 0;
  border: 0;
  border-top: 1px solid var(--line);
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.meals > li:first-child .mealrow { border-top: 0; }
.mealrow:hover { background: rgba(255, 255, 255, .02); }
.mealrow:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mealrow__time { display: flex; flex-direction: column; font-size: 13px; }
.mealrow__time .muted { margin: 0; font-size: 11px; }
.mealrow__main { display: flex; flex-direction: column; min-width: 0; }
.mealrow__name { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mealrow__meta { font-size: 12px; color: var(--muted); }
.mealrow__kcal { font-family: var(--serif); font-size: 16px; white-space: nowrap; }
.mealrow--pending .mealrow__kcal { color: var(--sand); font-size: 13px; font-family: var(--font); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card-2);
  font-size: 13px;
  color: var(--text);
}
.chip:hover { border-color: var(--accent); }
.chip--fav { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.habits { display: flex; flex-direction: column; gap: 4px; }
.habit {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 0;
  font-size: 15px;
  cursor: pointer;
}
.habit input { width: 20px; height: 20px; accent-color: var(--accent); }

/* ---------- поля ---------- */

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field:last-child { margin-bottom: 0; }
.field--inline {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.field__label { font-size: 13px; color: var(--muted); }

.input {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  min-width: 0;
  width: 100%;
  color: var(--text);
}
.input:focus { outline: none; border-color: var(--accent); }
.field--inline .input { width: auto; max-width: 160px; text-align: right; }
.input--steps { max-width: 100%; text-align: left; }
.input--grams { max-width: 92px; text-align: center; }
.input--weight { max-width: none; text-align: left; font-size: 20px; }

.btn {
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 11px 16px;
  font-size: 15px;
  transition: transform .08s, background .15s, border-color .15s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn--ghost { background: transparent; }
.btn--danger { background: transparent; border-color: rgba(184, 119, 106, .5); color: var(--brick); }
.btn--block { display: block; width: 100%; margin-bottom: 10px; }

/* ---------- вес ---------- */

.weight__form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.weight__form .input { flex: 1 1 110px; width: auto; }
.weight__now { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.weight__big { font-family: var(--serif); font-size: 42px; line-height: 1; }
.weight__unit { font-size: 15px; color: var(--muted); margin-left: 4px; }
.weight__delta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: 14px; text-align: right; }
.weight__delta .muted { margin: 0; font-size: 13px; }

.chart-wrap { margin: 14px -4px 0; height: 220px; }
.chart-wrap--short { height: 150px; }
.chart { width: 100%; height: 100%; display: block; }
.chart__grid { stroke: var(--line); stroke-width: 1; }
.chart__tick { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart__goal { stroke: var(--sand); stroke-width: 1; stroke-dasharray: 4 4; opacity: .8; }
.chart__goal-label { fill: var(--sand); font-size: 11px; font-family: var(--font); }
.chart__ma { fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.chart__ma--second { stroke: #7fa8c9; }
.chart__trend { fill: none; stroke: var(--accent); stroke-width: 1.4; stroke-dasharray: 5 5; opacity: .65; }
.chart__eta { fill: var(--sand); }
.chart__dot { fill: rgba(241, 239, 228, .5); }
.chart__empty { fill: var(--muted); font-size: 14px; font-family: var(--font); }
.chart__bar { fill: var(--accent); opacity: .85; }
.chart__bar--over { fill: var(--sand); }
.chart__bar-value { fill: var(--muted); font-size: 10px; font-family: var(--font); }

.forecast__value { margin: 0; font-family: var(--serif); font-size: 30px; line-height: 1.1; }
.forecast__value--muted { color: var(--muted); font-size: 22px; }
.forecast__caption { margin: 4px 0 10px; font-size: 13px; color: var(--muted); }

/* ---------- давление ---------- */

.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 2px 0;
  font-family: var(--serif);
  font-size: 15px;
  color: var(--muted);
}
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.bp__form { display: flex; align-items: center; gap: 8px; }
.bp__form .input { width: auto; flex: 1 1 60px; min-width: 0; text-align: center; }
.bp__form select.input { flex: 1 1 92px; text-align: left; }
.bp__slash { color: var(--muted); }

.bp__split { display: flex; gap: 8px; margin: 12px 0 0; }
.bp__split-cell {
  flex: 1;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px;
  text-align: center;
}
.bp__split-value { display: block; font-family: var(--serif); font-size: 20px; }

.protocol { margin: 8px 0 0; padding-left: 18px; color: var(--muted); font-size: 14px; }
.protocol li { margin: 6px 0; }

.card--prompt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-style: dashed;
}
.card--prompt p { margin: 0; font-size: 14px; }
.card--prompt .btn { flex: 0 0 auto; padding: 8px 12px; font-size: 14px; }

.history { list-style: none; margin: 0; padding: 0; }
.history li {
  display: grid;
  grid-template-columns: 1fr auto auto 28px;
  gap: 10px;
  align-items: center;
  padding: 9px 0;
  border-top: 1px solid var(--line);
  font-size: 14px;
}
.history li:first-child { border-top: 0; }
.history__date { color: var(--muted); }
.history__value { font-family: var(--serif); }
.history__ma { margin: 0; font-size: 12px; }
.history__del { background: none; border: 0; color: var(--muted); font-size: 18px; line-height: 1; }
.history__del:hover { color: var(--brick); }

/* ---------- архив ---------- */

.cal__weekdays,
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal__weekdays { margin-bottom: 6px; font-size: 11px; color: var(--muted); text-align: center; }
.cal__cell {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-soft);
  padding: 0;
  overflow: hidden;
  color: var(--text);
}
.cal__cell--empty { border: 0; background: none; }
.cal__cell.is-today { border-color: var(--accent); }
.cal__day { position: absolute; top: 3px; left: 5px; z-index: 2; font-size: 11px; text-shadow: 0 1px 3px rgba(0, 0, 0, .8); }
.cal__thumb { position: absolute; inset: 0; background-size: cover; background-position: center; opacity: .62; }
.cal__kcal {
  position: absolute; bottom: 2px; right: 4px; z-index: 2;
  font-size: 10px; color: var(--text);
  text-shadow: 0 1px 3px rgba(0, 0, 0, .9);
}
.cal__kcal.is-over { color: var(--sand); }
.cal__cell.has-food { border-color: #3b4433; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; margin-top: 12px; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; }

/* ---------- отчёты ---------- */

.report__text { margin: 0; font-size: 15px; line-height: 1.6; }
.streak {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 0; border-top: 1px solid var(--line); font-size: 15px;
}
.streak:first-of-type { border-top: 0; }
.streak__label { color: var(--muted); }
.streak__value { font-family: var(--serif); }
.collage__out { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.collage__img { width: 100%; border-radius: var(--radius-sm); border: 1px solid var(--line); }

.deficit__value { margin: 10px 0 0; font-family: var(--serif); font-size: 24px; }
.deficit__scale { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }

/* ---------- нижняя панель ---------- */

.nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: center;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(23, 26, 19, .93);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.nav__btn {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: 0; padding: 6px 0;
  color: var(--muted); font-size: 11px;
}
.nav__btn svg { width: 22px; height: 22px; }
.nav__btn.is-active { color: var(--accent); }

.fab {
  justify-self: center;
  display: grid; place-items: center;
  width: 58px; height: 58px;
  margin-top: -22px;
  border-radius: 50%;
  border: 3px solid var(--bg);
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .5);
}
.fab svg { width: 26px; height: 26px; }
.fab:active { transform: scale(.96); }

/* ---------- выдвижной лист ---------- */

.backdrop {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(0, 0, 0, .6);
  opacity: 0; transition: opacity .2s;
}
.backdrop.is-open { opacity: 1; }

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 41;
  max-height: 92vh;
  display: flex; flex-direction: column;
  background: var(--card);
  border-top: 1px solid var(--line);
  border-radius: 20px 20px 0 0;
  box-shadow: var(--shadow);
  transform: translateY(100%);
  transition: transform .24s cubic-bezier(.2, .8, .2, 1);
}
.sheet.is-open { transform: translateY(0); }
.sheet--wide { max-width: 560px; margin: 0 auto; }

.sheet__head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 16px 16px 8px;
}
.sheet__title { margin: 0; font-family: var(--serif); font-size: 19px; }
.sheet__subtitle { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.sheet__close { background: none; border: 0; color: var(--muted); font-size: 26px; line-height: 1; padding: 0 4px; }
.sheet__body { padding: 8px 16px 16px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet__foot {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding: 12px 16px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--bg-soft);
}
.sheet__foot .btn { flex: 1 1 auto; }

/* ---------- редактор порции ---------- */

.editor__photo { margin: 0 0 14px; border-radius: var(--radius-sm); overflow: hidden; background: var(--bg-soft); }
.editor__photo img { display: block; width: 100%; max-height: 240px; object-fit: cover; }

.editor__portion { margin: 14px 0; }
.editor__portion-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.editor__grams-value { font-family: var(--serif); font-size: 20px; }

.editor__slider {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 26px; background: transparent;
}
.editor__slider::-webkit-slider-runnable-track {
  height: 6px; border-radius: 999px; background: var(--card-2);
}
.editor__slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 24px; height: 24px; margin-top: -9px;
  border-radius: 50%; background: var(--accent); border: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .5);
}
.editor__slider::-moz-range-track { height: 6px; border-radius: 999px; background: var(--card-2); }
.editor__slider::-moz-range-thumb { width: 24px; height: 24px; border: 0; border-radius: 50%; background: var(--accent); }

.editor__quick { display: flex; gap: 8px; margin: 6px 0 12px; }
.editor__quick .chip { flex: 1; text-align: center; }
.editor__exact { display: flex; align-items: center; gap: 8px; }
.editor__exact .muted { margin: 0; }

.nutrients {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
  gap: 8px;
  margin: 14px 0;
}
.nutrients__cell {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px;
  text-align: center;
}
.nutrients__cell--big { grid-column: span 2; background: var(--card-2); }
.nutrients__value { display: block; font-family: var(--serif); font-size: 20px; }
.nutrients__cell--big .nutrients__value { font-size: 28px; }
.nutrients__label { display: block; margin-top: 2px; font-size: 11px; color: var(--muted); }

.components { list-style: none; margin: 8px 0 0; padding: 0; }
.components li {
  display: grid; grid-template-columns: 1fr auto auto; gap: 10px;
  padding: 7px 0; border-top: 1px solid var(--line); font-size: 14px;
}
.components__grams, .components__kcal { color: var(--muted); font-size: 13px; }
.editor__components summary, details summary { cursor: pointer; color: var(--muted); font-size: 14px; }

.notice {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  margin: 0 0 14px;
}
.notice p { margin: 0 0 8px; font-size: 14px; }
.notice--ask { border-color: rgba(216, 184, 119, .4); }
.notice__row { display: flex; gap: 8px; }
.notice__row .input { flex: 1; }

.flags { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.flag {
  padding: 3px 9px; border-radius: 999px;
  border: 1px solid rgba(216, 184, 119, .45);
  color: var(--sand); font-size: 12px;
}

/* ---------- всплывающие подсказки и ожидание ---------- */

.toasts {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 14px);
  z-index: 60;
  display: flex; flex-direction: column; gap: 8px;
  width: min(92vw, 420px);
}
.toast {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--card-2);
  box-shadow: var(--shadow);
  font-size: 14px;
  animation: toast-in .2s ease;
}
.toast--ok { border-color: rgba(173, 201, 138, .5); }
.toast--error { border-color: rgba(184, 119, 106, .55); }
.toast--out { opacity: 0; transition: opacity .3s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.busy {
  position: fixed; inset: 0; z-index: 70;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: rgba(18, 20, 15, .86);
  backdrop-filter: blur(3px);
  color: var(--text);
}
.busy p { margin: 0; font-size: 15px; color: var(--muted); }
.busy__timer { font-family: var(--serif); font-size: 22px; color: var(--text) !important; }
.busy__hint { font-size: 13px !important; }
.busy__spinner {
  width: 34px; height: 34px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media (min-width: 620px) {
  .screen { padding-bottom: 40px; }
  .nav { max-width: 560px; margin: 0 auto; border-radius: 18px 18px 0 0; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}
