/* ═══════════════════════════════════════════
   FITNESS FORGE — Design System
   Industrial / Raw / High-contrast
═══════════════════════════════════════════ */

:root {
  --bg:         #0d0d0b;
  --bg-2:       #141412;
  --bg-3:       #1c1b18;
  --bg-4:       #242320;
  --border:     #2e2c28;
  --border-hi:  #403e38;

  --text:       #f2ede4;
  --text-2:     #a09880;
  --text-3:     #5a5545;

  --fire:       #ff6b1a;
  --fire-dim:   rgba(255,107,26,0.12);
  --fire-glow:  rgba(255,107,26,0.25);
  --ember:      #ffb347;
  --steel:      #7ab3c8;
  --forge-green:#4dffaa;
  --danger:     #ff4444;

  --ff-mono:    'Fira Code', monospace;
  --ff-body:    'Fira Code', monospace;

  --r:    4px;
  --r2:   8px;
  --r-sm: 3px;
  --r-md: 6px;
  --r-lg: 10px;
  --r-xl: 14px;

  --fire-bright: #ff8540;
  --danger-dim:  rgba(255,68,68,0.08);
  --danger-glow: rgba(255,68,68,0.3);

  --shadow: 0 4px 24px rgba(0,0,0,0.5);
  --glow:   0 0 32px rgba(255,107,26,0.15);
}

/* ══ THEMES ══
   Override :root variables per theme.
   Chart.js colors are re-read from CSS vars on each init.
════════════════════════════════════════════════════════ */

/* ── Daylight ── */
html[data-theme="day"] {
  --bg:         #f5f0e8;
  --bg-2:       #ece7dc;
  --bg-3:       #e4ddd0;
  --bg-4:       #dcd5c6;
  --border:     #c4bbb0;
  --border-hi:  #b0a898;
  --text:       #1c1a16;
  --text-2:     #5a5040;
  --text-3:     #9a9080;
  --fire:       #c84808;
  --fire-dim:   rgba(200,72,8,0.10);
  --fire-glow:  rgba(200,72,8,0.22);
  --ember:      #b87800;
  --steel:      #3a7898;
  --forge-green:#007744;
  --danger:     #c02020;
  --shadow: 0 4px 24px rgba(0,0,0,0.10);
  --glow:   0 0 32px rgba(200,72,8,0.08);
}

/* ── Ambient (deep space) ── */
html[data-theme="ambient"] {
  --bg:         #07070f;
  --bg-2:       #0d0d1c;
  --bg-3:       #131328;
  --bg-4:       #191934;
  --border:     #222240;
  --border-hi:  #2e2e58;
  --text:       #e4e0fc;
  --text-2:     #8080c0;
  --text-3:     #404078;
  --fire:       #8b74ff;
  --fire-dim:   rgba(139,116,255,0.12);
  --fire-glow:  rgba(139,116,255,0.28);
  --ember:      #b094ff;
  --steel:      #40d8f8;
  --forge-green:#00e8cc;
  --danger:     #ff4488;
  --shadow: 0 4px 32px rgba(0,0,0,0.7);
  --glow:   0 0 48px rgba(139,116,255,0.2);
}

/* ── Steel (cold navy) ── */
html[data-theme="steel"] {
  --bg:         #060c12;
  --bg-2:       #0d1820;
  --bg-3:       #14222e;
  --bg-4:       #1b2c3c;
  --border:     #223040;
  --border-hi:  #2c3e52;
  --text:       #c8e2f4;
  --text-2:     #5888a8;
  --text-3:     #2e4a60;
  --fire:       #36b4e4;
  --fire-dim:   rgba(54,180,228,0.12);
  --fire-glow:  rgba(54,180,228,0.28);
  --ember:      #60c8f4;
  --steel:      #40ffb8;
  --forge-green:#40ffb8;
  --danger:     #ff5566;
  --shadow: 0 4px 28px rgba(0,0,0,0.6);
  --glow:   0 0 40px rgba(54,180,228,0.15);
}

/* ── Ember (campfire warm) ── */
html[data-theme="ember"] {
  --bg:         #0e0808;
  --bg-2:       #181010;
  --bg-3:       #201818;
  --bg-4:       #2a2020;
  --border:     #3c2828;
  --border-hi:  #4c3838;
  --text:       #f8e8d0;
  --text-2:     #b09070;
  --text-3:     #706048;
  --fire:       #ff7828;
  --fire-dim:   rgba(255,120,40,0.12);
  --fire-glow:  rgba(255,120,40,0.28);
  --ember:      #ffaa40;
  --steel:      #ffd060;
  --forge-green:#ffaa40;
  --danger:     #ff3333;
  --shadow: 0 4px 28px rgba(0,0,0,0.6);
  --glow:   0 0 40px rgba(255,120,40,0.15);
}

/* ── Smooth theme transitions ── */
body,
.sidebar, .sidebar-head, .sidebar-body, .sidebar-foot,
.card, .stat, .nav-btn, .page,
input, select, textarea,
.tag, .alert, .modal, .modal-overlay,
.active-session-overlay, .session-ex-block,
.rest-timer-bar, .pr-toast, .session-summary-toast {
  transition:
    background-color 0.28s ease,
    border-color     0.28s ease,
    color            0.28s ease,
    box-shadow       0.28s ease;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--ff-mono);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
}

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-hi); border-radius: 3px; }

/* ── TYPE UTILITIES ── */
.display    { font-family: var(--ff-mono); font-weight: 700; letter-spacing: 0.04em; line-height: 0.95; text-transform: uppercase; }
.display-it { font-family: var(--ff-mono); font-weight: 600; font-style: italic; line-height: 0.95; }
.mono       { font-family: var(--ff-mono); }
.label      { font-family: var(--ff-mono); font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--text-3); }
.fire       { color: var(--fire); }
.ember      { color: var(--ember); }
.steel      { color: var(--steel); }
.green      { color: var(--forge-green); }
.dim        { color: var(--text-2); }
.muted      { color: var(--text-3); }

/* ── APP SHELL ── */
#root { min-height: 100vh; }

.shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

