/* app.css — BolderFit.AI mobile-first dark theme */

/* ── Root vars ─────────────────────────────────────────────────────────────── */
:root {
  /* Iron Terminal (round-2 slice 5a): true-black ground, near-black flat
     surfaces separated by hairline borders - no shadows, no gradients.
     Red is reserved for the primary action and live states only. */
  --color-bg:          #000000;
  --color-surface:     #0d0d0d;
  --color-surface2:    #161616;
  --color-border:      #262626;
  --color-text:        #f0f0f0;
  --color-muted:       #8a8a8a;
  --color-primary:     #e02020;
  --color-success:     #4caf50;
  --color-warning:     #ffb74d;
  --color-danger:      #ff4444;
  --bottom-nav-height: 60px;
  --header-height:     52px;

  /* Radius scale — one system, no per-component drift:
     lg = cards/modals, md = rows/buttons/inputs, sm = badges/chips */
  --radius-lg: 12px;
  --radius-md: 10px;
  --radius-sm: 6px;

  /* Motion (Emil Kowalski curves) — transform/opacity only, UI stays <300ms */
  --ease-out:    cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);

  /* Override Bootstrap's primary to match our red */
  --bs-primary:        #e02020;
  --bs-primary-rgb:    224, 32, 32;
  --bs-link-color:     #e02020;
  --bs-link-color-rgb: 224, 32, 32;
}

html {
  height: 100%;
  /* html background fills the full screen including iOS home indicator area below viewport */
  background: #161616; /* matches --color-surface2; hardcoded because var() isn't reliable pre-render */
}

/* Lock nav + header during AI thinking or action applying */
.coach-thinking .bottom-nav,
.coach-thinking .app-header a,
.coach-thinking .app-header button,
.coach-thinking .coach-back-btn,
.coach-thinking #sendBtn,
.nav-applying .bottom-nav,
.nav-applying .app-header a,
.nav-applying .app-header button,
.nav-applying .coach-back-btn,
.nav-applying #sendBtn,
.nav-applying #followUpInput {
  opacity: 0.35;
  pointer-events: none;
}

.coach-thinking form[data-confirm],
.coach-thinking form[data-confirm] *,
.nav-applying form[data-confirm],
.nav-applying form[data-confirm] * {
  opacity: 0.35 !important;
  pointer-events: none !important;
}

/* Override Bootstrap's btn-primary — it uses its own vars, not --bs-primary */
.btn-primary {
  --bs-btn-bg:                var(--color-primary);
  --bs-btn-border-color:      var(--color-primary);
  --bs-btn-hover-bg:          #c01818;
  --bs-btn-hover-border-color:#c01818;
  --bs-btn-active-bg:         #a81010;
  --bs-btn-active-border-color:#a81010;
  --bs-btn-disabled-bg:       var(--color-primary);
  --bs-btn-disabled-border-color: var(--color-primary);
}

.btn-outline-primary {
  --bs-btn-color:              var(--color-primary);
  --bs-btn-border-color:       var(--color-primary);
  --bs-btn-hover-bg:           var(--color-primary);
  --bs-btn-hover-border-color: var(--color-primary);
  --bs-btn-active-bg:          var(--color-primary);
  --bs-btn-active-border-color:var(--color-primary);
}

.bg-primary { background-color: var(--color-primary) !important; }
.text-primary { color: var(--color-primary) !important; }
.border-primary { border-color: var(--color-primary) !important; }

/* Strip Bootstrap's focus box-shadow on buttons. */
.btn:focus,
.btn:focus-visible {
  outline: none !important;
  box-shadow: none !important;
}

/* Press feedback on every pressable — the interface confirms it heard the tap.
   transform-only (GPU), 160ms ease-out, subtle 0.97 scale. */
.btn {
  border-radius: var(--radius-md);
  transition: transform 160ms var(--ease-out), background-color .15s ease, border-color .15s ease, color .15s ease;
}
.btn:active {
  transform: scale(0.97);
}

/* Tappable list rows get the same acknowledgment, gentler */
.session-row:active,
.workout-manage-row:active,
.conversation-row:active {
  transform: scale(0.985);
}
.session-row,
.workout-manage-row,
.conversation-row {
  transition: transform 160ms var(--ease-out), border-color .15s ease;
}

