/* FitLog — тёмная мобильная тема */

:root {
  --bg: #0C1117;
  --card: #161D26;
  --card2: #1F2937;
  --line: rgba(255, 255, 255, 0.07);
  --ink: #F0F4F8;
  --ink2: #9DAFC0;
  --muted: #67788C;
  --accent: #1BAF7A;
  --accent-soft: rgba(27, 175, 122, 0.14);
  --on-accent: #06231A;
  --blue: #3987E5;
  --blue-soft: rgba(57, 135, 229, 0.16);
  --yellow: #C98500;
  --violet: #9085E9;
  --red: #D03B3B;
  --red-soft: rgba(208, 59, 59, 0.14);
  --good: #0CA30C;
  --r: 18px;
  --tabbar-h: 62px;
}

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

html { color-scheme: dark; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}

#screens {
  max-width: 480px;
  margin: 0 auto;
  padding: calc(6px + env(safe-area-inset-top)) 0 calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
  min-height: 100dvh;
}

.screen { padding: 0 12px; }
.screen-pad { height: 84px; }
.hidden { display: none !important; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Шапки ---------- */

.screen-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 6px 12px;
}
.screen-head h1 { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }

.date-nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 2px 12px;
}
.date-label {
  background: none; border: 0; color: var(--ink);
  font-size: 18px; font-weight: 700; font-family: inherit;
  padding: 8px 14px; border-radius: 12px; cursor: pointer;
}
.date-label:active { background: var(--card); }

.icon-btn {
  width: 44px; height: 44px; border: 0; border-radius: 12px;
  background: var(--card); color: var(--ink2); cursor: pointer;
  display: grid; place-items: center;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:active { background: var(--card2); }

/* ---------- Карточки ---------- */

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

.card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.card-title { font-size: 15px; font-weight: 700; }
.card-sub { font-size: 13px; color: var(--ink2); font-variant-numeric: tabular-nums; }

.section-label {
  font-size: 13px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em;
  margin: 16px 6px 8px;
}

/* ---------- Герой: кольцо калорий ---------- */

.hero-card { display: flex; align-items: center; gap: 14px; }

#ring-wrap { flex: 0 0 auto; position: relative; width: 158px; height: 158px; }
#ring-wrap svg { display: block; }

.ring-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; pointer-events: none;
}
.ring-num { font-size: 36px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.05; }
.ring-num.over { color: var(--red); }
.ring-cap { font-size: 12px; color: var(--ink2); margin-top: 2px; }

.hero-stats { flex: 1; display: flex; flex-direction: column; gap: 12px; }
.hstat { display: flex; flex-direction: column; }
.hstat-num { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }
.hstat-cap { font-size: 12px; color: var(--muted); }

/* ---------- Макросы ---------- */

