:root {
  --bg: #0d0f12;
  --surface: #161a1f;
  --surface-2: #1e232a;
  --line: #2a3038;
  --text: #f2f1ec;
  --muted: #9aa1ab;
  --accent: #d4ff4f;
  --accent-ink: #12160a;
  --danger: #ff6b5e;
  --ok: #7fe0a6;
  --radius: 16px;
  --tabbar-h: 64px;
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { min-height: 100dvh; line-height: 1.45; -webkit-tap-highlight-color: transparent; }
#root { max-width: 560px; margin: 0 auto; min-height: 100dvh; }
h1, h2, h3 { margin: 0 0 .4em; letter-spacing: -0.02em; line-height: 1.15; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.05rem; }
p { margin: .3em 0 .8em; }
code { background: var(--surface-2); padding: .1em .35em; border-radius: 6px; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: .85rem; margin: .4em 0 0; }
.error { color: var(--danger); font-size: .9rem; margin: .4em 0; }
.notice { color: var(--ok); font-size: .9rem; margin: .4em 0; }
.optional { color: var(--muted); font-weight: 400; font-size: .8rem; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin: 0 0 14px;
}
.card h3 { margin-bottom: .7em; }

/* Forms */
.field { margin-bottom: 16px; }
.field label, .field .label { display: block; font-weight: 600; font-size: .92rem; margin-bottom: 6px; }
input, select, textarea {
  width: 100%; font: inherit; font-size: 16px; /* prevents iOS zoom */
  color: var(--text); background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; outline: none; appearance: none;
}
textarea { resize: vertical; min-height: 84px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
.has-error input, .has-error select, .has-error textarea, .has-error .choices { border-color: var(--danger); }
.input-unit { position: relative; }
.input-unit .unit { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: .9rem; pointer-events: none; }
.input-unit input { padding-right: 58px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row.three { grid-template-columns: 1fr 1fr 1fr; }
.choices { display: grid; gap: 8px; border-radius: 12px; }
.choice {
  text-align: left; font: inherit; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; cursor: pointer;
}
.choice.selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface-2)); }
.toggle { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.toggle input { width: 24px; height: 24px; flex: none; margin-top: 2px; appearance: auto; accent-color: var(--accent); }
.toggle span { display: block; }

/* Buttons */
button { font: inherit; cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
.primary, .secondary, .danger-btn {
  display: block; width: 100%; padding: 14px 18px; border-radius: 14px; font-weight: 650; font-size: 1rem; border: 1px solid transparent;
}
.primary { background: var(--accent); color: var(--accent-ink); }
.secondary { background: var(--surface-2); color: var(--text); border-color: var(--line); }
.danger-btn { background: transparent; color: var(--danger); border-color: var(--danger); }
.link { background: none; border: none; color: var(--accent); padding: 12px 0; width: 100%; }
.link.small { width: auto; padding: 0; font-size: .85rem; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }

/* Auth */
.auth { padding: max(48px, env(safe-area-inset-top)) 20px 40px; }
.brand { text-align: center; margin: 24px 0 28px; }
.logo { font-size: 2.2rem; color: var(--accent); }
.auth form .primary { margin-top: 8px; }

/* Onboarding */
.onboarding { padding: max(20px, env(safe-area-inset-top)) 16px calc(110px + env(safe-area-inset-bottom)); }
.ob-header { margin: 8px 4px 18px; }
.progress { display: flex; gap: 4px; margin-bottom: 14px; }
.progress span { flex: 1; height: 4px; border-radius: 2px; background: var(--line); }
.progress span.on { background: var(--accent); }
.step-count { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; margin: 0 0 6px; }
.ob-nav {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 30%);
  max-width: 560px; margin: 0 auto;
}
.review { margin: 0; }
.review-row { display: grid; grid-template-columns: 110px 1fr auto; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: start; }
.review-row:last-child { border-bottom: 0; }
.review dt { color: var(--muted); font-size: .88rem; }
.review dd { margin: 0; white-space: pre-wrap; word-break: break-word; }

/* Shell */
.shell { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px); }
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center;
  padding: max(14px, env(safe-area-inset-top)) 16px 12px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.topbar h1 { font-size: 1.6rem; margin: 0; }
