/* Weights — colours borrow from competition plates: red 25 kg, blue 20 kg, yellow 15 kg, green 10 kg. */

@font-face { font-family: "Barlow Condensed"; font-weight: 600; font-display: swap; src: url("/static/fonts/barlow-condensed-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 700; font-display: swap; src: url("/static/fonts/barlow-condensed-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 400; font-display: swap; src: url("/static/fonts/barlow-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 500; font-display: swap; src: url("/static/fonts/barlow-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 600; font-display: swap; src: url("/static/fonts/barlow-latin-600-normal.woff2") format("woff2"); }

:root {
  color-scheme: dark;
  --bg: #24272b;          /* rubber floor */
  --surface: #2e3237;
  --surface-2: #383d43;
  --line: #474d55;
  --text: #ecedea;        /* chalk */
  --muted: #9ba2a9;
  --red: #d7262e;         /* 25 kg */
  --red-ink: #ffffff;
  --blue: #3b7ddb;        /* 20 kg */
  --yellow: #f2c230;      /* 15 kg */
  --green: #34a865;       /* 10 kg */
  --chart: #ec4a52;       /* the red, lifted to read on the dark surface */
  --shadow: 0 8px 28px rgba(0, 0, 0, .35);
  --num: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
  --body: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  --r-sm: 8px;
  --r-md: 12px;
  --tabs-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #e8eaec;        /* concrete */
    --surface: #ffffff;
    --surface-2: #f1f2f4;
    --line: #d2d6db;
    --text: #1c1f23;
    --muted: #5d656e;
    --red: #c81e27;
    --blue: #2563c4;
    --yellow: #e0ad12;
    --green: #23884d;
    --chart: #c81e27;
    --shadow: 0 8px 24px rgba(20, 24, 30, .14);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 400 17px/1.45 var(--body);
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(var(--tabs-h) + var(--safe-b));
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; margin: 0; font: 700 26px/1 var(--num); letter-spacing: .01em; }
.brand-mark { width: 30px; height: 30px; color: var(--text); }

.sync {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 36px; padding: 6px 12px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  font-size: 14px; font-weight: 500; color: var(--muted);
}
.sync-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.sync[data-state="ok"] .sync-dot { background: var(--green); }
.sync[data-state="waiting"] .sync-dot { background: var(--yellow); }
.sync[data-state="busy"] .sync-dot { background: var(--blue); animation: pulse 1s ease-in-out infinite; }
.sync[data-state="login"] { color: var(--text); border-color: var(--red); }
.sync[data-state="login"] .sync-dot { background: var(--red); }
@keyframes pulse { 50% { opacity: .3; } }

main { padding: 16px 16px 32px; max-width: 640px; margin: 0 auto; outline: none; }

/* ---------- bottom tabs */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabs-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: var(--surface); border-top: 1px solid var(--line);
}
.tabs a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  text-decoration: none; color: var(--muted); font-size: 12.5px; font-weight: 500;
}
.tabs svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs a[aria-current="page"] { color: var(--text); }
.tabs a[aria-current="page"] svg { stroke: var(--red); stroke-width: 2.3; }

/* ---------- type */
h2 { font: 700 30px/1.05 var(--num); margin: 4px 0 14px; letter-spacing: .005em; }
h3 { font: 700 22px/1.1 var(--num); margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 14.5px; }
.num { font-family: var(--num); font-weight: 700; font-variant-numeric: tabular-nums; }
p { margin: 0 0 12px; }

/* ---------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 18px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface); font-weight: 600; text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--red); border-color: var(--red); color: var(--red-ink); }
.btn-big { width: 100%; min-height: 60px; font: 700 24px/1 var(--num); letter-spacing: .01em; }
.btn-quiet { background: transparent; border-color: transparent; color: var(--muted); }
.btn-danger { color: var(--red); background: transparent; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row > .btn { flex: 1; }
.link-btn { background: none; border: 0; padding: 6px 0; color: var(--muted); font-size: 15px; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- lists */
.list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); overflow: hidden; }
.list > li + li { border-top: 1px solid var(--line); }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 14px 16px; min-height: 60px;
  background: none; border: 0; text-align: left; text-decoration: none;
}
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: 14.5px; color: var(--muted); display: block; }
.row-end { font: 700 20px/1 var(--num); color: var(--muted); white-space: nowrap; }
.chev { color: var(--muted); font-size: 22px; line-height: 1; }

