/* ═══════════════════════════════════════════════════════════════
   Sandbox Fitness — Gym-Mode Workout CSS
   Mobile-first. High contrast. No accidental zoom. Capacitor-ready.
   Depends on: DM Sans (Google Fonts or bundled)
   ═══════════════════════════════════════════════════════════════ */

/* ── Viewport lock — prevents double-tap zoom on all interactive elements ── */
/* Add this meta to every HTML file:
   <meta name="viewport" content="width=device-width, initial-scale=1.0,
         maximum-scale=1.0, user-scalable=no">                            */

/* ── CSS Custom Properties ── */
:root {
  /* Backgrounds */
  --bg:     #000000;
  --s1:     #000000;   /* card bg */
  --s2:     #111111;   /* elevated surface / active row */
  --s3:     #111111;   /* input bg */

  /* Brand */
  --gold:     #F5C842;
  --gold-dk:  #C9A84C;
  --g-light:  #7ecb47;
  --g-mid:    #4a9c1f;

  /* Text */
  --text:  #ffffff;
  --text2: #ffffff;
  --text3: #ffffff;

  /* Borders */
  --border:  #888888;
  --border2: #888888;

  /* Semantic */
  --danger: #e74c3c;

  /* Radii */
  --r:   14px;
  --rsm: 10px;
}

/* ═══════════════════════════════════════════════════════════════
   GLOBAL RESET & BODY
   ═══════════════════════════════════════════════════════════════ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  /* Prevent text-size inflation in landscape on iOS */
  -webkit-text-size-adjust: 100%;
}

