/* GymOrbita — design system
   Typography: Inter, 4 sizes (12 / 15 / 20 / 28) and 2 weights (500 / 700); Sora only for the brand
   Spacing: 4/8 px grid
   Colour 60/30/10: night blue #0B0F1A · lavender #E0E7FF · blue #3B82F6 → violet #A855F7 gradient for actions and indicators */

:root {
  --bg: #0b0f1a;
  --surface: #11162e;
  --surface-2: #19203f;
  --navy: #1e2a5b;
  --line: rgb(224 231 255 / 0.08);
  --text: #eef1ff;
  --text-2: rgb(224 231 255 / 0.72);
  --text-3: rgb(224 231 255 / 0.5);
  --blue: #3b82f6;
  --violet: #a855f7;
  --accent: #7c8cff;
  --accent-ink: #ffffff;
  --grad: linear-gradient(90deg, #3b82f6, #a855f7);
  --accent-soft: rgb(99 102 241 / 0.16);
  --accent-line: rgb(139 124 255 / 0.5);
  --danger: #ff5a7a;
  --danger-soft: rgb(255 90 122 / 0.12);
  --gold: #ffc94d;

  --fs-sm: 12px;
  --fs-md: 15px;
  --fs-lg: 20px;
  --fs-xl: 28px;
  --fw: 500;
  --fw-bold: 700;

  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 24px;
  --shadow: 0 8px 24px rgb(0 0 0 / 0.35);
  --glow: 0 8px 24px rgb(124 58 237 / 0.35), inset 0 1px 0 rgb(255 255 255 / 0.25);
  --tabbar-h: 64px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: var(--fs-md);
  font-weight: var(--fw);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body.has-tabbar main { padding-bottom: calc(var(--tabbar-h) + 32px + env(safe-area-inset-bottom)); }
body.has-cta main { padding-bottom: calc(var(--tabbar-h) + 104px + env(safe-area-inset-bottom)); }
body.has-cta:not(.has-tabbar) main { padding-bottom: calc(104px + env(safe-area-inset-bottom)); }

.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: var(--fs-sm); }
.bold { font-weight: var(--fw-bold); }
.accent { color: var(--accent); }

/* ---------- icons ---------- */
.icon {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.icon.sm { width: 16px; height: 16px; }
.icon.lg { width: 24px; height: 24px; }

/* ---------- header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px; min-height: 56px;
  padding: calc(env(safe-area-inset-top) + 8px) 16px 8px;
  background: rgb(11 15 26 / 0.82);
  backdrop-filter: saturate(160%) blur(16px);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  border-bottom: 1px solid var(--line);
}
/* Native app: the header stays put while the content rubber-bands (sticky would move with it);
   --topbar-h is kept up to date from app.js */
.native-app .topbar { position: fixed; left: 0; right: 0; }
.native-app body:not(.bare) { padding-top: var(--topbar-h, calc(env(safe-area-inset-top) + 57px)); }
/* Loading under the header: a single discreet shooting star crosses its bottom edge once */
.loadbar {
  position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; overflow: hidden; pointer-events: none;
}
.loadbar::before {
  content: ""; position: absolute; top: 1px; left: 0; width: 90px; height: 1px;
  background: linear-gradient(90deg, transparent, rgb(59 130 246 / 0.5) 45%, rgb(168 85 247 / 0.9));
  animation: loadbar-shoot 1s cubic-bezier(.35, 0, .65, 1) forwards;
}
.loadbar::after {
  content: ""; position: absolute; top: 0; left: 0; width: 3px; height: 3px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 6px 1px rgb(196 181 253 / 0.8);
  animation: loadbar-head 1s cubic-bezier(.35, 0, .65, 1) forwards;
}
@keyframes loadbar-shoot {
  0% { transform: translateX(-90px); opacity: 0; }
  15% { opacity: 1; }
  80% { opacity: 1; }
  100% { transform: translateX(100vw); opacity: 0; }
}
@keyframes loadbar-head {
  0% { transform: translateX(-3px); opacity: 0; }
  15% { opacity: 1; }
  80% { opacity: 1; }
  100% { transform: translateX(calc(100vw + 87px)); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .loadbar { display: none; } }
.topbar h1 {
  margin: 0; flex: 1; min-width: 0; font-size: var(--fs-lg); font-weight: var(--fw-bold);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.icon-btn {
  display: grid; place-items: center; width: 40px; height: 40px; margin-left: -8px;
  border-radius: 50%; background: none; color: var(--text); padding: 0;
}
.icon-btn:active { background: var(--surface-2); }

main { max-width: 560px; margin: 0 auto; padding: 16px; }

/* ---------- sections ---------- */
.section { margin-top: 32px; }
.section:first-child { margin-top: 8px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.section-title { margin: 0; font-size: var(--fs-lg); font-weight: var(--fw-bold); }
.section-link { color: var(--accent); text-decoration: none; font-size: var(--fs-md); }
.hint { margin: -4px 0 16px; color: var(--text-2); }

/* ---------- cards and lists ---------- */
.list { display: flex; flex-direction: column; gap: 8px; }
.card {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 16px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--line);
  color: inherit; text-decoration: none; text-align: left; font: inherit;
  justify-content: flex-start; white-space: normal; min-height: 0;
}
a.card:active, button.card:active { background: var(--surface-2); }
.card .grow { flex: 1; min-width: 0; }
.card .title { font-weight: var(--fw-bold); }
.card .meta { color: var(--text-2); font-size: var(--fs-sm); margin-top: 2px; }
.card .chev { color: var(--text-3); }
.card.selected { border-color: var(--accent-line); background: linear-gradient(var(--accent-soft), var(--accent-soft)), var(--surface); }
.card.dashed { border-style: dashed; border-color: rgb(255 255 255 / 0.16); background: transparent; }
.panel { padding: 16px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line); }
.panel > * + * { margin-top: 12px; }

.tile-icon {
  display: grid; place-items: center; width: 44px; height: 44px; flex: none;
  border-radius: var(--r-sm); background: var(--surface-2); color: var(--text-2);
}
.tile-icon.accent { background: var(--accent-soft); color: var(--accent); }

.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px;
  padding: 32px 16px; border-radius: var(--r-md); border: 1px dashed rgb(255 255 255 / 0.12);
  color: var(--text-2);
}
.empty .icon { width: 32px; height: 32px; color: var(--text-3); }
.empty .title { color: var(--text); font-weight: var(--fw-bold); }
.empty .button { margin-top: 8px; }

/* ---------- buttons ---------- */
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border: 0; border-radius: var(--r-sm);
  font: inherit; font-weight: var(--fw-bold); text-decoration: none; white-space: nowrap; cursor: pointer;
  background: var(--surface-2); color: var(--text);
  transition: transform 0.12s ease, background 0.15s ease, box-shadow 0.15s ease;
}
button:active, .button:active { transform: scale(0.97); }
button:disabled { opacity: 0.4; pointer-events: none; }
.primary { background: var(--grad); color: var(--accent-ink); box-shadow: var(--glow); }
.ghost { background: transparent; color: var(--text-2); }
.danger { background: var(--danger-soft); color: var(--danger); }
.block { display: flex; width: 100%; min-height: 52px; }
.row { display: flex; gap: 8px; align-items: center; }
.row > .grow { flex: 1; }
.row.wrap { flex-wrap: wrap; }

/* Fixed CTA in the thumb zone */
.cta-bar {
  position: fixed; left: 0; right: 0; z-index: 9;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding: 16px; background: linear-gradient(transparent, var(--bg) 40%);
}
body:not(.has-tabbar) .cta-bar { bottom: 0; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
.cta-bar > * { max-width: 528px; margin: 0 auto; }

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: center;
  padding-bottom: env(safe-area-inset-bottom);
  background: rgb(11 15 26 / 0.9);
  backdrop-filter: saturate(160%) blur(16px);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  border-top: 1px solid var(--line);
}
.tabbar[hidden] { display: none; }
.tabbar a {
  flex: 1; max-width: 112px; height: var(--tabbar-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--text-3); text-decoration: none; font-size: 11px; font-weight: var(--fw-bold); letter-spacing: 0.01em;
  -webkit-tap-highlight-color: transparent;
}
/* the active tab: a pill behind its icon */
.tab-ic { position: relative; display: grid; place-items: center; width: 56px; height: 30px; border-radius: 999px;
  transition: background 0.2s ease, transform 0.2s ease; }
.tabbar a .icon { width: 22px; height: 22px; transition: color 0.2s ease; }
.tabbar a.on { color: var(--text); }
.tabbar a.on .tab-ic { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent-line); }
.tabbar a.on .icon { color: var(--accent); }
.tabbar a:active .tab-ic { transform: scale(0.92); }
.tab-label { white-space: nowrap; }
.tab-badge {
  position: absolute; top: -3px; right: 6px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px;
  background: #f43f5e; color: #fff; font-size: 10px; line-height: 17px; text-align: center; box-shadow: 0 0 0 2px var(--bg);
}
/* gym mode: a gradient line along the top of the bar */
.tabbar.gym { border-top-color: transparent; }
.tabbar.gym::before { content: ""; position: absolute; left: 0; right: 0; top: -1px; height: 2px; background: var(--grad); opacity: 0.8; }

/* ---------- forms ---------- */
input, select {
  width: 100%; min-width: 0; min-height: 48px; padding: 0 16px;
  font: inherit; color: var(--text);
  background: var(--surface-2); border: 1px solid transparent; border-radius: var(--r-sm); outline: none;
}
input:focus { border-color: var(--accent-line); box-shadow: 0 0 0 4px var(--accent-soft); }
/* iOS zooms into any field with text under 16px when it's focused (and in the app the page stays zoomed):
   on touch screens fields are at least 16px */