.section-label { font: 600 15px/1.2 var(--body); color: var(--muted); margin: 26px 0 8px; }
.week-label { font: 600 15px/1.2 var(--body); color: var(--muted); margin: 20px 0 8px; display: flex; justify-content: space-between; }

/* ---------- start screen */
.start-hero { padding: 8px 0 4px; }
.start-hero .date { font: 600 18px/1.2 var(--body); color: var(--muted); margin-bottom: 2px; }
.week-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 18px 0 20px; }
.day { text-align: center; font-size: 13px; color: var(--muted); }
.day b {
  display: grid; place-items: center; margin: 4px auto 0; width: 100%; aspect-ratio: 1; max-width: 42px;
  border-radius: 50%; border: 1px solid var(--line); font: 700 18px/1 var(--num); color: var(--muted);
}
.day.today b { border-color: var(--text); color: var(--text); }
.day.trained b { background: var(--red); border-color: var(--red); color: var(--red-ink); }

/* ---------- workout */
.wo-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.wo-title {
  flex: 1; min-width: 0; margin: 0; padding: 2px 0; border: 0; background: none;
  font: 700 30px/1.1 var(--num); border-bottom: 1px dashed transparent;
}
.wo-title:focus { border-bottom-color: var(--line); outline: none; }
.wo-clock { font: 700 26px/1.2 var(--num); color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 3px; }
.wo-meta { color: var(--muted); font-size: 15px; margin: -8px 0 14px; }

.ex {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 14px 12px 10px; margin-bottom: 14px;
}
.ex-head { display: flex; align-items: flex-start; gap: 8px; padding: 0 4px 2px; }
.ex-name { flex: 1; font: 700 23px/1.1 var(--num); background: none; border: 0; padding: 0; text-align: left; }
.ex-menu { background: none; border: 0; width: 40px; height: 34px; margin: -4px -6px 0 0; color: var(--muted); font-size: 22px; line-height: 1; border-radius: var(--r-sm); }
.ex-last { padding: 0 4px; font-size: 14.5px; color: var(--muted); margin: 2px 0 10px; }
.ex-note { width: 100%; margin: 4px 0 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); font-size: 15px; resize: none; }