.macro-row { display: grid; grid-template-columns: 78px 1fr auto; gap: 10px; align-items: center; padding: 7px 0; }
.macro-name { font-size: 13.5px; color: var(--ink2); }
.macro-track { height: 6px; border-radius: 4px; background: var(--card2); overflow: hidden; }
.macro-fill { height: 100%; border-radius: 4px; width: 0; transition: width 0.35s ease; }
.macro-fill.m-p { background: var(--blue); }
.macro-fill.m-f { background: var(--yellow); }
.macro-fill.m-c { background: var(--violet); }
.macro-val { font-size: 13px; color: var(--ink2); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Вода ---------- */

.water-bar { height: 10px; border-radius: 6px; background: var(--card2); overflow: hidden; margin-bottom: 12px; }
.water-fill { height: 100%; width: 0; border-radius: 6px; background: var(--blue); transition: width 0.3s ease; }
.water-btns { display: flex; gap: 8px; }

/* ---------- Приёмы пищи ---------- */

.meal-card .card-head { margin-bottom: 4px; }
.meal-kcal { font-size: 14px; font-weight: 700; color: var(--ink2); font-variant-numeric: tabular-nums; }

.food-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 2px; border-top: 1px solid var(--line);
  cursor: pointer; min-height: 44px;
}
.food-row:first-of-type { border-top: 0; }
.food-row-name { flex: 1; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.food-row-info { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.food-row-kcal { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; min-width: 44px; text-align: right; }

.meal-add {
  width: 100%; margin-top: 6px; padding: 11px; border: 0; border-radius: 12px;
  background: var(--accent-soft); color: var(--accent);
  font-family: inherit; font-size: 14.5px; font-weight: 700; cursor: pointer;
}
.meal-add:active { opacity: 0.75; }

.meal-empty { font-size: 13.5px; color: var(--muted); padding: 8px 2px 2px; }

/* ---------- Кнопки, чипы, сегменты ---------- */

.wide-btn {
  width: 100%; padding: 14px; border: 0; border-radius: 14px;
  background: var(--card2); color: var(--ink);
  font-family: inherit; font-size: 16px; font-weight: 700; cursor: pointer;
}
.wide-btn.accent { background: var(--accent); color: var(--on-accent); }
a.wide-btn { display: block; text-align: center; text-decoration: none; }
.wide-btn.danger { background: var(--red-soft); color: #E66767; }
.wide-btn:active { transform: scale(0.985); }

.btn-row { display: flex; gap: 8px; margin-top: 12px; }
.btn-row .wide-btn { flex: 1; }
.btn-row input[type="text"] {
  flex: 1; min-width: 0;
}
.btn-col { display: flex; flex-direction: column; gap: 8px; }

.mini-btn {
  padding: 8px 14px; border: 0; border-radius: 10px;
  background: var(--accent-soft); color: var(--accent);
  font-family: inherit; font-size: 13.5px; font-weight: 700; cursor: pointer;
}

.chip-row {
  display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px;
  scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }

.chip-btn {
  padding: 9px 14px; border: 0; border-radius: 999px;
  background: var(--card2); color: var(--ink2);
  font-family: inherit; font-size: 13.5px; font-weight: 600;
  cursor: pointer; white-space: nowrap; flex: 0 0 auto;
}
.chip-btn.on { background: var(--accent); color: var(--on-accent); }
.chip-btn.ghost { background: transparent; border: 1px solid var(--line); }

.seg {
  display: flex; background: var(--card2); border-radius: 12px; padding: 3px; gap: 2px;
}
.seg button {
  flex: 1; padding: 9px 4px; border: 0; border-radius: 10px;
  background: transparent; color: var(--ink2);
  font-family: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
  white-space: nowrap;
}
.seg button.on { background: var(--accent); color: var(--on-accent); font-weight: 700; }

/* ---------- Тренировка ---------- */

.wo-timer { font-size: 15px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }

.wo-empty { text-align: center; padding: 26px 16px; }
.wo-empty-emoji { font-size: 44px; margin-bottom: 8px; }
.wo-empty p { color: var(--ink2); font-size: 14.5px; margin-bottom: 16px; }

.ex-card { margin-bottom: 10px; }
.ex-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.ex-name { font-size: 15.5px; font-weight: 700; }
.ex-muscle {
  font-size: 11.5px; font-weight: 700; color: var(--accent);
  background: var(--accent-soft); border-radius: 999px; padding: 3px 9px;
  white-space: nowrap;
}
.ex-del { background: none; border: 0; color: var(--muted); font-size: 18px; cursor: pointer; padding: 4px 8px; }

.set-grid-head, .set-grid {
  display: grid; grid-template-columns: 26px 1fr 66px 66px 44px 30px;
  gap: 6px; align-items: center;
}
.set-grid-head {
  font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em;
  padding: 4px 0;
}
.set-grid { padding: 3px 0; }
.set-num { font-size: 13px; color: var(--muted); font-weight: 700; text-align: center; }
.set-prev { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

.set-grid input {
  width: 100%; padding: 10px 4px; text-align: center;
  background: var(--card2); border: 1px solid transparent; border-radius: 10px;
  color: var(--ink); font-family: inherit; font-size: 15px; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.set-grid input:focus { outline: none; border-color: var(--accent); }
.set-grid.done input { color: var(--accent); background: var(--accent-soft); }

.set-check {
  width: 44px; height: 40px; border: 0; border-radius: 10px;
  background: var(--card2); color: var(--muted); font-size: 17px; cursor: pointer;
}
.set-check.on { background: var(--accent); color: var(--on-accent); }
.set-x { background: none; border: 0; color: var(--muted); font-size: 16px; cursor: pointer; padding: 6px 2px; }

.add-set {
  width: 100%; margin-top: 8px; padding: 10px; border: 0; border-radius: 10px;
  background: var(--card2); color: var(--ink2);
  font-family: inherit; font-size: 14px; font-weight: 700; cursor: pointer;
}

.wo-actions { display: flex; gap: 8px; margin: 4px 0 8px; }
.wo-actions .wide-btn { flex: 1; }

.wo-hist-item { cursor: pointer; }
.wo-hist-top { display: flex; justify-content: space-between; align-items: center; }
.wo-hist-date { font-size: 14.5px; font-weight: 700; }
.wo-hist-sub { font-size: 13px; color: var(--ink2); margin-top: 3px; }
.wo-hist-detail { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px; }
.wo-hist-ex { font-size: 13.5px; padding: 3px 0; color: var(--ink2); }
.wo-hist-ex b { color: var(--ink); font-weight: 600; }

.diary-wo-card { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.diary-wo-ico { font-size: 26px; }
.diary-wo-txt { flex: 1; }
.diary-wo-title { font-size: 14.5px; font-weight: 700; }
.diary-wo-sub { font-size: 13px; color: var(--ink2); }

/* ---------- Прогресс ---------- */

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.tile {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 12px 10px; text-align: center;
}
.tile-num { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.tile-cap { font-size: 11.5px; color: var(--muted); margin-top: 2px; line-height: 1.25; }

.weight-now { font-size: 26px; font-weight: 800; margin-bottom: 6px; font-variant-numeric: tabular-nums; }
.weight-now .delta { font-size: 14px; font-weight: 700; margin-left: 8px; }
.delta.down { color: var(--accent); }
.delta.up { color: var(--yellow); }

.chart-box { width: 100%; }
.chart-box svg { display: block; width: 100%; height: auto; }
.chart-empty { color: var(--muted); font-size: 13.5px; padding: 14px 0; }

/* ---------- Профиль ---------- */

.form-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; font-size: 13.5px; color: var(--ink2); }
.seg-row { display: block; }
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.form-grid.four { grid-template-columns: repeat(4, 1fr); }
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink2); }

input[type="number"], input[type="text"], input[type="search"], select {
  padding: 12px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--card2); color: var(--ink);
  font-family: inherit; font-size: 16px; width: 100%;
  appearance: none;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }

.calc-line { font-size: 13.5px; color: var(--ink2); padding: 4px 2px 8px; line-height: 1.5; }
.calc-line b { color: var(--ink); font-variant-numeric: tabular-nums; }

.check-row {
  display: flex; align-items: center; gap: 10px;
  font-size: 14.5px; color: var(--ink); padding: 4px 0;
}
.check-row input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); }
.inline-num { max-width: 110px; padding: 8px 10px; }
.inline-num:disabled { opacity: 0.4; }

.install-steps { padding-left: 20px; font-size: 14.5px; color: var(--ink2); display: flex; flex-direction: column; gap: 8px; }
.install-steps b { color: var(--ink); font-weight: 700; }
.install-note { font-size: 13px; color: var(--muted); margin-top: 10px; line-height: 1.5; }
.install-card .wide-btn { margin-top: 12px; }

/* иконка «Поделиться» из iOS — чтобы шаг искали глазами, а не по описанию */
.share-svg {
  width: 17px; height: 17px; vertical-align: -3px; margin: 0 1px;
  color: var(--blue);
}

.install-ok {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 7px;
  font-size: 14.5px; color: var(--ink2);
}
.install-ok li::before { content: '✓'; color: var(--accent); font-weight: 800; margin-right: 8px; }

.pill-ok {
  padding: 4px 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 12.5px; font-weight: 700;
}

.wide-btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--ink2); font-weight: 600; }
#sheet-install .btn-col { margin-top: 16px; }

