:root {
  --bg: #0c0e11; --bg2: #121519; --card: #171b20; --card2: #1f242b; --line: #2a3038; --line2: #343b45;
  --text: #f3f5f7; --muted: #98a2ae; --faint: #6b7480;
  --accent: #ff5a36; --accent-ink: #fff; --accent-soft: rgba(255, 90, 54, .14);
  --good: #2fbf86; --good-soft: rgba(47, 191, 134, .15); --warn: #f5a524; --warn-soft: rgba(245, 165, 36, .15); --bad: #ef4b4b; --bad-soft: rgba(239, 75, 75, .14);
  --blue: #4c9dff; --blue-soft: rgba(76, 157, 255, .14);
  --r: 14px; --r-sm: 10px; --shadow: 0 8px 30px rgba(0, 0, 0, .35);
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  --tabbar: calc(62px + var(--safe-b));
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f4f5f7; --bg2: #eceef1; --card: #ffffff; --card2: #f3f4f6; --line: #e3e6ea; --line2: #d5d9df;
  --text: #14171a; --muted: #5d6670; --faint: #8a929c; --accent-soft: rgba(255, 90, 54, .12);
  --shadow: 0 8px 24px rgba(20, 23, 26, .08); color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; overscroll-behavior-y: none; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; }
h1 { font-size: 28px; letter-spacing: -.02em; }
h2 { font-size: 20px; letter-spacing: -.01em; }
h3 { font-size: 17px; }
p { margin: 0; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: 13px; } .tiny { font-size: 11.5px; }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
svg { width: 1.1em; height: 1.1em; flex: none; vertical-align: -0.15em; }
.btn svg, .icon-btn svg { width: 20px; height: 20px; }
.btn.xs svg, .btn.sm svg { width: 16px; height: 16px; }
.thumb svg { width: 22px; height: 22px; }
.spark { width: 100%; height: 120px; }

/* ---------- layout ---------- */
#app { min-height: 100vh; }
.screen { padding: calc(12px + var(--safe-t)) 16px calc(var(--tabbar) + 24px); max-width: 640px; margin: 0 auto; }
.screen.full { padding-bottom: calc(110px + var(--safe-b)); }
.topbar { display: flex; align-items: center; gap: 10px; min-height: 44px; margin-bottom: 8px; }
.topbar h1, .topbar h2 { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; } .row.top { align-items: flex-start; } .row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 12px; } .stack-sm > * + * { margin-top: 8px; } .stack-lg > * + * { margin-top: 20px; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 22px 2px 10px; }
.section-title h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

/* ---------- cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
.card.tight { padding: 10px 12px; }
.card.tap { cursor: pointer; transition: transform .08s ease, border-color .15s; }
.card.tap:active { transform: scale(.985); }
.card.hero { background: linear-gradient(140deg, rgba(255, 90, 54, .22), rgba(255, 90, 54, .05) 55%), var(--card); border-color: rgba(255, 90, 54, .35); }
.card.warn { border-color: rgba(245, 165, 36, .45); background: linear-gradient(0deg, var(--warn-soft), var(--warn-soft)), var(--card); }
.card.good { border-color: rgba(47, 191, 134, .45); background: linear-gradient(0deg, var(--good-soft), var(--good-soft)), var(--card); }
.list { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line); min-height: 54px; cursor: pointer; background: none; width: 100%; text-align: left; border-left: 0; border-right: 0; border-bottom: 0; }
.list-row:first-child { border-top: 0; }
.list-row:active { background: var(--card2); }
.list-row .chev { color: var(--faint); font-size: 18px; }
.thumb { width: 44px; height: 44px; border-radius: 10px; background: var(--card2) center/cover no-repeat; flex: none; display: grid; place-items: center; color: var(--faint); font-size: 18px; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line2); background: var(--card2); font-weight: 650; cursor: pointer; text-decoration: none; color: var(--text); white-space: nowrap; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.good { background: var(--good); border-color: var(--good); color: #062b1d; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn.block { width: 100%; }
.btn.lg { min-height: 56px; font-size: 18px; border-radius: 14px; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn.xs { min-height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); display: inline-grid; place-items: center; cursor: pointer; font-size: 18px; flex: none; color: var(--text); }
.icon-btn.plain { border: 0; background: none; }
.link { background: none; border: 0; color: var(--accent); font-weight: 600; cursor: pointer; padding: 4px 0; }

/* ---------- chips / pills / seg ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line2); background: var(--card); font-size: 14px; cursor: pointer; white-space: nowrap; }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 650; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 650; background: var(--card2); color: var(--muted); }
.pill.accent { background: var(--accent-soft); color: var(--accent); } .pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); } .pill.bad { background: var(--bad-soft); color: var(--bad); } .pill.blue { background: var(--blue-soft); color: var(--blue); }
.seg { display: flex; background: var(--card2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; min-height: 36px; border: 0; border-radius: 9px; background: none; font-weight: 600; font-size: 14px; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .25); }

/* ---------- forms ---------- */
.field { display: block; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin: 0 2px 6px; font-weight: 600; }
.input, select.input, textarea.input { width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line2); background: var(--bg2); outline: none; }
textarea.input { min-height: 90px; resize: vertical; }
.input:focus { border-color: var(--accent); }
.check { display: flex; align-items: center; gap: 10px; padding: 8px 0; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }

