/* ==========================================================================
   iron — design tokens & components
   Apple HIG materials + Emil Kowalski motion rules.
   Everything needed for first paint lives here; Tailwind is layout sugar only.
   ========================================================================== */

:root {
  --bg: #000000;
  --card: rgba(28, 28, 30, 0.65);
  --card-solid: #1c1c1e;
  --hairline: rgba(255, 255, 255, 0.08);
  --fill: rgba(118, 118, 128, 0.24);
  --fill-2: rgba(118, 118, 128, 0.16);
  --text: #ffffff;
  --text-2: rgba(235, 235, 245, 0.62);
  --text-3: rgba(235, 235, 245, 0.32);
  --green: #30D158;
  --green-soft: rgba(48, 209, 88, 0.16);
  --blue: #0A84FF;
  --blue-soft: rgba(10, 132, 255, 0.16);
  --orange: #FF9F0A;
  --orange-soft: rgba(255, 159, 10, 0.16);
  --red: #FF453A;
  --red-soft: rgba(255, 69, 58, 0.14);

  --ease: cubic-bezier(0.16, 1, 0.3, 1);      /* house curve: modals, tabs, cards */
  --ease-press: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1); /* small overshoot for checks */

  --r-card: 20px;
  --r-ctrl: 12px;
  --gutter: 16px;
  --header-h: 52px;
  --tab-h: 58px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, "Segoe UI", Roboto, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", system-ui, sans-serif;
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--bg); }
body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.35;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { background: none; border: 0; cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
a { color: inherit; text-decoration: none; touch-action: manipulation; }
svg { display: block; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ---------- press feedback (active:scale-[0.97]) ---------- */
.press { transition: transform 160ms var(--ease-press), opacity 160ms var(--ease-press), background-color 200ms ease, color 200ms ease; }
.press:active { transform: scale(0.97); }

/* ---------- splash ---------- */
#splash {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  background: var(--bg);
  transition: opacity 360ms var(--ease);
}
#splash.out { opacity: 0; pointer-events: none; }
#splash .logo-mark { animation: splash-in 520ms var(--ease) both; }
@keyframes splash-in { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: scale(1); } }

/* ---------- header ---------- */
#header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  height: calc(var(--header-h) + var(--safe-t));
  padding: var(--safe-t) var(--gutter) 0;
  background: rgba(0, 0, 0, 0.72);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid transparent;
  transition: border-color 200ms ease;
}
#header.scrolled { border-bottom-color: var(--hairline); }
.brand { display: inline-flex; padding: 4px 0; }
body[data-mode="workout"] #header { display: none; }

/* ---------- main ---------- */
#app {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 8px var(--gutter) calc(var(--tab-h) + var(--safe-b) + 40px);
  outline: none;
}
body[data-mode="workout"] #app { padding-top: calc(var(--safe-t) + 8px); padding-bottom: calc(var(--safe-b) + 140px); }
.view { animation: view-in 320ms var(--ease) both; }
@keyframes view-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.large-title {
  font-family: var(--font-display);
  font-size: 34px; font-weight: 700; letter-spacing: -0.025em; line-height: 1.1;
  margin: 8px 0 4px;
}
.subtitle { color: var(--text-2); font-size: 15px; margin-bottom: 20px; }
.section-label {
  font-size: 13px; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase;
  color: var(--text-2); margin: 28px 4px 10px;
}
.stack > * + * { margin-top: 12px; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: 13px; }
.footnote { font-size: 12px; color: var(--text-3); line-height: 1.45; }