/* ── SIDEBAR ── */
.sidebar {
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-head {
  padding: 28px 24px 24px;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 36px; height: 36px;
  background: var(--fire);
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  box-shadow: 0 0 16px rgba(255,107,26,0.4);
}

.brand-name {
  font-family: var(--ff-mono);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.1em;
  line-height: 1;
  text-transform: uppercase;
}

.brand-tag {
  font-family: var(--ff-mono);
  font-size: 8px;
  letter-spacing: 0.2em;
  color: var(--text-3);
  text-transform: uppercase;
  margin-top: 3px;
}

.sidebar-body { padding: 16px 12px; flex: 1; }

.nav-group { margin-bottom: 24px; }

.nav-group-label {
  font-family: var(--ff-mono);
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 0 10px;
  margin-bottom: 6px;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  color: var(--text-2);
  font-family: var(--ff-mono);
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  transition: all 0.14s;
}

.nav-btn:hover { background: var(--bg-3); color: var(--text); }

.nav-btn.active {
  background: var(--fire-dim);
  border-color: var(--fire-glow);
  color: var(--fire);
}

.nav-icon { font-size: 15px; width: 20px; text-align: center; opacity: 0.8; }

.sidebar-foot {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

.user-chip {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 10px 12px;
}

.user-chip .name {
  font-family: var(--ff-mono);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.user-chip .meta {
  font-family: var(--ff-mono);
  font-size: 9px;
  color: var(--text-3);
  margin-top: 2px;
}

/* ── MAIN AREA ── */
.main { overflow-y: auto; }

.page {
  display: none;
  padding: 44px 48px;
  max-width: 1080px;
  animation: fadeUp 0.22s ease;
}

.page.active { display: block; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.page-title { font-size: 72px; }
.page-sub {
  font-family: var(--ff-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--text-3);
  text-transform: uppercase;
  margin-top: 6px;
}

.page-header { margin-bottom: 40px; }

/* ── CARDS ── */
.card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  padding: 24px;
}

.card-fire {
  border-color: var(--fire-glow);
  box-shadow: var(--glow);
}

/* ── GRIDS ── */
.g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.g3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.g4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; }
.g-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }

/* ── STAT CARD ── */
.stat {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  padding: 20px;
  position: relative;
  overflow: hidden;
}
.stat::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
}
.stat.s-fire::after   { background: var(--fire); }
.stat.s-ember::after  { background: var(--ember); }
.stat.s-steel::after  { background: var(--steel); }
.stat.s-green::after  { background: var(--forge-green); }

.stat-val {
  font-family: var(--ff-mono);
  font-weight: 700;
  font-size: 40px;
  line-height: 1;
  margin: 6px 0 4px;
  letter-spacing: -0.02em;
}

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 22px;
  font-family: var(--ff-mono);
  font-size: 11px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase;
  border: none; border-radius: var(--r-md); cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}
.btn-fire {
  background: var(--fire); color: var(--bg);
  box-shadow: 0 0 20px rgba(255,107,26,0.3);
}
.btn-fire:hover { background: var(--fire-bright); transform: translateY(-1px); box-shadow: 0 4px 24px rgba(255,107,26,0.5); }

.btn-ghost { background: transparent; color: var(--text-2); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--border-hi); color: var(--text); }

.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger-glow); }
.btn-danger:hover { background: var(--danger-dim); }

.btn-lg { padding: 14px 30px; font-size: 12px; }
.btn-sm { padding: 7px 14px; font-size: 10px; }

/* ── TAG ── */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px;
  font-family: var(--ff-mono); font-size: 9px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase;
  border-radius: var(--r-sm);
}
.t-fire  { background: rgba(255,107,26,0.14); color: var(--fire);  border: 1px solid rgba(255,107,26,0.3); }
.t-green { background: rgba(77,255,170,0.1);  color: var(--forge-green); border: 1px solid rgba(77,255,170,0.25); }
.t-steel { background: rgba(122,179,200,0.1); color: var(--steel); border: 1px solid rgba(122,179,200,0.25); }
.t-dim   { background: var(--bg-3); color: var(--text-3); border: 1px solid var(--border); }
.t-ember { background: rgba(255,179,71,0.12); color: var(--ember); border: 1px solid rgba(255,179,71,0.28); }

/* ── DIVIDER ── */
hr { border: none; border-top: 1px solid var(--border); margin: 24px 0; }

/* ── SECTION HEADING ── */
.sec-head, .section-label {
  font-family: var(--ff-mono); font-size: 10px; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--text-3);
  display: flex; align-items: center; gap: 12px; margin-bottom: 16px;
  font-weight: 600;
}
.sec-head::after, .section-label::after { content:''; flex:1; height:1px; background: var(--border); }

/* ── ACTIVE CARD modifier ── */
.card--active { border-left: 3px solid var(--fire) !important; padding-left: 17px; }

/* ── TABLE ── */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  font-family: var(--ff-mono); font-size: 9px; letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--text-3); text-align: left; padding: 8px 14px; border-bottom: 1px solid var(--border);
}
.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 13px; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover td { background: var(--bg-3); }
.tbl .ex-name { font-weight: 500; color: var(--text); }
.tbl .ex-note { font-size: 11px; color: var(--text-3); margin-top: 2px; }

/* ── PROGRESS BAR ── */
.pbar-wrap { background: var(--bg-3); border-radius: 2px; height: 4px; overflow: hidden; }
.pbar { height: 100%; border-radius: 2px; transition: width 0.7s cubic-bezier(.4,0,.2,1); }
.pbar-fire  { background: var(--fire); }
.pbar-green { background: var(--forge-green); }

/* ── INPUT ── */
.input {
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--r-md); color: var(--text);
  font-family: var(--ff-mono); font-size: 13px;
  padding: 11px 14px; width: 100%; outline: none;
  transition: border-color 0.15s;
}
.input:focus { border-color: var(--fire); }
.input::placeholder { color: var(--text-3); }

select.input { cursor: pointer; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-family: var(--ff-mono); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-3); }

/* ── ALERT ── */
.alert {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 16px; border-radius: var(--r); font-size: 13px;
}
.alert-fire    { background: rgba(255,107,26,0.08); border: 1px solid rgba(255,107,26,0.25); color: var(--fire); }
.alert-green   { background: rgba(77,255,170,0.07); border: 1px solid rgba(77,255,170,0.22); color: var(--forge-green); }
.alert-neutral { background: var(--bg-3); border: 1px solid var(--border); color: var(--text-2); }

/* ══ ONBOARDING / QUIZ ══ */
.onboard-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 40px 24px;
  position: relative;
}

.onboard-wrap::before {
  content: '';
  position: fixed; inset: 0;
  background: radial-gradient(ellipse 60% 40% at 50% 80%, rgba(255,107,26,0.07) 0%, transparent 70%);
  pointer-events: none;
}

