/* BUILD 45 — training command center, v2.
   Dark OLED athletic theme. Motion rules: transform/opacity only, 150–350ms
   micro-interactions, infinite loops reserved for the exercise demos, and
   everything dies under prefers-reduced-motion. */
@font-face {
  font-family: 'Anton';
  src: url('/fonts/anton.woff2') format('woff2');
  font-display: swap;
}

:root {
  --bg: #0a0b0f;
  --bg2: #13151c;
  --bg3: #1b1e28;
  --line: #262a36;
  --line2: #303544;
  --txt: #eef0f4;
  --dim: #99a0b0;
  --faint: #5d6374;
  --hot: #ff5a36;
  --hot-dim: rgba(255, 90, 54, 0.14);
  --go: #28d17c;
  --go-dim: rgba(40, 209, 124, 0.13);
  --blue: #5b8cff;
  --purple: #a78bfa;
  --green: #34d399;
  --gray: #6b7280;
  --amb: #ff5a36;            /* ambient tint — set per workout type from JS */
  --pa: #ff5a36;             /* pictogram accent — set per workout type */
  --display: 'Anton', 'Avenir Next Condensed', 'Arial Narrow', sans-serif;
  --body: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
  --r: 18px;
  --spring: cubic-bezier(0.22, 1, 0.36, 1);
  --pop: cubic-bezier(0.18, 1.6, 0.4, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { height: 100%; }
body {
  background: var(--bg);
  color: var(--txt);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.45;
  height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
}

#shell {
  max-width: 480px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--bg);
  overflow: hidden;
}
@media (min-width: 520px) {
  body { background: #060708; }
  #shell { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}

/* ---------- ambient motion layer ---------- */
/* two soft color blobs drifting behind everything, tinted by today's workout */
#amb { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
#amb i {
  position: absolute;
  width: 340px; height: 340px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--amb) 0%, transparent 62%);
  opacity: 0.13;
  transition: background 0.8s;
  animation: amb-drift 26s ease-in-out infinite alternate;
  will-change: transform;
}
#amb i:first-child { top: -140px; left: -120px; }
#amb i:last-child {
  bottom: -100px; right: -140px;
  opacity: 0.09;
  animation-duration: 34s;
  animation-direction: alternate-reverse;
}
@keyframes amb-drift {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(70px, 50px) scale(1.25); }
}

#view {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: calc(env(safe-area-inset-top) + 14px) 16px calc(100px + env(safe-area-inset-bottom));
  position: relative;
  z-index: 1;
}

h1, h2, h3 { font-weight: 700; }
.display { font-family: var(--display); font-weight: 400; letter-spacing: 0.5px; }

/* ---------- tab bar ---------- */
#tabbar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  display: flex;
  background: rgba(13, 14, 19, 0.9);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 50;
}
/* sliding active indicator — one per bar, glides between tabs */
.tab-ind {
  position: absolute;
  top: 0; left: 0;
  width: calc(100% / 6);
  height: 3px;
  transform: translateX(calc(var(--ti, 0) * 100%));
  transition: transform 0.35s var(--spring);
  display: flex;
  justify-content: center;
  pointer-events: none;
}
.tab-ind i {
  width: 30px; height: 3px;
  border-radius: 0 0 3px 3px;
  background: var(--hot);
  box-shadow: 0 0 12px rgba(255, 90, 54, 0.8);
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 11px 0 8px;
  color: var(--faint);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.3px;
  border: none;
  background: none;
  cursor: pointer;
  transition: color 0.2s, transform 0.1s;
}
.tab svg { width: 22px; height: 22px; transition: transform 0.25s var(--pop); }
.tab:active { transform: scale(0.92); }
.tab.on { color: var(--hot); }
.tab.on svg { transform: translateY(-1px); }
#tabbar.fresh .tab.on svg { animation: pop 0.4s var(--pop); }