/* ---------- cards (glass) ---------- */
.card {
  position: relative;
  background: var(--card);
  -webkit-backdrop-filter: blur(24px);
  backdrop-filter: blur(24px);
  border: 1px solid var(--hairline);
  border-radius: var(--r-card);
  padding: 16px;
}
.card-title { font-size: 17px; font-weight: 600; letter-spacing: -0.015em; }
.card-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
a.card, button.card { display: block; width: 100%; text-align: left; }
.card.tappable { transition: transform 160ms var(--ease-press), background-color 200ms ease; }
.card.tappable:active { transform: scale(0.985); }
@media (hover: hover) and (pointer: fine) { .card.tappable:hover { background: rgba(44, 44, 46, 0.7); } }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 50px; padding: 0 20px;
  border-radius: 14px;
  font-size: 17px; font-weight: 600; letter-spacing: -0.01em;
  white-space: nowrap;
}
.btn svg { width: 20px; height: 20px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--green); color: #000; }
.btn-secondary { background: var(--blue-soft); color: var(--blue); }
.btn-tinted { background: var(--fill-2); color: var(--text); }
.btn-danger { background: var(--red-soft); color: var(--red); }
.btn-ghost { background: transparent; color: var(--blue); padding: 0 8px; }
.btn-sm { height: 34px; padding: 0 14px; border-radius: 999px; font-size: 15px; }
.btn[disabled] { opacity: 0.4; pointer-events: none; }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; border-radius: 999px;
  background: var(--fill-2); color: var(--text-2);
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.bare { background: transparent; }
@media (hover: hover) and (pointer: fine) {
  .btn-tinted:hover, .icon-btn:hover { background: var(--fill); }
}

/* ---------- segmented control ---------- */
.seg {
  position: relative; display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  padding: 2px; border-radius: 10px; background: var(--fill-2);
  isolation: isolate;
}
.seg-thumb {
  position: absolute; z-index: -1; top: 2px; bottom: 2px; left: 2px;
  width: calc((100% - 4px) / var(--n, 2));
  border-radius: 8px; background: #636366;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 3px 1px rgba(0, 0, 0, 0.04);
  transform: translateX(calc(100% * var(--i, 0)));
  transition: transform 320ms var(--ease);
}
.seg-btn { height: 32px; padding: 0 14px; font-size: 14px; font-weight: 600; color: var(--text); border-radius: 8px; }
.seg-btn[aria-pressed="false"] { color: var(--text-2); }
.seg-sm .seg-btn { height: 26px; padding: 0 10px; font-size: 12px; letter-spacing: 0.02em; }
.seg-block { display: grid; width: 100%; }

/* ---------- chips ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--gutter)); padding: 2px var(--gutter); overscroll-behavior-x: contain; scroll-snap-type: x proximity; }
.chips::-webkit-scrollbar { display: none; }
/* Fade the trailing edge so it's obvious more muscles are off-screen. */
.chips { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 40px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 40px), transparent); }
.chip {
  flex: none; height: 32px; padding: 0 14px; border-radius: 999px;
  background: var(--fill-2); color: var(--text); font-size: 14px; font-weight: 500;
  scroll-snap-align: start;
}
.chip[aria-pressed="true"] { background: var(--green); color: #000; }
.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 12px; font-weight: 600; background: var(--fill-2); color: var(--text-2); }
.tag-green { background: var(--green-soft); color: var(--green); }
.tag-blue { background: var(--blue-soft); color: var(--blue); }

/* ---------- inputs ---------- */
.field { display: grid; gap: 6px; align-content: start; }
.field-label { font-size: 13px; color: var(--text-2); padding-left: 4px; }
.input {
  width: 100%; height: 44px; padding: 0 12px;
  border-radius: var(--r-ctrl); border: 1px solid transparent;
  background: var(--fill-2);
  font-size: 17px; /* >=16px: prevents iOS zoom */
  outline: none;
  transition: border-color 160ms ease, background-color 160ms ease;
}
.input::placeholder { color: var(--text-3); }
.input:focus { border-color: var(--blue); background: var(--fill); }
.input[aria-invalid="true"] { border-color: var(--red); }
.input-wrap { position: relative; }
.input-wrap > svg { position: absolute; left: 12px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.input-wrap > .input { padding-left: 38px; }
.field-error { font-size: 13px; color: var(--red); padding-left: 4px; min-height: 0; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ---------- lists ---------- */
.list { background: var(--card); border: 1px solid var(--hairline); border-radius: var(--r-card); -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px); overflow: hidden; }
.list-row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  min-height: 56px; padding: 10px 16px; text-align: left;
  transition: background-color 160ms ease;
}
.list-row + .list-row { border-top: 1px solid var(--hairline); }
.list-row:active { background: rgba(255, 255, 255, 0.05); }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .title { font-size: 17px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .meta { font-size: 13px; color: var(--text-2); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row > svg.chev { width: 18px; height: 18px; color: var(--text-3); flex: none; }

/* ---------- tab bar ---------- */
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tab-h) + var(--safe-b));
  padding: 6px 4px var(--safe-b);
  background: rgba(10, 10, 10, 0.72);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  backdrop-filter: saturate(180%) blur(24px);
  border-top: 1px solid var(--hairline);
  transition: transform 360ms var(--ease);
}
body[data-mode="workout"] #tabbar { transform: translateY(110%); }
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 3px;
  padding-top: 2px; color: var(--text-3); font-size: 10.5px; font-weight: 600; letter-spacing: 0.01em;
}
.tab svg { width: 26px; height: 26px; transition: transform 320ms var(--ease); }
.tab[aria-current="page"] { color: var(--green); }
.tab[aria-current="page"] svg { transform: translateY(-1px) scale(1.04); }

