:root {
  --bg: #0b0c0f;
  --surface: #15171c;
  --surface-2: #1d2027;
  --surface-3: #262a33;
  --line: #2a2e37;
  --text: #f3f5f7;
  --muted: #8d95a3;
  --faint: #5d6472;
  --accent: #c6f135;
  --accent-2: #a6d81c;
  --accent-ink: #0b0c0f;
  --accent-soft: rgba(198, 241, 53, .12);
  --ready: #ffb020;
  --danger: #ff5a4e;
  --danger-soft: rgba(255, 90, 78, .12);
  --protein: #5ad8ff;
  --fat: #ff9f5a;
  --carb: #b79cff;
  --ok: #3ddc84;
  --radius: 22px;
  --radius-s: 14px;
  --tab-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); }
body { font-size: 16px; line-height: 1.35; -webkit-font-smoothing: antialiased; overscroll-behavior-y: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
input, select { font: inherit; color: var(--text); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.hidden { display: none !important; }

/* ── каркас ─────────────────────────────────────── */
#app { min-height: 100dvh; }
.page {
  padding: calc(var(--safe-t) + 18px) 16px calc(var(--tab-h) + var(--safe-b) + 28px);
  max-width: 560px; margin: 0 auto;
  animation: fade .18s ease-out;
}
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 4px 2px 18px; }
.page-head h1 { font-size: 32px; line-height: 1.05; margin: 0; font-weight: 800; letter-spacing: -.02em; }
.page-head .sub { color: var(--muted); font-size: 15px; margin-top: 6px; }
.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 26px 4px 10px; }

/* ── нижние вкладки ─────────────────────────────── */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(13, 14, 18, .88); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
}
.tabbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--faint); font-size: 11px; font-weight: 600; }
.tabbar button svg { width: 26px; height: 26px; }
.tabbar button.on { color: var(--accent); }

/* ── карточки ───────────────────────────────────── */
.card { background: var(--surface); border-radius: var(--radius); padding: 18px; margin-bottom: 12px; position: relative; }
.card.tight { padding: 14px 16px; }
.card h2 { font-size: 20px; margin: 0 0 4px; font-weight: 800; letter-spacing: -.01em; }
.card h3 { font-size: 16px; margin: 0; font-weight: 700; }
.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 10px; }

.hero {
  background: radial-gradient(120% 140% at 100% 0%, rgba(198, 241, 53, .22), transparent 55%), var(--surface);
  border: 1px solid rgba(198, 241, 53, .25);
  padding: 20px;
}
.hero .kicker { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; color: var(--accent);
  background: var(--accent-soft); padding: 5px 10px; border-radius: 99px; }
.hero .kicker.warn { color: var(--ready); background: rgba(255, 176, 32, .12); }
.hero .big { font-size: 30px; font-weight: 800; line-height: 1.1; margin: 12px 0 4px; letter-spacing: -.02em; }
.hero .meta { color: var(--muted); font-size: 15px; }

/* ── кнопки ─────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 50px; padding: 0 20px;
  border-radius: 16px; font-weight: 700; font-size: 16px; background: var(--surface-2); color: var(--text); white-space: nowrap;
  transition: transform .08s ease, background .15s; user-select: none; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:active { background: var(--accent-2); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.block { width: 100%; }
.btn.lg { height: 60px; font-size: 18px; border-radius: 18px; }
.btn.sm { height: 38px; padding: 0 14px; font-size: 14px; border-radius: 12px; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn svg { width: 20px; height: 20px; }
.btn-row { display: flex; gap: 10px; }
.btn-row > * { flex: 1; }

.chip { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 13px; border-radius: 99px;
  background: var(--surface-2); color: var(--text); font-size: 14px; font-weight: 600; white-space: nowrap; }
.chip.on { background: var(--accent); color: var(--accent-ink); }
.chip.off { text-decoration: line-through; color: var(--danger); background: var(--danger-soft); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
.chips.scroll::-webkit-scrollbar { display: none; }
.tag { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 8px;
  background: var(--surface-3); color: var(--muted); }
.tag.accent { background: var(--accent-soft); color: var(--accent); }
.tag.warn { background: rgba(255, 176, 32, .12); color: var(--ready); }
.tag.danger { background: var(--danger-soft); color: var(--danger); }

/* ── сегменты ───────────────────────────────────── */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface); border-radius: 16px; padding: 4px; gap: 4px; margin-bottom: 14px; }
.seg button { height: 42px; border-radius: 12px; font-weight: 700; color: var(--muted); font-size: 15px; position: relative; }
.seg button.on { background: var(--surface-3); color: var(--text); }
.seg .dot { position: absolute; top: 7px; right: 10px; width: 7px; height: 7px; border-radius: 50%; }
.dot.missed { background: var(--danger); }
.dot.done { background: var(--ok); }
.dot.today { background: var(--accent); }

