/* LiftLog styles.
   Colours: a slate "rubber floor" background with chalk text, and the four
   competition bumper-plate colours, each used for one meaning only:
     --yellow  the main action (Log set, Start)
     --green   improvement (▲)
     --red     drops (▼), personal records, delete
     --blue    links, charts, selection
*/

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

:root {
  --floor: #1d2328;
  --surface: #262d34;
  --raised: #303841;
  --line: #3b444d;
  --chalk: #eceae6;
  --dust: #9ba4ad;
  --yellow: #f0b429;
  --on-yellow: #1d2328;
  --green: #45b883;
  --red: #ec5a54;
  --blue: #5b98f7;
  --focus: #8fb8ff;

  --font: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Barlow Condensed", "Barlow", system-ui, sans-serif;
  --radius-s: 8px;
  --radius-l: 14px;
  --tabbar: 64px;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --floor: #f2f3f4;
    --surface: #ffffff;
    --raised: #e7eaed;
    --line: #d3d8dd;
    --chalk: #1d2328;
    --dust: #5c6670;
    --yellow: #f0b429;
    --green: #1f8a59;
    --red: #cf3a34;
    --blue: #2f6fd6;
    --focus: #2f6fd6;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--floor);
  color: var(--chalk);
  font: 400 17px/1.45 var(--font);
  font-variant-numeric: tabular-nums;
  padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 24px);
}
body.timing { padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 96px); }

main { max-width: 560px; margin: 0 auto; padding: 0 16px; }

h1, h2, h3 { font-family: var(--display); font-weight: 700; line-height: 1.1; margin: 0; letter-spacing: .01em; }
h1 { font-size: 2rem; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.2rem; }
p { margin: 0 0 .75em; }
a { color: var(--blue); }
.muted { color: var(--dust); }
.small { font-size: .9rem; }
.num { font-family: var(--display); font-weight: 600; }
.up { color: var(--green); }
.down { color: var(--red); }
.hidden { display: none !important; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- Page header ---------- */
.page-head { padding: 22px 0 14px; display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.page-head p { margin: 4px 0 0; }

/* ---------- Buttons ---------- */
button, .btn {
  font: 600 1rem/1 var(--font);
  border: 0; border-radius: var(--radius-s);
  min-height: 48px; padding: 0 18px;
  background: var(--raised); color: var(--chalk);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
button:active, .btn:active { transform: translateY(1px); }
button:disabled { opacity: .5; }
.btn-primary { background: var(--yellow); color: var(--on-yellow); }
.btn-danger { background: transparent; color: var(--red); border: 2px solid var(--red); }
.btn-quiet { background: transparent; color: var(--blue); padding: 0 10px; }
.btn-block { width: 100%; }
.btn-big { min-height: 60px; font-size: 1.15rem; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row > * { flex: 1; }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; margin: 14px 0 6px; }
input, select, textarea {
  width: 100%; font: 400 1.05rem var(--font); color: var(--chalk);
  background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius-s);
  min-height: 48px; padding: 8px 12px;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--focus); outline: none; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 400; }
.check input { width: 26px; height: 26px; min-height: 0; accent-color: var(--yellow); }
.field-row { display: flex; gap: 10px; }
.field-row > div { flex: 1; }
.error-msg { color: var(--red); font-weight: 600; margin: 10px 0; }

/* ---------- Lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-bottom: 1px solid var(--line); }
.list > li:first-child { border-top: 1px solid var(--line); }
.row-link {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 2px; color: inherit; text-decoration: none; min-height: 60px; width: 100%;
  background: none; border-radius: 0; text-align: left; font-weight: 400;
}
.row-link strong { display: block; font-weight: 600; }
.row-link .chev { color: var(--dust); font-size: 1.3rem; }
.group-title { margin: 26px 0 8px; font-family: var(--display); font-size: 1.15rem; color: var(--dust); }

/* ---------- Home ---------- */
.resume {
  background: var(--surface); border-left: 6px solid var(--yellow);
  border-radius: var(--radius-s); padding: 16px; margin: 6px 0 20px;
}
.resume h2 { margin-bottom: 4px; }
.routine-pick { display: grid; gap: 10px; margin-bottom: 8px; }
.routine-pick button {
  justify-content: space-between; min-height: 72px; padding: 12px 16px;
  background: var(--surface); text-align: left; flex-direction: row;
}
.routine-pick .rname { font-family: var(--display); font-size: 1.5rem; font-weight: 700; }
.routine-pick .rmeta { color: var(--dust); font-weight: 400; font-size: .92rem; text-align: right; }

/* ---------- Workout screen ---------- */
.workout-bar {
  position: sticky; top: 0; z-index: 5; background: var(--floor);
  padding: 10px 0; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line);
}
.workout-bar .title { flex: 1; min-width: 0; }
.workout-bar h1 { font-size: 1.5rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.workout-bar .meta { color: var(--dust); font-size: .9rem; display: flex; gap: 10px; align-items: center; }
.workout-bar input[type=date] { min-height: 32px; padding: 2px 6px; width: auto; font-size: .9rem; border-width: 1px; }

.ex { border-bottom: 1px solid var(--line); }
.ex-head {
  width: 100%; background: none; border-radius: 0; min-height: 68px; padding: 12px 2px;
  display: flex; justify-content: space-between; align-items: center; text-align: left; gap: 12px; font-weight: 400;
}
.ex-head h2 { font-size: 1.35rem; }
.ex-head .sub { color: var(--dust); font-size: .92rem; margin-top: 2px; }
.ex-tally { font-family: var(--display); font-size: 1.25rem; font-weight: 700; white-space: nowrap; }
.ex-tally.done { color: var(--green); }
.ex.open .ex-head { padding-bottom: 4px; }
.ex-body { display: none; padding: 0 0 18px; }
.ex.open .ex-body { display: block; }

.last-time { color: var(--dust); font-size: .95rem; margin: 2px 0 10px; }
.last-time b { color: var(--chalk); font-weight: 600; }
.hint {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--surface); border-radius: var(--radius-s); padding: 8px 8px 8px 12px; margin: 0 0 12px; font-size: .95rem;
}
.hint button { min-height: 40px; }