/* ---------- sheets (bottom modal) ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0; transition: opacity 320ms var(--ease);
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 61;
  max-width: 640px; margin: 0 auto;
  max-height: calc(100dvh - var(--safe-t) - 24px);
  display: flex; flex-direction: column;
  background: rgba(28, 28, 30, 0.92);
  -webkit-backdrop-filter: blur(30px) saturate(160%);
  backdrop-filter: blur(30px) saturate(160%);
  border: 1px solid var(--hairline); border-bottom: 0;
  border-radius: 24px 24px 0 0;
  transform: translateY(100%);
  transition: transform 420ms var(--ease);
  overscroll-behavior: contain;
}
.sheet.open { transform: translateY(0); }
.sheet-backdrop.open { opacity: 1; }
.sheet.closing { transition-duration: 240ms; }
.sheet-backdrop.closing { transition-duration: 240ms; }
.sheet-grabber { width: 36px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.22); margin: 8px auto 2px; flex: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 16px 12px; flex: none; }
.sheet-title { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.sheet-body { overflow-y: auto; padding: 0 16px calc(var(--safe-b) + 24px); -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.sheet-actions { display: grid; gap: 10px; margin-top: 20px; }
body.sheet-open { overflow: hidden; }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; top: calc(var(--safe-t) + 10px); z-index: 90;
  max-width: calc(100% - 32px);
  padding: 10px 16px; border-radius: 999px;
  background: rgba(44, 44, 46, 0.92);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  border: 1px solid var(--hairline);
  font-size: 15px; font-weight: 500;
  opacity: 0; transform: translate(-50%, -120%);
  transition: transform 380ms var(--ease), opacity 240ms ease;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- streak & heatmap ---------- */
.streak-num { font-family: var(--font-display); font-size: 56px; font-weight: 700; line-height: 1; letter-spacing: -0.03em; color: var(--green); }
.week-dots { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.week-dot { display: grid; justify-items: center; gap: 6px; font-size: 11px; font-weight: 600; color: var(--text-3); }
.week-dot i { width: 100%; max-width: 30px; aspect-ratio: 1; border-radius: 999px; background: var(--fill-2); display: block; }
.week-dot.on i { background: var(--green); }
.week-dot.today { color: var(--text); }
.week-dot.today i { box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.5); }
.week-dot.on.today i { box-shadow: none; }

.heatmap { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 1fr); gap: 3px; }
.heatmap-scroll { overflow-x: auto; scrollbar-width: none; direction: rtl; }
.heatmap-scroll::-webkit-scrollbar { display: none; }
.heatmap-scroll > * { direction: ltr; }
.heat { width: 12px; height: 12px; border-radius: 3px; background: rgba(255, 255, 255, 0.06); }
.heat.l1 { background: rgba(48, 209, 88, 0.38); }
.heat.l2 { background: rgba(48, 209, 88, 0.62); }
.heat.l3 { background: rgba(48, 209, 88, 0.85); }
.heat.l4 { background: var(--green); }
.heat.future { background: transparent; }
.heat.today { box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.55); }
.heatmap.lg { grid-auto-columns: minmax(0, 1fr); } /* 26 weeks always fit the card, no clipped column */
.heatmap.lg .heat { width: auto; height: auto; aspect-ratio: 1; }
.heatmap.sm .heat { width: 9px; height: 9px; border-radius: 2px; }
.heatmap.sm { gap: 2px; }