/* ---------- tab bar ---------- */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; justify-content: space-around; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + var(--safe-b)); }
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--faint); text-decoration: none; font-size: 11px; font-weight: 600; padding: 4px 0; }
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a.on { color: var(--accent); }
.resume-bar { position: fixed; left: 12px; right: 12px; bottom: calc(var(--tabbar) + 8px); z-index: 29; max-width: 616px; margin: 0 auto; }

/* ---------- week strip ---------- */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.day { text-align: center; padding: 8px 0; border-radius: 12px; background: var(--card); border: 1px solid var(--line); cursor: pointer; }
.day .dn { font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; }
.day .dd { font-size: 17px; font-weight: 700; margin-top: 2px; }
.day .dot { width: 6px; height: 6px; border-radius: 50%; margin: 5px auto 0; background: transparent; }
.day.has .dot { background: var(--line2); } .day.done .dot { background: var(--good); }
.day.today { border-color: var(--accent); } .day.sel { background: var(--accent-soft); }

/* ---------- logger ---------- */
.ex-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.ex-card + .ex-card { margin-top: 12px; }
.ex-head { display: flex; align-items: center; gap: 12px; padding: 12px 12px 8px; }
.ex-head .name { font-weight: 700; font-size: 17px; }
.group-tag { display: flex; align-items: center; gap: 8px; padding: 8px 12px 0; font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--blue); }
.sets { padding: 0 8px 8px; }
.set-row { display: grid; grid-template-columns: 26px minmax(0, 1fr) 64px 50px 46px 44px; gap: 5px; align-items: center; padding: 4px 4px; border-radius: 10px; }
.set-row.head { font-size: 11px; color: var(--faint); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding-top: 2px; padding-bottom: 2px; }
.set-row.done { background: var(--good-soft); }
.set-row.mode-reps { grid-template-columns: 26px minmax(0, 1fr) 64px 50px 44px; }
.set-row.mode-time { grid-template-columns: 26px minmax(0, 1fr) 72px 50px 44px; }
.set-row.mode-cardio { grid-template-columns: 26px minmax(0, 1fr) 72px 64px 44px; }
.set-row.head > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.set-row .sn { text-align: center; font-weight: 700; color: var(--muted); font-size: 14px; cursor: pointer; border-radius: 8px; padding: 6px 0; }
.set-row .sn.w { color: var(--warn); } .set-row .sn.d { color: var(--blue); }
.set-row .prev { font-size: 13px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.set-row input { width: 100%; min-height: 40px; text-align: center; border-radius: 10px; border: 1px solid var(--line); background: var(--bg2); font-weight: 700; font-size: 16px; padding: 0 4px; outline: none; font-variant-numeric: tabular-nums; }
.set-row input:focus { border-color: var(--accent); }
.set-row input::placeholder { color: var(--faint); font-weight: 500; }
.set-row.done input { background: transparent; border-color: transparent; }
.tick { width: 44px; height: 40px; padding: 0; border-radius: 10px; border: 1.5px solid var(--line2); background: var(--card2); display: grid; place-items: center; cursor: pointer; font-size: 18px; color: var(--faint); }
.set-row.done .tick { background: var(--good); border-color: var(--good); color: #062b1d; }
.ex-foot { display: flex; gap: 8px; padding: 0 12px 12px; flex-wrap: wrap; }
.rest-dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 35; background: var(--card); border-top: 1px solid var(--line); box-shadow: var(--shadow); padding: 12px 16px calc(12px + var(--safe-b)); }
.rest-dock .inner { max-width: 640px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.rest-time { font-size: 34px; font-weight: 800; font-variant-numeric: tabular-nums; min-width: 92px; }
.rest-time.warn { color: var(--warn); }
.progress-line { height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; }
.progress-line > div { height: 100%; background: var(--accent); transition: width .3s linear; }
.log-bottom { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding: 10px 16px calc(10px + var(--safe-b)); }
.log-bottom .inner { max-width: 640px; margin: 0 auto; display: flex; gap: 10px; }

/* ---------- big timer (WOD / guided) ---------- */
.timer-screen { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: flex; flex-direction: column; padding: calc(10px + var(--safe-t)) 16px calc(16px + var(--safe-b)); }
.timer-screen.work { background: radial-gradient(120% 70% at 50% 0%, rgba(255, 90, 54, .22), transparent 70%), var(--bg); }
.timer-screen.rest { background: radial-gradient(120% 70% at 50% 0%, rgba(76, 157, 255, .2), transparent 70%), var(--bg); }
.timer-screen.ready { background: radial-gradient(120% 70% at 50% 0%, rgba(245, 165, 36, .2), transparent 70%), var(--bg); }
.timer-top { display: flex; align-items: center; gap: 10px; max-width: 640px; width: 100%; margin: 0 auto; }
.timer-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 10px; max-width: 640px; width: 100%; margin: 0 auto; min-height: 0; }
.timer-kind { font-size: 13px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.work .timer-kind { color: var(--accent); } .rest .timer-kind { color: var(--blue); } .ready .timer-kind { color: var(--warn); }
.timer-label { font-size: 26px; font-weight: 800; letter-spacing: -.01em; }
.timer-detail { color: var(--muted); font-size: 16px; }
.timer-clock { font-size: min(26vw, 132px); font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.03em; line-height: 1; }
.timer-next { color: var(--muted); font-size: 15px; }
.timer-controls { display: flex; gap: 12px; justify-content: center; max-width: 640px; width: 100%; margin: 0 auto; }
.timer-controls .btn { flex: 1; }
.demo { width: 100%; max-height: 38vh; aspect-ratio: 16/10; border-radius: 16px; overflow: hidden; background: #000; position: relative; }
.demo iframe { width: 100%; height: 100%; border: 0; display: block; background: #000; }
.demo img { width: 100%; height: 100%; border: 0; object-fit: contain; display: block; background: #fff; }
.demo img.f1 { position: absolute; inset: 0; animation: flip 2.4s steps(1) infinite; }
@keyframes flip { 0% { opacity: 0; } 50% { opacity: 1; } }
.demo .cap { position: absolute; left: 8px; bottom: 8px; font-size: 11px; color: #fff; background: rgba(0, 0, 0, .55); padding: 2px 8px; border-radius: 999px; }
.movements { list-style: none; padding: 0; margin: 4px 0 0; font-size: 18px; font-weight: 650; }
.movements li { padding: 4px 0; }
.counter { display: flex; align-items: center; gap: 14px; justify-content: center; }
.counter .val { font-size: 40px; font-weight: 800; min-width: 70px; font-variant-numeric: tabular-nums; }

/* ---------- charts / stats ---------- */
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; }
.stat .v { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 12px; color: var(--muted); font-weight: 600; }
.bars { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 82px 1fr 44px; align-items: center; gap: 10px; font-size: 14px; }
.bar { height: 10px; border-radius: 6px; background: var(--line); overflow: hidden; }
.bar > div { height: 100%; border-radius: 6px; background: var(--accent); }
.bar.good > div { background: var(--good); } .bar.warn > div { background: var(--warn); } .bar.bad > div { background: var(--bad); }
.spark { width: 100%; height: 120px; display: block; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal div { aspect-ratio: 1; border-radius: 8px; display: grid; place-items: center; font-size: 12px; color: var(--muted); background: var(--card); }
.cal div.on { background: var(--accent); color: #fff; font-weight: 700; }
.cal div.today { outline: 1.5px solid var(--accent); }
.cal div.empty { background: none; }
.cal .h { background: none; font-weight: 700; color: var(--faint); aspect-ratio: auto; }

/* ---------- coach chat ---------- */
.chat { display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 88%; padding: 10px 13px; border-radius: 16px; white-space: pre-wrap; word-wrap: break-word; }
.msg.me { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 5px; }
.msg.ai { align-self: flex-start; background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.msg.sys { align-self: center; background: none; color: var(--muted); font-size: 13px; text-align: center; }
.proposal { align-self: stretch; }
.diff { list-style: none; margin: 8px 0 0; padding: 0; font-size: 14px; }
.diff li { padding: 5px 0 5px 22px; position: relative; border-top: 1px solid var(--line); }
.diff li:first-child { border-top: 0; }
.diff li::before { position: absolute; left: 2px; font-weight: 800; }
.diff li.add::before { content: '+'; color: var(--good); } .diff li.remove::before { content: '\2212'; color: var(--bad); }
.diff li.change::before { content: '\2192'; color: var(--warn); } .diff li.same::before { content: '='; color: var(--faint); }
.composer { position: fixed; left: 0; right: 0; bottom: var(--tabbar); z-index: 25; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding: 10px 12px; }
.composer .inner { max-width: 640px; margin: 0 auto; display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { flex: 1; min-height: 44px; max-height: 140px; resize: none; border-radius: 14px; }
.typing span { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); margin: 0 2px; animation: bounce 1s infinite; }
.typing span:nth-child(2) { animation-delay: .15s; } .typing span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 80%, 100% { transform: translateY(0); opacity: .4; } 40% { transform: translateY(-4px); opacity: 1; } }

/* ---------- feed ---------- */
.feed-item { display: flex; gap: 12px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 800; font-size: 14px; color: #fff; background: var(--accent); }
.liftmas { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.lm { border-radius: 10px; padding: 6px 2px; text-align: center; background: var(--card2); border: 1px solid var(--line); font-size: 11px; cursor: pointer; min-height: 52px; display: flex; flex-direction: column; justify-content: center; }
.lm b { font-size: 15px; display: block; }
.lm.done { background: var(--good-soft); border-color: var(--good); }
.lm.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.lm.future { opacity: .45; }

/* ---------- sheet + toast (dom.js) ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .55); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease; }
.sheet { width: 100%; max-width: 640px; max-height: 92vh; background: var(--bg2); border-radius: 20px 20px 0 0; display: flex; flex-direction: column; box-shadow: var(--shadow); animation: up .2s ease; padding-bottom: var(--safe-b); }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { flex: 1; font-size: 18px; }
.sheet-body { overflow-y: auto; padding: 14px 16px 18px; -webkit-overflow-scrolling: touch; }
.sheet-foot { padding: 10px 16px 14px; border-top: 1px solid var(--line); display: flex; gap: 10px; }
.sheet-foot .btn { flex: 1; }
@keyframes up { from { transform: translateY(30px); opacity: .6; } }
@keyframes fade { from { opacity: 0; } }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar) + 18px); z-index: 80; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 14px; max-width: 90vw; box-shadow: var(--shadow); animation: fade .15s ease; }
.empty-state { text-align: center; padding: 28px 16px; color: var(--muted); }
.empty-state .big { font-size: 40px; margin-bottom: 8px; }
.steps { padding-left: 20px; margin: 6px 0 0; } .steps li { margin: 6px 0; color: var(--muted); }
.kbd-spacer { height: 40vh; }
.loading { display: grid; place-items: center; min-height: 70vh; color: var(--muted); }
.brand { font-weight: 900; letter-spacing: -.03em; } .brand b { color: var(--accent); }