/* ---------- Таббар ---------- */

#tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; justify-content: space-around;
  max-width: 480px; margin: 0 auto;
  background: rgba(15, 21, 29, 0.92);
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: 0; color: var(--muted);
  font-family: inherit; font-size: 10.5px; font-weight: 600; cursor: pointer;
  padding: 5px 0; border-radius: 12px;
}
.tab svg { width: 23px; height: 23px; }
.tab.on { color: var(--accent); }

/* ---------- Таймер отдыха ---------- */

#rest-pill {
  position: fixed; z-index: 40;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px);
  left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px;
  background: var(--accent); color: var(--on-accent);
  border-radius: 999px; padding: 10px 12px 10px 18px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}
#rest-time { font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; min-width: 52px; }
#rest-pill button {
  border: 0; border-radius: 999px; padding: 8px 12px;
  background: rgba(0, 0, 0, 0.18); color: var(--on-accent);
  font-family: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
}

/* ---------- Шторки ---------- */

#sheet-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0, 0, 0, 0.55);
}

.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  max-width: 480px; margin: 0 auto;
  background: var(--card); border-radius: 22px 22px 0 0;
  border-top: 1px solid var(--line);
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
  max-height: 86dvh; overflow-y: auto;
  animation: sheet-up 0.22s ease;
}
@keyframes sheet-up {
  from { transform: translateY(40px); opacity: 0.4; }
  to { transform: translateY(0); opacity: 1; }
}