html {
  /* Prevent font scaling in accessibility settings from breaking layout */
  font-size: 16px;
  /* Smooth scrolling on iOS */
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

body {
  background: var(--bg);
  color: var(--text);
  /* DM Sans only — loaded via Google Fonts in HTML head */
  font-family: 'DM Sans', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  /* Prevent overscroll bounce revealing background on Capacitor */
  overscroll-behavior: none;
  /* Reserve space for bottom nav */
  padding-bottom: 90px;
}

/* Prevent tap highlight flicker on all interactive elements */
a, button, [role="button"], input, select, textarea,
.ni, .exrow, .week-nav-btn, .back-btn, .cta {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* ═══════════════════════════════════════════════════════════════
   TOP BAR
   ═══════════════════════════════════════════════════════════════ */
.workout-header {
  background: var(--s1);
  border-bottom: 1px solid var(--border);
  padding: 14px 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 100;
  /* Capacitor safe area */
  padding-top: max(14px, env(safe-area-inset-top));
}

/* Back button — 44px min tap target (Apple HIG / WCAG 2.5.5) */
.back-btn {
  background: var(--s2);
  border: 1px solid var(--border2);
  color: var(--text2);
  font-size: 22px;
  font-family: inherit;
  width: 44px;
  height: 44px;
  border-radius: var(--rsm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .1s;
}
.back-btn:active { background: var(--border2); }

#workout-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
  flex: 1;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Pill badge cluster in header */
#workout-pill {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════
   SCROLL CONTAINER
   ═══════════════════════════════════════════════════════════════ */
#workout-scroll {
  padding: 14px 14px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  /* Momentum scrolling on iOS */
  -webkit-overflow-scrolling: touch;
}

/* ═══════════════════════════════════════════════════════════════
   PILLS
   ═══════════════════════════════════════════════════════════════ */
.pill {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid transparent;
  line-height: 1;
}

.pg    { background: rgba(74,156,31,.15);   color: var(--g-light);  border-color: rgba(74,156,31,.3); }
.pgold { background: rgba(245,200,66,.12);  color: var(--gold);     border-color: rgba(245,200,66,.25); }
.pgray { background: var(--s2);             color: var(--text3);    border-color: var(--border); }
.pdone { background: rgba(74,156,31,.2);    color: var(--g-light);  border-color: rgba(74,156,31,.35); }

/* ═══════════════════════════════════════════════════════════════
   SECTION CARD & HEADER
   ═══════════════════════════════════════════════════════════════ */
.card {
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}

.sechdr {
  padding: 11px 16px 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 9px;
}

.sec-lbl {
  font-size: 11px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .08em;
}

/* ═══════════════════════════════════════════════════════════════
   EXERCISE ROW
   — Tappable area is full width, min 60px tall.
   — Avoids the common trap of a 24px icon being the only tap target.
   ═══════════════════════════════════════════════════════════════ */
.exrow {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  /* Minimum 60px so even short exercise names are easy to hit */
  min-height: 60px;
  transition: background .12s;
}
.exrow:last-child { border-bottom: none; }
.exrow:active { background: var(--s2); }

/* Active / expanded state */
.exrow.ex-open {
  background: var(--s2);
}

.exinfo {
  flex: 1;
  min-width: 0; /* prevent text overflow breaking flex */
}

.exname {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  line-height: 1.25;
}

.exdet {
  font-size: 12px;
  color: var(--text3);
  letter-spacing: .02em;
  line-height: 1.4;
}

/* Target weight column */
.extgt {
  flex-shrink: 0;
  text-align: right;
  align-self: flex-start;
}

.exwt {
  font-size: 16px;
  font-weight: 700;
  color: var(--gold);
  line-height: 1.15;
}

/* Tappable quick-fill target weight */
.exwt-tap {
  cursor: pointer;
  padding: 4px 8px;
  margin: -4px -8px;
  border-radius: 6px;
  transition: background .1s;
}
.exwt-tap:active { background: rgba(245,200,66,.12); }

.extl {
  font-size: 10px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-top: 2px;
}

/* ═══════════════════════════════════════════════════════════════
   EXPANDED EXERCISE LOG PANEL
   ═══════════════════════════════════════════════════════════════ */
.exrow-expanded {
  background: var(--s3);
  border-top: 1px solid var(--border);
  padding: 14px 16px 18px;
  border-bottom: 1px solid var(--border);
}
.exrow-expanded:last-child { border-bottom: none; }

/* Coach note in expanded panel */
.ex-coach-note {
  font-size: 13px;
  color: var(--text2);
  font-style: italic;
  margin-bottom: 12px;
  line-height: 1.55;
  padding: 10px 12px;
  background: rgba(245,200,66,.06);
  border-left: 2px solid var(--gold-dk);
  border-radius: 0 6px 6px 0;
}

/* ── Log weights header row ── */
.logwt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.logwt-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .06em;
}

/* ── lbs / kg unit toggle ──
   Two buttons, full pill shape.
   Min 44px height for fat-finger safety.              */
.unit-toggle {
  display: flex;
  background: var(--s1);
  border: 1px solid var(--border2);
  border-radius: 8px;
  overflow: hidden;
  height: 34px;
}

.unit-toggle button {
  font-size: 12px;
  font-weight: 700;
  padding: 0 16px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text3);
  font-family: inherit;
  letter-spacing: .04em;
  touch-action: manipulation;
  transition: background .12s, color .12s;
}
.unit-toggle button.active {
  background: var(--s2);
  color: var(--gold);
}
.unit-toggle button:active { opacity: .75; }

/* ── Set inputs ──
   64px wide × 52px tall = comfortable one-thumb entry.
   Font size 18px to reduce squinting under gym lighting. */
.set-inp {
  width: 64px;
  height: 52px;
  background: var(--s1);
  border: 1.5px solid var(--border2);
  border-radius: var(--rsm);
  color: var(--text);
  font-family: inherit;
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  outline: none;
  padding: 0;
  /* Suppress native spinners & zoom (inputmode="decimal" handles mobile keyboard) */
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
  transition: border-color .15s;
}
.set-inp:focus { border-color: var(--gold); }
.set-inp::placeholder {
  color: var(--text3);
  font-size: 14px;
  font-weight: 400;
}