/* Motion is feedback, not decoration — honor the OS setting */
@media (prefers-reduced-motion: reduce) {
  .btn, .session-row, .workout-manage-row, .conversation-row {
    transition: background-color .15s ease, border-color .15s ease, color .15s ease;
  }
  .btn:active, .session-row:active, .workout-manage-row:active, .conversation-row:active {
    transform: none;
  }
  .typing-dots span, .loading-dots span {
    animation: none;
    opacity: .7;
  }
}

/* On touch-only devices iOS keeps :hover active after a tap until the next tap
   elsewhere. Bootstrap's hover changes bg/border/color, which shows as a
   persistent whitish highlight. Reset hover vars back to their resting values
   so tapping a button looks the same before and after. */
@media (hover: none) {
  .btn:hover {
    color: var(--bs-btn-color) !important;
    background-color: var(--bs-btn-bg) !important;
    border-color: var(--bs-btn-border-color) !important;
    box-shadow: none !important;
  }
}

body {
  height: 100%;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 15px;
  touch-action: manipulation; /* disables double-tap zoom, keeps pinch-to-zoom */
  -webkit-tap-highlight-color: transparent;
  /* Flex column so page-main fills available height between header and nav.
     overflow must NOT be set — it clips position:fixed children (loading overlay) on iOS Safari. */
  display: flex;
  flex-direction: column;
}

/* Only <main> scrolls. Nav is in-flow below it — no padding-bottom hack needed.
   overscroll-behavior: contain stops scroll from chaining up to body/html
   while preserving native pull-to-refresh. */
.page-main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;  /* content bugs must never make the page side-scrollable */
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-bottom: 16px;
}

/* Bootstrap 5 does NOT ship .min-w-0, but templates use it everywhere to let
   flex children shrink so .text-truncate can engage. Without it min-width:auto
   wins and long names push siblings off-screen (the Next-up card bug, 2026-07-14). */
.min-w-0 { min-width: 0 !important; }

/* ── Header ────────────────────────────────────────────────────────────────── */
.app-header {
  height: calc(var(--header-height) + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
  /* No sticky needed — header is outside the scroll container so it never moves */
}

.app-logo {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -.3px;
}

/* Remove the card-header's bottom border when its body is collapsed — the
   card's own border handles the bottom edge */
.card-header[data-bs-toggle="collapse"].collapsed {
  border-bottom: 0;
}

/* Flip chevrons when collapse panels are open */
[data-bs-toggle="collapse"] .bi-chevron-down {
  transition: transform .2s ease;
}
[data-bs-toggle="collapse"]:not(.collapsed) .bi-chevron-down {
  transform: rotate(180deg);
}

/* ── Bottom navigation ─────────────────────────────────────────────────────── */
/* Nav is in the flex column — NOT position:fixed. page-main scrolls above it.
   Safe-area padding handles the iPhone home indicator area below the nav.
   touch-action: none prevents swipes on the nav from rubber-banding the viewport. */
.bottom-nav {
  flex-shrink: 0;
  touch-action: none;
  height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  display: flex;
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--color-muted);
  font-size: 10px;
  gap: 2px;
  transition: color .15s;
}

.bottom-nav-item i { font-size: 22px; }

.bottom-nav-item.active {
  color: var(--color-primary);
}

/* Static active indicator — nav switching happens dozens of times a session,
   so it gets a marker, not an animation */
.bottom-nav-item {
  position: relative;
}
.bottom-nav-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 2px;
  border-radius: 0 0 2px 2px;
  background: var(--color-primary);
}

/* Hover only on devices that actually hover — tap shouldn't stick */
@media (hover: hover) and (pointer: fine) {
  .bottom-nav-item:hover {
    color: var(--color-primary);
  }
}

/* ── Cards ─────────────────────────────────────────────────────────────────── */
/* overflow:hidden clips children to border-radius so collapsed headers don't show square corners */
.card {
  overflow: hidden;
  background: var(--color-surface);
  border-color: var(--color-border);
  border-radius: var(--radius-lg);
}

