/* ---- Pager: one exercise per page; finished/skipped pages vanish ---- */
#screen-session { touch-action: pan-y; } /* swipe left/right anywhere on the screen */
#pager { margin-bottom: 0.9rem; }
#pager-progress { margin-bottom: 0.7rem; }
#pager-dots {
  display: flex;
  gap: 6px;
}
#pager-dots .dot {
  position: relative;
  flex: 1;
  height: 18px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: var(--bg-overlay);
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.2s, transform 0.2s;
}
#pager-dots .dot.inprog { background: var(--accent-orange); }
#pager-dots .dot.ss { background: var(--accent-purple); } /* paired = purple, always */
#pager-dots .dot.active { background: var(--accent-blue); transform: scaleY(1.18); }
#pager-dots .dot.ss.active { background: var(--accent-purple); filter: brightness(1.25); }
#pager-dots .dot.end { background: transparent; border: 2px solid var(--bg-overlay); }
#pager-dots .dot.end.active { border-color: var(--accent-blue); background: var(--accent-blue); }
#pager-dots .dot.vanish { animation: seg-vanish 320ms ease forwards; }
@keyframes seg-vanish {
  0% { transform: scaleY(1.18); opacity: 1; background: var(--accent-green); }
  45% { transform: scaleY(1.5); opacity: 1; background: var(--accent-green); }
  100% { transform: scaleY(0.4); opacity: 0; }
}

#pager-viewport {
  overflow: hidden;
  transition: height 0.25s ease;
  touch-action: pan-y;
}
#exercise-list {
  display: flex;
  align-items: flex-start;
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