.avatar { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font-weight: 700; }
.content { padding: 4px 16px; }
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: grid; grid-template-columns: repeat(5, 1fr);
  max-width: 560px; margin: 0 auto; height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line);
}
.tabbar button { background: none; border: 0; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: .68rem; }
.tabbar button.active { color: var(--accent); }
.tab-icon { font-size: 1.1rem; line-height: 1; }
.hero { padding: 8px 2px 18px; }
.hero h2 { font-size: 1.7rem; }
.pill { display: inline-block; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: .8rem; color: var(--muted); margin: 0 0 8px; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 0 0 6px; }
.stats dd { white-space: nowrap; }
.stats div { background: var(--surface-2); border-radius: 12px; padding: 10px; }
.stats dt { font-size: .72rem; color: var(--muted); }
.stats dd { margin: 2px 0 0; font-size: 1.2rem; font-weight: 700; }
.stats small { font-size: .7rem; color: var(--muted); font-weight: 500; }
.coming ul { padding-left: 1.1em; margin: 0; }
.coming li { margin: .35em 0; }
.sticky-save { position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 8px); z-index: 4; margin: 0 0 14px; }
.approval { border-color: var(--accent); }
.modal-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 560px; margin: 0; border-radius: 22px 22px 0 0; padding: 22px 18px calc(22px + env(safe-area-inset-bottom)); }
.danger { border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.danger input { margin: 6px 0; }

.center { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; text-align: center; gap: 10px; }
.center .primary { max-width: 260px; }
.spinner { width: 32px; height: 32px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

/* ---------- Phase 2: training ---------- */
:root { --fig-ink: #eceae4; --fig-far: #6b737d; --fig-accent: #d4ff4f; --fig-equip: #9aa3ad; --fig-floor: #2f363f; --warn: #ffc857; }
.small { font-size: .86rem; } .xsmall { font-size: .76rem; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 0 0 12px; }
.center-inline { display: flex; justify-content: center; padding: 40px 0; }
.pill.accent { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.flag { border-left: 3px solid var(--warn); background: color-mix(in srgb, var(--warn) 10%, var(--surface)); padding: 10px 12px; border-radius: 10px; color: var(--text); margin: 8px 0; }
.quote { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; font-size: .9rem; color: var(--muted); }
.card-inner { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin: 10px 0; }
.checks { display: grid; gap: 6px; margin: 8px 0 16px; }
.check { display: flex; align-items: center; gap: 10px; padding: 8px 0; cursor: pointer; }
.check input { width: 22px; height: 22px; flex: none; appearance: auto; accent-color: var(--accent); padding: 0; }
.actions.three { grid-template-columns: 1fr 1fr 1fr; }
.btn-like { display: flex; align-items: center; justify-content: center; text-decoration: none; text-align: center; font-weight: 650; border-radius: 14px; padding: 10px; font-size: .9rem; }
.icon-btn { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); border-radius: 50%; width: 36px; height: 36px; font-size: 1.3rem; line-height: 1; }

/* exercise images (combined START | END) */
:root { --teal: #0e8a8a; --cyan: #8fe1e6; --img-bg: #f3f5f6; }
.illus { background: var(--img-bg); border-radius: 12px; overflow: hidden; position: relative; }
.illus img { display: block; width: 100%; height: 100%; }
.illus.thumb { width: 64px; height: 64px; flex: none; }
.illus.thumb img { object-fit: cover; object-position: 100% 50%; } /* shows the END half */
.illus.large { margin: 0 0 6px; padding-bottom: 38px; }
.illus.large img { object-fit: contain; }
.illus.placeholder.large { aspect-ratio: 2 / 1; padding-bottom: 10px; }
.illus-zoom { all: unset; display: block; width: 100%; aspect-ratio: 2 / 1; cursor: zoom-in; }
.phase, .move-arrow { pointer-events: none; }
.phase { position: absolute; bottom: 8px; transform: translateX(-50%); background: var(--teal); color: #fff; font-weight: 700; font-size: .72rem; letter-spacing: .06em; padding: 4px 12px; border-radius: 999px; }
.phase.start { left: 25%; } .phase.end { left: 75%; }
.move-arrow { position: absolute; left: 50%; top: calc((100% - 38px) / 2); transform: translate(-50%, -50%); color: var(--teal); font-size: 1.8rem; font-weight: 800; }
.illus.placeholder { border: 2px dashed #c9d2d6; color: #5d6b72; display: flex; align-items: center; justify-content: center; text-align: center; font-size: .85rem; padding: 10px; }
.illus.placeholder.thumb { font-size: 1.1rem; }
.zoom-view { position: fixed; inset: 0; z-index: 80; background: var(--img-bg); display: flex; flex-direction: column; padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom)); }
.zoom-view .seg button.on { background: var(--teal); color: #fff; }
.zoom-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.zoom-img { flex: 1; overflow: hidden; display: flex; align-items: center; }
.zoom-img img { width: 200%; max-width: none; transition: transform .25s; }
.zoom-img.end img { transform: translateX(-50%); }
@media (orientation: landscape) { .zoom-img img { width: 100%; } .zoom-img.end img { transform: none; } }

/* light guide sheet (matches the image style) */
.guide { max-height: 94dvh; overflow-y: auto; }
.guide.light { background: #fff; color: #142126; border-color: #e3e8ea; }
.guide.light .icon-btn { background: #eef2f3; color: #142126; border-color: #dfe5e7; }
.guide-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.guide-head h2 { margin: 6px 0 2px; font-size: 1.5rem; }
.guide .cat { display: inline-block; background: #e3f5f5; color: #0b6f6f; font-weight: 600; font-size: .78rem; padding: 3px 10px; border-radius: 999px; }
.guide .sub { color: #4b5b62; font-size: .88rem; margin: 0; }
.muscles-worked { background: #f6f9fa; border: 1px solid #e3e8ea; border-radius: 14px; padding: 12px; margin: 10px 0; }
.muscles-worked h3 { margin: 0 0 8px; font-size: 1rem; }
.legend { display: grid; gap: 6px; font-size: .9rem; }
.legend div { display: grid; grid-template-columns: 18px auto 1fr; gap: 8px; align-items: center; }
.legend span:last-child { color: #4b5b62; }
.sw { width: 16px; height: 16px; border-radius: 4px; display: inline-block; }
.sw.sw-primary { background: var(--teal); } .sw.sw-secondary { background: var(--cyan); }
.guide-grid { display: grid; gap: 10px; margin: 6px 0 10px; }
.guide-grid section { border: 1px solid #e3e8ea; border-radius: 14px; padding: 10px 12px; }
.guide-grid h4 { margin: 0 0 4px; font-size: .95rem; display: flex; align-items: center; gap: 8px; }
.guide-grid p { margin: 0; font-size: .92rem; color: #2b3a40; }
.gi { display: inline-flex; width: 24px; height: 24px; border-radius: 50%; align-items: center; justify-content: center; font-size: .75rem; color: #fff; background: var(--teal); }
.gi.avoid { background: #0b6f6f; }
.guide .meta { font-size: .82rem; color: #4b5b62; margin: 4px 0; }
.guide.light .secondary { background: #eef2f3; color: #142126; border-color: #dfe5e7; }
@media (min-width: 480px) { .guide-grid { grid-template-columns: 1fr 1fr; } }
.restrict { margin-top: 12px; }

/* exercise rows */
.ex-list { list-style: none; padding: 0; margin: 8px 0; }
.ex-row { display: flex; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.ex-row:last-child { border-bottom: 0; }
.thumb-btn { background: none; border: 0; padding: 0; }
.ex-meta { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.ex-name { background: none; border: 0; padding: 0; color: var(--text); font-weight: 650; text-align: left; font-size: .98rem; }
.day { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin: 10px 0; }
.day summary { cursor: pointer; padding: 4px 0; }
.day .secondary { margin-top: 8px; }
.volume, .rules { margin: 12px 0; }
.volume summary, .rules summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
.volume table, .targets { width: 100%; border-collapse: collapse; font-size: .9rem; }
.volume th, .volume td, .targets th, .targets td { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: left; }
.num { text-align: right !important; white-space: nowrap; }
.status.below { color: var(--warn); } .status.above { color: var(--muted); } .status.within { color: var(--ok); }
.notes { padding-left: 1.1em; font-size: .9rem; color: var(--muted); }
.rule { padding: 8px 0; border-bottom: 1px solid var(--line); }
.rule .pill { margin: 0 0 0 4px; font-size: .7rem; padding: 2px 8px; }
.swap-opt { display: flex; gap: 12px; align-items: center; width: 100%; background: var(--surface-2); border: 1px solid var(--line); color: var(--text); border-radius: 12px; padding: 8px; margin: 0 0 8px; text-align: left; }
.ex-choices { list-style: none; padding: 0; margin: 10px 0 0; }
.ex-choices li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; flex: none; }
.seg button { background: var(--surface-2); color: var(--text); border: 0; padding: 8px 12px; min-width: 56px; }
.seg button.on { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.seg button.on.danger { background: var(--danger); color: #fff; }
.history { list-style: none; padding: 0; margin: 0; }
.history li { display: grid; grid-template-columns: 96px 1fr auto; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }

/* sync chip */
.sync-chip { border-radius: 999px; padding: 5px 12px; font-size: .78rem; font-weight: 600; border: 1px solid var(--line); background: var(--surface-2); color: var(--muted); }
.sync-chip.ok { color: var(--ok); } .sync-chip.pending { color: var(--warn); } .sync-chip.warn { color: var(--accent-ink); background: var(--warn); border-color: var(--warn); }

/* workout */
.workout h2 { margin: 0; }
.logger-head { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
.logger-head h3 { margin: 0 0 2px; }
.targets tr.done td { color: var(--ok); }
.log-form { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 10px; }
.log-form .field { margin-bottom: 6px; }
.toggles { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-bottom: 8px; }
.toggles .check { padding: 4px 0; font-size: .9rem; }
.rec { border-top: 1px solid var(--line); padding: 10px 0; }
.rec:first-of-type { border-top: 0; }
.rec ul { margin: 4px 0; padding-left: 1.1em; color: var(--muted); }
.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.scale button { padding: 12px 0; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font-weight: 600; }
.scale button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.scale-ends { display: flex; justify-content: space-between; font-size: .72rem; color: var(--muted); margin-top: 4px; }
.conflict { border-top: 1px solid var(--line); padding-top: 8px; }

/* ---------- Training Core: Focus Mode ---------- */
.focus { position: fixed; inset: 0; z-index: 30; background: var(--bg); overflow-y: auto; -webkit-overflow-scrolling: touch;
  max-width: 560px; margin: 0 auto; padding: max(10px, env(safe-area-inset-top)) 14px calc(16px + env(safe-area-inset-bottom)); }
.focus-head { position: sticky; top: calc(-1 * max(10px, env(safe-area-inset-top))); z-index: 6; background: var(--bg); padding: 4px 0 8px; }
.focus-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.focus-title strong { font-size: 1.05rem; }
.meter { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin: 8px 0 6px; }
.meter span { display: block; height: 100%; background: var(--accent); transition: width .2s; }
@media (prefers-reduced-motion: reduce) { .meter span { transition: none; } }
.focus-stats { display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.focus-actions { display: flex; gap: 6px; margin-top: 8px; }
.chip-btn { flex: 1; background: var(--surface-2); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 9px 6px; font-size: .85rem; font-weight: 600; }
.paused-banner { background: color-mix(in srgb, var(--warn) 14%, var(--surface)); border: 1px solid var(--warn); border-radius: 14px; padding: 12px; margin: 8px 0; display: grid; gap: 8px; font-size: .9rem; }
.rest { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 8px 12px; margin: 8px 0; }
.rest-label { color: var(--muted); font-size: .8rem; }
.rest-time { font-size: 1.6rem; font-weight: 750; font-variant-numeric: tabular-nums; flex: 1; }
.rest.done .rest-time { color: var(--muted); }
.rest-adj { display: flex; gap: 4px; }
.rest-adj button { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); border-radius: 9px; padding: 8px 9px; font-size: .8rem; min-width: 44px; }
.focus-card h2 { margin: 0 0 2px; font-size: 1.45rem; }
.ref { background: var(--surface-2); border-radius: 12px; padding: 8px 12px; margin: 10px 0; display: grid; gap: 4px; }
.ref > div { display: flex; justify-content: space-between; gap: 10px; font-size: .92rem; }
.ref-k { color: var(--muted); }
.ref-v { font-weight: 650; font-variant-numeric: tabular-nums; text-align: right; }
.cmp { font-weight: 800; } .cmp.higher { color: var(--accent); } .cmp.lower { color: var(--muted); } .cmp.similar { color: var(--muted); }
.steppers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0; }
.stepper { display: grid; grid-template-columns: 48px 1fr 48px; align-items: stretch; background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.stepper > button { background: none; border: 0; color: var(--text); font-size: 1.5rem; font-weight: 600; min-height: 64px; }
.stepper > button:active { background: var(--line); }
.stepper label { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.stepper input { background: none; border: 0; text-align: center; font-size: 1.6rem; font-weight: 750; padding: 4px 0 0; font-variant-numeric: tabular-nums; }
.stepper span { font-size: .7rem; color: var(--muted); padding-bottom: 4px; }
.rir { display: flex; align-items: center; gap: 4px; margin: 6px 0 10px; }
.rir-k { font-size: .78rem; color: var(--muted); width: 28px; }
.rir button { flex: 1; min-height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font-weight: 650; padding: 0; }
.rir button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.rir button.skip { flex: 1.4; font-size: .8rem; font-weight: 500; }
.rir button.skip.on { background: var(--surface); color: var(--text); border-color: var(--muted); }
.complete { min-height: 60px; font-size: 1.15rem; position: sticky; bottom: calc(8px + env(safe-area-inset-bottom)); z-index: 4; box-shadow: 0 6px 24px rgba(0,0,0,.45); }
.fx-links { display: flex; flex-wrap: wrap; gap: 4px 16px; justify-content: center; margin: 8px 0 2px; }
.fx-links .link { padding: 8px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); border-radius: 999px; padding: 8px 12px; font-size: .85rem; min-height: 38px; }
.chips button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 650; }
.note-box { display: grid; gap: 8px; margin: 6px 0 10px; }
.howto { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 8px; font-size: .88rem; }
.howto p { margin: 0 0 6px; }
.done-sets { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 8px 0 4px; }
.done-sets li { background: color-mix(in srgb, var(--ok) 15%, var(--surface-2)); color: var(--ok); border-radius: 8px; padding: 4px 8px; font-size: .8rem; font-variant-numeric: tabular-nums; }
.wk-list { list-style: none; padding: 0; margin: 0; }
.wk-list li { padding: 10px 0; border-bottom: 1px solid var(--line); display: grid; gap: 6px; }
.wk-list li.current .wk-name { color: var(--accent); }
.wk-name { background: none; border: 0; padding: 0; color: var(--text); font-weight: 650; text-align: left; font-size: .98rem; }
.wk-sets { display: flex; flex-wrap: wrap; gap: 6px; }
.setchip { min-width: 54px; min-height: 34px; border-radius: 8px; border: 1px dashed var(--line); background: none; color: var(--muted); font-size: .78rem; display: inline-flex; align-items: center; justify-content: center; padding: 0 6px; }
.setchip.done { border-style: solid; color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, var(--surface-2)); }
.done-card { text-align: center; }
/* today / briefing */
.brief { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 10px; }
.brief p { margin: 0 0 6px; }
.quick { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 8px; }
.quick summary { cursor: pointer; padding: 6px 0; color: var(--muted); }
.qrow { display: grid; grid-template-columns: 110px 1fr; align-items: center; gap: 8px; margin: 6px 0; font-size: .85rem; }
.mini { width: 90px; padding: 8px 10px; border-radius: 999px; font-size: .85rem; }
.pick summary { list-style: none; cursor: pointer; }
.weekdays .wd-row { display: grid; grid-template-columns: 1fr 150px; gap: 8px; align-items: center; padding: 4px 0; }
.hist summary { display: grid; grid-template-columns: 92px 1fr auto; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.hist p { margin: 6px 0; }
.label { font-weight: 600; font-size: .9rem; margin: 12px 0 6px; }
.guide .personal { color: #8a5a00; }

/* ---- Complete app: shared pieces (v3) ---- */
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sheet-head h3 { margin: 0; }
.icon-btn { font: inherit; font-size: 1.3rem; line-height: 1; background: transparent; color: var(--muted); border: 0; padding: 6px 10px; border-radius: 10px; cursor: pointer; min-width: 40px; min-height: 40px; }
.icon-btn:disabled { opacity: .3; }
.xsmall { font-size: .78rem; }
.small-btn { width: auto !important; padding: 8px 14px !important; margin: 0 !important; }
.tag { display: inline-block; font-size: .7rem; padding: 1px 7px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); margin-left: 6px; vertical-align: middle; }
.tag.warn { color: #ffcf66; border-color: #5a4a1d; }
.flag-text { color: #ffcf66; }
.k { color: var(--muted); font-weight: 600; }
.badge { position: absolute; top: -4px; right: -10px; background: var(--accent); color: var(--accent-ink); font-size: .62rem; font-weight: 800; border-radius: 99px; min-width: 16px; height: 16px; line-height: 16px; padding: 0 4px; }
.tab-icon { position: relative; }
.actions.wrap { flex-wrap: wrap; }

/* Dashboard */
.dash { cursor: default; }
.dash[role="button"] { cursor: pointer; }
.dash-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.dash-head h3 { margin: 0 0 .5em; }
.dash-title { font-size: 1.15rem; margin: .1em 0 .4em; }
.status-tag { font-size: .75rem; color: var(--muted); border: 1px solid var(--line); border-radius: 99px; padding: 2px 8px; margin-left: 6px; vertical-align: middle; }
.status-tag.ok { color: var(--ok); border-color: #2f5a41; }
.stats.three { grid-template-columns: repeat(3, 1fr); }
.insights { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.insights li { border-left: 3px solid var(--line); padding-left: 10px; }
.insights li.attention { border-color: #ffcf66; }
.insights li p { margin: .2em 0; }

/* Macro bars */
.macro { margin: 10px 0; }
.macro-top { display: flex; justify-content: space-between; font-size: .9rem; }
.macro-label { font-weight: 600; }
.bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: 5px 0 3px; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.bar.over span { background: #ffcf66; }
.macro-left { font-size: .8rem; color: var(--muted); }
.macro-left.over { color: #ffcf66; }
.big-left { display: flex; flex-direction: column; margin-bottom: 6px; }
.big-num { font-size: 2.4rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1.05; }
.big-num.over { color: #ffcf66; }

/* Nutrition */
.day-nav { display: flex; justify-content: space-between; align-items: center; margin: 0 0 10px; }
.chips.recent button { max-width: 100%; }
.meal-list { list-style: none; margin: 0; padding: 0; }
.meal-row { width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; text-align: left; font: inherit; color: var(--text); background: transparent; border: 0; border-top: 1px solid var(--line); padding: 12px 2px; cursor: pointer; }
.meal-name { font-weight: 600; }
.meal-kcal { font-weight: 700; text-align: right; }
.meal-macros { grid-column: 1 / -1; }
.hist-table { width: 100%; border-collapse: collapse; font-size: .85rem; margin-top: 8px; }
.hist-table th, .hist-table td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.hist-table td.off { color: #ffcf66; }
.hist-table tr.muted td { color: var(--muted); }

/* Progress */
.chart { width: 100%; height: auto; display: block; margin: 6px 0; }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 1.4; opacity: .55; }
.chart-line2 { fill: none; stroke: var(--text); stroke-width: 2; opacity: .35; }
.chart-dot { fill: var(--accent); }
.chart-label { fill: var(--muted); font-size: 10px; }
.quick-add { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 10px; }
.quick-add input[type="datetime-local"] { grid-column: 1 / -1; grid-row: 2; }
.quick-add .primary { width: auto; margin: 0; padding: 0 16px; }
.entry-list { list-style: none; padding: 0; margin: 8px 0 0; }
.entry-list li button { width: 100%; display: flex; justify-content: space-between; font: inherit; color: var(--text); background: transparent; border: 0; border-top: 1px solid var(--line); padding: 10px 2px; cursor: pointer; }
.entry-list.static li { display: flex; justify-content: space-between; align-items: center; gap: 8px; border-top: 1px solid var(--line); padding: 8px 0; }
.comp-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.comp-table td, .comp-table th { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: left; }
.other-row { display: grid; grid-template-columns: 1fr 90px auto auto; gap: 8px; align-items: center; margin: 6px 0; }
.weeks-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 10px; }
.weeks-row .wk { background: var(--surface-2); border-radius: 10px; padding: 8px; display: flex; flex-direction: column; align-items: center; }

/* Coach */
.chat .messages { display: flex; flex-direction: column; gap: 10px; max-height: 60vh; overflow-y: auto; margin: 10px 0; }
.msg { display: flex; flex-direction: column; }
.msg.user { align-items: flex-end; }
.msg .bubble { max-width: 88%; padding: 10px 12px; border-radius: 14px; background: var(--surface-2); font-size: .93rem; }
.msg .bubble p { margin: .15em 0; }
.msg.user .bubble { background: #2b3320; }
.msg.failed .bubble { opacity: .6; }
.msg-meta { max-width: 88%; margin-top: 4px; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.chat-input { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; margin-top: 8px; }
.chat-input .primary, .chat-input .secondary { width: auto; margin: 0; padding: 12px 16px; }
.quick-q button { font-size: .82rem; }
.proposal-card p { margin: .25em 0; }
.memory-list { list-style: none; padding: 0; }
.memory-list li { display: flex; align-items: center; gap: 6px; border-top: 1px solid var(--line); padding: 6px 0; justify-content: space-between; }
.technique { margin-top: 8px; }
.volume td.below { color: var(--muted); }
.volume td.above { color: #ffcf66; }

input, select, textarea { min-width: 0; max-width: 100%; }
input[type="date"], input[type="datetime-local"] { display: block; }
.row > * { min-width: 0; }
.chips.quick-q { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
.chips.quick-q button { flex: 0 0 auto; }

/* ---- v4 UX redesign: hierarchy, fewer words, big primary actions ---- */
.eyebrow { font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 6px; }
.accent-text { color: var(--accent); }
.primary.big { font-size: 1.1rem; padding: 16px; min-height: 56px; border-radius: 16px; }
.hero-card h2 { font-size: 1.6rem; margin-bottom: .15em; }
.hero-card .primary.big { margin-top: 12px; }
.home-date { margin: 0 0 10px; font-size: .9rem; }
.done-tick { font-size: .9rem; color: var(--ok); font-weight: 600; vertical-align: middle; }
.two-big { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; cursor: pointer; }
.two-big > div { display: flex; flex-direction: column; }
.two-big strong { font-size: 1.9rem; letter-spacing: -0.03em; line-height: 1.05; }
.two-big strong.over { color: #ffcf66; }
.two-big span { color: var(--muted); font-size: .85rem; }
.row-card { width: 100%; display: flex; align-items: center; gap: 10px; text-align: left; font: inherit; color: var(--text); cursor: pointer; }
.row-card .eyebrow { margin: 0; min-width: 64px; }
.row-card .row-main { flex: 1; font-weight: 650; }
.coach-row .row-main { font-weight: 500; }
.chip-static { display: inline-block; font-size: .78rem; padding: 4px 10px; border-radius: 99px; background: #1f2a17; color: var(--ok); border: 1px solid #2f4a24; }
.respects { margin: 8px 0 4px; }
details.more > summary, .card.more > summary { cursor: pointer; font-weight: 600; list-style: none; }
details.more > summary::before, .card.more > summary::before { content: '▸ '; color: var(--muted); }
details.more[open] > summary::before, .card.more[open] > summary::before { content: '▾ '; }
details.more { margin-top: 10px; }
.link-row { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; justify-content: center; margin: 4px 0 16px; }
.link-row .link { width: auto; margin: 0; }
.card.compact { padding: 12px 14px; }
.scroll-row { flex-wrap: nowrap !important; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; margin-top: 10px; }
.scroll-row > * { flex: 0 0 auto; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 3px; margin-bottom: 12px; }
.segmented button { font: inherit; font-size: .9rem; border: 0; background: transparent; color: var(--muted); padding: 9px 6px; border-radius: 9px; cursor: pointer; }
.segmented button.on { background: var(--surface-2); color: var(--text); font-weight: 650; }
.row.four { grid-template-columns: repeat(4, 1fr); gap: 8px; }
.row.four .field label { font-size: .78rem; }
.row.four input { padding: 12px 8px; text-align: center; }
.danger-link { color: var(--danger) !important; }
.big-chips button { min-height: 48px; padding: 10px 16px; font-size: .95rem; }
.pc-title { font-size: 1.05rem; margin: 0 0 4px; }

/* Nutrition tiles */
.macro-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.macro-tile { background: var(--surface-2); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.macro-tile.big { grid-column: 1 / -1; }
.macro-tile .mt-label { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.macro-tile .mt-left { font-size: 1.25rem; letter-spacing: -0.02em; }
.macro-tile.big .mt-left { font-size: 2.2rem; }
.macro-tile .mt-sub { font-size: .75rem; color: var(--muted); }
.macro-tile.over .mt-left { color: #ffcf66; }
.macro-tile .bar { margin: 4px 0 0; height: 5px; }

/* Week strip */
.week-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin: 0 0 14px; }
.ws-day { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 6px 2px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .78rem; }
.ws-day .ws-wd { color: var(--muted); font-size: .68rem; }
.ws-day .ws-name { font-weight: 700; }
.ws-day.rest .ws-name { color: var(--muted); }
.ws-day.done { border-color: #2f5a41; }
.ws-day.done .ws-name { color: var(--ok); }
.ws-day.missed .ws-name { color: #ffcf66; }
.ws-day.today { outline: 2px solid var(--accent); outline-offset: -1px; }
.day summary .day-wd { display: inline-block; min-width: 38px; color: var(--muted); font-size: .8rem; }

/* Focus Mode v4 */
.focus-title { display: grid !important; grid-template-columns: 44px 1fr 44px; align-items: center; }
.ft-mid { display: flex; flex-direction: column; align-items: center; text-align: center; }
.fx-pos { margin: 0; font-size: .78rem; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; font-weight: 700; }
.fx-name { font-size: 1.55rem; margin: 2px 0 2px; }
.fx-set { margin: 0 0 10px; color: var(--accent); font-weight: 650; }
.fx-ref { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.fx-ref > div { background: var(--surface-2); border-radius: 12px; padding: 8px 10px; display: flex; flex-direction: column; }
.fx-ref .ref-k { font-size: .72rem; color: var(--muted); }
.fx-ref .ref-v { font-weight: 700; }
.rir .rir-k { background: transparent !important; border: 0 !important; color: var(--muted); font-size: .8rem; padding: 0 4px !important; min-width: 0 !important; }
.fx-next { text-align: center; margin-top: 8px; }
.warm { margin-top: 8px; }
.rest { display: flex; flex-direction: column; align-items: stretch; gap: 6px; }
.rest-main { display: flex; justify-content: space-between; align-items: baseline; }
.rest .rest-time { font-size: 2.4rem; font-weight: 800; letter-spacing: -0.03em; }
.rest.done .rest-label { color: var(--ok); font-weight: 700; }
.undo-link { align-self: flex-start; }
.menu-sheet { display: flex; flex-direction: column; gap: 2px; padding: 10px; }
.menu-item { font: inherit; text-align: left; background: transparent; color: var(--text); border: 0; border-bottom: 1px solid var(--line); padding: 15px 10px; font-size: 1rem; cursor: pointer; }
.menu-item.danger { color: var(--danger); }
.menu-foot { padding: 10px; display: flex; justify-content: center; }
.home .card { margin-bottom: 12px; }
.rest { flex-direction: row !important; flex-wrap: wrap; align-items: center !important; gap: 4px 10px !important; padding: 8px 12px !important; }
.rest-main { flex: 1; display: flex; flex-direction: column !important; align-items: flex-start !important; }
.rest .rest-time { font-size: 2rem; line-height: 1; }
.rest .undo-link { flex-basis: 100%; text-align: left; margin: 0; padding: 2px 0; }
.rest.done { border-color: #2f5a41; background: #14241a; }
.h1-date { font-size: .95rem; font-weight: 500; color: var(--muted); letter-spacing: 0; margin-left: 6px; }
.row-list { padding: 4px 16px; }
.row-list .row-card { background: transparent; border: 0; padding: 14px 0; }
.row-list .row-card + .row-card { border-top: 1px solid var(--line); }
.hero-card { padding: 16px 18px; }
.ws-day .ws-name { font-size: .66rem; white-space: nowrap; }
.ft-mid .sync-chip { margin-top: 3px; padding: 1px 8px; font-size: .68rem; min-height: 0; }

/* ---- v5: Coach = conversation first ---- */
.coach-bar { display: flex; gap: 8px; margin: 0 0 10px; }
.pill-btn { font: inherit; font-size: .88rem; font-weight: 650; border-radius: 99px; padding: 8px 14px; background: var(--surface-2); color: var(--text); border: 1px solid var(--line); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; min-height: 38px; }
.pill-btn.ghost { background: transparent; color: var(--muted); }
.badge-inline { background: var(--accent); color: var(--accent-ink); font-size: .72rem; font-weight: 800; border-radius: 99px; min-width: 18px; height: 18px; line-height: 18px; padding: 0 5px; text-align: center; }
.chat { min-height: 60vh; display: flex; flex-direction: column; }
.chat .messages { flex: 1; max-height: none; }
.chat-input { position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 6px); background: var(--surface); padding-top: 6px; }
/* Focus Mode: target stands out from last time */
.fx-ref > div.target { background: #232b14; border: 1px solid #3d4b1e; }
.fx-ref > div.target .ref-k { color: var(--accent); }
.fx-ref > div.last .ref-v { color: var(--muted); font-weight: 600; }
