/*
VOICE: a coach's app on a client's phone — direct, energetic, no clutter.
IDEA: a gym whiteboard brought to life: the day's plan, with a moving figure showing each lift.
PICTURE: the animated demo stage — warm orange-tinted panel, ink figure, orange equipment.
COLOUR and TYPE: white and ink, one hot orange; Archivo wide/heavy for titles, Inter for text.
LAYOUT: single phone column, bottom tab bar; library goes to a grid on wide screens.
*/
:root {
  color-scheme: light dark;
  --bg: #ffffff; --ink: #121416; --mute: #5d636a; --card: #f4f4f2; --line: #e3e3df;
  --acc: #ff5a1f; --acc-2: #e04510; --on-acc: #ffffff; --soft: #fff0e8;
  --stage: #fff0e8; --fig: #16181b; --far: #bdb7b0; --eq: #ff5a1f; --over: #d92d20;
  --r: 16px; --tabh: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) {
    --bg: #0f1113; --ink: #f2f3f4; --mute: #9da3a9; --card: #1a1d20; --line: #2b2f33;
    --soft: #2a1c15; --stage: #221c18; --fig: #f4f4f4; --far: #6d655e; --eq: #ff6a33; --over: #ff6b5e;
  }
}
:root[data-theme=dark] {
  color-scheme: dark;
  --bg: #0f1113; --ink: #f2f3f4; --mute: #9da3a9; --card: #1a1d20; --line: #2b2f33;
  --soft: #2a1c15; --stage: #221c18; --fig: #f4f4f4; --far: #6d655e; --eq: #ff6a33; --over: #ff6b5e;
}
:root[data-theme=light] { color-scheme: light; }

* { box-sizing: border-box; min-width: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow-x: clip; padding-bottom: calc(var(--tabh) + var(--safe-b) + 24px);
  -webkit-tap-highlight-color: transparent;
}
body.resting { padding-bottom: calc(var(--tabh) + var(--safe-b) + 96px); }
body.locked { overflow: hidden; }
main { max-width: 640px; margin: 0 auto; padding: calc(var(--safe-t) + 20px) 16px 0; }
main.v-library { max-width: 1080px; }
h1, h2, h3 { font-family: Archivo, Inter, sans-serif; font-stretch: 112%; line-height: 1.05; margin: 0; text-wrap: balance; }
h1 { font-size: clamp(32px, 8vw, 44px); font-weight: 850; letter-spacing: -0.01em; }
h2 { font-size: 22px; font-weight: 800; }
h3 { font-size: 17px; font-weight: 800; margin-top: 20px; }
p { margin: 0; }
a { color: var(--acc-2); }
.sub { color: var(--mute); margin-top: 6px; }
.fine { color: var(--mute); font-size: 13px; margin: 20px 4px 8px; }
.kicker { color: var(--mute); font-size: 14px; font-weight: 500; margin-bottom: 4px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.i { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* controls */
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--acc); outline-offset: 2px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: 12px; border: 0;
  background: var(--card); font-weight: 600; white-space: nowrap;
}
.btn.primary { background: var(--acc); color: var(--on-acc); }
.btn.primary:active { background: var(--acc-2); }
.btn.ghost { background: transparent; border: 1.5px solid var(--line); }
.btn.sm { min-height: 40px; padding: 0 12px; font-size: 15px; }
.btn.sm .i { width: 18px; height: 18px; }
.btn.wide { width: 100%; margin-top: 20px; min-height: 52px; font-size: 17px; }
.icon-btn { width: 44px; height: 44px; display: inline-grid; place-items: center; border-radius: 12px; border: 0; background: transparent; }
.icon-btn:disabled { opacity: .3; cursor: default; }
.link { background: none; border: 0; padding: 0; color: var(--acc-2); text-decoration: underline; font-weight: 600; }
input, select {
  width: 100%; min-height: 44px; padding: 8px 12px; font-size: 16px;
  border-radius: 10px; border: 1.5px solid var(--line); background: var(--bg);
}
input:focus, select:focus { border-color: var(--acc); outline: none; }
label { display: grid; gap: 4px; font-size: 14px; font-weight: 600; color: var(--mute); }
label input, label select { color: var(--ink); font-weight: 400; }

