@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;600&family=Inter:wght@400;500;600&family=Oswald:wght@500;700&display=swap');

:root {
  --iron: #1C1B1A;
  --steel: #272524;
  --steel-2: #322F2D;
  --line: #3F3B38;
  --chalk: #EDE6D6;
  --chalk-dim: #A8A199;
  --rust: #C1622B;
  --rust-dim: #8B4520;
  --olive: #8A9550;
  --danger: #B0432F;

  --font-display: 'Oswald', 'Arial Narrow', sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', 'SF Mono', 'Consolas', monospace;

  --radius: 10px;
  --radius-sm: 6px;
  --tab-height: 60px;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: var(--font-body);
  background: var(--iron);
  color: var(--chalk);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(var(--tab-height) + env(safe-area-inset-bottom, 0px));
}

input, button, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  border: none;
  outline: none;
  background: none;
}

button {
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

/* ── Header ── */

.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--iron);
  border-bottom: 1px solid var(--line);
  padding: 12px 16px 8px;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}

.app-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.4rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--chalk);
  flex-shrink: 0;
}

.header-date {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--chalk-dim);
  flex-shrink: 0;
}

/* ── Heart rate status ── */

.hr-status {
  display: flex;
  align-items: center;
}

.btn-hr-connect {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--chalk-dim);
  background: var(--steel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 4px 10px;
  white-space: nowrap;
  min-height: 28px;
}

.btn-hr-connect:active {
  background: var(--steel-2);
}

.hr-bpm {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--danger);
  white-space: nowrap;
}

@media (prefers-reduced-motion: no-preference) {
  .hr-bpm {
    animation: hr-pulse 1s ease-in-out infinite;
  }
}

@keyframes hr-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ── Day chips (Today view) ── */

.day-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 0 4px;
  scrollbar-width: none;
}

.day-chips::-webkit-scrollbar { display: none; }

.day-chip {
  flex-shrink: 0;
  position: relative;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--steel);
  color: var(--chalk-dim);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.day-chip.active {
  background: var(--rust);
  border-color: var(--rust);
  color: var(--chalk);
}

.day-chip .today-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--olive);
  flex-shrink: 0;
}

.day-chip.active .today-dot {
  background: var(--chalk);
}

/* ── Tab bar ── */

.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  height: calc(var(--tab-height) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--steel);
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-around;
}

.tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 16px;
  min-width: 64px;
  min-height: 44px;
  border-radius: var(--radius-sm);
  color: var(--chalk-dim);
  transition: color 0.15s;
}

.tab-btn.active {
  color: var(--rust);
}

.tab-btn svg {
  width: 22px;
  height: 22px;
}

.tab-label {
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── Views ── */

.view {
  display: none;
  padding: 12px 16px 24px;
}

.view.active {
  display: block;
}

/* ── Exercise card (expanded "Now" card) ── */

.exercise-card {
  background: var(--steel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  transition: border-color 0.3s;
}

.exercise-card.done {
  border-color: var(--rust-dim);
}

.exercise-card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 4px;
}

.exercise-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.exercise-target {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--chalk-dim);
}

.exercise-last {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--olive);
  margin-bottom: 10px;
}

/* ── How-to disclosure (Today view) ── */

.howto-disclosure {
  margin-bottom: 8px;
}

.howto-toggle {
  font-family: var(--font-body);
  font-size: 0.75rem;
  color: var(--chalk-dim);
  cursor: pointer;
  list-style: none;
  padding: 4px 0;
}

.howto-toggle::-webkit-details-marker { display: none; }

.howto-toggle::before {
  content: '▸ ';
  font-size: 0.65rem;
}

.howto-disclosure[open] .howto-toggle::before {
  content: '▾ ';
}

.howto-body {
  font-size: 0.8rem;
  color: var(--chalk-dim);
  line-height: 1.45;
  padding: 6px 0;
}

.howto-demo-link {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--rust);
  text-decoration: none;
  padding: 4px 0 2px;
}

.howto-demo-link:active {
  color: var(--chalk);
}

/* ── Set dots ── */

.set-dots {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.set-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: var(--iron);
  transition: background 0.2s, border-color 0.2s;
}

.set-dot.filled {
  background: var(--rust);
  border-color: var(--rust);
}

.set-dot.mini {
  width: 10px;
  height: 10px;
  border-width: 1.5px;
}

@media (prefers-reduced-motion: no-preference) {
  .set-dot.pop {
    animation: dot-pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  }
}

@keyframes dot-pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.5); }
  100% { transform: scale(1); }
}

/* ── Timer area ── */

