/* Lift — graphite, chalk, and plate colours that only appear where they mean something.
   blue = tier 1 / rest, yellow = tier 2 / PR, green = tier 3 / done, red = miss. */
:root {
  --base: #1c1f25;
  --surface: #252a32;
  --raised: #303640;
  --line: #3b424e;
  --chalk: #efebe2;
  --muted: #a7a49c;
  --dim: #77756f;
  --blue: #4a86d6;
  --yellow: #e6b53c;
  --green: #55a872;
  --red: #d8573f;
  --white-plate: #d9d6cf;
  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 22px;
  --tab-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --body: 'Barlow', system-ui, sans-serif;
  --num: 'Barlow Condensed', 'Barlow', system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--base); }
body {
  margin: 0; min-height: 100dvh; background: var(--base); color: var(--chalk);
  font: 400 16px/1.45 var(--body); -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--tab-h) + var(--safe-b) + 16px);
  overscroll-behavior-y: none;
}
body.has-rest { padding-bottom: calc(var(--tab-h) + var(--safe-b) + 92px); }
body.locked { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 6px; }
.ic { width: 22px; height: 22px; flex: none; }
#view { max-width: 640px; margin: 0 auto; padding: calc(env(safe-area-inset-top, 0px) + 18px) 16px 0; outline: none; }
.num { font-family: var(--num); font-variant-numeric: tabular-nums; }
h1, h2, h3 { margin: 0; font-weight: 600; }
p { margin: 0; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }

/* ---------- buttons ---------- */
.btn {
  min-height: 48px; padding: 0 18px; border-radius: var(--r-md); border: 1px solid var(--line);
  background: var(--surface); font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn.primary { background: var(--chalk); color: var(--base); border-color: var(--chalk); }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .45; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 12px; border: 0; background: transparent; color: var(--muted);
  display: inline-grid; place-items: center;
}
.icon-btn:active { background: var(--raised); }
.row-btns { display: flex; gap: 10px; margin-top: 18px; }
.row-btns .btn { flex: 1; }
.chip {
  min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: transparent;
  font-weight: 500; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--chalk); color: var(--base); border-color: var(--chalk); }

/* ---------- train header ---------- */
.day-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.day-title { font: 700 56px/0.9 var(--num); letter-spacing: -0.01em; }
.day-sub { color: var(--muted); margin-top: 6px; }
.clock { text-align: right; }
.clock .num { font-size: 30px; font-weight: 600; line-height: 1; }
.clock small { display: block; color: var(--muted); font-size: 13px; }
.days { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 16px; padding: 2px 16px; scrollbar-width: none; }
.days::-webkit-scrollbar { display: none; }
.days .chip .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--blue); }

