:root {
  --bg:#121614; --card:#1c2320; --card2:#27302c; --line:#35403b; --text:#f1f5f2; --muted:#92a39a;
  --acc:#b7f34a; --accText:#122007; --good:#43d17f; --bad:#ff5d5d; --gold:#ffc53d;
  --num:"Avenir Next Condensed","Roboto Condensed","Arial Narrow",sans-serif-condensed,Impact,sans-serif;
  --tap:56px;
}
* { box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
html, body { margin:0; background:var(--bg); color:var(--text); }
body {
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif; line-height:1.4;
  /* the 24px keeps content clear of iOS's translucent status bar (the meal planner needed the same) */
  padding:calc(24px + env(safe-area-inset-top,0px)) env(safe-area-inset-right,0px) calc(84px + max(0px, calc(env(safe-area-inset-bottom,0px) - 16px))) env(safe-area-inset-left,0px);
  /* always slightly scrollable: on iOS a page that can't scroll gets a window ~68pt short of the screen */
  min-height:calc(100vh + 1px);
}
input, textarea, select { -webkit-user-select:text; user-select:text; }
button { font:inherit; color:inherit; border:none; background:none; cursor:pointer; touch-action:manipulation; }
a { color:inherit; }
.hidden { display:none !important; }
.num { font-family:var(--num); font-weight:800; }
.muted { color:var(--muted); }
.wrap { max-width:560px; margin:0 auto; padding:0 16px; }
h1 { font-family:var(--num); font-weight:800; font-size:2.1rem; margin:.1em 0 .5em; text-transform:uppercase; letter-spacing:.01em; line-height:1.05; }
h2 { font-family:var(--num); font-weight:800; font-size:1.15rem; margin:1.4em 0 .5em; text-transform:uppercase; color:var(--muted); letter-spacing:.05em; }
p { margin:.4em 0; }

/* bottom nav: same compact bar as the meal planner, so the home-indicator area isn't padded twice */
.nav {
  position:fixed; left:0; right:0; bottom:0; z-index:30; display:flex; align-items:stretch;
  background:#1c2320; /* opaque, no backdrop-filter: iOS mis-places blurred fixed bars while scrolling */
  -webkit-transform:translateZ(0); transform:translateZ(0);
  border-top:1px solid var(--line); padding:6px 4px max(6px, calc(env(safe-area-inset-bottom,0px) - 16px));
}
.nav a { flex:1; min-width:0; display:flex; flex-direction:column; align-items:center; gap:2px; padding:4px 0;
  text-decoration:none; color:var(--muted); font-size:.68rem; font-weight:600; border-radius:10px; }
.nav a span { display:block; font-size:1.35rem; line-height:1.1; filter:grayscale(1); opacity:.7; }
.nav a.on { color:var(--acc); }
.nav a.on span { filter:none; opacity:1; }

/* buttons: 44px is the floor, most are bigger */
.btn {
  display:flex; align-items:center; justify-content:center; gap:8px; width:100%;
  min-height:var(--tap); border-radius:999px; font-weight:700; font-size:1.1rem;
  background:var(--card2); color:var(--text); padding:0 18px;
}
.btn.primary { background:var(--acc); color:var(--accText); }
.btn.danger { background:#4a2323; color:#ffb4b4; }
.btn.ghost { background:none; border:1px solid var(--line); }
.btn.small { min-height:44px; font-size:1rem; width:auto; }
.btn:active { transform:scale(.98); filter:brightness(1.12); }
.btn[disabled] { opacity:.4; }
.icon-btn { width:44px; height:44px; border-radius:50%; background:var(--card2); font-size:1.15rem; display:grid; place-items:center; flex:none; }
.card { background:var(--card); border-radius:22px; padding:16px; }
.stack > * + * { margin-top:12px; }
.row { display:flex; gap:10px; align-items:center; }
.row > .grow { flex:1; min-width:0; }

/* page header */
.top { display:flex; align-items:center; gap:10px; margin-bottom:10px; }
.top h1 { margin:0; flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.back { width:44px; height:44px; border-radius:50%; background:var(--card); font-size:1.4rem; display:grid; place-items:center; text-decoration:none; flex:none; }

/* home: workouts */
.resume { background:linear-gradient(135deg, var(--acc), #7ee06a); color:var(--accText); border-radius:22px; padding:16px; display:block; text-decoration:none; margin-bottom:14px; }
.resume b { font-family:var(--num); font-size:1.5rem; text-transform:uppercase; display:block; }
.week { color:var(--muted); font-weight:600; margin:0 0 14px; }
.wcard { background:var(--card); border-radius:22px; padding:14px 14px 14px 16px; display:flex; gap:10px; align-items:center; }
.wcard + .wcard { margin-top:10px; }
.wcard .t { flex:1; min-width:0; }
.wcard .t b { display:block; font-size:1.15rem; }
.wcard .t small { display:block; color:var(--muted); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.wcard .go { background:var(--acc); color:var(--accText); font-weight:800; border-radius:999px; min-height:48px; padding:0 20px; font-size:1.05rem; }
.hint { background:var(--card); border-radius:18px; padding:14px 14px 14px 16px; display:flex; gap:10px; align-items:flex-start; margin-bottom:14px; }
.hint .x { margin-left:auto; flex:none; }
.hint ol { margin:.3em 0 0; padding-left:1.2em; color:var(--muted); }

/* the live workout */
.livebar { position:sticky; top:0; z-index:20; margin:0 -16px 12px; padding:calc(24px + env(safe-area-inset-top,0px)) 16px 10px;   /* clears iOS's top edge blur, like the other pages */
  background:color-mix(in srgb, var(--bg) 94%, transparent); backdrop-filter:blur(10px); display:flex; align-items:center; gap:10px; border-bottom:1px solid var(--line); }
.livebar .nm { flex:1; min-width:0; }
.livebar .nm b { display:block; font-size:1.05rem; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.livebar .nm small { color:var(--muted); font-weight:600; font-variant-numeric:tabular-nums; }
.livebar .rest { color:var(--acc); }
body.live { padding-top:0; }
.ex { margin-bottom:10px; padding:12px; }
.ex header { display:flex; align-items:center; gap:8px; }
.ex header b { flex:1; font-size:1.15rem; min-width:0; }
.ex header .icon-btn { margin:-4px -4px -4px 0; }
.ex .last { color:var(--muted); font-size:.85rem; margin:0 0 8px; }
.chip { display:inline-flex; align-items:center; gap:6px; background:rgba(183,243,74,.14); color:var(--acc); border-radius:999px; padding:0 14px; min-height:44px; font-weight:700; margin:0 0 8px; }
.sets > * + * { margin-top:6px; }
/* one box per set: the row and its editor share a single border, so nothing overlaps */
.setbox { background:var(--card2); border-radius:16px; border:2px solid transparent; }
.setbox.done { background:rgba(67,209,127,.16); }
.setbox.open { border-color:var(--acc); }
.set { display:flex; align-items:center; gap:8px; padding:2px 4px 2px 8px; min-height:52px; }
.set .i { width:24px; text-align:center; color:var(--muted); font-weight:800; font-family:var(--num); font-size:1.15rem; flex:none; }
.set .v { flex:1; font-family:var(--num); font-weight:800; font-size:1.5rem; text-align:left; min-height:44px; display:flex; align-items:center; font-variant-numeric:tabular-nums; }
.set .v small { color:var(--muted); font-size:.85rem; font-weight:600; margin:0 6px; }
.set .tick { width:44px; height:44px; border-radius:50%; background:var(--bg); border:2px solid var(--line); display:grid; place-items:center; font-size:1.3rem; color:transparent; flex:none; }
.setbox.done .tick { background:var(--good); border-color:var(--good); color:#062313; }
.editor { padding:2px 10px 10px; }
.editor .lbl { font-size:.72rem; font-weight:700; color:var(--muted); text-transform:uppercase; letter-spacing:.05em; margin:6px 0 3px; }
.edgrid { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.step { display:flex; align-items:center; gap:4px; }
.step button { width:44px; height:52px; border-radius:14px; background:var(--card); font-size:1.6rem; font-weight:700; flex:none; }
.step input { flex:1; min-width:0; width:100%; height:52px; text-align:center; font:inherit; font-family:var(--num); font-weight:800; font-size:1.7rem; border-radius:14px; border:1px solid var(--line); background:var(--bg); color:var(--text); -moz-appearance:textfield; }
.step input::-webkit-outer-spin-button, .step input::-webkit-inner-spin-button { -webkit-appearance:none; margin:0; }
.jump { display:flex; align-items:center; gap:6px; margin:4px 0 2px; }
.jump span { flex:1; font-size:.72rem; font-weight:700; color:var(--muted); text-transform:uppercase; letter-spacing:.05em; }
.jump button { min-width:48px; height:44px; padding:0 10px; border-radius:12px; background:var(--card); font-weight:700; font-variant-numeric:tabular-nums; }
.jump button.on { background:var(--acc); color:var(--accText); }
.done-btn { min-height:48px; margin-top:10px; }
.addset { display:flex; gap:8px; margin-top:8px; }
.addset .btn { min-height:44px; font-size:.95rem; background:var(--card2); }

/* lists */
.list > * + * { margin-top:8px; }
.mrow { display:flex; align-items:center; gap:12px; background:var(--card); border-radius:18px; padding:12px 14px; text-decoration:none; min-height:64px; width:100%; text-align:left; }
.mrow .t { flex:1; min-width:0; }
.mrow .t b { display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.mrow .t small { color:var(--muted); display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.mrow .n { text-align:right; font-family:var(--num); font-weight:800; font-size:1.3rem; line-height:1.1; white-space:nowrap; }
.mrow .n small { display:block; font-family:inherit; font-size:.72rem; color:var(--muted); font-weight:600; }
.mrow .chev { color:var(--muted); font-size:1.3rem; }
.mrow.picked { outline:2px solid var(--acc); }
.wk-item { background:var(--card); border-radius:18px; padding:12px 12px 14px; }
.wk-item + .wk-item { margin-top:10px; }
.wk-item header { display:flex; align-items:center; gap:6px; }
.wk-item header b { flex:1; min-width:0; }
.wk-item .two { display:grid; grid-template-columns:1fr 1fr; gap:12px; margin-top:8px; }
.mini { display:flex; align-items:center; gap:4px; background:var(--card2); border-radius:14px; padding:2px; }
.mini button { width:44px; height:44px; border-radius:12px; font-size:1.4rem; font-weight:700; flex:none; }
.mini span { flex:1; text-align:center; font-family:var(--num); font-weight:800; font-size:1.25rem; line-height:1.05; }
.mini span small { display:block; font-family:inherit; font-size:.68rem; color:var(--muted); font-weight:600; }
.chart { background:var(--card); border-radius:18px; padding:12px 12px 6px; }
.chart svg { width:100%; height:auto; display:block; }
.chart .ttl { display:flex; justify-content:space-between; font-weight:700; font-size:.9rem; }
.chart .ttl span { color:var(--muted); font-weight:600; }
.tiles { display:grid; grid-template-columns:repeat(3, 1fr); gap:8px; }
.tile { background:var(--card); border-radius:18px; padding:12px 8px; text-align:center; }
.tile .v { font-family:var(--num); font-weight:800; font-size:1.7rem; line-height:1.05; }
.tile .k { font-size:.74rem; color:var(--muted); font-weight:600; }
.pb { color:var(--gold); font-weight:700; }
.sumset { display:flex; justify-content:space-between; padding:6px 0; border-top:1px solid var(--line); font-variant-numeric:tabular-nums; }
.sumset:first-child { border-top:none; }

/* sheets and toasts */
.sheet { position:fixed; inset:0; z-index:50; background:rgba(0,0,0,.55); display:flex; align-items:flex-end; justify-content:center; }
.sheet-card { width:100%; max-width:560px; background:var(--card); border-radius:26px 26px 0 0; padding:20px 16px calc(20px + env(safe-area-inset-bottom,0)); max-height:90dvh; overflow:auto; }
.sheet-card h3 { margin:0 0 6px; font-family:var(--num); font-weight:800; font-size:1.6rem; text-transform:uppercase; }
.toast { position:fixed; left:50%; bottom:calc(96px + env(safe-area-inset-bottom,0)); transform:translateX(-50%) translateY(20px); opacity:0; pointer-events:none;
  background:#000; color:#fff; padding:12px 18px; border-radius:14px; font-weight:600; z-index:60; transition:.2s; max-width:90vw; text-align:center; }
.toast.show { opacity:1; transform:translateX(-50%); }
.toast.bad { background:#7a1d1d; }
.toast.act { pointer-events:auto; display:flex; align-items:center; gap:12px; padding:6px 8px 6px 16px; }
.toast button { background:var(--acc); color:var(--accText); font-weight:800; border-radius:999px; padding:0 18px; min-height:44px; }

/* forms */
.field { display:block; margin-bottom:12px; }
.field span { display:block; font-size:.85rem; color:var(--muted); margin-bottom:4px; font-weight:600; }
.field input, .field select, .field textarea { width:100%; font:inherit; font-size:1.1rem; padding:14px; border-radius:14px; border:1px solid var(--line); background:var(--card2); color:var(--text); }
.field textarea { min-height:140px; resize:vertical; }
.err { color:#ff9a9a; min-height:1.2em; font-weight:600; }
.login { max-width:380px; margin:0 auto; padding:10vh 16px 16px; }
.logo { font-family:var(--num); font-weight:800; font-size:3.4rem; text-transform:uppercase; line-height:.9; }
.logo em { font-style:normal; color:var(--acc); }
.seg { display:flex; gap:8px; }
.seg button { flex:1; min-height:48px; border-radius:14px; background:var(--card2); font-weight:700; }
.seg button.on { background:var(--acc); color:var(--accText); }
.offline-pill { position:fixed; top:calc(6px + env(safe-area-inset-top,0)); right:8px; z-index:40; background:#5a4214; color:#ffd98a; font-size:.72rem; font-weight:700; padding:3px 9px; border-radius:99px; }
.center { text-align:center; }
.empty { text-align:center; color:var(--muted); padding:28px 12px; }
.footer { color:var(--muted); font-size:.8rem; text-align:center; margin-top:24px; }
.sticky-save { position:sticky; bottom:calc(76px + env(safe-area-inset-bottom,0)); margin-top:16px; }

/* live workout: remove-a-set and reorder */
.edactions { display:flex; gap:8px; align-items:center; margin-top:10px; }
.edactions .done-btn { margin-top:0; flex:1; }
.trash { width:52px; height:48px; border-radius:14px; background:#4a2323; font-size:1.1rem; }
.rlist { margin:10px 0 4px; }
.rrow { display:flex; align-items:center; gap:10px; background:var(--card2); border-radius:14px; padding:4px 12px 4px 4px; min-height:56px; margin-top:6px; }
.rrow b { flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.rrow small { color:var(--muted); font-weight:600; }
.rrow .grip { width:48px; height:48px; display:grid; place-items:center; font-size:1.6rem; color:var(--muted); touch-action:none; cursor:grab; flex:none; }
.rrow.dragging { outline:2px solid var(--acc); background:var(--card); position:relative; z-index:2; }

/* focus view: one exercise open, the rest a line each */
.ex { scroll-margin-top:84px; }
.ex.opening { animation:exopen .15s ease-out; }
@keyframes exopen { from { opacity:.35; transform:translateY(-6px); } to { opacity:1; transform:none; } }
.ex.collapsed { display:flex; align-items:center; gap:10px; padding:6px 12px; min-height:60px; cursor:pointer; }
.ex.collapsed .ct { flex:1; min-width:0; }
.ex.collapsed .ct b { display:block; font-size:1.05rem; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.ex.collapsed .ct small { color:var(--muted); font-weight:600; }
.ex.collapsed .pill { background:var(--card2); border-radius:999px; padding:2px 10px; font-family:var(--num); font-weight:800; font-size:1.05rem; }
.ex.collapsed .chev { color:var(--muted); font-size:1.4rem; }
.ex.collapsed.fin { opacity:.6; }
.ex.collapsed.fin .pill { background:rgba(67,209,127,.2); color:var(--good); }
.setbox.done:not(.open) .set { min-height:40px; }
.setbox.done:not(.open) .v { font-size:1.15rem; min-height:36px; color:var(--muted); }
.setbox.done:not(.open) .tick { width:36px; height:36px; font-size:1.1rem; }
.setbox.open .editor { animation:exopen .12s ease-out; }
.livebar { position:sticky; }
.prog { position:absolute; left:0; right:0; bottom:-1px; height:3px; background:transparent; }
.prog i { display:block; height:100%; background:var(--acc); transition:width .2s ease-out; }

.upd-bar { position:fixed; left:16px; right:16px; bottom:calc(16px + env(safe-area-inset-bottom,0px)); z-index:45; min-height:48px; border-radius:999px; background:var(--acc); color:var(--accText); font-weight:800; box-shadow:0 4px 18px rgba(0,0,0,.4); }

/* rest timer: a pill in the sticky top bar, so it is always on screen */
.restpill { display:flex; align-items:baseline; gap:5px; flex:none; background:rgba(183,243,74,.16); color:var(--acc); border-radius:999px; padding:5px 12px; }
.restpill span { font-size:.7rem; font-weight:800; text-transform:uppercase; letter-spacing:.06em; }
.restpill b { font-family:var(--num); font-weight:800; font-size:1.3rem; font-variant-numeric:tabular-nums; line-height:1.1; }
.livebar .nm { min-width:0; }

/* warm-up sets */
.wutag { color:var(--muted); font-size:.65rem; font-weight:800; text-transform:uppercase; letter-spacing:.05em; border:1px solid var(--line); border-radius:999px; padding:1px 7px; flex:none; }
.wubtn { height:48px; padding:0 12px; border-radius:14px; background:var(--card); color:var(--muted); font-size:.85rem; font-weight:700; flex:none; }
.wubtn.on { background:var(--acc); color:var(--accText); }
.edactions .wubtn { align-self:stretch; margin-top:0; }
