/* ============================================================
   GYMTRACK DESIGN SYSTEM — Emerald Glassmorphism
   ============================================================
   Reusable tokens + components, applied identically across every
   screen (Plan, Workout, Library, History, Stats, Profile).

   SEMANTIC ICON COLOR MAP (reused everywhere, never redefined per-screen):
     --c-activity  #7FB08A  (green)  → movement / strength training / "good" status
     --c-sleep     #8C8FE0  (indigo) → rest & recovery timers (same concept as sleep: downtime)
     --c-hydration #5CA9E0  (blue)   → reserved for future hydration/recovery metrics
     --c-energy    #E29B4A  (amber)  → progress bars, ratings, "getting close" warnings

   NEW CATEGORY — documented per instructions, since it doesn't exist
   in the reference dashboard:
     --c-cardio    #E0725C  (coral)  → cardio / conditioning / Hyrox exercises,
                                        and timer-overtime alerts (same "high effort"
                                        concept as cardio, reused rather than adding
                                        a third new hue)
   ============================================================ */

:root {
  /* Core surface */
  --bg: #0a0b09;
  --bg-glow: radial-gradient(circle at 25% 15%, #4E7A5C, #0a0b09 65%);

  /* Accent — overridden per theme (see THEME PALETTES below); --accent-ink is
     the text/icon color that sits correctly on top of a solid --accent fill
     (light ink for dark accents, dark ink for pale/light accents). */
  --accent: #4E7A5C;
  --accent-ink: #eef2ec;

  /* Text */
  --text: #eef2ec;
  --text-muted: #a9b0a4;
  --text-on-glow: #c8d3ca;

  /* Glass panel */
  --glass-fill: rgba(255,255,255,0.06);
  --glass-fill-2: rgba(255,255,255,0.07);
  --glass-border: rgba(255,255,255,0.14);
  --glass-border-2: rgba(255,255,255,0.16);

  /* Semantic icon / status colors */
  --c-activity: #7FB08A;
  --c-sleep: #8C8FE0;
  --c-hydration: #5CA9E0;
  --c-energy: #E29B4A;
  --c-cardio: #E0725C;

  /* Radii */
  --r-sm: 16px;
  --r-lg: 20px;
  --r-pill: 100px;

  /* Shadows — hierarchy: hero (strong) > card (medium) > button (light) */
  --shadow-hero: 0 24px 60px -12px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.06);
  --shadow-card: 0 12px 32px -10px rgba(0,0,0,0.5);
  --shadow-btn: 0 6px 16px -4px rgba(0,0,0,0.4);

  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
}

/* ============================================================
   THEME PALETTES — user-selectable accent color, applied via a
   body class (see Settings screen). Each keeps the same radial-
   gradient glow treatment as the default green, just re-hued.
   ============================================================ */