.onboard-card {
  width: 100%; max-width: 580px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.onboard-top {
  background: var(--bg-3);
  padding: 32px 36px 24px;
  border-bottom: 1px solid var(--border);
}

.onboard-brand {
  display: flex; align-items: center; gap: 10px; margin-bottom: 28px;
}

.onboard-logo {
  width: 40px; height: 40px; background: var(--fire);
  border-radius: 6px; display: flex; align-items: center; justify-content: center;
  font-size: 20px; box-shadow: 0 0 20px rgba(255,107,26,0.5);
}

.quiz-progress {
  display: flex; gap: 4px; margin-top: 16px;
}
.quiz-pip {
  flex: 1; height: 3px; border-radius: 2px;
  background: var(--border);
  transition: background 0.3s;
}
.quiz-pip.done { background: var(--fire); }
.quiz-pip.active { background: var(--ember); }

.onboard-body { padding: 32px 36px; }

.quiz-q {
  font-family: var(--ff-mono);
  font-weight: 700; font-size: 24px; text-transform: uppercase; letter-spacing: 0.04em;
  line-height: 1.1; margin-bottom: 8px;
}

.quiz-sub {
  font-size: 13px; color: var(--text-2); margin-bottom: 28px;
}

.option-grid {
  display: grid; gap: 10px;
}

.option-btn {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--r-md); color: var(--text);
  cursor: pointer; text-align: left;
  transition: all 0.15s; font-family: var(--ff-mono); font-size: 13px;
}
.option-btn:hover { border-color: var(--fire-glow); background: rgba(255,107,26,0.05); }
.option-btn.selected {
  border-color: var(--fire);
  background: var(--fire-dim);
  color: var(--fire);
}

.option-icon { font-size: 22px; width: 30px; text-align: center; }

.option-label { font-weight: 500; }
.option-desc  { font-size: 11px; color: var(--text-3); margin-top: 2px; }

.quiz-nav {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 28px; gap: 12px;
}

/* ══ PROGRAM DISPLAY ══ */
.week-tabs {
  display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 24px;
}
.wtab {
  padding: 6px 14px; font-family: var(--ff-mono); font-size: 10px; letter-spacing: 0.08em;
  border: 1px solid var(--border); border-radius: var(--r);
  background: transparent; color: var(--text-3); cursor: pointer; transition: all 0.14s;
}
.wtab:hover { border-color: var(--border-hi); color: var(--text-2); }
.wtab.active { background: var(--fire-dim); border-color: var(--fire-glow); color: var(--fire); }

.day-card {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--r2); overflow: hidden; transition: border-color 0.15s;
}
.day-card:hover { border-color: var(--border-hi); }
.day-card.today-card { border-color: var(--fire-glow); box-shadow: 0 0 16px rgba(255,107,26,0.08); }

.day-head {
  background: var(--bg-3); border-bottom: 1px solid var(--border);
  padding: 14px 18px; display: flex; align-items: center; justify-content: space-between;
}
.day-name { font-family: var(--ff-mono); font-weight: 700; font-size: 18px; letter-spacing: 0.06em; text-transform: uppercase; }
.day-body { padding: 16px 18px; }

/* ══ LOG ENTRY ══ */
.log-row {
  display: flex; gap: 16px; padding: 16px 0;
  border-bottom: 1px solid var(--border); align-items: flex-start;
}
.log-row:last-child { border-bottom: none; }
.log-dt { font-family: var(--ff-mono); font-size: 10px; color: var(--text-3); min-width: 88px; padding-top: 3px; }

/* ══ BUILDER ══ */
.builder-row {
  display: grid; grid-template-columns: 1fr 70px 80px 70px 80px auto;
  gap: 8px; align-items: center; padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.builder-row:last-child { border-bottom: none; }

/* ══ MOBILE TOPBAR (always defined, hidden on desktop) ══ */
.mobile-topbar { display: none; }

.topbar-hamburger {
  background: none; border: none; color: var(--text);
  font-size: 22px; cursor: pointer; padding: 8px 10px;
  border-radius: var(--r); flex-shrink: 0;
  transition: background 0.12s; line-height: 1;
}
.topbar-hamburger:hover { background: var(--bg-3); }
.topbar-title {
  flex: 1; font-family: var(--ff-mono); font-weight: 700;
  font-size: 13px; letter-spacing: 0.1em; color: var(--text); text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 4px;
}
.topbar-back {
  display: none; /* shown via JS when history exists */
  background: none; border: 1px solid var(--border);
  color: var(--text-2); font-size: 11px; padding: 5px 10px;
  border-radius: var(--r); cursor: pointer; font-family: var(--ff-mono);
  transition: all 0.12s; flex-shrink: 0; white-space: nowrap; align-items: center; gap: 4px;
}
.topbar-back.visible { display: flex; }
.topbar-back:hover { border-color: var(--border-hi); color: var(--text); }

/* Backdrop — always defined, shown via class */
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 199;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.sidebar-backdrop.visible { display: block; }

/* ══ MOBILE ══ */
@media (max-width: 768px) {
  .shell { grid-template-columns: 1fr; }

  /* Fixed topbar */
  .mobile-topbar {
    display: flex;
    position: fixed; top: 0; left: 0; right: 0; height: 56px;
    background: var(--bg-2); border-bottom: 1px solid var(--border);
    align-items: center; padding: 0 4px; z-index: 150; gap: 2px;
    transition: background-color 0.28s, border-color 0.28s;
  }

  /* Sidebar = slide-in drawer from left */
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 280px; height: 100dvh;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 200;
    border-right: 1px solid var(--border);
    border-top: none; overflow-y: auto; overflow-x: hidden;
    flex-direction: column; max-height: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 8px 0 40px rgba(0,0,0,0.5);
  }

  /* Restore full sidebar layout inside drawer */
  .sidebar-head { display: flex; }
  .sidebar-foot { display: flex; }
  .nav-group-label { display: block; }
  .sidebar-body { display: block; overflow-x: visible; padding: 16px 12px; flex: 1; }
  .nav-group { display: block; padding: 0; margin-bottom: 24px; flex-shrink: unset; }
  .nav-group + .nav-group {
    border-left: none; border-top: 1px solid var(--border);
    margin-left: 0; padding-left: 0; margin-top: 0; padding-top: 16px;
  }
  .nav-btn {
    flex-direction: row; gap: 10px; padding: 10px 12px;
    font-size: 13px; border-radius: var(--r);
    white-space: normal; min-width: unset; border: 1px solid transparent;
  }
  .nav-icon { font-size: 15px; width: 20px; }

  /* Page content — top clears 56px topbar */
  .page { padding: 72px 16px 32px; }
  .page-title { font-size: 48px; }

  .g4 { grid-template-columns: 1fr 1fr; }
  .g3 { grid-template-columns: 1fr 1fr; }
  .g2 { grid-template-columns: 1fr; }
  .builder-row { grid-template-columns: 1fr 60px 60px auto; }
  .builder-row .br-rest, .builder-row .br-note { display: none; }
  .card { padding: 14px 12px; }
  .log-dt { min-width: 64px; font-size: 9px; }
}