.sets-head, .set {
  display: grid; grid-template-columns: 34px 1fr 18px 1fr 54px; align-items: center; gap: 6px;
}
.sets-head { padding: 0 2px 4px; font-size: 13px; color: var(--muted); text-align: center; }
.sets-head span:first-child { text-align: center; }
.set { padding: 4px 2px; border-radius: var(--r-sm); }
.set + .set { margin-top: 2px; }
.set-no {
  display: grid; place-items: center; width: 30px; height: 30px; justify-self: center;
  border-radius: 50%; border: 0; background: var(--surface-2); font: 700 17px/1 var(--num); color: var(--muted);
}
.set-no.warm { background: transparent; border: 1px dashed var(--line); color: var(--muted); font-size: 14px; }
.set-x { text-align: center; color: var(--muted); font-size: 15px; }
.set input {
  width: 100%; min-width: 0; height: 52px; padding: 0 6px; text-align: center;
  border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2);
  font: 700 27px/1 var(--num); font-variant-numeric: tabular-nums;
  -moz-appearance: textfield; appearance: textfield;
}
.set input::placeholder { color: var(--muted); opacity: .55; }
.set input:focus { outline: none; border-color: var(--blue); background: var(--surface); }
.set input::-webkit-outer-spin-button, .set input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.set .solo { grid-column: 2 / 5; }
.tick {
  width: 54px; height: 52px; border-radius: var(--r-sm);
  border: 2px solid var(--line); background: transparent; color: var(--muted);
  display: grid; place-items: center;
}
.tick svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.set.done .tick { background: var(--red); border-color: var(--red); color: var(--red-ink); }
.set.done input { border-color: transparent; background: transparent; }
.set.done .set-no { background: var(--text); color: var(--bg); }
.set.pr .set-no::after { content: ""; }
.pr-tag { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px; background: var(--yellow); color: #1c1f23; font: 700 13px/1.4 var(--num); letter-spacing: .02em; vertical-align: 2px; }
.set.just-done .tick { animation: thunk .28s ease-out; }
@keyframes thunk { 0% { transform: scale(.82); } 60% { transform: scale(1.06); } 100% { transform: scale(1); } }

.ex-foot { display: flex; gap: 8px; margin-top: 8px; }
.ex-foot .btn { flex: 1; min-height: 44px; font-size: 15.5px; }

.add-ex { width: 100%; min-height: 56px; border: 2px dashed var(--line); background: transparent; border-radius: var(--r-md); font-weight: 600; color: var(--text); margin-bottom: 22px; }

.empty { text-align: center; padding: 28px 12px; color: var(--muted); }
.empty svg { width: 64px; height: 64px; color: var(--muted); opacity: .6; margin-bottom: 8px; }

/* ---------- rest timer */
.rest {
  position: fixed; left: 10px; right: 10px; z-index: 25;
  bottom: calc(var(--tabs-h) + var(--safe-b) + 10px);
  max-width: 620px; margin: 0 auto;
  background: var(--text); color: var(--bg); border-radius: var(--r-md); overflow: hidden; box-shadow: var(--shadow);
}
.rest-bar { height: 5px; background: rgba(127,127,127,.35); }
.rest-fill { height: 100%; width: 100%; background: var(--red); transform-origin: left; }
.rest-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; }
.rest-time { flex: 1; text-align: center; font: 700 34px/1 var(--num); font-variant-numeric: tabular-nums; }
.rest-time small { display: block; font: 500 12.5px/1.2 var(--body); opacity: .7; }
.rest-btn { min-width: 54px; height: 44px; border: 0; border-radius: var(--r-sm); background: rgba(127,127,127,.18); color: inherit; font: 700 18px/1 var(--num); }
.rest-skip { font: 600 15px/1 var(--body); }
.rest.over { background: var(--red); color: #fff; }
.rest.over .rest-fill { background: #fff; }
body.resting main { padding-bottom: 110px; }
body.resting .toast { bottom: calc(var(--tabs-h) + var(--safe-b) + 106px); }

/* ---------- forms */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 15px; font-weight: 500; margin-bottom: 6px; color: var(--muted); }
.input, .field input, .field select, .field textarea {
  width: 100%; min-height: 50px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); font-size: 17px;
}
.field input:focus, .field select:focus, .input:focus { outline: none; border-color: var(--blue); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 0; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; }
.seg button { min-height: 46px; border: 0; background: var(--surface-2); font-weight: 600; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--text); color: var(--bg); }
.error { color: var(--red); font-weight: 500; margin: 0 0 12px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 16px; margin-bottom: 14px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; }
.kv + .kv { border-top: 1px solid var(--line); }

/* ---------- login */
.login { max-width: 420px; margin: 24px auto 0; }
.login-mark { width: 84px; height: 84px; display: block; margin: 0 0 14px; color: var(--text); }
.login h2 { font-size: 40px; }

