/* TRAIN, editorial session log, sibling of MAIL.
   Same magazine language (Didone masthead, tracked-caps labels, hairline
   pills, ink-filled selection, muted tones: oxblood record/danger, olive
   good, navy info) but printed on charcoal, not paper; this page gets
   read in a gym, not a reading chair. No emojis. .hidden is load-bearing. */

:root {
  --bg: #131311;
  --card: #1c1b18;
  --sheet: #1a1917;
  --ink: #ece7db;
  --muted: #97917f;
  --faint: #5f5a4e;
  --hairline: #2b2922;
  --oxblood: #a85e66;
  --olive: #99955e;
  --navy: #7d92b3;
  --serif: "Didot", "Bodoni 72", "Bodoni Moda", "Playfair Display", serif;
  --sans: -apple-system, "Helvetica Neue", system-ui, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }
html { background: var(--bg); }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 300;
  font-size: 15px;
  line-height: 1.5;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-font-smoothing: antialiased;
}

#app { position: relative; min-height: 100dvh; display: flex; flex-direction: column; }

/* ---------------------------------------------------------- masthead */
#topbar {
  position: sticky; top: 0; z-index: 20;
  padding: calc(env(safe-area-inset-top) + 16px) 20px 0;
  background: linear-gradient(var(--bg) 88%, transparent);
  text-align: center;
}
.wordmark {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 44px;
  line-height: 1;
  letter-spacing: .05em;
}
.subrow {
  margin-top: 7px;
  padding-bottom: 12px;
  font-size: 10.5px;
  font-weight: 400;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  min-height: 16px;
}
.subrow #day-type { color: var(--ink); font-weight: 500; }
.subrow span:not(:empty) ~ span:not(:empty)::before { content: '\00A0\00B7\00A0'; color: var(--faint); }
.progress-track { height: 1px; background: var(--hairline); }
.progress-fill {
  height: 100%; width: 0%;
  background: var(--ink);
  transition: width 240ms ease;
}

/* ---------------------------------------------------------- content */
#content { flex: 1; padding: 16px 16px 136px; max-width: 560px; margin: 0 auto; width: 100%; }

.state-screen { text-align: center; padding: 56px 24px; color: var(--muted); font-size: 13px; }
.state-screen .big {
  font-family: var(--serif); font-weight: 400;
  font-size: 32px; color: var(--ink); line-height: 1.1;
  display: block; margin-bottom: 10px;
}

.block-label {
  margin: 22px 4px 10px;
  font-size: 10.5px; font-weight: 500;
  letter-spacing: .22em; text-transform: uppercase;
  color: var(--muted);
}
.block-label:first-child { margin-top: 4px; }
.block-label .bonus { color: var(--olive); }

/* ------------------------------------------------------------- warm-up card */
/* Quieter than an exercise card: no fill, hairline left rule, muted lines.
   Read-only by design -- nothing here is tappable. */
.warmup {
  border-left: 1px solid var(--faint);
  padding: 2px 0 2px 14px;
  margin: 0 4px 14px;
}
.warmup-item {
  color: var(--muted); font-size: 13.5px;
  padding: 3px 0;
}