.banner {
  border-radius: var(--r-md); padding: 12px 14px; margin-bottom: 12px; background: var(--surface);
  display: flex; align-items: center; gap: 12px; justify-content: space-between; flex-wrap: wrap;
}
.banner p { flex: 1 1 200px; }
.banner.deload { border-left: 3px solid var(--blue); }
.checkin { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- exercise cards ---------- */
.ex-list { display: flex; flex-direction: column; gap: 10px; }
.ex {
  background: var(--surface); border-radius: var(--r-lg); border: 1px solid transparent;
  transition: border-color .2s;
}
.ex.open { border-color: var(--line); }
.ex.done:not(.open) { opacity: .72; }
.ex-top { display: flex; align-items: center; gap: 12px; padding: 14px 8px 14px 14px; width: 100%; background: none; border: 0; text-align: left; }
.plate-tag {
  width: 12px; height: 34px; border-radius: 3px; flex: none; background: var(--dim);
}
.plate-tag.t1 { background: var(--blue); }
.plate-tag.t2 { background: var(--yellow); }
.plate-tag.t3 { background: var(--green); }
.plate-tag.tab { background: var(--white-plate); }
.ex-main { flex: 1; min-width: 0; }
.ex-name { font-weight: 600; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.ex-rx { display: block; color: var(--muted); font-size: 14px; margin-top: 1px; }
.ex-rx b { color: var(--chalk); font-weight: 600; }
.ex-pr { color: var(--yellow); font-size: 12px; font-weight: 600; }
.ex-dots { display: flex; gap: 4px; }
.ex-dots i { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--dim); }
.ex-dots i.on { background: var(--green); border-color: var(--green); }
.ex-dots i.miss { background: var(--red); border-color: var(--red); }

.ex-body { padding: 0 14px 16px; }
.ex-note { color: var(--muted); font-size: 14px; margin-bottom: 12px; }
.ex-tools { display: flex; gap: 2px; margin: -4px -6px 10px; }
.ex-tools .icon-btn { color: var(--muted); }
.target { font-size: 14px; color: var(--muted); margin-bottom: 10px; }
.target strong { color: var(--chalk); }
.target.add strong { color: var(--green); }

.warm { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.warm span.label { color: var(--dim); font-size: 13px; margin-right: 2px; }
.warm .chip { min-height: 34px; font-size: 14px; padding: 0 10px; }
.warm .chip.done { text-decoration: line-through; color: var(--dim); }

.setrows { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.setrow {
  display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px;
  min-height: 46px; padding: 0 10px; border-radius: 12px; background: var(--base); border: 0; width: 100%; text-align: left;
}
.setrow .n { color: var(--dim); font: 600 15px var(--num); }
.setrow .v { font: 600 22px var(--num); }
.setrow .v small { font: 500 14px var(--body); color: var(--muted); margin-left: 4px; }
.setrow.todo .v { color: var(--dim); font-weight: 500; }
.setrow .tag { font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 999px; }
.tag.pr { background: color-mix(in srgb, var(--yellow) 22%, transparent); color: var(--yellow); }
.tag.miss { color: var(--red); }
.tag.ok { color: var(--green); }

/* the logger: the one loud thing on the page */
.logger { background: var(--raised); border-radius: var(--r-md); padding: 12px; }
.logger-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 8px; }
.stepper { display: grid; grid-template-columns: 40px 1fr 40px; align-items: center; background: var(--base); border-radius: 12px; }
.stepper button { height: 64px; border: 0; background: none; color: var(--muted); display: grid; place-items: center; }
.stepper button:active { color: var(--chalk); }
.stepper label { display: flex; flex-direction: column; align-items: center; }
.stepper input {
  width: 100%; border: 0; background: none; text-align: center; padding: 0;
  font: 700 34px/1 var(--num); font-variant-numeric: tabular-nums; -moz-appearance: textfield; letter-spacing: -0.01em;
}
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }
.stepper span { font-size: 12px; color: var(--dim); margin-top: 2px; }
.logbtn {
  margin-top: 10px; width: 100%; min-height: 56px; border-radius: 12px; border: 0;
  background: var(--chalk); color: var(--base); font: 700 22px var(--num); letter-spacing: .01em;
}
.logbtn:active { transform: scale(.985); }
.logger-foot { display: flex; justify-content: space-between; margin-top: 8px; }
.linkbtn { background: none; border: 0; color: var(--muted); min-height: 40px; padding: 0 4px; font-size: 14px; text-decoration: underline; text-underline-offset: 3px; }

.finish { margin: 22px 0 8px; }
.empty { text-align: center; padding: 40px 10px; color: var(--muted); }

/* ---------- rest bar ---------- */
.restbar {
  position: fixed; left: 12px; right: 12px; bottom: calc(var(--tab-h) + var(--safe-b) + 8px); z-index: 20;
  max-width: 616px; margin: 0 auto; border-radius: 18px; background: var(--blue); color: #fff;
  display: flex; align-items: center; gap: 6px; padding: 8px 8px 8px 16px; overflow: hidden;
}
.restbar[hidden] { display: none; }
.restbar .fill { position: absolute; inset: 0; background: rgba(0,0,0,.18); transform-origin: left; pointer-events: none; }
.restbar > * { position: relative; }
.restbar .t { font: 700 32px/1 var(--num); font-variant-numeric: tabular-nums; min-width: 72px; }
.restbar .lbl { flex: 1; font-size: 14px; line-height: 1.2; min-width: 0; }
.restbar .lbl small { display: block; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.restbar button { min-width: 48px; height: 44px; border-radius: 12px; border: 0; background: rgba(255,255,255,.16); color: #fff; font: 600 16px var(--num); }
.restbar.over { background: var(--green); }

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; display: flex; justify-content: space-around;
  height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--base) 92%, transparent); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--dim); text-decoration: none; font-size: 12px; font-weight: 500;
}
.tabbar a[aria-current="page"] { color: var(--chalk); }

