:root {
  --bg: #F6F5F3;
  --card: #FFFFFF;
  --text: #1A1A1A;
  --muted: #6B6B6B;
  --line: #ECEAE6;
  --soft: #F0EEEA;
  --ph: #ECEAE6;
  --accent: #FF6F59;
  --accent-soft: #FFF1EE;
  --accent-ink: #5A4A47;
  --good: #1F9D63;
  --good-text: #17804F;
  --warn: #F59E0B;
  --warn-text: #9A5200;
  --bad: #E5484D;
  --bad-text: #C42B30;
  --btn: #1A1A1A;
  --btn-text: #FFFFFF;
}
[data-theme="dark"] {
  --bg: #111111;
  --card: #1C1C1E;
  --text: #F2F2F2;
  --muted: #A1A1A6;
  --line: #2C2C2E;
  --soft: #2C2C2E;
  --ph: #2C2C2E;
  --accent-soft: #3A2420;
  --accent-ink: #F3C9C0;
  --good-text: #4CC38A;
  --warn-text: #F5B54A;
  --bad-text: #FF7A7E;
  --btn: #F2F2F2;
  --btn-text: #111111;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: Manrope, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

.page { max-width: 480px; margin: 0 auto; padding: 20px 16px 32px; display: flex; flex-direction: column; gap: 14px; }
.page.has-tabs { padding-bottom: 100px; }
.loading { padding: 48px 16px; text-align: center; color: var(--muted); font-weight: 600; }

h1 { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -0.4px; }
h2 { margin: 0; font-size: 15px; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 12px; font-weight: 600; }
.caption { font-size: 13px; font-weight: 500; color: var(--muted); }

.card { background: var(--card); border-radius: 20px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 12px; }
.between { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.big { font-size: 24px; font-weight: 800; }
.big span { font-size: 15px; color: var(--muted); font-weight: 600; }

.bar { height: 8px; border-radius: 4px; background: var(--soft); overflow: hidden; }
.bar > div { height: 100%; border-radius: 4px; background: var(--accent); }

.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat { background: var(--card); border-radius: 14px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.stat .label { font-size: 11px; color: var(--muted); font-weight: 600; }
.stat .value { font-size: 17px; font-weight: 800; }
.stat.accent { background: var(--accent-soft); }
.stat.accent .label { color: var(--accent-ink); }

.list { display: flex; flex-direction: column; gap: 8px; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--card); border-radius: 16px; }
.item .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.item .title { font-weight: 700; font-size: 15px; }
.avatar { position: relative; overflow: hidden; width: 44px; height: 44px; border-radius: 22px; background: var(--accent-soft); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; flex-shrink: 0; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

.status { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 4px; }
.status.good { color: var(--good-text); } .status.good::before { background: var(--good); }
.status.part { color: var(--warn-text); } .status.part::before { background: var(--warn); }
.status.none { color: var(--bad-text); } .status.none::before { background: var(--bad); }

.btn { height: 50px; border-radius: 25px; border: none; background: var(--btn); color: var(--btn-text); display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 700; padding: 0 20px; }
.btn.light { background: var(--card); color: var(--text); }
.link-card { background: var(--card); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 4px; }

.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; text-align: center; }
.week a { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 6px 0; border-radius: 12px; }
.week a.today { background: var(--btn); color: var(--btn-text); }
.week .wd { font-size: 11px; font-weight: 600; opacity: 0.7; }
.week .num { font-size: 15px; font-weight: 800; }
.week .dot { width: 6px; height: 6px; border-radius: 3px; background: transparent; }
.dot.good { background: var(--good) !important; }
.dot.part { background: var(--warn) !important; }

.daynav { display: flex; align-items: center; justify-content: space-between; }
.round { width: 44px; height: 44px; border-radius: 22px; background: var(--card); display: flex; align-items: center; justify-content: center; }
.round.disabled { opacity: 0.3; pointer-events: none; }

.meals { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.meal { background: var(--card); border-radius: 18px; overflow: hidden; display: flex; flex-direction: column; }
.meal img, .meal .empty { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; display: block; background: var(--ph); }
.meal .empty { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 12px; font-weight: 600; border: 1.5px dashed var(--line); background: transparent; border-radius: 18px 18px 0 0; }
.meal .info { padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.meal .info b { font-size: 14px; }
.meal .info span { font-size: 12px; color: var(--muted); }

.photos { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.photo { position: relative; border-radius: 12px; overflow: hidden; aspect-ratio: 3 / 4; background: var(--ph); }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo span { position: absolute; left: 6px; bottom: 6px; background: rgba(0,0,0,0.55); color: #fff; font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 6px; }
.ba { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.ba .photo { aspect-ratio: 3 / 4; }

.check { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--card); border-radius: 16px; }
.check .body { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.check .title { font-size: 14px; font-weight: 700; }
.tick { width: 26px; height: 26px; border-radius: 13px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.tick.on { background: var(--good); }
.tick.off { border: 1.5px dashed var(--muted); opacity: 0.6; }
.check.todo { border: 1px dashed var(--line); }

.pill { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 17px; background: var(--card); font-size: 13px; font-weight: 800; }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; height: 72px; padding-bottom: env(safe-area-inset-bottom); background: var(--card); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: center; }
.tabs a { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; color: var(--muted); }
.tabs a.active { color: var(--text); font-weight: 700; }

#lightbox { position: fixed; inset: 0; background: rgba(0,0,0,0.9); display: flex; align-items: center; justify-content: center; z-index: 10; }
#lightbox[hidden] { display: none; }
#lightbox img { max-width: 100%; max-height: 100%; }
img[data-zoom] { cursor: zoom-in; }

.comment { font-size: 12px; line-height: 1.35; background: var(--accent-soft); color: var(--text); border-radius: 10px; padding: 6px 8px; margin-top: 6px; word-break: break-word; }
.cform { display: flex; gap: 6px; margin-top: 8px; }
.cform input { flex: 1; min-width: 0; height: 36px; border-radius: 18px; border: 1px solid var(--line); background: var(--bg); color: var(--text); padding: 0 12px; font: inherit; font-size: 13px; }
.cform button { width: 36px; height: 36px; border-radius: 18px; border: none; background: var(--btn); color: var(--btn-text); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.cform :disabled { opacity: 0.5; }

/* Поля ввода */
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.input, select { width: 100%; min-width: 0; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--text); padding: 0 12px; font: inherit; font-size: 15px; }
.input.strong { font-weight: 700; font-size: 16px; background: var(--card); }
.input::placeholder { color: var(--muted); opacity: 0.8; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; border: none; background: var(--bg); color: var(--muted); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ex-edit { display: flex; flex-direction: column; gap: 8px; padding: 12px 0; border-top: 1px solid var(--line); }
.btn { width: 100%; cursor: pointer; }
.btn:disabled { opacity: 0.5; }
.btn.danger { color: var(--bad-text); }
.btn.accent { background: var(--accent); color: #1A1A1A; }
button.pill { border: none; color: var(--text); font-family: inherit; cursor: pointer; background: var(--bg); }

.card.dark { background: var(--btn); color: var(--btn-text); }

/* Тренировка */
.segments { display: grid; gap: 4px; }
.seg { height: 6px; border-radius: 3px; background: var(--line); }
.seg.half { background: var(--accent); opacity: 0.5; }
.seg.full { background: var(--accent); }
.set-head, .set-row { display: grid; grid-template-columns: 32px minmax(0, 1fr) minmax(0, 1fr) 40px; gap: 8px; align-items: center; }
.set-no { font-size: 14px; font-weight: 700; color: var(--muted); }
.set-btn { width: 40px; height: 40px; border-radius: 20px; border: 1.5px solid var(--line); background: transparent; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.set-btn svg { opacity: 0; }
.set-row.done .input { background: var(--accent-soft); border-color: transparent; font-weight: 800; }
.set-row.done .set-btn { background: var(--good); border-color: var(--good); }
.set-row.done .set-btn svg { opacity: 1; }
.badge { background: var(--accent); color: #1A1A1A; border-radius: 10px; padding: 4px 10px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.badge[hidden] { display: none; }

.no-anim .page > *, .no-anim .bar > div, .no-anim polyline.draw, .no-anim .tick.on, .no-anim .set-btn, .no-anim .badge { animation: none !important; }

/* Рецепты */
.filters { display: flex; flex-direction: column; gap: 8px; }
.chip-row { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }
.fchip { flex-shrink: 0; height: 36px; padding: 0 14px; border-radius: 18px; border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.fchip.on { background: var(--btn); color: var(--btn-text); border-color: var(--btn); }
.recipe-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.recipe-card { background: var(--card); border-radius: 18px; overflow: hidden; display: flex; flex-direction: column; transition: transform 0.12s ease; }
.recipe-card:active { transform: scale(0.97); }
.card .recipe-card { background: var(--bg); }
.rc-cover { position: relative; aspect-ratio: 4 / 3; }
.rc-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rc-emoji { width: 100%; height: 100%; display: grid; place-items: center; font-size: 52px; }
.rc-emoji.big { font-size: 96px; }
.rc-tag { position: absolute; left: 8px; top: 8px; background: var(--accent); color: #1A1A1A; font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 999px; }
.rc-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 3px; }
.rc-title { font-size: 14px; font-weight: 700; line-height: 1.3; }
.rc-meta { font-size: 12px; font-weight: 600; color: var(--text); }
.rc-macros { font-size: 11px; color: var(--muted); font-weight: 600; }
.recipe-hero { border-radius: 24px; overflow: hidden; aspect-ratio: 16 / 10; }
.gtags { display: flex; gap: 6px; flex-wrap: wrap; }
.gtag { font-size: 12px; font-weight: 700; background: var(--accent-soft); color: var(--accent-ink); padding: 4px 10px; border-radius: 999px; }
.macro-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.macro-row .value { font-size: 16px; }
.ingr { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.ingr li { display: flex; gap: 10px; font-size: 14px; line-height: 1.4; }
.ingr li::before { content: ""; flex-shrink: 0; width: 6px; height: 6px; margin-top: 7px; border-radius: 3px; background: var(--accent); }
.steps-list { margin: 0; padding: 0; list-style: none; counter-reset: st; display: flex; flex-direction: column; gap: 12px; }
.steps-list li { counter-increment: st; display: flex; gap: 12px; font-size: 14px; line-height: 1.45; }
.steps-list li::before { content: counter(st); flex-shrink: 0; width: 26px; height: 26px; border-radius: 13px; background: var(--btn); color: var(--btn-text); font-size: 13px; font-weight: 800; display: grid; place-items: center; }

/* Изменения во время тренировки */
.ex-tools { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.chip { height: 34px; padding: 0 12px; border-radius: 17px; border: 1px solid var(--line); background: transparent; color: var(--text); font: inherit; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.chip:disabled { opacity: 0.35; }
.chip.danger { color: var(--bad-text); }

/* До / после */
.ba-wrap { display: flex; flex-direction: column; gap: 12px; }
.ba-row { display: flex; flex-direction: column; gap: 6px; }
.ph-empty { display: flex; align-items: center; justify-content: center; background: transparent; border: 1.5px dashed var(--line); }
.ph-empty span { position: static; background: none; color: var(--muted); }

/* Анкета и архив */
textarea.input { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.4; }
.archive summary { cursor: pointer; font-size: 14px; font-weight: 700; color: var(--muted); padding: 8px 4px; list-style: none; }
.archive summary::before { content: "▸ "; }
.archive[open] summary::before { content: "▾ "; }
.archive .list { margin-top: 6px; }

/* Видео */
.video { display: flex; flex-direction: column; gap: 6px; padding-top: 10px; border-top: 1px solid var(--line); }
.video video { width: 100%; max-height: 420px; border-radius: 14px; background: #000; display: block; }
.video.note video { width: 220px; height: 220px; border-radius: 50%; object-fit: cover; align-self: center; }
.star { border: none; background: transparent; font-size: 22px; line-height: 1; color: var(--muted); cursor: pointer; padding: 4px; min-width: 36px; min-height: 36px; }
.star.on { color: #F5B83D; }

/* Пустые экраны */
.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 18px 8px; }
.empty-ico { width: 64px; height: 64px; border-radius: 32px; background: var(--accent-soft); color: var(--accent-ink); display: flex; align-items: center; justify-content: center; margin-bottom: 4px; }
.empty-title { font-size: 15px; font-weight: 700; }
.empty-text { font-size: 13px; color: var(--muted); line-height: 1.45; max-width: 300px; }

/* Окна: приветствие и поздравления */
.overlay { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, 0); display: flex; align-items: flex-end; justify-content: center; padding: 16px; transition: background 0.25s; }
.overlay.show { background: rgba(0, 0, 0, 0.45); }
.overlay-card { position: relative; overflow: hidden; width: 100%; max-width: 440px; background: var(--card); border-radius: 28px; padding: 24px 20px 20px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; transform: translateY(110%); transition: transform 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2); margin-bottom: env(safe-area-inset-bottom); }
.overlay.show .overlay-card { transform: none; }
.steps { display: flex; flex-direction: column; gap: 10px; width: 100%; text-align: left; margin: 4px 0; }
.step { display: flex; gap: 12px; align-items: flex-start; background: var(--bg); border-radius: 16px; padding: 12px; }
.step b { font-size: 14px; }
.step-ico { width: 36px; height: 36px; border-radius: 18px; background: var(--card); display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.confetti { position: absolute; inset: 0; pointer-events: none; }
.confetti i { position: absolute; top: -12px; width: 8px; height: 12px; border-radius: 2px; opacity: 0; animation: fall 1.6s ease-in forwards; }
@keyframes fall {
  0% { opacity: 1; transform: translateY(0) rotate(0); }
  100% { opacity: 0; transform: translateY(320px) rotate(540deg); }
}

/* Анимации */
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes grow { from { transform: scaleX(0); } }
@keyframes ringIn { from { stroke-dasharray: 0 var(--c); } }
@keyframes draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes pop { 0% { transform: scale(0.6); } 70% { transform: scale(1.12); } 100% { transform: scale(1); } }
.page > * { animation: fadeUp 0.35s ease both; }
.page > *:nth-child(2) { animation-delay: 0.03s; }
.page > *:nth-child(3) { animation-delay: 0.06s; }
.page > *:nth-child(4) { animation-delay: 0.09s; }
.page > *:nth-child(5) { animation-delay: 0.12s; }
.page > *:nth-child(n + 6) { animation-delay: 0.15s; }
.bar > div { transform-origin: left; animation: grow 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both 0.15s; }
.ring { animation: ringIn 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) both 0.15s; }
polyline.draw { stroke-dasharray: 1; animation: draw 1s ease-out both 0.2s; }
.tick.on, .set-row.done .set-btn, .badge:not([hidden]) { animation: pop 0.3s ease both; }

/* Отклик на нажатие и фокус */
.item, .btn, .pill, .link-card, .round, .week a, .set-btn, .icon-btn { transition: transform 0.12s ease, opacity 0.12s; }
.item:active, .btn:active, .pill:active, .link-card:active, .round:active, .week a:active, .set-btn:active, .icon-btn:active { transform: scale(0.97); }
a:focus-visible, button:focus-visible, .input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.input:focus { border-color: var(--accent); outline: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

.empty-note { text-align: center; color: var(--muted); font-size: 13px; font-weight: 600; padding: 16px 8px; }
