/* ============================================================
   GymTrace — design system
   Follows Apple HIG: semantic colors (light/dark/auto), iOS text
   styles, ≥44pt touch targets, safe areas, frosted bars, reduced
   motion support. Tab bar in compact width, sidebar in regular.
   ============================================================ */

/* ---------- Tokens ---------- */
:root {
  /* Semantic colors — light */
  --bg:            #f2f2f7;   /* systemGroupedBackground */
  --bg-card:       #ffffff;   /* secondarySystemGroupedBackground */
  --bg-card2:      #f2f2f7;   /* tertiarySystemGroupedBackground */
  --bg-elev:       #ffffff;
  --label:         #000000;
  --label2:        rgba(60,60,67,.60);
  --label3:        rgba(60,60,67,.30);
  --separator:     rgba(60,60,67,.29);
  --fill:          rgba(120,120,128,.20);
  --fill2:         rgba(120,120,128,.12);
  --accent:        #34c759;   /* systemGreen */
  --accent-dim:    rgba(52,199,89,.15);
  --on-accent:     #ffffff;
  --red:           #ff3b30;
  --red-dim:       rgba(255,59,48,.12);
  --orange:        #ff9500;
  --yellow:        #ffcc00;
  --cyan:          #32ade6;
  --blue:          #007aff;
  --purple:        #af52de;
  --pink:          #ff2d55;
  --bar-material:  rgba(249,249,249,.82);
  --grabber:       rgba(60,60,67,.30);
  --shadow-sheet:  0 -8px 40px rgba(0,0,0,.18);
  --shadow-pop:    0 12px 48px rgba(0,0,0,.22);

  /* Velocity zones (VBT) — always paired with a text label */
  --z-explosive: #32ade6;
  --z-fast:      #34c759;
  --z-moderate:  #ffcc00;
  --z-slow:      #ff9500;
  --z-grind:     #ff3b30;

  /* Goal gauges */
  --g-volume: #34c759;
  --g-sets:   #ff9500;
  --g-time:   #32ade6;

  /* Liquid Glass — functional layer material (controls & navigation only) */
  --glass-bg:       rgba(255,255,255,.52);
  --glass-bg-thick: rgba(255,255,255,.78);   /* sheets/alerts — more opaque for text */
  --glass-specular: rgba(255,255,255,.60);   /* inset top edge highlight */
  --glass-rim:      rgba(255,255,255,.28);   /* thin glass rim */
  --glass-sheen:    rgba(255,255,255,.22);   /* top-half light gradient (the "pure" look) */
  --glass-shadow:   0 8px 32px rgba(0,0,0,.10);
  --accent-glass:   color-mix(in srgb, var(--accent) 86%, transparent);  /* prominent tinted glass */
  --ease-apple: cubic-bezier(.28,.11,.32,1);

  --radius-card: 22px;
  --radius-btn: 999px;         /* Apple capsule */
  --hairline: 0.5px;
  --tap: 44px;                 /* HIG minimum touch target */

  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);

  --ease: cubic-bezier(.32,.72,0,1);   /* Apple sheet curve */
  --dur: .32s;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
          "Helvetica Neue", "Segoe UI", Roboto, Inter, sans-serif;
  --font-round: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont,
          "Helvetica Neue", "Segoe UI", Roboto, sans-serif;

  color-scheme: light dark;
}

/* Semantic colors — dark (elevated set) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:           #000000;
    --bg-card:      #1c1c1e;
    --bg-card2:     #2c2c2e;
    --bg-elev:      #2c2c2e;
    --label:        #ffffff;
    --label2:       rgba(235,235,245,.60);
    --label3:       rgba(235,235,245,.30);
    --separator:    rgba(84,84,88,.65);
    --fill:         rgba(120,120,128,.36);
    --fill2:        rgba(120,120,128,.20);
    --accent:       #30d158;
    --accent-dim:   rgba(48,209,88,.18);
    --red:          #ff453a;
    --red-dim:      rgba(255,69,58,.16);
    --orange:       #ff9f0a;
    --yellow:       #ffd60a;
    --cyan:         #64d2ff;
    --blue:         #0a84ff;
    --purple:       #bf5af2;
    --pink:         #ff375f;
    --bar-material: rgba(22,22,24,.80);
    --grabber:      rgba(235,235,245,.30);
    --glass-bg:       rgba(30,30,32,.52);
    --glass-bg-thick: rgba(28,28,30,.80);
    --glass-specular: rgba(255,255,255,.16);
    --glass-rim:      rgba(255,255,255,.09);
    --glass-sheen:    rgba(255,255,255,.075);
    --glass-shadow:   0 8px 32px rgba(0,0,0,.45);
    --accent-glass:   color-mix(in srgb, var(--accent) 74%, transparent);
    --z-explosive:  #64d2ff;
    --z-fast:       #30d158;
    --z-moderate:   #ffd60a;
    --z-slow:       #ff9f0a;
    --z-grind:      #ff453a;
    --g-volume:     #30d158;
    --g-sets:       #ff9f0a;
    --g-time:       #64d2ff;
  }
}
:root[data-theme="dark"] {
  --bg:           #000000;
  --bg-card:      #1c1c1e;
  --bg-card2:     #2c2c2e;
  --bg-elev:      #2c2c2e;
  --label:        #ffffff;
  --label2:       rgba(235,235,245,.60);
  --label3:       rgba(235,235,245,.30);
  --separator:    rgba(84,84,88,.65);
  --fill:         rgba(120,120,128,.36);
  --fill2:        rgba(120,120,128,.20);
  --accent:       #30d158;
  --accent-dim:   rgba(48,209,88,.18);
  --red:          #ff453a;
  --red-dim:      rgba(255,69,58,.16);
  --orange:       #ff9f0a;
  --yellow:       #ffd60a;
  --cyan:         #64d2ff;
  --blue:         #0a84ff;
  --purple:       #bf5af2;
  --pink:         #ff375f;
  --bar-material: rgba(22,22,24,.80);
  --grabber:      rgba(235,235,245,.30);
  --glass-bg:       rgba(30,30,32,.52);
  --glass-bg-thick: rgba(28,28,30,.80);
  --glass-specular: rgba(255,255,255,.16);
  --glass-rim:      rgba(255,255,255,.09);
  --glass-sheen:    rgba(255,255,255,.075);
  --glass-shadow:   0 8px 32px rgba(0,0,0,.45);
  --accent-glass:   color-mix(in srgb, var(--accent) 74%, transparent);
  --z-explosive:  #64d2ff;
  --z-fast:       #30d158;
  --z-moderate:   #ffd60a;
  --z-slow:       #ff9f0a;
  --z-grind:      #ff453a;
  --g-volume:     #30d158;
  --g-sets:       #ff9f0a;
  --g-time:       #64d2ff;
}

/* ---------- Liquid Glass material (functional layer only) ---------- */
.glass, .tabbar, .toast, .nav-head .ic-btn, .live-controls .btn.btn-gray {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
  box-shadow:
    var(--glass-shadow),
    inset 0 1px 0 var(--glass-specular),
    inset 0 0 0 .5px var(--glass-rim);
}
/* Thicker glass where there's real text to read (sheets, alerts) */
.sheet, .alert-box {
  background: var(--glass-bg-thick);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  backdrop-filter: blur(30px) saturate(180%);
}
/* Top-half light sheen — the surface gradient that makes glass read as glass */
.tabbar::before, .sidebar::before, .sheet::before, .alert-box::before,
.toast::before, .btn::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  border-radius: inherit;
  background: linear-gradient(180deg, var(--glass-sheen), transparent 55%);
  pointer-events: none;
}
.tabbar, .toast, .btn { position: relative; isolation: isolate; }
/* No backdrop-filter → solid fallback so text stays legible */
@supports not ((backdrop-filter: blur(4px)) or (-webkit-backdrop-filter: blur(4px))) {
  .glass, .tabbar, .toast, .nav-head .ic-btn, .live-controls .btn.btn-gray { background: var(--bg-card); }
  .sheet, .alert-box { background: var(--bg); }
  .exmedia .media-hint { background: rgba(0,0,0,.82); }
  .curve-overlay { background: rgba(8,10,9,.93); }
  .hud-pill, .hud-btn, .hud-weight { background: rgba(16,19,17,.92); }
}
@media (prefers-reduced-transparency: reduce) {
  .glass, .tabbar, .toast, .nav-head .ic-btn, .live-controls .btn.btn-gray {
    background: var(--bg-card);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .sheet, .alert-box { background: var(--bg); -webkit-backdrop-filter: none; backdrop-filter: none; }
  .exmedia .media-hint { background: rgba(0,0,0,.82); -webkit-backdrop-filter: none; backdrop-filter: none; }
  .curve-overlay { background: rgba(8,10,9,.93); -webkit-backdrop-filter: none; backdrop-filter: none; }
  .hud-pill, .hud-btn, .hud-weight { background: rgba(16,19,17,.92); -webkit-backdrop-filter: none; backdrop-filter: none; }
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-size: 1.0625rem;          /* Body — 17pt */
  line-height: 1.29;
  color: var(--label);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  isolation: isolate;            /* lets the ambient layer sit between bg and content */
}

/* Ambient ground — soft color light for the glass to refract.
   An opaque flat background defeats the translucency; this stays behind everything. */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(42% 34% at 10% 6%, color-mix(in srgb, var(--accent) 13%, transparent), transparent 72%),
    radial-gradient(34% 28% at 92% 14%, color-mix(in srgb, var(--cyan) 10%, transparent), transparent 72%),
    radial-gradient(40% 32% at 80% 96%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 72%),
    radial-gradient(30% 26% at 4% 78%, color-mix(in srgb, var(--cyan) 7%, transparent), transparent 72%);
}
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
img { display: block; max-width: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
/* Inside overflow-hidden containers an outside outline gets clipped — use an inset ring */
.list :focus-visible, .alert-actions button:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--accent);
}
::selection { background: var(--accent-dim); }