/* ---------- sheets ---------- */
dialog.sheet {
  border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 640px; max-height: 92dvh;
  background: var(--surface); color: var(--chalk); border-radius: var(--r-lg) var(--r-lg) 0 0;
}
dialog.sheet::backdrop { background: rgba(10, 12, 15, .6); }
.sheet-inner { display: flex; flex-direction: column; max-height: 92dvh; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 10px 4px 18px; }
.sheet-head h2 { font: 700 26px var(--num); }
.sheet-body { padding: 4px 18px calc(22px + var(--safe-b)); overflow-y: auto; }
.sheet-msg { font-size: 17px; margin-top: 8px; }
@media (prefers-reduced-motion: no-preference) {
  dialog.sheet[open] { animation: up .22s cubic-bezier(.2,.8,.2,1); }
  dialog.sheet.closing { animation: down .14s ease-in forwards; }
  @keyframes up { from { transform: translateY(40px); opacity: 0; } }
  @keyframes down { to { transform: translateY(40px); opacity: 0; } }
  .toast { transition: transform .2s ease-out, opacity .2s; }
}
@media (min-width: 700px) {
  dialog.sheet { margin: auto; border-radius: var(--r-lg); }
}

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label, .field .lbl { font-size: 14px; color: var(--muted); }
.field input, .field textarea, .field select {
  min-height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--base); padding: 10px 12px; font-size: 16px;
}
.field textarea { min-height: 90px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }

.pick { display: flex; flex-direction: column; gap: 6px; }
.pick button {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 54px; padding: 8px 14px;
  border-radius: 12px; border: 0; background: var(--base); text-align: left;
}
.pick button small { color: var(--muted); }
.pick h3 { font-size: 14px; color: var(--muted); font-weight: 500; margin: 12px 0 2px; }

.menu-list { display: flex; flex-direction: column; }
.menu-list button {
  display: flex; align-items: center; gap: 14px; min-height: 54px; border: 0; background: none; text-align: left; font-size: 17px;
  border-bottom: 1px solid var(--line); padding: 0 4px;
}
.menu-list button:last-child { border-bottom: 0; }
.menu-list button.danger { color: var(--red); }

/* form info */
.form-meta { color: var(--muted); font-size: 14px; margin-bottom: 10px; }
.form-gist { font-size: 17px; margin-bottom: 14px; }
.form-steps { margin: 0 0 14px; padding-left: 22px; }
.form-steps li { margin-bottom: 6px; }
.cues { display: flex; flex-direction: column; gap: 6px; }
.cues p { padding-left: 12px; border-left: 3px solid var(--yellow); }

/* plates */
.barviz { display: flex; align-items: center; height: 120px; margin: 10px 0 14px; overflow-x: auto; }
.barviz .sleeve { height: 14px; flex: 1 0 30px; background: var(--dim); border-radius: 0 4px 4px 0; }
.barviz .collar { width: 10px; height: 34px; background: var(--muted); border-radius: 3px; flex: none; }
.barviz .shaft { height: 10px; width: 46px; background: var(--dim); flex: none; }
.plate { flex: none; border-radius: 4px; margin-right: 2px; display: grid; place-items: center; font: 700 12px var(--num); color: rgba(0,0,0,.75); writing-mode: vertical-rl; }
.plate.p45 { background: var(--blue); width: 22px; height: 116px; }
.plate.p35 { background: var(--yellow); width: 20px; height: 100px; }
.plate.p25 { background: var(--green); width: 18px; height: 86px; }
.plate.p10 { background: var(--white-plate); width: 14px; height: 64px; }
.plate.p5 { background: var(--red); width: 12px; height: 50px; }
.plate.p2-5, .plate.pother { background: var(--muted); width: 10px; height: 40px; }
.plate-list { font: 600 22px var(--num); }