/* ---------------------------------------------------------- exercise cards */
.exercise {
  background: var(--card);
  border-radius: 14px;
  padding: 14px 16px 14px;
  margin-bottom: 10px;
}
.exercise-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.exercise-name {
  min-width: 0;
  font-weight: 500; font-size: 15px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.exercise-target {
  color: var(--muted); font-size: 13px; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.exercise-target.preview-target { text-align: right; }
.exercise-target.preview-target .t-sets {
  color: var(--faint); font-size: 9.5px; font-weight: 500;
  letter-spacing: .16em; text-transform: uppercase; margin-top: 2px;
}
.exercise-note { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.exercise-note .amrap {
  color: var(--oxblood);
  font-size: 9.5px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase;
}

/* ---------------------------------------------------------- set pills */
.chips { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
.chip {
  flex: 1 1 0; min-width: 74px; min-height: 50px;
  border-radius: 99px;
  border: 1px solid var(--hairline);
  background: transparent; color: var(--ink);
  font-family: var(--sans); font-weight: 400; font-size: 14.5px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px; font-variant-numeric: tabular-nums;
  transition: transform 90ms ease, background 120ms ease;
}
.chip .chip-sub {
  font-size: 9px; font-weight: 500; letter-spacing: .16em;
  text-transform: uppercase; color: var(--faint);
}
.chip:active { transform: scale(0.96); }

.chip.done {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--bg);
  font-weight: 500;
  animation: settle 160ms ease-out;
}
.chip.done .chip-sub { color: rgba(19, 19, 17, 0.55); }
.chip.skipped {
  border-style: dashed; color: var(--faint);
  text-decoration: line-through;
}
.chip.pr { border-color: var(--oxblood); box-shadow: 0 0 0 1px var(--oxblood); }
.chip.done.pr { background: var(--oxblood); border-color: var(--oxblood); color: #f7f2ea; }
.chip.done.pr .chip-sub { color: rgba(247, 242, 234, 0.7); }

@keyframes settle {
  0% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

/* ---------------------------------------------------------- footer */
#footer {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  padding: 12px 20px calc(env(safe-area-inset-bottom) + 8px);
  background: rgba(19, 19, 17, 0.93);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border-top: 1px solid var(--hairline);
}

.start-btn {
  width: 100%; padding: 14px; margin-bottom: 12px;
  font-family: var(--sans); font-weight: 600; font-size: 11px;
  letter-spacing: .22em; text-transform: uppercase;
  background: var(--ink); color: var(--bg);
  border: 1px solid var(--ink); border-radius: 99px;
}
.start-btn:active { transform: scale(0.985); opacity: 0.92; }
.state-screen .start-btn { margin-top: 28px; }

.finish-btn {
  width: 100%; padding: 13px; margin-bottom: 12px;
  font-family: var(--sans); font-weight: 600; font-size: 11px;
  letter-spacing: .22em; text-transform: uppercase;
  background: transparent; color: var(--ink);
  border: 1px solid var(--hairline); border-radius: 99px;
}
.finish-btn:active { transform: scale(0.985); background: var(--card); }

#tabbar { display: flex; justify-content: center; gap: 30px; }
.tab {
  background: none; border: 0; padding: 8px 2px 4px;
  font-family: var(--sans);
  font-size: 11px; font-weight: 500;
  letter-spacing: .2em; text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid transparent;
}
.tab.active { color: var(--ink); border-bottom-color: var(--ink); }

/* ---------------------------------------------------------- sheets */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(10, 10, 9, 0.72);
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: var(--sheet);
  border-top: 1px solid var(--hairline);
  border-radius: 18px 18px 0 0;
  padding: 14px 20px calc(env(safe-area-inset-bottom) + 18px);
  animation: sheet-up 220ms cubic-bezier(0.2, 1, 0.3, 1);
}
@keyframes sheet-up { from { transform: translateY(50%); opacity: 0.6; } to { transform: translateY(0); opacity: 1; } }
.sheet-grip { width: 32px; height: 3px; border-radius: 2px; background: var(--faint); margin: 0 auto 16px; opacity: 0.5; }
.sheet-title {
  font-family: var(--serif); font-weight: 400; font-size: 24px;
  margin-bottom: 18px;
}
.stepper-row { display: flex; gap: 12px; }
.stepper { flex: 1; min-width: 0; margin-bottom: 6px; }
.stepper-label {
  color: var(--muted); font-size: 10px; font-weight: 500;
  letter-spacing: .22em; text-transform: uppercase; margin-bottom: 8px;
}
.stepper-controls { display: flex; gap: 6px; }
.step-btn {
  width: 44px; flex-shrink: 0; min-height: 52px; border-radius: 99px;
  border: 1px solid var(--hairline); background: transparent;
  color: var(--muted); font-family: var(--sans);
  font-weight: 400; font-size: 16px;
}
.step-btn:active { background: var(--card); color: var(--ink); }
.stepper input {
  flex: 1; min-width: 0; text-align: center; padding: 0 6px;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--hairline); border-radius: 99px;
  font-family: var(--serif); font-weight: 400; font-size: 23px;
  font-variant-numeric: tabular-nums;
}
.sheet-log {
  width: 100%; margin-top: 18px; padding: 15px;
  font-family: var(--sans); font-weight: 600; font-size: 11px;
  letter-spacing: .22em; text-transform: uppercase;
  background: var(--ink); color: var(--bg);
  border: 1px solid var(--ink); border-radius: 99px;
}
.sheet-log:active { transform: scale(0.985); opacity: 0.92; }
.sheet-skip {
  width: 100%; margin-top: 10px; padding: 12px;
  background: transparent; border: none; color: var(--oxblood);
  font-family: var(--sans); font-weight: 500; font-size: 12.5px;
  letter-spacing: .04em;
}
.sheet-achieve {
  width: 100%; margin-top: 10px; padding: 12px;
  background: transparent;
  border: 1px solid var(--olive); border-radius: 99px;
  color: var(--olive);
  font-family: var(--sans); font-weight: 500; font-size: 12.5px;
  letter-spacing: .04em;
}
.sheet-achieve:active { background: rgba(153, 149, 94, 0.14); }
.unlogged-list { color: var(--muted); font-size: 14px; margin-bottom: 6px; max-height: 30dvh; overflow-y: auto; }
.unlogged-list div { padding: 5px 0; border-bottom: 1px solid var(--hairline); }
.unlogged-list div:last-child { border-bottom: none; }

.text-input {
  width: 100%; min-width: 0; padding: 12px 16px;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--hairline); border-radius: 99px;
  font-family: var(--sans); font-weight: 300; font-size: 16px;
}
.text-input::placeholder { color: var(--faint); }
textarea.text-input { resize: none; line-height: 1.4; border-radius: 16px; }
.date-input {
  min-height: 52px; font-variant-numeric: tabular-nums;
  color-scheme: dark;
}
.focus-info {
  color: var(--muted); font-size: 13.5px; font-family: var(--serif);
  font-style: italic; margin: -6px 0 14px; max-height: 22dvh; overflow-y: auto;
}
.toggle-row {
  display: flex; align-items: center; gap: 10px; margin: 12px 2px 2px;
  font-family: var(--sans); font-size: 12.5px; color: var(--muted);
}
.toggle-row input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--ink); flex-shrink: 0; }