body.theme-green   { --accent: #4E7A5C; --accent-ink: #eef2ec; --bg-glow: radial-gradient(circle at 25% 15%, #4E7A5C, #0a0b09 65%); }
body.theme-black    { --accent: #d9dbd7; --accent-ink: #14120e; --bg-glow: radial-gradient(circle at 25% 15%, #6b6d69, #0a0b09 65%); }
body.theme-gray      { --accent: #9098a0; --accent-ink: #14120e; --bg-glow: radial-gradient(circle at 25% 15%, #6b7178, #0a0b09 65%); }
body.theme-orange   { --accent: #e2954a; --accent-ink: #1c1408; --bg-glow: radial-gradient(circle at 25% 15%, #e2954a, #0a0b09 65%); }
body.theme-blue-light { --accent: #6fb8e6; --accent-ink: #0a1a24; --bg-glow: radial-gradient(circle at 25% 15%, #4a86ab, #0a0b09 65%); }
body.theme-blue-dark  { --accent: #3a5f8a; --accent-ink: #eef2ec; --bg-glow: radial-gradient(circle at 25% 15%, #3a5f8a, #0a0b09 65%); }
body.theme-violet-dark  { --accent: #5b4b8a; --accent-ink: #eef2ec; --bg-glow: radial-gradient(circle at 25% 15%, #5b4b8a, #0a0b09 65%); }
body.theme-violet-light { --accent: #b39ddb; --accent-ink: #1e1730; --bg-glow: radial-gradient(circle at 25% 15%, #8a72b3, #0a0b09 65%); }
body.theme-red-light  { --accent: #e2776a; --accent-ink: #240d09; --bg-glow: radial-gradient(circle at 25% 15%, #e2776a, #0a0b09 65%); }

/* Small swatch used in the theme picker itself */
.theme-swatch {
  width: 44px; height: 44px; border-radius: 14px; flex-shrink: 0; position: relative;
  border: 2px solid transparent; transition: border-color 0.15s, transform 0.15s;
}
.theme-swatch.selected { border-color: var(--text); transform: scale(1.06); }
.theme-swatch-check { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 900; opacity: 0; }
.theme-swatch.selected .theme-swatch-check { opacity: 1; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); height: 100%; }
/* Guaranteed minimum — never relies solely on the JS measurement. max() takes
   whichever is bigger, so this is a hard floor that cannot be undercut even if
   the live measurement is ever wrong, stale, or hasn't run yet. */
body { padding-bottom: max(180px, var(--nav-clearance, 180px)); }
button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; }
::-webkit-scrollbar { display: none; }

#app { max-width: 560px; margin: 0 auto; min-height: 100vh; position: relative; }

/* ============ TYPOGRAPHY ============ */
.headline, h1, .card h3 {
  text-transform: uppercase; letter-spacing: 0.6px; font-weight: 500;
  font-size: 20px; margin: 0; color: var(--text);
}
.card h3 { font-size: 15px; letter-spacing: 0.5px; margin-bottom: 10px; }
.stat-number { font-size: 28px; font-weight: 500; letter-spacing: -0.2px; color: var(--text); }
.label-sm, label.field, .section-title {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1px; font-weight: 600; color: var(--text-muted);
}

/* ============ LAYOUT ============ */
/* Single sticky container holding header + (when active) the pause/finish row.
   Sticking the whole block as one unit — rather than floating a separate fixed
   bar over the scrollable content below — means it reserves its own space in
   normal flow and can never overlap page content, at any scroll position. */
.sticky-top {
  position: sticky; top: 0; z-index: 15; background: var(--bg);
}
header.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 20px 14px; z-index: 10;
}
header.topbar .brand { display: flex; align-items: center; gap: 12px; }
.logo-img {
  width: 38px; height: 38px; border-radius: var(--r-sm); object-fit: cover;
  box-shadow: var(--shadow-btn);
}
header.topbar h1 { font-size: 15px; letter-spacing: 0.8px; }
header.topbar .sub { font-size: 11px; color: var(--text-muted); margin-top: 3px; text-transform: none; letter-spacing: 0; font-weight: 500; }
.icon-btn {
  width: 38px; height: 38px; border-radius: var(--r-sm);
  background: var(--glass-fill); border: 0.5px solid var(--glass-border);
  backdrop-filter: blur(14px);
  color: var(--text); font-size: 15px;
  display: flex; align-items: center; justify-content: center; transition: border-color 0.15s;
}
.icon-btn:active { border-color: var(--accent); }

nav.tabbar {
  position: fixed; bottom: calc(16px + var(--kb-offset, 0px) + env(safe-area-inset-bottom, 0px)); left: 14px; right: 14px; max-width: 532px; margin: 0 auto;
  display: flex; background: rgba(255,255,255,0.05); backdrop-filter: blur(16px) saturate(1.2);
  border: 0.5px solid var(--glass-border); border-radius: var(--r-lg); z-index: 20; padding: 6px;
  box-shadow: var(--shadow-card);
}
nav.tabbar button {
  flex: 1; background: none; border: none; color: var(--text-muted); padding: 9px 4px 7px;
  display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 9.5px;
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; border-radius: 13px; transition: all 0.2s; position: relative;
}
nav.tabbar button.active { color: var(--text); background: var(--glass-fill-2); }
nav.tabbar .icon { font-size: 17px; filter: grayscale(1); opacity: 0.55; transition: all 0.2s; }
nav.tabbar button.active .icon { filter: grayscale(0); opacity: 1; }
nav.tabbar button.active::before {
  content: ''; position: absolute; top: 1px; left: 50%; transform: translateX(-50%);
  width: 4px; height: 4px; border-radius: 50%; background: var(--c-activity);
}

.screen { padding: 8px 18px 40px; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.hidden { display: none !important; }

/* ============ GLASS PANEL / CARD ============ */
.glass-panel, .card {
  background: var(--glass-fill); border: 0.5px solid var(--glass-border);
  backdrop-filter: blur(16px); border-radius: var(--r-lg);
  padding: 18px 18px; margin-bottom: 14px; box-shadow: var(--shadow-card);
}
.card .meta { font-size: 12.5px; color: var(--text-muted); line-height: 1.55; text-transform: none; letter-spacing: 0; }

/* Hero card — behind it sits the radial emerald glow, stronger shadow */
.hero-card {
  border: 0.5px solid var(--glass-border-2);
  box-shadow: var(--shadow-hero);
}
.hero-card .meta { color: var(--text-on-glow); }

/* ============ STAT TILE ============ */
.stat-box {
  background: var(--glass-fill); border: 0.5px solid var(--glass-border); backdrop-filter: blur(14px);
  border-radius: var(--r-lg); padding: 18px 14px; text-align: center; box-shadow: var(--shadow-card);
}
.stat-box .num { font-size: 28px; font-weight: 500; color: var(--text); letter-spacing: -0.2px; }
.stat-box .label { font-size: 10px; color: var(--text-muted); margin-top: 4px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; }

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--glass-fill); border: 0.5px solid var(--glass-border); color: var(--text);
  border-radius: var(--r-sm); padding: 13px 18px; font-size: 13.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px;
  backdrop-filter: blur(14px);
  transition: transform 0.12s, opacity 0.12s, border-color 0.15s; box-shadow: var(--shadow-btn);
}
.btn:active { transform: scale(0.97); }
/* Primary = pill shape per design system spec */
.btn.primary { background: var(--accent); border: none; color: var(--accent-ink); border-radius: var(--r-pill); box-shadow: var(--shadow-btn); }
.btn.ghost { background: transparent; border-color: var(--glass-border); color: var(--text-muted); box-shadow: none; }
.btn.ghost:active { border-color: var(--accent); color: var(--text); }
.btn.danger { background: rgba(224,114,92,0.12); border-color: rgba(224,114,92,0.35); color: var(--c-cardio); }
.btn.green { background: var(--c-activity); border: none; color: #06170c; border-radius: var(--r-pill); }
.btn.block { width: 100%; }
.btn.sm { padding: 9px 13px; font-size: 11px; border-radius: 12px; }
.btn:disabled { opacity: 0.35; }

.row { display: flex; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

.chip {
  display: inline-flex; align-items: center; gap: 5px; background: var(--glass-fill);
  border: 0.5px solid var(--glass-border); backdrop-filter: blur(10px);
  border-radius: var(--r-pill); padding: 9px 15px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--text-muted); font-weight: 600; transition: all 0.15s;
}
.chip.selected { background: var(--accent); border-color: transparent; color: var(--accent-ink); }

/* ============ SELECT / DROPDOWN TRIGGER ============ */
.select-trigger {
  width: 100%; display: flex; align-items: center; gap: 14px; text-align: left;
  background: var(--glass-fill); border: 0.5px solid var(--glass-border); backdrop-filter: blur(14px);
  border-radius: var(--r-sm); padding: 14px 16px; transition: border-color 0.15s; box-shadow: var(--shadow-btn);
}
.select-trigger:active { border-color: var(--accent); }
.select-trigger-icon {
  width: 40px; height: 40px; border-radius: 13px; background: var(--glass-fill-2);
  display: flex; align-items: center; justify-content: center; font-size: 17px; flex-shrink: 0;
}
.select-trigger-text { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.select-trigger-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); }
.select-trigger-value { font-size: 14px; font-weight: 500; color: var(--text); text-transform: none; letter-spacing: 0; }
.select-trigger-chevron { color: var(--text-muted); font-size: 16px; }

.dropdown-option {
  display: flex; align-items: center; gap: 13px; padding: 13px 10px; border-radius: 14px;
  transition: background 0.15s;
}
.dropdown-option:active { background: var(--glass-fill); }
.dropdown-option-icon {
  width: 44px; height: 44px; border-radius: 13px; background: var(--glass-fill); border: 0.5px solid var(--glass-border);
  display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0;
}
.dropdown-option .name { font-weight: 500; font-size: 14px; text-transform: none; letter-spacing: 0; }
.dropdown-option .tags { font-size: 11px; color: var(--text-muted); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.4px; }

/* ============ FORM FIELDS ============ */
label.field { display: block; margin-bottom: 6px; margin-top: 14px; }
input[type=text], input[type=number], select, input[type=date] {
  width: 100%; background: var(--glass-fill); border: 0.5px solid var(--glass-border); color: var(--text);
  border-radius: 13px; padding: 12px 13px; font-size: 16px; font-weight: 500; transition: border-color 0.15s;
  backdrop-filter: blur(10px);
}
/* iOS Safari auto-zooms the whole page when a focused field's font-size is under
   16px — every text input/select must stay at 16px+ to prevent that "zoomed in
   and stuck" behavior, regardless of the viewport meta tag settings above. */
input:focus, select:focus { outline: none; border-color: var(--accent); }
input[type=file] { color: var(--text-muted); font-size: 12px; }

/* ============ EXERCISE / LIST ITEMS ============ */
.exercise-item {
  display: flex; align-items: center; gap: 13px;
  background: var(--glass-fill); border: 0.5px solid var(--glass-border); backdrop-filter: blur(14px);
  border-radius: var(--r-sm); padding: 12px 14px; margin-bottom: 9px; transition: border-color 0.15s;
  box-shadow: var(--shadow-card);
}
.exercise-item:active { border-color: var(--glass-border-2); }
.exercise-item .name { font-weight: 500; font-size: 14px; letter-spacing: 0; text-transform: none; }
.exercise-item .tags { font-size: 10.5px; color: var(--text-muted); margin-top: 3px; text-transform: uppercase; letter-spacing: 0.4px; }
.exercise-item.selected { border-color: var(--accent); }

/* Icon tile — frosted glass square holding either a real image or an outline pictogram */
.ex-icon {
  width: 50px; height: 50px; border-radius: 15px; flex-shrink: 0; overflow: hidden; position: relative;
  background: var(--glass-fill-2); border: 0.5px solid var(--glass-border);
}
.ex-icon svg { width: 100%; height: 100%; display: block; }
.ex-icon.sm { width: 42px; height: 42px; border-radius: 12px; }
.ex-icon.lg { width: 76px; height: 76px; border-radius: 20px; }

.intensity-badge { font-size: 9px; font-weight: 700; border-radius: 999px; padding: 3px 8px; text-transform: uppercase; letter-spacing: 0.5px; }
.intensity-badge.high { background: rgba(226,155,74,0.16); color: var(--c-energy); }
.intensity-badge.medium { background: rgba(255,255,255,0.08); color: var(--text-muted); }
.intensity-badge.low { background: rgba(127,176,138,0.16); color: var(--c-activity); }

/* ============ TIMERS ============
   Rest/recovery timer reuses the "sleep/downtime" indigo as its base
   (rest = a form of recovery, same concept as sleep in the reference system).
   As the timer runs low it shifts to energy amber, then to cardio coral
   once overtime — reusing existing hues rather than adding new ones. */
.timer-display {
  font-size: 54px; font-weight: 500; text-align: center; letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; color: var(--text);
}
.timer-sub { text-align: center; color: var(--text-muted); font-size: 11px; margin-top: -2px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px; }

.pulse-red { animation: pulse-cardio 1s ease-in-out; }
@keyframes pulse-cardio { 0%,100% { box-shadow: 0 0 0 0 rgba(224,114,92,0); } 30% { box-shadow: 0 0 0 22px rgba(224,114,92,0.22); } }

/* ---- Rest-over alert: card pulses coral continuously until the user acts ---- */
#restCard.rest-overdue {
  animation: restOverdueBg 1.2s ease-in-out infinite;
}
@keyframes restOverdueBg {
  0%, 100% { box-shadow: var(--shadow-hero), 0 0 0 0 rgba(224,114,92,0); }
  50% { box-shadow: var(--shadow-hero), 0 0 34px 6px rgba(224,114,92,0.45); }
}
#restCard.rest-overdue #restRingWrap { animation: restOverduePulseScale 1.2s ease-in-out infinite; }
@keyframes restOverduePulseScale { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.04); } }
#restCard.rest-overdue #restLabel { color: var(--c-cardio); font-weight: 800; }

/* One-shot full-viewport flash the instant rest hits zero — impossible to miss
   even if you glanced away from the screen. */
.screen-flash {
  position: fixed; inset: 0; z-index: 200; pointer-events: none;
  background: var(--c-cardio);
  animation: screenFlashFade 500ms ease-out forwards;
}
@keyframes screenFlashFade { 0% { opacity: 0.55; } 100% { opacity: 0; } }

.set-type-toggle { display: flex; gap: 6px; }
.set-type-toggle .btn { flex: 1; font-size: 10px; padding: 10px 4px; }

.machine-photo { width: 100%; max-height: 190px; object-fit: cover; border-radius: var(--r-sm); margin-bottom: 10px; }
.machine-thumb { width: 50px; height: 50px; object-fit: cover; border-radius: 15px; background: var(--glass-fill-2); flex-shrink: 0; }

.empty-state { text-align: center; color: var(--text-muted); padding: 46px 20px; font-size: 13px; line-height: 1.6; text-transform: none; letter-spacing: 0; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }

/* Frequency bar chart — each bar sits in a fixed-height track so alignment stays
   correct regardless of how sparse the data is (previously an absolutely-positioned
   count label plus a variable-height flex row caused misalignment with few workouts). */
.bar-chart { display: flex; gap: 7px; margin-top: 16px; align-items: flex-end; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: stretch; }
.bar-count { text-align: center; font-size: 10px; color: var(--text-muted); font-weight: 700; height: 16px; }
.bar-track { position: relative; height: 70px; display: flex; align-items: flex-end; }
.bar-chart .bar { width: 100%; background: var(--c-energy); border-radius: 5px 5px 2px 2px; opacity: 0.9; }
.lbl { text-align: center; font-size: 9px; color: var(--text-muted); margin-top: 7px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }

/* ---- Calendar (History tab) ---- */
.cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 10px; color: var(--text-muted); font-weight: 700; margin-bottom: 6px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-cell {
  aspect-ratio: 1; border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--glass-fill); border: 0.5px solid transparent; position: relative;
}
.cal-cell.empty { background: none; }
.cal-daynum { font-size: 11px; color: var(--text-muted); font-weight: 600; }
.cal-cell.has-workout { background: rgba(127,176,138,0.16); border-color: rgba(127,176,138,0.4); }
.cal-cell.has-workout .cal-daynum { color: var(--text); }
.cal-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--c-activity); margin-top: 2px; }
.cal-dur { font-size: 7.5px; color: var(--c-activity); font-weight: 700; margin-top: 1px; }
.cal-skip-dot { width: 4px; height: 4px; border-radius: 50%; background: var(--text-muted); opacity: 0.5; margin-top: 3px; }
.cal-cell.rest-day { background: rgba(140,143,224,0.16); border-color: rgba(140,143,224,0.4); }
.cal-cell.rest-day .cal-daynum { color: var(--text); }
.cal-rest-icon { font-size: 9px; margin-top: 2px; }
.cal-cell.skipped { opacity: 0.7; }
.cal-cell.today { border-color: var(--c-energy); border-width: 1.5px; }
.cal-legend-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.cal-legend-dot.workout { background: var(--c-activity); }
.cal-legend-dot.rest { background: var(--c-sleep); }
.cal-legend-dot.skip { background: var(--text-muted); opacity: 0.5; }