.timer-area {
  margin-bottom: 12px;
  text-align: center;
}

.timer-area.hidden { display: none; }

.timer-label {
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--chalk-dim);
  margin-bottom: 4px;
}

.timer-label.active { color: var(--rust); }
.timer-label.resting { color: var(--olive); }

.timer-display {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 3.2rem;
  color: var(--chalk);
  line-height: 1.1;
}

.rest-bar {
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}

.rest-bar-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--rust);
  transition: width 0.25s linear;
}

.rest-bar-fill.target-met {
  background: var(--olive);
}

/* ── Steppers ── */

.stepper-row {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.stepper {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--steel-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  overflow: hidden;
  height: 44px;
}

.stepper-label {
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--chalk-dim);
  margin-bottom: 4px;
}

.stepper-group {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.stepper-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--chalk);
  background: transparent;
  flex-shrink: 0;
}

.stepper-btn:active {
  background: var(--line);
}

.stepper-value {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 1rem;
  color: var(--chalk);
  text-align: center;
  width: 56px;
  background: transparent;
  border: none;
  -moz-appearance: textfield;
}

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

.stepper-unit {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--chalk-dim);
  padding-right: 10px;
}

/* ── RPE chips ── */

.rpe-row {
  margin-bottom: 10px;
}

.rpe-chips {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.rpe-chip {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: var(--iron);
  color: var(--chalk-dim);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.rpe-chip.active {
  background: var(--olive);
  border-color: var(--olive);
  color: var(--iron);
}

/* ── Notes input ── */

.notes-input {
  width: 100%;
  height: 40px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--iron);
  color: var(--chalk);
  font-size: 0.85rem;
  margin-bottom: 12px;
}

.notes-input::placeholder {
  color: var(--chalk-dim);
  opacity: 0.6;
}

/* ── Timer button (replaces Log Set) ── */

.btn-timer {
  width: 100%;
  height: 52px;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  transition: background 0.15s;
}

.btn-timer.idle {
  background: var(--rust);
  color: var(--chalk);
}

.btn-timer.idle:active {
  background: var(--rust-dim);
}

.btn-timer.active {
  background: var(--danger);
  color: var(--chalk);
}

.btn-timer.active:active {
  background: #8a3020;
}

.btn-timer.resting {
  background: var(--steel-2);
  border: 2px solid var(--rust-dim);
  color: var(--chalk-dim);
}

.btn-timer.resting.target-met {
  background: var(--olive);
  border-color: var(--olive);
  color: var(--iron);
}

.btn-timer.resting:active {
  background: var(--rust-dim);
}

.btn-timer.resting.target-met:active {
  background: #6e7a3f;
}

/* ── Logged sets list ── */

.logged-sets {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.logged-set {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--chalk-dim);
}

.logged-set-text span {
  color: var(--chalk);
}

.btn-delete-set {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--chalk-dim);
  font-size: 0.9rem;
}

.btn-delete-set:active {
  background: var(--danger);
  color: var(--chalk);
}

/* ── Exercise tile grid (Today view) ── */

.exercise-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 4px 0 0;
}

.exercise-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 8px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--steel);
  color: var(--chalk-dim);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  min-height: 56px;
  cursor: pointer;
}

.exercise-tile:active {
  background: var(--steel-2);
}

.exercise-tile.active {
  background: var(--rust);
  border-color: var(--rust);
  color: var(--chalk);
}

.exercise-tile.done {
  border-color: var(--rust-dim);
}

.exercise-tile.active.done {
  background: var(--rust-dim);
  border-color: var(--rust-dim);
}

.exercise-tile-name {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: center;
  line-height: 1.2;
  word-break: break-word;
}

.exercise-tile .set-dots {
  margin-bottom: 0;
  gap: 4px;
}

.exercise-tile .set-dot.mini {
  width: 7px;
  height: 7px;
  border-width: 1px;
}

.exercise-tile.active .set-dot {
  border-color: rgba(255,255,255,0.4);
  background: rgba(255,255,255,0.15);
}

.exercise-tile.active .set-dot.filled {
  background: var(--chalk);
  border-color: var(--chalk);
}

/* ── Empty state ── */

.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--chalk-dim);
  font-size: 0.9rem;
}

.empty-state p {
  margin-bottom: 12px;
}

.btn-link {
  color: var(--rust);
  text-decoration: underline;
  font-weight: 500;
}

/* ── Progress view ── */

.progress-section-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
  color: var(--chalk-dim);
}

/* ── Streak strip (Today) / summary strip (Progress) ── */