/* Exercise card */
.ex-card {
  background: var(--card);
  border: none;
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
/* In the pager each card is its own full-width page. */
#exercise-list .ex-card {
  flex: 0 0 100%;
  width: 100%;
  margin-bottom: 0;
}
.ex-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 1rem 0.2rem;
}
.ex-head .ex-name { flex: 1; font-weight: 700; font-size: 1.15rem; }
.ex-head .ex-check {
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid var(--line);
  display: grid; place-items: center;
  font-size: 0.85rem; color: var(--muted);
  flex: none;
}
.ex-card.done .ex-check { background: var(--accent-green); border-color: var(--accent-green); color: var(--on-accent); }
/* Above-the-sets info: last performance, form cue, then the target line */
.ex-last {
  padding: 0 1rem 0.1rem;
  color: var(--muted);
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
}
.ex-cue {
  padding: 0 1rem 0.1rem;
  color: var(--text-tertiary);
  font-size: 0.84rem;
  font-style: italic;
}
.ex-meta { padding: 0.15rem 1rem 0.55rem; color: var(--muted); font-size: 0.9rem; }
.ex-meta .target { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
.ex-meta .ss-tag {
  display: inline-block;
  margin-left: 0.3rem;
  color: var(--accent-purple);
  font-size: 0.78rem;
  font-weight: 600;
}

.ex-body { padding: 0.2rem 0.7rem 0.8rem; }

/* Set row */
.set-row {
  display: grid;
  grid-template-columns: 26px 1fr 1fr 54px 26px;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.2rem;
}
.set-row .set-no { color: var(--muted); font-size: 0.85rem; text-align: center; }
.set-row.logged { background: rgba(61, 220, 151, 0.08); border-radius: 10px; }

/* Warmup set: visually distinct, lighter, "W" badge */
.set-row.warmup { background: rgba(255, 157, 77, 0.07); border-radius: 10px; }
.set-no.warmup {
  color: var(--accent-orange);
  font-weight: 800;
  font-size: 0.8rem;
}
.set-row.warmup.logged { background: rgba(61, 220, 151, 0.08); }

/* Drop set: a continuation of the set above, not a set of its own */
.set-row.dropset { background: rgba(122, 162, 247, 0.07); border-radius: 10px; }
.set-row.dropset.logged { background: rgba(61, 220, 151, 0.08); }
.set-row.dropset .set-no { color: var(--accent-blue, #7aa2f7); font-weight: 700; }
.set-drop-wrap { display: flex; justify-content: flex-end; padding: 0 0.2rem 0.15rem; }
.set-drop {
  background: transparent;
  border: 1px dashed rgba(122, 162, 247, 0.4);
  color: var(--accent-blue, #7aa2f7);
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.set-drop:active { opacity: 0.6; }

/* Per-row remove control */
.set-del {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1.35rem;
  line-height: 1;
  height: 48px;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  opacity: 0.6;
}
.set-del:active { color: var(--danger); opacity: 1; }
.set-del-spacer { width: 26px; }

.stepper {
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.stepper button {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 1.35rem;
  font-weight: 700;
  height: 48px;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.stepper button:active { background: var(--bg-overlay); }
.stepper .val {
  text-align: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.stepper .val small { display: block; font-size: 0.62rem; color: var(--muted); font-weight: 500; }
.stepper .val.pop { animation: val-pop 150ms ease; }
@keyframes val-pop {
  50% { transform: scale(1.15); }
}

.set-log-btn {
  height: 48px; border-radius: 10px; border: 1px solid var(--primary-2);
  background: var(--primary); color: var(--on-accent); font-weight: 800; font-size: 1.15rem;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 120ms var(--spring);
}
.set-log-btn:active { transform: scale(0.94); }
.set-row.logged .set-log-btn { background: var(--card-2); border-color: var(--line); color: var(--accent-green); }

/* Add set / Skip / Superset: all three always visible, equal thirds */
.ex-actions { display: flex; gap: 0.4rem; padding: 0.4rem 0.3rem 0.1rem; }
.ex-actions .btn { flex: 1; padding: 0.5rem 0.2rem; font-size: 0.86rem; min-height: 40px; }
.ex-actions .btn.ss-waiting { color: var(--accent-purple); border-color: var(--accent-purple); }

/* Extended area: History, the card's only fold-out */
.ex-more { margin: 0.6rem 0.3rem 0.1rem; }
.ex-more summary.more-btn {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  font-size: 0.9rem;
}
.ex-more summary::-webkit-details-marker { display: none; }
.ex-more[open] summary.more-btn { color: var(--text); }
.ex-note { margin: 0.5rem 0.3rem 0.1rem; }
.ex-note textarea { font-size: 0.95rem; min-height: 96px; }

/* Past workouts of this exercise inside the fold-out */
.ex-hist { margin-top: 0.5rem; border-top: 1px solid var(--line); padding-top: 0.4rem; }
.ex-hist-empty { color: var(--text-tertiary); font-size: 0.88rem; padding: 0.3rem 0.2rem 0.5rem; }
.ex-hist-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.15rem 0.6rem;
  padding: 0.3rem 0.2rem;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.ex-hist-row:last-child { border-bottom: none; }
.ex-hist-date { color: var(--muted); font-size: 0.82rem; min-width: 5.4em; }
.ex-hist-sets { flex: 1; font-size: 0.9rem; }
.ex-hist-note { flex-basis: 100%; color: var(--text-tertiary); font-size: 0.82rem; font-style: italic; }

/* Locked (finished/skipped) exercises: reachable escape hatch */
.locked-list { margin-top: 0.7rem; border-top: 1px solid var(--line); padding-top: 0.5rem; }
.locked-title { color: var(--text-tertiary); font-size: 0.8rem; margin-bottom: 0.3rem; }
.locked-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0;
}
.locked-name { flex: 1; font-size: 0.9rem; color: var(--muted); }
.locked-tag { font-size: 0.75rem; color: var(--text-tertiary); }
.locked-reopen { min-height: 36px; padding: 0.3rem 0.7rem; font-size: 0.85rem; }

/* End page */
.end-page { padding-bottom: 1rem; }
.end-head { font-weight: 700; font-size: 1.15rem; padding: 0.85rem 1rem 0.2rem; }
.end-stats {
  display: flex;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
}
.end-stat {
  flex: 1;
  background: var(--card-2);
  border-radius: 12px;
  text-align: center;
  padding: 0.6rem 0.2rem;
}
.end-num {
  display: block;
  font-size: 1.5rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.end-label { display: block; font-size: 0.75rem; color: var(--muted); }
.end-note-label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.8rem;
  color: var(--muted);
  padding: 0.3rem 1rem 0.6rem;
}
.end-page #finish-btn { width: calc(100% - 2rem); margin: 0.3rem 1rem 0.4rem; }
.end-page .locked-list { margin: 0.3rem 1rem 0; }

/* Undo: floating pill, bottom corner, clear of the top rest-timer bar */
#undo-btn {
  position: fixed;
  right: 1rem;
  bottom: calc(env(safe-area-inset-bottom) + 1.1rem);
  z-index: 90;
  min-height: 46px;
  padding: 0.55rem 1.15rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-overlay);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}
#undo-btn:active { transform: scale(0.95); }

/* Finish overlay: checkmark pop, then Home */
#finish-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(13, 15, 18, 0.96);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}
.finish-check {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--accent-green);
  color: var(--on-accent);
  font-size: 3rem;
  font-weight: 800;
  display: grid;
  place-items: center;
  animation: check-pop 400ms var(--spring);
}
.finish-caption { color: var(--muted); font-size: 1.05rem; }
@keyframes check-pop {
  0% { transform: scale(0.4); opacity: 0; }
  70% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); }
}

/* Rest timer: pinned to the TOP, red + huge (readable from the bench) */
.rest-timer {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  width: 100%;
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: 0 0 18px 18px;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: calc(env(safe-area-inset-top) + 0.6rem) 1.1rem 0.65rem;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
  z-index: 100;
}
.rest-timer #rest-label {
  color: rgba(255, 255, 255, 0.85);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.85rem;
}
.rest-timer #rest-clock {
  flex: 1;
  font-size: clamp(2.2rem, 9vw, 3.4rem);
  line-height: 1.1;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #fff;
}
.rest-timer #rest-skip {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.35);
  color: #fff;
  font-weight: 700;
}
.rest-timer.urgent { animation: rest-pulse 1s ease-in-out infinite; }
@keyframes rest-pulse {
  0%, 100% { background: var(--danger); }
  50% { background: #d64545; }
}

/* History */
.hist-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: none;
  border-radius: var(--r-lg);
  padding: 0.9rem 1rem;
  margin-bottom: 0.7rem;
  color: var(--text);
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: var(--shadow-card);
  transition: transform 120ms var(--spring);
}
.hist-row:active { transform: scale(0.98); }
.hist-main { flex: 1; display: flex; flex-direction: column; gap: 0.1rem; }
.hist-date { font-weight: 700; }
.hist-meta { color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.hist-badge {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--accent-orange);
  border: 1px solid var(--accent-orange);
  border-radius: 6px;
  padding: 0.1rem 0.4rem;
}
.hist-badge.error { color: var(--danger); border-color: var(--danger); }
.hist-chev { color: var(--text-tertiary); font-size: 1.4rem; }