.card-header {
  background: var(--color-surface2);
  border-bottom-color: var(--color-border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important;
}

/* ── Phase banner ──────────────────────────────────────────────────────────── */
.phase-banner {
  background: var(--color-surface2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
}

/* Progress check-in card hover (was an inline handler — dead under CSP) */
.checkin-card { transition: border-color .15s ease; }
@media (hover: hover) and (pointer: fine) {
  .checkin-card:hover { border-color: var(--color-primary); }
}

/* Home "Next up" hero — the one-tap door into the next workout */
.next-up-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 14px;
  transition: transform 160ms var(--ease-out), border-color .15s ease;
}
/* The card is a real submit button since the CSRF pass (POST /session/next) -
   reset button chrome so it renders exactly like the old anchor-card */
button.next-up-card {
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
}
.next-up-card:active { transform: scale(0.98); }
@media (hover: hover) and (pointer: fine) {
  .next-up-card:hover { border-color: var(--color-primary); }
}
@media (prefers-reduced-motion: reduce) {
  .next-up-card:active { transform: none; }
}

/* ── Week label badges ─────────────────────────────────────────────────────── */
/* Week labels are identity chips, not actions - neutral with a hairline */
.week-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--color-surface2);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.week-badge-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  background: var(--color-surface2);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  font-weight: 700;
  font-size: 11px;
  flex-shrink: 0;
}

/* ── Next workout card ─────────────────────────────────────────────────────── */
.next-workout-card {
  border: 1px solid var(--color-primary);
}

/* ── Exercise preview cards (plans, preview, session) ─────────────────────── */
.exercise-preview-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 8px 12px;
}

.target-weight {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--color-text); /* data, not an action - see the red doctrine above */
}

.overload-note {
  color: var(--color-success);
  font-size: 12px;
}

.tempo-note {
  font-size: 12px;
}

/* ── Active session exercise cards ─────────────────────────────────────────── */
.exercise-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color .2s;
}

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

.exercise-card-header {
  padding: 12px 14px 8px;
}

/* ── Logged set rows ────────────────────────────────────────────────────────── */
.logged-sets {
  padding-bottom: 4px;
}

.logged-set-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  border-top: 1px solid var(--color-border);
  font-size: 14px;
}

.set-num {
  color: var(--color-muted);
  min-width: 46px;
  font-size: 12px;
}

.set-val { flex-grow: 1; font-weight: 500; }

.rpe-badge {
  display: inline-block;
  background: var(--color-surface2);
  color: var(--color-warning);
  border-radius: var(--radius-sm);
  padding: 0 5px;
  font-size: 11px;
  margin-left: 4px;
}

/* Set note shown under a logged-set row (workout history detail) */
.set-note {
  font-size: 12px;
  color: var(--color-muted);
  padding: 2px 0 6px;
  line-height: 1.4;
}

/* ── Session history list ────────────────────────────────────────────────────── */
.sessions-list { display: flex; flex-direction: column; gap: 4px; }

.session-row {
  display: flex;
  align-items: center;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color .15s;
}

.session-row:hover { border-color: var(--color-primary); }

.session-row-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 1;
  padding: 8px 12px;
  text-decoration: none;
  color: var(--color-text);
  min-width: 0;
}

.session-row-left { display: flex; align-items: center; gap: 8px; }

.session-plan-name { font-weight: 500; }

/* ── Section labels ─────────────────────────────────────────────────────────── */
.section-label {
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: .8px;
  color: var(--color-muted);
  margin-bottom: 8px;
}

/* ── AI content rendering ───────────────────────────────────────────────────── */
.ai-content {
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
}

/* ── Large tap targets for buttons ─────────────────────────────────────────── */
/* inline-flex centering so label sits centered within the min-height (otherwise
   text aligns to the top of the 44/36px box and looks high/left). */
.btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
.btn-sm { min-height: 36px; }

/* ── Textareas: no internal scroll by default — the global autogrow in base.html
      expands them to fit content (and flips overflow-y back on inline when a
      max-height clamps growth, e.g. the chat input). No !important: the JS
      fallback must be able to win. overscroll-behavior stops iOS rubber-banding
      within the element, which caused a "wiggle" that blocked page scrolling. ── */