.streak-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 2px 14px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.streak-current {
  color: var(--chalk);
}

.streak-best {
  color: var(--chalk-dim);
}

.upcoming-session-line {
  padding: 8px 2px 14px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--chalk-dim);
}

.streak-strip + .upcoming-session-line {
  padding-top: 0;
}

.progress-summary-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.summary-item {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--chalk-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.summary-item .value {
  color: var(--chalk);
  font-weight: 600;
}

/* ── Progress tile grid ── */

.progress-filters {
  margin-bottom: 14px;
}

.progress-tile-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  width: 100%;
  margin-bottom: 20px;
}

.progress-tile {
  position: relative;
  min-width: 0;
  background: var(--steel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.2s;
}

.progress-tile:active {
  border-color: var(--rust-dim);
}

.progress-tile-pr {
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: 0.9rem;
}

.progress-tile-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.88rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  padding-right: 20px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-tile-bodypart {
  font-size: 0.68rem;
  color: var(--chalk-dim);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-top: 2px;
}

.progress-tile-spark {
  margin: 8px 0;
}

.progress-tile-spark svg {
  width: 100%;
  height: 28px;
  display: block;
}

.progress-tile-best {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--rust);
}

/* ── Exercise detail bottom sheet ── */

.sheet-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0, 0, 0, 0.6);
  align-items: flex-end;
  justify-content: center;
}

.sheet-overlay.open {
  display: flex;
}

.bottom-sheet {
  background: var(--steel);
  border: 1px solid var(--line);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom, 0px));
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.25s ease;
}

.sheet-overlay.open .bottom-sheet {
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .bottom-sheet {
    transition: none;
  }
}

.sheet-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px;
}

.sheet-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  text-transform: uppercase;
}

.sheet-subtitle {
  font-size: 0.75rem;
  color: var(--chalk-dim);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-top: 2px;
}

.sheet-close {
  color: var(--chalk-dim);
  font-size: 1.4rem;
  line-height: 1;
  padding: 4px 8px;
  flex-shrink: 0;
}

.sheet-pr-summary {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 0.78rem;
  color: var(--chalk-dim);
  margin-bottom: 16px;
}

.sheet-pr-summary .value {
  font-family: var(--font-mono);
  color: var(--rust);
  font-weight: 600;
}

.sheet-session-list {
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.sheet-session-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--chalk-dim);
}

.sheet-session-date {
  color: var(--chalk);
  flex-shrink: 0;
}

.sheet-session-sets {
  flex: 1;
  text-align: center;
}

.sheet-session-top {
  color: var(--rust);
  flex-shrink: 0;
}

.sheet-session-notes {
  font-size: 0.72rem;
  color: var(--chalk-dim);
  padding: 0 0 8px;
  border-bottom: 1px solid var(--line);
  font-style: italic;
}

.progress-metric-toggle {
  display: flex;
  gap: 4px;
  margin-bottom: 10px;
}

.progress-metric-btn {
  flex: 1;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--iron);
  color: var(--chalk-dim);
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.progress-metric-btn.active {
  background: var(--rust);
  border-color: var(--rust);
  color: var(--chalk);
}

.progress-chart {
  margin-bottom: 10px;
}

.progress-chart svg {
  width: 100%;
  height: 120px;
}

/* ── Body-part balance ── */

.balance-section {
  margin-bottom: 24px;
}

.balance-window-chips {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}

.balance-window-chip {
  flex-shrink: 0;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 6px 12px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--steel);
  color: var(--chalk-dim);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  min-height: 30px;
}

.balance-window-chip.active {
  background: var(--rust);
  border-color: var(--rust);
  color: var(--chalk);
}

.balance-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.balance-bar-label {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--chalk-dim);
  width: 90px;
  flex-shrink: 0;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.balance-bar-track {
  flex: 1;
  height: 20px;
  background: var(--steel);
  border-radius: 3px;
  border: 1px solid var(--line);
  overflow: hidden;
  position: relative;
}

.balance-bar-fill {
  height: 100%;
  background: var(--rust);
  border-radius: 2px;
  transition: width 0.3s ease;
  min-width: 2px;
}

.balance-bar-fill.untagged {
  background: var(--chalk-dim);
  opacity: 0.5;
}

.balance-bar-value {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--chalk-dim);
  width: 70px;
  flex-shrink: 0;
  text-align: left;
}

.progress-sessions-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
  color: var(--chalk-dim);
}

.session-card {
  background: var(--steel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 8px;
  overflow: hidden;
}

.session-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  cursor: pointer;
  min-height: 48px;
}