.hd-meta { margin-bottom: 0.6rem; }
.hd-ex { border-top: 1px solid var(--line); padding: 0.7rem 0; }
.hd-ex:first-child { border-top: none; padding-top: 0.2rem; }
.hd-ex h3 { font-size: 1rem; margin-bottom: 0.25rem; }
.hd-set {
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
  font-variant-numeric: tabular-nums;
  padding: 0.1rem 0;
}
.hd-w { width: 18px; color: var(--accent-orange); font-weight: 800; font-size: 0.8rem; }
.hd-note { margin-top: 0.3rem; }

/* Metrics screen */
.card-title { font-size: 1.05rem; margin-bottom: 0.4rem; }
.bw-entry { display: grid; grid-template-columns: 1fr auto; gap: 0.5rem; margin: 0.6rem 0; }
.bw-recent { margin-top: 0.4rem; }
.bw-row {
  display: flex; justify-content: space-between;
  padding: 0.35rem 0.2rem; border-top: 1px solid var(--line);
  font-size: 0.92rem; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.bw-row strong { color: var(--text); }

.measure-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  margin: 0.7rem 0;
}
.measure-cell { display: flex; flex-direction: column; gap: 0.2rem; }
.measure-name { font-size: 0.82rem; color: var(--muted); }
.measure-sub { font-size: 0.7rem; }

