/* w8tz: chalk-grey floor, slate ink, one plate-blue accent.
   The weight/reps steppers are the loud element; everything else stays quiet. */

:root {
  color-scheme: light;
  --bg: #e9edf0;
  --surface: #ffffff;
  --ink: #1f2a33;
  --muted: #5c6b77;
  --line: #cbd3da;
  --accent: #1d5fb8;
  --accent-ink: #ffffff;
  --strava: #fc4c02;
  --danger: #b3261e;
  --display: "Barlow Condensed", "Roboto Condensed", "Arial Narrow", sans-serif;
  --body: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --r: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #182026;
    --surface: #222c34;
    --ink: #e7ecef;
    --muted: #98a6b1;
    --line: #36444f;
    --accent: #5b9bef;
    --accent-ink: #0f1a24;
    --strava: #fc5a1a;
    --danger: #f2827a;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.45 var(--body);
  padding-bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px));
}

a { color: var(--accent); }

/* ---------- chrome ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: calc(.8rem + env(safe-area-inset-top, 0px)) 1rem .65rem;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { margin: 0; font: 700 1.8rem/1 var(--display); }
.clock { font: 600 1.35rem/1 var(--display); font-variant-numeric: tabular-nums; color: var(--accent); }

main { max-width: 34rem; margin: 0 auto; padding: 1rem 1rem 2rem; }

.tabs {
  position: fixed;
  inset: auto 0 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tabs a {
  padding: .8rem .25rem .9rem;
  text-align: center;
  text-decoration: none;
  color: var(--muted);
  font: 600 1.05rem/1 var(--display);
  border-top: 3px solid transparent;
}
.tabs a[aria-current="page"] { color: var(--ink); border-top-color: var(--accent); }

/* ---------- controls ---------- */
button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  min-height: 3rem;
  padding: .75rem 1.1rem;
  border: 2px solid transparent;
  border-radius: var(--r);
  background: none;
  color: inherit;
  font: 600 1.15rem/1 var(--display);
  letter-spacing: .01em;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