.session-header:active {
  background: var(--steel-2);
}

.session-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.session-day-name {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.9rem;
  text-transform: uppercase;
}

.session-date {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--chalk-dim);
}

.session-volume {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--chalk-dim);
}

.session-chevron {
  color: var(--chalk-dim);
  transition: transform 0.2s;
  font-size: 0.8rem;
}

.session-card.expanded .session-chevron {
  transform: rotate(90deg);
}

.session-detail {
  display: none;
  padding: 0 16px 12px;
  border-top: 1px solid var(--line);
}

.session-card.expanded .session-detail {
  display: block;
}

.session-entry {
  padding: 6px 0;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--chalk-dim);
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.session-entry:last-child {
  border-bottom: none;
}

.session-entry-name {
  font-family: var(--font-display);
  font-weight: 500;
  text-transform: uppercase;
  font-size: 0.8rem;
  color: var(--chalk);
}

/* ── Program view ── */

.program-day {
  background: var(--steel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 14px;
  overflow: hidden;
}

.program-day-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
}

.program-day.expanded .program-day-header {
  border-bottom: 1px solid var(--line);
}

.program-day-chevron {
  flex-shrink: 0;
  color: var(--chalk-dim);
  transition: transform 0.15s;
}

.program-day.expanded .program-day-chevron {
  transform: rotate(90deg);
}

.program-day-count {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--chalk-dim);
  flex-shrink: 0;
  white-space: nowrap;
}

.program-day-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  text-transform: uppercase;
  flex: 1;
  background: transparent;
  color: var(--chalk);
  border-bottom: 1px solid transparent;
  padding: 4px 0;
  min-width: 0;
  cursor: text;
}

.program-day-name:focus {
  border-bottom-color: var(--rust);
}

.program-dow-select {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  background: var(--steel-2);
  color: var(--chalk);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  min-height: 36px;
}

.btn-delete-day {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--chalk-dim);
  font-size: 1rem;
}

.btn-delete-day:active {
  background: var(--danger);
  color: var(--chalk);
}

.program-ex-col-headers {
  display: flex;
  gap: 8px;
  padding: 8px 16px 2px;
  font-family: var(--font-display);
  font-size: 0.65rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--chalk-dim);
}

.program-ex-col-headers span {
  flex: 1;
  text-align: center;
}

.program-exercise {
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
}

.program-exercise:last-of-type {
  border-bottom: none;
}

.program-ex-line1 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.program-ex-name {
  flex: 1;
  min-width: 0;
  font-size: 0.88rem;
  background: transparent;
  color: var(--chalk);
  border-bottom: 1px solid transparent;
  padding: 4px 0;
}

.program-ex-name:focus {
  border-bottom-color: var(--rust);
}

.btn-delete-ex {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--chalk-dim);
  font-size: 0.95rem;
  flex-shrink: 0;
}

.btn-delete-ex:active {
  background: var(--danger);
  color: var(--chalk);
}

.program-ex-line2 {
  display: flex;
  gap: 8px;
}

.program-ex-field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.program-ex-readonly-value {
  width: 100%;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--chalk-dim);
  background: var(--steel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 6px;
  min-height: 40px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pt-lock-tag {
  display: inline-block;
  margin-left: 6px;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 2px 6px;
  border-radius: 8px;
  color: var(--rust);
  background: rgba(193, 98, 43, 0.15);
  text-decoration: none;
  vertical-align: middle;
}

.program-ex-select {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  background: var(--steel-2);
  color: var(--chalk);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 6px;
  min-height: 40px;
  appearance: auto;
}

.program-ex-custom {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  text-align: center;
  background: var(--iron);
  color: var(--chalk);
  border: 1px solid var(--rust);
  border-radius: var(--radius-sm);
  padding: 6px;
  min-height: 36px;
  -moz-appearance: textfield;
}

.program-ex-custom::-webkit-inner-spin-button,
.program-ex-custom::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.program-howto-details {
  margin-top: 6px;
}

.program-howto-toggle {
  font-family: var(--font-body);
  font-size: 0.75rem;
  color: var(--rust);
  cursor: pointer;
  list-style: none;
  padding: 2px 0;
}

.program-howto-toggle::-webkit-details-marker { display: none; }

.program-howto-textarea {
  width: 100%;
  margin-top: 6px;
  padding: 8px 10px;
  font-family: var(--font-body);
  font-size: 0.82rem;
  color: var(--chalk);
  background: var(--iron);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  resize: vertical;
  line-height: 1.4;
  min-height: 60px;
}

.program-howto-textarea::placeholder {
  color: var(--chalk-dim);
  opacity: 0.5;
}

.program-howto-textarea:focus {
  border-color: var(--rust);
}

.btn-add-exercise {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 16px;
  width: 100%;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--rust);
  border-top: 1px solid var(--line);
}