.toast {
  position: fixed; bottom: calc(var(--nav-clearance, 110px) + 8px); left: 50%; transform: translateX(-50%);
  background: var(--glass-fill-2); border: 0.5px solid var(--glass-border); backdrop-filter: blur(16px); color: var(--text);
  padding: 12px 20px; border-radius: var(--r-pill); font-size: 12.5px; font-weight: 500; z-index: 100; opacity: 0;
  transition: opacity 0.3s, transform 0.3s; pointer-events: none; box-shadow: var(--shadow-card);
  white-space: nowrap; text-transform: none; letter-spacing: 0;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.65); display: flex; align-items: flex-end;
  z-index: 50; justify-content: center; backdrop-filter: blur(4px);
}
.modal-sheet {
  background: #0f120f; border: 0.5px solid var(--glass-border);
  width: 100%; max-width: 560px; border-radius: 24px 24px 0 0;
  padding: 22px 18px 26px; max-height: 85vh; overflow-y: auto; border-bottom: none;
  backdrop-filter: blur(20px);
  animation: slideUp 0.28s cubic-bezier(.2,.8,.3,1); box-shadow: var(--shadow-hero);
}
@keyframes slideUp { from { transform: translateY(30px); opacity: 0.5; } to { transform: none; opacity: 1; } }
.modal-sheet h3 { margin-top: 0; font-size: 16px; }
.close-x {
  float: right; background: var(--glass-fill); border: 0.5px solid var(--glass-border); color: var(--text-muted);
  font-size: 15px; width: 32px; height: 32px; border-radius: 12px; backdrop-filter: blur(10px);
}