/* ---------------------------------------------------------- toast */
.toast {
  position: fixed; top: calc(env(safe-area-inset-top) + 14px); left: 50%;
  transform: translateX(-50%);
  max-width: 86%;
  background: var(--ink); color: var(--bg);
  border-radius: 99px; padding: 10px 20px;
  font-size: 11px; font-weight: 500; letter-spacing: .1em; text-transform: uppercase;
  z-index: 60; text-align: center;
  animation: toast-in 160ms ease;
}
.toast.pr-toast { background: var(--oxblood); color: #f7f2ea; }
@keyframes toast-in { from { transform: translate(-50%, -8px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* ---------------------------------------------------------- rows (history / prs / weight / coach) */
.row-card {
  padding: 12px 4px; margin: 0;
  border-bottom: 1px solid var(--hairline);
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
}
.row-card .row-main { min-width: 0; flex: 1; }
.row-card .row-title {
  font-weight: 400; font-size: 15px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row-card .row-sub { color: var(--muted); font-size: 11.5px; font-weight: 300; margin-top: 1px; }
.row-card .row-stat {
  font-size: 15px; font-weight: 400;
  color: var(--ink); white-space: nowrap; font-variant-numeric: tabular-nums;
}
.row-card .row-stat .unit {
  color: var(--faint); font-size: 9.5px;
  font-weight: 500; letter-spacing: .16em; text-transform: uppercase;
}
.row-card.tappable:active { background: var(--card); }
.row-card .row-chevron { color: var(--faint); font-size: 15px; }
.detail-sets { margin: 4px 0 14px; padding: 0 4px 10px; border-bottom: 1px solid var(--hairline); }
.detail-sets .ex-name {
  font-weight: 500; font-size: 10.5px;
  letter-spacing: .18em; text-transform: uppercase; color: var(--muted);
  margin-top: 10px;
}
.detail-sets .set-line { color: var(--ink); font-size: 14px; font-variant-numeric: tabular-nums; margin-top: 2px; }
.detail-sets .pr-mark { color: var(--oxblood); }

/* segmented switch (history mode, weight range) */
.range-switch { display: flex; gap: 6px; margin: 2px 0 16px; }
.range-btn {
  flex: 1; padding: 7px 0;
  background: transparent; color: var(--muted);
  border: 1px solid var(--hairline); border-radius: 99px;
  font-family: var(--sans); font-weight: 500; font-size: 10.5px;
  letter-spacing: .12em; text-transform: uppercase;
}
.range-btn.active { background: var(--ink); border-color: var(--ink); color: var(--bg); }

.weight-canvas-wrap {
  padding: 6px 2px 18px; margin-bottom: 6px;
  border-bottom: 1px solid var(--hairline);
}
.weight-headline {
  font-family: var(--serif); font-weight: 400; font-size: 46px; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.weight-headline .unit {
  font-family: var(--sans); font-size: 11px; color: var(--muted);
  font-weight: 500; letter-spacing: .16em; text-transform: uppercase;
}
.weight-headline .delta {
  font-family: var(--sans); font-size: 10.5px; color: var(--olive);
  margin-left: 10px; font-weight: 500; letter-spacing: .14em; text-transform: uppercase;
}
.weight-headline .delta.up { color: var(--oxblood); }
.weight-headline .delta.scrub { color: var(--muted); }
#weight-canvas { width: 100%; height: 150px; display: block; margin-top: 14px; touch-action: none; }
.tab-empty { color: var(--muted); text-align: center; padding: 48px 20px; font-family: var(--serif); font-size: 19px; }

/* ---------------------------------------------------------- coach tab */
.coach-back {
  color: var(--muted); font-size: 10.5px; font-weight: 500;
  letter-spacing: .2em; text-transform: uppercase;
  padding: 4px 2px 12px; cursor: pointer;
}
.coach-back:active { color: var(--ink); }
.focus-muscles {
  color: var(--faint); font-size: 9.5px; font-weight: 500;
  letter-spacing: .16em; text-transform: uppercase; margin-top: 3px;
}
.focus-retired .row-title, .focus-retired .row-stat { color: var(--faint); }
.add-row-btn {
  width: 100%; margin-top: 18px; padding: 12px;
  background: transparent; color: var(--muted);
  border: 1px dashed var(--hairline); border-radius: 99px;
  font-family: var(--sans); font-weight: 500; font-size: 10.5px;
  letter-spacing: .18em; text-transform: uppercase;
}
.add-row-btn:active { background: var(--card); color: var(--ink); }

.status-chip {
  display: inline-block; padding: 2px 9px; margin-left: 8px;
  border: 1px solid var(--hairline); border-radius: 99px;
  font-family: var(--sans);
  font-size: 9px; font-weight: 600; letter-spacing: .16em;
  text-transform: uppercase; color: var(--muted); vertical-align: 2px;
}
.status-chip.improving { color: var(--olive); border-color: var(--olive); }
.status-chip.on { border-color: var(--ink); background: var(--ink); color: var(--bg); }

.rehab-update-line {
  font-size: 12.5px; font-weight: 300;
  color: var(--muted); padding: 5px 0; border-top: 1px solid var(--hairline);
  font-family: var(--sans); font-style: normal;
}
.rehab-update-line .u-date { color: var(--faint); font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase; margin-right: 8px; }
.pt-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  font-family: var(--sans); font-style: normal; font-size: 13px; color: var(--ink);
  padding: 6px 0; border-top: 1px solid var(--hairline);
}
.pt-row .pt-sub { color: var(--faint); font-size: 11px; }
.pt-retire, .row-retire {
  background: transparent; border: 1px solid var(--hairline); border-radius: 99px;
  color: var(--muted);
  font-family: var(--sans); font-size: 9.5px; font-weight: 500;
  letter-spacing: .14em; text-transform: uppercase;
  padding: 3px 11px; white-space: nowrap;
}
.pt-retire:active, .row-retire:active { border-color: var(--oxblood); color: var(--oxblood); }
.info-head {
  font-family: var(--sans); font-style: normal; font-weight: 500;
  font-size: 9.5px; letter-spacing: .2em; text-transform: uppercase;
  color: var(--faint); margin: 12px 0 2px;
}

.hidden { display: none !important; }