/* ---------- cards & common ---------- */
.card {
  background: linear-gradient(180deg, var(--bg2), rgba(19, 21, 28, 0.7));
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px;
  margin-bottom: 12px;
}
.sec-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--faint);
  margin: 22px 4px 10px;
}
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.dim { color: var(--dim); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.tiny { font-size: 11px; }
.hot { color: var(--hot); }
.go { color: var(--go); }

button { font-family: var(--body); color: inherit; border: none; background: none; font-size: inherit; cursor: pointer; }
.btn {
  display: block;
  width: 100%;
  padding: 15px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--hot), #ff7a36);
  color: #fff;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0.6px;
  text-align: center;
  position: relative;
  overflow: hidden;
  transition: transform 0.12s, filter 0.12s;
}
.btn:active { transform: scale(0.97); filter: brightness(1.15); }
.btn.done {
  background: linear-gradient(135deg, var(--go), #3fe492);
  animation: glow 1.7s ease-in-out infinite;
}
/* shimmer sweep across the ready-to-complete button */
.btn.done::after {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  width: 50%;
  left: -60%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  animation: sweep 2.2s ease-in-out infinite;
}
@keyframes sweep { 0%, 25% { left: -60%; } 70%, 100% { left: 120%; } }
@keyframes glow { 50% { box-shadow: 0 0 28px rgba(40, 209, 124, 0.5); } }
.btn.ghost { background: var(--bg3); color: var(--dim); font-weight: 600; animation: none; }
.btn.ghost::after { display: none; }
.btn svg { width: 16px; height: 16px; vertical-align: -3px; margin-right: 6px; }

/* press feedback everywhere */
.press { transition: transform 0.12s ease, background 0.15s, border-color 0.15s; cursor: pointer; }
.press:active { transform: scale(0.96); }

/* ---------- PIN screen ---------- */
#pin-screen[hidden] { display: none; }
#pin-screen {
  position: absolute;
  inset: 0;
  z-index: 100;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 26px;
  padding-bottom: env(safe-area-inset-bottom);
}
#pin-screen .logo {
  font-size: 44px;
  color: var(--txt);
  animation: logo-in 0.7s var(--spring) both;
}
@keyframes logo-in { from { opacity: 0; transform: translateY(18px) scale(0.92); letter-spacing: 6px; } }
#pin-screen .logo b { color: var(--hot); font-weight: 400; text-shadow: 0 0 24px rgba(255, 90, 54, 0.5); }
.pin-dots { display: flex; gap: 14px; height: 16px; }
.pin-dot {
  width: 13px; height: 13px;
  border-radius: 50%;
  border: 2px solid var(--faint);
  transition: all 0.15s;
}
.pin-dot.full { background: var(--hot); border-color: var(--hot); transform: scale(1.15); box-shadow: 0 0 10px rgba(255, 90, 54, 0.6); }
.pin-dots.shake { animation: shake 0.4s; }
@keyframes shake {
  20%, 60% { transform: translateX(-9px); }
  40%, 80% { transform: translateX(9px); }
}
.pin-pad { display: grid; grid-template-columns: repeat(3, 76px); gap: 14px; }
.pin-key {
  height: 76px;
  border-radius: 50%;
  background: var(--bg2);
  border: 1px solid var(--line);
  font-size: 26px;
  font-weight: 600;
  transition: transform 0.12s var(--pop), background 0.1s;
}
.pin-key:active { transform: scale(0.88); background: var(--bg3); }
.pin-key.ok { background: var(--hot); border-color: var(--hot); }
.pin-msg { height: 18px; font-size: 13px; color: var(--dim); }
.pin-msg.err { color: var(--hot); }

