/* Deck log: one column, sticky header, scoreboard, week strip, session cards. Bottom tab bar on phones. */
:root {
  --bg: #EDF1F0; --surface: #FFFFFF; --surface2: #F6F8F8; --ink: #13232E; --muted: #5B6B73; --line: #D3DCDB;
  --teak: #A8642E; --b: #1F7A8C; --t: #C8466C; --ok: #2E8B57; --warn: #C27C0E; --bad: #C0392B;
  --hl: #E8642A; --fig: #13232E; --figfar: #9AA9AE; --ground: #B9C6C5;
  --display: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
  --body: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --sel: var(--b);
  --tabh: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E171D; --surface: #16222A; --surface2: #1B2932; --ink: #E4ECEC; --muted: #93A4AB; --line: #26353E;
    --teak: #D08A4E; --b: #4FB3C6; --t: #E9789A; --ok: #4FBF84; --warn: #E3A33A; --bad: #E86A5A;
    --hl: #FF8A4C; --fig: #E4ECEC; --figfar: #4F626B; --ground: #33454F;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; letter-spacing: .01em; margin: 0; text-wrap: balance; }
a { color: inherit; }
.eyebrow { font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.wrap { max-width: 760px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }

/* header */
.appbar { position: sticky; top: 0; z-index: 20; background: var(--bg); padding-top: env(safe-area-inset-top, 0px); border-bottom: 1px solid var(--line); }
.appbar .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 10px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand svg { width: 30px; height: 30px; }
.brand h1 { font-size: 24px; line-height: 1; }
.brand .eyebrow { font-size: 10px; }
.me { display: flex; align-items: center; gap: 8px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--sel); color: #fff; display: grid; place-items: center; font-family: var(--display); font-weight: 700; font-size: 18px; border: 0; cursor: pointer; }
.sync { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.sync.off { background: var(--warn); }

main { padding-block: 16px calc(var(--tabh) + 28px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 16px; }

/* scoreboard */
.board { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.score { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; border-top: 4px solid var(--c); }
.score .name { font-family: var(--display); font-size: 20px; font-weight: 700; color: var(--c); display: flex; justify-content: space-between; align-items: baseline; }
.score .name .pts { font-family: var(--mono); font-size: 12px; color: var(--muted); font-weight: 500; }
.big { font-family: var(--display); font-size: 40px; line-height: 1; font-weight: 700; font-variant-numeric: tabular-nums; }
.big small { font-size: 15px; color: var(--muted); font-weight: 500; margin-left: 4px; }
.row { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); gap: 8px; }
.row b { font-family: var(--mono); color: var(--ink); font-weight: 500; font-variant-numeric: tabular-nums; }
.bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--c); transition: width .4s; }
.lead { font-size: 13px; color: var(--muted); text-align: center; }

/* week strip */
.weekhead { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.weekhead .focus { font-size: 13px; color: var(--muted); }
.iconbtn { width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; display: grid; place-items: center; font-size: 18px; }
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.day { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 7px 2px; display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer; }
.day .dn { font-family: var(--mono); font-size: 10px; letter-spacing: .06em; color: var(--muted); text-transform: uppercase; }
.day .dd { font-family: var(--display); font-size: 19px; font-weight: 700; }
.day .dots { display: flex; gap: 3px; height: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--c); }
.dot.done { background: var(--c); }
.dot.off { border-style: dotted; opacity: .5; }
.day[aria-current="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.day.today .dn { color: var(--teak); font-weight: 600; }
.day.out { opacity: .4; }

/* segmented controls */
.seg { display: inline-flex; gap: 3px; background: var(--surface2); border: 1px solid var(--line); border-radius: 9px; padding: 3px; }
.seg button { border: 0; background: none; color: var(--muted); padding: 7px 12px; border-radius: 7px; cursor: pointer; font-weight: 600; font-size: 13px; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.14); }

/* session */
.shead { display: flex; flex-direction: column; gap: 6px; padding-bottom: 10px; border-bottom: 2px solid var(--sel); }
.shead h2 { font-size: 30px; line-height: 1.05; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--muted); align-items: center; }
.meta b { color: var(--ink); font-family: var(--mono); font-weight: 500; }
.note { font-size: 14px; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--warn); border-radius: 8px; padding: 10px 12px; }
.block h3 { font-size: 17px; color: var(--teak); text-transform: uppercase; letter-spacing: .07em; margin-bottom: 8px; }
.list { display: flex; flex-direction: column; gap: 8px; }
.ex { display: grid; grid-template-columns: 112px minmax(0, 1fr) auto; gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.ex.done { opacity: .62; }
.thumb { width: 112px; height: 76px; border-radius: 8px; background: var(--surface2); border: 0; padding: 0; cursor: pointer; position: relative; overflow: hidden; }
.thumb canvas { width: 100%; height: 100%; display: block; }
.thumb .how { position: absolute; right: 4px; bottom: 4px; font-family: var(--mono); font-size: 9px; letter-spacing: .06em; text-transform: uppercase; background: var(--surface); color: var(--muted); padding: 2px 5px; border-radius: 4px; }
.ex .nm { font-weight: 600; font-size: 15px; }
.ex .dose { font-family: var(--mono); font-size: 13px; color: var(--sel); font-variant-numeric: tabular-nums; }
.ex .rst { font-size: 12.5px; color: var(--muted); margin-top: 3px; line-height: 1.35; }
.ex .rst b { font-family: var(--mono); font-weight: 600; color: var(--ink); }
.restbtn { border: 1px solid var(--line); background: var(--surface2); color: var(--ink); font: 600 12px var(--mono); padding: 4px 9px; border-radius: 999px; cursor: pointer; margin-right: 4px; font-variant-numeric: tabular-nums; }
.restbtn:active { transform: scale(.97); }
.restbar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabh) + 12px + env(safe-area-inset-bottom, 0px)); z-index: 50; width: min(420px, calc(100% - 32px));
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: var(--ink); color: var(--bg); box-shadow: 0 8px 24px rgba(0,0,0,.25); overflow: hidden; }
.restbar::before { content: ""; position: absolute; left: 0; bottom: 0; height: 3px; width: calc(var(--p, 0) * 100%); background: var(--hl); }
.restbar b { font: 700 26px var(--mono); font-variant-numeric: tabular-nums; flex: 1; }
.restbar .eyebrow { color: inherit; opacity: .75; }
.restbar button { border: 1px solid rgba(255,255,255,.3); background: none; color: inherit; font: 600 13px var(--body); padding: 8px 12px; border-radius: 9px; cursor: pointer; }
.restbar.go { background: var(--hl); color: #fff; }
.ex .xn { font-size: 13px; color: var(--muted); margin-top: 2px; }
.ex .open { margin-top: 4px; font-size: 12px; color: var(--muted); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.tick { width: 38px; height: 38px; border-radius: 50%; border: 2px solid var(--line); background: none; cursor: pointer; display: grid; place-items: center; color: transparent; font-size: 18px; font-weight: 700; }
.tick[aria-pressed="true"] { background: var(--sel); border-color: var(--sel); color: #fff; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.card h3 { font-size: 20px; }
.btn { border: 0; border-radius: 10px; padding: 13px 16px; background: var(--sel); color: #fff; cursor: pointer; font-weight: 600; font-size: 15px; }
.btn.ghost { background: none; color: var(--ink); border: 1px solid var(--line); }
.btn:disabled { opacity: .5; cursor: default; }
.scale { display: grid; grid-template-columns: repeat(11, 1fr); gap: 3px; }
.scale button { font-family: var(--mono); font-size: 12px; padding: 8px 0; border: 1px solid var(--line); background: var(--surface2); border-radius: 6px; cursor: pointer; }
.scale button[aria-pressed="true"] { background: var(--pc); color: #fff; border-color: var(--pc); }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline input { width: 110px; }
input[type="email"], input[type="number"] { font: 500 16px var(--body); padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface2); color: var(--ink); min-width: 0; }
input:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--teak); outline-offset: 2px; }
.rest { background: var(--surface); border: 1px dashed var(--line); border-radius: 12px; padding: 18px; display: flex; flex-direction: column; gap: 8px; }

/* fuel */
.macros { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.macro .v { font-family: var(--display); font-size: 28px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; display: block; }
.macro .k { font-size: 12px; color: var(--muted); }
.split { display: flex; height: 10px; border-radius: 5px; overflow: hidden; }
.split i { display: block; height: 100%; }
.legend { display: flex; gap: 12px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.legend span::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; background: var(--k); }
.meals { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.meals li { display: grid; grid-template-columns: 110px minmax(0, 1fr) auto; gap: 10px; align-items: baseline; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.meals li:last-child { border-bottom: 0; padding-bottom: 0; }
.meals .when { font-family: var(--mono); font-size: 11px; color: var(--teak); text-transform: uppercase; letter-spacing: .06em; }
.meals .p { font-family: var(--mono); font-size: 13px; color: var(--sel); white-space: nowrap; }
.supp { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.supp:last-of-type { border-bottom: 0; }
.tier { font-family: var(--mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
ul.plain { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }

/* progress */
.chart { width: 100%; height: auto; display: block; }
.heat { display: grid; grid-template-columns: 34px repeat(7, 1fr); gap: 3px; font-family: var(--mono); font-size: 10px; color: var(--muted); align-items: center; }
.heat i { display: block; aspect-ratio: 1; border-radius: 3px; background: var(--surface2); border: 1px solid var(--line); }
.heat i.done { background: var(--c); border-color: var(--c); }
.heat i.rest { background: none; border-style: dotted; }
.heat i.miss { background: color-mix(in srgb, var(--bad) 18%, transparent); }
.heat i.future { opacity: .35; }

/* research */
.find { display: flex; flex-direction: column; gap: 6px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.find:last-child { border-bottom: 0; }
.find .h { font-weight: 600; }
.find .use { font-size: 14px; border-left: 3px solid var(--sel); padding-left: 10px; }
.find a { color: var(--muted); font-size: 13px; }

/* bottom tabs */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px); }
.tabbar .wrap { display: grid; grid-template-columns: repeat(4, 1fr); height: var(--tabh); }
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .02em; }
.tabbar a svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a[aria-current="page"] { color: var(--sel); }

/* exercise sheet */
dialog.sheet { border: 0; padding: 0; width: min(640px, 100%); max-width: 100%; max-height: 100%; height: 100%; margin: 0 auto; background: var(--bg); color: var(--ink); }
dialog.sheet::backdrop { background: rgba(8, 14, 18, .55); }
@media (min-width: 700px) { dialog.sheet { height: auto; max-height: 92vh; margin-top: 4vh; border-radius: 16px; } }
.sheet-in { display: flex; flex-direction: column; min-height: 100%; }
.sheet-top { position: sticky; top: 0; background: var(--bg); z-index: 2; padding-top: env(safe-area-inset-top, 0px); }
.sheet-top .wrap { display: flex; align-items: center; justify-content: space-between; padding-block: 10px; gap: 10px; }
.sheet-top h2 { font-size: 24px; line-height: 1.05; }
.stage { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.stage canvas { width: 100%; height: 240px; display: block; }
.stage canvas[hidden] { display: none; }
.stage3d { height: 360px; touch-action: none; position: relative; }
.stage3d:not(.on)::after { content: "Loading 3D…"; position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.stage3d canvas { height: 100% !important; }
.stage .ph { position: absolute; left: 12px; top: 10px; display: flex; gap: 6px; }
.stage .ph span { font-family: var(--mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; background: var(--surface2); color: var(--muted); transition: background .2s, color .2s; }
.stage .ph span.on { background: var(--hl); color: #fff; }
.stage .vw { position: absolute; right: 12px; top: 12px; font-family: var(--mono); font-size: 10px; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.controls { display: flex; gap: 8px; justify-content: space-between; align-items: center; flex-wrap: wrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12px; padding: 4px 9px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); }
.chip.hl { border-color: var(--hl); color: var(--hl); font-weight: 600; }
.steps { margin: 0; padding: 0; list-style: none; counter-reset: s; display: flex; flex-direction: column; gap: 8px; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 28px 1fr; gap: 8px; align-items: start; }
.steps li::before { content: counter(s); width: 24px; height: 24px; border-radius: 50%; background: var(--sel); color: #fff; display: grid; place-items: center; font-family: var(--mono); font-size: 12px; }
.do li::marker { color: var(--ok); }
.dont li::marker { color: var(--bad); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kv { font-size: 14px; }
.kv b { display: block; font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 500; margin-bottom: 2px; }
.sheet-body { display: flex; flex-direction: column; gap: 14px; padding-block: 4px 32px; padding-bottom: calc(32px + env(safe-area-inset-bottom, 0px)); }

/* login */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px max(16px, env(safe-area-inset-left, 0px)); }
.login .card { width: min(420px, 100%); gap: 14px; padding: 22px; }
.login h1 { font-size: 34px; line-height: 1; }
.msg { font-size: 14px; color: var(--muted); }
.msg.err { color: var(--bad); }

/* toast + confetti */
.toast { position: fixed; left: 50%; bottom: calc(var(--tabh) + 16px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 60; max-width: calc(100% - 32px); }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 70; width: 100%; height: 100%; }

@media (max-width: 480px) {
  .ex { grid-template-columns: 92px minmax(0, 1fr) auto; gap: 10px; }
  .thumb { width: 92px; height: 64px; }
  .big { font-size: 32px; }
  .macros { grid-template-columns: repeat(2, 1fr); }
  .meals li { grid-template-columns: minmax(0, 1fr) auto; }
  .meals .when { grid-column: 1 / -1; }
  .two { grid-template-columns: 1fr; }
  .stage canvas { height: 210px; }
  .stage3d { height: 320px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.stage:has(.stage3d.on) .vw { display: none; }
/* Set ticks and suggested weights (exercise sheet and session list) */
.ex .setp { display: inline-block; margin-left: 6px; font: 600 11px var(--mono); color: var(--sel); border: 1px solid currentColor; border-radius: 999px; padding: 0 6px; vertical-align: 1px; }
.ex .tryw { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.ex .tryw b { font-family: var(--mono); color: var(--ink); }
.setcard .row, .trycard .row { align-items: baseline; }
.setc { font: 700 18px var(--mono); color: var(--sel); font-variant-numeric: tabular-nums; }
.setrow { display: flex; flex-wrap: wrap; gap: 10px; }
.setb { position: relative; width: 56px; height: 56px; border-radius: 50%; border: 2px solid var(--line); background: var(--surface2); cursor: pointer; display: grid; place-items: center; touch-action: manipulation; transition: background .15s, border-color .15s, transform .15s; }
.setb .sn { font: 700 18px var(--mono); color: var(--ink); }
.setb .sk { position: absolute; font-size: 22px; font-weight: 700; color: #fff; opacity: 0; transform: scale(.4); transition: opacity .15s, transform .2s; }
.setb[aria-pressed="true"] { background: var(--sel); border-color: var(--sel); animation: setpop .28s ease-out; }
.setb[aria-pressed="true"] .sn { opacity: 0; }
.setb[aria-pressed="true"] .sk { opacity: 1; transform: none; }
.setb:active { transform: scale(.94); }
.setrow.one .setb { width: 100%; height: 52px; border-radius: 12px; }
.setrow.one .setb[aria-pressed="false"] .sk { opacity: .35; color: var(--muted); transform: none; }
@keyframes setpop { 0% { transform: scale(.9); } 60% { transform: scale(1.08); } 100% { transform: none; } }
.msg.tiny { font-size: 12px; }
.tryk { font-size: 16px; color: var(--ink); text-align: right; }
.tryk b { font: 700 20px var(--mono); color: var(--sel); }
dialog.sheet .restbar { bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
@media (prefers-reduced-motion: reduce) { .setb, .setb .sk { transition: none; } .setb[aria-pressed="true"] { animation: none; } }
