@font-face { font-family: 'Big Shoulders Display'; src: url('../fonts/big-shoulders-display-latin-700-normal.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Big Shoulders Display'; src: url('../fonts/big-shoulders-display-latin-800-normal.woff2') format('woff2'); font-weight: 800; font-display: swap; }
@font-face { font-family: 'Atkinson Hyperlegible'; src: url('../fonts/atkinson-hyperlegible-latin-400-normal.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Atkinson Hyperlegible'; src: url('../fonts/atkinson-hyperlegible-latin-700-normal.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --chalk: #E8EBEE;
  --paper: #F7F8F9;
  --ink: #10141F;
  --muted: #4C5564;
  --rule: #BEC5CE;
  --danger: #A81F15;
  --display: 'Big Shoulders Display', 'Arial Narrow', Impact, sans-serif;
  --body: 'Atkinson Hyperlegible', 'Segoe UI', Roboto, sans-serif;
  --tabs-height: 60px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--chalk);
  color: var(--ink);
  font: 400 17px/1.5 var(--body);
  overflow-wrap: anywhere;
}
h1, h2, p, ul, ol, fieldset { margin: 0; padding: 0; }
ul, ol { list-style: none; }
fieldset { border: 0; min-width: 0; }
a { color: inherit; }
small { display: block; font-size: 15px; color: var(--muted); }
h1:focus { outline: none; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }

/* Type */
.display { font: 800 clamp(44px, 11vw, 64px)/0.98 var(--display); letter-spacing: 0.002em; }
.display.huge { font-size: clamp(68px, 19vw, 124px); line-height: 0.92; }
h2 { font: 700 26px/1.1 var(--display); margin-bottom: 10px; }
legend { font-weight: 700; padding: 0; margin-bottom: 8px; }
.lead { font-size: 19px; margin-top: 10px; max-width: 34em; }
.hint { color: var(--muted); font-size: 15px; max-width: 38em; }

/* Page frame */
.page {
  max-width: 760px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 24px) 20px calc(var(--tabs-height) + env(safe-area-inset-bottom) + 32px);
}
.page > section { margin-top: 32px; }
.setup { padding-bottom: 48px; }
.setup > .primary { margin-top: 28px; }

/* Buttons */
.primary, .secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 10px 22px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  font: 700 18px/1.2 var(--body);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
.primary { background: var(--ink); color: #fff; width: 100%; min-height: 60px; font-size: 20px; }
.secondary { background: transparent; color: var(--ink); }
.primary:hover { background: #2A3142; }
.secondary:hover { background: rgb(16 20 31 / 0.08); }
.primary:active, .secondary:active, .step:active, .chip:active { transform: scale(0.98); }
.text-button {
  background: none;
  border: 0;
  padding: 10px 4px;
  min-height: 44px;
  font: 400 16px/1.2 var(--body);
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.text-button:disabled { opacity: 0.4; cursor: default; text-decoration: none; }
.text-button.danger { color: var(--danger); margin-top: 14px; }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.file-button { cursor: pointer; position: relative; }
.file-button input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.file-button:focus-within { outline: 3px solid var(--ink); outline-offset: 2px; }
.back { display: inline-block; padding: 6px 0; margin-bottom: 8px; }

/* Bottom tabs, moved to the top on a laptop */
.tabs {
  position: fixed;
  inset: auto 0 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--paper);
  border-top: 2px solid var(--ink);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs a {
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--tabs-height);
  font: 700 20px/1 var(--display);
  text-decoration: none;
  color: var(--muted);
}
.tabs a[aria-current='page'] { color: var(--ink); box-shadow: inset 0 5px 0 var(--ink); }

/* Status messages */
.message { padding: 12px 14px; border-left: 6px solid var(--ink); background: var(--paper); margin: 12px 0; }
.message.error { border-color: var(--danger); color: var(--danger); }

/* Forms */
.choices, .toggles { margin-top: 20px; }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choices legend { width: 100%; }
.choice { flex: 1 1 96px; cursor: pointer; }
.choice input { position: absolute; opacity: 0; }
.choice-body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 100%;
  min-height: 56px;
  padding: 8px 14px;
  border: 2px solid var(--rule);
  border-radius: 14px;
  background: var(--paper);
}
.choice input:checked + .choice-body { background: var(--ink); border-color: var(--ink); color: #fff; }
.choice input:checked + .choice-body small { color: #D5DAE1; }
.choice input:focus-visible + .choice-body { outline: 3px solid var(--ink); outline-offset: 2px; }
.toggle { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--rule); cursor: pointer; min-height: 56px; }
.toggle input { width: 24px; height: 24px; flex: none; accent-color: var(--ink); }
input[type='text'], input[type='number'], input[type='search'], select {
  width: 100%;
  min-height: 46px;
  padding: 8px 10px;
  border: 2px solid var(--rule);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  font: 400 17px/1.2 var(--body);
}
input:focus, select:focus { border-color: var(--ink); }
.select-field { display: block; font-weight: 700; margin-top: 16px; }
.select-field input, .select-field select { margin-top: 6px; font-weight: 400; }

/* Band editor */
.band-list { margin: 8px 0 14px; }
.band-row {
  display: grid;
  grid-template-columns: 22px 1fr 1fr 74px;
  gap: 8px 10px;
  align-items: end;
  padding: 12px 0;
  border-bottom: 1px solid var(--rule);
}
.band-row .dot.big { align-self: center; margin-bottom: 10px; grid-row: 1; }
.band-row .grow { grid-column: 2 / 3; }
.band-row .text-button { grid-column: 2 / -1; justify-self: start; min-height: 32px; padding: 4px 0; font-size: 15px; }
.band-field { font-size: 14px; color: var(--muted); display: block; }
.band-field input, .band-field select { margin-top: 3px; }
.dot { display: inline-block; width: 16px; height: 16px; border-radius: 50%; flex: none; outline: 1.5px solid rgb(16 20 31 / 0.45); outline-offset: -1px; }
.dot.big { width: 22px; height: 22px; }

/* Today */
.week { margin-bottom: 22px; }
.week-cells { display: flex; gap: 6px; margin-bottom: 6px; max-width: 280px; }
.week-cells span { flex: 1; height: 12px; border-radius: 999px; border: 2px solid var(--ink); }
.week-cells .on { background: var(--ink); }
.week p { font-size: 15px; color: var(--muted); }
.eyebrowless { color: var(--muted); font-size: 17px; }
.today-hero .primary { margin-top: 20px; max-width: 420px; }
.safety { margin-top: 12px; }
.ladder, .summary-list { margin-top: 28px; border-top: 2px solid var(--ink); }
.ladder-row, .summary-row, .library-row {
  display: flex;
  gap: 14px;
  align-items: stretch;
  padding: 13px 0;
  border-bottom: 1px solid var(--rule);
  text-decoration: none;
}
.ladder-row:hover strong, .library-row:hover strong { text-decoration: underline; text-underline-offset: 3px; }
.stripe { width: 10px; flex: none; border-radius: 999px; outline: 1.5px solid rgb(16 20 31 / 0.45); outline-offset: -1px; }
.ladder-text { min-width: 0; }
.library-row { display: block; }
.summary-list { margin-bottom: 24px; }
.next-time { color: var(--ink); margin-top: 2px; }

/* Workout: the screen wears the band */
.work { min-height: 100dvh; display: flex; flex-direction: column; }
.field {
  background: var(--band);
  color: var(--on);
  padding: calc(env(safe-area-inset-top) + 4px) 18px 16px;
  transition: background-color 200ms ease, color 200ms ease;
}
.field-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 15px; min-height: 44px; }
.field-link { background: none; border: 0; padding: 10px 0; color: inherit; font: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.field :focus-visible { outline-color: currentColor; }
.field-name { font: 800 clamp(42px, 12vw, 76px)/0.95 var(--display); margin-top: 4px; }
.field-figure { width: min(62vw, 34dvh, 340px); margin: 4px auto 0; }
.figure { display: block; width: 100%; height: auto; }
.field-note { font-size: 16px; line-height: 1.3; }
.controls { padding: 14px 18px calc(env(safe-area-inset-bottom) + 20px); flex: 1; }
.set-of { font: 700 26px/1.1 var(--display); }
.set-range { font: 400 15px/1 var(--body); color: var(--muted); margin-left: 6px; }
.controls > .primary { position: sticky; bottom: calc(env(safe-area-inset-bottom) + 10px); z-index: 2; }
.stepper { display: grid; grid-template-columns: 76px 1fr 76px; align-items: center; margin: 6px 0 10px; }
.step {
  height: 76px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: transparent;
  color: var(--ink);
  font: 700 40px/1 var(--body);
  cursor: pointer;
}
.step:hover { background: rgb(16 20 31 / 0.08); }
.reps { text-align: center; font: 800 104px/0.95 var(--display); font-variant-numeric: lining-nums tabular-nums; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chips legend { width: 100%; }
.band-label { font-weight: 400; color: var(--muted); }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 46px;
  padding: 6px 13px 6px 10px;
  border-radius: 999px;
  border: 2px solid var(--rule);
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1 var(--body);
  cursor: pointer;
}
.chip[aria-pressed='true'] { border-color: var(--ink); background: var(--ink); color: #fff; font-weight: 700; }
.chip[aria-pressed='true'] .dot { outline-color: #fff; }
.chip-kg { font-size: 13px; opacity: 0.75; font-weight: 400; }
.how { margin-top: 14px; border-top: 1px solid var(--rule); padding-top: 10px; }
.how summary { cursor: pointer; font-weight: 700; min-height: 32px; }
.how p { margin-top: 8px; }
.cues { margin-top: 8px; }
.cues li { padding: 5px 0 5px 16px; position: relative; }
.cues li::before { content: ''; position: absolute; left: 0; top: 14px; width: 8px; height: 3px; border-radius: 2px; background: var(--ink); }
.minor-actions { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-top: 6px; }

/* Rest: the band retracts as the time runs out */
.rest { min-height: 100dvh; display: flex; flex-direction: column; padding: calc(env(safe-area-inset-top) + 4px) 18px calc(env(safe-area-inset-bottom) + 20px); }
.rest-main { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 16px; padding: 24px 0; }
.rest-count { font: 800 clamp(130px, 44vw, 240px)/0.85 var(--display); font-variant-numeric: lining-nums tabular-nums; }
.rest-count:focus { outline: none; }
.rest-track { width: calc(100% + 36px); margin: 0 -18px; display: flex; justify-content: center; }
.rest-band {
  height: 26px;
  width: max(26px, calc(var(--p) * 100%));
  border-radius: 999px;
  border: 2px solid var(--ink);
  transition: width 200ms linear;
}
.rest-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.rest-next { border-top: 2px solid var(--ink); padding-top: 12px; }
.rest-next-label { color: var(--muted); font-size: 15px; }
.rest-next-name { font: 800 38px/1 var(--display); }

/* Progress */
.weeks { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; max-width: 480px; }
.week-col { display: flex; flex-direction: column; gap: 3px; }
.week-col span { height: 11px; border-radius: 3px; background: rgb(16 20 31 / 0.1); }
.week-col .on { background: var(--ink); }
.weeks + .hint { margin-top: 8px; }

.chart { position: relative; height: 200px; margin: 28px 0 0 26px; border-bottom: 2px solid var(--ink); }
.chart-guide { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--muted); }
.chart-guide span { position: absolute; left: -26px; top: -10px; font-size: 13px; color: var(--muted); width: 20px; text-align: right; }
.bars { position: absolute; inset: 0; display: flex; align-items: flex-end; gap: 2px; }
.bar { flex: 1; min-width: 0; max-width: 56px; height: 100%; padding: 0; border: 0; background: none; display: flex; align-items: flex-end; cursor: pointer; }
.bar:hover { background: rgb(16 20 31 / 0.05); }
.bar-fill {
  position: relative;
  display: block;
  width: 100%;
  height: var(--h);
  min-height: 3px;
  background: var(--fill);
  border-radius: 4px 4px 0 0;
  outline: 1.5px solid rgb(16 20 31 / 0.45);
  outline-offset: -1.5px;
}
.bar[aria-pressed='true'] .bar-fill { outline: 3px solid var(--ink); outline-offset: -3px; }
.bar-label { position: absolute; top: -21px; left: 0; right: 0; text-align: center; font-size: 14px; color: var(--ink); }
.band-runs { display: flex; gap: 2px; margin-left: 26px; padding-top: 4px; font-size: 13px; }
.band-runs span { flex: 1 1 0; min-width: 0; overflow: hidden; white-space: nowrap; border-top: 2px solid var(--muted); padding-top: 1px; }
.chart-axis { display: flex; justify-content: space-between; margin-left: 26px; font-size: 13px; color: var(--muted); padding-top: 4px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 10px; font-size: 15px; }
.legend li { display: flex; align-items: center; gap: 6px; }
.readout { margin-top: 10px; font-weight: 700; }
.readout + .hint { margin-top: 4px; }
table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 16px; }
th, td { text-align: left; padding: 7px 8px 7px 0; border-bottom: 1px solid var(--rule); }
.history-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--rule); }

/* Exercise detail */
.exercise-figure { width: min(82vw, 380px); margin: 16px auto 0; color: var(--ink); }
.how-open p { margin-top: 8px; }

/* Dialogs */
dialog {
  border: 2px solid var(--ink);
  border-radius: 18px;
  padding: 22px;
  width: min(92vw, 440px);
  background: var(--paper);
  color: var(--ink);
}
dialog::backdrop { background: rgb(16 20 31 / 0.55); }
dialog h2 { font-size: 32px; }
.dialog-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; }
.dialog-actions .text-button { align-self: center; }