/* ---------- Today hero ---------- */
.hero { text-align: center; padding: 6px 0 2px; }
.hero-top { display: flex; align-items: center; justify-content: space-between; }
.day-arrow {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--bg2);
  border: 1px solid var(--line);
  color: var(--dim);
  font-size: 18px;
  transition: transform 0.12s var(--pop), opacity 0.2s;
}
.day-arrow:active { transform: scale(0.85); }
.day-arrow[disabled] { opacity: 0.25; cursor: default; }
.ring-wrap { position: relative; width: 172px; height: 172px; margin: 0 auto; }
.ring-wrap svg { transform: rotate(-90deg); }
.ring-track { stroke: var(--bg3); }
.ring-fill {
  transition: stroke-dashoffset 0.6s var(--spring);
  filter: drop-shadow(0 0 7px color-mix(in srgb, var(--rc, var(--hot)) 65%, transparent));
}
/* ring sweeps in from empty when a screen enters */
#view.enter .ring-fill { animation: ring-in 1s 0.1s var(--spring) backwards; }
@keyframes ring-in { from { stroke-dashoffset: var(--c); } to { stroke-dashoffset: var(--off); } }
.ring-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.ring-center .daynum { font-size: 58px; line-height: 1; }
.ring-center .of { font-size: 12px; color: var(--faint); letter-spacing: 2px; margin-top: 2px; }
.hero .wname {
  font-size: 22px;
  margin-top: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  text-shadow: 0 0 26px color-mix(in srgb, currentColor 45%, transparent);
}
.hero .meta-row { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 6px; font-size: 13px; color: var(--dim); }
.streak { color: var(--hot); font-weight: 700; display: inline-flex; align-items: center; gap: 3px; }
.flame { width: 15px; height: 15px; transform-origin: 50% 90%; animation: flick 1.1s ease-in-out infinite; }
@keyframes flick {
  0%, 100% { transform: scaleY(1) rotate(0deg); }
  30% { transform: scaleY(1.12) rotate(-2.5deg); }
  60% { transform: scaleY(0.94) rotate(2.5deg); }
}
.done-chip {
  display: inline-block;
  margin-top: 10px;
  padding: 5px 14px;
  border-radius: 999px;
  background: var(--go-dim);
  color: var(--go);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  animation: pop 0.4s var(--pop);
}

/* ---------- exercise cards ---------- */
.ex-card { padding: 0; overflow: hidden; transition: border-color 0.25s; }
.ex-card.open { border-color: color-mix(in srgb, var(--pa) 45%, var(--line)); }
.ex-head { display: flex; align-items: center; gap: 12px; padding: 13px 14px; width: 100%; text-align: left; }
.ex-pic {
  width: 52px; height: 52px;
  flex: none;
  background: var(--bg3);
  border-radius: 12px;
  padding: 4px;
}
.ex-pic .flow { display: none; }   /* motion arcs only show on the big stage */
.ex-name { font-weight: 700; font-size: 15px; }
.ex-sub { font-size: 12px; color: var(--dim); margin-top: 1px; }
.ex-prog { font-size: 12px; font-weight: 700; color: var(--faint); transition: color 0.2s; }
.ex-prog.full { color: var(--go); }
.chev { color: var(--faint); transition: transform 0.25s; font-size: 12px; }
.ex-card.open .chev { transform: rotate(180deg); }
.ex-body { display: none; border-top: 1px solid var(--line); padding: 12px 14px 14px; }
.ex-card.open .ex-body { display: block; animation: slidein 0.26s var(--spring); }
@keyframes slidein {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

/* the stage: big animated demo of the movement */
.ex-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 0 8px;
}
.ex-stage::before {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: 150px; height: 150px;
  transform: translate(-50%, -54%);
  border-radius: 50%;
  background: radial-gradient(circle, var(--pa) 0%, transparent 65%);
  opacity: 0.1;
  animation: stage-breathe 3.4s ease-in-out infinite;
}
@keyframes stage-breathe { 50% { transform: translate(-50%, -54%) scale(1.18); opacity: 0.16; } }
.ex-stage svg { width: 132px; height: 132px; position: relative; }
.stage-tempo {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1.6px;
  color: var(--faint);
  margin-top: 2px;
}
.stage-tempo b { color: var(--pa); }