/* ══ UTILS ══ */
.flex   { display: flex; }
.col    { flex-direction: column; }
.i-ctr  { align-items: center; }
.j-btwn { justify-content: space-between; }
.j-ctr  { justify-content: center; }
.gap4   { gap: 4px; }
.gap8   { gap: 8px; }
.gap12  { gap: 12px; }
.gap16  { gap: 16px; }
.gap24  { gap: 24px; }
.gap32  { gap: 32px; }
.mt8    { margin-top: 8px; }
.mt12   { margin-top: 12px; }
.mt16   { margin-top: 16px; }
.mt24   { margin-top: 24px; }
.mt32   { margin-top: 32px; }
.mb16   { margin-bottom: 16px; }
.mb24   { margin-bottom: 24px; }
.mb32   { margin-bottom: 32px; }
.w100   { width: 100%; }
.tc     { text-align: center; }
.tr     { text-align: right; }
.hidden { display: none !important; }
.fs12   { font-size: 12px; }
.fs11   { font-size: 11px; }
.fs13   { font-size: 13px; }

/* ══ EXERCISE DETAIL MODAL ══ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fadeIn 0.15s ease;
}
@keyframes fadeIn { from{opacity:0} to{opacity:1} }

.modal {
  background: var(--bg-2);
  border: 1px solid var(--border-hi);
  border-radius: var(--r-xl);
  width: 100%; max-width: 680px;
  max-height: 92dvh;
  overflow-y: auto;
  box-shadow: 0 24px 80px rgba(0,0,0,0.7);
  animation: slideUp 0.2s ease;
}
@keyframes slideUp { from{transform:translateY(20px);opacity:0} to{transform:translateY(0);opacity:1} }

.modal-head {
  padding: 24px 28px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  background: var(--bg-2);
  z-index: 1;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
}

.modal-close {
  background: var(--bg-3); border: 1px solid var(--border);
  color: var(--text-2); border-radius: var(--r-md);
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 16px; flex-shrink: 0;
  transition: all 0.14s;
}
.modal-close:hover { background: var(--bg-4); color: var(--text); }

.modal-body { padding: 24px 28px 32px; }

.muscle-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: var(--r-sm);
  font-family: var(--ff-mono); font-size: 10px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
  margin: 3px;
}
.muscle-primary   { background: rgba(255,107,26,0.15); color: var(--fire);        border: 1px solid rgba(255,107,26,0.3); }
.muscle-secondary { background: rgba(77,255,170,0.1);  color: var(--forge-green); border: 1px solid rgba(77,255,170,0.25); }
.muscle-stab      { background: var(--bg-3);            color: var(--text-3);      border: 1px solid var(--border); }

.cue-item {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 8px 0; border-bottom: 1px solid var(--border);
  font-size: 13px; line-height: 1.5;
}
.cue-num {
  font-family: var(--ff-mono); font-size: 10px; color: var(--fire);
  min-width: 20px; margin-top: 2px; font-weight: 600;
}

.error-item {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 8px 12px; background: rgba(255,68,68,0.05);
  border: 1px solid rgba(255,68,68,0.12); border-radius: 3px; margin: 4px 0;
  font-size: 12px; color: var(--text-2);
}

.video-embed {
  position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;
  border-radius: var(--r-md); background: var(--bg-3);
  border: 1px solid var(--border);
}
.video-embed iframe {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  border: none; border-radius: var(--r-md);
}
.video-placeholder {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; cursor: pointer;
  transition: background 0.15s;
}
.video-placeholder:hover { background: rgba(255,107,26,0.05); }
.play-btn {
  width: 56px; height: 56px; background: var(--fire);
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 22px; box-shadow: 0 0 24px rgba(255,107,26,0.4);
  transition: transform 0.15s;
}
.video-placeholder:hover .play-btn { transform: scale(1.1); }

/* ══ FREESTYLE PAGE ══ */
.muscle-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px;
  margin-bottom: 24px;
}
.muscle-tile {
  padding: 14px 12px;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--r2); cursor: pointer; text-align: center;
  transition: all 0.14s; user-select: none;
}
.muscle-tile:hover { border-color: var(--border-hi); background: var(--bg-3); }
.muscle-tile.selected {
  border-color: var(--fire);
  background: var(--fire-dim);
}
.muscle-tile .tile-icon { font-size: 26px; margin-bottom: 6px; }
.muscle-tile .tile-label { font-size: 12px; font-weight: 500; }

.intensity-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.int-btn {
  padding: 8px 16px; background: var(--bg-3);
  border: 1px solid var(--border); border-radius: var(--r);
  color: var(--text-2); font-family: var(--ff-mono); font-size: 10px;
  letter-spacing: 0.08em; text-transform: uppercase; cursor: pointer;
  transition: all 0.14s;
}
.int-btn:hover  { border-color: var(--border-hi); color: var(--text); }
.int-btn.active { background: var(--fire-dim); border-color: var(--fire); color: var(--fire); }

.freestyle-ex-card {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--r2); padding: 16px 18px;
  display: flex; align-items: center; gap: 14px;
  transition: border-color 0.14s; cursor: pointer;
}
.freestyle-ex-card:hover { border-color: var(--border-hi); }

.ex-card-num {
  font-family: var(--ff-mono); font-size: 22px; font-weight: 700;
  color: var(--text-3); min-width: 36px; text-align: center;
}

@media (max-width: 768px) {
  .muscle-grid { grid-template-columns: repeat(3, 1fr); }
  .modal { max-width: 100%; margin: 0; border-radius: 12px 12px 0 0; max-height: 95vh; }
  .modal-overlay { align-items: flex-end; padding: 0; }
}

