:root {
  --bg: #0d0f14;
  --card: #161a22;
  --card2: #1d222c;
  --line: #262c38;
  --text: #eef1f6;
  --muted: #8a93a6;
  --accent: #7cf29c;
  --cal: #ffb44d;
  --pro: #ff6b8a;
  --water: #4db8ff;
  --steps: #b48cff;
  --danger: #ff5d5d;
  --r: 18px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif; }
body { min-height: 100dvh; overscroll-behavior-y: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.err { color: var(--danger); min-height: 1.2em; font-size: 14px; }
h1 { font-size: 30px; margin: 0; letter-spacing: -0.02em; }
h2 { font-size: 17px; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }

/* login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 360px; text-align: center; }
.login-card form { display: grid; gap: 12px; margin-top: 20px; }
.logo-dot { width: 64px; height: 64px; border-radius: 20px; margin: 0 auto 16px; background: linear-gradient(135deg, var(--accent), var(--water)); }

/* layout */
.top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: flex-end; padding: calc(var(--safe-t) + 14px) 18px 12px; background: linear-gradient(var(--bg) 70%, transparent); }
.eyebrow { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
main { padding: 0 14px calc(var(--safe-b) + 96px); }
.screen { display: grid; gap: 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; position: relative; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid2.tight { gap: 8px; }
.row-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.row-head h2 { margin: 0; }

/* hero */
.hero { display: grid; grid-template-columns: 132px 1fr; gap: 16px; align-items: center; }
.ring-wrap { position: relative; width: 132px; height: 132px; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--card2); stroke-width: 11; }
.ring-fg { fill: none; stroke: var(--cal); stroke-width: 11; stroke-linecap: round; stroke-dasharray: 326.7; stroke-dashoffset: 326.7; transition: stroke-dashoffset .6s ease, stroke .3s; }
.ring-fg.over { stroke: var(--danger); }
.ring-text { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.big { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.hero-stats { display: grid; gap: 12px; }
.label { font-size: 13px; color: var(--muted); }
.val { font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; }
.unit { font-size: 13px; color: var(--muted); font-weight: 500; }
.bar { height: 7px; background: var(--card2); border-radius: 99px; overflow: hidden; margin-top: 5px; }
.bar i { display: block; height: 100%; width: 0; border-radius: 99px; transition: width .6s ease; }
.c-pro { background: var(--pro); } .c-water { background: var(--water); } .c-steps { background: var(--steps); }
.chips { display: flex; gap: 6px; }
.chip { flex: 1; background: var(--card2); color: var(--water); border: 1px solid var(--line); border-radius: 99px; padding: 7px 0; font: inherit; font-size: 14px; font-weight: 600; }
.chip:active { transform: scale(.96); }
.tile { min-height: 112px; display: grid; align-content: start; gap: 4px; }
.tile-hit { position: absolute; inset: 0; background: none; border: 0; border-radius: var(--r); }

/* lists */
.list { list-style: none; padding: 0; margin: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .num { font-variant-numeric: tabular-nums; text-align: right; font-size: 14px; }
.x { background: none; border: 0; color: var(--muted); font-size: 18px; padding: 4px 6px; }

/* buttons + fields */
.btn { font: inherit; font-weight: 600; border-radius: 14px; padding: 13px 16px; border: 1px solid var(--line); background: var(--card2); color: var(--text); }
.btn.primary { background: var(--accent); color: #07210f; border-color: transparent; }
.btn.danger { background: var(--danger); color: #fff; border-color: transparent; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .45; }
.btn:active:not(:disabled) { transform: scale(.98); }
.link { background: none; border: 0; color: var(--accent); font: inherit; font-weight: 600; font-size: 15px; padding: 4px 0; }
.icon-btn { background: var(--card); border: 1px solid var(--line); color: var(--text); width: 40px; height: 40px; border-radius: 12px; font-size: 18px; }
input, textarea { font: inherit; font-size: 16px; }
#pass, .field { width: 100%; background: var(--card2); border: 1px solid var(--line); color: var(--text); border-radius: 12px; padding: 12px 14px; outline: none; }
.field:focus, #pass:focus { border-color: var(--accent); }
.mini { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.check { display: flex; align-items: center; gap: 8px; margin: 12px 0; color: var(--muted); }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.pill { font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 99px; background: var(--card2); color: var(--muted); }
.pill.low { color: var(--danger); } .pill.high { color: var(--accent); }

/* snap */
.snap-drop { display: grid; place-items: center; min-height: 240px; border: 2px dashed var(--line); border-radius: 16px; text-align: center; overflow: hidden; margin-bottom: 12px; cursor: pointer; }
.snap-drop img { width: 100%; max-height: 340px; object-fit: cover; display: block; }
.snap-icon { font-size: 44px; margin-bottom: 6px; }
#snap-caption { margin-bottom: 12px; }
#snap-result .field { margin-bottom: 8px; }

/* chat */
#s-chat { display: flex; flex-direction: column; min-height: calc(100dvh - 190px); }
.chat-log { flex: 1; display: flex; flex-direction: column; gap: 8px; padding-bottom: 8px; }
.msg { max-width: 84%; padding: 10px 13px; border-radius: 18px; white-space: pre-wrap; word-wrap: break-word; font-size: 15px; }
.msg.me { align-self: flex-end; background: var(--accent); color: #07210f; border-bottom-right-radius: 6px; }
.msg.bot { align-self: flex-start; background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg.typing { color: var(--muted); }
.day-sep { align-self: center; font-size: 12px; color: var(--muted); padding: 6px 0; }
.chat-form { position: sticky; bottom: calc(var(--safe-b) + 80px); display: flex; gap: 8px; align-items: flex-end; background: var(--bg); padding: 8px 0; }
.chat-form textarea { flex: 1; resize: none; max-height: 140px; background: var(--card); border: 1px solid var(--line); color: var(--text); border-radius: 20px; padding: 11px 15px; outline: none; }
.send { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--accent); color: #07210f; font-size: 20px; font-weight: 700; flex: none; }
.confirm-bar { display: flex; gap: 8px; }
.confirm-bar .btn { flex: 1; }

/* workout */
.ex { padding: 12px 0; border-top: 1px solid var(--line); }
.ex:first-of-type { border-top: 0; }
.ex-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.ex-name { font-weight: 600; }
.ex-meta { font-size: 13px; color: var(--muted); }
.sets { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.set-chip { font-size: 13px; background: var(--card2); border: 1px solid var(--line); border-radius: 99px; padding: 4px 10px; font-variant-numeric: tabular-nums; }
.set-chip.done { border-color: var(--accent); color: var(--accent); }
.log-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px; }
.log-row .field { padding: 9px 10px; }
.log-row .btn { padding: 9px 14px; }
.block-note { font-size: 12px; color: var(--muted); margin: 10px 0 0; text-transform: uppercase; letter-spacing: .06em; }
a.form { color: var(--water); font-size: 13px; text-decoration: none; }

/* progress */
.seg { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 3px; }
.seg button { background: none; border: 0; color: var(--muted); font: inherit; font-weight: 600; padding: 8px; border-radius: 9px; }
.seg button.on { background: var(--card2); color: var(--text); }
.chart { height: 150px; }
.chart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart text { fill: var(--muted); font-size: 10px; }
.chart .empty { display: grid; place-items: center; height: 100%; color: var(--muted); font-size: 14px; }

/* tabs */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(5, 1fr); padding: 8px 8px calc(var(--safe-b) + 8px); background: rgba(13, 15, 20, .92); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--line); }
.tabs button { background: none; border: 0; color: var(--muted); font: inherit; font-size: 11px; font-weight: 600; display: grid; justify-items: center; gap: 2px; padding: 4px 0; }
.tabs button span { font-size: 19px; line-height: 1.2; }
.tabs button.on { color: var(--text); }
.tabs .snap-tab span { width: 52px; height: 52px; margin-top: -18px; border-radius: 50%; background: var(--accent); color: #07210f; display: grid; place-items: center; font-size: 30px; font-weight: 400; box-shadow: 0 6px 20px rgba(124, 242, 156, .3); }

/* sheet + toast */
.sheet { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .55); display: flex; align-items: flex-end; }
.sheet-card { width: 100%; background: var(--card); border-radius: 22px 22px 0 0; padding: 20px 18px calc(var(--safe-b) + 20px); display: grid; gap: 10px; animation: up .22s ease; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.toast { position: fixed; left: 50%; bottom: calc(var(--safe-b) + 96px); transform: translateX(-50%); background: var(--card2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 99px; z-index: 30; font-size: 14px; max-width: 90%; text-align: center; }