.ex-cue { font-size: 12.5px; color: var(--dim); padding: 8px 10px; background: var(--bg3); border-radius: 10px; margin-bottom: 12px; }
.ex-cue b { color: var(--pa); }

.set-row { display: flex; align-items: center; gap: 8px; padding: 7px 0; }
.set-n { width: 20px; font-size: 12px; font-weight: 700; color: var(--faint); flex: none; }
.stepper { display: flex; align-items: center; background: var(--bg3); border-radius: 11px; overflow: hidden; flex: none; }
.stepper button {
  width: 36px; height: 40px;
  font-size: 19px;
  color: var(--dim);
  font-weight: 600;
  transition: background 0.1s;
}
.stepper button:active { background: var(--line); color: var(--txt); }
.stepper .val { min-width: 44px; text-align: center; font-weight: 700; font-size: 15px; }
.stepper .val span { font-size: 10px; color: var(--faint); font-weight: 600; }
.set-last { font-size: 10.5px; color: var(--faint); flex: 1; text-align: center; line-height: 1.3; min-width: 0; }
.beat {
  display: inline-block;
  font-size: 9px;
  font-weight: 800;
  color: var(--go);
  background: linear-gradient(100deg, var(--go-dim) 30%, rgba(40, 209, 124, 0.35) 50%, var(--go-dim) 70%);
  background-size: 220% 100%;
  border-radius: 5px;
  padding: 1px 5px;
  letter-spacing: 0.5px;
  animation: shimmer 1.8s linear infinite;
}
.beat.anim { animation: pop 0.4s var(--pop), shimmer 1.8s linear infinite; }
@keyframes shimmer { from { background-position: 130% 0; } to { background-position: -90% 0; } }

/* set tick: check draws itself in, ring bursts outward */
.set-done {
  width: 40px; height: 40px;
  flex: none;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: var(--bg3);
  position: relative;
  transition: all 0.15s;
}
.set-done svg { width: 17px; height: 17px; display: block; margin: 0 auto; }
.set-done svg path { fill: none; stroke: transparent; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; }
.set-done.on { background: var(--go); border-color: var(--go); }
.set-done.on svg path { stroke: #fff; stroke-dashoffset: 0; }
.set-done.on.anim { animation: pop 0.35s var(--pop); }
.set-done.on.anim svg path { animation: draw 0.3s 0.08s ease both; }
.set-done.on.anim::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 2px solid var(--go);
  animation: burst-ring 0.55s ease-out forwards;
}
@keyframes draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes burst-ring { from { opacity: 0.9; transform: scale(1); } to { opacity: 0; transform: scale(1.75); } }
@keyframes pop {
  0% { transform: scale(0.5); }
  60% { transform: scale(1.18); }
  100% { transform: scale(1); }
}
.last-line { font-size: 11px; color: var(--faint); margin-bottom: 8px; }
.optional-tag { font-size: 9px; font-weight: 800; color: var(--purple); letter-spacing: 1px; }

/* ---------- checklists (supps / posture) ---------- */
.check-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); width: 100%; text-align: left; cursor: pointer; }
.check-row:last-child { border-bottom: none; }
.check-box {
  width: 26px; height: 26px;
  flex: none;
  border-radius: 8px;
  border: 2px solid var(--faint);
  display: flex; align-items: center; justify-content: center;
  position: relative;
  transition: all 0.15s;
}
.check-box svg { width: 14px; height: 14px; }
.check-box svg path { fill: none; stroke: transparent; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; }
.check-row.on .check-box { background: var(--go); border-color: var(--go); }
.check-row.on .check-box svg path { stroke: #fff; stroke-dashoffset: 0; }
.check-row.on .check-box.anim { animation: pop 0.35s var(--pop); }
.check-row.on .check-box.anim svg path { animation: draw 0.3s 0.08s ease both; }
.check-row.on .check-box.anim::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 8px;
  border: 2px solid var(--go);
  animation: burst-ring 0.55s ease-out forwards;
}
.check-row.on .check-name { color: var(--dim); text-decoration: line-through; text-decoration-color: var(--faint); }
.check-name { font-weight: 600; font-size: 14px; }
.check-dose { font-size: 11.5px; color: var(--faint); }
.check-pic { width: 44px; height: 44px; flex: none; background: var(--bg3); border-radius: 10px; padding: 3px; }
.check-pic .flow { display: none; }