/* ══════════════════════════════════════════
   NEW FEATURES — v2
   Active Workout, Charts, Nutrition,
   Body Stats, Achievements, Cardio
══════════════════════════════════════════ */

/* ── SHARED UTILITIES ── */
.chart-wrap {
  position: relative; width: 100%; height: 200px;
}
.form-input {
  background: var(--bg-3); border: 1px solid var(--border);
  color: var(--text); font-family: var(--ff-mono); font-size: 12px;
  padding: 8px 10px; border-radius: var(--r);
  transition: border-color 0.14s;
}
.form-input:focus { outline: none; border-color: var(--fire); }
.form-input::placeholder { color: var(--text-3); }
select.form-input option { background: var(--bg-3); }
.btn-remove {
  background: none; border: none; color: var(--text-3); cursor: pointer;
  font-size: 12px; padding: 4px 8px; border-radius: var(--r);
  transition: color 0.14s;
}
.btn-remove:hover { color: var(--danger); }
.tab-bar { display: flex; gap: 6px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.tab-btn {
  padding: 7px 16px; background: none; border: 1px solid var(--border);
  color: var(--text-2); font-family: var(--ff-mono); font-size: 10px;
  letter-spacing: 0.08em; text-transform: uppercase; cursor: pointer;
  border-radius: var(--r); transition: all 0.14s;
}
.tab-btn:hover { border-color: var(--border-hi); color: var(--text); }
.tab-btn.active { background: var(--fire-dim); border-color: var(--fire); color: var(--fire); }
.btn-green {
  background: rgba(77,255,170,0.12); border: 1px solid var(--forge-green);
  color: var(--forge-green); padding: 7px 14px; border-radius: var(--r);
  font-family: var(--ff-mono); font-size: 10px; cursor: pointer;
  transition: all 0.14s;
}
.btn-green:hover { background: rgba(77,255,170,0.2); }

/* ── NAV GROUP SEPARATOR ── */
.nav-group + .nav-group { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }

/* ── ACTIVE SESSION OVERLAY ── */
.active-session-overlay {
  position: absolute; inset: 0; z-index: 100;
  background: var(--bg); overflow-y: auto;
  padding: 24px 32px; box-sizing: border-box;
}
.session-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 16px; flex-wrap: wrap; gap: 12px;
  padding-bottom: 16px; border-bottom: 1px solid var(--border);
}
.session-timer-wrap { text-align: right; }
.session-volume-bar {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--r); padding: 8px 14px;
  margin-bottom: 20px; flex-wrap: wrap;
  font-family: var(--ff-mono); font-size: 11px;
}
.session-ex-block {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--r2); padding: 16px 18px;
  margin-bottom: 14px;
}
.session-ex-header {
  display: flex; align-items: flex-start; gap: 12px;
  margin-bottom: 12px; flex-wrap: wrap;
}
.session-ex-name {
  font-family: var(--ff-mono); font-size: 15px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.overload-suggest {
  font-family: var(--ff-mono); font-size: 10px; color: var(--forge-green);
  margin-top: 4px; opacity: 0.85;
}
.set-rows-header {
  display: flex; gap: 8px; align-items: center;
  padding: 4px 0 6px; border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.set-row {
  display: flex; gap: 8px; align-items: center;
  padding: 7px 0; border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.set-row-done { background: rgba(77,255,170,0.03); }
.set-num  { font-family: var(--ff-mono); font-size: 11px; color: var(--text-3); width: 28px; }
.set-val  { font-family: var(--ff-mono); font-size: 12px; flex: 1; }
.set-rir  { font-family: var(--ff-mono); font-size: 10px; color: var(--text-3); width: 56px; }
.set-done-badge { color: var(--forge-green); font-size: 12px; }
.set-input-row {
  display: flex; gap: 8px; align-items: center;
  padding: 10px 0; margin-top: 4px;
}
.set-input {
  background: var(--bg-3); border: 1px solid var(--border);
  color: var(--text); font-family: var(--ff-mono); font-size: 13px;
  padding: 7px 10px; border-radius: var(--r); flex: 1; min-width: 60px;
  transition: border-color 0.14s;
}
.set-input:focus { outline: none; border-color: var(--fire); }
.set-input.input-error { border-color: var(--danger); animation: shake 0.3s; }
.rir-selector { display: flex; gap: 3px; width: 90px; flex-shrink: 0; }
.rir-btn {
  padding: 5px 6px; background: var(--bg-3); border: 1px solid var(--border);
  color: var(--text-3); font-family: var(--ff-mono); font-size: 9px;
  border-radius: var(--r); cursor: pointer; transition: all 0.1s; line-height: 1;
}
.rir-btn:hover { border-color: var(--steel); color: var(--steel); }
.rir-btn.active { background: rgba(122,179,200,0.15); border-color: var(--steel); color: var(--steel); }
.btn-log-set {
  padding: 8px 12px; background: var(--forge-green); border: none;
  color: var(--bg); font-weight: 700; font-size: 14px;
  border-radius: var(--r-md); cursor: pointer; transition: opacity 0.14s;
  flex-shrink: 0;
}
.btn-log-set:hover { opacity: 0.85; }
.session-notes-wrap { margin-top: 24px; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* ── PR TOAST ── */
.pr-toast {
  position: fixed; bottom: -80px; left: 50%; transform: translateX(-50%);
  background: var(--bg-4); border: 1px solid var(--forge-green);
  color: var(--forge-green); font-family: var(--ff-mono); font-size: 12px;
  padding: 12px 20px; border-radius: 40px; z-index: 9999;
  transition: bottom 0.4s ease; white-space: nowrap; max-width: 90vw;
  overflow: hidden; text-overflow: ellipsis;
}
.pr-toast.show { bottom: 32px; }

/* ── SESSION SUMMARY TOAST ── */
.session-summary-toast {
  position: fixed; bottom: -200px; right: 24px;
  background: var(--bg-4); border: 1px solid var(--fire);
  padding: 20px 24px; border-radius: var(--r2); z-index: 9999;
  width: 280px; transition: bottom 0.4s ease;
  box-shadow: var(--shadow);
}
.session-summary-toast.show { bottom: 24px; }

/* ── NUTRITION PAGE ── */
.macro-ring-wrap {
  position: relative; display: flex; justify-content: center;
  align-items: center; height: 180px;
}
.macro-ring-center {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%); text-align: center;
  pointer-events: none;
}
.macro-bars { }
.food-form-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px,1fr)); gap: 10px;
}
.food-entry-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.food-entry-row:last-child { border-bottom: none; }
.water-tracker { }
.water-glasses { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.water-glass {
  background: none; border: 1px solid var(--border); border-radius: var(--r);
  font-size: 20px; padding: 4px 6px; cursor: pointer; transition: all 0.12s;
  line-height: 1;
}
.water-glass:hover { border-color: var(--steel); }
.water-glass.filled { border-color: var(--steel); background: rgba(122,179,200,0.1); }

/* ── BODY STATS PAGE ── */
.checkin-form { }
.measurement-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px,1fr)); gap: 8px;
}