.btn-add-exercise:active {
  background: var(--steel-2);
}

.btn-add-day {
  width: 100%;
  height: 48px;
  border-radius: var(--radius);
  border: 2px dashed var(--line);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--chalk-dim);
  margin-bottom: 24px;
  transition: border-color 0.15s, color 0.15s;
}

.btn-add-day:active {
  border-color: var(--rust);
  color: var(--rust);
}

/* ── Backup reminder ── */

.backup-reminder {
  background: var(--steel);
  border: 1px solid var(--rust-dim);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 14px;
  font-size: 0.85rem;
  color: var(--chalk-dim);
  line-height: 1.4;
}

.settings-backup-reminder {
  margin-top: 20px;
}

.backup-reminder-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  align-items: center;
}

.btn-reminder-dismiss {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--chalk-dim);
  font-size: 1.1rem;
  flex-shrink: 0;
  border: 1px solid var(--line);
}

.btn-reminder-dismiss:active {
  background: var(--steel-2);
}

/* ── Data actions ── */

.section-label {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--chalk-dim);
  margin-bottom: 8px;
}

.section-label + .section-label {
  margin-top: 0;
}

.data-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.data-actions .section-label {
  margin-bottom: 0;
  margin-top: 10px;
}

.data-actions .section-label:first-child {
  margin-top: 0;
}

.button-row {
  display: flex;
  gap: 10px;
}

.button-row .btn-action {
  flex: 1;
}

.btn-action {
  height: 44px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--steel);
  color: var(--chalk);
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: background 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-action svg {
  flex-shrink: 0;
}

.btn-action:active {
  background: var(--steel-2);
}

.btn-action.danger {
  border-color: var(--danger);
  color: var(--danger);
}

.btn-action.danger:active {
  background: var(--danger);
  color: var(--chalk);
}

.btn-action.primary {
  width: 100%;
  border-color: var(--rust);
  background: var(--rust);
  color: var(--chalk);
  margin-top: 4px;
}

.btn-action.primary:active {
  background: var(--rust-dim);
  border-color: var(--rust-dim);
}

.settings-note {
  font-size: 0.78rem;
  color: var(--chalk-dim);
  margin-top: -2px;
}

.settings-nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--steel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  min-height: 52px;
  transition: background 0.15s;
}

.settings-nav-row:active {
  background: var(--steel-2);
}

.settings-nav-label {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--chalk);
}

.settings-back {
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--rust);
  margin-bottom: 14px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.settings-back:active {
  color: var(--chalk);
}

.settings-divider {
  border: none;
  border-top: 1px solid var(--line);
  margin: 20px 0;
}

.settings-divider-danger {
  margin-top: 28px;
}

/* ── Backup history sheet ── */

.backup-list {
  border-top: 1px solid var(--line);
  padding-top: 4px;
}

.backup-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.backup-row-info {
  min-width: 0;
}

.backup-row-label {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--chalk);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.backup-row-meta {
  font-size: 0.72rem;
  color: var(--chalk-dim);
  margin-top: 2px;
}

.backup-row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.btn-backup-restore {
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--rust);
  background: transparent;
  color: var(--rust);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  transition: background 0.15s, color 0.15s;
}

.btn-backup-restore:active {
  background: var(--rust);
  color: var(--chalk);
}

.btn-backup-delete {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  color: var(--danger);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}

.btn-backup-delete:active {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--chalk);
}

.backup-sheet-note {
  font-size: 0.72rem;
  font-style: italic;
  color: var(--chalk-dim);
  margin-top: 12px;
}

.account-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.account-row .btn-action {
  flex-shrink: 0;
  padding: 0 16px;
}

.account-card {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 44px;
  padding: 0 14px;
  background: var(--steel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.account-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--steel-2);
}

.account-name {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--chalk);
}

/* ── PT section (Settings) ── */

.pt-avatar-initials {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--chalk);
}

.pt-program-banner {
  background: var(--steel);
  border: 1px solid var(--rust-dim);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 10px 0;
}

.pt-program-banner-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--chalk);
  margin-bottom: 4px;
}

.pt-program-banner-meta {
  font-size: 0.78rem;
  color: var(--chalk-dim);
  margin-bottom: 10px;
}