/* ---------- water ---------- */
.water-cups { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.cup {
  width: 30px; height: 38px;
  border-radius: 6px 6px 9px 9px;
  border: 2px solid var(--line);
  background: var(--bg3);
  position: relative;
  overflow: hidden;
  transition: transform 0.12s, border-color 0.25s;
}
.cup:active { transform: scale(0.88); }
.cup::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 0;
  background: linear-gradient(180deg, #7ba4ff, var(--blue));
  transition: height 0.25s ease;
}
.cup.full { border-color: var(--blue); }
.cup.full::after { height: 100%; }
.cup.full.anim::after { animation: cup-fill 0.5s var(--pop); }
@keyframes cup-fill {
  0% { height: 0; }
  65% { height: 115%; }
  100% { height: 100%; }
}

/* ---------- rest day ---------- */
.rest-card { padding: 22px 16px; }
.rest-fig svg { width: 120px; height: 120px; }
.zz {
  fill: var(--pa);
  font: 800 13px var(--body);
  opacity: 0;
  transform-box: fill-box;
  animation: zfloat 3.6s ease-in-out infinite;
}
.z2 { animation-delay: 1.2s; font-size: 15px; }
.z3 { animation-delay: 2.4s; font-size: 17px; }
@keyframes zfloat {
  0% { opacity: 0; transform: translateY(5px); }
  25% { opacity: 0.9; }
  60% { opacity: 0.5; }
  100% { opacity: 0; transform: translateY(-8px); }
}

/* ---------- rest timer sheet ---------- */
#sheet-veil {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 80;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
#sheet-veil.show { opacity: 1; pointer-events: auto; }
#timer-sheet {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 90;
  background: var(--bg2);
  border-radius: 24px 24px 0 0;
  border-top: 1px solid var(--line);
  padding: 22px 20px calc(26px + env(safe-area-inset-bottom));
  text-align: center;
  transform: translateY(105%);
  transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
}
#timer-sheet.show { transform: none; }
#timer-sheet .t-ring { position: relative; width: 150px; height: 150px; margin: 12px auto; }
#timer-sheet .t-ring svg { transform: rotate(-90deg); }
#timer-sheet .t-num { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 46px; }
#timer-sheet.urgent .t-num { animation: tick-pulse 1s ease-in-out infinite; }
@keyframes tick-pulse { 0%, 100% { transform: scale(1); } 14% { transform: scale(1.14); } }
#timer-sheet.zero .t-num { color: var(--go); animation: pop 0.45s var(--pop); }
.t-btns { display: flex; gap: 10px; margin-top: 8px; }
.t-btns .btn { flex: 1; padding: 12px; font-size: 14px; }