.sets { list-style: none; margin: 0 0 12px; padding: 0; }
.sets li button {
  width: 100%; background: none; border-radius: 0; min-height: 48px; padding: 6px 2px;
  display: grid; grid-template-columns: 2.2rem 1fr auto; align-items: center; gap: 8px; text-align: left; font-weight: 400;
  border-top: 1px dashed var(--line);
}
.sets .n { color: var(--dust); font-family: var(--display); font-size: 1.1rem; }
.sets .v { font-family: var(--display); font-size: 1.45rem; font-weight: 600; }
.sets .warm .v { color: var(--dust); }
.tag {
  display: inline-block; font: 600 .8rem/1 var(--font); padding: 5px 7px; border-radius: 5px;
  background: var(--raised); color: var(--dust); white-space: nowrap;
}
.tag-pr { background: var(--red); color: #fff; }
.tags { display: flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; }

/* The set-entry block: the one loud thing in the app. */
.entry { background: var(--surface); border-radius: var(--radius-l); padding: 14px; }
.entry-label { display: flex; justify-content: space-between; color: var(--dust); font-size: .95rem; margin-bottom: 10px; }
.stepper { display: grid; grid-template-columns: 64px 1fr 64px; align-items: center; gap: 8px; margin-bottom: 10px; }
.stepper button { min-height: 64px; font: 700 2rem/1 var(--display); padding: 0; background: var(--raised); }
.stepper .val { position: relative; }
.stepper input {
  text-align: center; font: 700 2.9rem/1 var(--display); min-height: 64px; padding: 0 34px 0 4px;
  background: transparent; border: 2px solid transparent;
}
.stepper input:focus { border-color: var(--focus); }
.stepper .unit { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); color: var(--dust); font-size: .9rem; pointer-events: none; }
.entry-foot { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: stretch; }
.toggle {
  min-height: 60px; padding: 0 14px; background: var(--raised); color: var(--dust);
  border: 2px solid transparent; font-weight: 600;
}
.toggle[aria-pressed="true"] { color: var(--chalk); border-color: var(--dust); }

.ex-tools { display: flex; justify-content: flex-end; gap: 4px; margin-top: 8px; }
.add-ex { margin: 18px 0; }
.finish-area { margin: 26px 0 10px; }

/* ---------- Rest timer ---------- */
.timer {
  position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom)); z-index: 20;
  background: var(--raised); border-top: 3px solid var(--yellow);
}
.timer-inner { max-width: 560px; margin: 0 auto; padding: 8px 16px; display: flex; align-items: center; gap: 8px; }
.timer .clock { font: 700 2.2rem/1 var(--display); flex: 1; }
.timer .clock small { font: 400 .9rem var(--font); color: var(--dust); margin-left: 6px; }
.timer button { min-height: 48px; padding: 0 12px; background: var(--surface); }
.timer.done { border-top-color: var(--green); }
.timer.done .clock { color: var(--green); }
.timer-bar { height: 4px; background: var(--yellow); transform-origin: left; }

/* ---------- Bottom tab bar ---------- */
.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);
}
.tabbar nav { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); }
.tabbar a {
  height: var(--tabbar); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--dust); text-decoration: none; font-size: .82rem; font-weight: 600;
}
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a[aria-current="page"] { color: var(--chalk); }
.tabbar a[aria-current="page"] svg { color: var(--yellow); }