/* ── Set label above each input ── */
.set-inp-label {
  font-size: 10px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .06em;
  text-align: center;
  margin-bottom: 4px;
}

/* ── Hint line below set row ── */
.log-hint {
  font-size: 11px;
  color: var(--text3);
  margin-top: 10px;
  line-height: 1.5;
}

/* Target callout (% 1RM, RPE, etc.) */
.ex-target-note {
  font-size: 12px;
  color: var(--text3);
  margin-bottom: 10px;
}

/* ═══════════════════════════════════════════════════════════════
   CHECKBOX EXERCISES (SMR, Stretch, Bodyweight, Band)
   44×44 touch target — critical for gloved or sweaty hands.
   ═══════════════════════════════════════════════════════════════ */
.ex-check-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 6px 0;
}

.chk-box {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 2px solid var(--border2);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .18s, border-color .18s;
}
.chk-box.checked {
  background: var(--g-mid);
  border-color: var(--g-mid);
}
.chk-box:active { opacity: .75; }

.chk-label {
  font-size: 15px;
  color: var(--text2);
}

/* Small inline checkbox (right column of exrow) */
.chk-box-sm {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 2px solid var(--border2);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  transition: background .18s, border-color .18s;
}
.chk-box-sm.checked {
  background: var(--g-mid);
  border-color: var(--g-mid);
}

/* ═══════════════════════════════════════════════════════════════
   SESSION NOTES & ENERGY CARD
   ═══════════════════════════════════════════════════════════════ */
.notes-card {
  padding: 16px;
}

.notes-section-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 14px;
}

.energy-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.energy-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

/* Energy input — same generous size as set inputs */
#energy-score {
  width: 64px;
  height: 52px;
  background: var(--s3);
  border: 1.5px solid var(--border2);
  border-radius: var(--rsm);
  color: var(--text);
  font-family: inherit;
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
  flex-shrink: 0;
}
#energy-score:focus { border-color: var(--gold); }

.notes-label-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  display: block;
  margin-bottom: 8px;
}

#session-notes {
  background: var(--s3);
  border: 1.5px solid var(--border2);
  border-radius: var(--rsm);
  padding: 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.55;
  width: 100%;
  outline: none;
  resize: none;
  touch-action: manipulation;
  /* min-height prevents the textarea from being too tiny to tap into */
  min-height: 100px;
}
#session-notes:focus { border-color: var(--gold); }
#session-notes::placeholder { color: var(--text3); }

/* ═══════════════════════════════════════════════════════════════
   PRIMARY CTA — LOG WORKOUT
   Full width, 56px tall, high-contrast gold on near-black.
   Ratio: #F5C842 on #0d0d0d = 8.4:1 (WCAG AAA).
   ═══════════════════════════════════════════════════════════════ */
.cta {
  display: block;
  width: 100%;
  background: var(--gold);
  color: #0d0d0d;
  font-family: inherit;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 18px 24px;
  border: none;
  border-radius: var(--r);
  cursor: pointer;
  text-align: center;
  line-height: 1;
  touch-action: manipulation;
  transition: opacity .12s, transform .1s;
  /* iOS button reset */
  -webkit-appearance: none;
  appearance: none;
}
.cta:active {
  opacity: .85;
  transform: scale(.98);
}
.cta:disabled {
  opacity: .45;
  cursor: not-allowed;
  transform: none;
}

/* Secondary ghost CTA (e.g. Skip session) */
.cta-ghost {
  display: block;
  width: 100%;
  background: transparent;
  color: var(--text2);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 15px 24px;
  border: 1.5px solid var(--border2);
  border-radius: var(--r);
  cursor: pointer;
  text-align: center;
  touch-action: manipulation;
  transition: background .12s, border-color .12s;
  -webkit-appearance: none;
  appearance: none;
}
.cta-ghost:active { background: var(--s2); }