@media (pointer: coarse) { input, select, textarea { font-size: max(16px, 1em) !important; } }
input::placeholder { color: var(--text-3); }
.field { display: flex; flex-direction: column; gap: 4px; font-size: var(--fs-sm); color: var(--text-2); }
.inline { display: flex; gap: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.search { position: relative; }
.search .icon { position: absolute; left: 16px; top: 14px; color: var(--text-3); pointer-events: none; }
.search input { padding-left: 48px; }

/* ---------- chips and selectors ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; margin: 12px -16px; padding: 0 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; min-height: 36px; padding: 0 12px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  color: var(--text-2); font-size: var(--fs-sm); font-weight: var(--fw-bold); text-decoration: none; white-space: nowrap;
}
.chip.on { background: var(--grad); border-color: transparent; color: var(--accent-ink); }
.tag {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-2); font-size: var(--fs-sm); white-space: nowrap;
}
.tag.accent { background: var(--accent-soft); color: var(--accent); }
.tag.gold { background: rgb(255 201 77 / 0.14); color: var(--gold); }

.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: var(--r-sm); background: var(--surface-2); }
.segmented button { min-height: 36px; padding: 0 8px; background: transparent; color: var(--text-2); font-size: var(--fs-sm); border-radius: 8px; }
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.day-picker { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.day-picker button { min-height: 44px; padding: 0; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--line); color: var(--text-2); }
.day-picker button.on { background: var(--grad); border-color: transparent; color: var(--accent-ink); box-shadow: var(--glow); }

.option-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.option {
  flex-direction: column; align-items: flex-start; gap: 8px; min-height: 88px; padding: 16px;
  border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line); color: var(--text); text-align: left; white-space: normal;
}
.option .icon { color: var(--text-2); }
.option.on { border-color: var(--accent-line); background: linear-gradient(var(--accent-soft), var(--accent-soft)), var(--surface); }
.option.on .icon { color: var(--accent); }

/* ---------- avatar ---------- */
.avatar {
  display: grid; place-items: center; flex: none; border-radius: 50%; object-fit: cover;
  background: var(--surface-2); color: var(--text); font-weight: var(--fw-bold);
}

/* ---------- home ---------- */
.greeting { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.greeting .hello { font-size: var(--fs-xl); font-weight: var(--fw-bold); line-height: 1.15; }
.greeting .where { display: flex; align-items: center; gap: 4px; margin-top: 4px; color: var(--text-2); }

.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.week button {
  flex-direction: column; gap: 4px; min-height: 64px; padding: 8px 0;
  border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--line); color: var(--text-2);
}
.week .d { font-size: var(--fs-sm); }
.week .n { font-size: var(--fs-lg); font-weight: var(--fw-bold); color: var(--text); }
.week .dot { width: 6px; height: 6px; border-radius: 50%; background: transparent; }
.week button.has .dot { background: var(--grad); }
.week button.done .dot { background: var(--text); }
.week button.today { border-color: var(--accent-line); }
.week button.sel { background: var(--grad); border-color: transparent; color: var(--accent-ink); }
.week button.sel .n { color: var(--accent-ink); }
/* selected: the dot only when that day has a routine or a workout */
.week button.sel.has .dot, .week button.sel.done .dot { background: var(--accent-ink); }

.hero-card {
  position: relative; overflow: hidden; padding: 24px; border-radius: var(--r-lg);
  background: radial-gradient(120% 80% at 100% 0%, rgb(124 92 255 / 0.28), transparent 60%), var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow);
}
.hero-card .eyebrow { color: var(--accent); font-size: var(--fs-sm); font-weight: var(--fw-bold); text-transform: uppercase; letter-spacing: 0.08em; }
.hero-card .big { margin: 8px 0 4px; font-size: var(--fs-xl); font-weight: var(--fw-bold); line-height: 1.15; }
.hero-card .thumbs { display: flex; margin: 16px 0 24px; }
.hero-card .thumbs img, .hero-card .thumbs .more {
  width: 48px; height: 48px; border-radius: 50%; object-fit: cover; background: #fff;
  border: 2px solid var(--surface); margin-left: -8px;
}
.hero-card .thumbs :first-child { margin-left: 0; }
.hero-card .thumbs .more { display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); font-size: var(--fs-sm); }
.hero-card + .hero-card { margin-top: 8px; }

