/* Форма — тренер по данным WHOOP. Тёмная тема по умолчанию, светлая — если светлая тема Telegram. */
:root {
  --bg: #07080a;
  --surface: #111317;
  --surface-2: #181b21;
  --surface-3: #22262e;
  --line: rgba(255, 255, 255, .06);
  --line-2: rgba(255, 255, 255, .11);
  --text: #f2f4f7;
  --text-2: #b4bac6;
  --muted: #727a89;
  --green: #22e08a;
  --yellow: #ffc93c;
  --red: #ff4d5e;
  --strain: #3d9bff;
  --sleep: #9a8cff;
  --food: #ff9f43;
  --water: #3fa9f5;
  --accent: #22e08a;
  --accent-ink: #04140c;
  --zone: var(--muted);
  --shadow: 0 12px 34px rgba(0, 0, 0, .45);
  --r: 22px;
  --r-sm: 14px;
  --tab-h: 66px;
  --safe-b: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
  --ease: cubic-bezier(.2, .8, .2, 1);
}
body.light {
  --bg: #f2f3f6;
  --surface: #ffffff;
  --surface-2: #f3f4f7;
  --surface-3: #e8eaef;
  --line: rgba(10, 20, 40, .07);
  --line-2: rgba(10, 20, 40, .12);
  --text: #0d1117;
  --text-2: #3f4655;
  --muted: #8a909c;
  --green: #0fbf6e;
  --yellow: #e5a50a;
  --red: #ec3a4c;
  --strain: #1f7fe6;
  --sleep: #6c5ce7;
  --food: #f0801c;
  --water: #1f8fe0;
  --accent: #0fbf6e;
  --accent-ink: #fff;
  --shadow: 0 10px 30px rgba(20, 30, 60, .1);
}
.z-green { --zone: var(--green); }
.z-yellow { --zone: var(--yellow); }
.z-red { --zone: var(--red); }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.42 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  min-height: 100vh;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: var(--text); }
svg { flex: none; }
.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.num { font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.hidden { display: none !important; }

#view { padding: 6px 16px calc(var(--tab-h) + var(--safe-b) + 28px); max-width: 620px; margin: 0 auto; }
.enter > * { animation: rise .45s var(--ease) both; }
.enter > *:nth-child(2) { animation-delay: .04s; }
.enter > *:nth-child(3) { animation-delay: .08s; }
.enter > *:nth-child(4) { animation-delay: .12s; }
.enter > *:nth-child(5) { animation-delay: .16s; }
.enter > *:nth-child(n+6) { animation-delay: .2s; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

.boot { height: 70vh; display: grid; place-items: center; }
.boot-ring { width: 46px; height: 46px; border-radius: 50%; border: 3px solid var(--surface-3); border-top-color: var(--accent); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- шапка ---------- */
.top { display: flex; align-items: center; gap: 12px; padding: 12px 0 10px; }
.top .grow { flex: 1; min-width: 0; }
.eyebrow { font-size: 12px; font-weight: 650; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.title { font-size: 30px; font-weight: 800; letter-spacing: -.025em; line-height: 1.1; margin: 3px 0 0; }
.icon-btn { width: 40px; height: 40px; border-radius: 14px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line); color: var(--text-2); transition: transform .15s; }
.icon-btn:active { transform: scale(.92); }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 750; font-size: 16px; color: var(--accent-ink); background: linear-gradient(140deg, var(--green), #19b8a6); }

/* ---------- карточки ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin-bottom: 12px; position: relative; overflow: hidden; }
.card-h { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.card-h h3 { margin: 0; font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); flex: 1; }
.card-h .more { font-size: 13px; color: var(--text-2); font-weight: 600; }
.tap { transition: transform .15s var(--ease); }
.tap:active { transform: scale(.985); }
.dim { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- главное кольцо ---------- */
.hero { text-align: center; padding: 22px 16px 18px; background:
  radial-gradient(120% 90% at 50% 0%, color-mix(in srgb, var(--zone) 22%, transparent) 0%, transparent 60%), var(--surface); }
.ring-wrap { position: relative; width: 212px; height: 212px; margin: 0 auto; }
.ring-wrap svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { stroke: var(--surface-3); }
.ring-fg { stroke: var(--zone); transition: stroke-dashoffset 1.1s var(--ease); }
.ring-wrap::before { content: ""; position: absolute; inset: 14px; border-radius: 50%; box-shadow: 0 0 46px color-mix(in srgb, var(--zone) 30%, transparent), inset 0 0 30px color-mix(in srgb, var(--zone) 12%, transparent); pointer-events: none; }
.ring-in { position: absolute; inset: 0; display: grid; place-content: center; }
.ring-val { font-size: 64px; font-weight: 800; line-height: 1; letter-spacing: -.04em; }
.ring-val small { font-size: 26px; font-weight: 700; color: var(--text-2); margin-left: 2px; }
.ring-lbl { font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-top: 6px; }
.verdict { display: inline-flex; align-items: center; gap: 8px; margin-top: 14px; padding: 8px 14px; border-radius: 99px; font-weight: 700; font-size: 14px;
  color: var(--zone); background: color-mix(in srgb, var(--zone) 14%, transparent); }
.verdict i { width: 8px; height: 8px; border-radius: 50%; background: var(--zone); box-shadow: 0 0 10px var(--zone); }
.hero-sub { color: var(--text-2); font-size: 14px; margin-top: 10px; }

/* ---------- показатели ---------- */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.metric { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 14px; min-width: 0; }
.metric .k { font-size: 12px; font-weight: 650; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.metric .k b { width: 7px; height: 7px; border-radius: 50%; background: var(--c, var(--muted)); }
.metric .v { font-size: 27px; font-weight: 780; margin-top: 6px; line-height: 1.05; }
.metric .v small { font-size: 14px; font-weight: 650; color: var(--muted); margin-left: 3px; }
.metric .d { font-size: 12.5px; margin-top: 5px; color: var(--muted); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up { color: var(--green); } .down { color: var(--red); }

/* ---------- тренер ---------- */
.coach { background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 12%, var(--surface)) 0%, var(--surface) 55%); }
.coach-badge { width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); }
.coach-badge .ic { width: 17px; height: 17px; stroke-width: 2.4; }
.prose { font-size: 15.5px; line-height: 1.5; color: var(--text); }
.prose b { font-weight: 720; }
.prose p { margin: 0 0 8px; }
.prose ul { margin: 4px 0 8px; padding-left: 0; list-style: none; }
.prose li { position: relative; padding-left: 16px; margin: 5px 0; }
.prose li::before { content: ""; position: absolute; left: 2px; top: .62em; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.row-btns { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 18px; border-radius: 14px; font-weight: 700; font-size: 15px;
  background: var(--accent); color: var(--accent-ink); transition: transform .15s, opacity .2s; }
.btn:active { transform: scale(.96); }
.btn.ghost { background: var(--surface-3); color: var(--text); }
.btn.wide { width: 100%; height: 52px; font-size: 16px; border-radius: 16px; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn .ic { width: 18px; height: 18px; }

.tips { display: grid; gap: 8px; }
.tip { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--text-2); line-height: 1.45; }
.tip i { flex: none; width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; background: var(--c); box-shadow: 0 0 8px var(--c); }

/* ---------- нагрузка ---------- */
.gauge { position: relative; height: 12px; border-radius: 99px; background: var(--surface-3); margin: 14px 0 8px; }
.gauge .band { position: absolute; top: 0; bottom: 0; border-radius: 99px; background: color-mix(in srgb, var(--strain) 32%, transparent); border: 1px dashed color-mix(in srgb, var(--strain) 70%, transparent); }
.gauge .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 99px; background: linear-gradient(90deg, #2a6fd6, var(--strain)); box-shadow: 0 0 12px color-mix(in srgb, var(--strain) 60%, transparent); transition: width 1s var(--ease); }
.gauge-scale { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); font-weight: 600; }
.big-line { display: flex; align-items: baseline; gap: 10px; }
.big-line .v { font-size: 34px; font-weight: 800; line-height: 1; }
.big-line .s { color: var(--muted); font-weight: 600; font-size: 14px; }

/* ---------- сон ---------- */
.stages { display: flex; height: 14px; border-radius: 99px; overflow: hidden; gap: 2px; margin: 12px 0 10px; background: var(--surface-3); }
.stages span { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: 12.5px; color: var(--text-2); font-weight: 600; }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 3px; margin-right: 6px; vertical-align: 1px; }

/* ---------- тренировки ---------- */
.wk { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.wk:first-of-type { border-top: 0; padding-top: 2px; }
.wk-ic { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; font-size: 20px; background: color-mix(in srgb, var(--strain) 16%, transparent); }
.wk .grow { flex: 1; min-width: 0; }
.wk .t { font-weight: 700; }
.wk .s { font-size: 13px; color: var(--muted); }
.wk .val { font-weight: 800; font-size: 20px; color: var(--strain); }
.zones { display: flex; height: 6px; border-radius: 99px; overflow: hidden; margin-top: 6px; gap: 1px; }

/* ---------- графики ---------- */
.seg { display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 3px; margin-bottom: 12px; }
.seg button { flex: 1; height: 36px; border-radius: 11px; font-weight: 700; font-size: 14px; color: var(--muted); transition: background .2s, color .2s; }
.seg button.on { background: var(--surface-3); color: var(--text); }
.chart { width: 100%; height: 132px; display: block; overflow: visible; }
.chart text { font-size: 10px; fill: var(--muted); font-weight: 600; }
.chart .grid { stroke: var(--line-2); stroke-dasharray: 2 4; }
.chart-top { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.chart-top .v { font-size: 26px; font-weight: 800; }
.chart-top .s { color: var(--muted); font-size: 13px; font-weight: 600; }

/* ---------- питание ---------- */
.food-hero { display: flex; align-items: center; gap: 18px; }
.food-ring { position: relative; width: 132px; height: 132px; flex: none; }
.food-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.food-ring .ring-in .v { font-size: 30px; font-weight: 800; line-height: 1; }
.food-ring .ring-in .s { font-size: 12px; color: var(--muted); font-weight: 650; text-align: center; margin-top: 4px; }
.macros { flex: 1; display: grid; gap: 12px; min-width: 0; }
.macro .top-l { display: flex; justify-content: space-between; font-size: 13px; font-weight: 650; color: var(--text-2); }
.macro .top-l b { color: var(--text); }
.bar { height: 7px; border-radius: 99px; background: var(--surface-3); overflow: hidden; margin-top: 6px; }
.bar span { display: block; height: 100%; border-radius: 99px; background: var(--c); transition: width .9s var(--ease); }
.ask { display: flex; gap: 8px; align-items: flex-end; }
.ask textarea { flex: 1; resize: none; min-height: 48px; max-height: 140px; border-radius: 16px; border: 1px solid var(--line-2); background: var(--surface-2); padding: 13px 14px; outline: none; line-height: 1.35; }
.ask textarea:focus { border-color: color-mix(in srgb, var(--accent) 60%, transparent); }
.send { width: 48px; height: 48px; border-radius: 16px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); flex: none; transition: transform .15s; }
.send:active { transform: scale(.9); }
.send[disabled] { opacity: .5; }
.meal { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }
.meal:first-child { border-top: 0; }
.meal .time { font-size: 12px; color: var(--muted); font-weight: 700; width: 40px; flex: none; }
.meal .grow { flex: 1; min-width: 0; }
.meal .t { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meal .s { font-size: 12.5px; color: var(--muted); }
.meal .k { font-weight: 800; }
.meal .del { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; color: var(--muted); }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 10px; }

/* ---------- чат ---------- */
.chat { display: flex; flex-direction: column; gap: 10px; padding-bottom: 8px; }
.msg { max-width: 88%; padding: 11px 14px; border-radius: 18px; font-size: 15px; line-height: 1.45; animation: rise .3s var(--ease) both; word-wrap: break-word; }
.msg.me { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 6px; font-weight: 550; }
.msg.coach { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.dots { display: inline-flex; gap: 5px; padding: 4px 2px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; } .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 9px 14px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line-2); font-size: 14px; font-weight: 600; color: var(--text-2); white-space: nowrap; }
.chip:active { transform: scale(.96); }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.composer { position: sticky; bottom: calc(var(--tab-h) + var(--safe-b) + 10px); padding-top: 8px; background: linear-gradient(transparent, var(--bg) 30%); }
.empty-chat { text-align: center; padding: 28px 10px 10px; color: var(--text-2); }
.empty-chat .big { font-size: 46px; }

/* ---------- подключение ---------- */
.onb { text-align: center; padding: 30px 6px 10px; }
.onb .logo { width: 84px; height: 84px; border-radius: 28px; margin: 0 auto 18px; display: grid; place-items: center; background: linear-gradient(140deg, var(--green), #19b8a6);
  box-shadow: 0 16px 40px color-mix(in srgb, var(--green) 35%, transparent); color: var(--accent-ink); }
.onb .logo .ic { width: 42px; height: 42px; stroke-width: 2.4; }
.onb h1 { font-size: 28px; letter-spacing: -.02em; margin: 0 0 8px; }
.onb p { color: var(--text-2); margin: 0 auto 20px; max-width: 340px; }
.steps { text-align: left; display: grid; gap: 12px; margin: 18px 0; }
.step { display: flex; gap: 12px; align-items: flex-start; font-size: 14.5px; color: var(--text-2); }
.step b.n { flex: none; width: 26px; height: 26px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-3); color: var(--text); font-size: 13px; }
.code { display: block; margin-top: 6px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line-2); font: 12.5px/1.4 ui-monospace, Menlo, monospace; color: var(--text); word-break: break-all; }
.feats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 20px 0 6px; text-align: left; }
.feat { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 14px; font-size: 13.5px; color: var(--text-2); }
.feat .e { font-size: 22px; margin-bottom: 6px; }
.feat b { display: block; color: var(--text); font-size: 14.5px; margin-bottom: 2px; }

/* ---------- нижние вкладки ---------- */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: space-around; padding: 8px 10px calc(8px + var(--safe-b));
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(22px) saturate(1.6); -webkit-backdrop-filter: blur(22px) saturate(1.6); border-top: 1px solid var(--line); }
.tab { flex: 1; max-width: 120px; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px 0; color: var(--muted); font-size: 11px; font-weight: 650; transition: color .2s; }
.tab .ic { width: 24px; height: 24px; transition: transform .25s var(--ease); }
.tab.on { color: var(--text); }
.tab.on .ic { color: var(--accent); transform: translateY(-1px) scale(1.06); }