/* ---------- Text styles (iOS scale) ---------- */
.t-large-title { font-size: 2.125rem; line-height: 1.2;  font-weight: 700; letter-spacing: .011em; }
.t-title1      { font-size: 1.75rem;  line-height: 1.21; font-weight: 700; }
.t-title2      { font-size: 1.375rem; line-height: 1.27; font-weight: 700; }
.t-title3      { font-size: 1.25rem;  line-height: 1.25; font-weight: 600; }
.t-headline    { font-size: 1.0625rem; line-height: 1.29; font-weight: 600; }
.t-body        { font-size: 1.0625rem; line-height: 1.29; font-weight: 400; }
.t-callout     { font-size: 1rem;      line-height: 1.31; font-weight: 400; }
.t-subhead     { font-size: 0.9375rem; line-height: 1.33; font-weight: 400; }
.t-footnote    { font-size: 0.8125rem; line-height: 1.38; font-weight: 400; }
.t-caption     { font-size: 0.75rem;   line-height: 1.33; font-weight: 400; }
.t-caption2    { font-size: 0.6875rem; line-height: 1.18; font-weight: 400; }
.t-sec  { color: var(--label2); }
.t-ter  { color: var(--label3); }
.t-num  { font-family: var(--font-round); font-variant-numeric: tabular-nums; }
.t-up   { text-transform: uppercase; letter-spacing: .06em; }

/* ---------- App frame ---------- */
.app { min-height: 100dvh; display: flex; }
.main { flex: 1; min-width: 0; }
.view {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 16px calc(120px + var(--sab));   /* content scrolls beneath the floating tab bar */
  padding-left: max(16px, var(--sal));
  padding-right: max(16px, var(--sar));
}

/* ---------- Sidebar (regular width) ---------- */
.sidebar { display: none; }
@media (min-width: 900px) {
  .app { --sidebar-w: 276px; }
  .sidebar {
    display: flex; flex-direction: column;
    width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
    position: sticky; top: 14px; height: calc(100dvh - 28px);
    margin: 14px 0 14px 14px;
    padding: 22px 12px 18px;
    border-radius: 28px;
    background: var(--glass-bg);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    backdrop-filter: blur(24px) saturate(180%);
    box-shadow:
      var(--glass-shadow),
      inset 0 1px 0 var(--glass-specular),
      inset 0 0 0 .5px var(--glass-rim);
  }
  @media (prefers-reduced-transparency: reduce) {
    .sidebar { background: var(--bg-card); -webkit-backdrop-filter: none; backdrop-filter: none; }
  }
  @supports not ((backdrop-filter: blur(4px)) or (-webkit-backdrop-filter: blur(4px))) {
    .sidebar { background: var(--bg-card); }
  }
  .tabbar { display: none !important; }
  .view { padding-bottom: 64px; }
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 4px 12px 22px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 11px; flex: 0 0 auto;
  background: linear-gradient(145deg, #aff34c 0%, #2fbf4f 100%);
  position: relative;
}
.brand-mark::after {
  content: ""; position: absolute; inset: 0;
  background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="rgba(0,0,0,0.82)" stroke-width="2.1" stroke-linecap="round"><path d="M3.5 12h2.2M18.3 12h2.2M8.6 12h6.8"/><rect x="5.7" y="7.6" width="2.9" height="8.8" rx="1.2"/><rect x="15.4" y="7.6" width="2.9" height="8.8" rx="1.2"/></svg>') center/24px no-repeat;
}
.brand-copy { display: flex; flex-direction: column; }
.brand-name { font-weight: 700; font-size: 1.0625rem; }
.brand-sub { font-size: .75rem; color: var(--label2); }
.sidebar-items { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side-item {
  display: flex; align-items: center; gap: 12px;
  min-height: var(--tap); padding: 0 12px;
  border-radius: 10px; font-size: 1rem; font-weight: 500;
  color: var(--label); text-align: left; width: 100%;
  transition: background .15s ease;
}
.side-item .ic { color: var(--accent); }
.side-item:hover { background: var(--fill2); }
.side-item[aria-selected="true"] { background: var(--accent-dim); }
.side-item[aria-selected="true"], .side-item[aria-selected="true"] .ic { color: var(--accent); font-weight: 600; }
.sidebar-foot { padding-top: 8px; border-top: var(--hairline) solid var(--separator); }

/* ---------- Tab bar — floating Liquid Glass island (compact width) ---------- */
.tabbar {
  position: fixed; left: 50%; bottom: max(14px, calc(10px + var(--sab))); z-index: 40;
  transform: translateX(-50%);
  display: flex; align-items: stretch; gap: 2px;
  padding: 6px;
  border-radius: 999px;
  background: var(--glass-bg-thick);   /* thicker than default glass — small labels need the contrast */
}
.tab-item {
  width: 60px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  min-height: 50px; padding-top: 2px;
  color: var(--label); font-size: .625rem; font-weight: 500;
  border-radius: 999px;
  transition: background .2s var(--ease-apple), color .2s var(--ease-apple);
}
.tab-item .ic { width: 24px; height: 24px; }
.tab-item[aria-selected="true"] { color: var(--accent); background: var(--fill2); }
@media (max-width: 374px) { .tab-item { width: 48px; font-size: .5625rem; } }
/* These come after the .tabbar background override above, so they must repeat it */
@supports not ((backdrop-filter: blur(4px)) or (-webkit-backdrop-filter: blur(4px))) {
  .tabbar { background: var(--bg-card); }
}
@media (prefers-reduced-transparency: reduce) {
  .tabbar { background: var(--bg-card); -webkit-backdrop-filter: none; backdrop-filter: none; }
}

/* ---------- Large-title header ---------- */
.nav-head {
  position: sticky; top: 0; z-index: 30;
  margin: 0 -16px; padding: calc(10px + var(--sat)) 16px 10px;
  display: flex; align-items: center; justify-content: center; min-height: 52px;
  background: transparent;
  transition: background .2s ease;
}
.nav-head .nav-title {
  font-size: 1.0625rem; font-weight: 600;
  opacity: 0; transform: translateY(4px);
  transition: opacity .2s ease, transform .2s ease;
}
/* Scroll edge effect — progressive blur+fade on a pseudo layer, so the bar is
   never a boxed glass strip and the title stays crisp above the falloff. */
.nav-head::before {
  content: ""; position: absolute; inset: 0 0 -14px; z-index: -1;
  -webkit-backdrop-filter: blur(12px) saturate(160%);
  backdrop-filter: blur(12px) saturate(160%);
  -webkit-mask-image: linear-gradient(to bottom, black 55%, transparent 100%);
  mask-image: linear-gradient(to bottom, black 55%, transparent 100%);
  background: linear-gradient(color-mix(in srgb, var(--bg) 55%, transparent), transparent);
  opacity: 0; transition: opacity .2s ease;
  pointer-events: none;
}
.nav-head.is-stuck::before { opacity: 1; }
@supports not ((backdrop-filter: blur(4px)) or (-webkit-backdrop-filter: blur(4px))) {
  .nav-head::before { background: linear-gradient(var(--bg) 40%, transparent); }
}
@media (prefers-reduced-transparency: reduce) {
  .nav-head::before {
    -webkit-backdrop-filter: none; backdrop-filter: none;
    background: linear-gradient(var(--bg) 40%, transparent);
  }
}
.nav-head.is-stuck .nav-title { opacity: 1; transform: none; }
.nav-lead, .nav-trail { position: absolute; display: flex; gap: 6px; align-items: center; }
.nav-lead { left: 10px; } .nav-trail { right: 10px; }
.page-head { padding: 2px 0 14px; }
.page-eyebrow { font-size: .8125rem; font-weight: 600; color: var(--label2); text-transform: uppercase; letter-spacing: .05em; }
.page-title { font-size: 2.125rem; font-weight: 700; letter-spacing: .011em; }
.page-sub { color: var(--label2); margin-top: 2px; }

/* Icon button (nav bar) — floating glass circle in nav contexts */
.ic-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: var(--tap); height: var(--tap); border-radius: 50%;
  color: var(--accent);
  transition: background .15s var(--ease-apple), transform .12s var(--ease-apple);
}
.ic-btn:active { transform: scale(.92); background: var(--fill2); }
.nav-head .ic-btn { color: var(--label); }   /* keeps the 44pt base size */

/* ---------- Icons ---------- */
.ic { width: 22px; height: 22px; flex: 0 0 auto; display: inline-block; vertical-align: middle; }
.ic svg { display: block; width: 100%; height: 100%; }
.ic-s { width: 17px; height: 17px; }
.ic-l { width: 28px; height: 28px; }
.ic-xl { width: 40px; height: 40px; }

/* ---------- Cards & grouped lists ---------- */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-card);
  padding: 16px;
  margin-bottom: 14px;
}
.card-title { font-size: 1.0625rem; font-weight: 600; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.card-title .ic { color: var(--accent); }
.sect-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 18px 4px 8px;
}
.sect-head h2 { font-size: 1.375rem; font-weight: 700; }
.sect-link { color: var(--accent); font-size: 1rem; font-weight: 500; min-height: var(--tap); display: inline-flex; align-items: center; }

