:root {
  --bg: #0f1012;
  --surface: #17191c;
  --surface-2: #1f2226;
  --line: #2a2e33;
  --text: #f1f0ec;
  --muted: #8d929a;
  --faint: #5b6068;
  --accent: #c8f53c;
  --accent-ink: #141a02;
  --up: #c8f53c;
  --down: #ff8a4c;
  --pr: #ffd25c;
  --danger: #ff5d5d;
  --radius: 14px;
  --display: 'Space Grotesk', system-ui, sans-serif;
  --body: 'Inter', system-ui, -apple-system, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 var(--body); -webkit-font-smoothing: antialiased; }
body { min-height: 100dvh; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--display); margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 28px; line-height: 1.1; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 12px; }
.stack-lg > * + * { margin-top: 20px; }
[hidden] { display: none !important; }

#app { max-width: 560px; margin: 0 auto; padding: 20px 16px calc(96px + var(--safe-b)); }
.boot { display: grid; place-items: center; min-height: 80dvh; }
.logo-mark { width: 44px; height: 44px; border-radius: 12px; background: var(--accent); mask: url(../icons/mark.svg) center/contain no-repeat; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .4; } }

/* Header */
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.eyebrow { font: 600 12px/1 var(--body); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.brand { font: 700 15px var(--display); display: flex; align-items: center; gap: 8px; }
.brand i { width: 18px; height: 18px; background: var(--accent); mask: url(../icons/mark.svg) center/contain no-repeat; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card.hero { background: linear-gradient(160deg, #1d2312, var(--surface) 55%); border-color: #34401a; }
.card.flat { background: transparent; }
.card-link { display: block; text-decoration: none; }
.card-link:active { transform: scale(.995); }
.banner { border-radius: 12px; padding: 10px 12px; font-size: 13px; background: #23200f; border: 1px solid #4a4219; color: #f0dfa0; }
.banner.info { background: #121b22; border-color: #23384a; color: #a9cbe6; }

/* Buttons */
.btn { appearance: none; border: 1px solid var(--line); background: var(--surface-2); border-radius: 12px; padding: 12px 16px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; text-decoration: none; }
.btn:hover { border-color: #3a3f46; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: 13px; border-radius: 10px; }
.btn.icon { min-height: 36px; width: 36px; padding: 0; border-radius: 10px; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: 13px; }

/* Forms */
label.field { display: block; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.input, select.input { width: 100%; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; min-height: 46px; outline: none; }
.input:focus { border-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: var(--surface-2); border-radius: 999px; padding: 9px 14px; cursor: pointer; font-weight: 500; font-size: 14px; }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.choice { display: block; width: 100%; text-align: left; border: 1px solid var(--line); background: var(--surface-2); border-radius: 12px; padding: 12px 14px; cursor: pointer; }
.choice b { display: block; font-weight: 600; }
.choice small { color: var(--muted); }
.choice[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.choice-grid { display: grid; gap: 8px; }
.seg { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.seg button { border: 1px solid var(--line); background: var(--surface-2); border-radius: 10px; min-height: 40px; cursor: pointer; font-weight: 600; }
.seg button[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.seg-labels { display: flex; justify-content: space-between; font-size: 11px; color: var(--faint); margin-top: 4px; }

/* Auth */
.auth { min-height: 85dvh; display: flex; flex-direction: column; justify-content: center; }
.auth .hero-title { font-size: 40px; line-height: 1; margin: 18px 0 10px; }
.auth .hero-title em { font-style: normal; color: var(--accent); }
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); border-radius: 12px; padding: 4px; border: 1px solid var(--line); }
.tabs button { border: 0; background: transparent; padding: 9px; border-radius: 9px; font-weight: 600; cursor: pointer; color: var(--muted); }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); }

/* Onboarding */
.progress-dots { display: flex; gap: 6px; }
.progress-dots i { height: 4px; flex: 1; border-radius: 2px; background: var(--line); }
.progress-dots i.on { background: var(--accent); }

/* Today */
.day-chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.day-chips .chip { white-space: nowrap; }
.preview-list { list-style: none; margin: 0; padding: 0; }
.preview-list li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 14px; }
.preview-list li:first-child { border-top: 0; }
.preview-list .tgt { color: var(--muted); white-space: nowrap; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.stat b { display: block; font: 700 22px/1.1 var(--display); }
.stat span { font-size: 12px; color: var(--muted); }

/* Workout */
.wk-top { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px); margin: -20px -16px 16px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.ex-card { padding: 14px; }
.ex-head { display: flex; align-items: flex-start; gap: 10px; }
.ex-title { font: 600 17px/1.2 var(--display); }
.ex-meta { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.reasons { margin: 10px 0 0; padding: 0; list-style: none; }
.reasons li { font-size: 12.5px; color: #b9c3a4; background: #1a1f12; border-radius: 8px; padding: 7px 10px; margin-top: 6px; }
.sets { margin-top: 12px; width: 100%; border-collapse: separate; border-spacing: 0 6px; table-layout: fixed; }
.sets col.c-n { width: 26px; } .sets col.c-rpe { width: 22%; } .sets col.c-ok { width: 48px; }
.sets th { font: 600 11px var(--body); color: var(--faint); text-transform: uppercase; letter-spacing: .06em; text-align: left; padding: 0 4px; }
.sets td { padding: 0 3px; }
.sets td:first-child { color: var(--muted); font-weight: 600; text-align: center; }
.sets .input { padding: 8px 8px; min-height: 42px; text-align: center; border-radius: 10px; font-variant-numeric: tabular-nums; }
.sets select.input { padding: 8px 2px; }
.sets tr.done .input { background: #1c2310; border-color: #3a4a1a; }
.check { width: 42px; height: 42px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); cursor: pointer; display: grid; place-items: center; }
.check svg { width: 20px; height: 20px; stroke: var(--faint); fill: none; stroke-width: 2.5; }
tr.done .check { background: var(--accent); border-color: var(--accent); }
tr.done .check svg { stroke: var(--accent-ink); }
.ex-actions { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.target-hint { font-size: 11.5px; color: var(--faint); text-align: center; }

/* Rest timer */
.rest { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(76px + var(--safe-b)); z-index: 20; width: min(528px, calc(100% - 32px)); background: var(--text); color: var(--bg); border-radius: 16px; padding: 10px 12px 10px 16px; display: flex; align-items: center; gap: 10px; box-shadow: 0 12px 40px rgba(0,0,0,.5); }
.rest b { font: 700 24px var(--display); font-variant-numeric: tabular-nums; }
.rest .btn { background: #e3e2dd; border-color: transparent; color: var(--bg); min-height: 36px; padding: 6px 12px; }
.rest .bar { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--accent-ink); border-radius: 0 0 0 16px; transition: width 1s linear; }

body.no-tab .rest { bottom: calc(16px + var(--safe-b)); }

/* Summary */
.change { display: flex; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.change:first-child { border-top: 0; }
.change .dot { width: 26px; height: 26px; border-radius: 8px; flex: none; display: grid; place-items: center; font-weight: 700; font-size: 13px; background: var(--surface-2); color: var(--muted); }
.change .dot.up { background: #26310f; color: var(--up); }
.change .dot.down { background: #33200f; color: var(--down); }
.pr { background: #2a2410; border: 1px solid #574a17; border-radius: 12px; padding: 10px 12px; color: var(--pr); font-weight: 600; }

/* History */
.hist-item { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.pill { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.pill.deload { color: #a9cbe6; border-color: #23384a; }
table.log { width: 100%; border-collapse: collapse; font-size: 14px; }
table.log td { padding: 6px 0; border-top: 1px solid var(--line); }
table.log td:last-child { text-align: right; color: var(--muted); }

/* Progress */
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--faint); font: 10px var(--body); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: url(#fade); }
.chart .pt { fill: var(--bg); stroke: var(--accent); stroke-width: 2; }
.vol-row { display: grid; grid-template-columns: 92px 1fr 40px; align-items: center; gap: 10px; font-size: 13px; padding: 5px 0; }
.vol-track { position: relative; height: 10px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.vol-band { position: absolute; top: 0; bottom: 0; background: #26310f; }
.vol-fill { position: absolute; top: 2px; bottom: 2px; left: 0; border-radius: 3px; background: var(--muted); }
.vol-fill.ok { background: var(--accent); }
.vol-fill.hi { background: var(--down); }
.lift-row { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 14px; }
.lift-row:first-child { border-top: 0; }

/* Program editor */
.prog-day h3 { margin-bottom: 6px; }
.prog-ex { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }

/* Tab bar */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(4, 1fr); background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding: 6px max(8px, calc((100% - 560px)/2)) calc(6px + var(--safe-b)); }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; text-decoration: none; color: var(--faint); font-size: 11px; font-weight: 600; }
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a.on { color: var(--text); }
.tabbar a.on svg { stroke: var(--accent); }

/* Modal */
.modal-back { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.modal { width: min(560px, 100%); max-height: 85dvh; overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + var(--safe-b)); animation: rise .2s ease-out; }
@media (min-width: 600px) { .modal-back { align-items: center; } .modal { border-radius: 20px; } }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(24px); opacity: .5; } }

.toast { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 50; background: var(--surface-2); border: 1px solid var(--line); padding: 10px 14px; border-radius: 12px; font-size: 14px; max-width: calc(100% - 32px); box-shadow: 0 8px 30px rgba(0,0,0,.4); }
.toast.err { border-color: #5a2626; color: #ffb3b3; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* v2: progression tag, prompts, cardio */
.style-tag { margin-top: 6px; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: transparent; color: var(--muted); border-radius: 999px; padding: 3px 10px; font: 600 11.5px var(--body); cursor: pointer; }
.style-tag::after { content: '›'; font-size: 13px; }
.style-tag:hover { color: var(--text); border-color: #3a3f46; }
.prompt { margin-top: 10px; border: 1px solid #3b4a1c; background: #1a1f12; border-radius: 10px; padding: 10px 12px; }
.prompt p { margin: 0 0 8px; font-size: 13px; color: #d6e3b5; }
.cardio-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cardio-grid .field:first-child { grid-column: 1 / -1; }
button.lift-row { width: 100%; background: none; border: 0; border-top: 1px solid var(--line); color: inherit; font: inherit; cursor: pointer; align-items: center; text-align: right; }
button.lift-row:first-child { border-top: 0; }
button.lift-row:hover .grow { color: var(--accent); }
.choice .pill { margin-left: 4px; }

/* Personalisation */
.notes { margin: 0; padding-left: 18px; display: grid; gap: 8px; font-size: 13.5px; color: #c9ccd1; }
fieldset.field { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.checks label { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.checks input { width: 18px; height: 18px; accent-color: var(--accent); }

/* v3: warm-ups, program tools */
.sets tr.warm td:first-child { color: var(--accent); font-size: 12px; }
.sets tr.warm .input { opacity: .8; border-style: dashed; }
.prog-tools { display: flex; align-items: center; gap: 2px; flex: none; }
.prog-tools .btn.icon { width: 32px; min-height: 32px; }
.prog-tools .btn:disabled { opacity: .25; }
.prog-ex .grow { min-width: 0; }
.check:not(:has(svg)) { color: var(--muted); font-size: 14px; }
.report-ctx { font-size: 11px; color: var(--muted); background: var(--surface-2); border-radius: 10px; padding: 10px; overflow-x: auto; max-height: 200px; white-space: pre-wrap; word-break: break-word; }
textarea.input { resize: vertical; min-height: 110px; font: inherit; }

/* Sign in with Google */
.google-btn { background: var(--text); color: var(--bg); border-color: var(--text); }
.google-btn:hover { filter: brightness(.95); }
.or { display: flex; align-items: center; gap: 10px; color: var(--faint); font-size: 12px; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* iPhone fit: Safari zooms into any text field under 16px and stays zoomed,
   so every form control uses 16px. Nothing may push the page wider than the screen. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { overflow-x: hidden; }
input, select, textarea, .input { font-size: 16px; }
.sets .input { font-size: 16px; }
.review-list li { align-items: center; }

/* Plans */
.plan-link { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; letter-spacing: inherit; text-transform: inherit; cursor: pointer; }
.plan-card { padding: 12px 14px; }
.plan-card.active { border-color: #3b4a1c; }