/* ---------- plan grid ---------- */
.plan-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 7px; }
.plan-dow { text-align: center; font-size: 10px; font-weight: 700; color: var(--faint); letter-spacing: 1px; }
.plan-cell {
  aspect-ratio: 1;
  border-radius: 12px;
  background: var(--bg2);
  border: 1.5px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  position: relative;
  transition: transform 0.1s;
}
.plan-cell:active { transform: scale(0.9); }
/* cells cascade in when the Plan screen enters */
#view.enter .plan-cell { animation: cell-in 0.32s var(--spring) both; animation-delay: calc(var(--i, 0) * 11ms); }
@keyframes cell-in { from { opacity: 0; transform: scale(0.6); } }
.plan-cell .n { font-size: 10px; color: var(--faint); font-weight: 600; }
.plan-cell .t { font-size: 16px; font-family: var(--display); }
.plan-cell.now { border-color: var(--hot); animation: now-pulse 2s ease-in-out infinite; }
#view.enter .plan-cell.now { animation: cell-in 0.32s var(--spring) both, now-pulse 2s 0.6s ease-in-out infinite; animation-delay: calc(var(--i, 0) * 11ms), 0.6s; }
@keyframes now-pulse {
  0%, 100% { box-shadow: 0 0 0 1.5px var(--hot); }
  50% { box-shadow: 0 0 0 1.5px var(--hot), 0 0 16px rgba(255, 90, 54, 0.45); }
}
.plan-cell.done .t { display: none; }
.plan-cell.done .ck { color: var(--go); font-size: 16px; font-weight: 800; }
.plan-cell.future { opacity: 0.6; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 14px; justify-content: center; }
.legend .row { gap: 5px; font-size: 11.5px; color: var(--dim); }
.swatch { width: 10px; height: 10px; border-radius: 3px; }

/* ---------- food ---------- */
.meal { display: flex; gap: 13px; align-items: flex-start; padding: 13px 0; border-bottom: 1px solid var(--line); }
.meal:last-child { border-bottom: none; }
.meal-n {
  width: 34px; height: 34px;
  flex: none;
  border-radius: 10px;
  background: var(--hot-dim);
  color: var(--hot);
  font-family: var(--display);
  font-size: 17px;
  display: flex; align-items: center; justify-content: center;
}
.target-big { font-size: 30px; line-height: 1.1; }
.swap-cat { margin-bottom: 10px; }
.chiprow { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip {
  font-size: 12px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--bg3);
  border: 1px solid var(--line);
  color: var(--dim);
}

/* ---------- progress ---------- */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: linear-gradient(180deg, var(--bg2), rgba(19, 21, 28, 0.7)); border: 1px solid var(--line); border-radius: var(--r); padding: 13px 14px; }
.stat .v { font-size: 27px; line-height: 1.1; display: flex; align-items: center; gap: 2px; }
.stat .v .flame { width: 19px; height: 19px; margin-left: 3px; }
.stat .k { font-size: 10.5px; color: var(--faint); letter-spacing: 1px; text-transform: uppercase; font-weight: 700; margin-top: 3px; }
.chart-box { margin-top: 8px; }
.chart-box svg { display: block; width: 100%; }
/* charts draw themselves in on screen entry */
#view.enter .draw { stroke-dasharray: 1; animation: chart-draw 1.1s 0.2s ease-out both; }
@keyframes chart-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
#view.enter .pt { animation: pt-in 0.3s ease-out both; animation-delay: calc(0.25s + var(--i, 0) * 90ms); }
@keyframes pt-in { from { opacity: 0; } }
.spark-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.spark { background: var(--bg2); border: 1px solid var(--line); border-radius: 14px; padding: 11px 12px 8px; }
.spark .k { font-size: 11px; font-weight: 700; color: var(--dim); }
.spark .v { font-size: 13px; font-weight: 800; color: var(--hot); margin-top: 1px; }
.meas-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.meas-field label { font-size: 11px; color: var(--faint); font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; }
.meas-field input {
  width: 100%;
  margin-top: 4px;
  padding: 11px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--bg3);
  color: var(--txt);
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  -webkit-user-select: auto;
  user-select: auto;
}
table.meas { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.meas th { color: var(--faint); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.7px; text-align: right; padding: 5px 4px; }
table.meas td { padding: 6px 4px; text-align: right; border-top: 1px solid var(--line); }
table.meas th:first-child, table.meas td:first-child { text-align: left; }
.delta-up { color: var(--go); font-weight: 700; }
.delta-dn { color: var(--hot); font-weight: 700; }

.photo-pair { display: flex; gap: 10px; }
.photo-pair figure { flex: 1; margin: 0; }
.photo-pair img, .photo-grid img {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
  border-radius: 12px;
  background: var(--bg3);
}
.photo-pair figcaption { text-align: center; font-size: 11px; color: var(--faint); margin-top: 5px; font-weight: 700; letter-spacing: 1px; }
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.photo-grid .ph { position: relative; }
.photo-grid .ph .d {
  position: absolute;
  bottom: 5px; left: 5px;
  font-size: 9.5px;
  font-weight: 800;
  background: rgba(0, 0, 0, 0.65);
  padding: 2px 7px;
  border-radius: 6px;
}

/* ---------- toast & celebrate ---------- */
#toast {
  position: absolute;
  left: 50%;
  bottom: calc(110px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px) scale(0.92);
  background: var(--bg3);
  border: 1px solid var(--line2);
  color: var(--txt);
  font-size: 13.5px;
  font-weight: 600;
  padding: 11px 20px;
  border-radius: 999px;
  opacity: 0;
  transition: all 0.35s var(--spring);
  z-index: 95;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
}
#toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
#confetti { position: absolute; inset: 0; z-index: 99; pointer-events: none; }