.pt-link-option {
  background: var(--steel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.pt-link-option-title {
  font-family: var(--font-display);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.9rem;
  color: var(--chalk);
  margin-bottom: 4px;
}

.pt-link-option-desc {
  font-size: 0.82rem;
  color: var(--chalk-dim);
  line-height: 1.4;
  margin-bottom: 12px;
}

.pt-code-input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--iron);
  color: var(--chalk);
  font-family: var(--font-mono);
  font-size: 1rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.pt-code-error {
  font-size: 0.8rem;
  color: var(--danger);
  margin-top: -4px;
  margin-bottom: 10px;
}

.pt-schedule-date-header {
  font-family: var(--font-display);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  color: var(--chalk-dim);
  margin: 18px 0 6px;
}

.pt-schedule-date-header:first-child {
  margin-top: 0;
}

.pt-schedule-session {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.pt-schedule-session:last-child {
  border-bottom: none;
}

.pt-schedule-session.status-cancelled .pt-schedule-session-top {
  opacity: 0.4;
  text-decoration: line-through;
}

.pt-schedule-session-top {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--chalk);
}

.pt-schedule-session-note {
  font-size: 0.82rem;
  color: var(--chalk-dim);
  margin-top: 4px;
  line-height: 1.4;
}

.pt-status-badge {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 2px 8px;
  border-radius: 10px;
}

.pt-status-badge.completed {
  color: var(--olive);
  background: rgba(138, 149, 80, 0.15);
}

.pt-status-badge.cancelled {
  color: var(--danger);
  background: rgba(176, 67, 47, 0.15);
}

.pt-preview-day {
  margin-bottom: 18px;
}

.pt-preview-day-name {
  font-family: var(--font-display);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 1rem;
  color: var(--chalk);
  margin-bottom: 8px;
}

.pt-preview-ex-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.88rem;
}

.pt-preview-ex-row:last-child {
  border-bottom: none;
}

.pt-preview-ex-target {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--chalk-dim);
  white-space: nowrap;
}

/* ── Confirm dialog ── */

.dialog-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0, 0, 0, 0.6);
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.dialog-overlay.open {
  display: flex;
}

.dialog {
  background: var(--steel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 320px;
  width: 100%;
}

.dialog-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.dialog-message {
  font-size: 0.9rem;
  color: var(--chalk-dim);
  margin-bottom: 20px;
  line-height: 1.4;
}

.dialog-buttons {
  display: flex;
  gap: 10px;
}

.dialog-buttons button {
  flex: 1;
  height: 44px;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.btn-cancel {
  border: 1px solid var(--line);
  color: var(--chalk-dim);
}

.btn-confirm-danger {
  background: var(--danger);
  color: var(--chalk);
}

/* ── QR dialog ── */

.qr-dialog {
  max-width: 360px;
  text-align: center;
}

.qr-dialog canvas {
  width: 100%;
  max-width: 280px;
  height: auto;
  border-radius: var(--radius-sm);
  margin: 12px auto;
  display: block;
  image-rendering: pixelated;
}

/* ── Scanner overlay ── */

.scanner-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 400;
  background: var(--iron);
  flex-direction: column;
}

.scanner-overlay.open {
  display: flex;
}

.scanner-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.scanner-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  text-transform: uppercase;
}

.scanner-overlay video {
  flex: 1;
  width: 100%;
  object-fit: cover;
  background: #000;
}

.scanner-status {
  padding: 14px 16px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--chalk-dim);
  border-top: 1px solid var(--line);
}

/* ── File input (hidden) ── */

.file-input {
  display: none;
}

/* ── Toast ── */

.toast {
  position: fixed;
  bottom: calc(var(--tab-height) + 16px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--steel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 20px;
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--chalk);
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 250;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Exercises tab ── */

.exercises-header {
  margin-bottom: 12px;
}

.exercises-search {
  width: 100%;
  height: 44px;
  padding: 8px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--steel);
  color: var(--chalk);
  font-size: 0.9rem;
  margin-bottom: 10px;
}

.exercises-search::placeholder {
  color: var(--chalk-dim);
  opacity: 0.6;
}

.exercises-search:focus {
  border-color: var(--rust);
}

.bodypart-filters {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.bodypart-filters::-webkit-scrollbar { display: none; }

.bodypart-chip {
  flex-shrink: 0;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 6px 12px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--steel);
  color: var(--chalk-dim);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  min-height: 32px;
}

.bodypart-chip.active {
  background: var(--rust);
  border-color: var(--rust);
  color: var(--chalk);
}

.exercise-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--steel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
  cursor: pointer;
  min-height: 56px;
  transition: background 0.15s;
}