/* ---------- progress */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 10px 12px; }
.stat b { display: block; font: 700 28px/1.05 var(--num); font-variant-numeric: tabular-nums; }
.stat span { font-size: 13px; color: var(--muted); }
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .line { fill: none; stroke: var(--chart); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--chart); stroke: var(--surface); stroke-width: 2; }
.chart text { fill: var(--muted); font: 500 12px var(--body); }
.chart .val { fill: var(--text); font: 700 14px var(--num); }
.chart .bar { fill: var(--chart); }
.chart .bar.now { opacity: .55; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .col { fill: transparent; }
.chart .guide { stroke: var(--muted); stroke-width: 1; opacity: 0; }
.chart .pt.on .guide { opacity: .6; }
.chart .pt.on .dot { fill: var(--text); }
.chart .pt.on .col { fill: var(--surface-2); }
.chart-read { font: 600 16px/1.3 var(--body); margin-bottom: 6px; min-height: 21px; }

/* ---------- plans */
.week-card { display: block; text-decoration: none; padding: 8px 16px; }
.plan-row { display: flex; align-items: center; }
.plan-row .row { flex: 1; min-width: 0; }
.plan-go { min-height: 44px; margin-right: 12px; padding: 8px 18px; }
.plan-name { display: block; width: 100%; margin-bottom: 4px; }
.plan-name::placeholder { color: var(--muted); opacity: .6; }
.plan-item { padding: 12px 14px; }
.plan-ex { display: block; width: 100%; background: none; border: 0; padding: 0 0 8px; text-align: left; font: 700 21px/1.15 var(--num); }
.plan-fields { display: flex; align-items: center; gap: 10px; }
.stepper { display: flex; align-items: center; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); }
.stepper button { width: 44px; height: 48px; border: 0; background: none; font: 700 22px/1 var(--num); color: var(--muted); }
.stepper span { min-width: 44px; text-align: center; line-height: 1; }
.stepper b, .reps-target input { font: 700 24px/1 var(--num); font-variant-numeric: tabular-nums; }
.stepper small, .reps-target small { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.reps-target { flex: 1; display: flex; flex-direction: column; align-items: center; }
.reps-target input { width: 100%; height: 48px; text-align: center; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); }
.reps-target input:focus { outline: none; border-color: var(--blue); }
.reps-target small { margin-top: 3px; }
.ex-plan { padding: 0 4px; font-size: 14.5px; font-weight: 600; margin-top: 2px; }
.vol-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 6px 14px 12px; margin-bottom: 14px; }
.vol-card a { color: var(--muted); }
.vol-bar { height: 6px; border-radius: 3px; background: var(--surface-2); margin-top: 8px; overflow: hidden; }
.vol-bar div { height: 100%; background: var(--chart); border-radius: 3px; transition: width .3s ease-out; }
.wo-meta a { color: inherit; }
.session { padding: 12px 16px; }
.session-sets { font: 600 18px/1.4 var(--num); font-variant-numeric: tabular-nums; }

/* ---------- sheet (pop-up from the bottom) */
.sheet {
  width: 100%; max-width: 640px; max-height: 88dvh; margin: auto auto 0; padding: 0;
  border: 0; border-radius: 18px 18px 0 0; background: var(--surface); color: var(--text);
  box-shadow: var(--shadow);
}
.sheet::backdrop { background: rgba(10, 12, 14, .55); }
.sheet[open] { animation: rise .22s ease-out; }
@keyframes rise { from { transform: translateY(40px); opacity: .4; } }
.sheet-in { padding: 10px 16px calc(18px + var(--safe-b)); }
.sheet-grip { width: 42px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet h3 { margin-bottom: 12px; }
.sheet-list { max-height: 52dvh; overflow-y: auto; margin: 10px -16px 12px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.sheet-list .row { border-radius: 0; }
.sheet-list .row + .row { border-top: 1px solid var(--line); }
.sheet-list .row[aria-pressed="true"] { background: var(--surface-2); }
.sheet-list .row[aria-pressed="true"] .chev { color: var(--red); }
.menu-btn { width: 100%; justify-content: flex-start; border-radius: 0; border-left: 0; border-right: 0; border-top: 0; background: none; min-height: 54px; }

/* ---------- toast / update */
.toast {
  position: fixed; left: 16px; right: 16px; z-index: 40; max-width: 600px; margin: 0 auto;
  bottom: calc(var(--tabs-h) + var(--safe-b) + 12px);
  padding: 12px 14px; border-radius: var(--r-md); background: var(--text); color: var(--bg);
  font-weight: 500; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 12px;
}
.toast .btn { min-height: 38px; padding: 6px 12px; background: var(--red); border-color: var(--red); color: #fff; margin-left: auto; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