.search-bar input { margin-bottom: 12px; }
.cat-scroll { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 10px; margin-bottom: 4px; }
.cat-scroll .chip { white-space: nowrap; }

.progress-line { height: 5px; background: rgba(255,255,255,0.08); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.progress-line .fill { height: 100%; background: var(--c-energy); border-radius: 3px; }

.section-title { margin: 20px 4px 10px; }

.log-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 0.5px solid var(--glass-border); font-size: 13px; font-weight: 500; }
.log-row:last-child { border-bottom: none; }

/* Pause/Finish action bar — lives inside the sticky header block (not floating
   independently), so it reserves its own space and can never overlap page
   content the way a separately-fixed bar could. Always visible, never covers
   anything else. */
.workout-action-bar {
  display: flex; gap: 10px; padding: 0 20px 14px;
}
.workout-action-bar .btn { box-shadow: var(--shadow-card); }
.set-type-pill { font-size: 10px; padding: 3px 9px; border-radius: 999px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; }
.pill-warmup { background: rgba(226,155,74,0.16); color: var(--c-energy); }
.pill-working { background: rgba(127,176,138,0.16); color: var(--c-activity); }
.pill-dropset { background: rgba(224,114,92,0.16); color: var(--c-cardio); }

/* ============================================================
   MOTION SYSTEM
   ============================================================ */