.exercise-list-item:active {
  background: var(--steel-2);
}

.exercise-list-thumb {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--steel-2);
  flex-shrink: 0;
}

.exercise-list-thumb-placeholder {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--steel-2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--chalk-dim);
  font-size: 1.2rem;
}

.exercise-list-info {
  flex: 1;
  min-width: 0;
}

.exercise-list-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--chalk);
}

.exercise-list-bodypart {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--chalk-dim);
}

.exercise-list-chevron {
  color: var(--chalk-dim);
  font-size: 0.8rem;
  flex-shrink: 0;
}

/* ── Exercise detail/edit ── */

.exercise-detail {
  background: var(--steel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.exercise-detail-back {
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--rust);
  margin-bottom: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.exercise-detail-back:active {
  color: var(--chalk);
}

.exercise-detail-field {
  margin-bottom: 14px;
}

.exercise-detail-label {
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--chalk-dim);
  margin-bottom: 4px;
}

.exercise-detail-input {
  width: 100%;
  height: 44px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--iron);
  color: var(--chalk);
  font-size: 0.9rem;
}

.exercise-detail-input:focus {
  border-color: var(--rust);
}

.exercise-detail-select {
  width: 100%;
  height: 44px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--iron);
  color: var(--chalk);
  font-size: 0.9rem;
  appearance: auto;
}

.exercise-detail-textarea {
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--iron);
  color: var(--chalk);
  font-size: 0.85rem;
  line-height: 1.4;
  resize: vertical;
  min-height: 80px;
  font-family: var(--font-body);
}

.exercise-detail-textarea:focus {
  border-color: var(--rust);
}

.exercise-detail-textarea::placeholder {
  color: var(--chalk-dim);
  opacity: 0.5;
}

.btn-delete-exercise {
  width: 100%;
  height: 44px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--danger);
  color: var(--danger);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 8px;
}

.btn-delete-exercise:active {
  background: var(--danger);
  color: var(--chalk);
}

/* ── Photo management ── */

.photo-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0;
  scrollbar-width: none;
}

.photo-strip::-webkit-scrollbar { display: none; }

.photo-thumb-wrap {
  position: relative;
  flex-shrink: 0;
}

.photo-thumb {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  cursor: pointer;
  border: 1px solid var(--line);
}

.photo-thumb:active {
  opacity: 0.8;
}

.photo-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--danger);
  color: var(--chalk);
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--steel);
}

.btn-add-photo {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-sm);
  border: 2px dashed var(--line);
  color: var(--chalk-dim);
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.btn-add-photo:active {
  border-color: var(--rust);
  color: var(--rust);
}

/* ── Inline photo strip (Today view how-to) ── */

.howto-photos {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 6px 0 2px;
  scrollbar-width: none;
}

.howto-photos::-webkit-scrollbar { display: none; }

.howto-photo-thumb {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  cursor: pointer;
  border: 1px solid var(--line);
  flex-shrink: 0;
}

.howto-photo-thumb:active {
  opacity: 0.8;
}

.howto-video-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--rust);
  text-decoration: none;
  padding: 4px 0 2px;
}

.howto-video-link:active {
  color: var(--chalk);
}

/* ── Exercise picker overlay ── */

.picker-dialog {
  max-width: 380px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.picker-search {
  width: 100%;
  height: 40px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--iron);
  color: var(--chalk);
  font-size: 0.85rem;
  margin-bottom: 8px;
}

.picker-search::placeholder {
  color: var(--chalk-dim);
  opacity: 0.6;
}

.picker-search:focus {
  border-color: var(--rust);
}

.picker-filters {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  margin-bottom: 10px;
  scrollbar-width: none;
}

.picker-filters::-webkit-scrollbar { display: none; }

.picker-list {
  flex: 1;
  overflow-y: auto;
  min-height: 120px;
  max-height: 40vh;
}

.picker-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.15s;
}

.picker-item:last-child {
  border-bottom: none;
}

.picker-item:active {
  background: var(--steel-2);
}

.picker-item-name {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.88rem;
  text-transform: uppercase;
  color: var(--chalk);
}

.picker-item-bodypart {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--chalk-dim);
}

.picker-empty {
  text-align: center;
  padding: 24px 8px;
  color: var(--chalk-dim);
  font-size: 0.85rem;
  line-height: 1.5;
}

/* ── Image viewer ── */