/* ── неделя ─────────────────────────────────────── */
.week { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.week .d { background: var(--surface); border-radius: 16px; padding: 10px 8px; text-align: center; }
.week .d b { display: block; font-size: 15px; }
.week .d span { font-size: 12px; color: var(--muted); }
.week .d.done { box-shadow: inset 0 0 0 1.5px var(--ok); }
.week .d.missed { box-shadow: inset 0 0 0 1.5px var(--danger); }
.week .d.today { box-shadow: inset 0 0 0 1.5px var(--accent); }

/* ── прогресс ───────────────────────────────────── */
.bar { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--accent); transition: width .4s ease; }
.bar.protein > i { background: var(--protein); }
.bar.fat > i { background: var(--fat); }
.bar.carb > i { background: var(--carb); }
.goal { padding: 12px 0; }
.goal + .goal { border-top: 1px solid var(--line); }
.goal .top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.goal .val { font-size: 22px; font-weight: 800; }
.goal .val small { font-size: 14px; color: var(--muted); font-weight: 600; }
.goal .left { font-size: 13px; color: var(--muted); text-align: right; }
.goal .eta { font-size: 13px; color: var(--muted); margin-top: 6px; }

.ring-wrap { display: flex; align-items: center; gap: 18px; }
.ring { position: relative; width: 116px; height: 116px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .c { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring .c b { font-size: 26px; font-weight: 800; line-height: 1; }
.ring .c span { font-size: 12px; color: var(--muted); margin-top: 3px; }
.macros { flex: 1; display: grid; gap: 10px; }
.macro .lbl { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
.macro .lbl b { font-weight: 700; }

/* ── списки ─────────────────────────────────────── */
.list { background: var(--surface); border-radius: var(--radius); overflow: hidden; margin-bottom: 12px; }
.item { display: flex; align-items: center; gap: 14px; padding: 14px 16px; width: 100%; text-align: left; }
.item + .item { border-top: 1px solid var(--line); }
.item .n { width: 30px; height: 30px; border-radius: 10px; background: var(--surface-3); display: flex; align-items: center;
  justify-content: center; font-size: 14px; font-weight: 800; color: var(--muted); flex: none; }
.item .t { font-weight: 700; }
.item .s { font-size: 14px; color: var(--muted); margin-top: 2px; }
.item .chev { color: var(--faint); flex: none; }
.item.btnlike:active { background: var(--surface-2); }

/* ── еда ────────────────────────────────────────── */
.meal .kind { font-size: 13px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .06em; }
.meal.shake .kind { color: var(--protein); }
.meal .name { font-size: 18px; font-weight: 800; margin: 4px 0 10px; }
.meal ul { list-style: none; margin: 0 0 12px; padding: 0; }
.meal li { display: flex; justify-content: space-between; padding: 5px 0; font-size: 15px; border-bottom: 1px dashed var(--line); }
.meal li:last-child { border-bottom: 0; }
.meal li span:last-child { color: var(--muted); white-space: nowrap; padding-left: 10px; }
.kbju { display: flex; gap: 12px; font-size: 13px; color: var(--muted); }
.kbju b { color: var(--text); }
.meal.eaten { opacity: .55; }

/* ── формы ──────────────────────────────────────── */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 14px; font-weight: 700; margin-bottom: 6px; }
.field > small { display: block; font-size: 13px; color: var(--muted); margin: -2px 0 6px; }
.input { width: 100%; height: 52px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface-2);
  padding: 0 14px; font-size: 18px; font-weight: 700; outline: none; }
.input:focus { border-color: var(--accent); }
.input-unit { position: relative; }
.input-unit em { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); font-style: normal; color: var(--muted); font-weight: 600; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.stepper { display: flex; align-items: center; background: var(--surface-2); border-radius: 16px; height: 56px; }
.stepper button { width: 56px; height: 56px; font-size: 26px; font-weight: 700; color: var(--accent); }
.stepper .v { flex: 1; text-align: center; font-size: 24px; font-weight: 800; }
.toggle { width: 52px; height: 32px; border-radius: 99px; background: var(--surface-3); position: relative; flex: none; transition: background .2s; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; transition: transform .2s; }
.toggle.on { background: var(--accent); }
.toggle.on::after { transform: translateX(20px); }
.search { position: relative; margin-bottom: 12px; }
.search input { padding-left: 42px; font-weight: 600; font-size: 16px; }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: var(--muted); }