.list { background: var(--bg-card); border-radius: var(--radius-card); overflow: hidden; margin-bottom: 14px; }
.row {
  display: flex; align-items: center; gap: 12px;
  min-height: 52px; padding: 8px 16px;
  width: 100%; text-align: left; color: var(--label);
  position: relative;
  transition: background .12s ease;
}
.row + .row::before {
  content: ""; position: absolute; top: 0; left: 16px; right: 0;
  border-top: var(--hairline) solid var(--separator);
}
.row.has-thumb + .row.has-thumb::before { left: 76px; }
button.row:active, a.row:active { background: var(--fill2); }
.row-body { flex: 1; min-width: 0; }
.row-title { font-size: 1.0625rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: .8125rem; color: var(--label2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-trail { display: flex; align-items: center; gap: 8px; color: var(--label2); font-size: 1rem; }
.row .chev { color: var(--label3); width: 18px; height: 18px; }
.row-icon {
  width: 30px; height: 30px; border-radius: 8px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center; color: #fff;
}
.row-icon .ic { width: 19px; height: 19px; }

/* ---------- Buttons ---------- */
/* Prominent button = tinted Liquid Glass (glassProminent): translucent accent over blur */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 0 22px; width: 100%;
  border-radius: var(--radius-btn);
  font-size: 1.0625rem; font-weight: 600;
  background: var(--accent-glass); color: var(--on-accent);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  backdrop-filter: blur(16px) saturate(180%);
  box-shadow:
    0 6px 18px color-mix(in srgb, var(--accent) 32%, transparent),
    inset 0 1px 0 rgba(255,255,255,.34),
    inset 0 0 0 .5px rgba(255,255,255,.22);
  transition: transform .2s var(--ease-apple), opacity .2s var(--ease-apple),
              filter .2s var(--ease-apple), background .2s var(--ease-apple);
}
@media (hover: hover) { .btn:hover { filter: brightness(1.06); } }
.btn:active { transform: scale(.96); filter: brightness(1.1); }
/* Secondary button = regular Liquid Glass (.glass button style) */
.btn.btn-gray {
  background: var(--glass-bg); color: var(--label);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  box-shadow:
    0 4px 18px rgba(0,0,0,.08),
    inset 0 1px 0 var(--glass-specular),
    inset 0 0 0 .5px var(--glass-rim);
}
.btn.btn-tinted, .btn.btn-danger, .btn.btn-plain { box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
.btn.btn-tinted { background: var(--accent-dim); color: var(--accent); }
.btn.btn-gray.tint-label { color: var(--accent); }   /* App Store "Get" recipe: glass fill, accent label */
.btn.btn-danger { background: var(--red-dim); color: var(--red); }
.btn.btn-danger-solid { background: var(--red); color: #fff; }
.btn.btn-plain { background: none; color: var(--accent); min-height: var(--tap); }
.btn.btn-plain::before, .btn.btn-tinted::before, .btn.btn-danger::before { display: none; }  /* sheen only on glass fills */
/* Solid fallbacks — placed after the glass rules so they win */
@supports not ((backdrop-filter: blur(4px)) or (-webkit-backdrop-filter: blur(4px))) {
  .btn { background: var(--accent); }
  .btn.btn-gray { background: var(--fill2); }
}
@media (prefers-reduced-transparency: reduce) {
  .btn { background: var(--accent); -webkit-backdrop-filter: none; backdrop-filter: none; }
  .btn.btn-gray { background: var(--fill2); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
.btn.btn-sm { min-height: 38px; width: auto; padding: 0 16px; font-size: .9375rem; }
.btn[disabled] { opacity: .4; pointer-events: none; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

/* ---------- Inputs ---------- */
.field {
  width: 100%; min-height: 46px; padding: 10px 14px;
  background: var(--bg-card2); border: none; border-radius: 11px;
  font-size: 1.0625rem; color: var(--label);
}
.field::placeholder { color: var(--label3); }
.field:focus { outline: 2px solid var(--accent); }
.search-wrap { position: relative; margin-bottom: 12px; }
.search-wrap .ic { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--label2); width: 18px; height: 18px; }
.search-wrap .field { padding-left: 36px; min-height: 40px; border-radius: 999px; background: var(--fill2); }

/* iOS switch */
.switch { position: relative; width: 51px; height: 31px; flex: 0 0 auto; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .knob {
  position: absolute; inset: 0; border-radius: 16px; background: var(--fill);
  transition: background .2s ease; pointer-events: none;
}
.switch .knob::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px;
  border-radius: 50%; background: #fff;
  box-shadow: 0 3px 8px rgba(0,0,0,.15), 0 1px 1px rgba(0,0,0,.16);
  transition: transform .2s var(--ease);
}
.switch input:checked + .knob { background: var(--accent); }
.switch input:checked + .knob::after { transform: translateX(20px); }
.switch input:focus-visible + .knob { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Segmented control */
.seg {
  display: flex; background: var(--fill2); border-radius: 9px; padding: 2px;
  position: relative; margin-bottom: 14px;
}
.seg button {
  flex: 1; min-height: 34px; border-radius: 7px;
  font-size: .8125rem; font-weight: 500; color: var(--label);
  transition: background .18s ease, box-shadow .18s ease;
  position: relative;
}
.seg button::after { content: ""; position: absolute; inset: -5px 0; }       /* 44pt hit area */
.seg-mini button::after { inset: -7px 0; }
.seg button[aria-selected="true"] {
  background: var(--bg-elev); font-weight: 600;
  box-shadow: 0 3px 8px rgba(0,0,0,.12), 0 1px 1px rgba(0,0,0,.06),
    inset 0 1px 0 var(--glass-specular);   /* glassy knob */
}

/* Chips */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 7px 0 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; min-height: 34px; padding: 6px 15px; border-radius: 999px;
  background: var(--bg-card); color: var(--label); font-size: .9375rem; font-weight: 500;
  border: var(--hairline) solid var(--separator);
  transition: background .2s var(--ease-apple), color .2s var(--ease-apple);
  position: relative;
}
.chip::after { content: ""; position: absolute; inset: -5px 0; }   /* 44pt hit area */
.chip[aria-pressed="true"] { background: var(--label); color: var(--bg); border-color: transparent; font-weight: 600; }
.chip-static {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 13px; font-size: .8125rem; font-weight: 500;
  background: var(--fill2); color: var(--label2);
}

/* SGP Trace chip + row badge */
.chip-sensor {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent-dim); color: var(--accent); border-color: transparent;
  font-weight: 600;
}
.chip-sensor .ic { width: 15px; height: 15px; }
.chip-sensor[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.sensor-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 17px; height: 17px; border-radius: 6px; flex: 0 0 auto;
  background: var(--accent-dim); color: var(--accent); vertical-align: -3px;
}
.sensor-badge .ic { width: 11px; height: 11px; }
.sensor-note {
  display: flex; gap: 10px; align-items: center;
  padding: 8px 4px 12px; color: var(--label2); font-size: .8125rem;
}
.sensor-note .ic { color: var(--accent); }

/* Sensor metric grid (exercise detail) */
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; margin-top: 10px; }
.metric-item { display: flex; align-items: center; gap: 8px; font-size: .8125rem; font-weight: 500; }
.metric-item .ic { width: 15px; height: 15px; color: var(--accent); }
.metric-item.est { color: var(--label2); }
.metric-item.est .ic { color: var(--label3); }
.metric-item small { color: var(--label3); font-weight: 400; }

/* Stepper (big, 44pt targets) */
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper .st-btn {
  width: var(--tap); height: var(--tap); border-radius: 12px;
  background: var(--fill2); color: var(--label);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; transition: transform .1s ease, background .12s ease;
}
.stepper .st-btn:active { transform: scale(.92); background: var(--fill); }
.stepper .st-val {
  min-width: 86px; text-align: center;
  font-family: var(--font-round); font-variant-numeric: tabular-nums;
  font-size: 1.75rem; font-weight: 700;
}
.stepper .st-unit { font-size: .8125rem; font-weight: 500; color: var(--label2); display: block; }

/* Compact stepper: value on top, buttons below — three fit on a phone */
.stepper.compact {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  width: 100%; max-width: 110px; margin: 0 auto;
}
.stepper.compact .st-val { grid-row: 1; grid-column: 1 / 3; min-width: 0; font-size: 1.4rem; }
.stepper.compact .st-btn { grid-row: 2; width: 100%; min-width: 0; height: 40px; border-radius: 10px; }

/* ---------- Goal gauges (custom capacity gauges — NOT Activity Rings) ---------- */
.gauges { display: flex; justify-content: space-between; gap: 8px; }
.gauge { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 1; }
.gauge > svg { width: 92px; height: 92px; }
.gauge .g-track { stroke: var(--fill2); }
.gauge .g-val {
  font-family: var(--font-round); font-variant-numeric: tabular-nums;
  font-size: 1.0625rem; font-weight: 700; fill: var(--label);
}
.gauge .g-unit { font-size: .5625rem; font-weight: 600; fill: var(--label2); letter-spacing: .04em; }
.gauge .g-label { display: flex; align-items: center; gap: 4px; font-size: .75rem; font-weight: 600; color: var(--label2); }
.gauge .g-label .ic { width: 13px; height: 13px; }
.g-arc { transition: stroke-dashoffset .8s var(--ease); }

/* ---------- Hero / stat tiles ---------- */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-tile { background: var(--bg-card); border-radius: var(--radius-card); padding: 14px 16px; }
.stat-kicker { display: flex; align-items: center; gap: 6px; font-size: .8125rem; font-weight: 600; color: var(--label2); }
.stat-kicker .ic { width: 15px; height: 15px; }
.stat-value { font-family: var(--font-round); font-variant-numeric: tabular-nums; font-size: 1.75rem; font-weight: 700; margin-top: 2px; }
.stat-value small { font-size: .9375rem; font-weight: 600; color: var(--label2); }
.stat-delta { font-size: .8125rem; font-weight: 600; }
.up { color: var(--accent); } .down { color: var(--red); } .flat { color: var(--label2); }

/* Week strip */
.week-strip { display: flex; justify-content: space-between; }
.wday { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: .6875rem; font-weight: 600; color: var(--label2); }
.wday .dot {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--fill2); display: flex; align-items: center; justify-content: center;
  color: transparent;
}
.wday.done .dot { background: var(--accent); color: #fff; }
.wday.planned .dot { background: var(--accent-dim); color: var(--accent); }
/* halo ring keeps "today" visible even when the dot is filled (done) */
.wday.today .dot { box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 4px var(--accent); }
.wday .dot .ic { width: 15px; height: 15px; }
button.wday { cursor: pointer; transition: transform .12s var(--ease-apple); position: relative; }
button.wday::after { content: ""; position: absolute; inset: -4px -7px; }   /* 44pt hit area */
button.wday:active { transform: scale(.92); }

/* ---------- Exercise thumbs & media ---------- */
.thumb {
  width: 52px; height: 52px; border-radius: 10px; object-fit: cover;
  background: #fff; flex: 0 0 auto;
}
.thumb-ph {
  width: 52px; height: 52px; border-radius: 10px; flex: 0 0 auto;
  background: var(--fill2); color: var(--label3);
  display: flex; align-items: center; justify-content: center;
}
.exmedia {
  border-radius: var(--radius-card); overflow: hidden; background: #fff;
  position: relative; margin-bottom: 14px; cursor: pointer;
  padding: 16px 0;
}
/* The dataset's media is 180×180 — shown near native size it stays crisp;
   stretching it to 400px+ is what made it look mushy. */
.exmedia img { width: 60%; max-width: 220px; aspect-ratio: 1; object-fit: contain; margin: 0 auto; }
.exmedia .media-hint {
  position: absolute; right: 10px; bottom: 10px;
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(0,0,0,.55); color: #fff; font-size: .6875rem; font-weight: 600;
  padding: 4px 10px; border-radius: 12px;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.exmedia .media-hint .ic { width: 12px; height: 12px; }

/* ---------- Sheets ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(0,0,0,.40);
  opacity: 0; transition: opacity var(--dur) ease;
}
.alert-backdrop { z-index: 94; }   /* above open sheets (91), below the alert (95) */
.sheet-backdrop.in { opacity: 1; }
.sheet {
  position: fixed; z-index: 91; left: 0; right: 0; bottom: 0;
  max-height: calc(100dvh - 40px - var(--sat));
  border-radius: 28px 28px 0 0;
  transform: translateY(100%); transition: transform var(--dur) var(--ease);
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-sheet), inset 0 1px 0 var(--glass-specular), inset 0 0 0 .5px var(--glass-rim);
}
.sheet.in { transform: translateY(0); }
.sheet-grab { flex: 0 0 auto; padding: 8px 0 2px; display: flex; justify-content: center; }
.sheet-grab::after { content: ""; width: 36px; height: 5px; border-radius: 3px; background: var(--grabber); }
.sheet-head {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: center;
  min-height: 48px; position: relative; padding: 0 56px;
}
.sheet-title { font-size: 1.0625rem; font-weight: 600; text-align: center; }
.sheet-close { position: absolute; right: 8px; top: 2px; color: var(--label2); }
.sheet-close .ic { width: 28px; height: 28px; }
.sheet-body { overflow-y: auto; padding: 4px 16px calc(20px + var(--sab)); overscroll-behavior: contain; }
@media (min-width: 900px) {
  .sheet {
    left: 50%; right: auto; bottom: auto; top: 50%;
    width: min(560px, calc(100vw - 48px));
    max-height: min(760px, calc(100dvh - 64px));
    border-radius: 28px;
    transform: translate(-50%, -46%) scale(.96); opacity: 0;
    transition: transform var(--dur) var(--ease), opacity var(--dur) ease;
    box-shadow: var(--shadow-pop), inset 0 1px 0 var(--glass-specular), inset 0 0 0 .5px var(--glass-rim);
  }
  .sheet.in { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  .sheet-grab { display: none; }
  .sheet-head { padding-top: 8px; }
}

/* Alert (centered, always) */
.alert-box {
  position: fixed; z-index: 95; left: 50%; top: 50%;
  transform: translate(-50%, -50%) scale(1.08); opacity: 0;
  width: min(280px, calc(100vw - 80px));
  border-radius: 22px; overflow: hidden;
  text-align: center; transition: transform .22s var(--ease), opacity .22s ease;
  box-shadow: var(--shadow-pop), inset 0 1px 0 var(--glass-specular), inset 0 0 0 .5px var(--glass-rim);
}
.alert-box.in { transform: translate(-50%, -50%) scale(1); opacity: 1; }
.alert-msg { padding: 20px 18px 16px; }
.alert-msg h3 { font-size: 1.0625rem; font-weight: 600; }
.alert-msg p { font-size: .8125rem; color: var(--label2); margin-top: 4px; }
.alert-actions { display: flex; border-top: var(--hairline) solid var(--separator); }
.alert-actions button {
  flex: 1; min-height: 44px; font-size: 1.0625rem; color: var(--accent);
}
.alert-actions button + button { border-left: var(--hairline) solid var(--separator); }
.alert-actions .destructive { color: var(--red); }
.alert-actions .bold { font-weight: 600; }

/* ---------- Toast ---------- */
.toast-root {
  position: fixed; top: calc(10px + var(--sat)); left: 0; right: 0; z-index: 99;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 8px;
  color: var(--label);
  border-radius: 999px; padding: 10px 18px;
  font-size: .9375rem; font-weight: 600;
  opacity: 0; transform: translateY(-12px);
  transition: opacity .25s ease, transform .25s var(--ease);
}
.toast.in { opacity: 1; transform: none; }
.toast .ic { color: var(--accent); width: 19px; height: 19px; }
.toast.err .ic { color: var(--red); }

/* ---------- Live session (full-screen, always dark — motion-legible) ---------- */
.live-root {
  position: fixed; inset: 0; z-index: 70;
  background: #000; color: #fff;
  overflow-y: auto;
  color-scheme: dark;
  --bg: #000; --bg-card: #1c1c1e; --bg-card2: #2c2c2e; --bg-elev: #2c2c2e;
  --label: #fff; --label2: rgba(235,235,245,.6); --label3: rgba(235,235,245,.3);
  --separator: rgba(84,84,88,.65); --fill: rgba(120,120,128,.36); --fill2: rgba(120,120,128,.2);
  --accent: #30d158; --accent-dim: rgba(48,209,88,.18);
  --red: #ff453a; --red-dim: rgba(255,69,58,.16);
  --orange: #ff9f0a; --yellow: #ffd60a; --cyan: #64d2ff;
  --bar-material: rgba(22,22,24,.8); --grabber: rgba(235,235,245,.3);
  --glass-bg: rgba(30,30,32,.52); --glass-bg-thick: rgba(28,28,30,.8);
  --glass-specular: rgba(255,255,255,.16); --glass-rim: rgba(255,255,255,.09);
  --glass-sheen: rgba(255,255,255,.075);
  --glass-shadow: 0 8px 32px rgba(0,0,0,.45);
  --accent-glass: color-mix(in srgb, var(--accent) 74%, transparent);
  --z-explosive: #64d2ff; --z-fast: #30d158; --z-moderate: #ffd60a; --z-slow: #ff9f0a; --z-grind: #ff453a;
  transform: translateY(3%); opacity: 0;
  transition: transform var(--dur) var(--ease), opacity var(--dur) ease;
}
.live-root.in { transform: none; opacity: 1; }
.live-wrap { max-width: 680px; margin: 0 auto; padding: calc(10px + var(--sat)) 16px calc(24px + var(--sab)); }
.live-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.live-clock {
  font-family: var(--font-round); font-variant-numeric: tabular-nums;
  font-size: 2.6rem; font-weight: 700; color: var(--yellow); line-height: 1;
}
.live-state { font-size: .8125rem; font-weight: 600; color: var(--label2); text-transform: uppercase; letter-spacing: .06em; }
.live-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; }
.lm {
  background: var(--bg-card); border-radius: 14px; padding: 10px 12px;
}
.lm .lm-v { font-family: var(--font-round); font-variant-numeric: tabular-nums; font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.lm .lm-l { font-size: .6875rem; font-weight: 600; color: var(--label2); text-transform: uppercase; letter-spacing: .05em; }
.vel-hero { text-align: center; padding: 6px 0 2px; }
.vel-hero .vh-num {
  font-family: var(--font-round); font-variant-numeric: tabular-nums;
  font-size: 4.6rem; font-weight: 800; line-height: 1; letter-spacing: -.02em;
}
.vel-hero .vh-unit { font-size: 1rem; font-weight: 600; color: var(--label2); }
.vel-hero .vh-zone { font-size: .8125rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; margin-top: 4px; }
.rep-bars { display: flex; align-items: flex-end; gap: 6px; height: 128px; padding: 8px 2px 18px; position: relative; box-sizing: content-box; }
.rep-bar { flex: 1; max-width: 44px; border-radius: 6px 6px 2px 2px; position: relative; min-height: 6px; transition: height .3s var(--ease); }
.rep-bar .rb-v {
  position: absolute; top: -17px; left: -2px; right: -2px; text-align: center;
  font-size: .625rem; font-weight: 700; font-variant-numeric: tabular-nums;
  letter-spacing: -.02em; white-space: nowrap;
}
.rep-bars-cap { padding: 4px 2px 0; }

/* ---------- Muscle map ---------- */
.bodymap { height: 340px; width: 100%; max-width: 200px; display: block; margin: 0 auto; }
.bodymap .bm-m {
  transition: fill .25s var(--ease), opacity .2s ease; cursor: pointer;
  stroke: var(--bg-card, #111); stroke-width: .5;   /* keeps neighbours readable */
}
.bodymap .bm-m:active { opacity: .6; }
.bodymap .bm-sil { stroke: var(--separator); stroke-width: 1; }
@media (hover: hover) { .bodymap .bm-m:hover { stroke: var(--label); stroke-width: 1.6; } }
.rep-bar .rb-rom {
  position: absolute; bottom: -17px; left: 0; right: 0; text-align: center;
  font-size: .625rem; font-weight: 600; color: var(--label2); font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.rep-slot {
  flex: 1; max-width: 44px; align-self: stretch; margin-top: 8px;
  border: 1.5px dashed var(--separator); border-radius: 6px; opacity: .55;
}
.rb-live { transition: height .12s linear, background .2s ease; }
.rep-thresh {
  position: absolute; left: 0; right: 0; border-top: 2px dashed var(--red);
  opacity: .75; pointer-events: none;
}
.rep-thresh span {
  position: absolute; right: 0; top: -18px; font-size: .625rem; font-weight: 700;
  color: var(--red); text-transform: uppercase; letter-spacing: .05em;
}
.live-warn {
  display: flex; align-items: center; gap: 10px;
  background: var(--red-dim); color: var(--red);
  border-radius: 12px; padding: 10px 14px; margin: 10px 0;
  font-size: .9375rem; font-weight: 600;
}
.set-log-row {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px; align-items: start; padding: 8px 0 4px;
}
.live-controls {
  position: sticky; bottom: 0; margin: 16px -16px 0; padding: 12px 16px calc(12px + var(--sab));
  background: linear-gradient(transparent, rgba(0,0,0,.85) 55%);
  display: flex; gap: 10px;
}
.live-controls .btn { flex: 1; }
/* (glass for .live-controls .btn.btn-gray comes from the grouped material rule) */
.rest-ring { display: flex; flex-direction: column; align-items: center; padding: 12px 0 4px; }
.rest-ring svg { width: 180px; height: 180px; }
.rest-num { font-family: var(--font-round); font-variant-numeric: tabular-nums; font-size: 2.6rem; font-weight: 700; fill: #fff; }
.rest-cap { font-size: .75rem; font-weight: 600; fill: var(--label2); letter-spacing: .06em; }
.setlist .row { min-height: 46px; }
.set-badge {
  min-width: 28px; height: 28px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--fill2); color: var(--label2); font-size: .8125rem; font-weight: 700;
}
.set-badge.done { background: var(--accent-dim); color: var(--accent); }
.set-badge.pr { background: var(--yellow); color: #000; }

/* ---------- Coach ---------- */
.coach-hero { overflow: hidden; }
.coach-orb {
  width: 46px; height: 46px; border-radius: 50%; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(145deg, #aff34c, #2fbf4f); color: rgba(0,0,0,.75);
  box-shadow: 0 4px 16px color-mix(in srgb, var(--accent) 40%, transparent),
    inset 0 1px 0 rgba(255,255,255,.5);
}
.coach-orb .ic { width: 24px; height: 24px; }
.coach-chat { padding: 12px; }
.chat-log { display: flex; flex-direction: column; gap: 8px; min-height: 42vh; max-height: 56vh; overflow-y: auto; padding: 4px 2px; overscroll-behavior: contain; }
.coach-chips { padding: 10px 0 10px; margin-bottom: 0; }
.bubble.pending { animation: pulse 1.2s ease-in-out infinite; }
.bubble {
  max-width: 86%; padding: 9px 14px; border-radius: 18px;
  font-size: .9375rem; line-height: 1.35; white-space: pre-wrap; word-break: break-word;
}
.bubble.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 6px; }
.bubble.assistant { align-self: flex-start; background: var(--fill2); color: var(--label); border-bottom-left-radius: 6px; }
.bubble .btn { width: auto; display: inline-flex; }
.bubble .cb-p { display: block; }
.bubble .cb-p + .cb-p { margin-top: 6px; }
.bubble .cb-li { display: block; position: relative; padding-left: 15px; margin-top: 5px; }
.bubble .cb-li::before { content: "•"; position: absolute; left: 2px; color: var(--accent); font-weight: 700; }
.bubble .cb-li strong, .bubble .cb-p strong { font-weight: 700; }
.bubble.follow { border: 1.5px solid var(--accent); }
.bubble.follow .btn { display: flex; width: 100%; justify-content: center; }

/* ---------- Curve game (eGym-style tempo follower) ---------- */
.seg-mini { max-width: 240px; margin: 0 auto 10px; }
.seg-mini button { min-height: 30px; font-size: .8125rem; }
.curve-game { position: relative; }
.curve-hud { display: flex; justify-content: space-between; padding: 2px 6px 10px; }
.ch-item { display: flex; flex-direction: column; align-items: center; min-width: 62px; }
.ch-v { font-size: 1.375rem; font-weight: 800; line-height: 1.1; }
.ch-l { font-size: .625rem; font-weight: 600; color: var(--label2); text-transform: uppercase; letter-spacing: .06em; }
.curve-stage {
  position: relative; height: 258px;
  background: rgba(10, 12, 11, .55);
  border-radius: 14px; overflow: hidden;
}
.curve-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.curve-overlay {
  position: absolute; inset: 0; z-index: 2;
  display: flex; align-items: center; justify-content: center;
  overflow-y: auto;                       /* tall idle content scrolls, never clips */
  background: rgba(8, 10, 9, .55);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.curve-overlay > div {
  margin: auto; max-width: 100%;          /* flex+auto margins: centered when short, scrollable when tall */
  box-sizing: border-box;
}
.curve-overlay[hidden] { display: none; }
.cg-panel {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  text-align: center; padding: 8px 14px; max-width: 340px;
}
.cg-panel .t-footnote { line-height: 1.3; }
.cg-panel .btn { width: auto; min-width: 160px; }
.tempo-chips { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.tempo-chips .chip { min-height: 30px; padding: 4px 12px; font-size: .8125rem; }
.tempo-chips .chip::after { inset: -7px 0; }   /* 44pt hit area */
.tempo-chips .chip[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: transparent; }
.cg-range { width: 200px; height: 8px; border-radius: 4px; background: var(--fill2); overflow: hidden; }
.cg-range-fill { height: 100%; border-radius: 4px; background: var(--accent); transition: width .2s ease; }
.cg-final { font-size: 2.8rem; font-weight: 800; line-height: 1; }
.cg-link { color: var(--accent); font-size: inherit; text-decoration: underline; padding: 0; }

/* ---------- Device view ---------- */
.device-hero {
  background: radial-gradient(120% 120% at 50% 0%, #22321f 0%, #101312 55%, #0a0a0b 100%);
  border-radius: 20px; padding: 22px 16px 18px; color: #fff; text-align: center;
  margin-bottom: 14px; position: relative; overflow: hidden;
}
:root[data-theme="light"] .device-hero { box-shadow: inset 0 0 0 var(--hairline) rgba(255,255,255,.08); }
.device-hero h2 { font-size: 1.375rem; font-weight: 700; }
.device-hero .t-sec { color: rgba(235,235,245,.6); }
.device-status {
  display: inline-flex; align-items: center; gap: 7px;
  margin-top: 10px; padding: 6px 14px; border-radius: 15px;
  background: rgba(120,120,128,.24); font-size: .8125rem; font-weight: 600;
}
.device-status .dot-ind { width: 8px; height: 8px; border-radius: 50%; background: var(--label3); }
.device-status.on { color: #30d158; }
.device-status.on .dot-ind { background: #30d158; box-shadow: 0 0 8px #30d158; }
.device-status.demo { color: #ffd60a; }
.device-status.demo .dot-ind { background: #ffd60a; }
.barbell-art { margin: 8px auto 2px; width: min(300px, 80%); }

/* Live 3D barbell viewport (bleeds to the hero card edges) */
.bar3d-wrap {
  position: relative;
  height: clamp(240px, 58vw, 320px);
  margin: -22px -16px 14px;
  border-radius: 20px 20px 0 0;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
}
.bar3d-wrap:active { cursor: grabbing; }
.bar3d-wrap canvas { display: block; }
#bar3d-fallback { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.hud { position: absolute; left: 12px; right: 12px; display: flex; align-items: center; gap: 8px; pointer-events: none; z-index: 2; }
.hud-top { top: 12px; justify-content: space-between; }
.hud-bottom { bottom: 12px; justify-content: center; gap: 12px; }
.hud-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(16, 19, 17, .55); color: #e8f5e9;
  padding: 6px 12px; border-radius: 15px; font-size: .75rem; font-weight: 600;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.hud-pill .ic { color: #7ce787; }
.hud-pill b { font-size: .9375rem; }
.hud-hint { opacity: .7; font-weight: 500; }
.hud-btn {
  pointer-events: auto;
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(16, 19, 17, .6); color: #fff;
  display: flex; align-items: center; justify-content: center;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  transition: transform .12s ease, background .12s ease;
}
.hud-btn:active { transform: scale(.9); background: rgba(60, 70, 62, .7); }
.hud-weight {
  pointer-events: auto; text-align: center;
  background: rgba(16, 19, 17, .6); color: #e8f5e9;
  border-radius: 16px; padding: 6px 18px; min-width: 128px;
  font-size: .9375rem; font-weight: 600;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.hud-weight b { font-size: 1.375rem; font-weight: 800; color: #fff; }
.hud-plates { font-size: .6875rem; color: rgba(235, 245, 235, .6); font-weight: 500; }
.live-strip { width: 100%; height: 120px; display: block; }
.tile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
@media (min-width: 560px) { .tile-grid { grid-template-columns: repeat(3, 1fr); } }
.tile { background: var(--bg-card); border-radius: var(--radius-card); padding: 12px 14px; }
.tile .tl { display: flex; align-items: center; gap: 6px; font-size: .75rem; font-weight: 600; color: var(--label2); }
.tile .tl .ic { width: 14px; height: 14px; }
.tile .tv { font-family: var(--font-round); font-variant-numeric: tabular-nums; font-size: 1.5rem; font-weight: 700; margin-top: 2px; }
.tile .tv small { font-size: .8125rem; color: var(--label2); font-weight: 600; }

/* ---------- Charts & heatmap ---------- */
.chart-canvas { width: 100%; height: 190px; display: block; }
.chart-canvas.tall { height: 230px; }
.spark { width: 100%; height: 44px; display: block; }
.heatmap { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 1fr); gap: 3px; overflow-x: auto; padding-bottom: 4px; }
.hm-cell { width: 13px; height: 13px; border-radius: 3.5px; background: var(--fill2); }
.hm-1 { background: color-mix(in srgb, var(--accent) 30%, var(--fill2)); }
.hm-2 { background: color-mix(in srgb, var(--accent) 55%, transparent); }
.hm-3 { background: color-mix(in srgb, var(--accent) 80%, transparent); }
.hm-4 { background: var(--accent); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; font-size: .75rem; font-weight: 500; color: var(--label2); }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---------- Encoder (VBT lab) ---------- */
.enc-table { display: flex; flex-direction: column; gap: 2px; }
.enc-tr {
  display: grid; grid-template-columns: 1.4fr 2fr 2fr 1.8fr 1.8fr 1.6fr;
  align-items: center; gap: 4px;
  padding: 7px 10px; border-radius: 10px;
  font-size: .9375rem;
}
.enc-tr small { font-size: .625rem; color: var(--label3); margin-left: 1px; }
.enc-tr.enc-head {
  font-size: .625rem; font-weight: 700; color: var(--label2);
  text-transform: uppercase; letter-spacing: .05em; padding-bottom: 3px;
}
.enc-tr:not(.enc-head):nth-child(even) { background: var(--fill2); }
.enc-tr.hit { box-shadow: inset 2.5px 0 0 var(--accent); }
.enc-tr.miss { box-shadow: inset 2.5px 0 0 var(--red); background: var(--red-dim); }

/* ---------- History calendar ---------- */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-head span {
  text-align: center; font-size: .6875rem; font-weight: 600; color: var(--label2);
  padding-bottom: 4px;
}
.cal-day {
  min-height: 46px; border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--label); font-size: .9375rem;
  transition: background .15s var(--ease-apple), transform .12s var(--ease-apple);
}
.cal-day.blank { pointer-events: none; }
button.cal-day:active { transform: scale(.9); background: var(--fill2); }
.cal-day[disabled] { color: var(--label3); }
.cal-day .cal-num { font-variant-numeric: tabular-nums; font-weight: 500; }
.cal-day.done { background: var(--accent-dim); }
.cal-day.done .cal-num { font-weight: 700; color: var(--accent); }
.cal-day.today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-dots { display: flex; gap: 2px; height: 4px; }
.cal-dots i { width: 4px; height: 4px; border-radius: 50%; background: var(--accent); }
.cal-dots i.bw { background: var(--cyan); }

/* ---------- Empty states ---------- */
.empty { text-align: center; padding: 44px 24px; color: var(--label2); }
.empty .ic { width: 44px; height: 44px; color: var(--label3); margin: 0 auto 10px; }
.empty h3 { color: var(--label); font-size: 1.0625rem; font-weight: 600; margin-bottom: 4px; }
.empty p { font-size: .9375rem; max-width: 300px; margin: 0 auto 16px; }
.empty .btn { width: auto; margin: 0 auto; }

/* ---------- PR celebration ---------- */
.pr-banner {
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(120deg, rgba(255,214,10,.22), rgba(255,159,10,.16));
  color: var(--label);
  border-radius: 12px; padding: 10px 14px; margin: 8px 0;
  font-weight: 600; font-size: .9375rem;
}
.pr-banner .ic { color: var(--orange); }

/* ---------- Utility ---------- */
.mt-0{margin-top:0}.mt-8{margin-top:8px}.mt-14{margin-top:14px}.mt-20{margin-top:20px}
.mb-0{margin-bottom:0}.mb-8{margin-bottom:8px}.mb-14{margin-bottom:14px}
.center{text-align:center}
.hstack{display:flex;align-items:center;gap:10px}
.vstack{display:flex;flex-direction:column;gap:10px}
.spread{display:flex;align-items:center;justify-content:space-between;gap:10px}
.grow{flex:1;min-width:0}
.hidden{display:none!important}
.fade-in{animation:fadeIn .3s ease}
@keyframes fadeIn{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}
.pulse{animation:pulse 1.6s ease-in-out infinite}
@keyframes pulse{0%,100%{opacity:1}50%{opacity:.45}}

/* Scroll chunks for the big library */
.lib-sentinel{height:1px}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001s !important;
  }
}

/* ---------- Print ---------- */
@media print {
  .tabbar, .sidebar, .nav-head { display: none !important; }
}

/* ---------- 3D machines (blueprint stage) ---------- */
.m3-entry { border-radius: 16px; margin-bottom: 14px; width: 100%; text-align: left; }
.m3-entry-ic { background: linear-gradient(145deg, #1d5fae, #0b2f5c); color: #fff; }
.m3-stage {
  position: relative; height: min(62vh, 560px); min-height: 340px;
  border-radius: 20px; overflow: hidden; color: #fff;
  background:
    linear-gradient(rgba(255,255,255,.07) 1px, transparent 1px) 0 0 / 100% 28px,
    linear-gradient(90deg, rgba(255,255,255,.07) 1px, transparent 1px) 0 0 / 28px 100%,
    radial-gradient(120% 90% at 50% 20%, #1c5aa6 0%, #0e3a72 55%, #082649 100%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.14);
}
.m3-canvas { position: absolute; inset: 0; touch-action: none; }
.m3-canvas canvas { display: block; outline: none; }
.m3-hud { position: absolute; left: 12px; right: 12px; top: 12px; display: flex; flex-wrap: wrap; gap: 6px; pointer-events: none; }
.m3-pill {
  display: inline-flex; align-items: baseline; gap: 5px; padding: 6px 11px; border-radius: 999px;
  background: rgba(6,24,48,.55); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,.18); font-size: .8125rem; line-height: 1.2;
}
.m3-pill small { opacity: .7; font-size: .6875rem; }
.m3-pill b { font-weight: 700; font-variant-numeric: tabular-nums; }
.m3-pill i { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,.45); align-self: center; }
.m3-pill[data-st="connected"] i, .m3-pill[data-st="demo"] i { background: #7dff6a; }
.m3-pill[data-st="connecting"] i { background: #ffd60a; }
.m3-name { position: absolute; left: 14px; bottom: 12px; display: flex; flex-direction: column; gap: 1px; pointer-events: none; text-shadow: 0 1px 6px rgba(0,0,0,.45); }
.m3-name b { font-size: 1.125rem; font-weight: 700; }
.m3-name span { font-size: .75rem; opacity: .8; }
.m3-loading { position: absolute; inset: 0; display: grid; place-items: center; font-size: .9375rem; background: rgba(8,38,73,.55); }
.m3-loading[hidden] { display: none; }
.m3-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0 4px; }
.m3-bar .btn { width: auto; flex: 0 0 auto; }
.m3-bar .seg { flex: 0 0 auto; width: 176px; margin: 0; }
.m3-credit { color: var(--label2); margin: 14px 2px 0; }

/* 3D muscle map (Progress ▸ Body) */
.body3d { height: 360px; width: 100%; max-width: 320px; margin: 0 auto; position: relative; }

/* Laser view (Sensor ▸ Laser view) */
.ld-stage { position: relative; height: 340px; border-radius: var(--radius-card); overflow: hidden; background: radial-gradient(120% 100% at 50% 0%, #10141b 0%, #06080b 70%); box-shadow: inset 0 0 0 .5px rgba(255,255,255,.09); }
.ld-canvas, .ld-canvas canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.ld-hud { position: absolute; left: 10px; top: 10px; right: 10px; display: flex; gap: 6px; flex-wrap: wrap; pointer-events: none; }
.ld-hud .hud-pill { background: rgba(16,18,22,.72); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border-radius: 999px; padding: 6px 11px; font-size: .8125rem; color: #fff; box-shadow: inset 0 0 0 .5px rgba(255,255,255,.14); }
.ld-hud .hud-pill b { font-variant-numeric: tabular-nums; }
.ld-hint { position: absolute; left: 0; right: 0; bottom: 8px; text-align: center; font-size: .6875rem; color: rgba(255,255,255,.45); pointer-events: none; }
.ld-grid { display: grid; gap: 2px; aspect-ratio: 1; max-width: 340px; margin: 4px auto 0; }
.ld-grid i { display: flex; align-items: center; justify-content: center; border-radius: 4px; font-style: normal; font-weight: 600; color: rgba(255,255,255,.95); font-variant-numeric: tabular-nums; text-shadow: 0 1px 2px rgba(0,0,0,.45); transition: background .12s linear; }
.ld-grid.n8 i { font-size: .5625rem; } .ld-grid.n4 i { font-size: .875rem; border-radius: 8px; }
.ld-dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; vertical-align: -1px; margin: 0 3px; }
/* "Sensor-ready only" switch (library + exercise picker) */
.sensor-switch { display: flex; align-items: center; gap: 12px; padding: 10px 14px; margin: 0 0 10px; border-radius: 16px; background: var(--bg-card); box-shadow: inset 0 0 0 .5px var(--separator); cursor: pointer; }
.sensor-switch > .ic { width: 20px; height: 20px; color: var(--label2); flex: 0 0 auto; }
.sensor-switch strong { display: block; font-size: 15px; font-weight: 600; }
.sensor-switch small { display: block; font-size: 12px; color: var(--label2); margin-top: 1px; }

/* ============================================================
   First run — welcome, account, profile questions (js/views/onboard.js)
   ============================================================ */
.ob-root { position: fixed; inset: 0; z-index: 200; overflow-y: auto; -webkit-overflow-scrolling: touch; background: var(--bg); color: var(--label); animation: ob-in .28s var(--ease) both; }
@keyframes ob-in { from { opacity: 0; } to { opacity: 1; } }
.ob-wrap { max-width: 460px; min-height: 100%; margin: 0 auto; padding: calc(18px + var(--sat)) 22px calc(26px + var(--sab)); display: flex; flex-direction: column; }
.ob-center { justify-content: center; text-align: center; align-items: stretch; }
.ob-brand { display: flex; justify-content: center; margin-bottom: 18px; }
.ob-logo { width: 76px; height: 76px; border-radius: 22px; display: grid; place-items: center; background: var(--accent); color: var(--on-accent); box-shadow: 0 14px 40px rgba(0,0,0,.25); }
.ob-logo svg, .ob-logo .ic { width: 38px; height: 38px; color: inherit; }
.ob-h1 { font-size: 2.25rem; font-weight: 700; letter-spacing: -0.035em; line-height: 1.08; margin: 0 0 10px; }
.ob-h2 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.03em; line-height: 1.14; margin: 18px 0 8px; }
.ob-lead { font-size: 1.0625rem; color: var(--label2); line-height: 1.4; margin: 0 auto 22px; max-width: 320px; }
.ob-sub { font-size: .9375rem; color: var(--label2); line-height: 1.4; margin: 0 0 20px; }
.ob-points { list-style: none; padding: 0; margin: 0 0 28px; display: grid; gap: 10px; text-align: left; }
.ob-points li { display: flex; align-items: center; gap: 12px; padding: 13px 14px; border-radius: 16px; background: var(--bg-card); box-shadow: inset 0 0 0 .5px var(--separator); font-size: .9375rem; font-weight: 500; }
.ob-points svg { width: 22px; height: 22px; flex: none; color: var(--label); }
.ob-actions { display: grid; gap: 10px; }
.ob-note { font-size: .75rem; color: var(--label3); text-align: center; margin: 16px 0 0; }
.ob-back { width: 40px; height: 40px; margin-left: -8px; border-radius: 50%; display: grid; place-items: center; color: var(--label); flex: none; }
.ob-back svg { width: 24px; height: 24px; }
.ob-form { display: grid; gap: 8px; margin-bottom: 6px; }
.ob-label, .ob-mini { font-size: .8125rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--label2); margin: 10px 2px 0; }
.ob-mini { margin: 16px 2px 8px; }
.ob-mini:first-child { margin-top: 0; }
.ob-input { width: 100%; min-height: 52px; font-size: 1.0625rem; border-radius: 14px; padding: 0 16px; }
.ob-big { min-height: 60px; font-size: 1.375rem; font-weight: 600; }
.ob-area { padding: 14px 16px; min-height: 130px; line-height: 1.4; resize: none; }
.ob-passrow { position: relative; }
.ob-passrow .ob-input { padding-right: 52px; }
.ob-eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; display: grid; place-items: center; color: var(--label2); }
.ob-eye svg { width: 22px; height: 22px; }
.ob-err { min-height: 20px; margin: 8px 2px; font-size: .875rem; color: var(--red); }
.ob-top { display: flex; align-items: center; gap: 10px; }
.ob-bar { flex: 1; height: 5px; border-radius: 3px; background: var(--fill); overflow: hidden; }
.ob-bar i { display: block; height: 100%; border-radius: 3px; background: var(--accent); transition: width .3s var(--ease); }
.ob-count { font-size: .8125rem; font-variant-numeric: tabular-nums; color: var(--label2); min-width: 38px; text-align: right; }
.ob-q .ob-body { flex: 1; }
.ob-foot { display: grid; gap: 6px; position: sticky; bottom: 0; padding-top: 10px; }
.ob-choices { display: grid; gap: 10px; }
.ob-choice { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 60px; padding: 12px 16px; border-radius: 16px; text-align: left;
  background: var(--bg-card); color: var(--label); box-shadow: inset 0 0 0 .5px var(--separator); transition: transform .12s, box-shadow .15s, background .15s; }
.ob-choice:active { transform: scale(.985); }
.ob-choice strong { display: block; font-size: 1.0625rem; font-weight: 600; }
.ob-choice small { display: block; margin-top: 2px; font-size: .8125rem; color: var(--label2); }
.ob-choice i { width: 24px; height: 24px; border-radius: 50%; flex: none; display: grid; place-items: center; box-shadow: inset 0 0 0 1.5px var(--label3); color: transparent; }
.ob-choice i svg { width: 15px; height: 15px; }
.ob-choice[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--accent); }
.ob-choice[aria-pressed="true"] i { background: var(--accent); color: var(--on-accent); box-shadow: none; }
.ob-chips { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 10px; }
.ob-chips .chip { min-height: 46px; padding: 0 18px; font-size: 1rem; }
.ob-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(64px, 1fr)); }
.ob-grid .chip { justify-content: center; padding: 0 6px; }
.ob-numrow { display: flex; align-items: baseline; gap: 10px; }
.ob-numrow span { font-size: 1.125rem; color: var(--label2); font-weight: 500; }
.ob-num { width: 132px; min-height: 76px; font-size: 2.5rem; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; padding: 0 8px; }
.ob-num::-webkit-outer-spin-button, .ob-num::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.ob-recap { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 4px 0 26px; }
.ob-recap div { padding: 12px 6px; border-radius: 14px; background: var(--bg-card); box-shadow: inset 0 0 0 .5px var(--separator); }
.ob-recap small { display: block; font-size: .6875rem; letter-spacing: .08em; text-transform: uppercase; color: var(--label2); margin-bottom: 4px; }
.ob-recap strong { font-size: .875rem; font-weight: 600; }

/* live AI coach line (spoken + shown) */
.coach-line { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0 2px; padding: 12px 14px; border-radius: 16px; background: var(--bg-card); box-shadow: inset 0 0 0 .5px var(--separator);
  font-size: .9375rem; line-height: 1.35; opacity: 0; transform: translateY(6px); }
.coach-line.in { opacity: 1; transform: none; transition: opacity .35s ease, transform .35s var(--ease); }
.coach-line svg { width: 18px; height: 18px; flex: none; margin-top: 1px; color: var(--label2); }


/* ---------- Call mode: floating bar on top of the app ---------- */
.call-bar { position: fixed; z-index: 150; left: 50%; transform: translateX(-50%); top: calc(8px + var(--sat)); width: min(440px, calc(100vw - 20px));
  padding: 8px; border-radius: 26px; color: #fff; background: rgba(18,20,26,.82); -webkit-backdrop-filter: blur(26px) saturate(170%); backdrop-filter: blur(26px) saturate(170%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.16), inset 0 0 0 .5px rgba(255,255,255,.14), 0 14px 40px rgba(0,0,0,.45); animation: call-in .3s var(--ease) both; }
@keyframes call-in { from { opacity: 0; transform: translate(-50%, -14px); } }
.call-row { display: flex; align-items: center; gap: 8px; }
.call-orb { width: 40px; height: 40px; border-radius: 50%; flex: none; display: grid; place-items: center; background: #fff; color: #000; transition: transform .25s, box-shadow .25s; }
.call-orb svg { width: 20px; height: 20px; }
.call-bar[data-mode="listening"] .call-orb { animation: call-pulse 1.4s ease-in-out infinite; }
.call-bar[data-mode="thinking"] .call-orb { opacity: .55; }
.call-bar[data-mode="speaking"] .call-orb { box-shadow: 0 0 0 5px rgba(255,255,255,.22), 0 0 0 11px rgba(255,255,255,.09); }
@keyframes call-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255,255,255,.35); } 50% { box-shadow: 0 0 0 9px rgba(255,255,255,0); } }
.call-mid { flex: 1; min-width: 0; }
.call-state { font-size: .6875rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: rgba(255,255,255,.6); }
.call-text { font-size: .875rem; line-height: 1.25; max-height: 2.5em; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.call-btn { width: 40px; height: 40px; border-radius: 50%; flex: none; display: grid; place-items: center; background: rgba(255,255,255,.12); color: #fff; }
.call-btn svg { width: 20px; height: 20px; }
.call-btn[aria-pressed="true"] { background: #fff; color: #000; }
.call-end { background: #ff453a; }
.call-type { display: flex; gap: 8px; margin-top: 8px; }
.call-type[hidden] { display: none; }
.call-type .field { flex: 1; min-height: 40px; border-radius: 20px; background: rgba(255,255,255,.12); color: #fff; }
.call-start svg { width: 18px; height: 18px; }
@media (prefers-reduced-motion: reduce) { .call-bar, .call-bar .call-orb { animation: none !important; } }


/* ---------- Coach notes (automatic analysis) ---------- */
.coach-notes .cnote { display: flex; gap: 12px; padding: 12px 0; border-top: var(--hairline) solid var(--separator); }
.coach-notes .cnote:first-of-type { border-top: 0; padding-top: 4px; }
.cnote-ic { width: 34px; height: 34px; border-radius: 10px; flex: none; display: grid; place-items: center; background: var(--fill2); color: var(--label); position: relative; }
.cnote-ic svg { width: 18px; height: 18px; }
.cnote.new .cnote-ic::after { content: ""; position: absolute; top: -3px; right: -3px; width: 9px; height: 9px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 2px var(--bg-card); }
.cnote-body { flex: 1; min-width: 0; }
.cnote-top { display: flex; justify-content: space-between; gap: 8px; font-size: .6875rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--label2); }
.cnote-title { font-size: 1rem; font-weight: 600; margin: 3px 0 2px; }
.cnote-text { font-size: .9375rem; line-height: 1.4; color: var(--label2); }
.sheet .coach-notes { padding: 0 4px 8px; }

/* ---------- Muscle recovery ---------- */
.rec-advice { display: grid; gap: 8px; margin-top: 12px; }
.rec-advice > div { padding: 10px 12px; border-radius: 14px; background: var(--fill2); }
.rec-advice strong { display: block; font-size: .6875rem; letter-spacing: .08em; text-transform: uppercase; color: var(--label2); margin-bottom: 3px; }
.rec-advice span { font-size: .9375rem; line-height: 1.35; }
.rec-bar { height: 4px; border-radius: 2px; background: var(--fill); margin-top: 6px; overflow: hidden; }
.rec-bar i { display: block; height: 100%; border-radius: 2px; }
.rec-banner { display: flex; gap: 10px; align-items: flex-start; padding: 11px 12px; margin-bottom: 12px; border-radius: 14px; background: var(--fill2); font-size: .9375rem; line-height: 1.35; }
.rec-banner i { width: 12px; height: 12px; border-radius: 4px; flex: none; margin-top: 4px; }


/* ---------- Coaching engine ---------- */
.eng-hint:empty { display: none; }
.eng-hint, .eng-verdict { display: grid; gap: 6px; margin-top: 10px; }
.eng-row { display: flex; gap: 9px; align-items: flex-start; padding: 10px 12px; border-radius: 14px; background: var(--fill2); font-size: .875rem; line-height: 1.35; }
.eng-row svg { width: 17px; height: 17px; flex: none; margin-top: 1px; color: var(--label2); }
.eng-row.warn, .eng-verdict[data-code="missed"] .eng-row, .eng-verdict[data-code="grind"] .eng-row, .eng-verdict[data-code="fading"] .eng-row { box-shadow: inset 0 0 0 1px rgba(255,159,10,.45); }
.eng-row.warn svg, .eng-verdict[data-code="missed"] svg, .eng-verdict[data-code="grind"] svg, .eng-verdict[data-code="fading"] svg { color: var(--orange); }
.eng-verdict .btn { justify-self: start; }
.eng-today-title { font-size: 1.125rem; font-weight: 700; letter-spacing: -.01em; margin-top: 2px; }
.eng-today-text { font-size: .9375rem; line-height: 1.4; color: var(--label2); margin-top: 3px; }
.eng-today[data-code="rest"] .eng-today-title, .eng-today[data-code="adjust"] .eng-today-title { color: var(--orange); }

.call-bar[data-mode="standby"] { background: rgba(18,20,26,.62); }
.call-bar[data-mode="standby"] .call-orb { background: rgba(255,255,255,.22); color: #fff; animation: none; }
.call-bar[data-mode="standby"] .call-text { color: rgba(255,255,255,.6); }
.call-orb { cursor: pointer; }


/* ---------- Today's plan (Train) ---------- */
.today-plan { margin-bottom: 10px; }
.tp-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 10px; }
.tp-kicker { font-size: .6875rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--label2); }
.tp-name { font-size: 1.5rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.tp-meta { font-size: .75rem; color: var(--label2); text-align: right; line-height: 1.35; white-space: nowrap; }
.tp-list { list-style: none; margin: 0 0 14px; padding: 0; }
.tp-list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: var(--hairline) solid var(--separator); }
.tp-list li:first-child { border-top: 0; }
.tp-n { width: 20px; flex: none; font-size: .8125rem; font-weight: 700; color: var(--label2); text-align: center; font-variant-numeric: tabular-nums; }
.tp-list .thumb { width: 42px; height: 42px; border-radius: 10px; flex: none; object-fit: cover; background: #fff; }
.tp-ex { min-width: 0; }
.tp-ex strong { display: block; font-size: .9375rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tp-ex small { font-size: .8125rem; color: var(--label2); }
.tp-ex em { font-style: normal; color: var(--orange); }
.tp-note { margin: 10px 2px 0; font-size: .75rem; color: var(--label3); text-align: center; line-height: 1.35; }

/* ---------- Guided session: the exercise card ---------- */
.gd-intro { position: fixed; inset: 0; z-index: 80; overflow-y: auto; background: #000; color: #fff; animation: ob-in .25s var(--ease) both; }
.gd-wrap { max-width: 520px; min-height: 100%; margin: 0 auto; padding: calc(16px + var(--sat)) 18px calc(20px + var(--sab)); display: flex; flex-direction: column; gap: 10px; }
.gd-step { font-size: .75rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: rgba(235,235,245,.6); text-align: center; }
.gd-media { border-radius: 22px; overflow: hidden; background: #fff; aspect-ratio: 1 / 1; max-height: 44vh; margin: 0 auto; width: min(100%, 44vh); }
.gd-media img { width: 100%; height: 100%; object-fit: contain; display: block; }
.gd-name { font-size: 1.625rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; text-align: center; margin: 6px 0 0; }
.gd-rx { text-align: center; font-size: 1.0625rem; color: rgba(235,235,245,.85); }
.gd-rx strong { font-size: 1.375rem; font-weight: 700; color: #fff; font-variant-numeric: tabular-nums; }
.gd-rx span { display: block; font-size: .8125rem; color: rgba(235,235,245,.55); margin-top: 2px; }
.gd-sensor { display: flex; gap: 9px; align-items: flex-start; font-size: .8125rem; line-height: 1.35; color: rgba(235,235,245,.6); padding: 2px 4px; }
.gd-sensor svg { width: 16px; height: 16px; flex: none; margin-top: 1px; }
.gd-foot { margin-top: auto; display: grid; gap: 4px; padding-top: 8px; }
.gd-foot #gd-left { font-variant-numeric: tabular-nums; }

/* moving exercises in today's plan */
.tp-list li { position: relative; background: transparent; transition: background .15s, box-shadow .15s, transform .15s; border-radius: 12px; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.tp-ex { flex: 1; }
.tp-grip { flex: none; width: 36px; height: 40px; display: grid; place-items: center; color: var(--label3); touch-action: none; cursor: grab; }
.tp-grip svg { width: 18px; height: 18px; }
.tp-list li.dragging { background: var(--bg-elev); box-shadow: 0 10px 30px rgba(0,0,0,.35), inset 0 0 0 1px var(--separator); transform: scale(1.02); z-index: 2; border-top-color: transparent; }
.tp-list li.dragging .tp-grip { color: var(--label); cursor: grabbing; }
.tp-list.sorting li:not(.dragging) { opacity: .75; }
.tp-reset { color: var(--label2); text-decoration: underline; font-size: inherit; }
.today-plan .tp-start { width: 100%; }


/* ---------- The AI mark: two purple stars, only on what runs on the AI ---------- */
:root { --ai: #a24bf0; }
.theme-mono, .live-root, .gd-intro, .call-bar { --ai: #c77dff; }
.theme-mono[data-theme="light"] { --ai: #8a3ffc; }
.theme-mono[data-theme="light"] .live-root, .theme-mono[data-theme="light"] .call-bar { --ai: #c77dff; }
.ai-ic, .ai-ic .ic, .ai-ic svg { color: var(--ai) !important; }
.ai-ic { display: inline-flex; align-items: center; }
.ai-ic.ai-sm svg { width: 12px; height: 12px; vertical-align: -1px; }
.btn .ai-ic svg { width: 18px; height: 18px; }
.theme-mono .btn:not(.btn-gray):not(.btn-plain):not(.btn-danger) .ai-ic svg { color: #7a2ff0 !important; }      /* on the white button */
.theme-mono[data-theme="light"] .btn:not(.btn-gray):not(.btn-plain):not(.btn-danger) .ai-ic svg { color: #d7a8ff !important; }   /* on the black button */
.row-icon.ai-bg { background: var(--ai); color: #fff; }
.row-icon.ai-bg svg { color: #fff !important; }
.coach-orb.ai-ic svg { color: var(--ai) !important; }
.theme-mono .coach-orb.ai-ic { color: var(--ai) !important; }
.call-orb svg { color: #8a3ffc; }
.call-bar[data-mode="standby"] .call-orb svg { color: #e3c8ff; }
.tabbar [data-route="coach"] svg, .side-item[data-route="coach"] svg { color: var(--ai); }
.ai-note { display: flex; gap: 7px; align-items: center; font-size: .75rem; color: var(--label2); margin: 2px 2px 8px; }
.ai-note svg { width: 14px; height: 14px; }
.coach-line .ai-ic svg { width: 18px; height: 18px; }


/* ---------- Exercise pictures: poses that cross-fade, in three looks ---------- */
.pose-anim { position: relative; width: 100%; aspect-ratio: 1 / 1; }
.pose-anim img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; opacity: 0; transition: opacity .55s ease-in-out; }
.pose-anim img.on { opacity: 1; }
.exmedia { padding: 0; }
.exmedia .pose-anim { width: min(100%, 380px); margin: 0 auto; }
.exmedia .pose-anim img { width: 100%; max-width: none; margin: 0; }
.gd-media .pose-anim { height: 100%; }
html[data-exlook="night"] .thumb, html[data-exlook="night"] .exmedia, html[data-exlook="night"] .gd-media { background: #000; }
html[data-exlook="holo"] .thumb, html[data-exlook="holo"] .exmedia, html[data-exlook="holo"] .gd-media { background: #02040a; }
html[data-exlook="night"] .thumb, html[data-exlook="holo"] .thumb { box-shadow: inset 0 0 0 .5px rgba(255,255,255,.14); }
html[data-exlook="night"] .exmedia, html[data-exlook="holo"] .exmedia { box-shadow: inset 0 0 0 .5px rgba(255,255,255,.12); }
.look-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.look-pick button { display: grid; gap: 6px; justify-items: center; padding: 8px 6px 9px; border-radius: 16px; background: var(--fill2); color: var(--label2); font-size: .8125rem; font-weight: 600; }
.look-pick img { width: 100%; aspect-ratio: 1; border-radius: 11px; object-fit: cover; background: #fff; }
.look-pick button[data-look="night"] img { background: #000; }
.look-pick button[data-look="holo"] img { background: #02040a; }
.look-pick button[aria-checked="true"] { box-shadow: inset 0 0 0 2px var(--accent); color: var(--label); }
@media (prefers-reduced-motion: reduce) { .pose-anim img { transition: none; } }

/* ---------- Cloud account screens ---------- */
.ob-link { display: block; margin: 10px 2px 0 auto; padding: 4px 0; font-size: .875rem; font-weight: 600; color: var(--accent); background: none; }
.ob-code { text-align: center; letter-spacing: .42em; font-variant-numeric: tabular-nums; font-size: 1.6rem; font-weight: 700; padding-left: .42em; }
.ob-close { position: absolute; top: max(14px, env(safe-area-inset-top)); left: 14px; }
.ob-wrap.ob-center { position: relative; }