/* ---------- progress ---------- */
.page-title { font: 700 44px/1 var(--num); margin-bottom: 14px; }
.tabs-seg { display: flex; gap: 6px; margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.list { display: flex; flex-direction: column; gap: 8px; }
.list-row {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; padding: 12px 14px;
  border-radius: var(--r-md); background: var(--surface); border: 0; text-align: left; width: 100%;
}
.list-row .t { font-weight: 600; }
.list-row .s { color: var(--muted); font-size: 14px; }
.list-row .big { font: 600 24px var(--num); text-align: right; }
.list-row .big small { font: 500 13px var(--body); color: var(--muted); display: block; }
.spark { width: 84px; height: 30px; }
.section-h { font-size: 15px; color: var(--muted); font-weight: 500; margin: 20px 0 8px; }

.chart { width: 100%; height: auto; display: block; margin: 4px 0 6px; }
.chart text { fill: var(--dim); font: 500 11px var(--body); }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.stat { background: var(--base); border-radius: 12px; padding: 10px 12px; }
.stat b { display: block; font: 600 26px/1.1 var(--num); }
.stat span { font-size: 13px; color: var(--muted); }
table.log { width: 100%; border-collapse: collapse; font-size: 15px; }
table.log td { padding: 9px 4px; border-top: 1px solid var(--line); vertical-align: top; }
table.log td:last-child { text-align: right; }

.vol { display: flex; flex-direction: column; gap: 10px; }
.vol-row { display: grid; grid-template-columns: 104px 1fr 44px; align-items: center; gap: 10px; font-size: 15px; }
.vol-track { position: relative; height: 18px; background: var(--surface); border-radius: 5px; }
.vol-bar { position: absolute; left: 0; top: 0; bottom: 0; background: var(--chalk); border-radius: 5px; }
.vol-prev { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--muted); border-radius: 2px; }
.vol-row .num { font-size: 20px; font-weight: 600; text-align: right; }
.vol-row.low .vol-bar { background: var(--red); }
.vol-row.low .name { color: var(--red); }

/* ---------- summary ---------- */
.summary-big { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 6px 0 14px; }
.summary-big .stat b { font-size: 34px; }
.pr-list p { padding: 8px 0; border-top: 1px solid var(--line); }
.pr-list p:first-child { border-top: 0; }

/* ---------- settings ---------- */
.card { background: var(--surface); border-radius: var(--r-lg); padding: 16px; margin-bottom: 12px; }
.card h2 { font: 700 24px var(--num); margin-bottom: 10px; }
.card p + p { margin-top: 8px; }
.toggle { display: flex; align-items: center; justify-content: space-between; min-height: 48px; gap: 12px; }
.toggle input { width: 24px; height: 24px; accent-color: var(--chalk); }
.sync-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--dim); margin-right: 6px; }
.sync-dot.idle { background: var(--green); } .sync-dot.error { background: var(--red); } .sync-dot.syncing { background: var(--blue); }

.toast {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 12px); z-index: 50;
  transform: translate(-50%, -80px); opacity: 0; background: var(--chalk); color: var(--base);
  padding: 10px 16px; border-radius: 12px; font-weight: 600; max-width: calc(100% - 32px); pointer-events: none;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.pr { background: var(--yellow); }

/* PR flash on the logged row */
@media (prefers-reduced-motion: no-preference) {
  .setrow.flash { animation: flash 1.2s ease-out; }
  @keyframes flash { 0% { background: color-mix(in srgb, var(--yellow) 45%, var(--base)); } 100% { background: var(--base); } }
}
.grid2 > * { min-width: 0; }
.field input, .field textarea, .field select { width: 100%; min-width: 0; }
