/* Gym Tracker — mobile-first, one-handed. Colour tokens first; dark mode follows the OS
   unless the user picks a theme in Settings (html[data-theme]). */

:root {
  color-scheme: light;
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --surface-3: #e2e5ea;
  --text: #12151a;
  --text-2: #464e5a;
  --muted: #6f7884;
  --border: #e0e3e8;
  --grid: #e7e9ed;
  --axis: #c9ced6;
  --accent: #d4521a;
  --accent-ink: #b5441a;
  --on-accent: #ffffff;
  --accent-soft: #fde8dd;
  --good: #0ca30c;
  --good-ink: #006300;
  --good-soft: #e3f4e3;
  --danger: #c73232;
  --warmup: #8a6a00;
  --warmup-soft: #fbf0cf;
  /* workout-day identity colours (validated as a set, see README) */
  --day-blue: #2a78d6;
  --day-magenta: #e87ba4;
  --day-yellow: #eda100;
  --day-green: #008300;
  --on-day-blue: #ffffff;
  --on-day-magenta: #2b0a17;
  --on-day-yellow: #241900;
  --on-day-green: #ffffff;
  /* muscle map + heat ramp: one hue, light -> dark */
  --heat-ink-1: #2b1307;
  --heat-ink-2: #2b1307;
  --heat-ink-3: #ffffff;
  --heat-ink-4: #ffffff;
  --mm-base: #e4e7eb;
  --mm-muscle: #c6ccd4;
  --mm-sec: #f08f5a;
  --mm-pri: #c9501b;
  --heat-1: #f08f5a;
  --heat-2: #e46a30;
  --heat-3: #c9501b;
  --heat-4: #9a3a10;
  --demo-bg: #ffffff;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 2px 8px rgba(16, 24, 40, .06);
  --scrim: rgba(10, 12, 16, .45);
  --radius: 16px;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d0f12;
    --surface: #171a1f;
    --surface-2: #21252c;
    --surface-3: #2c3139;
    --text: #eef1f5;
    --text-2: #bcc3cd;
    --muted: #8d96a3;
    --border: #2a2f37;
    --grid: #252a31;
    --axis: #3a404a;
    --accent: #ff7f3f;
    --accent-ink: #ff9a63;
    --on-accent: #1b0f08;
    --accent-soft: #3a2116;
    --good: #22b822;
    --good-ink: #4cc94c;
    --good-soft: #13301a;
    --danger: #f06a6a;
    --warmup: #e0b13a;
    --warmup-soft: #3a3016;
    --day-blue: #3987e5;
    --day-magenta: #d55181;
    --day-yellow: #c98500;
    --day-green: #008300;
    --on-day-blue: #ffffff;
    --on-day-magenta: #ffffff;
    --on-day-yellow: #1d1400;
    --on-day-green: #ffffff;
    --heat-ink-1: #ffffff;
    --heat-ink-2: #ffffff;
    --heat-ink-3: #1b0f08;
    --heat-ink-4: #1b0f08;
    --mm-base: #252a31;
    --mm-muscle: #3c434d;
    --mm-sec: #a24b1e;
    --mm-pri: #ff8a4c;
    --heat-1: #7a3a1c;
    --heat-2: #b0521f;
    --heat-3: #e86a2c;
    --heat-4: #ff9a63;
    --demo-bg: #f2f2f2;
    --shadow: none;
    --scrim: rgba(0, 0, 0, .6);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0f12;
  --surface: #171a1f;
  --surface-2: #21252c;
  --surface-3: #2c3139;
  --text: #eef1f5;
  --text-2: #bcc3cd;
  --muted: #8d96a3;
  --border: #2a2f37;
  --grid: #252a31;
  --axis: #3a404a;
  --accent: #ff7f3f;
  --accent-ink: #ff9a63;
  --on-accent: #1b0f08;
  --accent-soft: #3a2116;
  --good: #22b822;
  --good-ink: #4cc94c;
  --good-soft: #13301a;
  --danger: #f06a6a;
  --warmup: #e0b13a;
  --warmup-soft: #3a3016;
  --day-blue: #3987e5;
  --day-magenta: #d55181;
  --day-yellow: #c98500;
  --day-green: #008300;
  --on-day-blue: #ffffff;
  --on-day-magenta: #ffffff;
  --on-day-yellow: #1d1400;
  --on-day-green: #ffffff;
  --heat-ink-1: #ffffff;
  --heat-ink-2: #ffffff;
  --heat-ink-3: #1b0f08;
  --heat-ink-4: #1b0f08;
  --mm-base: #252a31;
  --mm-muscle: #3c434d;
  --mm-sec: #a24b1e;
  --mm-pri: #ff8a4c;
  --heat-1: #7a3a1c;
  --heat-2: #b0521f;
  --heat-3: #e86a2c;
  --heat-4: #ff9a63;
  --demo-bg: #f2f2f2;
  --shadow: none;
  --scrim: rgba(0, 0, 0, .6);
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 var(--font);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
  min-height: calc(100dvh / var(--zoom, 1));
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; touch-action: manipulation; }
a { color: var(--accent-ink); text-decoration: none; }
img { display: block; max-width: 100%; }
h1, h2, h3, p { margin: 0; }
h2 { font-size: 18px; font-weight: 700; }
h3 { font-size: 16px; font-weight: 650; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.tnum { font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 12px; }
.center { text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- shell ---------- */
#view {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 16px calc(var(--nav-h) + var(--safe-b) + 24px);
}
body.resting #view { padding-bottom: calc(var(--nav-h) + var(--safe-b) + 96px); }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 4px;
  min-height: 60px;
  margin: 0 -16px 8px;
  padding: env(safe-area-inset-top, 0px) 8px 0 16px;
  background: var(--bg);
}
.topbar.has-back { padding-left: 4px; }
.topbar h1 {
  flex: 1; min-width: 0;
  font-size: 21px; font-weight: 750; letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar .sub { display: block; font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: 0; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font-size: 11.5px; font-weight: 600; position: relative;
}
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a.on { color: var(--accent-ink); }
.tabbar a.on::before {
  content: ""; position: absolute; top: 6px; width: 56px; height: 32px; border-radius: 16px;
  background: var(--accent-soft); z-index: -1;
}
.tabbar a .live-dot {
  position: absolute; top: 9px; left: calc(50% + 9px);
  width: 9px; height: 9px; border-radius: 50%; background: var(--good); border: 2px solid var(--surface);
}

/* ---------- icons ---------- */
.i { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.i.fill { fill: currentColor; stroke: none; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px;
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 16px; font-weight: 650;
  white-space: nowrap;
  transition: transform .08s ease, background-color .15s;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.good { background: var(--good); color: #fff; }
.btn.ghost { background: transparent; }
.btn.outline { background: transparent; border: 1.5px solid var(--border); }
.btn.danger { color: var(--danger); }
.btn.block { display: flex; width: 100%; }
.btn.lg { min-height: 56px; font-size: 17px; border-radius: 16px; }
.btn.sm { min-height: 40px; padding: 0 14px; font-size: 14.5px; border-radius: 12px; }
.btn:disabled { opacity: .5; pointer-events: none; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; flex: none; border-radius: 50%;
  color: var(--text-2);
}
.icon-btn:active { background: var(--surface-3); }
.icon-btn.tinted { background: var(--surface-2); }
.icon-btn.accent { background: var(--accent-soft); color: var(--accent-ink); }
.btn-row { display: flex; gap: 10px; }
.btn-row > .btn { flex: 1; }

/* ---------- cards & lists ---------- */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  border: 1px solid transparent;
}
:root[data-theme="dark"] .card { border-color: var(--border); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .card { border-color: var(--border); } }
.card + .card, .card + .section, .section + .card, .section + .section { margin-top: 14px; }
.card-title { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.card-title h2, .card-title h3 { flex: 1; }
.section-label {
  margin: 22px 4px 8px; font-size: 13px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--muted);
}
.list { list-style: none; margin: 0; padding: 0; }
.list > li + li { border-top: 1px solid var(--border); }
.empty { padding: 28px 12px; text-align: center; color: var(--muted); }
.empty .i { width: 40px; height: 40px; margin: 0 auto 10px; display: block; opacity: .6; }

/* ---------- form controls ---------- */
.field { display: block; }
.field + .field { margin-top: 14px; }
.field > span { display: block; font-size: 13.5px; font-weight: 650; color: var(--text-2); margin-bottom: 6px; }
.input, select.input, textarea.input {
  width: 100%; min-height: 48px; padding: 10px 14px;
  border-radius: 12px; border: 1.5px solid var(--border);
  background: var(--surface); font-size: 16px;
  appearance: none;
}
select.input {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 21px, calc(100% - 15px) 21px;
  background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px;
}
textarea.input { min-height: 96px; resize: vertical; }
.input:focus { outline: none; border-color: var(--accent); }

.search {
  position: relative; display: flex; align-items: center;
}
.search .i { position: absolute; left: 14px; color: var(--muted); pointer-events: none; }
.search input {
  width: 100%; height: 50px; padding: 0 44px 0 44px;
  border-radius: 25px; border: 1.5px solid var(--border); background: var(--surface);
  font-size: 16px;
}
.search input:focus { outline: none; border-color: var(--accent); }
.search .clear { position: absolute; right: 3px; }

.chips {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  margin: 10px -16px 0; padding: 2px 16px;
  scroll-padding: 16px;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 38px; padding: 0 15px;
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 19px; border: 1.5px solid var(--border);
  background: var(--surface); color: var(--text-2);
  font-size: 14.5px; font-weight: 600; white-space: nowrap;
}
.chip.on { background: var(--text); border-color: var(--text); color: var(--bg); }
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  height: 28px; padding: 0 11px; border-radius: 14px;
  background: var(--surface-2); color: var(--text-2);
  font-size: 13px; font-weight: 600; white-space: nowrap;
}
.tag.accent { background: var(--accent-soft); color: var(--accent-ink); }
.tag.good { background: var(--good-soft); color: var(--good-ink); }
.tag .i { width: 15px; height: 15px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }

.seg {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  padding: 4px; border-radius: 14px; background: var(--surface-2);
}
.seg button {
  min-height: 40px; border-radius: 11px; font-size: 14.5px; font-weight: 650; color: var(--text-2);
}
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

.switch-row { display: flex; align-items: center; gap: 12px; min-height: 52px; }
.switch-row > div { flex: 1; }
.switch { position: relative; width: 52px; height: 32px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch span {
  position: absolute; inset: 0; border-radius: 16px; background: var(--surface-3); transition: background .2s;
  pointer-events: none;
}
.switch span::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s;
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); }

.stepper { display: inline-flex; align-items: center; border-radius: 12px; background: var(--surface-2); }
.stepper button { width: 44px; height: 44px; font-size: 22px; font-weight: 600; color: var(--text-2); }
.stepper input {
  width: 46px; height: 44px; border: 0; background: transparent; text-align: center;
  font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.stepper input:focus { outline: none; }

/* ---------- home ---------- */
.hello { padding: 6px 4px 4px; }
.hello .date { font-size: 13.5px; color: var(--muted); font-weight: 600; }
.week-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 12px; }
.week-strip div { text-align: center; font-size: 12px; color: var(--muted); font-weight: 600; }
.week-strip b {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; margin: 4px auto 0; border-radius: 50%;
  background: var(--surface-2); color: var(--text-2); font-size: 13px;
}
.week-strip .today b { box-shadow: inset 0 0 0 2px var(--text); }
.week-strip .hit b { color: #fff; }

.live-banner {
  display: flex; align-items: center; gap: 12px;
  margin-top: 14px; padding: 14px 16px; border-radius: var(--radius);
  background: var(--good); color: #fff;
}
.live-banner + .card { margin-top: 14px; }
.live-banner .i { width: 26px; height: 26px; }
.live-banner b { display: block; font-size: 16px; }
.live-banner span { font-size: 13.5px; opacity: .9; }

.day-card { position: relative; padding: 0; overflow: hidden; }
.day-card .stripe { position: absolute; left: 0; top: 0; bottom: 0; width: 6px; }
.day-card .body { padding: 16px 16px 16px 22px; }
.day-card .head { display: flex; align-items: flex-start; gap: 10px; }
.day-card .day-num {
  flex: none; width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 750; font-size: 14px;
}
.day-card h2 { font-size: 19px; line-height: 1.25; }
.day-card .meta { font-size: 13.5px; color: var(--muted); margin-top: 2px; }
.day-card .preview { margin-top: 10px; font-size: 14px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.day-card .actions { display: flex; gap: 10px; margin-top: 14px; }
.day-card .actions .btn.primary { flex: 1; }
.next-tag { margin-left: auto; }

/* ---------- library ---------- */
.lib-head { padding: 0 0 6px; }
.lib-meta { display: flex; align-items: center; gap: 10px; margin: 6px 4px 6px; font-size: 13.5px; color: var(--muted); }
.lib-meta select { width: auto; min-height: 36px; padding: 4px 34px 4px 12px; font-size: 14px; border-radius: 10px; background-position: calc(100% - 18px) 15px, calc(100% - 13px) 15px; }
.ex-row { display: flex; align-items: center; gap: 4px; }
.ex-link { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 10px 0; color: inherit; }
.thumb {
  flex: none; width: 76px; height: 51px; border-radius: 10px; object-fit: cover;
  background: var(--demo-bg);
}
.thumb.ph { display: flex; align-items: center; justify-content: center; color: var(--muted); background: var(--surface-2); }
.thumb.ph .i { width: 26px; height: 26px; }
.ex-name { font-weight: 650; font-size: 15.5px; line-height: 1.3; }
.ex-sub { font-size: 13px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ex-meta { min-width: 0; flex: 1; }
.lib-list { padding: 0 12px; }
.fab {
  position: fixed; right: max(16px, calc(50% - 324px)); bottom: calc(var(--nav-h) + var(--safe-b) + 16px); z-index: 25;
  height: 56px; padding: 0 20px 0 16px; border-radius: 28px;
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 15.5px;
  box-shadow: 0 6px 18px rgba(0,0,0,.22);
}
.pick-bar {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 16px; margin-bottom: 10px;
  border-radius: 14px; background: var(--accent-soft); color: var(--accent-ink); font-weight: 650; font-size: 14.5px;
}
.added { color: var(--good-ink); }

/* ---------- exercise page ---------- */
.demo {
  position: relative; aspect-ratio: 3 / 2; border-radius: var(--radius); overflow: hidden;
  background: var(--demo-bg); margin: 0 -4px;
}
.demo img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain;
  transition: opacity .45s ease;
}
.demo .f1 { opacity: 0; }
.demo.end .f1 { opacity: 1; }
.demo .ctl {
  position: absolute; left: 10px; bottom: 10px;
  display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px 0 10px;
  border-radius: 20px; background: rgba(15, 17, 21, .72); color: #fff; font-size: 13.5px; font-weight: 650;
  backdrop-filter: blur(6px);
}
.demo .ctl .i { width: 20px; height: 20px; }
.demo .frame {
  position: absolute; right: 10px; bottom: 10px; display: flex; gap: 6px;
  padding: 8px 10px; border-radius: 14px; background: rgba(15, 17, 21, .72);
}
.demo .frame i { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,.45); transition: background .3s; }
.demo .frame i.on { background: #fff; }
.demo.ph { display: flex; align-items: center; justify-content: center; color: var(--muted); background: var(--surface-2); }
.demo.ph .i { width: 56px; height: 56px; }
.demo.photo img { object-fit: cover; }

.ex-title { font-size: 23px; font-weight: 780; letter-spacing: -.015em; line-height: 1.2; margin: 16px 4px 10px; }
.steps { margin: 0; padding: 0; list-style: none; counter-reset: s; }
.steps li { counter-increment: s; position: relative; padding: 0 0 0 40px; min-height: 28px; }
.steps li + li { margin-top: 12px; }
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: -1px;
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent-ink); font-size: 13.5px; font-weight: 750;
}
.mm { display: block; width: 100%; max-width: 380px; margin: 0 auto; }
.mm-sil { fill: var(--mm-base); stroke: var(--mm-base); stroke-width: 3.4; stroke-linejoin: round; }
.mm text { fill: var(--muted); font: 600 9px var(--font); text-anchor: middle; }
.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; margin-top: 10px; font-size: 13px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.muscle-names { margin-top: 10px; font-size: 14px; color: var(--text-2); text-align: center; }
.sticky-cta {
  position: sticky; bottom: calc(var(--nav-h) + var(--safe-b) + 12px); z-index: 10; margin-top: 16px;
}
.sticky-cta .btn { box-shadow: 0 6px 18px rgba(0,0,0,.18); }
body.resting .sticky-cta, body.resting .fab { bottom: calc(var(--nav-h) + var(--safe-b) + 88px); }

/* ---------- day editor ---------- */
.tpl-item {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 6px 10px 2px; background: var(--surface);
  position: relative;
}
.tpl-item.dragging { z-index: 5; box-shadow: 0 10px 28px rgba(0,0,0,.25); border-radius: 12px; transition: none; }
.tpl-item.shifting { transition: transform .18s ease; }
.drag-handle { touch-action: none; width: 40px; height: 52px; display: flex; align-items: center; justify-content: center; color: var(--muted); cursor: grab; flex: none; }
.tpl-item .thumb { width: 60px; height: 40px; }
.tpl-item .ex-meta { cursor: pointer; }
.tpl-item .sr { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.mini-step { display: inline-flex; align-items: center; border-radius: 10px; background: var(--surface-2); height: 36px; }
.mini-step button { width: 34px; height: 36px; font-size: 18px; color: var(--text-2); font-weight: 600; }
.mini-step b { min-width: 24px; text-align: center; font-size: 15px; font-variant-numeric: tabular-nums; }
.mini-step small { font-size: 12px; color: var(--muted); padding-right: 2px; }
.tpl-x { font-size: 13px; color: var(--muted); }

/* ---------- logging ---------- */
.log-head { display: flex; align-items: center; gap: 12px; padding: 4px 4px 12px; }
.log-head .clock { font-size: 28px; font-weight: 780; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.log-head .stat { font-size: 13px; color: var(--muted); }
.ex-card { padding: 14px 12px 12px; }
.ex-card .hd { display: flex; align-items: center; gap: 10px; }
.ex-card .hd .thumb { width: 64px; height: 43px; cursor: pointer; }
.ex-card .hd .ttl { flex: 1; min-width: 0; cursor: pointer; }
.ex-card .hd .ttl b { display: block; font-size: 16px; line-height: 1.25; }
.ex-card .sub { display: flex; align-items: center; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.rest-chip {
  display: inline-flex; align-items: center; gap: 4px; height: 30px; padding: 0 10px;
  border-radius: 15px; background: var(--surface-2); color: var(--text-2); font-size: 13px; font-weight: 650;
}
.rest-chip .i { width: 15px; height: 15px; }
.sets { margin-top: 10px; }
.set-row {
  display: grid; grid-template-columns: 36px minmax(0, 1fr) 72px 60px 48px; gap: 6px; align-items: center;
  min-height: 52px; padding: 3px 2px; border-radius: 12px;
}
.set-row.edit { grid-template-columns: 36px minmax(0, 1fr) minmax(0, 1fr) 46px; }
.set-row.head { min-height: 26px; font-size: 11.5px; font-weight: 750; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.set-row.head > * { text-align: center; }
.set-row.head > :nth-child(2) { text-align: left; padding-left: 4px; }
.set-row.done { background: var(--good-soft); }
.set-n {
  height: 40px; border-radius: 10px; font-weight: 750; font-size: 15px; color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
}
.set-n.w { background: var(--warmup-soft); color: var(--warmup); }
.prev { font-size: 13.5px; color: var(--muted); padding-left: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.prev .pr { color: var(--accent-ink); font-weight: 700; }
.num {
  width: 100%; height: 44px; border-radius: 10px; border: 1.5px solid transparent;
  background: var(--surface-2); text-align: center; font-size: 18px; font-weight: 700;
  font-variant-numeric: tabular-nums; padding: 0 4px;
}
.num:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.num::placeholder { color: var(--muted); font-weight: 500; opacity: .7; }
.set-row.done .num { background: transparent; }
.prev .pr { display: inline-flex; align-items: center; gap: 3px; }
.prev .pr .i { width: 15px; height: 15px; }
.tick {
  width: 46px; height: 44px; border-radius: 12px; justify-self: end;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); color: var(--muted);
}
.tick .i { width: 24px; height: 24px; stroke-width: 2.6; }
.set-row.done .tick { background: var(--good); color: #fff; }
.tick.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.set-actions { display: flex; gap: 8px; margin-top: 8px; }
.set-actions .btn { flex: 1; }
.hint { font-size: 12.5px; color: var(--muted); margin: 8px 4px 0; }

.restbar {
  position: fixed; left: 8px; right: 8px; z-index: 28;
  bottom: calc(var(--nav-h) + var(--safe-b) + 8px);
  max-width: 664px; margin: 0 auto;
  display: flex; align-items: center; gap: 6px;
  padding: 10px 10px 10px 16px; border-radius: 18px;
  background: var(--text); color: var(--bg);
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  overflow: hidden;
}
.restbar .bar { position: absolute; left: 0; top: 0; height: 4px; background: var(--accent); transition: width .25s linear; }
.restbar .t { font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums; min-width: 82px; }
.restbar .l { font-size: 12px; opacity: .7; font-weight: 600; line-height: 1.2; flex: 1; min-width: 0; }
.restbar .l b { display: block; font-size: 13.5px; opacity: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.restbar button { height: 44px; min-width: 48px; padding: 0 10px; border-radius: 12px; background: rgba(127,127,127,.22); font-weight: 700; font-size: 14.5px; }
.restbar.over { background: var(--good); color: #fff; animation: pulse 1s ease-in-out 3; }
@keyframes pulse { 50% { transform: scale(1.03); } }

/* ---------- summary ---------- */
.hero { text-align: center; padding: 18px 8px 8px; }
.hero .badge-big {
  width: 76px; height: 76px; margin: 0 auto 12px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent-ink);
}
.hero .badge-big .i { width: 40px; height: 40px; }
.hero h1 { font-size: 26px; font-weight: 800; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-tile { background: var(--surface-2); border-radius: 14px; padding: 12px 14px; }
.stat-tile .k { font-size: 12.5px; color: var(--muted); font-weight: 650; }
.stat-tile .v { font-size: 22px; font-weight: 780; margin-top: 2px; letter-spacing: -.01em; }
.stat-tile .v small { font-size: 13px; font-weight: 600; color: var(--muted); }
.pr-item { display: flex; gap: 12px; padding: 10px 0; align-items: flex-start; }
.pr-item .medal {
  flex: none; width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent-ink);
}
.pr-item .medal .i { width: 20px; height: 20px; }

/* ---------- history ---------- */
.cal-head { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.cal-head h2 { flex: 1; text-align: center; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .dow { text-align: center; font-size: 11.5px; font-weight: 700; color: var(--muted); padding: 4px 0; }
.cal .d {
  aspect-ratio: 1; border-radius: 12px; position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  padding-top: 6px; font-size: 13.5px; font-weight: 600; color: var(--text-2);
}
.cal .d.out { visibility: hidden; }
.cal .d.today { box-shadow: inset 0 0 0 2px var(--text); }
.cal .d.sel { background: var(--surface-3); }
.cal .d .dots { display: flex; gap: 2px; margin-top: 3px; }
.cal .d .dots b {
  width: 19px; height: 19px; border-radius: 50%; font-size: 11px; font-weight: 800; color: #fff;
  display: flex; align-items: center; justify-content: center; border: 2px solid var(--surface);
}
.cal .d .dots b + b { margin-left: -9px; }
.day-legend { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 12px; font-size: 13px; color: var(--text-2); }
.day-legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot-n {
  width: 20px; height: 20px; border-radius: 50%; color: #fff; font-size: 11px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.sess-row { display: flex; align-items: center; gap: 12px; padding: 12px 2px; color: inherit; }
.sess-row .dot-n { width: 34px; height: 34px; font-size: 14px; }
.sess-row .grow { flex: 1; min-width: 0; }
.sess-row b { display: block; font-size: 15.5px; }
.sess-row .small { color: var(--muted); }

/* ---------- progress ---------- */
.chart { position: relative; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.chart canvas { display: block; width: 100%; }
.chart .tip {
  position: absolute; top: 0; pointer-events: none; z-index: 2;
  padding: 6px 10px; border-radius: 10px; white-space: nowrap;
  background: var(--text); color: var(--bg); font-size: 12.5px; font-weight: 650; line-height: 1.35;
  transform: translateX(-50%);
}
.chart .tip span { display: block; font-weight: 500; opacity: .75; font-size: 11.5px; }
.chart-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.chart-head h3 { flex: 1; }
.chart-head .val { font-size: 20px; font-weight: 780; }
.chart-head .val small { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.chart-legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--text-2); margin: 2px 0 6px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend .ln { width: 16px; height: 2px; border-radius: 1px; display: inline-block; }
.chart-legend .pt { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.range { display: flex; gap: 6px; }
.range button {
  height: 34px; min-width: 44px; padding: 0 10px; border-radius: 10px; font-size: 13.5px; font-weight: 700;
  color: var(--text-2); background: var(--surface-2);
}
.range button.on { background: var(--text); color: var(--bg); }
.prog-row { display: flex; align-items: center; gap: 12px; padding: 12px 2px; color: inherit; }
.prog-row .grow { flex: 1; min-width: 0; }
.prog-row b { display: block; font-size: 15px; line-height: 1.3; }
.prog-row .small { color: var(--muted); }
.spark { width: 76px; height: 30px; flex: none; }
.spark polyline { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark circle { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.records { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hist-sets { font-size: 14px; color: var(--text-2); margin-top: 3px; font-variant-numeric: tabular-nums; }

.mg-row { padding: 7px 0; }
.mg-top { display: flex; align-items: baseline; gap: 8px; }
.mg-row .lbl { flex: 1; font-size: 14.5px; font-weight: 650; }
.mg-row .n { font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.mg-row .track { height: 10px; margin-top: 6px; border-radius: 0 5px 5px 0; background: var(--surface-2); position: relative; overflow: hidden; }
.mg-row .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 0 4px 4px 0; background: var(--accent); }
.mg-row.zero .lbl, .mg-row.zero .n { color: var(--muted); font-weight: 500; }
.matrix { display: grid; gap: 3px; font-size: 11.5px; }
.matrix .lbl { font-size: 12.5px; color: var(--text-2); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 4px; align-self: center; }
.matrix .wk { text-align: center; color: var(--muted); font-weight: 650; font-size: 10.5px; }
.matrix .c { height: 22px; border-radius: 5px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-weight: 750; font-size: 11px; }
.heat-legend { display: flex; align-items: center; justify-content: center; gap: 4px; margin-top: 10px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.heat-legend i { width: 18px; height: 12px; border-radius: 3px; display: inline-block; }
.bw-entry { display: flex; gap: 10px; align-items: flex-end; }
.bw-entry .field { flex: 1; margin: 0; }

/* ---------- sheet / dialog / toast ---------- */
.scrim {
  position: fixed; inset: 0; z-index: 60; background: var(--scrim);
  opacity: 0; transition: opacity .2s;
}
.scrim.open { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 61;
  max-width: 680px; margin: 0 auto; max-height: calc(90dvh / var(--zoom, 1)); overflow-y: auto; overscroll-behavior: contain;
  padding: 8px 16px calc(18px + var(--safe-b));
  background: var(--surface); border-radius: 22px 22px 0 0;
  transform: translateY(100%); transition: transform .24s cubic-bezier(.2, .8, .2, 1);
}
.sheet.open { transform: none; }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--surface-3); margin: 2px auto 10px; }
.sheet h2 { font-size: 19px; margin: 4px 4px 4px; }
.sheet .msg { color: var(--text-2); margin: 4px 4px 14px; }
.sheet .opts > * + * { margin-top: 8px; }
.sheet .opt {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 8px 14px;
  border-radius: 14px; background: var(--surface-2); text-align: left; font-weight: 650; font-size: 16px;
}
.sheet .opt .grow { flex: 1; min-width: 0; }
.sheet .opt small { display: block; font-weight: 500; font-size: 13px; color: var(--muted); }
.sheet .opt.on { box-shadow: inset 0 0 0 2px var(--good); }
.sheet .opt .ok { color: var(--good-ink); }
.sheet .opt > .i { color: var(--text-2); }
.sheet .opt.danger-opt, .sheet .opt.danger-opt > .i { color: var(--danger); }
.sheet .opt:disabled { opacity: .4; }
.sheet .opt .dot-n { width: 32px; height: 32px; font-size: 14px; }
.sheet .demo { margin: 0; }
.dot-n .i { width: 16px; height: 16px; }
.icon-btn:disabled { opacity: .35; pointer-events: none; }
.stepper output { min-width: 58px; text-align: center; font-size: 17px; font-weight: 750; font-variant-numeric: tabular-nums; }
.link { color: var(--accent-ink); font-weight: 700; text-transform: none; letter-spacing: 0; font-size: 13px; padding: 4px 2px; }
.sess-row .small, .prog-row .small { display: block; }
.i.small { width: 15px; height: 15px; vertical-align: -3px; }
img.img-missing { opacity: 0; }
.demo:has(img.img-missing)::after {
  content: "Photo not saved for offline yet"; position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center; padding: 16px; text-align: center;
  color: #5b6472; font-size: 14px; font-weight: 600;
}

.toast-wrap {
  position: fixed; left: 0; right: 0; z-index: 80; pointer-events: none;
  bottom: calc(var(--nav-h) + var(--safe-b) + 14px);
  display: flex; justify-content: center; padding: 0 12px;
}
body.resting .toast-wrap { bottom: calc(var(--nav-h) + var(--safe-b) + 92px); }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px;
  max-width: 560px; min-height: 48px; padding: 8px 8px 8px 16px; border-radius: 14px;
  background: var(--text); color: var(--bg); font-size: 15px; font-weight: 550;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  transform: translateY(20px); opacity: 0; transition: transform .2s, opacity .2s;
}
.toast.show { transform: none; opacity: 1; }
.toast button { padding: 0 12px; height: 36px; border-radius: 10px; color: var(--accent-soft); font-weight: 750; background: transparent; }
.toast span { padding: 6px 0; }

.progress-line { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin-top: 10px; }
.progress-line div { height: 100%; background: var(--accent); width: 0; transition: width .3s; }

.about p + p { margin-top: 10px; }
.about a { font-weight: 650; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* ---------- accounts ---------- */
body.auth-mode .tabbar, body.auth-mode .restbar { display: none !important; }
body.auth-mode #view { padding-bottom: 32px; }
.auth-wrap {
  max-width: 420px; margin: 0 auto; padding: 32px 0 24px;
  min-height: calc(100dvh / var(--zoom, 1)); display: flex; flex-direction: column; justify-content: center;
}
.auth-brand { text-align: center; margin-bottom: 20px; }
.auth-brand img { margin: 0 auto 10px; border-radius: 16px; }
.auth-brand h1 { font-size: 24px; font-weight: 800; letter-spacing: -.01em; }
.form-error { color: var(--danger); font-size: 14px; font-weight: 600; }
.avatar {
  flex: none; width: 44px; height: 44px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent-ink); font-weight: 800; font-size: 18px;
}
.sync-box {
  display: flex; align-items: center; gap: 10px; margin: 14px 0; padding: 10px 12px;
  border-radius: 12px; background: var(--surface-2); color: var(--text-2); font-size: 14px; font-weight: 550;
}
.sync-box .i { width: 20px; height: 20px; color: var(--muted); }
.login-details { display: grid; gap: 2px; padding: 14px 16px; border-radius: 14px; background: var(--surface-2); }
.login-details b { font-size: 16px; word-break: break-all; }
.login-details .small { margin-top: 8px; }
.login-details .small:first-child { margin-top: 0; }
.mono { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; letter-spacing: .02em; }
.user-row { width: 100%; text-align: left; }
#sync-ind { color: var(--warmup); }