/* ── ACHIEVEMENTS PAGE ── */
.streak-flame { font-size: 56px; line-height: 1; }
.achievement-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px,1fr));
  gap: 12px; margin-bottom: 24px;
}
.achievement-badge {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--r2); padding: 16px 12px; text-align: center;
  transition: border-color 0.14s;
}
.achievement-badge.unlocked { border-color: var(--fire-glow); }
.achievement-badge.locked { opacity: 0.45; }
.badge-icon { font-size: 28px; margin-bottom: 8px; }
.badge-label {
  font-family: var(--ff-mono); font-size: 11px; font-weight: 700;
  color: var(--text); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.06em;
}
.badge-desc { font-size: 11px; color: var(--text-2); line-height: 1.4; }
.badge-date { font-family: var(--ff-mono); font-size: 9px; color: var(--text-3); margin-top: 6px; }
.pr-card {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--r2); padding: 16px;
  transition: border-color 0.14s;
}
.pr-card:hover { border-color: var(--fire-glow); }

/* ── STREAK CALENDAR ── */
.streak-calendar {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--r2); padding: 16px; overflow-x: auto;
}
.cal-dow-labels {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 3px; margin-bottom: 4px;
}
.cal-dow-labels span {
  font-family: var(--ff-mono); font-size: 9px; color: var(--text-3);
  text-align: center;
}
.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px;
}
.cal-cell {
  width: 100%; aspect-ratio: 1; border-radius: 2px;
  background: var(--bg-3); border: 1px solid var(--border);
  min-width: 12px;
}
.cal-cell.active { background: var(--fire); border-color: var(--fire); opacity: 0.8; }
.cal-cell.today  { border-color: var(--forge-green) !important; }

/* ── CARDIO LOG ── */
.cardio-entry-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.cardio-entry-row:last-child { border-bottom: none; }
.cardio-icon { font-size: 24px; width: 32px; text-align: center; flex-shrink: 0; }

/* ── RESPONSIVE: mobile overlays ── */
@media (max-width: 768px) {
  /* Active session overlay sits below topbar */
  .active-session-overlay { padding: 72px 12px 32px; }
  .set-input-row { flex-wrap: wrap; }
  .rir-selector { width: auto; }
  /* Toasts — no bottom nav to clear */
  .pr-toast.show { bottom: 16px; }
  .session-summary-toast { right: 8px; left: 8px; width: auto; }
  .session-summary-toast.show { bottom: 16px; }
  .achievement-grid { grid-template-columns: repeat(auto-fill, minmax(110px,1fr)); }
  .pr-board-grid { grid-template-columns: 1fr 1fr; }
  .rest-timer-bar { bottom: 0; left: 0; right: 0; border-radius: 0; border-left: none; border-right: none; }
  .theme-picker { grid-template-columns: repeat(3, 1fr); }
}

/* ── BACKUP / RESTORE CARD ── */
.backup-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px;
}
.btn-backup {
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--r2); padding: 20px 12px; text-align: center;
  cursor: pointer; color: var(--text); width: 100%;
  transition: border-color 0.14s, background 0.14s;
}
.btn-backup:hover { border-color: var(--fire-glow); background: var(--fire-dim); }
.btn-backup-icon { font-size: 32px; margin-bottom: 8px; }
.btn-backup-label { font-family: var(--ff-mono); font-size: 13px; font-weight: 700; margin-bottom: 3px; text-transform: uppercase; letter-spacing: 0.06em; }
.btn-backup-desc { font-size: 11px; color: var(--text-3); }

/* ── REST TIMER BAR ── */
.rest-timer-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--bg-4); border-top: 2px solid var(--forge-green);
  padding: 10px 20px; z-index: 500;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.5);
  animation: slideUp 0.25s ease;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
.rest-timer-bar.urgent { border-top-color: var(--fire); }
.rest-timer-bar.urgent .rest-countdown { color: var(--fire); }
.rest-label { font-family: var(--ff-mono); font-size: 10px; letter-spacing: 0.15em; color: var(--text-3); white-space: nowrap; }
.rest-countdown {
  font-family: var(--ff-mono); font-size: 32px; font-weight: 700;
  color: var(--forge-green); line-height: 1; min-width: 72px;
  letter-spacing: 0.04em;
}
.rest-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.rest-btn {
  padding: 6px 12px; font-size: 11px; border-radius: var(--r);
  background: var(--bg-3); border: 1px solid var(--border);
  color: var(--text); cursor: pointer; font-family: var(--ff-mono);
  transition: all 0.12s;
}
.rest-btn:hover { background: var(--bg-2); border-color: var(--border-hi); }
.rest-skip { color: var(--text-3); }
.rest-done-flash {
  font-family: var(--ff-mono); font-size: 32px; font-weight: 700;
  color: var(--fire); letter-spacing: 0.08em; animation: restPulse 0.5s ease infinite alternate;
  text-transform: uppercase;
}
@keyframes restPulse {
  from { opacity: 1; } to { opacity: 0.4; }
}