/* ---------- metrics ---------- */
.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.metric .label { font-size: 13px; color: var(--text-2); }
.metric .value { font-family: var(--font-display); font-size: 28px; font-weight: 700; letter-spacing: -0.02em; margin-top: 4px; }
.metric .value small { font-size: 15px; font-weight: 600; color: var(--text-2); margin-left: 2px; letter-spacing: 0; }
.metric .hint { font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* ---------- workout ---------- */
.wk-bar {
  position: sticky; top: 0; z-index: 15;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  margin: calc(-1 * (var(--safe-t) + 8px)) calc(-1 * var(--gutter)) 0;
  padding: calc(var(--safe-t) + 8px) var(--gutter) 8px;
  background: rgba(0, 0, 0, 0.78);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
}
.wk-bar .left { justify-self: start; } .wk-bar .right { justify-self: end; }
.wk-clock { font-size: 17px; font-weight: 600; }
.wk-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0 8px; }
.wk-stat .label { font-size: 12px; color: var(--text-2); font-weight: 500; }
.wk-stat .value { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; margin-top: 2px; }
.ex-card { padding: 14px 12px 10px; }
.ex-head { display: flex; align-items: flex-start; gap: 8px; padding: 0 4px; }
.ex-name { font-size: 17px; font-weight: 600; color: var(--green); text-align: left; letter-spacing: -0.015em; }
.ex-last { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.ex-target { font-size: 13px; color: var(--text-3); }
.set-grid { display: grid; grid-template-columns: 44px 1fr 1fr 48px; align-items: center; gap: 8px; }
.set-head { font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; padding: 12px 0 6px; }
.set-head > :nth-child(2), .set-head > :nth-child(3) { text-align: center; }
.set-row { padding: 4px 0; border-radius: 10px; transition: background-color 260ms ease; }
.set-row[data-done="true"] { background: rgba(48, 209, 88, 0.1); }
.set-idx { position: relative; display: grid; place-items: center; height: 36px; font-size: 15px; font-weight: 600; color: var(--text-2); }
.set-input {
  width: 100%; height: 36px; border-radius: 8px; border: 1px solid transparent;
  background: var(--fill-2); text-align: center; font-size: 17px; font-weight: 600;
  outline: none; transition: background-color 200ms ease, border-color 160ms ease;
}
.set-input::placeholder { color: var(--text-3); font-weight: 500; }
.set-input:focus { border-color: var(--blue); }
.set-row[data-done="true"] .set-input { background: transparent; }
.ex-actions { display: flex; gap: 8px; padding: 8px 4px 2px; }
.ex-actions .btn { flex: 1; }

/* checkbox: transitions only (no keyframes) so re-renders never replay */
.check {
  justify-self: center;
  display: grid; place-items: center;
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--fill-2); color: #000;
  transition: background-color 220ms ease, transform 160ms var(--ease-press);
}
.check:active { transform: scale(0.9); }
.check svg { width: 22px; height: 22px; opacity: 0; transform: scale(0.5); transition: transform 380ms var(--ease-spring), opacity 160ms ease; }
.check[aria-checked="true"] { background: var(--green); }
.check[aria-checked="true"] svg { opacity: 1; transform: scale(1); }

/* PR badge */
.pr-badge {
  position: absolute; top: -6px; right: -4px;
  height: 16px; padding: 0 5px; border-radius: 5px;
  background: var(--orange); color: #000;
  font-size: 9.5px; font-weight: 800; letter-spacing: 0.04em; line-height: 16px;
}
.pr-badge[data-new] { animation: pr-pop 520ms var(--ease-spring) both; }
@keyframes pr-pop { from { opacity: 0; transform: scale(0.6) translateY(4px); } to { opacity: 1; transform: none; } }
.pr-line { display: flex; align-items: center; gap: 8px; color: var(--orange); font-weight: 600; }