.image-viewer {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-viewer img {
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: var(--radius);
}

.image-viewer-close {
  position: absolute;
  top: -12px;
  right: -12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--steel);
  border: 1px solid var(--line);
  color: var(--chalk);
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Program exercise (reference style) ── */

.program-ex-name-readonly {
  flex: 1;
  min-width: 0;
  font-size: 0.88rem;
  color: var(--rust);
  padding: 4px 0;
  text-decoration: underline;
  text-decoration-color: transparent;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.program-ex-name-readonly:active {
  text-decoration-color: var(--rust);
}

/* ── Scrollbar ── */

::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 2px;
}

/* ── Coach ── */

.coach-fab {
  display: none;
  position: fixed;
  bottom: calc(var(--tab-height) + 16px + env(safe-area-inset-bottom, 0px));
  right: 18px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--rust);
  border: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  align-items: center;
  justify-content: center;
  z-index: 220;
  cursor: pointer;
}

.coach-fab.visible {
  display: flex;
}

.coach-fab svg {
  width: 24px;
  height: 24px;
  color: var(--chalk);
}

.coach-overlay {
  position: fixed;
  inset: 0;
  background: var(--iron);
  z-index: 450;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.coach-overlay.open {
  transform: translateY(0);
}

.coach-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  flex-shrink: 0;
  background: var(--steel);
  border-bottom: 1px solid var(--line);
  padding: 14px 18px;
  padding-top: calc(14px + env(safe-area-inset-top, 0px));
}

.coach-title {
  grid-column: 2;
  justify-self: center;
  font-family: var(--font-display);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--chalk);
  font-size: 18px;
}

.coach-clear {
  grid-column: 1;
  justify-self: start;
  background: none;
  border: none;
  color: var(--chalk-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  cursor: pointer;
}

.coach-close {
  grid-column: 3;
  justify-self: end;
  background: none;
  border: none;
  color: var(--chalk-dim);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

.coach-disclaimer {
  display: none;
  flex-shrink: 0;
  background: var(--steel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin: 12px 16px 0;
}

.coach-disclaimer-text {
  display: block;
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.5;
  color: var(--chalk-dim);
}

.coach-disclaimer-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.coach-disclaimer-dismiss {
  background: none;
  border: none;
  color: var(--rust);
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 4px 6px;
  cursor: pointer;
}

.coach-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
}

.msg-user {
  align-self: flex-end;
  background: var(--rust);
  color: var(--iron);
  border-radius: 18px 18px 4px 18px;
  padding: 10px 14px;
  max-width: 80%;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-coach {
  align-self: flex-start;
  background: var(--steel-2);
  color: var(--chalk);
  border-radius: 18px 18px 18px 4px;
  padding: 10px 14px;
  max-width: 85%;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
}

.msg-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--chalk-dim);
  animation: coach-typing-bounce 1.2s infinite ease-in-out;
}

.msg-typing span:nth-child(2) { animation-delay: 0.15s; }
.msg-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes coach-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .msg-typing span {
    animation: none;
  }
}

.coach-prompts {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 12px;
}

.coach-prompt-chip {
  background: var(--steel);
  border: 1px solid var(--line);
  color: var(--chalk-dim);
  border-radius: 999px;
  padding: 8px 14px;
  font-family: var(--font-body);
  font-size: 13px;
  cursor: pointer;
}

.coach-input-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--steel);
  border-top: 1px solid var(--line);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
}

.coach-input {
  flex: 1;
  background: var(--iron);
  color: var(--chalk);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 16px;
  font-family: var(--font-body);
  font-size: 14px;
}

.coach-input:focus {
  outline: none;
  border-color: var(--rust);
}

.coach-send {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--rust);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.coach-send svg {
  width: 18px;
  height: 18px;
  color: var(--chalk);
}

.coach-loading {
  color: var(--chalk-dim);
  font-family: var(--font-body);
  font-size: 13px;
  text-align: center;
  padding: 8px 0;
}

.coach-action-card {
  align-self: flex-start;
  background: var(--steel);
  border: 1px solid var(--rust-dim);
  border-radius: var(--radius);
  padding: 14px;
  margin-top: 8px;
  max-width: 85%;
}

.coach-action-header {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--chalk-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.coach-action-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  color: var(--chalk);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.coach-action-meta {
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--chalk-dim);
  margin-bottom: 12px;
}

.coach-action-buttons {
  display: flex;
  gap: 8px;
}

.coach-action-accept {
  flex: 1;
  background: var(--rust);
  color: var(--iron);
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  padding: 9px 0;
  cursor: pointer;
}

.coach-action-dismiss {
  background: none;
  border: 1px solid var(--line);
  color: var(--chalk-dim);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 9px 14px;
  cursor: pointer;
}