/* ---- Ripple (primary pill buttons only) ---- */
.btn-ripple {
  position: absolute; border-radius: 50%; background: rgba(255,255,255,0.35);
  transform: scale(0); opacity: 1; pointer-events: none;
  animation: rippleOut 400ms ease-out forwards;
}
@keyframes rippleOut { to { transform: scale(1); opacity: 0; } }

/* ---- Screen transitions ---- */
@keyframes slideInRight { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: translateX(0); } }
@keyframes slideInLeft { from { opacity: 0; transform: translateX(-16px); } to { opacity: 1; transform: translateX(0); } }
.screen-enter-forward { animation: slideInRight 260ms ease-out; }
.screen-enter-back { animation: slideInLeft 260ms ease-out; }

/* ---- Staggered card entrance (navigation only, not in-place updates) ---- */
@keyframes cardEnter { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.card-enter { animation: cardEnter 300ms ease-out backwards; }

/* ---- Modal presentation: scale + fade + slight rise ---- */
@keyframes modalIn { from { opacity: 0; transform: translateY(20px) scale(0.96); } to { opacity: 1; transform: translateY(0) scale(1); } }
.modal-sheet { animation: modalIn 220ms ease-out !important; }
@keyframes overlayFadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-overlay { animation: overlayFadeIn 180ms ease-out; }

/* ---- Progress bar / bar-chart animated fill ---- */
.progress-line .fill { transition: width 700ms cubic-bezier(.16,1,.3,1); }
.bar-chart .bar { transition: height 700ms cubic-bezier(.16,1,.3,1); }
@keyframes glowPulse {
  0% { box-shadow: 0 0 0 0 rgba(226,155,74,0); }
  40% { box-shadow: 0 0 16px 4px rgba(226,155,74,0.9); }
  100% { box-shadow: 0 0 0 0 rgba(226,155,74,0); }
}
.glow-complete { animation: glowPulse 500ms ease-out; }

/* ---- Numeric counter milestone bounce ---- */
@keyframes bounceNum { 0% { transform: scale(1); } 50% { transform: scale(1.1); } 100% { transform: scale(1); } }
.bounce-num { display: inline-block; animation: bounceNum 300ms cubic-bezier(.34,1.56,.64,1); }

/* ---- Icon pulse (stat/value just updated) ---- */
@keyframes iconPulse { 0% { transform: scale(1); filter: brightness(1); } 50% { transform: scale(1.15); filter: brightness(1.35); } 100% { transform: scale(1); filter: brightness(1); } }
.icon-pulse { animation: iconPulse 300ms ease-out; }

/* ---- Hero glow: separate layer so it can animate independently of card content ---- */
.hero-card { position: relative; overflow: hidden; background: var(--glass-fill-2); }
.hero-card::before {
  content: ''; position: absolute; inset: -20%; z-index: 0; pointer-events: none;
  background: var(--bg-glow);
  opacity: 0; transform: scale(0.8);
  animation: heroGlowIn 400ms ease-out forwards;
}
body.breathing-on .hero-card::before {
  animation: heroGlowIn 400ms ease-out forwards, heroBreathe 5s ease-in-out 400ms infinite;
}
.hero-card > * { position: relative; z-index: 1; }
@keyframes heroGlowIn { from { opacity: 0.6; transform: scale(0.8); } to { opacity: 1; transform: scale(1); } }
@keyframes heroBreathe { 0%, 100% { opacity: 0.9; } 50% { opacity: 1; } }

/* ---- Glass panel blur fade-in (navigation entrance only) ---- */
@keyframes blurFadeIn { from { backdrop-filter: blur(0px); } to { backdrop-filter: blur(16px); } }
.card-enter.card, .card-enter.glass-panel { animation: cardEnter 300ms ease-out backwards, blurFadeIn 350ms ease-out backwards; }

/* ---- Celebration overlay ---- */
.celebration-overlay {
  position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(0,0,0,0.35); animation: overlayFadeIn 200ms ease-out;
}
.celebration-card {
  pointer-events: auto; margin: 0 14px 100px; max-width: 500px; width: 100%;
  background: #0f120f; border: 0.5px solid var(--glass-border); border-radius: 24px;
  padding: 26px 22px; box-shadow: var(--shadow-hero); backdrop-filter: blur(20px);
  transform: translateY(100%); opacity: 0;
  animation: celebrationIn 300ms ease-out forwards;
}
@keyframes celebrationIn { to { transform: translateY(0); opacity: 1; } }
@keyframes celebrationOut { to { transform: translateY(100%); opacity: 0; } }
.celebration-card h3 { text-transform: none; letter-spacing: 0; font-size: 17px; }

/* ---- Scroll-wheel number picker (weight/reps entry) ---- */
.wheel-picker { overflow-y: scroll; scroll-snap-type: y mandatory; -webkit-overflow-scrolling: touch; }
.wheel-picker::-webkit-scrollbar { display: none; }
.wheel-item {
  display: flex; align-items: center; justify-content: center; scroll-snap-align: center;
  font-size: 19px; font-weight: 600; color: var(--text-muted); font-variant-numeric: tabular-nums;
  transition: color 0.15s, font-size 0.15s;
}
.wheel-item.center { color: var(--text); font-weight: 800; font-size: 24px; }
.wheel-center-indicator {
  position: absolute; top: 50%; left: 0; right: 0; transform: translateY(-50%);
  background: var(--glass-fill-2); border-top: 0.5px solid var(--glass-border-2); border-bottom: 0.5px solid var(--glass-border-2);
  border-radius: 12px; pointer-events: none; z-index: 0;
}

/* ---- Launch splash ---- */
#splash {
  position: fixed; inset: 0; z-index: 999; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px; background: var(--bg);
  animation: splashOut 550ms ease-in forwards; animation-delay: 1050ms;
}
.splash-glow {
  position: absolute; width: 300px; height: 300px; border-radius: 50%; filter: blur(24px);
  background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
  opacity: 0; animation: splashGlowPulse 1.5s ease-out forwards;
}
.splash-logo-img {
  width: 88px; height: 88px; border-radius: 22px; position: relative; z-index: 1;
  box-shadow: 0 14px 44px rgba(78,122,92,0.5);
  opacity: 0; transform: scale(0.6);
  animation: splashLogoIn 550ms cubic-bezier(.22,1.4,.4,1) forwards;
}
.splash-title {
  font-size: 17px; font-weight: 700; letter-spacing: 4px; color: var(--text);
  position: relative; z-index: 1;
  opacity: 0; animation: splashTextIn 400ms ease-out forwards; animation-delay: 350ms;
}
.splash-tagline {
  font-size: 10px; font-weight: 600; letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--text-muted); position: relative; z-index: 1;
  opacity: 0; animation: splashTextIn 400ms ease-out forwards; animation-delay: 500ms;
}
@keyframes splashGlowPulse { 0% { opacity: 0; transform: scale(0.7); } 45% { opacity: 0.5; transform: scale(1); } 100% { opacity: 0; transform: scale(1.2); } }
@keyframes splashLogoIn { from { opacity: 0; transform: scale(0.6); } to { opacity: 1; transform: scale(1); } }
@keyframes splashTextIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes splashOut { to { opacity: 0; visibility: hidden; transform: scale(1.05); } }
.check-circle { stroke-dasharray: 170; stroke-dashoffset: 170; animation: drawStroke 400ms ease-out forwards; }
.check-path { stroke-dasharray: 40; stroke-dashoffset: 40; animation: drawStroke 350ms ease-out forwards 350ms; }
@keyframes drawStroke { to { stroke-dashoffset: 0; } }