/* ── MUSCLE TAGS in active session ── */
.ex-muscles-row { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; margin-bottom: 4px; }
.muscle-tag {
  font-family: var(--ff-mono); font-size: 9px; letter-spacing: 0.12em;
  text-transform: uppercase; padding: 2px 6px; border-radius: 2px;
  background: rgba(255,107,26,0.1); border: 1px solid rgba(255,107,26,0.2);
  color: var(--fire);
}
.muscle-tag.secondary {
  background: rgba(122,179,200,0.08); border-color: rgba(122,179,200,0.2);
  color: var(--steel);
}
.ex-cues {
  margin-top: 6px; border-top: 1px solid var(--border); padding-top: 8px;
}
.ex-cues summary {
  font-family: var(--ff-mono); font-size: 10px; letter-spacing: 0.12em;
  color: var(--text-3); cursor: pointer; user-select: none;
  list-style: none; display: flex; align-items: center; gap: 6px;
}
.ex-cues summary::-webkit-details-marker { display: none; }
.ex-cues summary::before { content: '▶'; font-size: 8px; transition: transform 0.15s; }
details[open] .ex-cues summary::before { transform: rotate(90deg); }
.ex-cues ul { margin: 8px 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.ex-cues li { font-size: 12px; color: var(--text-2); line-height: 1.4; }

/* ── CHART WRAP ── */
.chart-wrap canvas { display: block; }

/* ══ THEME PICKER ══ */
.theme-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px;
}
.theme-swatch {
  background: var(--bg-2);
  border: 2px solid var(--border);
  border-radius: var(--r2);
  padding: 0;
  cursor: pointer;
  text-align: center;
  overflow: hidden;
  transition: border-color 0.2s, transform 0.15s;
}
.theme-swatch:hover { border-color: var(--border-hi); transform: translateY(-2px); }
.theme-swatch.active { border-color: var(--fire); }
.theme-swatch.active .swatch-name { color: var(--fire); }

.swatch-preview {
  height: 52px;
  display: flex;
  position: relative;
  overflow: hidden;
}
.swatch-bg    { flex: 1; }
.swatch-accent { width: 28px; flex-shrink: 0; }
/* diagonal split overlay */
.swatch-preview::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, transparent 48%, rgba(0,0,0,0.25) 48%);
  pointer-events: none;
}

.swatch-name {
  font-family: var(--ff-mono);
  font-weight: 700; font-size: 11px;
  color: var(--text);
  padding: 6px 4px 2px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.swatch-desc {
  font-family: var(--ff-mono);
  font-size: 9px; color: var(--text-3);
  padding: 0 4px 8px;
  letter-spacing: 0.08em;
}
.swatch-check {
  display: none;
  color: var(--fire); font-size: 11px; margin-bottom: 6px;
}
.theme-swatch.active .swatch-check { display: block; }

@media (max-width: 768px) {
  .theme-picker { grid-template-columns: repeat(3, 1fr); }
}

/* ══ EXERCISE ANIMATED PREVIEW (free-exercise-db) ══ */
.ex-gif-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--bg-3);
  border: 1px solid var(--border);
  margin-bottom: 6px;
}
.ex-gif-wrap img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.ex-gif-wrap .frame-0 { animation: gifFlip 2s step-end infinite; }
.ex-gif-wrap .frame-1 { animation: gifFlip 2s step-end infinite reverse; }
@keyframes gifFlip {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}
.ex-gif-source {
  font-family: var(--ff-mono);
  font-size: 9px;
  color: var(--text-3);
  text-align: right;
  margin-bottom: 20px;
  letter-spacing: 0.06em;
}

/* ── CALISTHENICS category tag ── */
.t-cali {
  background: rgba(77,255,170,0.1);
  color: var(--forge-green);
  border: 1px solid rgba(77,255,170,0.25);
}

/* ── CALISTHENICS exercise cards ── */
.cali-ex-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.cali-ex-card:hover {
  border-color: var(--fire);
  background: rgba(255,107,26,0.05);
}
.card-locked {
  pointer-events: none;
}
.cali-circuit-card {
  transition: border-color 0.15s, background 0.15s;
}
.cali-circuit-card:hover {
  border-color: var(--fire);
  background: rgba(255,107,26,0.05);
}

/* ═══════════════════════════════════════════
   v2.7 ADDITIONS — Fasting, Sleep, Activity, Analytics
═══════════════════════════════════════════ */

/* ── STATS STRIP ── */
.stats-strip {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  padding: 5px 16px;
  font-family: var(--ff-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  overflow-x: auto;
  white-space: nowrap;
  position: sticky;
  top: 56px;
  z-index: 90;
  scrollbar-width: none;
}
.stats-strip::-webkit-scrollbar { display: none; }
.strip-item {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 14px;
  border-right: 1px solid var(--border);
  color: var(--text-2);
}
.strip-item:first-child { padding-left: 0; }
.strip-item:last-child  { border-right: none; }
@media (min-width: 769px) {
  .stats-strip { top: 0; }
  /* push main content down to account for strip height */
  .shell { margin-top: 0; }
}
/* On mobile, pages need extra top padding for topbar + strip */
@media (max-width: 768px) {
  .page { padding-top: 110px !important; }
}

/* ── FASTING RING ── */
.fast-ring-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px 0 8px;
}
.fast-ring { display: block; }
.fast-status {
  font-family: var(--ff-mono);
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  text-align: center;
}
.metabolic-timeline {
  display: flex;
  width: 100%;
  height: 36px;
  border-radius: var(--r-sm);
  overflow: hidden;
  margin: 12px 0 4px;
  border: 1px solid var(--border);
}
.met-phase {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--ff-mono);
  font-size: 8px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-right: 1px solid var(--bg);
  transition: opacity 0.3s;
  overflow: hidden;
}
.met-phase.current {
  outline: 2px solid var(--fire);
  outline-offset: -2px;
  opacity: 1 !important;
}

/* ── SLEEP & ACTIVITY HEATMAP ── */
.sleep-heatmap {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
  margin: 4px 0;
}
.sleep-cell {
  aspect-ratio: 1;
  border-radius: var(--r-sm);
  background: var(--bg-3);
  transition: background 0.2s;
}

/* ── GOAL RINGS (ANALYTICS) ── */
.goal-rings-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  padding: 8px 0;
}
.goal-ring-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.goal-ring-label {
  font-family: var(--ff-mono);
  font-size: 8px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
  text-align: center;
  max-width: 72px;
}

/* ── DIET PROGRAM ACCORDION ── */
details summary::-webkit-details-marker { display: none; }
details[open] summary span:last-child { transform: rotate(180deg); display: inline-block; }

/* ── FOOD FORM GRID (wider with meal tag) ── */
.food-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
  align-items: end;
}

/* ══════════════════════════════════════════
   HIIT MODULE
══════════════════════════════════════════ */

