/* --nb: место внизу под значок «Powered by Netlify» (на бесплатном тарифе его нельзя скрыть). На сайте 64px, на компьютере 0. */
html { --nb: 0px; }
html.nf { --nb: 64px; }
:root {
  --accent: #ff5a36; --accent-2: #ff8a3d; --on-accent: #fff;
  --bg: #f4f5f7; --card: #ffffff; --text: #16181d; --muted: #6b7280; --line: #e5e7eb; --soft: #f1f2f4;
  --p: #3b82f6; --f: #f59e0b; --c: #10b981; --ok: #16a34a; --danger: #dc2626;
  --r: 18px; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0e0f12; --card: #181a1f; --text: #f3f4f6; --muted: #9ca3af; --line: #2a2d34; --soft: #22252b; --shadow: none; color-scheme: dark; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
button, input { font: inherit; color: inherit; }
h1 { font-size: 26px; margin: 0; letter-spacing: -.02em; }
h2 { font-size: 20px; margin: 0 0 12px; }
h3, .h3 { font-size: 16px; margin: 0; font-weight: 650; }
p { margin: 8px 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; justify-content: center; }
.pad { padding: 8px 12px; }
.warn { color: #b45309; }
@media (prefers-color-scheme: dark) { .warn { color: #fbbf24; } }

.view { max-width: 520px; margin: 0 auto; padding: calc(12px + env(safe-area-inset-top)) 16px calc(24px + var(--nb)); }
.view.has-tabs { padding-bottom: calc(96px + env(safe-area-inset-bottom) + var(--nb)); }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 0 16px; }
.top > div { flex: 1; }
.top .icon-btn + h1, .top .icon-btn + div { flex: 1; }

.card { display: block; width: 100%; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin: 0 0 12px; box-shadow: var(--shadow); }
button.card { cursor: pointer; }
.ch { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; }
.row.wrap { flex-wrap: wrap; }
.row.wrap > * { flex: 1 1 140px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.grid2 .card { margin: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 10px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--soft); font-weight: 600; cursor: pointer; text-decoration: none; transition: transform .08s; }
.btn:active { transform: scale(.98); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--on-accent); border-color: transparent; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.danger { color: var(--danger); }
.btn.big { min-height: 54px; font-size: 17px; border-radius: 14px; }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.btn.block { display: flex; width: 100%; margin-top: 8px; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-size: 22px; line-height: 1; cursor: pointer; flex: none !important; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn.sm { width: 30px; height: 30px; font-size: 13px; color: var(--muted); }
.icon-btn:disabled { opacity: .35; }
.link, .link-plain { background: none; border: 0; padding: 0; cursor: pointer; text-align: left; }
.link { color: var(--accent); font-weight: 600; text-decoration: underline; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--soft); color: var(--muted); vertical-align: middle; }
.badge.ok { background: rgba(22,163,74,.12); color: var(--ok); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px 12px; padding: 0 16px; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 8px 14px; border-radius: 99px; border: 1px solid var(--line); background: var(--card); cursor: pointer; font-size: 14px; font-weight: 600; }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }

/* Формы */
.form label, .sheet label { display: block; font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 12px; }
input[type=number], input[type=search], input:not([type]), input[type=text], input[type=email], input[type=password] { width: 100%; margin-top: 4px; min-height: 44px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--soft); color: var(--text); font-size: 16px; outline: none; }
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,90,54,.18); }
.lbl { font-size: 13px; color: var(--muted); font-weight: 600; margin: 4px 0 6px; }
.seg { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.seg label { flex: 1 1 0; margin: 0 !important; min-width: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: flex; align-items: center; justify-content: center; text-align: center; min-height: 44px; padding: 8px 6px; border-radius: 12px; border: 1px solid var(--line); background: var(--soft); color: var(--text); font-size: 14px; font-weight: 600; cursor: pointer; line-height: 1.2; }
.seg input:checked + span { background: var(--accent); color: #fff; border-color: var(--accent); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.seg.sm span { min-height: 36px; font-size: 13px; }

/* Онбординг */
.onb .brand { text-align: center; padding: 24px 0 16px; }
.logo { width: 72px; height: 72px; margin: 0 auto 12px; }
.logo.sm { width: 56px; height: 56px; }
.logo svg { width: 100%; height: 100%; display: block; }
.onb .brand h1 { font-size: 32px; }

/* Главная */
.streak { background: rgba(255,90,54,.12); color: var(--accent); font-weight: 800; padding: 6px 12px; border-radius: 99px; flex: none !important; }
.kc-top { display: flex; gap: 16px; align-items: center; margin-bottom: 8px; }
.ring { position: relative; width: 128px; height: 128px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 11; }
.rbg { stroke: var(--soft); }
.rfg { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .5s; }
.rfg.over { stroke: var(--danger); }
.rc { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.rc b { font-size: 26px; line-height: 1; }
.rc span { font-size: 11px; color: var(--muted); max-width: 80px; }
.macros { flex: 1; min-width: 0; }
.mb { margin-bottom: 10px; }
.mbh { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 4px; gap: 4px; }
.mbh span:first-child { color: var(--text); font-weight: 600; }
.track { height: 8px; background: var(--soft); border-radius: 99px; overflow: hidden; }
.track i { display: block; height: 100%; border-radius: 99px; transition: width .4s; }
.track .p { background: var(--p); } .track .f { background: var(--f); } .track .c { background: var(--c); }
.big-t { font-size: 20px; font-weight: 700; margin: 4px 0; }
.glasses { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 12px; }
.glass { width: 22px; height: 28px; border-radius: 4px 4px 8px 8px; border: 2px solid #7dd3fc; background: transparent; }
.glass.on { background: #38bdf8; border-color: #38bdf8; }
.ai { display: flex; gap: 12px; align-items: center; background: linear-gradient(135deg, rgba(255,90,54,.10), rgba(59,130,246,.10)); }
.ai-i { font-size: 32px; }
.install { font-weight: 700; color: var(--accent); }
.tip p { margin-bottom: 0; }

/* Тренировки */
.exl { list-style: none; padding: 0; margin: 4px 0 4px; }
.exl li button { width: 100%; display: flex; justify-content: space-between; gap: 8px; padding: 10px 0; border: 0; border-bottom: 1px solid var(--line); background: none; cursor: pointer; text-align: left; }
.exl li:last-child button { border-bottom: 0; }
.li { display: flex; justify-content: space-between; align-items: center; }
.pbar { height: 8px; background: var(--soft); border-radius: 99px; overflow: hidden; }
.pbar i { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.sets { display: grid; gap: 6px; }
.sh, .sr { display: grid; grid-template-columns: 24px 1fr 1fr 48px; gap: 8px; align-items: center; }
.sh { font-size: 12px; color: var(--muted); font-weight: 600; }
.sr input { margin: 0; min-height: 42px; text-align: center; }
.sr span { color: var(--muted); font-weight: 700; text-align: center; }
.chk { height: 42px; border-radius: 12px; border: 1px solid var(--line); background: var(--soft); color: var(--muted); font-size: 18px; font-weight: 800; cursor: pointer; }
.sr.done .chk { background: var(--ok); color: #fff; border-color: var(--ok); }
.sr.done input { background: rgba(22,163,74,.08); }

/* Таймер */
.timer { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(84px + env(safe-area-inset-bottom) + var(--nb)); width: min(488px, calc(100% - 32px)); z-index: 30; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 16px; background: var(--text); color: var(--bg); overflow: hidden; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.timer i { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--accent); width: 100%; transition: width .25s linear; }
.timer span { flex: 1; font-weight: 600; }
.timer b { font-size: 22px; font-variant-numeric: tabular-nums; }
.timer button { border: 0; border-radius: 10px; padding: 8px 10px; background: rgba(127,127,127,.25); color: inherit; font-weight: 700; cursor: pointer; }

/* Питание */
.datenav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sum4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; }
.sum4 b { display: block; font-size: 20px; }
.sum4 span { font-size: 12px; color: var(--muted); }
.sum4 small { display: block; font-size: 11px; color: var(--muted); }
.s-k b { color: var(--accent); } .s-p b { color: var(--p); } .s-f b { color: var(--f); } .s-c b { color: var(--c); }
.fi { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.fi:last-of-type { border-bottom: 0; }
.fr { display: flex; align-items: center; gap: 8px; }

/* Прогресс */
.wnow { font-size: 15px; margin-bottom: 8px; }
.wnow b { font-size: 34px; letter-spacing: -.02em; }
.delta { margin-left: 8px; font-weight: 700; color: var(--muted); }
.delta.down { color: var(--ok); } .delta.up { color: var(--accent); }
.chart { width: 100%; height: auto; display: block; margin: 4px 0 12px; }
.chart .ln { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .ar { fill: var(--accent); opacity: .1; }
.chart .dt { fill: var(--card); stroke: var(--accent); stroke-width: 2; }
.chart .gl { stroke: var(--line); stroke-dasharray: 3 4; }
.chart .ax { fill: var(--muted); font-size: 10px; text-anchor: end; }
.stat small { display: block; color: var(--muted); font-size: 12px; font-weight: 600; }
.stat b { display: block; font-size: 24px; margin: 2px 0; }
.bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; height: 160px; }
.bc { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.bw { position: relative; flex: 1; width: 100%; background: var(--soft); border-radius: 8px; overflow: hidden; }
.bw i { position: absolute; left: 0; right: 0; bottom: 0; background: var(--c); border-radius: 8px 8px 0 0; }
.bw i.over { background: var(--accent); }
.bw i span { position: absolute; top: -16px; left: 0; right: 0; text-align: center; font-size: 9px; color: var(--muted); font-style: normal; }
.bw em { position: absolute; left: 0; right: 0; border-top: 2px dashed var(--muted); z-index: 1; opacity: .6; }
.bc small { font-size: 11px; color: var(--muted); }
.locked-wrap { position: relative; }
.locked-wrap .blur { filter: blur(6px); pointer-events: none; user-select: none; }
.locked-wrap > .btn { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); white-space: nowrap; }

/* Профиль и Premium */
.norms { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0; }
.norms div { background: var(--soft); border-radius: 12px; padding: 10px 6px; text-align: center; }
.norms b { display: block; font-size: 18px; }
.norms small { font-size: 11px; color: var(--muted); }
.prem { text-align: center; }
.feats { list-style: none; padding: 0; margin: 0; text-align: left; display: grid; gap: 8px; }
.feats li { padding: 8px 12px; background: var(--soft); border-radius: 12px; font-weight: 500; }
.plans { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.plan { text-align: center; position: relative; display: flex; flex-direction: column; gap: 2px; align-items: center; justify-content: center; }
.plan b { font-size: 22px; }
.plan.best { border: 2px solid var(--accent); }
.plan .badge { position: absolute; top: -10px; }

/* Нижняя панель */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: center; background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom) + var(--nb)); }
.tabs button { flex: 1; max-width: 104px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; border: 0; background: none; color: var(--muted); font-size: 11px; font-weight: 600; cursor: pointer; }
.tabs button.on { color: var(--accent); }
.ic { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Нижний лист */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 40; animation: fade .2s; }
.sheet { position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); width: min(520px, 100%); max-height: 88vh; overflow-y: auto; z-index: 41; background: var(--card); border-radius: 22px 22px 0 0; padding: 8px 16px calc(20px + env(safe-area-inset-bottom) + var(--nb)); animation: up .25s ease-out; }
.sheet.tall { height: 88vh; display: flex; flex-direction: column; }
.grab { width: 40px; height: 5px; border-radius: 99px; background: var(--line); margin: 4px auto 14px; }
.flist { flex: 1; overflow-y: auto; margin: 8px -4px; min-height: 120px; }
.fli { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 4px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; cursor: pointer; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; margin: -4px 0 8px; }
.prev { background: var(--soft); border-radius: 12px; padding: 12px; }
.huge { font-size: 64px; }
@keyframes up { from { transform: translate(-50%, 100%); } }
@keyframes fade { from { opacity: 0; } }

.toast { position: fixed; top: calc(16px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 99px; font-weight: 600; z-index: 60; animation: fade .2s; box-shadow: 0 8px 24px rgba(0,0,0,.2); max-width: calc(100% - 32px); text-align: center; }

@media (max-width: 360px) { .kc-top { flex-direction: column; } .macros { width: 100%; } .row3 { grid-template-columns: 1fr 1fr; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Пробный период и подписка */
.status { text-align: center; font-weight: 600; margin: 0 0 12px; }
.expired { border: 2px solid var(--accent); text-align: center; }
.trial-b { color: var(--accent); font-weight: 600; background: rgba(255,90,54,.08); }
button.plan { cursor: pointer; font: inherit; color: inherit; }
.plan.sel { border: 2px solid var(--accent); box-shadow: 0 0 0 3px rgba(255,90,54,.15); }
.plan.best { border: 1px solid var(--line); }
.plan.best.sel { border: 2px solid var(--accent); }
.paym { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 4px; }
.paym .chip { min-height: 48px; border-radius: 12px; }
.paym .chip.on { background: var(--card); color: var(--text); border: 2px solid var(--accent); }
.blik { font-weight: 900; letter-spacing: .04em; background: #000; color: #fff; padding: 3px 8px; border-radius: 6px; }
@media (prefers-color-scheme: dark) { .blik { background: #fff; color: #000; } }

/* ИИ-тренер */
.ai > span:nth-child(2) { flex: 1; }
.chat { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.msg { max-width: 88%; padding: 10px 14px; border-radius: 18px; line-height: 1.45; word-wrap: break-word; overflow-wrap: anywhere; }
.msg.bot { align-self: flex-start; background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg.me { align-self: flex-end; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--on-accent); border-bottom-right-radius: 6px; white-space: pre-wrap; }
.msg .li-dot { display: inline-block; padding-left: 4px; }
.msg.typing { color: var(--muted); font-style: italic; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .5; } }
.qchips { margin-top: 4px; }
.qchips .chip { white-space: normal; text-align: left; font-weight: 500; flex: 1 1 100%; border-radius: 14px; }
.composer { position: sticky; bottom: calc(76px + env(safe-area-inset-bottom) + var(--nb)); display: flex; gap: 8px; align-items: flex-end; background: var(--bg); padding: 8px 0; z-index: 5; }
.composer textarea { flex: 1; min-height: 46px; max-height: 140px; resize: none; padding: 12px 14px; border-radius: 16px; border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit; font-size: 16px; outline: none; }
.composer textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,90,54,.18); }
.composer .btn { flex: none; width: 48px; min-height: 46px; padding: 0; border-radius: 16px; font-size: 18px; }
.composer .btn:disabled { opacity: .5; }
.limit { border: 2px solid var(--accent); }

/* Дневник, реабилитация, спортпит, диеты */
.tabs3 span { min-height: 40px; font-size: 13px; }
.warnc { background: rgba(245,158,11,.10); border-color: rgba(245,158,11,.35); font-size: 14px; }
.moods { display: flex; gap: 6px; margin-bottom: 12px; }
.mood { flex: 1; min-height: 46px; font-size: 24px; border-radius: 12px; border: 1px solid var(--line); background: var(--soft); cursor: pointer; filter: grayscale(.6); }
.mood.on { border: 2px solid var(--accent); background: rgba(255,90,54,.10); filter: none; }
.form textarea { width: 100%; margin-top: 4px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--soft); color: var(--text); font: inherit; font-size: 16px; resize: vertical; outline: none; }
.form textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,90,54,.18); }
.mt { margin-top: 16px; }
.sheet h3 { margin-bottom: 8px; }
.rehab-c { background: linear-gradient(135deg, rgba(16,185,129,.10), rgba(59,130,246,.08)); }
.li > span:first-child { flex: 1; }
.tabs button { max-width: 92px; font-size: 10.5px; }
@media (max-width: 360px) { .tabs button span { font-size: 9.5px; } }

/* Вход и регистрация */
.err { color: var(--danger); font-size: 14px; margin: 0 0 12px; }
.form label small.muted { display: block; margin-top: 4px; font-weight: 400; }