/* ---- Swipe-to-confirm (start/finish a set) ---- */
.swipe-track {
  position: relative; height: 56px; border-radius: 28px; overflow: hidden;
  background: var(--glass-fill); border: 0.5px solid var(--glass-border); backdrop-filter: blur(10px);
}
.swipe-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; opacity: 0.28; border-radius: 28px; pointer-events: none; }
.swipe-label {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--text-muted); pointer-events: none; transition: opacity 0.1s linear;
}
.swipe-thumb {
  position: absolute; left: 3px; top: 3px; width: 50px; height: 50px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 19px; font-weight: 900;
  color: #06170c; touch-action: none; cursor: grab; box-shadow: var(--shadow-btn); z-index: 1;
}
.swipe-thumb:active { cursor: grabbing; }

/* ---- "Set in progress" animated figure — original filled silhouette design,
   replacing the earlier thin stick-figure line drawing. ---- */
.working-figure { display: inline-block; margin-top: 4px; animation: figureBob 1.1s ease-in-out infinite; }
@keyframes figureBob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
.working-figure-forearm-l { transform-box: view-box; transform-origin: 33px 68px; animation: curlRepL 1.1s ease-in-out infinite; }
.working-figure-forearm-r { transform-box: view-box; transform-origin: 87px 68px; animation: curlRepR 1.1s ease-in-out infinite; }
@keyframes curlRepL { 0%, 100% { transform: rotate(0deg); } 55% { transform: rotate(95deg); } }
@keyframes curlRepR { 0%, 100% { transform: rotate(0deg); } 55% { transform: rotate(-95deg); } }
.working-figure-bicep-l, .working-figure-bicep-r { transform-box: fill-box; transform-origin: center; animation: bicepPulse 1.1s ease-in-out infinite; }
@keyframes bicepPulse { 0%, 100% { transform: scale(1); opacity: 0.85; } 55% { transform: scale(1.18); opacity: 1; } }