/* ── нижний лист ────────────────────────────────── */
.sheet-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 40; animation: bgin .2s ease; }
@keyframes bgin { from { opacity: 0; } }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 92dvh; overflow-y: auto;
  background: var(--surface); border-radius: 26px 26px 0 0; padding: 10px 16px calc(var(--safe-b) + 20px);
  animation: up .25s cubic-bezier(.2, .9, .3, 1); max-width: 560px; margin: 0 auto; overscroll-behavior: contain; }
@keyframes up { from { transform: translateY(100%); } }
.sheet .grab { width: 40px; height: 5px; border-radius: 9px; background: var(--surface-3); margin: 0 auto 14px; }
.sheet h2 { font-size: 22px; font-weight: 800; margin: 0 0 4px; }
.sheet .lead { color: var(--muted); margin: 0 0 16px; font-size: 15px; }
.sheet .card, .sheet .list { background: var(--surface-2); }
.sheet .item + .item { border-color: var(--surface-3); }

/* ── тост ───────────────────────────────────────── */
.toast { position: fixed; left: 50%; top: calc(var(--safe-t) + 12px); transform: translateX(-50%);
  z-index: 60; background: var(--text); color: var(--bg); font-weight: 700; padding: 12px 18px; border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .4); animation: up2 .2s ease; max-width: calc(100% - 32px); text-align: center; }
.toast.err { background: var(--danger); color: #fff; }
@keyframes up2 { from { opacity: 0; transform: translate(-50%, -10px); } }

/* ── тренировка ─────────────────────────────────── */
.wk { position: fixed; inset: 0; z-index: 30; background: var(--bg); overflow-y: auto;
  padding: calc(var(--safe-t) + 10px) 16px calc(var(--safe-b) + 20px); }
.wk-top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; max-width: 560px; margin-left: auto; margin-right: auto; }
.wk-top .x { width: 42px; height: 42px; border-radius: 14px; background: var(--surface); display: flex; align-items: center; justify-content: center; }
.wk-prog { flex: 1; display: flex; gap: 4px; }
.wk-prog i { flex: 1; height: 5px; border-radius: 9px; background: var(--surface-3); }
.wk-prog i.done { background: var(--accent); }
.wk-prog i.cur { background: var(--text); }
.wk-body { max-width: 560px; margin: 0 auto; }
.wk .count { font-size: 14px; color: var(--muted); font-weight: 700; }
.wk .exname { font-size: 28px; font-weight: 800; line-height: 1.1; letter-spacing: -.02em; margin: 6px 0 14px; }
.weight-card { background: var(--surface); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.weight-card .w { font-size: 44px; font-weight: 900; line-height: 1; letter-spacing: -.03em; }
.weight-card .w small { font-size: 18px; color: var(--muted); font-weight: 700; letter-spacing: 0; }
.weight-card .change { margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); font-size: 14px; }
.weight-card .change b { color: var(--accent); }
.db-svg { width: 100%; height: 76px; margin-top: 10px; }
.sets { display: flex; gap: 8px; margin: 16px 0; }
.sets .s { flex: 1; height: 54px; border-radius: 14px; background: var(--surface); display: flex; flex-direction: column;
  align-items: center; justify-content: center; font-weight: 800; font-size: 18px; color: var(--faint); }