/* ---------- окно снизу ---------- */
.backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .5); animation: fade .25s both; }
@keyframes fade { from { opacity: 0; } }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 92vh; overflow-y: auto; background: var(--surface); border-radius: 26px 26px 0 0;
  padding: 10px 18px calc(22px + var(--safe-b)); animation: up .35s var(--ease) both; max-width: 620px; margin: 0 auto; box-shadow: var(--shadow); }
@keyframes up { from { transform: translateY(100%); } }
.sheet .grip { width: 38px; height: 5px; border-radius: 99px; background: var(--surface-3); margin: 0 auto 14px; }
.sheet h2 { margin: 0 0 16px; font-size: 22px; letter-spacing: -.01em; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 700; color: var(--muted); margin-bottom: 6px; letter-spacing: .02em; }
.field input, .field textarea { width: 100%; border-radius: 14px; border: 1px solid var(--line-2); background: var(--surface-2); padding: 12px 14px; outline: none; }
.field textarea { resize: vertical; min-height: 70px; }
.field input:focus, .field textarea:focus { border-color: color-mix(in srgb, var(--accent) 60%, transparent); }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.row2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.status-line { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px; background: var(--surface-2); margin-bottom: 14px; font-size: 14px; }
.status-line i { width: 9px; height: 9px; border-radius: 50%; background: var(--c); box-shadow: 0 0 8px var(--c); }
.status-line .grow { flex: 1; }

.toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + var(--safe-b) + 18px); transform: translate(-50%, 20px); opacity: 0; z-index: 60; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 11px 16px; border-radius: 14px; font-weight: 650; font-size: 14px; transition: all .3s var(--ease); max-width: 90vw; text-align: center; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 8px; height: 14px; margin: 8px 0; }
@keyframes shimmer { to { background-position: -200% 0; } }
.day-nav { display: flex; align-items: center; gap: 6px; }
