:root{--red:#e53935;--red2:#fdecea;--bg:#f2f2f7;--card:#fff;--txt:#111;--sub:#8e8e93;--line:#e5e5ea;--grey:#ececf0;--orange:#f39a3c;
  --st:env(safe-area-inset-top);--sb:env(safe-area-inset-bottom);}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;padding:0;width:100%;height:100%;height:-webkit-fill-available;height:100dvh;background:var(--bg);color:var(--txt);font:17px/1.35 -apple-system,BlinkMacSystemFont,"SF Pro Text","Helvetica Neue",Arial,sans-serif;
  -webkit-text-size-adjust:100%;overflow:hidden;overflow-x:hidden;overscroll-behavior:none;touch-action:manipulation}
body{position:fixed;inset:0}
/* fixed full-height shell: only #view, the workout body and the editor body scroll */
#app{position:fixed;inset:0;height:100%;height:-webkit-fill-available;height:100dvh;overflow:hidden;max-width:100vw}
img,svg,video{max-width:100%}
body{-webkit-user-select:none;user-select:none;-webkit-touch-callout:none}
button{font:inherit;color:inherit;border:0;background:none;padding:0;cursor:pointer;touch-action:manipulation}
input,select,textarea{font:inherit;font-size:17px}
.hidden{display:none!important}
#view{position:absolute;inset:0;bottom:calc(64px + var(--sb));overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain;touch-action:pan-y;-webkit-overflow-scrolling:touch;padding:calc(var(--st) + 12px) 16px 24px}
#tabs{position:absolute;left:0;right:0;bottom:0;height:calc(64px + var(--sb));padding-bottom:var(--sb);display:flex;background:rgba(249,249,249,.94);
  backdrop-filter:blur(20px);-webkit-backdrop-filter:blur(20px);border-top:1px solid var(--line);z-index:5}