.banner {
  display: flex; align-items: center; gap: 12px; padding: 16px; border-radius: var(--r-md);
  background: var(--grad); color: var(--accent-ink); text-decoration: none; box-shadow: var(--glow);
}
.banner .grow { flex: 1; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stats.two { grid-template-columns: 1fr 1fr; }
.stat { padding: 16px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line); min-width: 0; }
.stat .v { font-size: var(--fs-lg); font-weight: var(--fw-bold); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .k { color: var(--text-3); font-size: var(--fs-sm); margin-top: 2px; }

/* ---------- exercise images ---------- */
.thumb { width: 56px; height: 56px; flex: none; border-radius: var(--r-sm); object-fit: cover; background: #fff; }
.thumb.ph { display: grid; place-items: center; background: var(--surface-2); color: var(--text-3); }
.demo { position: relative; aspect-ratio: 3 / 2; overflow: hidden; border-radius: var(--r-md); background: #fff; }
.demo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.demo img:nth-child(2) { animation: demo-swap 2.4s steps(1, end) infinite; }
@keyframes demo-swap { 0% { opacity: 0; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .demo img:nth-child(2) { animation: none; opacity: 0; } }

/* ---------- templates ---------- */
.template { overflow: hidden; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); }
.template .strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; background: #fff; }
.template .strip img, .template .strip .ph { width: 100%; aspect-ratio: 1; object-fit: cover; display: grid; place-items: center; background: var(--surface-2); color: var(--text-3); }
.template .body { padding: 16px; }
.template .body > * + * { margin-top: 12px; }
.ex-list { list-style: none; margin: 0; padding: 0; }
.ex-list li { display: flex; justify-content: space-between; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); color: var(--text-2); }
.ex-list li span:last-child { color: var(--text-3); font-variant-numeric: tabular-nums; }

/* ---------- catalog ---------- */
.catalog { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 480px) { .catalog { grid-template-columns: repeat(3, 1fr); } }
.cat-card {
  position: relative; flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 4px;
  min-height: 0; padding: 0 0 12px; overflow: hidden; white-space: normal; text-align: left;
  border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line);
}
.cat-card img, .cat-card .ph { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; background: #fff; display: grid; place-items: center; }
.cat-card .ph { background: var(--surface-2); color: var(--text-3); }
.cat-card .t { padding: 8px 12px 0; line-height: 1.3; }
.cat-card .m { padding: 0 12px; color: var(--text-3); font-size: var(--fs-sm); font-weight: var(--fw); }
.cat-card .tag { position: absolute; top: 8px; left: 8px; }

/* ---------- bottom sheet ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 30; display: flex; align-items: flex-end; justify-content: center; background: rgb(0 0 0 / 0.6); }
.sheet-backdrop[hidden] { display: none; }
.sheet {
  width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
  padding: 8px 16px calc(24px + env(safe-area-inset-bottom));
  border-radius: var(--r-lg) var(--r-lg) 0 0; background: var(--bg); border-top: 1px solid var(--line);
  animation: sheet-up 0.22s ease-out;
}
.sheet::before { content: ""; display: block; width: 40px; height: 4px; margin: 0 auto 16px; border-radius: 4px; background: var(--surface-2); }
.sheet > * + * { margin-top: 16px; }
@keyframes sheet-up { from { transform: translateY(48px); opacity: 0; } }

/* ---------- workout ---------- */
.progress { height: 8px; border-radius: 8px; background: var(--surface-2); overflow: hidden; }
.progress > div { height: 100%; border-radius: 8px; background: var(--grad); transition: width 0.3s ease; }
.exercise { padding: 16px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); }
.exercise + .exercise { margin-top: 12px; }
.exercise.complete { border-color: var(--accent-line); }
.exercise .demo { aspect-ratio: auto; height: 160px; margin-bottom: 16px; }
.exercise .demo img { object-fit: cover; }
.exercise .head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.exercise .head .title { font-size: var(--fs-lg); font-weight: var(--fw-bold); line-height: 1.25; }
.sets { list-style: none; margin: 16px 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.sets li { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 4px 0 12px; border-radius: var(--r-sm); background: var(--surface-2); }
.sets .n { width: 24px; color: var(--text-3); font-size: var(--fs-sm); }
.sets .v { flex: 1; font-weight: var(--fw-bold); font-variant-numeric: tabular-nums; }
.sets button { min-height: 36px; width: 36px; padding: 0; background: none; color: var(--text-3); }
.log { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: end; }
.log button { min-height: 48px; }

/* ---------- summary / celebration ---------- */
.celebrate { position: relative; text-align: center; padding: 32px 16px 24px; }
.celebrate .badge {
  display: grid; place-items: center; width: 96px; height: 96px; margin: 0 auto 24px; border-radius: 50%;
  background: var(--grad); color: var(--accent-ink);
  box-shadow: 0 0 0 12px var(--accent-soft), 0 16px 48px rgb(124 58 237 / 0.45);
  animation: pop 0.6s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
.celebrate .badge .icon { width: 48px; height: 48px; stroke-width: 2.5; }
.celebrate h2 { margin: 0; font-size: var(--fs-xl); font-weight: var(--fw-bold); }
.celebrate p { margin: 8px 0 0; color: var(--text-2); }
.spark { position: absolute; width: 8px; height: 8px; border-radius: 2px; opacity: 0; animation: spark 1.4s ease-out forwards; }
@keyframes pop { from { transform: scale(0.3); opacity: 0; } }
@keyframes spark {
  0% { opacity: 1; transform: translate(0, 0) rotate(0); }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(240deg); }
}
@media (prefers-reduced-motion: reduce) { .celebrate .badge, .spark { animation: none; } .spark { display: none; } }
.record {
  display: flex; align-items: center; gap: 12px; padding: 16px; border-radius: var(--r-md);
  background: linear-gradient(rgb(255 201 77 / 0.1), rgb(255 201 77 / 0.1)), var(--surface); border: 1px solid rgb(255 201 77 / 0.3);
}
.record .tile-icon { background: rgb(255 201 77 / 0.16); color: var(--gold); }

/* ---------- charts ---------- */
.chart { display: block; width: 100%; height: auto; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; }
.chart .area { fill: url(#chart-fill); }
.chart .dot { fill: var(--bg); stroke: var(--accent); stroke-width: 2; }
.chart .grid { stroke: var(--line); }
.chart text { fill: var(--text-3); font-size: 11px; font-family: inherit; }

/* ---------- login ---------- */
.login { display: flex; flex-direction: column; min-height: calc(100vh - 120px); padding-top: 48px; }
.login .logo {
  width: 96px; height: 96px; margin: 0 auto; border-radius: 28px;
  box-shadow: 0 0 0 1px var(--line), 0 16px 64px rgb(124 58 237 / 0.35);
}
.login h2 { margin: 32px 0 8px; text-align: center; font-size: var(--fs-xl); font-weight: var(--fw-bold); line-height: 1.15; }
.login p { margin: 0 auto; max-width: 320px; text-align: center; color: var(--text-2); }
.login .actions { margin-top: auto; padding-top: 48px; display: flex; flex-direction: column; gap: 8px; }
.provider {
  position: relative; min-height: 44px; font-size: var(--fs-md);
  background: var(--surface); color: var(--text); border: 1px solid rgb(255 255 255 / 0.12);
}
.provider:active { background: var(--surface-2); }
.provider .brand { position: absolute; left: 16px; width: 18px; height: 18px; color: var(--text); }
.dev-login { margin-top: 16px; }

/* ---------- toasts ---------- */
#toast {
  position: fixed; left: 50%; z-index: 40;
  bottom: calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(16px); opacity: 0; pointer-events: none;
  max-width: calc(100% - 32px); padding: 12px 16px; border-radius: 999px;
  background: var(--text); color: var(--bg); font-weight: var(--fw-bold); box-shadow: var(--shadow);
  transition: opacity 0.2s, transform 0.2s;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

details summary { cursor: pointer; color: var(--text-2); padding: 8px 0; }
.credit { margin-top: 24px; text-align: center; color: var(--text-3); font-size: var(--fs-sm); }
.skeleton { height: 72px; border-radius: var(--r-md); background: linear-gradient(90deg, var(--surface), var(--surface-2), var(--surface)); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- login (GymOrbita template) ---------- */
body.bare .topbar { display: none; }
body.bare main { padding-top: 0; }
.auth { display: flex; flex-direction: column; gap: 16px; padding-bottom: 32px; }


.auth-form { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.auth-field {
  position: relative; display: flex; align-items: center;
  border-radius: var(--r-md); background: rgb(17 22 46 / 0.6); border: 1px solid rgb(124 140 255 / 0.25);
}
.auth-field:focus-within { border-color: var(--accent-line); box-shadow: 0 0 0 4px var(--accent-soft); }
.auth-field > .icon { position: absolute; left: 16px; color: var(--text-2); }
.auth-field input { min-height: 56px; padding-left: 48px; background: transparent; border: 0; box-shadow: none; }
.auth-field input:focus { box-shadow: none; }
.auth-field .eye { position: absolute; right: 4px; min-height: 48px; width: 48px; padding: 0; background: none; color: var(--text-2); }
.auth-form .primary { min-height: 56px; border-radius: var(--r-md); margin-top: 4px; }
.auth-error { padding: 12px 16px; border-radius: var(--r-sm); background: var(--danger-soft); color: var(--danger); }
.auth-title { margin: 8px 0 0; font-size: var(--fs-xl); font-weight: var(--fw-bold); text-align: center; }
.auth-forgot { align-self: center; color: var(--accent); text-decoration: none; padding: 4px 8px; }
.auth-form .auth-forgot { align-self: flex-end; margin-top: -4px; }
.center { text-align: center; }
.verify-email .list { margin-top: 16px; }
.verify-email [role="status"]:empty { display: none; }
.verify-email [role="status"] { margin-top: 12px; }
.tag.warn { background: rgb(251 191 36 / 0.14); color: #fbbf24; }

.auth-divider { display: flex; align-items: center; gap: 16px; color: var(--text-2); margin-top: 8px; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.auth-providers { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 12px; }
.auth-providers .button {
  min-height: 52px; border-radius: var(--r-md); background: rgb(17 22 46 / 0.6);
  border: 1px solid rgb(124 140 255 / 0.25); color: #fff; gap: 10px;
}
.auth-providers .button .icon { color: #c4b5fd; }
.auth-providers .button:active { background: var(--surface-2); }
.auth-providers .brand { width: 20px; height: 20px; }
.auth-switch { margin: 0; text-align: center; color: var(--text-2); }
.auth-switch a { color: var(--accent); text-decoration: none; font-weight: var(--fw-bold); }


/* Alien thumbnails instead of photos */
.thumb.alien-stage { width: 56px; height: 56px; flex: none; border-radius: var(--r-sm); }
.hero-card .thumbs .mini {
  width: 48px; height: 48px; border-radius: 50%; margin-left: -8px; border: 2px solid var(--surface);
}
.hero-card .thumbs .mini:first-child { margin-left: 0; }
.template .strip { background: var(--surface-2); }
.template .strip-alien, .template .strip .ph { aspect-ratio: 1; }
.cat-card .cat-alien { width: 100%; aspect-ratio: 4 / 3; }

/* ---------- progress dashboard (public/charts.js) ---------- */
.range { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--line); }
.range button { min-height: 36px; background: transparent; color: var(--text-2); font-size: var(--fs-sm); border-radius: 8px; }
/* more options than fit on a phone: scroll sideways instead of squeezing */
.range.scroll { grid-auto-columns: max-content; overflow-x: auto; scrollbar-width: none; }
.range.scroll::-webkit-scrollbar { display: none; }
.range.scroll button { padding: 0 14px; }
.range button.on { background: var(--surface-2); color: var(--text); }
.dash.loading { opacity: 0.5; transition: opacity 0.2s; }
.hero-figure { padding: 24px 16px 16px; border-radius: var(--r-lg); background: radial-gradient(120% 90% at 100% 0%, rgb(124 92 255 / 0.22), transparent 60%), var(--surface); border: 1px solid var(--line); }
.hero-figure .k { color: var(--text-2); }
.hero-figure .big { font-size: 48px; font-weight: var(--fw-bold); line-height: 1.1; letter-spacing: -0.02em; margin: 4px 0 8px; }
.delta { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-sm); font-weight: var(--fw-bold); padding: 2px 8px; border-radius: 999px; }
.delta.up { background: rgb(52 211 153 / 0.14); color: #6ee7b7; }
.delta.down { background: var(--danger-soft); color: #ff8fa3; }
.delta.flat { background: var(--surface-2); color: var(--text-2); }
.chart-card { padding: 16px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line); }
.chart-card .sub { color: var(--text-3); font-size: var(--fs-sm); margin: -4px 0 12px; }
.chart { position: relative; }
.chart-svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-axis { fill: var(--text-3); font-size: 10px; font-family: inherit; font-variant-numeric: tabular-nums; }
.chart-value { fill: var(--text); font-size: 11px; font-weight: 700; font-family: inherit; }
.chart-mark { transition: opacity 0.15s; }
.chart-svg rect[tabindex]:focus { outline: none; }
.chart-svg rect[tabindex]:hover + *, .chart-mark:hover { opacity: 0.85; }
.chart-tip {
  position: absolute; z-index: 2; transform: translate(-50%, -100%); pointer-events: none; white-space: nowrap;
  padding: 6px 10px; border-radius: 10px; background: #e0e7ff; color: #0b0f1a; box-shadow: var(--shadow); text-align: center;
}
.chart-tip .v { font-weight: 700; }
.chart-tip .l { font-size: 11px; opacity: 0.7; }
.chart-data { margin-top: 8px; }
.chart-data summary { font-size: var(--fs-sm); color: var(--text-3); padding: 4px 0; }
.chart-data table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.chart-data th, .chart-data td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.chart-data th { color: var(--text-3); font-weight: 500; }
/* Admin analytics: ranked lists (full label, thin bar below) */
.ranked { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.ranked-head { display: flex; justify-content: space-between; gap: 12px; font-size: var(--fs-sm); margin-bottom: 4px; }
.ranked-label { overflow-wrap: anywhere; }
.ranked-track { height: 6px; border-radius: 3px; background: var(--surface-2); }
.ranked-fill { height: 100%; border-radius: 3px; background: #36459a; }
.ranked-fill.em { background: #7c8cff; }
/* Admin analytics: weekly retention cohorts (sequential ramp, the value always written in the cell) */
.table-wrap { overflow-x: auto; }
.cohorts { width: 100%; border-collapse: separate; border-spacing: 2px; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.cohorts th { color: var(--text-3); font-weight: 500; text-align: center; padding: 4px; }
.cohorts th:first-child, .cohorts td:first-child { text-align: left; white-space: nowrap; }
.cohorts td { padding: 8px 6px; text-align: center; border-radius: 6px; }
.cohorts td.cell { font-weight: 600; }
.heat-legend { display: flex; align-items: center; justify-content: flex-end; gap: 3px; margin-top: 8px; font-size: 10px; color: var(--text-3); }
.heat-legend i { width: 10px; height: 10px; border-radius: 2px; }
.heat-legend span { margin: 0 4px; }
.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar { display: grid; grid-template-columns: 84px 1fr 40px; align-items: center; gap: 8px; font-size: var(--fs-sm); }
.hbar-label { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { height: 12px; }
.hbar-fill { height: 100%; border-radius: 0 4px 4px 0; background: var(--muted, #36459a); background: #36459a; }
.hbar-fill.em { background: #7c8cff; }
.hbar-value { text-align: right; color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
.lift { display: grid; grid-template-columns: 44px 1fr; gap: 12px; align-items: center; }
.lift + .lift { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.lift .thumb.alien-stage { width: 44px; height: 44px; }
.lift .name { font-weight: 700; }
.lift .meta { color: var(--text-3); font-size: var(--fs-sm); }


/* ---------- logo always present in the header ---------- */
.topbar-brand { flex: 1; display: flex; align-items: center; text-decoration: none; min-height: 40px; }
.topbar-brand .wordmark { font-size: 24px; }
.topbar-mark { display: grid; place-items: center; width: 40px; height: 40px; margin-right: -4px; }
.logo-mark .glyph-o { display: block; width: 22px; height: 22px; margin: 0; overflow: visible; }
.page-title { margin: 8px 0 0; font-size: var(--fs-xl); font-weight: var(--fw-bold); line-height: 1.15; }
button.near.on { background: var(--accent-soft); color: var(--text); border: 1px solid var(--accent-line); }
.chart-legend { display: flex; gap: 16px; margin-bottom: 8px; font-size: var(--fs-sm); color: var(--text-2); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; }

/* ---------- activities: calendar ---------- */
.calendar { padding: 12px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-head .icon-btn { margin: 0; }
.cal-title { font-weight: var(--fw-bold); font-size: var(--fs-lg); text-transform: capitalize; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-week span { text-align: center; font-size: var(--fs-sm); color: var(--text-3); padding: 4px 0; }
.cal-day {
  flex-direction: column; gap: 2px; min-height: 48px; padding: 6px 0; border-radius: var(--r-sm);
  background: transparent; color: var(--text); font-weight: var(--fw);
}
.cal-day .n { font-variant-numeric: tabular-nums; }
.cal-day .dots { display: flex; gap: 3px; height: 6px; }
.cal-day .dots i { width: 6px; height: 6px; border-radius: 50%; background: #7c8cff; }
.cal-day .dots i.joined { background: #6ee7b7; }
.cal-day.past { color: var(--text-3); }
.cal-day.today { box-shadow: inset 0 0 0 1px var(--accent-line); }
.cal-day.has:not(.sel) { background: var(--surface-2); }
.cal-day.sel { background: var(--grad); color: #fff; box-shadow: var(--glow); }
.cal-day.sel .dots i { background: #fff; }
.activity {
  display: flex; align-items: center; gap: 12px; padding: 16px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--line); color: inherit; text-decoration: none;
}
.activity.joined { border-color: rgb(110 231 183 / 0.45); }
.activity .time { width: 48px; flex: none; text-align: center; }
.activity .grow { min-width: 0; }
.activity .title { font-weight: var(--fw-bold); }
.activity .meta { color: var(--text-2); font-size: var(--fs-sm); }
.activity button { min-height: 40px; padding: 0 12px; font-size: var(--fs-sm); }
.spots { margin-top: 8px; }
.meter { height: 6px; border-radius: 6px; background: rgb(124 140 255 / 0.18); overflow: hidden; margin-bottom: 4px; }
.meter > div { height: 100%; border-radius: 6px; background: #7c8cff; }
.meter > div.full { background: #ff8fa3; }
textarea {
  width: 100%; padding: 12px 16px; font: inherit; color: var(--text); resize: vertical;
  background: var(--surface-2); border: 1px solid transparent; border-radius: var(--r-sm); outline: none;
}
textarea:focus { border-color: var(--accent-line); box-shadow: 0 0 0 4px var(--accent-soft); }
.banner { cursor: pointer; }

/* ---------- gymbros ---------- */
.bro-head { display: flex; align-items: center; gap: 8px; }
.bro-head .plus { color: var(--accent); }
.bro-head .grow { margin-left: 8px; }
.vs { padding: 12px 0; border-top: 1px solid var(--line); }
.vs:first-of-type { border-top: 0; }
.vs .k { color: var(--text-3); font-size: var(--fs-sm); margin-bottom: 4px; }
.vs .bold { font-size: var(--fs-lg); }
.vs .key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
.tag-x { min-height: 0; width: 18px; height: 18px; padding: 0; margin-left: 2px; background: transparent; color: inherit; }
.invite-box {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--r-md);
  background: linear-gradient(var(--accent-soft), var(--accent-soft)), var(--surface); border: 1px solid var(--accent-line);
}
.invite-box.warn { background: rgb(255 201 77 / 0.08); border-color: rgb(255 201 77 / 0.35); color: var(--text); }
.invite-box.warn .icon { color: var(--gold); }

/* ---------- space ranks ---------- */
.rank-emblem { display: inline-block; flex: none; }
.rank-emblem svg { display: block; width: 100%; height: 100%; overflow: visible; }
.rank-emblem.tier-5 svg, .rank-emblem.tier-7 svg { filter: drop-shadow(0 0 5px rgb(252 211 77 / 0.35)); }
.rank-emblem.tier-8 svg { filter: drop-shadow(0 0 6px rgb(168 85 247 / 0.7)); }
.rank-emblem.tier-9 svg { filter: drop-shadow(0 0 7px rgb(251 191 36 / 0.6)) drop-shadow(0 0 14px rgb(236 72 153 / 0.45)); }
.rank-card {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--line); color: inherit; text-decoration: none;
}
.rank-bar { height: 8px; border-radius: 8px; background: rgb(124 140 255 / 0.16); overflow: hidden; margin: 8px 0 4px; }
.rank-bar > div { height: 100%; border-radius: 8px; background: var(--grad); }
.rank-hero { text-align: center; padding: 8px 0 0; }
.rank-hero .big { font-size: var(--fs-xl); font-weight: var(--fw-bold); margin-top: 8px; }
.ladder { display: flex; flex-direction: column; gap: 4px; }
.rung { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: var(--r-sm); }
.rung.current { background: var(--accent-soft); border: 1px solid var(--accent-line); }
.rung.locked { opacity: 0.45; filter: grayscale(0.6); }
.pos { width: 18px; text-align: center; color: var(--text-3); font-weight: var(--fw-bold); }
.points-gained { text-align: center; font-size: var(--fs-lg); color: var(--text-2); margin: -8px 0 16px; }
.points-gained .plus { font-size: var(--fs-xl); font-weight: var(--fw-bold); background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.rank-up {
  display: flex; align-items: center; gap: 16px; padding: 16px; margin-bottom: 16px; border-radius: var(--r-lg);
  background: linear-gradient(rgb(255 201 77 / 0.1), rgb(255 201 77 / 0.1)), var(--surface); border: 1px solid rgb(255 201 77 / 0.4);
  color: inherit; text-decoration: none; animation: pop 0.6s cubic-bezier(0.2, 1.4, 0.4, 1) 0.3s both;
}
.rank-up .eyebrow { color: var(--gold); font-size: var(--fs-sm); font-weight: var(--fw-bold); text-transform: uppercase; letter-spacing: 0.08em; }
.rung .grow { flex: 1; }

/* Photo with rank: progress ring, crown and a bubble on hover/tap */
.avatar-rank {
  position: relative; display: grid; place-items: center; flex: none; padding: 0; min-height: 0;
  background: none; border-radius: 50%; overflow: visible;
}
.avatar-rank .ring { position: absolute; inset: 0; width: 100%; height: 100%; }
.avatar-rank .crown {
  position: absolute; top: -6px; right: -6px;
  filter: drop-shadow(0 2px 3px rgb(0 0 0 / 0.5)); pointer-events: none;
}
.rank-tip {
  position: absolute; z-index: 15; top: calc(100% + 8px); left: 0; min-width: 190px;
  display: flex; flex-direction: column; gap: 2px; align-items: flex-start; text-align: left;
  padding: 10px 12px; border-radius: var(--r-sm); background: #1d2350; border: 1px solid var(--accent-line);
  box-shadow: var(--shadow); color: var(--text); font-size: var(--fs-sm); font-weight: var(--fw);
  opacity: 0; transform: translateY(-4px); pointer-events: none; transition: opacity 0.15s, transform 0.15s;
}
.rank-tip .rank-bar { display: block; width: 100%; margin: 4px 0; }
.rank-tip .rank-bar > span { display: block; height: 100%; border-radius: 8px; background: var(--grad); }
.avatar-rank:hover .rank-tip, .avatar-rank:focus-visible .rank-tip, .avatar-rank.open .rank-tip { opacity: 1; transform: none; }
.card .avatar-rank .rank-tip { left: auto; right: -160px; }

/* Gym panel getting-started steps */
.card.done { opacity: 0.6; }
.card.done .tile-icon { color: #6ee7b7; }

/* Gym machine videos */
.gym-videos { display: grid; gap: 8px; margin: 12px 0; }
.gym-video { display: block; width: 100%; max-height: 70vh; margin-top: 12px; border-radius: var(--r-md); background: #000; }
.upload-bar { height: 8px; margin-top: 12px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.upload-bar > span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--grad); transition: width 0.2s; }

/* Notifications bell (header) */
.bell { position: relative; display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 50%; color: var(--text); }
.bell:active { background: var(--surface-2); }
.bell .icon { width: 22px; height: 22px; }
.bell .badge {
  position: absolute; top: 3px; right: 1px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: #f43f5e; color: #fff; font-size: 11px; font-weight: var(--fw-bold); line-height: 18px; text-align: center;
  box-shadow: 0 0 0 2px var(--bg);
}
.notif { display: flex; gap: 12px; align-items: flex-start; text-align: left; }
.notif.unread { border-color: var(--accent-line); background: linear-gradient(var(--accent-soft), var(--accent-soft)), var(--surface); }
.notif .body { flex: 1; min-width: 0; }
.notif .t { font-weight: var(--fw-bold); }
.notif .d { margin-top: 2px; color: var(--text-2); white-space: pre-line; overflow-wrap: anywhere; }
.notif .when { margin-top: 6px; font-size: var(--fs-sm); color: var(--text-3); }
.notif .dot { width: 8px; height: 8px; margin-top: 8px; border-radius: 50%; background: var(--grad); flex: none; }
.username { color: var(--text-3); }

/* Login and sign-up: static logo with the tagline (without the rocket animation) */
.auth-brand.static { margin-top: 64px; margin-bottom: 8px; }
.auth-brand.static .w-gym, .auth-brand.static .orbit, .auth-brand.static .orbit-a, .auth-brand.static .tagline, .auth-brand.static .glyph { opacity: 1; animation: none; }
.login-stars.static { opacity: 1; animation: none; }
/* full-width lunar footer (styles in /web/moon-footer.css) */
.auth .auth-footer.moon-footer { margin: auto calc(50% - 50vw) -64px; }
.auth { min-height: calc(100vh - 32px); }

/* «GymBro» in the logo colours */
.gymbro { white-space: nowrap; }
.gymbro .bro { background: linear-gradient(90deg, #6366f1, #a855f7); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* Login and sign-up: back to the website */
.auth-home {
  position: absolute; top: calc(env(safe-area-inset-top) + 16px); left: 0; z-index: 2; align-self: flex-start;
  display: inline-flex; align-items: center; gap: 4px; min-height: 40px; padding: 0 12px 0 6px; border-radius: 999px;
  color: var(--text-2); font-weight: var(--fw-bold); font-size: var(--fs-sm); text-decoration: none;
  background: rgb(17 22 46 / 0.6); border: 1px solid var(--line);
}
.auth-home:hover { color: var(--text); }
.auth { position: relative; }

/* ---------- desktop: side menu and wider content ---------- */
.sidebar { display: none; }
@media (min-width: 1024px) {
  /* content column width: the top bar aligns with it (arrow and title start where the content does) */
  body.has-sidebar { --side-w: 260px; --content-w: 960px; padding-left: var(--side-w); }
  body.has-sidebar:has(main .gym-dash), body.has-sidebar:has(main .members-table), body.has-sidebar:has(main .week-board) { --content-w: 1160px; }
  body.has-sidebar .tabbar { display: none !important; }
  body.has-sidebar main { max-width: var(--content-w); padding: 24px 40px; }
  body.has-sidebar.has-tabbar main { padding-bottom: 48px; }
  body.has-sidebar.has-cta main { padding-bottom: 120px; }
  body.has-sidebar .cta-bar { left: var(--side-w); bottom: 0; padding-bottom: 16px; }
  body.has-sidebar .cta-bar > * { max-width: calc(var(--content-w) - 80px); }
  body.has-sidebar .topbar { --edge: max(40px, calc((100% - var(--content-w)) / 2 + 40px)); padding-left: var(--edge); padding-right: var(--edge); }
  body.has-sidebar .topbar .icon-btn { margin-left: -10px; }
  body.has-sidebar .topbar-brand { display: none !important; }
  body.has-sidebar .bell { display: none !important; } /* on desktop, notifications live in the side menu */
  body.has-sidebar #toast { left: calc(50% + var(--side-w) / 2); }
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 20; width: var(--side-w);
    display: flex; flex-direction: column; gap: 20px; padding: 24px 16px 16px; overflow-y: auto;
    background: rgb(11 15 26 / 0.96); border-right: 1px solid var(--line);
  }
  .sidebar[hidden] { display: none; }
  .side-logo { display: flex; padding: 4px 10px 8px; text-decoration: none; }
  .side-logo .wordmark { font-size: 26px; }
  .side-group { display: flex; flex-direction: column; gap: 2px; }
  .side-label { padding: 8px 12px 6px; font-size: var(--fs-sm); color: var(--text-3); }
  .sidebar a:not(.side-logo) {
    display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 12px;
    color: var(--text-2); text-decoration: none; font-weight: var(--fw-bold); font-size: 15px;
  }
  .sidebar a:not(.side-logo):hover { background: var(--surface); color: var(--text); }
  .sidebar a.on { background: var(--accent-soft); color: var(--text); }
  .sidebar a.on .icon { color: var(--accent); }
  .sidebar .icon { width: 20px; height: 20px; flex: none; }
  .side-dot { width: 9px; height: 9px; border-radius: 50%; background: #f43f5e; box-shadow: 0 0 0 3px rgb(244 63 94 / 0.2), 0 0 10px rgb(244 63 94 / 0.6); }
  .side-dot[hidden] { display: none; }
  .side-badge { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; background: #f43f5e; color: #fff; font-size: 12px; line-height: 22px; text-align: center; }
  .side-me { margin-top: auto; min-height: 60px !important; border-top: 1px solid var(--line); border-radius: 0 !important; padding-top: 12px !important; }
  .side-me .grow { display: flex; flex-direction: column; min-width: 0; }
  .side-me .bold { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
  .side-toggle {
    display: flex; align-items: center; justify-content: center; align-self: flex-start; width: 40px; min-height: 40px; margin: auto 0 0 2px; padding: 0; border: 0; border-radius: 12px;
    background: none; color: var(--text-3); font: inherit; font-size: var(--fs-sm); font-weight: var(--fw-bold); cursor: pointer; text-align: left;
  }
  .side-toggle:hover { background: var(--surface); color: var(--text); }
  .side-toggle + .side-me { margin-top: 0; }
  /* only while folding/unfolding (not on every screen change) */
  body.side-anim, body.side-anim .sidebar, body.side-anim .cta-bar { transition: padding-left 0.2s ease, width 0.2s ease, left 0.2s ease; }

  /* text a step larger: on a monitor the phone sizes read too small (charts included) */
  body.has-sidebar { --fs-sm: 13px; --fs-md: 16px; }
  body.has-sidebar .chart text, body.has-sidebar .chart-value { font-size: 13px; }
  body.has-sidebar .chart-axis { font-size: 12.5px; }
  body.has-sidebar .chart-tip .l, body.has-sidebar .heat-legend { font-size: 12px; }
  /* full-width buttons a bit lower than on the phone */
  body.has-sidebar main .block { min-height: 46px; }
  /* the screen's main action floats at the bottom right instead of a full-width bar */
  body.has-sidebar .cta-bar { background: none; pointer-events: none; padding: 0 40px 24px; }
  body.has-sidebar .cta-bar > * { display: flex; justify-content: flex-end; max-width: var(--content-w); margin: 0 auto; padding: 0 40px; }
  body.has-sidebar .cta-bar .block { pointer-events: auto; width: auto; min-width: 0; min-height: 48px; padding: 0 24px; }
  body.has-sidebar.has-cta main { padding-bottom: 104px; }
  /* more columns where there's room */
  body.has-sidebar .stats.two { grid-template-columns: repeat(4, 1fr); }
  body.has-sidebar .option-grid { grid-template-columns: repeat(4, 1fr); }
  body.has-sidebar .catalog { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }

  /* folded: icons only, and the logo is just the orbiting O */
  body.has-sidebar.side-collapsed { --side-w: 76px; }
  .side-collapsed .sidebar { padding-left: 12px; padding-right: 12px; overflow-x: hidden; }
  .side-collapsed .sidebar .grow, .side-collapsed .side-label { display: none; }
  .side-collapsed .sidebar a:not(.side-logo) { justify-content: center; padding: 0; position: relative; }
  .side-collapsed .side-toggle { align-self: center; margin-left: 0; }
  .side-collapsed .side-group + .side-group { border-top: 1px solid var(--line); padding-top: 12px; }
  .side-collapsed .side-dot { position: absolute; top: 8px; right: 12px; }
  .side-collapsed .side-me { padding-top: 12px !important; }
  .side-collapsed .side-logo { justify-content: center; padding: 4px 0 8px; }
  .side-collapsed .side-logo .w-gym, .side-collapsed .side-logo .orbit { display: none; }
  .side-collapsed .side-logo .wordmark { font-size: 34px; }
}

/* ---------- gym management ---------- */
.gym-kpis { grid-template-columns: repeat(3, 1fr); }
.members-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.members-tools .search { flex: 1 1 220px; }
.members-tools select { width: auto; flex: 0 0 auto; }
.members-tools .ghost { flex: 0 0 auto; }
.members-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.members-table th { text-align: left; font-size: var(--fs-sm); font-weight: var(--fw-bold); color: var(--text-3); padding: 10px 12px; border-bottom: 1px solid var(--line); }
.members-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; color: var(--text-2); }
.members-table td.num { font-variant-numeric: tabular-nums; }
.members-table td.actions { white-space: nowrap; text-align: right; }
.members-table .role-select { min-height: 38px; width: auto; padding: 0 10px; }
.members-table tbody tr:hover { background: rgb(124 140 255 / 0.04); }
/* on mobile, each row is a card */
@media (max-width: 760px) {
  .members-table thead { display: none; }
  .members-table, .members-table tbody, .members-table tr, .members-table td { display: block; width: 100%; }
  .members-table tr { margin-bottom: 10px; padding: 12px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line); }
  .members-table td { border: 0; padding: 4px 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
  .members-table td[data-label]:not(:first-child)::before { content: attr(data-label); color: var(--text-3); font-size: var(--fs-sm); }
  .members-table td:first-child { padding-bottom: 8px; }
  .members-table td.actions { justify-content: flex-end; }
}
@media (min-width: 1024px) {
  body.has-sidebar.main-screen .topbar { display: none; }
  .gym-kpis { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  /* two columns that fill without gaps */
  .gym-dash { columns: 2; column-gap: 28px; }
  .gym-dash > * { break-inside: avoid; margin: 0 0 32px !important; }
  .gym-dash > .span-all { margin-bottom: 36px !important; }
  .gym-dash > .span-all { column-span: all; }
}

/* Activities: weekly board (desktop only) */
.week-board { display: none; }
@media (min-width: 1024px) {
  .act-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; align-items: start; }
  .act-layout > .section { margin-top: 0; }
  .week-board { display: block; }
  .wb-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
  .wb-col { min-height: 180px; padding: 8px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
  .wb-col.today { border-color: var(--accent-line); }
  .wb-col.sel { background: linear-gradient(var(--accent-soft), var(--accent-soft)), var(--surface); }
  .wb-head { display: flex; align-items: center; justify-content: space-between; }
  .wb-day { display: flex; flex-direction: column; align-items: flex-start; gap: 0; min-height: 0; padding: 2px 4px; background: none; color: var(--text); }
  .wb-add { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; color: var(--text-3); }
  .wb-add:hover { background: var(--surface-2); color: var(--text); }
  .wb-item { display: flex; flex-direction: column; gap: 3px; padding: 8px; border-radius: 10px; background: var(--surface-2); text-decoration: none; color: var(--text); font-size: 14px; }
  .wb-item.joined { box-shadow: inset 3px 0 0 var(--accent); }
  .wb-item:hover { background: rgb(124 140 255 / 0.14); }
  .wb-meter { height: 4px; border-radius: 4px; background: rgb(224 231 255 / 0.1); overflow: hidden; }
  .wb-meter i { display: block; height: 100%; background: var(--grad); }
  .wb-meter i.full { background: #f472b6; }
  .wb-empty { padding: 6px 4px; }
}

/* Notifications: read ones softer, unread ones highlighted; each opens and can be deleted */
.notif { display: flex; align-items: flex-start; gap: 4px; padding: 0; }
.notif .notif-main { flex: 1; min-width: 0; display: flex; gap: 12px; align-items: flex-start; padding: 14px 0 14px 14px; text-decoration: none; color: inherit; }
.notif .notif-del { flex: none; margin: 8px 6px 0 0; color: var(--text-3); }
.notif .notif-del:hover { color: var(--danger); }
.notif.read { background: transparent; border-color: rgb(255 255 255 / 0.06); }
.notif.read .t { font-weight: 500; color: var(--text-2); }
.notif.read .d, .notif.read .when { color: var(--text-3); }
.notif.read .avatar, .notif.read .tile-icon { opacity: 0.6; }
.notif .d.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.notif-detail { display: flex; flex-direction: column; gap: 16px; }
.notif-title { margin: 0; font-size: var(--fs-lg); line-height: 1.3; }
.notif-text { margin: 0; color: var(--text); line-height: 1.6; white-space: pre-line; }

/* ---------- AI assistant (public/assistant.js) ---------- */
/* The sparkle button: a slowly turning gradient halo behind a four-point star that twinkles now and then */
.ai-btn {
  position: relative; display: grid; place-items: center; width: 40px; height: 40px; min-height: 0; padding: 0; flex: none;
  border-radius: 50%; background: none; isolation: isolate;
}
/* a soft glow that breathes (only opacity animates: a turning blurred gradient was costly on phones) */
.ai-btn::before {
  content: ""; position: absolute; inset: 2px; z-index: -1; border-radius: 50%;
  background: radial-gradient(circle, rgb(124 140 255 / 0.55), rgb(168 85 247 / 0.25) 45%, transparent 70%);
  opacity: 0.6; animation: ai-breathe 3.2s ease-in-out infinite alternate;
}
@keyframes ai-breathe { from { opacity: 0.35; } to { opacity: 0.85; } }
.ai-btn:active { transform: scale(0.92); }
.ai-btn .sparkle-svg { width: 24px; height: 24px; overflow: visible; }
.sparkle-svg .s-big { transform-origin: 10px 9.6px; animation: ai-twinkle 4s ease-in-out infinite; }
.sparkle-svg .s-small { transform-origin: 18px 16.9px; animation: ai-twinkle 4s ease-in-out 0.6s infinite; }
@keyframes ai-twinkle {
  0%, 70%, 100% { transform: scale(1) rotate(0deg); }
  80% { transform: scale(1.25) rotate(45deg); }
  90% { transform: scale(0.9) rotate(90deg); }
}

/* Sheet on the phone, side panel on desktop */
.ai-layer { position: fixed; inset: 0; z-index: 60; }
.ai-backdrop { position: absolute; inset: 0; background: rgb(0 0 0 / 0.55); opacity: 0; transition: opacity 0.25s ease; }
.ai-panel {
  position: absolute; left: 0; right: 0; bottom: 0; height: min(88dvh, 760px);
  display: flex; flex-direction: column; overflow: hidden;
  background: linear-gradient(180deg, #121833, var(--bg) 40%); border: 1px solid var(--line); border-bottom: 0;
  border-radius: 24px 24px 0 0; box-shadow: 0 -20px 60px rgb(0 0 0 / 0.5);
  transform: translateY(100%); transition: transform 0.28s cubic-bezier(.2, .8, .2, 1);
}
.ai-layer.open .ai-backdrop { opacity: 1; }
.ai-layer.open .ai-panel { transform: none; }
@media (min-width: 1024px) {
  .ai-panel { left: auto; top: 0; width: 440px; height: auto; border-radius: 0; border: 0; border-left: 1px solid var(--line); transform: translateX(100%); }
  .ai-backdrop { background: rgb(0 0 0 / 0.3); }
}
.ai-head { display: flex; align-items: center; gap: 12px; padding: 4px 12px 12px 16px; border-bottom: 1px solid var(--line); }
/* drag handle (phone): the sheet follows the finger while dragged */
.ai-grab { width: 40px; height: 5px; margin: 8px auto 6px; border-radius: 3px; background: rgb(224 231 255 / 0.25); flex: none; }
.ai-panel.dragging { transition: none; }
@media (min-width: 1024px) { .ai-grab { display: none; } .ai-head { padding-top: 16px; } }
.ai-head .grow { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.ai-count { font-size: var(--fs-sm); color: var(--text-3); }
.ai-avatar {
  display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgb(124 140 255 / 0.35), rgb(168 85 247 / 0.12)); border: 1px solid var(--accent-line);
}
.ai-avatar .sparkle-svg { width: 20px; height: 20px; overflow: visible; }
.ai-avatar.sm { width: 28px; height: 28px; }
.ai-avatar.sm .sparkle-svg { width: 16px; height: 16px; }
.ai-avatar.lg { width: 64px; height: 64px; box-shadow: 0 0 40px rgb(168 85 247 / 0.35); }
.ai-avatar.lg .sparkle-svg { width: 34px; height: 34px; }

.ai-msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; overscroll-behavior: contain; }
.ai-msg { display: flex; gap: 8px; align-items: flex-end; max-width: 100%; }
.ai-msg.me { justify-content: flex-end; }
.ai-msg.bot { align-items: flex-start; }
.ai-col { display: flex; flex-direction: column; gap: 8px; min-width: 0; flex: 1; }
.ai-bubble { padding: 10px 14px; border-radius: 18px; line-height: 1.45; white-space: pre-line; overflow-wrap: anywhere; max-width: 85%; }
.ai-msg.me .ai-bubble { background: var(--grad); color: #fff; border-bottom-right-radius: 6px; }
.ai-msg.bot .ai-bubble { background: var(--surface); border: 1px solid var(--line); border-top-left-radius: 6px; max-width: 100%; align-self: flex-start; }
.ai-bubble.err { color: var(--danger); }

/* «Pensando…»: shimmering text, three dots and the star spinning slowly */
.ai-thinking .ai-bubble { display: inline-flex; align-items: center; gap: 8px; }
.ai-shimmer {
  background: linear-gradient(90deg, var(--text-3) 0%, #e0e7ff 45%, #c4b5fd 55%, var(--text-3) 100%);
  background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: ai-shimmer 1.6s linear infinite; font-weight: var(--fw-bold);
}
.ai-dots { display: inline-flex; gap: 4px; }
.ai-dots i { width: 6px; height: 6px; border-radius: 50%; background: #a78bfa; animation: ai-dot 1.2s ease-in-out infinite; }
.ai-dots i:nth-child(2) { animation-delay: 0.15s; }
.ai-dots i:nth-child(3) { animation-delay: 0.3s; }
.ai-avatar.spin .sparkle-svg { animation: ai-spin 2.4s cubic-bezier(.5, 0, .5, 1) infinite; }
@keyframes ai-shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@keyframes ai-dot { 0%, 60%, 100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-5px); opacity: 1; } }
@keyframes ai-spin { 0% { transform: rotate(0) scale(1); } 50% { transform: rotate(180deg) scale(1.15); } 100% { transform: rotate(360deg) scale(1); } }

/* Welcome with suggestions */
.ai-welcome { margin: auto 0; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; padding: 8px; }
.ai-welcome p { margin: 0 0 8px; max-width: 320px; }
.ai-chips { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.ai-chip {
  justify-content: flex-start; min-height: 44px; padding: 10px 14px; white-space: normal; text-align: left;
  background: var(--surface); border: 1px solid var(--line); color: var(--text-2); font-weight: var(--fw); border-radius: 14px;
}
.ai-chip:hover { border-color: var(--accent-line); color: var(--text); }

/* Routine proposal */
.ai-routine { padding: 14px; border-radius: 16px; background: var(--surface); border: 1px solid var(--accent-line); display: flex; flex-direction: column; gap: 10px; }
.ai-r-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.ai-days { display: flex; gap: 3px; }
.ai-days span { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 6px; font-size: 11px; font-weight: var(--fw-bold); color: var(--text-3); background: var(--surface-2); }
.ai-days span.on { background: var(--grad); color: #fff; }
.ai-ex { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.ai-ex li { display: flex; align-items: center; gap: 10px; font-size: var(--fs-sm); }
.ai-thumb { width: 34px; height: 34px; flex: none; border-radius: 8px; background: var(--surface-2); }
.ai-sr { color: var(--text-2); font-variant-numeric: tabular-nums; font-weight: var(--fw-bold); }
.ai-routine .block { min-height: 44px; }

.ai-form { display: flex; align-items: flex-end; gap: 8px; padding: 12px 12px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--bg); }
.ai-form textarea { flex: 1; min-height: 44px; max-height: 140px; padding: 11px 14px; border-radius: 22px; resize: none; line-height: 1.4; }
.ai-send { width: 44px; height: 44px; min-height: 44px; padding: 0; border-radius: 50%; flex: none; }

/* Side menu entry (desktop) */
.sidebar .side-ai .sparkle-svg { width: 20px; height: 20px; flex: none; overflow: visible; }

@media (prefers-reduced-motion: reduce) {
  .ai-btn::before, .sparkle-svg .s-big, .sparkle-svg .s-small, .ai-avatar.spin .sparkle-svg, .ai-shimmer, .ai-dots i { animation: none; }
  .ai-shimmer { color: var(--text-2); background: none; }
  .ai-panel, .ai-backdrop { transition: none; }
}
.ai-ex li .grow { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.ai-ex-name { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ai-ex-name .tag { font-size: 10px; padding: 1px 6px; }
.ai-src { font-size: 11px; color: var(--text-3); font-style: italic; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-sr { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
.ai-sr small { font-size: 11px; color: var(--text-3); font-weight: var(--fw); }

/* Gold «verified» badge after a verified gym's name */
.gym-label { display: inline-flex; align-items: center; gap: 4px; min-width: 0; }
.verified-mark { display: inline-flex; flex: none; color: var(--gold); filter: drop-shadow(0 0 4px rgb(255 201 77 / 0.35)); }
.verified-mark .icon { width: 1em; height: 1em; }
#title .verified-mark { margin-left: 6px; vertical-align: -2px; }
.sidebar .verified-mark .icon { width: 15px; height: 15px; }
.tag .verified-mark { margin-left: 2px; }

/* ---------- the gym's own machines ---------- */
.machine-photo { object-fit: cover; background: var(--surface-2); }
img.thumb.machine-photo { width: 48px; height: 48px; border-radius: 12px; flex: none; }
.cat-card img.cat-alien.machine-photo { width: 100%; aspect-ratio: 4 / 3; height: auto; border-radius: 0; background: var(--surface-2); }
.machine-hero { display: block; width: 100%; max-height: 280px; object-fit: cover; border-radius: var(--r-md); background: var(--surface-2); }
.machine-media { display: flex; flex-direction: column; gap: 8px; }
.machine-notes { margin: 0; white-space: pre-line; }
.machine-preview:empty { display: none; }
.machines-title { display: flex; align-items: center; }
.field-label { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: var(--fs-sm); color: var(--text-2); font-weight: var(--fw-bold); }
.panel input[type="file"] { min-height: 0; padding: 10px 12px; }
.storage-admin { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.storage-admin input { width: 88px; flex: none; text-align: right; }
[role="status"].error { color: var(--danger); font-weight: var(--fw-bold); }

/* Machine photo + video: the photo with a play button over it; the video plays in place */
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mstage { position: relative; overflow: hidden; border-radius: var(--r-md); background: var(--surface-2); aspect-ratio: 4 / 3; max-height: 360px; width: 100%; }
.mstage img, .mstage video { display: block; width: 100%; height: 100%; object-fit: cover; }
.mstage.playing { background: #000; aspect-ratio: auto; max-height: 70vh; }
.mstage.playing video { height: auto; max-height: 70vh; object-fit: contain; }
.mstage.empty { aspect-ratio: 16 / 9; }
.mstage-ph { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-3);
  background: radial-gradient(circle at 50% 40%, rgb(124 140 255 / 0.18), transparent 70%); }
.mplay {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 0; padding: 0; border-radius: 0; color: #fff;
  background: linear-gradient(180deg, rgb(11 15 26 / 0) 40%, rgb(11 15 26 / 0.55));
}
.mplay-circle {
  display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: var(--grad); color: #fff;
  box-shadow: 0 8px 28px rgb(124 92 255 / 0.55), 0 0 0 6px rgb(255 255 255 / 0.12);
  transition: transform 0.15s ease;
}
.mplay-circle .icon { width: 26px; height: 26px; margin-left: 3px; fill: currentColor; }
.mplay:hover .mplay-circle, .mplay:active .mplay-circle { transform: scale(1.08); }
.mplay-label { font-weight: var(--fw-bold); font-size: var(--fs-sm); padding: 4px 12px; border-radius: 999px; background: rgb(11 15 26 / 0.55); backdrop-filter: blur(6px); }
.mplay-circle.sm { position: absolute; width: 44px; height: 44px; left: 50%; top: 42%; transform: translate(-50%, -50%); box-shadow: 0 6px 20px rgb(124 92 255 / 0.5); }
.mplay-circle.sm .icon { width: 18px; height: 18px; }

.mnotes { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-md);
  background: var(--accent-soft); border: 1px solid var(--accent-line); color: var(--text); }
.mnotes .icon { color: var(--accent); margin-top: 2px; flex: none; }
.mnotes p { margin: 0; font-size: var(--fs-sm); white-space: pre-line; line-height: 1.5; }

/* Thumbnail that opens the viewer, with a ▶ badge when there's a video */
.mthumb { position: relative; padding: 0; min-height: 0; background: none; border-radius: 12px; flex: none; }
.mthumb-play { position: absolute; right: -4px; bottom: -4px; display: grid; place-items: center; width: 22px; height: 22px;
  border-radius: 50%; background: var(--grad); color: #fff; box-shadow: 0 0 0 2px var(--surface); }
.mthumb-play .icon { width: 11px; height: 11px; margin-left: 1px; fill: currentColor; }
.cat-card .mthumb-play.big { right: 10px; bottom: auto; top: 10px; left: auto; width: 30px; height: 30px; box-shadow: 0 4px 12px rgb(0 0 0 / 0.4); }
.cat-card .mthumb-play.big .icon { width: 14px; height: 14px; }
.cat-card.machine { position: relative; }

/* Full-screen viewer */
.mviewer { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 16px;
  background: rgb(5 7 14 / 0.86); backdrop-filter: blur(8px); opacity: 0; transition: opacity 0.2s ease; }
.mviewer.open { opacity: 1; }
.mviewer-card { width: 100%; max-width: 560px; max-height: 100%; overflow-y: auto; display: flex; flex-direction: column; gap: 12px;
  padding: 14px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line); transform: scale(0.97); transition: transform 0.2s ease; }
.mviewer.open .mviewer-card { transform: none; }
.mviewer-head { display: flex; align-items: center; gap: 8px; }
html.viewer-open, html.viewer-open body { overflow: hidden; }

/* Machine page: photo and video tiles */
.media-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.media-tile {
  position: relative; display: flex; flex-direction: column; justify-content: flex-end; aspect-ratio: 4 / 3; overflow: hidden; cursor: pointer;
  border-radius: var(--r-md); border: 1.5px dashed var(--accent-line); background: var(--surface-2);
}
.media-tile.filled { border-style: solid; border-color: var(--line); }
.media-tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.media-ph { position: absolute; inset: 0; display: grid; place-items: center; color: var(--accent); }
.media-cap {
  position: relative; display: flex; align-items: center; gap: 6px; padding: 8px 10px; font-size: 12px; font-weight: var(--fw-bold);
  color: var(--text); background: linear-gradient(transparent, rgb(11 15 26 / 0.85));
}
.media-tile:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.media-actions { gap: 8px; }

/* ---------- gym mode ---------- */
.mode-switch { margin-bottom: 4px; }
.mode-switch button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.sidebar .mode-switch.side button { min-height: 32px; font-size: 13px; }
.gym-day-head { display: flex; align-items: center; gap: 14px; }
.tile-icon.lg { width: 56px; height: 56px; border-radius: 16px; }
.tile-icon.lg .icon { width: 26px; height: 26px; }
.gym-day-kpis .stat .v { font-size: 26px; }
.quick-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.quick {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 4px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--line); color: var(--text-2); text-decoration: none;
  font-size: 12px; font-weight: var(--fw-bold); text-align: center; line-height: 1.2;
}
.quick:hover { border-color: var(--accent-line); color: var(--text); }
.time-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 52px; height: 48px; flex: none;
  border-radius: 12px; background: var(--accent-soft); color: var(--text); font-variant-numeric: tabular-nums; }
.time-tile b { font-size: 15px; }
.time-tile small { font-size: 11px; color: var(--text-3); }
.card.done { opacity: 0.55; }
.occ { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.occ .meter { flex: 1; margin: 0; max-width: 160px; }
.tag.live { gap: 6px; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: #34d399; box-shadow: 0 0 0 3px rgb(52 211 153 / 0.2); animation: live 1.6s ease-in-out infinite; }
@keyframes live { 50% { opacity: 0.35; } }
.sm-btn { min-height: 32px; padding: 0 10px; font-size: 12px; gap: 4px; }
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }
.gym-day-head .hello { font-size: var(--fs-lg); font-weight: var(--fw-bold); }
.gym-day-head .where { display: flex; align-items: center; gap: 6px; margin-top: 2px; color: var(--text-2); }
body.has-sidebar .home-switch { display: none; }
/* phone browsers: no native pull-to-refresh (the app does its own, see webPullToRefresh) */
html.web-ptr, html.web-ptr body { overscroll-behavior-y: contain; }
.ai-class { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 16px; background: var(--surface); border: 1px solid var(--accent-line); }
.ai-class .grow { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.ai-class button { min-height: 40px; padding: 0 12px; flex: none; font-size: var(--fs-sm); }
.ai-class.joined { border-color: rgb(52 211 153 / 0.5); }
.ai-class.joined .time-tile { background: rgb(52 211 153 / 0.15); }
.ai-class button { gap: 4px; }
.hero-card.done { border-color: rgb(52 211 153 / 0.4); background: linear-gradient(160deg, rgb(52 211 153 / 0.08), transparent 60%), var(--surface); }
.done-label { display: inline-flex; align-items: center; gap: 6px; color: #34d399 !important; }

/* ---------- muscle map (public/bodymap.js) ---------- */
.bm { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.bm-switch { width: 100%; max-width: 240px; }
.bm-stage { width: 100%; max-width: 200px; perspective: 900px; cursor: pointer; }
.bm-turn { position: relative; aspect-ratio: 200 / 430; transform-style: preserve-3d; transition: transform 0.7s cubic-bezier(.4, .1, .2, 1); }
.bm-turn.flipped { transform: rotateY(180deg); }
.bm-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.bm-face.back { transform: rotateY(180deg); }
.bm-svg { width: 100%; height: 100%; display: block; overflow: visible; }
.bm-base { fill: #161d3a; }
.bm-dim { fill: #252f5c; stroke: var(--surface); stroke-width: 1.4; stroke-linejoin: round; }
.bm-hot { stroke: var(--surface); stroke-width: 1.4; stroke-linejoin: round; }
.bm-hot.top { filter: drop-shadow(0 0 6px rgb(125 211 252 / 0.6)); }
.bm-muscle { cursor: pointer; outline: none; transition: opacity 0.15s; }
/* selected: a soft glow, brighter (no outline) */
.bm-muscle.on { filter: brightness(1.25) drop-shadow(0 0 8px rgb(125 211 252 / 0.75)); }
.bm-muscle:focus-visible .bm-dim { stroke: var(--accent); stroke-width: 2.4; }
.bm-legend { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-3); }
.bm-legend i { width: 120px; height: 8px; border-radius: 4px; background: linear-gradient(90deg, rgb(37 47 92), rgb(59 130 246), rgb(125 211 252)); }
.bm-info { text-align: center; min-height: 40px; }
@media (prefers-reduced-motion: reduce) { .bm-turn { transition: none; } }
/* the done card has no thumbnails: the buttons need their own space from the summary */
.hero-card.done .row { margin-top: 20px; gap: 10px; }

/* ---------- 3D muscle map (public/body3d.js) ---------- */
.b3d { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.b3d-stage { width: 100%; max-width: 420px; min-height: 300px; display: grid; place-items: center; touch-action: none;
  border-radius: var(--r-md); background: radial-gradient(ellipse at 50% 40%, rgb(59 130 246 / 0.12), transparent 65%); }
.b3d-stage canvas { display: block; cursor: grab; }
.b3d-stage canvas:active { cursor: grabbing; }
.b3d-loading { display: flex; flex-direction: column; align-items: center; gap: 12px; color: var(--text-3); font-size: var(--fs-sm); }
.b3d-loading span { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--accent-soft); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.b3d-hint { text-align: center; }
.b3d-credit { font-size: 10px; color: var(--text-3); }
.b3d-credit a { color: inherit; }

/* ---------- following ---------- */
.follow-counts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.follow-counts > * { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 6px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--line); color: var(--text); text-decoration: none; text-align: center; }
.follow-counts > a:hover { border-color: var(--accent-line); }
.follow-counts b { font-size: 22px; display: grid; place-items: center; min-height: 28px; }
.follow-counts b .icon { color: var(--accent); }
.follow-counts span { font-size: 12px; color: var(--text-2); }
/* profile cover: the app's starry sky, the same for everyone; the header below overlaps it */
.profile-cover { height: 132px; margin: 0 0 -36px; border-radius: var(--radius-lg, 20px);
  background:
    radial-gradient(1.5px 1.5px at 18% 30%, #fff8 50%, transparent 51%), radial-gradient(1px 1px at 62% 22%, #fff9 50%, transparent 51%),
    radial-gradient(1px 1px at 82% 64%, #fff7 50%, transparent 51%), radial-gradient(1.5px 1.5px at 40% 72%, #fff6 50%, transparent 51%),
    radial-gradient(circle at 85% 0%, rgb(168 85 247 / 0.45), transparent 60%), linear-gradient(135deg, #1e2a5b, #141b2e);
}
.profile-cover + .section { position: relative; }
.profile-cover + .section .avatar-rank, .profile-cover + .section > :first-child { filter: drop-shadow(0 4px 12px rgb(0 0 0 / 0.5)); }
.user-head { display: flex; align-items: center; gap: 16px; }
button.follow { min-height: 38px; padding: 0 14px; font-size: var(--fs-sm); gap: 6px; flex: none; }
.user-head + .section + .section button.follow { flex: 1; min-height: 46px; font-size: var(--fs-md); }
button.icon-only { width: 36px; min-height: 36px; padding: 0; }

/* community ranking: gold, silver and bronze for the podium */
.rank-medal { color: #1a1a1a; font-weight: var(--fw-bold); }
.rank-medal.m1 { background: #fcd34d; }
.rank-medal.m2 { background: #d1d5db; }
.rank-medal.m3 { background: #f59e6b; }

/* ---------- a routine's main card: what it is, when it's on, and ▶︎ ---------- */
.routine-hero {
  position: relative; display: flex; align-items: center; gap: 16px; padding: 20px; overflow: hidden;
  border-radius: 22px; border: 1px solid rgb(255 255 255 / 0.08);
  background:
    radial-gradient(circle at 100% 0%, rgb(168 85 247 / 0.45), transparent 55%),
    radial-gradient(circle at 0% 100%, rgb(59 130 246 / 0.3), transparent 60%),
    linear-gradient(135deg, #1e2a5b, #141b2e);
}
/* its first exercises' aliens, faint behind the text */
.routine-hero-aliens { position: absolute; right: 84px; bottom: -10px; display: flex; gap: 6px; opacity: 0.22; pointer-events: none; }
.routine-hero-aliens .thumb.alien-stage { width: 64px; height: 64px; background: transparent; }
.routine-hero > .grow { position: relative; flex: 1; min-width: 0; }
.routine-hero-title { margin: 0; font-size: var(--fs-xl, 24px); line-height: 1.15; color: #fff; overflow-wrap: anywhere; }
.routine-hero-meta { margin-top: 4px; color: rgb(255 255 255 / 0.75); font-size: var(--fs-sm); }
.routine-hero-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.routine-hero-chips .chip { min-height: 28px; padding: 0 10px; font-size: 12px; background: rgb(0 0 0 / 0.25); border-color: rgb(255 255 255 / 0.12); color: #fff; }
.routine-hero-origin { display: flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 12px; color: rgb(255 255 255 / 0.7); }
.routine-play {
  position: relative; flex: none; width: 64px; height: 64px; min-height: 64px; padding: 0; border-radius: 50%;
  display: grid; place-items: center; border: 0; color: #fff; margin-right: 4px;
  /* flat: the brand gradient, no shine, no effects */
  background: linear-gradient(135deg, #3b82f6, #a855f7); box-shadow: none;
}
/* inside a routine (only here): a halo that beats around it */
.routine-play::before {
  content: ""; position: absolute; inset: -5px; border-radius: 50%;
  border: 1.5px solid rgb(196 181 253 / 0.5); animation: play-pulse 2.4s ease-out infinite;
}
@keyframes play-pulse { 0% { transform: scale(0.95); opacity: 0.9; } 100% { transform: scale(1.35); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .routine-play::before { animation: none; opacity: 0.5; } }
.routine-play .icon { width: 28px; height: 28px; margin-left: 3px; fill: currentColor; }
.routine-play:active { transform: scale(0.94); }
/* a card with something that unfolds under it (the days picker) */
.card-group { display: flex; flex-direction: column; gap: 8px; }

/* exercise rows: a little stock-style chart of the heaviest set per workout */
.ex-row { cursor: pointer; }
.ex-meta { display: flex; align-items: center; gap: 10px; }
/* the sets text in a fixed column: every row's chart starts at the same place, same size */
.ex-meta > span { flex: none; width: 7.5em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trend-spark { width: 56px; height: 20px; flex: none; overflow: visible; }
.spark-line { fill: none; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.spark-area { stroke: none; opacity: 0.18; }
.trend-spark.up .spark-line { stroke: #34d399; } .trend-spark.up .spark-area, .trend-spark.up .spark-dot { fill: #34d399; }
.trend-spark.down .spark-line { stroke: #ff5a7a; } .trend-spark.down .spark-area, .trend-spark.down .spark-dot { fill: #ff5a7a; }
.trend-spark.flat .spark-line { stroke: var(--text-3); stroke-dasharray: 3 3; } .trend-spark.flat .spark-area { display: none; } .trend-spark.flat .spark-dot { fill: var(--text-3); }

/* rows that slide left to show their actions (iOS-style) */
.swipe-row { position: relative; border-radius: var(--r-md); overflow: hidden; touch-action: pan-y; }
.swipe-row > .card { position: relative; z-index: 1; }
.swipe-actions { position: absolute; inset: 0 0 0 auto; display: flex; }
.swipe-action {
  width: 76px; min-height: 0; height: 100%; padding: 0; border: 0; border-radius: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-size: 12px; font-weight: var(--fw-bold); color: #fff;
}
.swipe-action.edit { background: #3b82f6; }
.swipe-action.danger { background: var(--danger); color: #fff; }
/* the pencil only with a mouse; on touch screens it's the swipe */
@media (hover: none) { .pointer-only { display: none !important; } }