textarea {
  overflow-y: hidden;
  overscroll-behavior: contain;
  resize: none;
}

/* ── Form inputs: bigger on mobile ─────────────────────────────────────────── */
.form-control, .form-select {
  background: var(--color-surface2);
  border-color: var(--color-border);
  color: var(--color-text);
  border-radius: var(--radius-md);
  font-size: 16px !important; /* prevents iOS Safari auto-zoom on focus (triggers below 16px) */
}

.form-control::placeholder {
  color: #757575; /* readable on surface2 — #555 failed contrast */
  opacity: 1;     /* Firefox reduces opacity by default */
}

.form-control:focus, .form-select:focus {
  background: var(--color-surface2);
  border-color: var(--color-primary);
  color: var(--color-text);
  box-shadow: 0 0 0 2px rgba(224, 32, 32, .2);
}

/* ── Modal ──────────────────────────────────────────────────────────────────── */
.modal-content {
  background: var(--color-surface);
  border-color: var(--color-border);
  border-radius: var(--radius-lg);
}

.modal-header, .modal-footer {
  border-color: var(--color-border);
}

/* When a <form> wraps the body + footer inside a scrollable modal, the form
   (not the body) becomes the flex child of .modal-content, which breaks
   Bootstrap's scroll behavior — the form grows past the viewport and the
   footer/submit button gets clipped. Make the form a flex column that can
   shrink so the body scrolls and the footer stays pinned and reachable. */
.modal-dialog-scrollable .modal-content > form {
  display: flex;
  flex-direction: column;
  min-height: 0;       /* allow the form to shrink below content height */
  overflow: hidden;
}

/* ── Announcement body (plain-text mini-format renderer output) ─────────────── */
.announcement-body p { margin: 0 0 8px; }
.announcement-body p:last-child { margin-bottom: 0; }
.announcement-body ul { margin: 0 0 8px; padding-left: 20px; }
.announcement-body ul:last-child { margin-bottom: 0; }
.announcement-body li { margin-bottom: 3px; }
.announcement-body a { color: var(--color-primary); }

/* ── Utilities ──────────────────────────────────────────────────────────────── */
.font-monospace, code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ── Dashboard stat cards ───────────────────────────────────────────────────── */
.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 70px;
}
.stat-value {
  /* Number-hero: the number IS the interface (Iron Terminal slice 5b).
     Big, monospaced, tabular, white-hot on true black - data, not action. */
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums; /* columns of numbers align */
}
.stat-label {
  font-size: 10px;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: .8px;
  margin-top: 3px;
}

/* Numbers that sit in lists (weights, reps, dates) read better tabular too */
.set-val, .session-date, .target-weight {
  font-variant-numeric: tabular-nums;
}

/* Headings: subtle tracking + balanced wrapping (no orphan words on mobile) */
h4, h5, .modal-title {
  letter-spacing: -0.015em;
  text-wrap: balance;
}

/* ── How it works steps ─────────────────────────────────────────────────────── */
.how-step {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-border);
}
.how-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--color-surface2);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ── Goal selector (profile page) ──────────────────────────────────────────── */
.goal-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

.goal-option input[type="radio"] { margin-top: 3px; flex-shrink: 0; accent-color: var(--color-primary); }

.goal-option.selected {
  border-color: var(--color-primary);
  background: rgba(224, 32, 32, 0.08);
}

.goal-option-body { flex: 1; }

/* ── Workout management rows ─────────────────────────────────────────────────── */
.workout-manage-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 8px 10px 8px 12px;
  transition: border-color .15s;
}

.workout-manage-content {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  text-decoration: none;
  color: var(--color-text);
}

.workout-manage-content:hover { color: var(--color-text); }

/* Start-workout is a POST form since the CSRF pass - the form takes the anchor's
   place in the row flex layout, the button resets to plain text content */
.workout-start-form {
  display: flex;
  flex: 1;
  min-width: 0;
  margin: 0;
}
button.workout-manage-content {
  background: none;
  border: 0;
  padding: 0;
  text-align: left;
  font: inherit;
}