/* ═══════════════════════════════════════════════════════════════
   BOTTOM NAV
   88px total: icon area + label + Capacitor safe-area inset.
   ═══════════════════════════════════════════════════════════════ */
.app-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--s1);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  align-items: flex-start;
  padding: 10px 0;
  /* Capacitor home indicator safe area */
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 200;
  /* Blur behind nav for depth without GPU-expensive shadows */
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* Each nav item: min 64px wide tap zone */
.ni {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 12px;
  border-radius: var(--rsm);
  cursor: pointer;
  min-width: 64px;
  min-height: 48px;
  touch-action: manipulation;
  transition: background .1s;
}
.ni.active-ni { background: rgba(245,200,66,.1); }
.ni:active     { background: var(--s2); }

.ni-icon {
  font-size: 24px;
  line-height: 1;
}

.nl {
  font-size: 10px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .05em;
  line-height: 1;
}
.nl.active { color: var(--gold); }

/* ═══════════════════════════════════════════════════════════════
   WEEK COMPLETE CARD
   ═══════════════════════════════════════════════════════════════ */
.week-complete-card {
  background: var(--s2);
  border: 1px solid var(--border2);
  border-radius: var(--r);
  padding: 20px 18px;
  text-align: center;
  position: relative;
}
.week-complete-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}
.week-complete-sub {
  font-size: 14px;
  color: var(--text2);
  line-height: 1.55;
  margin-bottom: 18px;
}

/* ═══════════════════════════════════════════════════════════════
   SKIP MODAL
   ═══════════════════════════════════════════════════════════════ */
#skip-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.72);
  display: flex;
  align-items: flex-end;
  z-index: 600;
  padding-bottom: env(safe-area-inset-bottom);
}

.skip-sheet {
  background: var(--s1);
  border-radius: 20px 20px 0 0;
  padding: 20px 18px 28px;
  width: 100%;
  border-top: 1px solid var(--border2);
}

.skip-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.skip-sub {
  font-size: 14px;
  color: var(--text2);
  line-height: 1.55;
  margin-bottom: 20px;
}

/* ═══════════════════════════════════════════════════════════════
   TOAST
   ═══════════════════════════════════════════════════════════════ */
#toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--s2);
  border: 1px solid var(--border2);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  padding: 11px 20px;
  border-radius: 24px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
  z-index: 500;
  max-width: 90vw;
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ═══════════════════════════════════════════════════════════════
   SPLASH
   ═══════════════════════════════════════════════════════════════ */
#splash {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  z-index: 9999;
  transition: opacity .5s ease;
}

/* ═══════════════════════════════════════════════════════════════
   UTILITY CLASSES
   ═══════════════════════════════════════════════════════════════ */

/* 80px spacer at bottom of scroll areas to clear nav */
.nav-spacer { height: 80px; }

/* Prevents keyboard from obscuring inputs on scroll */
.scroll-container {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

/* Loading skeleton */
.loading-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text3);
  font-size: 14px;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 20px;
}
.empty-state p {
  font-size: 16px;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 8px;
}
.empty-state small {
  font-size: 14px;
  color: var(--text3);
  line-height: 1.5;
}

/* ═══════════════════════════════════════════════════════════════
   WEEK CALENDAR (Dash)
   ═══════════════════════════════════════════════════════════════ */
.wcal {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-top: 8px;
}

.wday {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 2px;
  border-radius: var(--rsm);
  cursor: pointer;
  background: var(--s2);
  border: 1px solid var(--border);
  min-height: 56px;
  touch-action: manipulation;
  transition: background .1s;
}
.wday:active { background: var(--border2); }
.wday.today  {
  background: rgba(197,168,76,.1);
  border-color: rgba(197,168,76,.3);
}
.wday.selected {
  background: rgba(245,200,66,.15);
  border-color: var(--gold-dk);
}