/* Tab bar */
.hiit-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.hiit-tab {
  font-family: var(--ff-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 10px 18px;
  border: none;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
.hiit-tab:hover { color: var(--text); }
.hiit-tab.active { color: var(--fire); border-bottom-color: var(--fire); }

/* Stats row */
.hiit-stats-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.hiit-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 8px 16px;
  min-width: 64px;
}
.hiit-stat-v {
  font-family: var(--ff-mono);
  font-size: 22px;
  font-weight: 700;
  color: var(--fire);
  line-height: 1;
}
.hiit-stat-k {
  font-size: 9px;
  color: var(--text-2);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 2px;
}

/* Week switcher */
.hiit-week-switcher {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.hiit-wk-btn {
  font-family: var(--ff-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.hiit-wk-btn:hover { border-color: var(--fire); color: var(--fire); }
.hiit-wk-btn.active {
  background: var(--fire);
  border-color: var(--fire);
  color: var(--bg);
  font-weight: 700;
}

/* Day grid */
.hiit-day-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

/* Day card */
.hiit-day-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  transition: border-color 0.2s;
}
.hiit-day-card.is-today { border-color: var(--fire); }
.hiit-day-card.is-done  { border-color: var(--forge-green); }

.hiit-day-hdr {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
}
.hiit-day-name {
  font-family: var(--ff-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
}
.hiit-type-tag {
  font-family: var(--ff-mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  padding: 3px 7px;
  border-radius: var(--r-sm);
  text-transform: uppercase;
}

/* Exercise list */
.hiit-ex-list { padding: 8px 12px; }
.hiit-ex-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.hiit-ex-item:last-child { border-bottom: none; }
.hiit-ex-chk {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  border: 1px solid var(--border);
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.hiit-ex-chk.on { background: var(--fire); border-color: var(--fire); }
.hiit-ex-chk.on::after { content: '✓'; color: var(--bg); font-size: 10px; font-weight: 700; }
.hiit-ex-info { flex: 1; min-width: 0; }
.hiit-ex-name { font-size: 12px; font-weight: 500; }
.hiit-ex-meta { font-size: 10px; color: var(--text-2); margin-top: 1px; }
.hiit-demo-btn {
  font-family: var(--ff-mono);
  font-size: 9px;
  letter-spacing: 0.05em;
  padding: 3px 7px;
  border-radius: var(--r-sm);
  border: none;
  cursor: pointer;
  background: rgba(255, 0, 0, 0.15);
  color: #ff6b6b;
  flex-shrink: 0;
  transition: opacity 0.2s;
}
.hiit-demo-btn:hover { opacity: 0.7; }

/* Day card footer */
.hiit-day-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--bg-2);
  border-top: 1px solid var(--border);
}
.hiit-done-btn {
  font-size: 11px;
  font-weight: 700;
  padding: 5px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--forge-green);
  background: transparent;
  color: var(--forge-green);
  cursor: default;
  font-family: var(--ff-mono);
  letter-spacing: 0.08em;
}
.hiit-start-btn { font-size: 11px; padding: 5px 14px; }
.hiit-rest-body {
  padding: 16px 12px;
  text-align: center;
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.8;
}

/* HIIT workout modal overlay — fixed positioning, hidden by default */
.hiit-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(6px);
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
  animation: fadeIn 0.18s ease;
}
.hiit-modal-overlay.open { display: flex; }
.hiit-modal-overlay.open .hiit-modal { transform: scale(1); }

/* Workout modal card */
.hiit-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  width: 100%;
  max-width: 520px;
  max-height: 94dvh;
  overflow-y: auto;
  transform: scale(0.93);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.hiit-media-box {
  margin: 0 18px;
  border: 1px solid var(--border);
  border-radius: 0 var(--r-md) var(--r-md) var(--r-md);
  background: var(--bg-2);
  overflow: hidden;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Video/GIF tab buttons */
.hiit-vtab {
  font-family: var(--ff-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  padding: 5px 12px;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  border: 1px solid var(--border);
  border-bottom: none;
  background: var(--bg-2);
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.2s;
}
.hiit-vtab.active { background: var(--surface); color: var(--text); }

/* Rating buttons */
.hiit-rating-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text-2);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  font-family: var(--ff-mono);
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.hiit-rating-btn.active {
  background: var(--fire);
  border-color: var(--fire);
  color: var(--bg);
}

/* Exercise library card */
.hiit-ex-card { transition: border-color 0.2s, background-color 0.15s; }
.hiit-ex-card:hover { border-color: var(--fire) !important; background: rgba(255,107,26,0.04); }

/* Exercise frequency badge */
.hiit-freq-badge {
  margin-left: auto;
  background: rgba(255,107,26,0.15);
  color: var(--fire);
  border: 1px solid rgba(255,107,26,0.3);
  border-radius: var(--r-sm);
  padding: 2px 6px;
  font-size: 10px;
  font-family: var(--ff-mono);
  font-weight: 700;
  white-space: nowrap;
}

/* Build Workout — exercise picker cards */
.hiit-pick-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 12px 10px 10px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  user-select: none;
}
.hiit-pick-card:hover  { border-color: var(--fire); background: rgba(255,107,26,0.04); }
.hiit-pick-card:active { transform: scale(0.97); }
.hiit-pick-card.selected {
  border-color: var(--fire);
  background: rgba(255,107,26,0.1);
}
.hiit-pick-icon { font-size: 28px; line-height: 1; margin-bottom: 6px; }
.hiit-pick-name {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
  line-height: 1.3;
  margin-bottom: 3px;
}
.hiit-pick-meta { font-size: 10px; color: var(--text-3); font-family: var(--ff-mono); }
.hiit-pick-badge {
  position: absolute;
  top: 6px; right: 6px;
  background: var(--fire);
  color: var(--bg);
  font-size: 10px;
  font-weight: 700;
  font-family: var(--ff-mono);
  width: 18px; height: 18px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
}

/* Heatmap cells */
.hiit-hm-cell {
  aspect-ratio: 1;
  border-radius: 3px;
  background: var(--border);
}
.hiit-hm-cell.w1 { background: rgba(255, 107, 26, 0.25); }
.hiit-hm-cell.w2 { background: rgba(255, 107, 26, 0.50); }
.hiit-hm-cell.w3 { background: rgba(255, 107, 26, 0.75); }
.hiit-hm-cell.w4 { background: var(--fire); }

/* Confetti keyframe (safe to duplicate) */
@keyframes cfall {
  0%   { transform: translateY(-20px) rotate(0deg);   opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}
/* Exercise icon pulse in GIF fallback card */
@keyframes workout-pulse {
  0%, 100% { transform: scale(1);    }
  50%       { transform: scale(1.12); }
}