#celebrate {
  position: absolute; inset: 0;
  z-index: 98;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(10, 11, 15, 0.9);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
#celebrate.show { display: flex; animation: fadein 0.3s; }
#celebrate .burst {
  position: absolute;
  width: 320px; height: 320px;
  animation: burst-rays 0.9s ease-out both;
}
#celebrate .burst line { stroke: var(--go); stroke-width: 3; stroke-linecap: round; }
@keyframes burst-rays {
  from { opacity: 0; transform: scale(0.3) rotate(-20deg); }
  35% { opacity: 0.9; }
  to { opacity: 0; transform: scale(1.25) rotate(8deg); }
}
#celebrate .big {
  font-size: 64px;
  color: var(--go);
  text-shadow: 0 0 40px rgba(40, 209, 124, 0.55);
  animation: slam 0.55s var(--pop) both;
}
@keyframes slam { from { opacity: 0; transform: scale(1.8); } }
#celebrate .sub { color: var(--dim); font-weight: 600; animation: rise 0.4s 0.25s var(--spring) backwards; }
@keyframes fadein { from { opacity: 0; } }

/* offline pill */
#net-pill {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 8px);
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 700;
  padding: 5px 13px;
  border-radius: 999px;
  background: #3a2a14;
  color: #f0a44b;
  z-index: 60;
  display: none;
}
#net-pill.show { display: block; animation: fadein 0.3s; }