/* ── Coach conversation list ────────────────────────────────────────────────── */
.conversation-row {
  display: flex;
  align-items: center;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color .15s;
}

.conversation-row:hover { border-color: var(--color-primary); }

.conversation-row-content {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  flex: 1;
  padding: 8px 12px;
  text-decoration: none;
  color: var(--color-text);
  min-width: 0;
}

.conversation-row-content:hover { color: var(--color-text); }

.conv-row-left {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.conv-title {
  font-weight: 500;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.35;
}

.conv-time {
  white-space: nowrap;
  padding-top: 2px;
}

/* ── Chat bubbles ────────────────────────────────────────────────────────────── */
.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 8px;
}

.chat-bubble-user {
  background: var(--color-primary);
  color: #fff;
  border-radius: 18px 18px 4px 18px;
  padding: 10px 14px;
  max-width: 80%;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

.chat-bubble-assistant {
  background: var(--color-surface2);
  color: var(--color-text);
  border-radius: 18px 18px 18px 4px;
  padding: 10px 14px;
  max-width: 90%;
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Typing indicator dots ───────────────────────────────────────────────────── */
/* The indicator bubble is a flex box with a fixed comfortable height so the
   bouncing dots stay visually centered and have headroom for the bounce. */
.typing-bubble {
  display: flex;
  align-items: center;
  min-height: 36px;
  padding: 8px 14px;
}

.typing-dots {
  display: inline-flex;
  gap: 5px;
  align-items: center;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-muted);
  animation: typing-bounce .8s ease-in-out infinite;
}

.typing-dots span:nth-child(2) { animation-delay: .15s; }
.typing-dots span:nth-child(3) { animation-delay: .3s; }

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

/* ── Chat input (sticky at bottom of scroll container) ───────────────────────── */
.chat-input-area {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--color-bg);
  padding: 8px 14px;
  border-top: 1px solid var(--color-border);
}

/* ── Coach action cards ─────────────────────────────────────────────────────── */
/* A distinct OBJECT in the chat, not another bubble (slice 5c): flat panel,
   hairline border, an accent rail carrying the state (amber = awaiting your
   decision, green = applied), and a caption-strip header. The streaming
   session's "building proposal" indicator will render into this same shell. */
.action-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-warning);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-top: 8px;
  max-width: 90%;
  position: relative;
  flex-shrink: 0;
}

.action-card-applied {
  border-left-color: var(--color-success);
  opacity: .85;
}

.action-card-header {
  padding: 9px 14px 7px;
  background: var(--color-surface2);
  border-bottom: 1px solid var(--color-border);
  font-size: 14px;
}

.action-card-header strong {
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: .8px;
}

.action-card-body {
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.action-change-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  flex-wrap: wrap;
}

.action-change-row--col {
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.action-change-row-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.action-plan-tag {
  background: rgba(224, 32, 32, .15);
  color: var(--color-primary);
  border-radius: var(--radius-sm);
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}

.action-exercise {
  font-weight: 600;
  flex: 1;
}

.action-targets {
  font-size: 13px;
  color: var(--bs-body-color);
  padding-left: 2px;
}

.action-targets .action-set-line {
  display: block;
  color: var(--color-muted);
  font-size: 12px;
}

.action-before {
  color: var(--color-muted);
  margin-right: 2px;
}

.action-set-line.action-before {
  color: var(--color-muted);
}

.action-unchanged {
  color: var(--color-muted);
  opacity: 0.6;
}

.action-notes-label {
  color: var(--color-muted);
  font-style: italic;
}

/* Reorder badge — makes a position change read instantly on the action card */
.action-reorder {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 4px;
  padding: 2px 9px;
  border-radius: 11px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--color-primary);
  background: rgba(224, 32, 32, 0.12);
  border: 1px solid rgba(224, 32, 32, 0.30);
}
.action-reorder .reorder-from {
  color: var(--color-muted);
  font-weight: 500;
}

.action-after,
.action-targets .action-set-line.action-after,
.action-targets .action-set-line .action-after {
  color: var(--bs-body-color);
  font-weight: 600;
}