#tabs button{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;color:var(--sub);font-size:11px}
#tabs svg{width:26px;height:26px;fill:currentColor}
#tabs button.on{color:var(--red)}
h1{font-size:32px;margin:6px 4px 14px;font-weight:700;letter-spacing:-.5px}
h2{font-size:20px;margin:22px 4px 10px;font-weight:600}
.sub{color:var(--sub);font-size:15px}
.card{background:var(--card);border-radius:16px;padding:16px;margin-bottom:12px}
.row{display:flex;align-items:center;justify-content:space-between;gap:10px}
.big-btn{display:block;width:100%;background:var(--red);color:#fff;font-weight:600;font-size:19px;border-radius:14px;padding:17px;margin:14px 0 4px;text-align:center}
.big-btn:active{opacity:.8}
.btn2{display:block;width:100%;background:var(--card);color:var(--red);font-weight:600;border-radius:14px;padding:15px;margin:8px 0;text-align:center}
.btn2.danger{color:#d00}
.link{color:var(--red);font-weight:500}
.lift-line{display:flex;justify-content:space-between;padding:7px 0;border-top:1px solid var(--line);font-size:16px}
.lift-line:first-of-type{border-top:0}
.lift-line .w{color:var(--sub);text-align:right}
.badge{display:inline-block;background:var(--red2);color:var(--red);border-radius:8px;padding:2px 8px;font-size:13px;font-weight:600}
.seg{display:flex;background:#e3e3e8;border-radius:10px;padding:2px;margin:0 0 14px}
.seg button{flex:1;padding:7px 4px;border-radius:8px;font-size:15px;color:#333}
.seg button.on{background:#fff;box-shadow:0 1px 3px rgba(0,0,0,.12);font-weight:600}
/* workout overlay */
#workout{position:absolute;inset:0;overflow:hidden;background:#fff;z-index:10;display:flex;flex-direction:column}
.w-head{padding:calc(var(--st) + 8px) 14px 8px;display:flex;align-items:center;justify-content:space-between;gap:8px}
.pill{background:var(--bg);border-radius:20px;padding:9px 16px;font-weight:600;color:var(--red);font-size:16px}
.pill.solid{background:var(--red);color:#fff}
.w-title{text-align:center;font-weight:600}
.w-title .sub{font-weight:400;font-size:13px}
.w-tabs{padding:0 14px}
.w-body{flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain;touch-action:pan-y;-webkit-overflow-scrolling:touch;padding:4px 16px 120px}
.ex{margin:10px 0 18px}
.ex-head{display:flex;justify-content:space-between;align-items:center;padding:6px 0 10px}
.ex-head .n{font-size:19px;font-weight:500}
.ex-head .t{color:var(--txt);font-size:16px}
.ex-head .t b{color:var(--red);font-weight:400;margin-left:6px}
.sets{display:flex;gap:10px;flex-wrap:wrap}
.set{display:flex;flex-direction:column;align-items:center;gap:4px;width:56px}
.circle{width:56px;height:56px;border-radius:50%;background:var(--grey);color:#b0b0b8;font-size:22px;display:flex;align-items:center;justify-content:center;font-weight:500;
  transition:transform .08s}
.circle:active{transform:scale(.92)}
.circle.done{background:var(--red);color:#fff}
.circle.fail{background:#fff;color:var(--red);box-shadow:inset 0 0 0 3px var(--red)}
.circle.more{background:var(--red);color:#fff;box-shadow:0 0 0 3px #ffcdd2}
.set .kg{font-size:12.5px;color:var(--sub)}
.set .tag{font-size:10px;color:var(--red);font-weight:600;height:12px;margin-top:-3px}
.hint{font-size:13px;color:var(--sub);margin:-4px 0 6px}
.w-foot{position:absolute;left:0;right:0;bottom:0;padding:10px 14px calc(var(--sb) + 10px);display:flex;justify-content:space-between;align-items:center;
  background:linear-gradient(rgba(255,255,255,0),#fff 30%)}
.timer{background:#1c1c1e;color:#fff;border-radius:22px;padding:9px 16px;font-weight:600;font-variant-numeric:tabular-nums;font-size:16px;min-width:96px;text-align:center}
.rest{position:absolute;left:14px;right:14px;bottom:calc(var(--sb) + 70px);background:#1c1c1e;color:#fff;border-radius:18px;padding:12px 16px;display:flex;align-items:center;gap:12px;
  box-shadow:0 6px 20px rgba(0,0,0,.25);z-index:12}
.rest .clock{font-size:30px;font-weight:600;font-variant-numeric:tabular-nums;flex:1}
.rest .msg{font-size:13px;color:#bbb}
.rest button{background:#3a3a3c;border-radius:12px;padding:9px 12px;font-size:15px;font-weight:600}
.rest.over{background:var(--red)}
.rest.over button{background:rgba(255,255,255,.25)}
.wu-row{display:flex;align-items:center;gap:14px;padding:8px 0;border-bottom:1px solid var(--line)}
.wu-row .circle{width:48px;height:48px;font-size:19px}
.wu-row .circle.done{background:var(--orange)}
.wu-row .x{flex:1}
.wu-row .p{color:var(--sub);font-size:15px}
/* sheet */
#sheet-wrap{position:fixed;inset:0;z-index:20}
#sheet-bg{position:absolute;inset:0;background:rgba(0,0,0,.35)}
#sheet{position:absolute;left:0;right:0;bottom:0;max-height:92%;overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain;touch-action:pan-y;background:var(--bg);border-radius:18px 18px 0 0;padding:14px 16px calc(var(--sb) + 16px);
  animation:up .2s ease-out}
@keyframes up{from{transform:translateY(40%);opacity:.4}to{transform:none;opacity:1}}
.sheet-title{text-align:center;font-weight:600;font-size:18px;margin:2px 0 2px}
.sheet-sub{text-align:center;color:var(--sub);font-size:14px;margin-bottom:12px}
.stepper{display:flex;align-items:center;justify-content:center;gap:26px;margin:10px 0 16px}
.stepper button{width:64px;height:64px;border-radius:50%;background:#fff;font-size:32px;color:var(--red);font-weight:500}
.stepper .val{font-size:52px;font-weight:600;min-width:80px;text-align:center;font-variant-numeric:tabular-nums}
.grid{display:grid;grid-template-columns:repeat(7,1fr);gap:7px}
.grid button{background:#fff;border-radius:10px;padding:10px 0;font-size:17px}
.grid button.on{background:var(--red);color:#fff}
/* lift editor (full screen) */
#editor{position:absolute;inset:0;z-index:25;background:var(--bg);display:flex;flex-direction:column;overflow:hidden;animation:up .18s ease-out}
.ed-head{flex:none;display:flex;align-items:center;justify-content:space-between;padding:calc(var(--st) + 10px) 14px 10px;background:#fff;border-bottom:1px solid var(--line)}
.ed-back{width:44px;height:44px;border-radius:50%;background:var(--bg);display:flex;align-items:center;justify-content:center;color:var(--txt)}
.ed-back svg{width:24px;height:24px}
.ed-title{text-align:center;font-weight:600;font-size:18px;line-height:1.2}
.ed-title .sub{font-weight:400;font-size:14px;margin-top:2px}
.ed-body{flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain;touch-action:pan-y;padding:10px 16px 16px}
.ed-where{text-align:center;color:var(--sub);font-size:13px;margin:2px 0 4px;min-height:4px}
.ed-cols{display:grid;grid-template-columns:1fr 84px 100px;padding:8px 16px 6px;color:var(--sub);font-size:15px}
.ed-cols span:nth-child(n+2){text-align:right}
.ed-cols.bw,.ed-table.bw .ed-row{grid-template-columns:1fr 100px}
.ed-table{background:#fff;border-radius:14px;overflow:hidden}
.ed-row{display:grid;grid-template-columns:1fr 84px 100px;align-items:stretch;border-top:1px solid var(--line);min-height:52px}
.ed-row:first-child{border-top:0}
.ed-n{display:flex;align-items:center;gap:8px;padding-left:16px;color:var(--sub);font-size:17px}
.ed-n .tag{font-size:10px;font-weight:700;color:var(--red);letter-spacing:.3px}
.ed-c{text-align:right;padding:0 16px;font-size:18px;font-variant-numeric:tabular-nums;border-left:1px solid var(--line)}
.ed-c.target{color:var(--sub)}
.ed-c.kg{color:var(--txt);font-weight:500}
.ed-c.on{background:var(--red2);color:var(--red);font-weight:600;box-shadow:inset 0 0 0 2px var(--red)}
.caret{display:inline-block;width:2px;height:20px;background:var(--red);margin-left:2px;vertical-align:-3px;animation:blink 1s steps(1) infinite}
@keyframes blink{50%{opacity:0}}
.ed-note{color:var(--sub);font-size:13px;text-align:center;margin:12px 10px 0}
.ed-keys{flex:none;display:grid;grid-template-columns:1fr 1fr 1fr 1.45fr;grid-auto-rows:52px;gap:8px 6px;padding:10px 10px calc(var(--sb) + 10px);background:#d9d9de;box-shadow:0 -1px 0 rgba(0,0,0,.06)}
.ed-keys button{font-size:23px;border-radius:10px;color:var(--txt);display:flex;align-items:center;justify-content:center}
.ed-keys button:active{background:rgba(255,255,255,.6)}
.ed-keys .act{background:#fff;font-size:17px;font-weight:600;box-shadow:0 1px 0 rgba(0,0,0,.12)}
.ed-keys .act:active{background:#f0f0f3}
.ed-keys .act:disabled{opacity:.4}
.ed-keys .go{background:var(--red);color:#fff}
.ed-keys .go:active{background:#c62828}
.pm{display:flex;gap:1px;border-radius:10px;overflow:hidden;box-shadow:0 1px 0 rgba(0,0,0,.12)}
.pm button{flex:1;border-radius:0!important;box-shadow:none!important;font-size:24px!important;font-weight:500!important}
.plates{display:flex;align-items:center;justify-content:center;height:108px;margin:4px 0 0}
.plates .bar{height:12px;background:linear-gradient(#cfcfd4,#a9a9af);width:70px;border-radius:2px 0 0 2px}
.plates .collar{height:26px;width:10px;background:#8e8e93;border-radius:2px}
.plates .sleeve{height:14px;background:linear-gradient(#cfcfd4,#a9a9af);width:70px;border-radius:0 3px 3px 0;margin-left:2px}
.plates .pl{width:24px;margin-left:2px;border-radius:4px;font-size:12px;font-weight:700;display:flex;align-items:center;justify-content:center;writing-mode:vertical-rl;box-shadow:inset 0 0 0 1px rgba(0,0,0,.12)}
.plates .pl.thin{width:17px;font-size:10px}
.pv-lift{display:block;width:100%;text-align:left;margin:0 0 10px}
.pv-lift .chev{color:var(--red);margin-left:6px;font-size:20px;vertical-align:-1px}
.badge.grey{background:var(--grey);color:#555}
.lift-line.ed .w{color:var(--txt)}
/* history */
.h-ex{display:flex;justify-content:space-between;gap:12px;padding:5px 0;font-size:15px}
.h-ex .n{white-space:nowrap}
.h-ex .s{color:var(--sub);text-align:right}
.cal{display:grid;grid-template-columns:repeat(7,1fr);gap:4px;text-align:center}
.cal .dow{font-size:12px;color:var(--sub);padding:4px 0}
.cal .d{aspect-ratio:1;display:flex;align-items:center;justify-content:center;border-radius:50%;font-size:16px}
.cal .d.w{background:var(--red);color:#fff;font-weight:600}
.cal .d.today{box-shadow:inset 0 0 0 2px var(--red)}
/* progress */
.chips{display:flex;gap:8px;overflow-x:auto;touch-action:pan-x pan-y;overscroll-behavior-x:contain;padding-bottom:6px;margin:0 -16px 10px;padding-left:16px;padding-right:16px;scrollbar-width:none}
.chips::-webkit-scrollbar{display:none}
.chips button{background:#fff;border-radius:18px;padding:8px 14px;font-size:15px;white-space:nowrap}
.chips button.on{background:var(--red);color:#fff}
.stat{display:flex;gap:10px;margin-bottom:12px}
.stat .card{flex:1;margin:0;padding:12px}
.stat .v{font-size:22px;font-weight:700}
.stat .l{font-size:12px;color:var(--sub)}
svg.chart{width:100%;height:210px;display:block}
/* settings */
.set-row{display:flex;justify-content:space-between;align-items:center;padding:13px 0;border-top:1px solid var(--line)}
.set-row:first-child{border-top:0}
.mini-step{display:flex;align-items:center;gap:10px}
.mini-step button{width:36px;height:36px;border-radius:50%;background:var(--bg);color:var(--red);font-size:22px}
.mini-step span{min-width:52px;text-align:center;font-variant-numeric:tabular-nums}
.set-row input[type=number],.set-row input[type=text]{width:120px;text-align:right;border:0;background:var(--bg);border-radius:8px;padding:6px 8px}
details summary{list-style:none;cursor:pointer}
details summary::-webkit-details-marker{display:none}
textarea{width:100%;min-height:140px;border:0;border-radius:12px;padding:12px;-webkit-user-select:text;user-select:text}
#toast{position:absolute;left:50%;transform:translateX(-50%);bottom:calc(var(--sb) + 90px);background:#1c1c1e;color:#fff;padding:11px 18px;border-radius:14px;font-size:15px;z-index:30;max-width:90%;text-align:center}
.switch{position:relative;width:51px;height:31px;border-radius:16px;background:#e3e3e8;transition:.2s}
.switch::after{content:"";position:absolute;top:2px;left:2px;width:27px;height:27px;border-radius:50%;background:#fff;box-shadow:0 2px 4px rgba(0,0,0,.2);transition:.2s}
.switch.on{background:#34c759}.switch.on::after{left:22px}