/* Short phones: keep the figure and the reps on one screen */
@media (max-height: 720px) and (max-width: 899px) {
  .field-name { font-size: 40px; }
  .field-figure { width: min(46vw, 26dvh); }
  .field-note { font-size: 15px; }
  .stepper { grid-template-columns: 60px 1fr 60px; margin: 2px 0 6px; }
  .step { height: 60px; font-size: 32px; }
  .reps { font-size: 76px; }
  .chip { min-height: 42px; }
}

/* Laptop */
@media (min-width: 900px) {
  .tabs {
    position: fixed;
    inset: 0 0 auto;
    display: flex;
    justify-content: center;
    gap: 8px;
    border-top: 0;
    border-bottom: 2px solid var(--ink);
    padding: 0;
  }
  .tabs a { padding: 0 24px; height: 52px; }
  .tabs a[aria-current='page'] { box-shadow: inset 0 -5px 0 var(--ink); }
  .page { padding-top: 84px; padding-bottom: 48px; }
  .setup { padding-top: 40px; }
  .today { max-width: 1120px; display: grid; grid-template-columns: 1.15fr 1fr; gap: 0 56px; align-items: start; }
  .today > .message { grid-column: 1 / -1; }
  .today-hero { position: sticky; top: 84px; }
  .ladder { margin-top: 0; }
  .work { flex-direction: row; height: 100dvh; }
  .field { flex: 1.1; padding: 14px 40px 24px; display: flex; flex-direction: column; min-width: 0; overflow: auto; }
  .field-figure { width: auto; height: min(52dvh, 520px); aspect-ratio: 1; margin: auto; }
  .field-note { font-size: 18px; }
  .controls { flex: 1; padding: 28px 44px; overflow: auto; max-width: 620px; }
  .set-of { font-size: 34px; }
  .rest { max-width: 900px; margin: 0 auto; width: 100%; }
}

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

@media (forced-colors: active) {
  .bar-fill, .stripe, .dot, .rest-band { forced-color-adjust: none; }
}