/* ---- Mini clocks (Total / This Exercise / Rest) — small, ms-precision, per user's reference ---- */
.mini-clocks { display: flex; justify-content: center; gap: 22px; }
.mini-clock { display: flex; flex-direction: column; align-items: center; }
.mini-clock-label { font-size: 9px; color: var(--text-muted); letter-spacing: 0.6px; font-weight: 700; text-transform: uppercase; }
.mini-clock-val { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 3px; }

/* ---- "Rest's over" takeover — emerges at T-15s (not at expiry), giving time to
   configure and start the next set before ever hitting true overtime. Genuinely
   opaque (solid --bg at the edges, not a low-alpha tint) so it never bleeds
   together with whatever's scrolled behind it — that was the earlier bug.
   Dismissible via the small close button, but that's the escape hatch. */
.rest-popup-overlay {
  position: fixed; inset: 0; z-index: 45; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 30%, #241b14 0%, var(--bg) 65%);
  animation: overlayFadeIn 250ms ease-out; padding: 24px;
}
.rest-popup-inner { width: 100%; max-width: 420px; text-align: center; }

/* Swipe slider inside the popup stays invisible/inert until the final 2 seconds,
   then fades in smoothly right up to the moment rest would have ended. */
.swipe-track { transition: opacity 2000ms ease; }
.swipe-track.slider-hidden { opacity: 0; pointer-events: none; }
.swipe-track.slider-visible { opacity: 1; pointer-events: auto; }