/* ---------- Bottom sheet (dialogs) ---------- */
.sheet-back { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 40; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 88vh; overflow-y: auto;
  background: var(--floor); border-radius: var(--radius-l) var(--radius-l) 0 0;
  padding: 18px 16px calc(20px + env(safe-area-inset-bottom));
  max-width: 560px; margin: 0 auto;
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.sheet .btn-row { margin-top: 18px; }
@media (prefers-reduced-motion: no-preference) {
  .sheet { animation: rise .18s ease-out; }
  @keyframes rise { from { transform: translateY(30px); opacity: .6; } }
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; top: 14px; transform: translateX(-50%); z-index: 60;
  background: var(--chalk); color: var(--floor); padding: 12px 18px; border-radius: var(--radius-s);
  font-weight: 600; width: max-content; max-width: calc(100vw - 32px); text-align: center; box-shadow: 0 6px 20px rgba(0,0,0,.3);
}
.toast.pr { background: var(--red); color: #fff; font-family: var(--display); font-size: 1.3rem; }

/* ---------- Summary / comparisons ---------- */
.totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border-radius: var(--radius-s); overflow: hidden; margin-bottom: 22px; }
.totals div { background: var(--surface); padding: 12px; }
.totals .big { font: 700 1.6rem/1.1 var(--display); display: block; }
.totals .lbl { color: var(--dust); font-size: .85rem; }

.cmp { padding: 16px 0; border-bottom: 1px solid var(--line); }
.cmp-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.cmp .tally { font-family: var(--display); font-size: 1.15rem; color: var(--dust); margin-bottom: 8px; }
.cmp table { width: 100%; border-collapse: collapse; font-size: .98rem; }
.cmp td { padding: 4px 0; vertical-align: baseline; }
.cmp td:first-child { color: var(--dust); width: 34%; }
.cmp td.now { font-family: var(--display); font-size: 1.2rem; font-weight: 600; }
.cmp td.delta { text-align: right; white-space: nowrap; font-weight: 600; }

/* ---------- Segmented control ---------- */
.seg { display: flex; background: var(--surface); border-radius: var(--radius-s); padding: 4px; gap: 4px; margin: 6px 0 16px; }
.seg button { flex: 1; min-height: 42px; background: none; color: var(--dust); padding: 0 6px; font-size: .95rem; }
.seg button[aria-pressed="true"] { background: var(--raised); color: var(--chalk); }

/* ---------- Charts & tables ---------- */
.chart-box { position: relative; height: 240px; margin-bottom: 18px; }
.records { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.record { background: var(--surface); border-radius: var(--radius-s); padding: 10px 12px; }
.record .big { font: 700 1.5rem/1.1 var(--display); display: block; }
.record .lbl { color: var(--dust); font-size: .85rem; }
.hist td { padding: 10px 6px 10px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.hist { width: 100%; border-collapse: collapse; }
.hist .d { white-space: nowrap; color: var(--dust); width: 5.5rem; }
.hist .s { font-family: var(--display); font-size: 1.1rem; }

/* Consistency calendar: 7 rows (Mon–Sun) × N weeks. */
.cal { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 1fr); gap: 4px; margin: 8px 0 6px; }
.cal span { aspect-ratio: 1; border-radius: 4px; background: var(--surface); }
.cal span.on { background: var(--green); }
.cal span.today { outline: 2px solid var(--dust); outline-offset: -2px; }
.cal span.future { background: transparent; }

/* ---------- Manage ---------- */
.re-row { padding: 12px 0; border-bottom: 1px solid var(--line); }
.re-row .top { display: flex; align-items: center; gap: 6px; }
.re-row .top strong { flex: 1; }
.re-row .top button { min-height: 44px; min-width: 44px; padding: 0 8px; }
.re-row .targets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
.re-row .targets label { margin: 0 0 4px; font-size: .82rem; color: var(--dust); font-weight: 400; }
.re-row .targets input { min-height: 44px; }
.picker-search { position: sticky; top: -18px; background: var(--floor); padding: 4px 0 10px; }

.login { max-width: 380px; margin: 14vh auto 0; }
.login h1 { font-size: 3rem; margin-bottom: 6px; }
.empty { padding: 26px 0; }

/* ---------- Effort (RPE) ---------- */
.rpe-row { display: grid; grid-template-columns: auto repeat(5, 1fr); gap: 6px; align-items: center; margin: 2px 0 4px; }
.rpe-label { color: var(--dust); font-size: .95rem; padding-right: 4px; }
.rpe-row button { min-height: 48px; padding: 0; font: 700 1.25rem/1 var(--display); background: var(--raised); color: var(--dust); border: 2px solid transparent; }
.rpe-row button[aria-pressed="true"] { background: var(--blue); color: #fff; }
.rpe-help { color: var(--dust); font-size: .88rem; margin: 0 0 12px; min-height: 1.3em; }
.sets .v .rpe { font-size: 1rem; color: var(--blue); font-weight: 600; margin-left: 4px; }