/* Charts */
.metric-toggle { display: flex; gap: 0.4rem; margin: 0.6rem 0; }
.metric-toggle button {
  flex: 1; padding: 0.45rem; border-radius: 9px; border: 1px solid var(--line);
  background: var(--card-2); color: var(--muted); font-size: 0.85rem; font-weight: 600;
  cursor: pointer;
}
.metric-toggle button.active { background: var(--primary); border-color: var(--primary-2); color: var(--on-accent); }
.plot { margin-top: 0.5rem; }
.chart-svg { width: 100%; height: auto; display: block; background: var(--card-2); border-radius: 10px; }
.chart-caption { font-size: 0.88rem; margin-top: 0.4rem; }
#chart-ex-select, #chart-measure-select { margin-bottom: 0.2rem; }

/* Coach chat */
#screen-chat { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
#chat-log {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.4rem 0.1rem 0.8rem;
}
.chat-msg {
  max-width: 85%;
  padding: 0.6rem 0.8rem;
  border-radius: 14px;
  font-size: 0.98rem;
  line-height: 1.4;
  white-space: normal;
  word-wrap: break-word;
}
.chat-msg.me {
  align-self: flex-end;
  background: var(--primary);
  color: var(--on-accent);
  border-bottom-right-radius: 4px;
}
.chat-msg.coach {
  align-self: flex-start;
  background: var(--card);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}
.chat-msg.typing { color: var(--muted); font-size: 1.3rem; letter-spacing: 2px; }
#chat-input-row {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  padding: 0.5rem 0 calc(env(safe-area-inset-bottom) + 0.4rem);
}
#chat-input {
  flex: 1;
  resize: none;
  max-height: 120px;
  font-size: 1rem;
  line-height: 1.35;
}
#chat-input-row .btn { min-height: 44px; padding: 0.6rem 1rem; }

/* Feedback */
.card.reviewing { text-align: center; padding: 1.6rem 1rem; }
.spinner {
  width: 40px; height: 40px; margin: 0.4rem auto 1rem;
  border: 4px solid var(--line);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.fb-summary { font-size: 1.02rem; }
.fb-flags { list-style: none; margin-top: 0.6rem; }
.fb-flags li { padding: 0.5rem 0.7rem; background: rgba(255, 157, 77, 0.12); border-radius: 10px; margin-bottom: 0.4rem; font-size: 0.9rem; }
.fb-ex { border-top: 1px solid var(--line); padding: 0.8rem 0; }
.fb-ex h3 { font-size: 1rem; }
.fb-ex .fb-next { color: var(--text); font-weight: 600; margin-top: 0.3rem; font-variant-numeric: tabular-nums; }
.fb-ex .fb-analysis { color: var(--muted); font-size: 0.92rem; margin-top: 0.2rem; }

/* Skip today: destructive to the whole exercise, so it lives below the sets,
   away from the logging controls, and reads as a warning rather than an option. */
.btn-skip-away {
  display: block;
  margin: 1.4rem auto 0.2rem;
  padding: 0.5rem 1.4rem;
  background: transparent;
  border: 1px solid rgba(214, 105, 94, 0.45);
  border-radius: 999px;
  color: #d6695e;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.btn-skip-away:active { background: rgba(214, 105, 94, 0.12); }

/* Discard: the one destructive action of a workout, so it sits at the very
   bottom of the end page, quiet until you need it, and always asks first. */
.btn-discard-away {
  display: block;
  width: 100%;
  margin: 2.2rem 0 0.3rem;
  padding: 0.7rem 1rem;
  background: transparent;
  border: 1px solid rgba(214, 105, 94, 0.4);
  border-radius: 12px;
  color: #d6695e;
  font-size: 0.9rem;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.btn-discard-away:active { background: rgba(214, 105, 94, 0.12); }
.btn-discard-away:disabled { opacity: 0.5; }