.wday-letter { font-size: 9px;  color: var(--text3); }
.wday-num    { font-size: 14px; font-weight: 700; color: var(--text); }
.wday.today .wday-num  { color: var(--gold); }
.wday.selected .wday-num { color: var(--gold); }

/* ═══════════════════════════════════════════════════════════════
   WEEK NAV ARROWS
   ═══════════════════════════════════════════════════════════════ */
.week-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.week-nav-btn {
  width: 40px;
  height: 40px;
  background: var(--s2);
  border: 1px solid var(--border2);
  border-radius: var(--rsm);
  color: var(--text2);
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  touch-action: manipulation;
  font-family: inherit;
  transition: background .1s;
}
.week-nav-btn:active  { background: var(--border2); }
.week-nav-btn:disabled { opacity: .3; cursor: not-allowed; }
.week-nav-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
}

/* ═══════════════════════════════════════════════════════════════
   METRIC CARDS (dash grid)
   ═══════════════════════════════════════════════════════════════ */
.mgrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.mc {
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px 14px;
}
.mlbl {
  font-size: 11px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 6px;
}
.mval {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  margin-bottom: 4px;
}
.mgold { color: var(--gold); }
.msub  { font-size: 11px; color: var(--text3); }

/* Progress bar */
.track {
  background: var(--s3);
  border-radius: 4px;
  height: 5px;
  overflow: hidden;
}
.fg {
  background: var(--gold);
  height: 100%;
  border-radius: 4px;
  transition: width .4s ease;
  min-width: 4px;
}

/* ═══════════════════════════════════════════════════════════════
   COACH MESSAGE CARD
   ═══════════════════════════════════════════════════════════════ */
.coach {
  background: var(--s1);
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold-dk);
  border-radius: 0 var(--r) var(--r) 0;
  padding: 16px 16px 14px;
  position: relative;
}
.coach-lbl  { font-size: 11px; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 7px; }
.coach-msg  { font-size: 14px; color: var(--text); line-height: 1.6; margin-bottom: 8px; }
.coach-time { font-size: 11px; color: var(--text3); }

/* ═══════════════════════════════════════════════════════════════
   FORMS — LOGIN / SIGNUP
   ═══════════════════════════════════════════════════════════════ */
.form-input {
  width: 100%;
  background: var(--s3);
  border: 1.5px solid var(--border2);
  border-radius: var(--rsm);
  padding: 15px 14px;
  color: var(--text);
  font-family: inherit;
  font-size: 16px;  /* 16px minimum prevents iOS auto-zoom on focus */
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
  transition: border-color .15s;
}
.form-input:focus { border-color: var(--gold); }
.form-input::placeholder { color: var(--text3); }

/* ═══════════════════════════════════════════════════════════════
   PREVIEW MODAL
   ═══════════════════════════════════════════════════════════════ */
#preview-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.72);
  display: flex;
  align-items: flex-end;
  z-index: 400;
}