/* ---------- pictogram motion ---------- */
.acc { stroke: var(--pa, #ff5a36); }
.pm, .pm2 { transform-box: view-box; }
/* rep cycle: explosive lift → 1s squeeze at the top → slow controlled lower.
   Matches the program's tempo cue (lower every rep 2–3s). */
.pm {
  animation: pm-rep var(--dur, 3.4s) infinite;
}
@keyframes pm-rep {
  0% {
    transform: translate(var(--tx0, 0px), var(--ty0, 0px)) rotate(var(--r0, 0deg)) scale(var(--sx0, 1), var(--sy0, 1));
    animation-timing-function: cubic-bezier(0.32, 0.02, 0.22, 1);
  }
  34% {
    transform: translate(var(--tx, 0px), var(--ty, 0px)) rotate(var(--r, 0deg)) scale(var(--sx, 1), var(--sy, 1));
    animation-timing-function: linear;
  }
  48% {
    transform: translate(var(--tx, 0px), var(--ty, 0px)) rotate(var(--r, 0deg)) scale(var(--sx, 1), var(--sy, 1));
    animation-timing-function: cubic-bezier(0.45, 0.04, 0.55, 0.96);
  }
  94%, 100% {
    transform: translate(var(--tx0, 0px), var(--ty0, 0px)) rotate(var(--r0, 0deg)) scale(var(--sx0, 1), var(--sy0, 1));
  }
}
/* stretch cycle: slow ease in, long hold, gentle release */
.pm.sl { animation: pm-stretch var(--dur, 5.2s) infinite; }
@keyframes pm-stretch {
  0% {
    transform: translate(var(--tx0, 0px), var(--ty0, 0px)) rotate(var(--r0, 0deg)) scale(var(--sx0, 1), var(--sy0, 1));
    animation-timing-function: cubic-bezier(0.45, 0, 0.3, 1);
  }
  40% {
    transform: translate(var(--tx, 0px), var(--ty, 0px)) rotate(var(--r, 0deg)) scale(var(--sx, 1), var(--sy, 1));
    animation-timing-function: linear;
  }
  72% {
    transform: translate(var(--tx, 0px), var(--ty, 0px)) rotate(var(--r, 0deg)) scale(var(--sx, 1), var(--sy, 1));
    animation-timing-function: cubic-bezier(0.5, 0, 0.5, 1);
  }
  100% {
    transform: translate(var(--tx0, 0px), var(--ty0, 0px)) rotate(var(--r0, 0deg)) scale(var(--sx0, 1), var(--sy0, 1));
  }
}
.pm-a, .pm-b { animation: pm-fade var(--dur, 4.6s) ease-in-out infinite alternate; }
.pm-b { animation-delay: calc(var(--dur, 4.6s) * -1); }
@keyframes pm-fade { from { opacity: 1; } to { opacity: 0; } }
/* motion-path guide: dashes flow along the movement direction */
.flow {
  stroke: var(--pa, #ff5a36);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-dasharray: 1 7;
  opacity: 0.45;
  animation: flow 1.3s linear infinite;
}
@keyframes flow { to { stroke-dashoffset: -8; } }

/* ---------- screen motion ---------- */
#view.enter > * { animation: rise 0.36s var(--spring) both; }
#view.enter > *:nth-child(2) { animation-delay: 0.04s; }
#view.enter > *:nth-child(3) { animation-delay: 0.08s; }
#view.enter > *:nth-child(4) { animation-delay: 0.12s; }
#view.enter > *:nth-child(5) { animation-delay: 0.16s; }
#view.enter > *:nth-child(6) { animation-delay: 0.19s; }
#view.enter > *:nth-child(7) { animation-delay: 0.22s; }
#view.enter > *:nth-child(n+8) { animation-delay: 0.25s; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

/* ---------- reduced motion: everything settles instantly ---------- */
@media (prefers-reduced-motion: reduce) {
  .pm, .pm.sl, .pm-a, .pm-b, .flow, .zz,
  #view.enter > *, #view.enter .plan-cell, #view.enter .ring-fill,
  #view.enter .draw, #view.enter .pt,
  .btn.done, .btn.done::after, .beat, .flame, .streak,
  #amb i, .ex-stage::before, .plan-cell.now,
  #celebrate .burst, #celebrate .big, #celebrate .sub,
  #timer-sheet.urgent .t-num, #pin-screen .logo {
    animation: none !important;
  }
  .pm-b { opacity: 0; }
  .tab-ind { transition: none; }
}

/* ---------- mission (Why) tab ---------- */
.goal-row { display: flex; gap: 12px; align-items: flex-start; padding: 11px 0; border-bottom: 1px solid var(--line); }
.goal-row:last-child { border-bottom: none; }
.goal-ic {
  width: 38px; height: 38px;
  flex: none;
  border-radius: 11px;
  background: var(--hot-dim);
  color: var(--hot);
  display: flex; align-items: center; justify-content: center;
}
.goal-ic svg { width: 20px; height: 20px; }
.why-fig { display: flex; justify-content: center; margin: 4px 0 8px; }
.why-fig svg { width: 230px; }

.center { text-align: center; }
.mt8 { margin-top: 8px; }
.mt14 { margin-top: 14px; }