.sheet-grip {
  width: 40px; height: 4px; border-radius: 2px;
  background: var(--card2); margin: 4px auto 14px;
}
.sheet-title { font-size: 18px; font-weight: 800; margin-bottom: 6px; }
.sheet-sub { font-size: 13.5px; color: var(--ink2); margin-bottom: 14px; }

.sheet-list { margin: 6px 0 12px; max-height: 46dvh; overflow-y: auto; }

.pick-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 4px; border-bottom: 1px solid var(--line);
  cursor: pointer; min-height: 46px;
}
.pick-name { flex: 1; font-size: 14.5px; }
.pick-info { font-size: 12.5px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.pick-empty { color: var(--muted); font-size: 14px; padding: 18px 4px; text-align: center; }

.portion-preview {
  display: flex; justify-content: space-between;
  background: var(--card2); border-radius: 14px; padding: 12px 16px; margin: 12px 0;
}
.pp-item { text-align: center; }
.pp-num { font-size: 16px; font-weight: 800; font-variant-numeric: tabular-nums; }
.pp-cap { font-size: 11px; color: var(--muted); }

.finish-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0 16px; }

#sheet-portion .seg { margin-bottom: 4px; }

/* ---------- Тост ---------- */

#toast {
  position: fixed; z-index: 80;
  top: calc(12px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  background: var(--card2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 18px; font-size: 14px; font-weight: 600;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
  max-width: 90%; text-align: center;
  animation: sheet-up 0.2s ease;
}

/* ---------- Сканер ---------- */

#scan-video {
  border-radius: 14px; overflow: hidden; background: #000;
  min-height: 200px; margin-bottom: 10px;
}
#scan-video video { width: 100%; display: block; }
#sheet-scan .btn-row { margin: 4px 0 10px; }
#sheet-scan .wide-btn { margin-bottom: 8px; }

/* ---------- Баннеры ---------- */

.banner-card { display: flex; align-items: center; gap: 10px; }
.banner-card .banner-txt { flex: 1; font-size: 13.5px; color: var(--ink2); line-height: 1.45; }
.banner-card.warn { border-color: rgba(208, 59, 59, 0.55); }
.banner-card.warn .banner-txt { color: var(--ink); }

/* Десктоп: рамка телефона по центру */
@media (min-width: 600px) {
  body { background: #070B10; }
  #screens { border-left: 1px solid var(--line); border-right: 1px solid var(--line); background: var(--bg); }
}