/* header */
.top { margin-bottom: 16px; }
.top.row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.daynav { display: flex; gap: 2px; margin-bottom: -6px; }
.prog { display: flex; align-items: center; gap: 12px; margin-top: 16px; font-size: 14px; color: var(--mute); }
.prog span { white-space: nowrap; }
.track { flex: 1; height: 8px; border-radius: 8px; background: var(--card); overflow: hidden; }
.track i { display: block; height: 100%; background: var(--acc); border-radius: 8px; transition: width .4s ease; }
.note { background: var(--soft); border-radius: var(--r); padding: 14px 16px; margin-bottom: 16px; }
.note b { font-size: 14px; }
.note p { margin-top: 2px; }

/* demo stage */
.stage { display: block; background: var(--stage); border-radius: 14px; aspect-ratio: 4 / 3; overflow: hidden; }
.demo svg { display: block; width: 100%; height: 100%; }
.fig .lm { fill: none; stroke: var(--fig); stroke-width: 8.5; stroke-linecap: round; stroke-linejoin: round; }
.fig .far { stroke: var(--far); }
.fig .tor { fill: none; stroke: var(--fig); stroke-width: 13; stroke-linecap: round; }
.fig .hd { fill: var(--fig); }
.fig .gnd { stroke: var(--far); stroke-width: 2; opacity: .6; }
.fig .eq circle { fill: var(--eq); }
.fig .eq.far circle { fill: var(--eq); opacity: .45; }
.fig .kb .ring { fill: none; stroke: var(--eq); stroke-width: 3; }
.fig .bb .hub { fill: var(--stage); }
.fig .bench { fill: var(--far); }
.fig .bleg, .fig .bar, .fig .cab { stroke: var(--far); stroke-width: 4; stroke-linecap: round; }
.fig .cab { stroke-width: 2; }

/* exercise list */
.exlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.ex { border: 1.5px solid var(--line); border-radius: var(--r); background: var(--bg); overflow: hidden; }
.ex.open { border-color: var(--ink); }
.ex-head { width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: none; border: 0; text-align: left; min-height: 64px; }
.thumb { width: 64px; flex: none; aspect-ratio: 4 / 3; border-radius: 10px; background: var(--stage); overflow: hidden; }
.ex.open .thumb { display: none; }
.ex-t { flex: 1; display: grid; }
.ex-t b { font-size: 17px; line-height: 1.25; }
.ex-t small { color: var(--mute); font-size: 14px; }
.badge { flex: none; min-width: 44px; height: 32px; padding: 0 10px; display: grid; place-items: center; border-radius: 16px; background: var(--card); font-size: 14px; font-weight: 600; }
.ex.complete .badge { background: var(--acc); color: var(--on-acc); }
.ex.complete .badge .i { width: 18px; height: 18px; stroke-width: 3; }
.ex.open .ex-t b { font-size: 20px; }
.ex-body { padding: 0 12px 14px; }
.cue { margin: 10px 2px 0; color: var(--mute); }