button:active { transform: translateY(1px); }
button:disabled { opacity: .55; cursor: default; transform: none; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.primary { background: var(--accent); color: var(--accent-ink); }
.strava { background: var(--strava); color: #fff; }
/* Official button artwork when present; orange text button as fallback */
.strava-connect { padding: 0; min-height: 0; border: 0; border-radius: 4px; }
.strava-connect img { display: block; height: 48px; width: auto; }
.strava-connect span { display: none; }
.strava-connect.fallback { min-height: 3rem; padding: .75rem 1.1rem; background: var(--strava); color: #fff; border-radius: var(--r); }
.strava-connect.fallback span { display: inline; }
.ghost { background: var(--surface); border-color: var(--line); }
.danger { color: var(--danger); }
.small { min-height: 2.5rem; padding: .45rem .85rem; font-size: 1rem; }
.big { width: 100%; min-height: 5.5rem; font-size: 1.75rem; }
.link { min-height: 0; padding: 0; font: 700 1.35rem/1.15 var(--display); text-align: left; }
.icon { width: 2.5rem; min-height: 2.5rem; padding: 0; color: var(--muted); font: 400 1.5rem/1 var(--body); }

.field { display: grid; gap: .3rem; margin: 0 0 .9rem; }
.field > span { color: var(--muted); font-size: .875rem; font-weight: 500; }
.field.gap { margin-top: 1rem; }

input, select, textarea {
  width: 100%;
  min-height: 3rem;
  padding: .65rem .8rem;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: inherit;
  font: inherit;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; }

/* ---------- today ---------- */
.entry {
  margin-bottom: 1.25rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.entry input:not([type]), .entry input[list] { background: var(--bg); }
.setup { margin: -.3rem 0 .4rem; font-weight: 600; }
.last { margin: -.3rem 0 .4rem; color: var(--muted); font-size: .95rem; }

.steppers { display: grid; gap: .5rem; margin: .75rem 0 1rem; }
.stepper { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .2rem; }

/* the plates */
.stepper button {
  width: 3.25rem;
  height: 3.25rem;
  min-height: 0;
  padding: 0;
  border: 6px solid var(--ink);
  border-radius: 50%;
  background: var(--surface);
  box-shadow: inset 0 0 0 3px var(--surface), inset 0 0 0 5px var(--line);
  font: 700 1.7rem/1 var(--display);
}
.stepper label { display: flex; align-items: baseline; justify-content: center; gap: .35rem; }
.stepper input { width: 4.5ch; }
.stepper input {
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: right;
  font: 700 3.25rem/1 var(--display);
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
  appearance: textfield;
}
.stepper input::-webkit-inner-spin-button,
.stepper input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.stepper label span { width: 2.5rem; color: var(--muted); font: 600 1.1rem/1 var(--display); }

.log { width: 100%; min-height: 3.75rem; font-size: 1.5rem; }
.rest { margin: .75rem 0 0; text-align: center; color: var(--muted); font: 600 1.15rem/1 var(--display); font-variant-numeric: tabular-nums; }

.block { padding: .9rem 0; border-top: 1px solid var(--line); }
.block header { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; }
.block small, .meta, .pending { color: var(--muted); font-size: .875rem; }
.meta, .pending { margin: .2rem 0 0; }

.sets { list-style: none; margin: .4rem 0 0; padding: 0; counter-reset: set; }
.sets li {
  counter-increment: set;
  display: flex;
  align-items: center;
  gap: .75rem;
  font: 600 1.3rem/1.2 var(--display);
  font-variant-numeric: tabular-nums;
}
.sets li::before {
  content: counter(set);
  display: grid;
  place-items: center;
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 50%;
  background: var(--bg);
  color: var(--muted);
  font-size: .9rem;
}
.sets .v { flex: 1; }

.actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.25rem; }
.actions > * { flex: 1 1 auto; }
.actions.inline { margin-top: .75rem; }
.actions.inline > * { flex: 0 0 auto; }

.repeat li + li { margin-top: .5rem; }
.row { width: 100%; justify-content: space-between; text-align: left; flex-wrap: wrap; }
.row small { color: var(--muted); font: 400 .875rem/1.2 var(--body); }

/* ---------- review ---------- */
.row2 { display: grid; grid-template-columns: 1.5fr 1fr; gap: .75rem; }
.preview {
  margin: 0;
  padding: .85rem;
  white-space: pre-wrap;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  font: .95rem/1.5 var(--body);
}

/* ---------- history ---------- */
.history { list-style: none; margin: 0; padding: 0; }
.history > li { border-bottom: 1px solid var(--line); }
summary {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .15rem .75rem;
  align-items: center;
  padding: .9rem 0;
  list-style: none;
  cursor: pointer;
}
summary::-webkit-details-marker { display: none; }
.h-name { font: 700 1.3rem/1.15 var(--display); }
.h-meta { grid-column: 1; color: var(--muted); font-size: .9rem; }
.badge {
  grid-column: 2;
  grid-row: 1 / span 2;
  padding: .25rem .6rem;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
}
.badge.on { border-color: var(--strava); color: var(--strava); }
.h-body { padding: 0 0 1rem; }
.h-body li { padding: .15rem 0; }
.notes { color: var(--muted); font-style: italic; }

/* ---------- exercises ---------- */
.add-ex { display: flex; gap: .5rem; margin-bottom: 1.25rem; }
.add-ex input { flex: 1; }
.ex { margin-bottom: .75rem; padding: .8rem; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.ex-name { margin-bottom: .6rem; padding-left: .3rem; border-color: transparent; font: 700 1.3rem/1.1 var(--display); }

/* ---------- settings ---------- */
section + section { margin-top: 1.75rem; }
.sub { margin: 1.5rem 0 .5rem; font: 700 1.25rem/1.2 var(--display); }
section > .sub:first-child { margin-top: 0; }
.segmented { display: inline-flex; border: 1.5px solid var(--line); border-radius: 8px; overflow: hidden; }
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segmented span { display: block; padding: .6rem 1.4rem; font: 600 1.1rem/1 var(--display); cursor: pointer; background: var(--surface); }
.segmented input:checked + span { background: var(--accent); color: var(--accent-ink); }
.segmented input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: -3px; }
.check { display: flex; align-items: flex-start; gap: .65rem; margin-top: 1rem; cursor: pointer; }
.check input { flex: none; width: 1.3rem; height: 1.3rem; min-height: 0; margin: .1rem 0 0; padding: 0; accent-color: var(--accent); }

.plain { list-style: none; margin: 0; padding: 0; }
.hint, .empty { color: var(--muted); }

/* Local dev stack only: a reminder to sign in with the test Strava account. */
.dev-banner {
  padding: calc(.4rem + env(safe-area-inset-top, 0px)) 1rem .4rem;
  background: #ffd23f;
  color: #1f2a33;
  font: 600 .95rem/1.3 var(--body);
  text-align: center;
}
.dev-note { margin: .6rem 0 0; color: var(--danger); font-weight: 600; }

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(5.25rem + env(safe-area-inset-bottom, 0px));
  z-index: 10;
  max-width: calc(100% - 2rem);
  padding: .65rem 1rem;
  border-radius: 8px;
  background: var(--ink);
  color: var(--bg);
  opacity: 0;
  transform: translate(-50%, .75rem);
  transition: opacity .18s, transform .18s;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: var(--danger); color: var(--bg); }

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