.action-card-footer {
  padding: 8px 14px;
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.action-notes-preview {
  font-size: 13px;
  color: var(--color-text);
  white-space: pre-wrap;
  max-height: 160px;
  overflow-y: auto;
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  line-height: 1.5;
}

.action-card-warnings {
  font-size: 12px;
  color: var(--color-warning);
  margin-top: 4px;
}

/* ── App toast (bottom notification, e.g. network errors) ───────────────────── */
.app-toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom) + 16px);
  transform: translateX(-50%) translateY(8px);
  background: var(--color-surface2);
  color: var(--color-text);
  border: 1px solid var(--color-danger);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  font-size: 13px;
  z-index: 10000;
  opacity: 0;
  transition: opacity .25s var(--ease-out), transform .25s var(--ease-out);
  max-width: 90vw;
  text-align: center;
}

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

/* ── Page loading overlay ───────────────────────────────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-overlay.loading-hidden { display: none; }

.loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.loading-logo {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -.3px;
  color: var(--color-text);
}

.loading-dots {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.loading-dots span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--color-primary);
  animation: dot-bounce 0.7s ease-in-out infinite;
}

.loading-dots span:nth-child(2) { animation-delay: -0.55s; }
.loading-dots span:nth-child(3) { animation-delay: -0.40s; }

@keyframes dot-bounce {
  0%, 60%, 100% { transform: translateY(0);   opacity: 0.4; }
  30%           { transform: translateY(-9px); opacity: 1;   }
}



/* ── Exercise-history bottom sheet ─────────────────────────────────────────── */
/* The exercise name on session cards is the tap target - styled as the plain
   heading it replaces, with a small history icon as the affordance. */
.ex-history-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--color-text);
  text-align: left;
  font-weight: 600;
}
.ex-history-btn .bi-clock-history {
  font-size: 12px;
  color: var(--color-muted);
  margin-left: 6px;
}

.ex-history-sheet {
  height: auto;
  max-height: 70vh;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.ex-history-group {
  padding: 8px 0 10px;
  border-top: 1px solid var(--color-border);
}
.ex-history-group:first-child { border-top: none; padding-top: 0; }

.ex-history-set {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 3px 0;
  font-size: 14px;
}
.ex-history-note {
  flex-basis: 100%;
  font-size: 11px;
  padding-left: 56px; /* aligns under set-val (set-num min-width + gap) */
}

/* ── Rest timer bar ────────────────────────────────────────────────────────── */
/* Fixed just above the bottom nav; slides in when a set is logged. Sits under
   modals and offcanvas sheets (Bootstrap ~1045+) so it never blocks them. */
.rest-timer {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom) + 12px);
  z-index: 1030;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--color-surface2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity .18s var(--ease-out), transform .18s var(--ease-out);
}
.rest-timer-show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.rest-timer-info { flex-grow: 1; min-width: 0; }
.rest-timer-caption {
  font-size: 11px;
  color: var(--color-muted);
  letter-spacing: .4px;
  text-transform: uppercase;
}
.rest-timer-label {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rest-timer-time {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 22px;
  font-weight: 700;
  min-width: 58px;
  text-align: right;
}

/* Done state: live-state color on the number, caption flips to Rest complete */
.rest-timer-done .rest-timer-time    { color: var(--color-success); }
.rest-timer-done .rest-timer-caption { color: var(--color-success); }

@media (prefers-reduced-motion: reduce) {
  .rest-timer { transition: opacity .15s ease; transform: none; }
}

/* ── Coach strip (Home) ────────────────────────────────────────────────────── */
/* The coach's presence on the dashboard: latest insight, tap-through to its
   source. Same strip language as the diet phase banner - flat, hairlined. */
.coach-strip {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  transition: transform 160ms var(--ease-out), border-color .15s ease;
}
.coach-strip:active { transform: scale(0.985); }
@media (hover: hover) and (pointer: fine) {
  .coach-strip:hover { border-color: var(--color-primary); }
}
@media (prefers-reduced-motion: reduce) {
  .coach-strip:active { transform: none; }
}

.coach-strip-caption {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--color-muted);
  font-weight: 600;
}

.coach-strip-text {
  color: var(--color-text);
  font-size: 13px;
  line-height: 1.45;
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