/* ---------- Dynamic Island rest timer ---------- */
#island {
  position: fixed; left: 50%; bottom: calc(var(--safe-b) + 18px); z-index: 50;
  transform: translate(-50%, 16px) scale(0.92);
  opacity: 0;
  transition: transform 460ms var(--ease), opacity 220ms ease;
  pointer-events: none;
}
#island.show { transform: translate(-50%, 0) scale(1); opacity: 1; pointer-events: auto; }
#island.hiding { transition-duration: 220ms; }
body:not([data-mode="workout"]) #island { bottom: calc(var(--tab-h) + var(--safe-b) + 12px); }
.island-inner {
  display: flex; align-items: center; gap: 6px;
  height: 56px; padding: 0 8px 0 10px;
  border-radius: 999px;
  background: #0b0b0c;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6), 0 0 0 0.5px rgba(255, 255, 255, 0.04) inset;
  transition: transform 300ms var(--ease-spring), border-color 300ms ease;
}
#island.done .island-inner { border-color: rgba(48, 209, 88, 0.6); transform: scale(1.04); }
.island-ring { width: 36px; height: 36px; transform: rotate(-90deg); flex: none; }
.ring-track { fill: none; stroke: rgba(48, 209, 88, 0.2); stroke-width: 3.5; }
.ring-fill { fill: none; stroke: var(--green); stroke-width: 3.5; stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: 0; }
.island-text { display: grid; line-height: 1.05; min-width: 64px; padding: 0 4px; }
.island-label { font-size: 11px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.06em; }
.island-time { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.island-btn { height: 36px; padding: 0 12px; border-radius: 999px; background: rgba(255, 255, 255, 0.1); font-size: 14px; font-weight: 600; }
.island-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 999px; background: rgba(255, 255, 255, 0.1); color: var(--text-2); }
.island-icon svg { width: 16px; height: 16px; }

/* ---------- anatomy ---------- */
.anatomy-stage { perspective: 1200px; display: grid; justify-items: center; padding: 4px 0 0; }
.anatomy-flip { position: relative; width: min(44vw, 172px); aspect-ratio: 200 / 404; transform-style: preserve-3d; transition: transform 620ms var(--ease); }
.anatomy-flip.back { transform: rotateY(180deg); }
.anatomy-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.anatomy-face.back-face { transform: rotateY(180deg); }
.anatomy-face svg { width: 100%; height: 100%; overflow: visible; }
.body-shape { fill: rgba(255, 255, 255, 0.045); stroke: rgba(255, 255, 255, 0.1); stroke-width: 1; pointer-events: none; }
.muscle { cursor: pointer; outline: none; }
.muscle path, .muscle rect { fill: rgba(255, 255, 255, 0.12); stroke: rgba(0, 0, 0, 0.6); stroke-width: 0.8; transition: fill 260ms ease; }
@media (hover: hover) and (pointer: fine) { .muscle:hover path, .muscle:hover rect { fill: rgba(255, 255, 255, 0.24); } }
.muscle:focus-visible path, .muscle:focus-visible rect { fill: rgba(10, 132, 255, 0.55); }
.muscle[aria-pressed="true"] path, .muscle[aria-pressed="true"] rect { fill: var(--green); }
.anatomy-caption { text-align: center; margin-top: 10px; font-size: 15px; font-weight: 600; min-height: 22px; }

