:root {
  --bg: #131516; --panel: #1A1D1F; --panel2: #1E2123; --line: #2A2E30;
  --text: #F2F2EE; --muted: #A9ADAF; --accent: #F2F2EE; --accent2: #B8D8C8; --warn: #E8C98A; --bad: #E59A9A;
  --radius: 18px; --tap: 52px;
  --push: #A9ADAF; --pull: #A9ADAF; --legs: #A9ADAF; --core: #A9ADAF; --pt: #A9ADAF; --other: #A9ADAF;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 17px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; border-radius: 10px; background: var(--panel2); padding: 10px 14px; min-height: 40px; }
button.primary { background: var(--accent); color: #131516; font-weight: 700; }
button.ghost { background: transparent; border: 1px solid var(--line); }
button.danger { background: var(--bad); color: #fff; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 44px; width: 100%; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .right { text-align: right; } .center { text-align: center; }
.mt { margin-top: 14px; } .mb { margin-bottom: 14px; }
h1 { font-size: 22px; margin: 0 0 6px; } h2 { font-size: 17px; margin: 18px 0 8px; } h3 { font-size: 15px; margin: 0 0 6px; }

.top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top)); background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { font-weight: 800; letter-spacing: .3px; display: flex; align-items: center; gap: 8px; }
.logo { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #131516; font-weight: 900; }
.who { font-size: 13px; color: var(--muted); }

.view { padding: 14px 16px 20px; max-width: 760px; margin: 0 auto; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.card.tight { padding: 10px 12px; }

.tabs { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--panel); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 6px; font-size: 11px; color: var(--muted); }
.tabs a .ic { font-size: 18px; line-height: 1; }
.tabs a.active { color: var(--accent); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; padding: 7px 12px; border-radius: 999px; background: var(--panel2); border: 1px solid var(--line); font-size: 13px; white-space: nowrap; }
.chip.active { background: var(--accent); color: #131516; border-color: var(--accent); font-weight: 700; }

/* exercise card */
.ex { display: grid; grid-template-columns: 1fr; gap: 10px; }
.ex .name { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.ex .meta { font-size: 13px; color: var(--muted); }
.ex .meta b { color: var(--text); }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: var(--panel2); border: 1px solid var(--line); }
.pill.good { background: color-mix(in srgb, var(--accent2) 20%, transparent); border-color: var(--accent2); }
.pill.hold { background: color-mix(in srgb, var(--warn) 20%, transparent); border-color: var(--warn); }
.pill.bad { background: color-mix(in srgb, var(--bad) 20%, transparent); border-color: var(--bad); }
.ctrl { display: flex; align-items: center; gap: 8px; }
.ctrl .addset { flex: 1; }
.ctrl:empty { display: none; }
.stepper { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.stepper button { border-radius: 0; min-width: 38px; min-height: 44px; background: var(--panel2); font-size: 20px; }
.stepper .val { min-width: 50px; text-align: center; font-weight: 800; font-size: 20px; font-variant-numeric: tabular-nums; }
.stepper .val small { font-size: 11px; color: var(--muted); font-weight: 500; display: block; margin-top: -4px; }
.addset { min-height: 44px; padding: 0 16px; font-weight: 800; font-size: 16px; background: var(--accent); color: #131516; border-radius: 10px; }
.iconbtn { min-width: 44px; min-height: 44px; padding: 0; font-size: 20px; border-radius: 10px; }
.sets { display: flex; flex-wrap: wrap; gap: 6px; }
.sets:empty { display: none; }
.sets .s { padding: 4px 10px; border-radius: 8px; background: var(--panel2); border: 1px solid var(--line); font-size: 13px; font-variant-numeric: tabular-nums; }
.sets .s.best { border-color: var(--accent2); }

.stat { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 10px; }
.stat .k { font-size: 12px; color: var(--muted); } .stat .v { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 12px; color: var(--muted); font-weight: 500; margin-left: 2px; }
.delta { font-size: 12px; } .delta.up { color: var(--accent2); } .delta.down { color: var(--bad); }

table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { padding: 7px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
td.num, th.num { text-align: right; }
.scroll { overflow-x: auto; }

canvas.chart { width: 100% !important; height: 220px !important; }

.fab { position: fixed; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); width: 56px; height: 56px; border-radius: 50%; font-size: 24px; background: var(--accent2); color: #131516; box-shadow: 0 8px 24px rgba(0,0,0,.35); z-index: 6; }
.fab.listening { animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.1); } }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
.modal.hidden, .hidden { display: none !important; }
.sheet { width: 100%; max-width: 760px; max-height: 92vh; overflow: auto; background: var(--panel); border-radius: 18px 18px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.sheet h2 { margin-top: 0; }
.sheet .actions { display: flex; gap: 10px; margin-top: 14px; }
.sheet .actions > * { flex: 1; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(80px + env(safe-area-inset-bottom)); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; z-index: 30; display: flex; gap: 14px; align-items: center; box-shadow: 0 8px 24px rgba(0,0,0,.35); }
.toast button { background: transparent; color: var(--accent); font-weight: 800; padding: 0; min-height: 0; }

/* counter sheet */
.camwrap { position: relative; width: 100%; aspect-ratio: 4 / 3; background: #000; border-radius: 12px; overflow: hidden; }
.camwrap video, .camwrap canvas.overlay { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.camwrap video.mirror { transform: scaleX(-1); }
.roi { position: absolute; border: 2px dashed var(--accent); background: rgba(242,242,238,.08); touch-action: none; }
.roi .h { position: absolute; right: -10px; bottom: -10px; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); }
.bigcount { font-size: 72px; font-weight: 900; text-align: center; line-height: 1; font-variant-numeric: tabular-nums; margin: 10px 0 4px; }
.level { height: 10px; border-radius: 5px; background: var(--panel2); overflow: hidden; }
.level i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .08s linear; }
.bigtime { font-size: 64px; font-weight: 900; text-align: center; font-variant-numeric: tabular-nums; margin: 16px 0; }

.bpcat { font-weight: 700; }
.cat-Normal { color: var(--accent2); } .cat-Elevated { color: var(--warn); } .cat-Stage\ 1 { color: #fb923c; } .cat-Stage\ 2, .cat-Crisis { color: var(--bad); }
.note { background: var(--panel2); border-left: 3px solid var(--accent); padding: 8px 10px; border-radius: 8px; margin-bottom: 8px; font-size: 14px; }
.note .by { font-size: 12px; color: var(--muted); }
.empty { color: var(--muted); text-align: center; padding: 24px 0; }

/* PT sessions */
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
@media (max-width: 420px) { .grid4 { grid-template-columns: repeat(2, 1fr); } }
.ptrow { border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-top: 10px; }
.card.tap { cursor: pointer; }

/* ---------- Focus theme ---------- */
h1 { font-size: 26px; letter-spacing: -.3px; } h2 { font-size: 20px; } h3 { font-size: 17px; }
.small { font-size: 14px; } label { font-size: 14px; }
.view { padding: 20px 20px 28px; }
.card { padding: 18px; margin-bottom: 14px; border-color: transparent; }
button { border-radius: 14px; min-height: 48px; font-size: 16px; }
input, select, textarea { border-radius: 14px; min-height: 50px; font-size: 16px; }
.logo { background: var(--text); color: var(--bg); width: auto; padding: 0 7px; }
.logo svg { height: 13px; display: block; fill: currentColor; }
.dot { display: none; }
.pill.good, .pill.hold, .pill.bad { background: transparent; }
.tabs a { font-size: 14px; padding: 20px 0 18px; }
.tabs a .ic { display: none; }
.tabs a.active { color: var(--text); font-weight: 700; }
.chips { gap: 0; padding: 4px; margin: 4px 0 14px; background: var(--panel2); border-radius: 14px; }
.chip { flex: 1 0 auto; text-align: center; border: 0; background: transparent; color: var(--muted); font-size: 14px; padding: 11px 10px; border-radius: 10px; min-height: 0; }
.chip.active { background: var(--text); color: var(--bg); }
a.chip { color: var(--muted); } a.chip.active { color: var(--bg); }
table { font-size: 15px; } th { font-size: 13px; } th, td { padding: 10px 6px; }
.stat .k { font-size: 13px; } .stat .v { font-size: 26px; }
.fab { background: var(--panel2); color: var(--text); border: 1px solid var(--line); box-shadow: none; font-size: 15px; font-weight: 600; width: auto; height: 48px; padding: 0 18px; border-radius: 24px; }
.note { border-left: 0; }
.sets .s { padding: 7px 12px; font-size: 15px; border-radius: 10px; }
.sets .s.best { border-color: var(--text); }

.focus { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 28px 0 8px; text-align: center; max-width: 520px; margin: 0 auto; }
.eyebrow { font-size: 13px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); }
.focus .fname { margin: 0; font-size: 26px; font-weight: 600; cursor: pointer; }
.focus .big { display: flex; align-items: center; justify-content: center; gap: 24px; margin-top: 4px; }
.focus .big .v { font-size: 116px; font-weight: 700; line-height: 1; letter-spacing: -4px; font-variant-numeric: tabular-nums; min-width: 150px; }
.focus .big .v.t { font-size: 84px; letter-spacing: -2px; }
.round { width: 60px; height: 60px; min-height: 60px; border-radius: 50%; border: 1px solid #3A3F42; background: transparent; font-size: 28px; padding: 0; }
.focus .loadrow { display: flex; align-items: center; gap: 16px; font-size: 22px; font-weight: 600; }
.focus .loadrow .round { width: 48px; height: 48px; min-height: 48px; font-size: 22px; }
.focus .sub { font-size: 17px; color: var(--muted); }
.logbtn { width: 100%; height: 64px; margin-top: 14px; border-radius: 18px; background: var(--text); color: var(--bg); font-size: 19px; font-weight: 700; }
.linkbtn { background: transparent; color: var(--muted); font-size: 15px; min-height: 44px; }
.focus .sets { justify-content: center; }
.upnext { max-width: 520px; margin: 14px auto 0; }
.upnext .row2 { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 16px 0; border-top: 1px solid var(--line); border-radius: 0; background: transparent; font-size: 18px; text-align: left; min-height: 56px; }
.upnext .row2 span:last-child { color: var(--muted); white-space: nowrap; padding-left: 12px; }
.upnext .row2 .done { color: var(--accent2); }

/* ---------- desktop ---------- */
.tabs a.sub { display: none; }
a.chip { color: var(--text); }
.prog { display: block; }
@media (min-width: 960px) {
  body { padding-bottom: 0; padding-left: 200px; }
  .top { margin-left: -200px; padding-left: 20px; }
  .tabs { top: 57px; bottom: 0; left: 0; right: auto; width: 200px; flex-direction: column; border-top: 0; border-right: 1px solid var(--line); padding: 10px 0; }
  .tabs a { flex: 0 0 auto; flex-direction: row; gap: 12px; padding: 12px 20px; font-size: 15px; }
  .tabs a.active { background: var(--panel2); }
  .tabs.prog-open a.sub { display: flex; padding: 8px 20px 8px 52px; font-size: 14px; }
  .tabs a.sub.active { background: transparent; color: var(--accent); font-weight: 700; }
  .view { max-width: 1240px; padding: 20px 28px 40px; }
  .prog { display: grid; grid-template-columns: 280px 1fr; gap: 20px; align-items: start; }
  .exlist { position: sticky; top: 76px; max-height: calc(100vh - 96px); overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; }
  .exgroup { display: flex; align-items: center; gap: 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); padding: 10px 10px 4px; }
  .exlist a { display: flex; flex-direction: column; padding: 8px 10px; border-radius: 10px; color: var(--text); }
  .exlist a:hover { background: var(--panel2); }
  .exlist a.active { background: color-mix(in srgb, var(--accent) 18%, transparent); outline: 1px solid var(--accent); }
  canvas.chart { height: 300px !important; }
  .fab { right: 28px; bottom: 28px; }
}

@media (min-width: 960px) {
  .tabs a { padding: 13px 22px; font-size: 16px; }
  .tabs.prog-open a.sub { padding: 9px 22px 9px 40px; font-size: 15px; }
  .focus { padding-top: 40px; }
}
td:first-child { white-space: nowrap; }
.view { padding-bottom: 96px; }

/* PT session runner */
.ptrun { text-align: center; }
.ptrun .chips { justify-content: center; flex-wrap: wrap; overflow: visible; }
.ptrun #pre .chip { flex: 0 0 auto; padding: 9px 12px; }
.ptrun .clock { font-size: 96px; font-weight: 700; line-height: 1; letter-spacing: -3px; font-variant-numeric: tabular-nums; margin: 12px 0 4px; }
.ptrun .clock.done { color: var(--accent2); }
.ptrun label { text-align: left; }
.ptrun #go { flex: 2; height: 64px; font-size: 19px; font-weight: 700; }
.round.sm { width: 44px; height: 44px; min-height: 44px; font-size: 22px; flex: 0 0 44px; }
.row2.pick { width: 100%; display: flex; justify-content: space-between; gap: 12px; padding: 14px 4px; border: 0; border-top: 1px solid var(--line); background: transparent; color: var(--text); font-size: 17px; text-align: left; border-radius: 0; min-height: 0; }
.row2.pick span:last-child { font-size: 14px; white-space: nowrap; }
.hidden { display: none !important; }

/* gym day picker */
.chips.daychips { flex-wrap: wrap; overflow: visible; }
.daychips .sug { font-size: 10px; letter-spacing: 1px; text-transform: uppercase; color: var(--accent2); margin-left: 4px; }
.daychips .chip.active .sug { color: var(--bg); }
.daynote { margin: -6px 0 6px; text-align: center; }
.daynote .linkbtn { font-size: inherit; padding: 0; min-height: 0; }

/* machine photo picker (gym days) */
.mstrip { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 12px; margin: 0 -4px 6px; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
.mtile { flex: 0 0 104px; display: flex; flex-direction: column; gap: 6px; padding: 0; border: 2px solid transparent; background: transparent; border-radius: 14px; color: var(--text); min-height: 0; scroll-snap-align: center; }
.mtile img, .mtile .noimg { width: 100%; height: 120px; object-fit: cover; border-radius: 12px; background: var(--panel2); display: grid; place-items: center; font-size: 14px; color: var(--muted); text-align: center; padding: 0; }
.mtile .mlabel { font-size: 12px; line-height: 1.25; color: var(--muted); text-align: left; padding: 0 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mtile.on { border-color: var(--text); }
.mtile.on .mlabel { color: var(--text); }
.mtile.more .noimg { font-size: 34px; }
.mgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; margin-top: 10px; }
.mgrid .mtile { flex: none; width: 100%; }
.fphoto { width: 100%; max-width: 280px; height: 150px; object-fit: cover; border-radius: 14px; margin: 8px auto 0; display: block; }
.inlinesel { display: inline; width: auto; padding: 2px 6px; font-size: inherit; min-height: 0; background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; }

/* Settings: rights checkboxes */
.chk { display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 2px 0; font-size: 15px; color: var(--text); cursor: pointer; }
.chk input { width: 20px; height: 20px; min-height: 0; flex: 0 0 auto; accent-color: var(--text); }
.acts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.acts button { white-space: nowrap; }

/* Settings: Users list and Rights table */
.ulist { border-top: 1px solid var(--line); }
.urow { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 60px; padding: 10px 2px; background: transparent; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; color: var(--text); text-align: left; font: inherit; }
button.urow { cursor: pointer; }
table.rights { width: 100%; }
table.rights th.c, table.rights td.c { text-align: center; min-width: 76px; }
table.rights th { font-weight: 600; white-space: nowrap; }
table.rights td:first-child { white-space: nowrap; padding-right: 12px; }
table.rights tr.grp td { color: var(--muted); font-size: 13px; letter-spacing: 1px; text-transform: uppercase; padding-top: 16px; border-bottom: 0; }
table.rights input[type=checkbox] { width: 22px; height: 22px; min-height: 0; accent-color: var(--text); }
@media (max-width: 959px) { .tabs a { flex: 1 1 auto; font-size: 13px; } }

/* accounts */
button.who { background: transparent; border: 1px solid var(--line); border-radius: 999px; min-height: 36px; padding: 6px 12px; color: var(--text); font: inherit; font-size: 13px; cursor: pointer; flex: 0 1 auto; width: auto; max-width: 52vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.authbox { max-width: 440px; margin: 24px auto; }
.authbox .err, .err { color: var(--bad); font-size: 15px; margin-top: 10px; }
label.check { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; color: var(--text); padding: 8px 0; cursor: pointer; }
label.check input { width: 22px; height: 22px; min-height: 0; flex: 0 0 auto; margin: 1px 0 0; padding: 0; }