.sets .s small { font-size: 11px; font-weight: 700; }
.sets .s.done { background: var(--accent-soft); color: var(--accent); }
.sets .s.cur { box-shadow: inset 0 0 0 2px var(--text); color: var(--text); }
.reps-label { text-align: center; color: var(--muted); font-weight: 700; font-size: 14px; margin-bottom: 8px; }
.reps-big { display: flex; align-items: center; justify-content: center; gap: 18px; margin-bottom: 16px; }
.reps-big button { width: 64px; height: 64px; border-radius: 20px; background: var(--surface); font-size: 32px; font-weight: 800; color: var(--accent); }
.reps-big .v { font-size: 64px; font-weight: 900; min-width: 110px; text-align: center; line-height: 1; letter-spacing: -.03em; }
.how { background: var(--surface); border-radius: var(--radius); padding: 14px 16px; margin-top: 12px; font-size: 15px; color: #cfd4dc; }
.how .last { color: var(--muted); font-size: 14px; margin-top: 8px; }
.wk-tools { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.wk-tools .btn { height: 46px; font-size: 14px; padding: 0 8px; }

/* отдых */
.rest { position: fixed; inset: 0; z-index: 35; background: var(--bg); display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: calc(var(--safe-t) + 20px) 24px calc(var(--safe-b) + 24px); transition: background .3s; }
.rest.ready { background: #1f1608; }
.rest.go { background: var(--accent); color: var(--accent-ink); }
.rest .lbl { font-size: 18px; font-weight: 800; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }
.rest.ready .lbl { color: var(--ready); }
.rest.go .lbl { color: var(--accent-ink); }
.rest .clock { position: relative; width: min(78vw, 320px); aspect-ratio: 1; margin: 22px 0; }
.rest .clock svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.rest .clock .t { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 92px; font-weight: 900; letter-spacing: -.04em; }
.rest .next { color: var(--muted); font-size: 16px; text-align: center; margin-bottom: 24px; }
.rest.go .next { color: var(--accent-ink); }
.rest .btn-row { width: 100%; max-width: 420px; }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.04); } }
.rest.ready .clock { animation: pulse 1s ease-in-out infinite; }

/* итог */
.summary .big { font-size: 56px; font-weight: 900; letter-spacing: -.03em; line-height: 1; }
.summary .stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 18px 0; }
.summary .stats div { background: var(--surface); border-radius: 16px; padding: 12px; text-align: center; }
.summary .stats b { display: block; font-size: 22px; }
.summary .stats span { font-size: 12px; color: var(--muted); }

/* ── график ─────────────────────────────────────── */
.chart svg { width: 100%; height: 190px; display: block; }
.chart .axis { fill: var(--faint); font-size: 11px; font-family: var(--font); }

/* ── экран входа ────────────────────────────────── */
.gate { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 32px; }
.gate .logo { width: 96px; height: 96px; border-radius: 28px; margin-bottom: 22px; }
.gate h1 { font-size: 30px; margin: 0 0 10px; font-weight: 800; }
.gate p { color: var(--muted); max-width: 320px; }

.banner { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 16px; background: var(--surface);
  font-size: 14px; color: #cfd4dc; margin-bottom: 12px; }
.banner.accent { background: var(--accent-soft); color: var(--text); }
.banner.warn { background: rgba(255, 176, 32, .1); }
.banner .ic { font-size: 18px; line-height: 1.2; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.skeleton { height: 120px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%);
  background-size: 200% 100%; animation: sk 1.2s infinite; margin-bottom: 12px; }
@keyframes sk { to { background-position: -200% 0; } }
.photo { width: 100%; border-radius: 16px; margin-bottom: 12px; display: block; max-height: 260px; object-fit: cover; }
a.btn { text-decoration: none; }

.shop .box { width: 24px; height: 24px; border-radius: 8px; border: 2px solid var(--line); flex: none; }
.shop.done .box { background: var(--accent); border-color: var(--accent); }
.shop.done .t, .shop.done b { color: var(--faint); text-decoration: line-through; }
.weight-card .w { white-space: nowrap; }
.water { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.water .top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.water .top b { font-size: 18px; }