.sets { width: 100%; border-collapse: collapse; margin-top: 10px; font-variant-numeric: tabular-nums; }
.sets th { font-size: 13px; font-weight: 600; color: var(--mute); text-align: left; padding: 6px 4px; }
.sets td { padding: 4px; }
.sets th:nth-child(3), .sets th:nth-child(4) { text-align: center; }
.sets .n { width: 34px; font-weight: 700; padding-left: 8px; }
.sets .prev { color: var(--mute); font-size: 14px; white-space: nowrap; }
.cell { text-align: center; padding: 8px 4px; max-width: 84px; margin: 0 auto; display: block; }
.chk { width: 44px; height: 44px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--bg); display: grid; place-items: center; color: var(--mute); }
.chk[aria-pressed=true] { background: var(--acc); border-color: var(--acc); color: var(--on-acc); }
.chk .i { stroke-width: 3; }
tr.done td { background: var(--soft); }
tr.done td:first-child { border-radius: 10px 0 0 10px; }
tr.done td:last-child { border-radius: 0 10px 10px 0; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* rest timer */
.rest {
  position: fixed; left: 50%; bottom: calc(var(--tabh) + var(--safe-b) + 10px); z-index: 30;
  width: min(608px, calc(100% - 24px)); transform: translate(-50%, 140%); transition: transform .25s ease;
  background: var(--ink); color: var(--bg); border-radius: 16px; overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
.rest.on { transform: translate(-50%, 0); }
.rest-bar { height: 4px; background: rgba(127,127,127,.35); }
.rest-bar i { display: block; height: 100%; background: var(--acc); transition: width .25s linear; }
.rest-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px 8px 14px; }
.rest-t { font: 800 26px/1 Archivo, sans-serif; font-variant-numeric: tabular-nums; }
.rest-l { flex: 1; opacity: .7; font-size: 14px; }
.rest .btn.ghost { border-color: rgba(127,127,127,.5); color: inherit; }
.rest .btn:not(.ghost) { background: var(--acc); color: var(--on-acc); }

/* library */
.search { position: relative; display: block; }
.search .i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--mute); }
.search input { padding-left: 42px; min-height: 48px; border-radius: 12px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 12px 0 4px; scrollbar-width: none; }
.chip { flex: none; min-height: 40px; padding: 0 16px; border-radius: 20px; border: 1.5px solid var(--line); background: var(--bg); font-weight: 600; font-size: 15px; }
.chip[aria-pressed=true] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
@media (min-width: 720px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1000px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.card { display: grid; gap: 8px; padding: 0; border: 0; background: none; text-align: left; }
.card-t { display: grid; padding: 0 2px; }
.card-t b { font-size: 15px; line-height: 1.3; }
.card-t small { color: var(--mute); font-size: 13px; }
.card:hover .stage { outline: 2px solid var(--acc); }
.empty { color: var(--mute); padding: 24px 4px; text-align: center; grid-column: 1 / -1; }
.cues { padding-left: 22px; margin: 8px 0 0; }
.cues li { padding: 4px 0; }
.stage.big { margin: 0 -2px 16px; }

/* sheets */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; }
.scrim { position: absolute; inset: 0; background: rgba(10,10,10,.45); opacity: 0; transition: opacity .2s; }
.sheet {
  position: absolute; left: 50%; bottom: 0; width: min(640px, 100%); max-height: 92vh; max-height: 92dvh; overflow: auto;
  background: var(--bg); border-radius: 22px 22px 0 0; padding: 20px 18px calc(24px + var(--safe-b));
  transform: translate(-50%, 100%); transition: transform .22s ease; overscroll-behavior: contain;
}
.sheet.tall { min-height: 70vh; min-height: 70dvh; }
.sheet-wrap.open .scrim { opacity: 1; }
.sheet-wrap.open .sheet { transform: translate(-50%, 0); }
.sheet-x { position: sticky; top: -8px; float: right; margin: -8px -8px 0 8px; background: var(--card); z-index: 2; }
.sheet h2 { padding-right: 48px; }
@media (min-width: 700px) {
  .sheet { bottom: auto; top: 50%; border-radius: 22px; transform: translate(-50%, -46%); opacity: 0; transition: transform .22s ease, opacity .22s; }
  .sheet-wrap.open .sheet { transform: translate(-50%, -50%); opacity: 1; }
}
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 16px; }
.stats div, .m4 div { background: var(--card); border-radius: 12px; padding: 12px; display: grid; }
.stats b, .m4 b { font: 800 24px/1.1 Archivo, sans-serif; font-variant-numeric: tabular-nums; }
.stats span, .m4 span { color: var(--mute); font-size: 13px; }
.plain { padding-left: 20px; }

