/* Training log — dark, high contrast, big targets.
   Built for reading mid-set with a pump under bright gym lighting,
   not for looking at on a desktop. System fonts only: web fonts would
   fail on a cold offline load, which is the one case that has to work. */

:root {
  --bg:        #0E0F0D;
  --surface:   #171916;
  --surface-2: #1F221D;
  --line:      #2C302A;
  --ink:       #EDEEE8;
  --ink-dim:   #A8AEA1;
  --ink-faint: #6E7568;

  --accent:    #D4A048;   /* growth targets and priority work */
  --accent-dim:#3A2F16;
  --done:      #7BB36F;
  --done-dim:  #1C2A19;
  --warn:      #D07A4A;
  --danger:    #C25B4E;

  --radius: 12px;
  --tap: 46px;            /* every interactive control clears 44px */

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding: 0 0 96px;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.wrap { max-width: 640px; margin: 0 auto; padding: 0 16px; }

/* ---------------- header ---------------- */

.masthead {
  padding: 20px 0 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
}

.crumb {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.crumb .sep { color: var(--ink-faint); }

h1 {
  font-size: 30px;
  line-height: 1.1;
  margin: 8px 0 6px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.subtitle { color: var(--ink-dim); font-size: 16px; margin: 0; }

/* ---------------- mode switch ---------------- */

.modes { display: flex; gap: 6px; margin-top: 14px; }

.mode-btn {
  flex: 1;
  min-height: var(--tap);
  padding: 8px 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink-dim);
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.mode-btn[aria-pressed="true"] {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

.mode-btn small {
  display: block;
  font-size: 13px;
  font-weight: 400;
  color: var(--ink-faint);
  margin-top: 1px;
}

.mode-btn[aria-pressed="true"] small { color: var(--accent); opacity: 0.75; }

/* ---------------- exercise cards ---------------- */

.exercise {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
}

.exercise.is-priority { border-left: 3px solid var(--accent); }
.exercise.is-complete { opacity: 0.55; }

.ex-head { padding: 14px 14px 10px; }

.ex-name {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.25;
  margin: 0 0 3px;
  display: flex;
  align-items: baseline;
  gap: 7px;
}

.star { color: var(--accent); font-size: 14px; flex: none; }

.ex-meta {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink-faint);
  letter-spacing: 0.04em;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.ex-note {
  font-size: 16px;
  color: var(--ink-dim);
  margin: 8px 0 0;
  line-height: 1.4;
}

.ex-last {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink-faint);
  margin-top: 8px;
  word-break: break-word;
}

.ex-last b { color: var(--ink-dim); font-weight: 400; }

/* ---------------- set rows ---------------- */

.sets { padding: 0 8px 8px; }

.set-legend {
  display: flex;
  gap: 3px;
  padding: 0 2px 4px 19px;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.set-legend span:first-child { flex: 1 1 0; text-align: center; }
.set-legend span:last-child  { flex: 1 1 0; text-align: center; }

/* The whole row is the confirm target. That gives the most common action in the
   app a ~320x46px hit area instead of a 46px square, and frees the horizontal
   space the stepper buttons need to clear 44px on a 375px screen. */
.set-row {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 4px 2px;
  border-top: 1px solid var(--line);
  cursor: pointer;
}

.set-row:first-child { border-top: none; }
.set-row.is-done .stepper { opacity: 0.45; }
.set-row:active { background: var(--surface-2); }

.set-n {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--ink-faint);
  width: 13px;
  flex: none;
  text-align: center;
}

.stepper {
  display: flex;
  align-items: center;
  background: var(--surface-2);
  border-radius: 9px;
  flex: 1 1 0;
  min-width: 0;
}

.step-btn {
  width: 44px;
  min-width: 44px;
  height: var(--tap);
  flex: none;
  border: 0;
  background: transparent;
  color: var(--ink-dim);
  font-size: 21px;
  line-height: 1;
  cursor: pointer;
  border-radius: 9px;
  font-family: var(--sans);
}

.step-btn:active { background: var(--line); color: var(--ink); }

.step-val {
  flex: 1 1 0;
  min-width: 0;
  align-self: stretch;
  height: var(--tap);
  min-width: 44px;
  text-align: center;
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  border: 0;
  background: transparent;
  padding: 0;
  -moz-appearance: textfield;
}

.step-val::-webkit-outer-spin-button,
.step-val::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* Status indicator, not the tap target — the row is. */
.confirm {
  width: 22px;
  height: var(--tap);
  flex: none;
  border: 0;
  background: transparent;
  color: var(--ink-faint);
  font-size: 21px;
  line-height: 1;
  pointer-events: none;
}

.set-row.is-done .confirm { color: var(--done); }

/* Tapping to log a set that has no weight yet: flash rather than accept it.
   Storing a null-weight set would corrupt the working-load median. */
.set-row.needs-weight { background: rgba(194, 91, 78, 0.18); }
.set-row.needs-weight .stepper[data-field="weight"] { box-shadow: inset 0 0 0 1px var(--danger); }

/* ---------------- rest timer ---------------- */

.rest-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: var(--accent-dim);
  border-top: 1px solid var(--accent);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  z-index: 40;
}

.rest-bar[hidden] { display: none; }

.rest-label {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.rest-time {
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.rest-skip {
  min-height: var(--tap);
  padding: 0 16px;
  border: 1px solid var(--accent);
  border-radius: 9px;
  background: transparent;
  color: var(--accent);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

/* ---------------- tab bar ---------------- */

.tabs {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 30;
}

.tab {
  flex: 1;
  min-height: 58px;
  border: 0;
  background: transparent;
  color: var(--ink-faint);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  padding: 8px 4px;
}

.tab[aria-selected="true"] { color: var(--accent); box-shadow: inset 0 2px 0 var(--accent); }
.tab .glyph { display: block; font-size: 19px; margin-bottom: 2px; }

/* ---------------- buttons ---------------- */

.btn {
  display: block;
  width: 100%;
  min-height: var(--tap);
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 12px;
}

.btn-primary { background: var(--accent); border-color: var(--accent); color: #17190F; }
.btn:active { transform: scale(0.99); }

/* ---------------- progress screen ---------------- */

.section-title {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 26px 0 12px;
}

.stat-row {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.stat {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  min-width: 0;
}

.stat dt {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0 0 4px;
}

.stat dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stat .delta { font-size: 14px; font-weight: 400; color: var(--ink-dim); }

/* volume ledger — the Atlas's best visual, kept */
.ledger-row { padding: 11px 0; border-top: 1px solid var(--line); }
.ledger-row:last-child { border-bottom: 1px solid var(--line); }

.ledger-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 7px;
}

.ledger-name { font-size: 16px; font-weight: 600; }
.ledger-name .tier { color: var(--accent); font-size: 13px; margin-left: 5px; }

.ledger-val {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--accent);
  font-weight: 700;
  white-space: nowrap;
}

.track { position: relative; height: 14px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.seg-mav { position: absolute; top: 0; bottom: 0; background: rgba(212, 160, 72, 0.22); }
.tick { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--ink-faint); }
.tick.mev { width: 2px; background: var(--done); }
.marker { position: absolute; top: -2px; bottom: -2px; width: 3px; background: var(--accent); border-radius: 2px; }

.ledger-scale {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink-faint);
  margin-top: 4px;
}

.spark { width: 100%; height: 90px; display: block; }

.prompt {
  border-left: 3px solid var(--ink-faint);
  background: var(--surface);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 12px 14px;
  margin-bottom: 10px;
  font-size: 16px;
  line-height: 1.45;
}

.prompt.warn { border-left-color: var(--warn); }
.prompt.good { border-left-color: var(--done); }
.prompt.info { border-left-color: var(--accent); }

.inline-form { display: flex; gap: 8px; align-items: stretch; margin-top: 10px; }

.inline-form input {
  flex: 1;
  min-width: 0;
  min-height: var(--tap);
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 17px;
}

.inline-form button {
  flex: none;
  min-width: 84px;
  min-height: var(--tap);
  border-radius: 9px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #17190F;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

/* ---------------- atlas / reference ---------------- */

.atlas h2 { font-size: 22px; margin: 26px 0 8px; font-weight: 600; letter-spacing: -0.01em; }
.atlas h3 { font-size: 17px; margin: 18px 0 5px; font-weight: 600; }
.atlas p  { color: var(--ink-dim); margin: 0 0 12px; font-size: 16px; line-height: 1.55; }
.atlas ul { color: var(--ink-dim); padding-left: 20px; margin: 0 0 14px; font-size: 16px; line-height: 1.55; }
.atlas li { margin-bottom: 6px; }
.atlas strong { color: var(--ink); font-weight: 600; }
.atlas .callout {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 13px 15px;
  margin: 0 0 16px;
}
.atlas .callout p:last-child { margin-bottom: 0; }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-bottom: 16px; }
table { border-collapse: collapse; width: 100%; font-size: 16px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-family: var(--mono); font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-faint); font-weight: 400; }
td { color: var(--ink-dim); }
td:first-child { color: var(--ink); }

/* ---------------- misc ---------------- */

.empty { color: var(--ink-faint); font-size: 16px; padding: 28px 0; text-align: center; }

.sync {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding: 14px 0 4px;
  text-align: center;
}

.sync.pending { color: var(--warn); }

.screen[hidden] { display: none; }

@media (min-width: 600px) {
  h1 { font-size: 36px; }
  .wrap { padding: 0 24px; }
}