.preview-sheet {
  background: var(--s1);
  border-radius: 20px 20px 0 0;
  border-top: 1px solid var(--border2);
  padding: 20px 18px;
  padding-bottom: max(24px, env(safe-area-inset-bottom));
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ═══════════════════════════════════════════════════════════════
   CAPACITOR SAFE AREAS
   Ensure nothing is hidden behind the home indicator (iPhone)
   or the status bar (Android).
   ═══════════════════════════════════════════════════════════════ */
.view-app {
  padding-top: env(safe-area-inset-top);
}

/* ═══════════════════════════════════════════════════════════════
   INPUT ZOOM PREVENTION
   All inputs must be font-size ≥ 16px to prevent iOS auto-zoom.
   The rules below are a safety net catch-all.
   ═══════════════════════════════════════════════════════════════ */
input, textarea, select {
  font-size: max(16px, 1rem);
  font-family: inherit;
}

/* Custom workout library dropdown */
.cw-lib-item {
  padding: 11px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  touch-action: manipulation;
}
.cw-lib-item:active { background: var(--s2); }

/* ═══════════════════════════════════════════════════════════════
   PRINT / DESKTOP OVERRIDE
   Sidebar layout for tablets (landscape) while keeping
   touch targets mobile-sized.
   ═══════════════════════════════════════════════════════════════ */
@media (min-width: 600px) {
  body { max-width: 420px; margin: 0 auto; }
  .app-nav { max-width: 420px; left: 50%; transform: translateX(-50%); }
  #toast { bottom: 110px; }
}

/* ═══════════════════════════════════════════════════════════════
   EXERCISE CARD FIX — append to end of gym-workout.css
   Restores expand/collapse + mobile readability without
   undoing the compliance pass (44px targets, safe areas, etc.)
   ═══════════════════════════════════════════════════════════════ */

/* 1. Let the card grow with expanded content.
      overflow:hidden was clipping .exrow-expanded on iOS Safari. */
.card {
  overflow: visible;
}
/* Keep rounded corners clean on the OUTER edges only */
.card > :first-child { border-top-left-radius: var(--r); border-top-right-radius: var(--r); }
.card > :last-child  { border-bottom-left-radius: var(--r); border-bottom-right-radius: var(--r); }

/* 2. Make .exrow a reliable tap target.
      user-select:none stops iOS long-press from eating the click.
      width:100% guarantees the flex container fills the card. */
.exrow {
  width: 100%;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  position: relative;
  /* Keep compliance min-height but ensure content can breathe */
  min-height: 60px;
  padding: 14px 16px;
}

/* 3. Restore readable text hierarchy that * { margin:0 } flattened */
.exrow .exname {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 4px;
  color: var(--text);
  /* Allow wrap on long CES cues like "Self-Myofascial Release: Gastroc/Soleus" */
  word-break: break-word;
}
.exrow .exdet {
  font-size: 13px;       /* bumped from 12px — 12px is below WCAG comfort on small devices */
  line-height: 1.45;
  color: var(--text2);   /* was --text3 (#666) — failing contrast on --s1 bg */
  letter-spacing: 0;
}

/* 4. Expand/collapse — CSS-driven so JS only toggles .ex-open.
      Default: collapsed. When parent .exrow has .ex-open, the
      SIBLING .exrow-expanded shows. */
.exrow-expanded {
  display: none;
  background: var(--s2);
  border-top: 1px solid var(--border);
  padding: 14px 16px 18px;
  animation: ex-slide-down .18s ease-out;
}
.exrow.ex-open + .exrow-expanded {
  display: block;
}

/* Fallback for JS that toggles inline style.display="block" */
.exrow-expanded[style*="block"] {
  display: block !important;
}

@keyframes ex-slide-down {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* 5. Visual affordance — the row is tappable, show it */
.exrow::after {
  content: '';
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--text3);
  border-bottom: 2px solid var(--text3);
  transform: rotate(45deg);
  align-self: center;
  flex-shrink: 0;
  transition: transform .18s ease;
  margin-left: 4px;
}
.exrow.ex-open::after {
  transform: rotate(-135deg);
  border-color: var(--gold);
}

/* 6. Open-state background — make it obvious which card is active */
.exrow.ex-open {
  background: var(--s2);
  border-bottom-color: transparent;
}

/* 7. Target weight column stays tidy when name wraps */
.exrow .extgt {
  align-self: center;
  min-width: 64px;
}

/* 8. Narrow phones (≤360px — iPhone SE 1st gen, small Androids) */
@media (max-width: 360px) {
  .exrow { padding: 12px 12px; gap: 8px; }
  .exrow .exname { font-size: 15px; }
  .exrow .exdet  { font-size: 12.5px; }
  .exrow .exwt   { font-size: 15px; }
  .exrow-expanded { padding: 12px 12px 16px; }
}

/* ─── END gym-workout.css ─── */