/* nutrition */
.sum { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 20px; align-items: center; background: var(--soft); border-radius: 20px; padding: 18px; }
.ring { position: relative; aspect-ratio: 1; }
.ring svg { width: 100%; height: 100%; display: block; }
.ring .rt { fill: none; stroke: var(--bg); stroke-width: 12; }
.ring .rv { fill: none; stroke: var(--acc); stroke-width: 12; stroke-linecap: round; transition: stroke-dashoffset .5s ease; }
.ring.over .rv { stroke: var(--over); }
.ring-c { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring-c strong { font: 850 clamp(28px, 7vw, 34px)/1 Archivo, sans-serif; font-stretch: 110%; font-variant-numeric: tabular-nums; }
.ring-c span { font-size: 13px; color: var(--mute); }
.ring.over .ring-c strong { color: var(--over); }
.eaten { font-size: 14px; color: var(--mute); margin-bottom: 8px; }
.eaten b { color: var(--ink); font-size: 16px; }
.mac { margin-top: 8px; }
.mac-h { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 4px; gap: 8px; }
.mac-h span { color: var(--mute); white-space: nowrap; font-variant-numeric: tabular-nums; }
.mac-h strong { color: var(--ink); }
.mac .track { background: var(--bg); }
.mac.over .track i { background: var(--over); }
@media (max-width: 420px) { .sum { grid-template-columns: 1fr; } .ring { width: 170px; margin: 0 auto; } }

.meal { margin-top: 22px; }
.meal-h { display: flex; align-items: center; gap: 10px; padding-bottom: 6px; border-bottom: 2px solid var(--ink); }
.meal-h h2 { font-size: 20px; flex: 1; }
.meal-h span { color: var(--mute); font-size: 14px; white-space: nowrap; }
.ents { list-style: none; margin: 0; padding: 0; }
.ents li { display: flex; align-items: center; border-bottom: 1px solid var(--line); }
.ent { flex: 1; display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 10px 4px; background: none; border: 0; text-align: left; min-height: 56px; }
.ent-n, .ent-k { display: grid; }
.ent-n b { font-weight: 600; line-height: 1.3; }
.ent small { color: var(--mute); font-size: 13px; }
.ent-k { text-align: right; font-variant-numeric: tabular-nums; }
.ent-k small { white-space: nowrap; }
.del { color: var(--mute); }

.seg { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; background: var(--card); border-radius: 14px; padding: 4px; margin: 16px 0; }
.seg button { min-height: 52px; border: 0; border-radius: 10px; background: none; display: grid; justify-items: center; gap: 2px; font-size: 13px; font-weight: 600; color: var(--mute); padding: 4px 2px; }
.seg button[aria-selected=true] { background: var(--bg); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.seg[hidden] { display: none; }
.banner { background: var(--soft); border-radius: 12px; padding: 10px 12px; margin-top: 10px; font-size: 14px; }
.results { list-style: none; margin: 8px 0 0; padding: 0; }
.results button { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 4px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; min-height: 56px; }
.results span { display: grid; }
.results small { color: var(--mute); font-size: 13px; }
.results .kc { text-align: right; flex: none; font-variant-numeric: tabular-nums; }
.reader { background: #111; color: #ddd; border-radius: 14px; min-height: 220px; display: grid; place-items: center; overflow: hidden; text-align: center; padding: 0; }
.reader p { padding: 20px; font-size: 14px; }
.reader video { width: 100% !important; display: block; }
.inline { display: flex; gap: 8px; margin-top: 14px; }
.inline input { flex: 1; }
.status { font-size: 14px; color: var(--mute); margin-top: 10px; min-height: 1.5em; }
.form { display: grid; gap: 12px; margin-top: 14px; }
.cols4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 460px) { .cols4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.editor .back { margin-bottom: 12px; }
.amt { display: grid; grid-template-columns: 1fr 1.6fr; gap: 10px; margin-top: 16px; }
.m4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin: 14px 0; }
.m4 b { font-size: 20px; }
.m4 div:first-child { background: var(--acc); color: var(--on-acc); }
.m4 div:first-child span { color: inherit; opacity: .85; }
.full { margin-top: 4px; }

/* tab bar */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: flex; justify-content: center;
  background: var(--bg); border-top: 1px solid var(--line); padding-bottom: var(--safe-b);
}
.tabs a {
  flex: 1; max-width: 200px; height: var(--tabh); display: grid; place-content: center; justify-items: center; gap: 2px;
  color: var(--mute); text-decoration: none; font-size: 13px; font-weight: 600;
}
.tabs a[aria-current=page] { color: var(--ink); }
.tabs a[aria-current=page] .i { color: var(--acc); stroke-width: 2.4; }

#toast {
  position: fixed; left: 50%; top: calc(var(--safe-t) + 12px); z-index: 60; transform: translate(-50%, -150%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 15px;
  transition: transform .25s ease; max-width: calc(100% - 32px);
}
#toast.show { transform: translate(-50%, 0); }

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