/* ---------- news ---------- */
.news-card { display: block; }
.news-src { font-size: 12px; font-weight: 600; color: var(--green); text-transform: uppercase; letter-spacing: 0.05em; }
.news-title { font-size: 17px; font-weight: 600; letter-spacing: -0.015em; margin-top: 6px; line-height: 1.3; }
.news-sum { font-size: 15px; color: var(--text-2); margin-top: 6px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.spin { animation: spin 700ms linear infinite; } /* constant rotation is the one place linear is correct */
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- misc ---------- */
.avatar { width: 44px; height: 44px; border-radius: 999px; background: var(--fill); object-fit: cover; flex: none; display: grid; place-items: center; font-weight: 700; color: var(--text-2); }
.code-pill { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px; border-radius: 10px; background: var(--fill-2); font-weight: 700; letter-spacing: 0.06em; }
.empty { text-align: center; padding: 28px 16px; }
.empty .title { font-size: 17px; font-weight: 600; }
.empty p { color: var(--text-2); font-size: 15px; margin: 6px auto 16px; max-width: 32ch; }
.banner { display: flex; align-items: center; gap: 12px; background: var(--green-soft); border: 1px solid rgba(48, 209, 88, 0.25); }
.divider { height: 1px; background: var(--hairline); margin: 14px 0; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; font-size: 15px; }
.kv .k { color: var(--text-2); }
.steps { counter-reset: s; list-style: none; display: grid; gap: 10px; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 24px 1fr; gap: 10px; font-size: 15px; line-height: 1.45; }
.steps li::before { content: counter(s); display: grid; place-items: center; width: 24px; height: 24px; border-radius: 999px; background: var(--fill-2); font-size: 13px; font-weight: 700; color: var(--text-2); }
.tip { display: grid; grid-template-columns: 4px 1fr; gap: 12px; font-size: 15px; line-height: 1.45; }
.tip::before { content: ""; border-radius: 2px; background: var(--orange); }

/* ---------- motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  .view, #splash .logo-mark, .pr-badge[data-new] { animation: fade 200ms ease both; }
  .press:active, .card.tappable:active, .check:active { transform: none; }
  .anatomy-flip { transition: none; }
  .sheet { transition: opacity 200ms ease; transform: none; opacity: 0; }
  .sheet.open { opacity: 1; }
  #island, #island.show { transform: translate(-50%, 0); transition: opacity 200ms ease; }
  .seg-thumb, #tabbar, .tab svg, .check svg, .island-inner { transition-duration: 0ms; }
  #toast { transform: translate(-50%, 0); }
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- layout helpers (critical, so not left to the Tailwind CDN) ---------- */
.row { display: flex; align-items: center; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.card.banner { display: flex; align-items: center; text-align: left; }
.flame { width: 16px; height: 16px; }
.seg[data-empty] .seg-thumb { opacity: 0; }
.seg-thumb { transition: transform 320ms var(--ease), opacity 200ms ease; }

.btn-google { background: #fff; color: #1f1f1f; }
.btn-google svg { width: 18px; height: 18px; }

/* routine editor */
.ed-ex { padding: 12px 0 4px; border-top: 1px solid var(--hairline); margin-top: 12px; }
.ed-ex-name { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-mini { display: grid; gap: 4px; }
.ed-mini span { font-size: 11px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; padding-left: 2px; }
.ed-mini .input { height: 38px; text-align: center; padding: 0 6px; }

/* skeleton loaders */
.skel { height: 12px; border-radius: 6px; background: var(--fill-2); animation: skel 1.4s ease-in-out infinite; }
@keyframes skel { 50% { opacity: 0.45; } }
@media (prefers-reduced-motion: reduce) { .skel { animation: none; } }

@media (max-width: 360px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .set-grid { grid-template-columns: 36px 1fr 1fr 44px; gap: 6px; }
  .island-text { min-width: 54px; }
}

/* ---------- header actions, avatars, search ---------- */
.header-actions { display: flex; align-items: center; gap: 10px; }
.avatar-lg { width: 64px; height: 64px; font-size: 24px; }
.avatar-xl { width: 112px; height: 112px; font-size: 40px; }
.avatar-btn { position: relative; flex: none; border-radius: 999px; }
.avatar-btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.avatar-badge {
  position: absolute; right: -3px; bottom: -3px;
  display: grid; place-items: center; width: 20px; height: 20px; border-radius: 999px;
  background: var(--blue); color: #fff; border: 2px solid #1c1c1e;
}
.avatar-badge svg { width: 11px; height: 11px; }
.sheet.sheet-tall { height: calc(100dvh - var(--safe-t) - 24px); }
.sheet.sheet-tall .sheet-body { flex: 1; }
.list-row > .avatar { width: 36px; height: 36px; font-size: 15px; }

/* ---------- progress charts ---------- */
.ch-card { padding: 16px 16px 10px; }
.ch-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 8px; }
.ch-value { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.chart { position: relative; touch-action: pan-y; border-radius: 12px; outline: none; }
.chart:focus-visible { box-shadow: 0 0 0 2px var(--blue); }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.ch-grid { stroke: rgba(255, 255, 255, 0.08); stroke-width: 1; }
.ch-axis { fill: var(--text-3); font-size: 10px; font-variant-numeric: tabular-nums; }
.ch-label { fill: var(--text); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.ch-line { fill: none; stroke: var(--green); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ch-dot { fill: var(--green); stroke: #1c1c1e; stroke-width: 2; }
.ch-focus { fill: var(--green); stroke: #fff; stroke-width: 2; }
.ch-cross { stroke: rgba(255, 255, 255, 0.35); stroke-width: 1; stroke-dasharray: 3 3; }
.ch-tip {
  position: absolute; left: 0; top: 0; pointer-events: none; white-space: nowrap;
  padding: 6px 10px; border-radius: 10px; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
  background: rgba(58, 58, 60, 0.96); color: var(--text); border: 1px solid var(--hairline);
}
.chart.is-active .ch-label { opacity: 0; }
.spark { flex: none; }
.ex-suggest { display: flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; color: var(--text); margin-top: 2px; }
.ex-suggest[data-kind="increase"] svg { width: 14px; height: 14px; color: var(--green); }
