:root {
  --bg: #0c0d0f;
  --bg-2: #111317;
  --card: #16181d;
  --card-2: #1d2026;
  --line: #24272e;
  --text: #f2f3f5;
  --muted: #9299a4;
  --faint: #5c6470;
  --bar: rgba(12, 13, 15, 0.92);
  --accent: #d0f244;
  --accent-dim: #aacc2c;
  --accent-ink: #10130a;
  --accent-soft: rgba(208, 242, 68, 0.12);
  --gold: #e8c268;
  --silver: #b9c4d0;
  --bronze: #c99772;
  --red: #f26d6d;
  --green: #58d68d;
  --radius: 14px;
  --radius-sm: 10px;
  --accent-text: var(--accent); /* darkened in light mode for contrast */
}
body[data-theme='light'] { --accent-text: var(--accent-dim); }

body[data-theme='light'] {
  --bg: #f2f3f6;
  --bg-2: #ffffff;
  --card: #ffffff;
  --card-2: #e9ebef;
  --line: #dfe2e8;
  --text: #17191d;
  --muted: #5b6472;
  --faint: #97a0ad;
  --bar: rgba(248, 249, 251, 0.92);
  --gold: #c99516;
  --silver: #7e8ea0;
  --bronze: #b0713d;
}

/* accent palettes (applied on body[data-accent]) */
body[data-accent='flamingo'] { --accent: #ff7eb6; --accent-dim: #e0559a; --accent-ink: #2a0517; --accent-soft: rgba(255, 126, 182, 0.14); }
body[data-accent='violet']   { --accent: #b79bf5; --accent-dim: #9a78e6; --accent-ink: #170b33; --accent-soft: rgba(183, 155, 245, 0.14); }
body[data-accent='ocean']    { --accent: #5fc9f2; --accent-dim: #37a9d8; --accent-ink: #06202b; --accent-soft: rgba(95, 201, 242, 0.14); }
body[data-accent='ember']    { --accent: #ff9d5c; --accent-dim: #e67c33; --accent-ink: #291002; --accent-soft: rgba(255, 157, 92, 0.14); }
/* unlockable, extravagant accents — glow included */
body[data-accent='aurora']    { --accent: #34f5c5; --accent-dim: #12c69a; --accent-ink: #01271d; --accent-soft: rgba(52, 245, 197, 0.15); }
body[data-accent='sakura']    { --accent: #ff9ad5; --accent-dim: #e560ac; --accent-ink: #2b0a1e; --accent-soft: rgba(255, 154, 213, 0.16); }
body[data-accent='royal']     { --accent: #8f6bff; --accent-dim: #6d43e8; --accent-ink: #12062e; --accent-soft: rgba(143, 107, 255, 0.16); }
body[data-accent='inferno']   { --accent: #ff5c3d; --accent-dim: #e0361a; --accent-ink: #2a0802; --accent-soft: rgba(255, 92, 61, 0.16); }
body[data-accent='gold24']    { --accent: #ffd700; --accent-dim: #cfa500; --accent-ink: #241c00; --accent-soft: rgba(255, 215, 0, 0.16); }
body[data-accent='bloodruby'] { --accent: #ff2d55; --accent-dim: #d40f37; --accent-ink: #2a020c; --accent-soft: rgba(255, 45, 85, 0.16); }
body[data-accent='diamond']   { --accent: #b9f2ff; --accent-dim: #5fc9e8; --accent-ink: #04222b; --accent-soft: rgba(185, 242, 255, 0.17); }
/* the rare ones glow */
body[data-accent='gold24'] .btn-primary,
body[data-accent='bloodruby'] .btn-primary,
body[data-accent='diamond'] .btn-primary,
body[data-accent='aurora'] .btn-primary,
body[data-accent='royal'] .btn-primary,
body[data-accent='inferno'] .btn-primary,
body[data-accent='sakura'] .btn-primary { box-shadow: 0 0 16px var(--accent-soft), 0 0 4px var(--accent-soft); }

/* ---------- profile borders (avatar rings) ---------- */
.avatar-ring {
  display: inline-flex;
  padding: 3px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--line);
}
.avatar-ring .avatar { border: 2px solid var(--bg); }
.avatar-ring.b-steel    { background: linear-gradient(135deg, #aeb8c4, #5c6470, #e6edf5, #7c8794); }
.avatar-ring.b-rose     { background: linear-gradient(135deg, #ffc2e2, #e0559a, #fff0f8, #ff7eb6); }
.avatar-ring.b-amethyst { background: linear-gradient(135deg, #d9c8ff, #6b46c1, #f0e8ff, #9a78e6); }
.avatar-ring.b-flame    { background: conic-gradient(#ff6b3d, #ffd45e, #ff3d3d, #ff9d5c, #ff6b3d); }
.avatar-ring.b-gold     { background: conic-gradient(#ffd700, #8a6d1a, #fff3b0, #c9a227, #ffd700); box-shadow: 0 0 10px rgba(255, 215, 0, 0.35); }
.avatar-ring.b-ruby     { background: conic-gradient(#ff2d55, #7a0c22, #ffb3c2, #d40f37, #ff2d55); box-shadow: 0 0 12px rgba(255, 45, 85, 0.4); }
.avatar-ring.b-prism    {
  background: conic-gradient(#ff004c, #ff9d00, #ffee00, #35e05a, #00cfff, #7b5bff, #ff00d4, #ff004c);
  box-shadow: 0 0 14px rgba(160, 120, 255, 0.45);
  animation: prism-spin 5s linear infinite;
}
@keyframes prism-spin { to { filter: hue-rotate(360deg); } }
.avatar-ring.b- { background: transparent; }
.avatar-ring.ring-locked { opacity: 0.35; filter: saturate(0.4); animation: none; }

.border-pick { background: none; border: 0; padding: 0; cursor: pointer; border-radius: 50%; }
.border-pick.sel { outline: 2px solid var(--text); outline-offset: 2px; }
.border-pick.locked { opacity: 0.35; filter: saturate(0.4); cursor: not-allowed; }
.border-pick.locked .avatar-ring { animation: none; }

/* ---------- level gem ---------- */
.lvl-gem { width: 15px; height: 15px; }
.lvl-gem.t-iron     { color: #8b95a3; }
.lvl-gem.t-bronze   { color: var(--bronze); }
.lvl-gem.t-silver   { color: var(--silver); }
.lvl-gem.t-gold     { color: var(--gold); }
.lvl-gem.t-emerald  { color: #4cd98a; }
.lvl-gem.t-sapphire { color: #4c9dff; }
.lvl-gem.t-ruby     { color: #ff4c6a; filter: drop-shadow(0 0 3px rgba(255, 76, 106, 0.5)); }
.lvl-gem.t-diamond  { color: #9be8ff; filter: drop-shadow(0 0 4px rgba(155, 232, 255, 0.6)); }
.lvl-chip-top { display: inline-flex; align-items: center; gap: 5px; }
.podium-lvl { display: inline-flex; align-items: center; gap: 3px; }

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  font-size: 15px;
}

.hidden { display: none !important; }

.ic { width: 20px; height: 20px; fill: currentColor; flex-shrink: 0; }

button { font-family: inherit; }

/* ---------- logo ---------- */
.logo {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.04em;
}
.logo span { color: var(--accent-text); }
.logo-sm { font-size: 18px; }

/* ---------- auth ---------- */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(24px + env(safe-area-inset-top, 0px)) 24px calc(24px + env(safe-area-inset-bottom, 0px));
  background:
    radial-gradient(700px 380px at 85% -5%, rgba(208, 242, 68, 0.07), transparent),
    var(--bg);
}
.auth-card { width: 100%; max-width: 380px; }
.auth-card .logo { text-align: center; }
.tagline { color: var(--muted); margin: 6px 0 26px; text-align: center; font-size: 14px; }

.auth-tabs {
  display: flex;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 18px;
}
.auth-tab {
  flex: 1;
  padding: 9px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.auth-tab.active { background: var(--card-2); color: var(--text); }

.auth-note {
  color: var(--muted);
  font-size: 13.5px;
  margin-bottom: 16px;
  line-height: 1.55;
}
.auth-note b { color: var(--text); }
.auth-links { margin-top: 16px; text-align: center; font-size: 13.5px; color: var(--muted); }
.auth-links a, .link-btn {
  color: var(--accent);
  text-decoration: none;
  background: none;
  border: 0;
  font-size: inherit;
  cursor: pointer;
  padding: 0;
}
.link-btn:hover { text-decoration: underline; }

.code-input { letter-spacing: 0.5em; text-align: center; font-size: 22px !important; font-weight: 700; }

.dev-hint {
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  color: var(--faint);
  font-size: 12.5px;
  line-height: 1.5;
}

/* ---------- forms ---------- */
.field { text-align: left; margin-bottom: 13px; }
.field label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 5px;
}
input, select, textarea {
  width: 100%;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  font-size: 16px;
  outline: none;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent-dim); }
input::placeholder { color: var(--faint); }

.error { color: var(--red); font-size: 13.5px; margin: 4px 0 10px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 11px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.05s ease, filter 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn:hover { filter: brightness(1.12); }
.btn .ic { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 8px; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-outline { background: transparent; }
.btn-danger { color: var(--red); }
.btn[disabled] { opacity: 0.55; cursor: default; }

/* ---------- app shell ---------- */
.app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
@media (min-width: 560px) {
  .app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* keep clear of the iPhone status bar / notch in standalone PWA mode */
  padding: calc(13px + env(safe-area-inset-top, 0px)) 18px 13px;
  background: var(--bar);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-right { display: flex; align-items: center; gap: 10px; }
.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 700;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 11px;
  color: var(--text);
}
.streak-badge .ic { width: 14px; height: 14px; color: #f2a13c; }

/* ---------- notification bell ---------- */
.bell-btn {
  position: relative;
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.bell-btn .ic { width: 16px; height: 16px; }
.bell-badge {
  position: absolute;
  top: -4px; right: -4px;
  min-width: 16px; height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 10px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}
.unread-row { background: var(--accent-soft); border-radius: 8px; padding-left: 8px; padding-right: 8px; margin: 0 -8px; }

/* ---------- podium leaderboard ---------- */
.podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 8px;
  padding: 26px 0 20px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.podium-slot { display: flex; flex-direction: column; align-items: center; width: 32%; min-width: 0; }
.podium-slot.empty-slot { visibility: hidden; }
.podium-avatar {
  position: relative;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 108px;
  height: 108px;
}
.podium-slot.p1 .podium-avatar { width: 136px; height: 136px; }
.wreath {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.wreath.w1 { color: var(--gold); filter: drop-shadow(0 0 10px color-mix(in srgb, var(--gold) 45%, transparent)); }
.wreath.w2 { color: var(--silver); }
.wreath.w3 { color: var(--bronze); }
.avatar-xl { width: 88px; height: 88px; font-size: 30px; }
.podium-slot .avatar-lg { width: 68px; height: 68px; font-size: 24px; }
.podium-slot.p1 .avatar { border: 3px solid var(--gold); box-shadow: 0 0 26px color-mix(in srgb, var(--gold) 40%, transparent); }
.podium-slot.p2 .avatar { border: 3px solid var(--silver); }
.podium-slot.p3 .avatar { border: 3px solid var(--bronze); }
.place-badge {
  position: absolute;
  bottom: 2px; left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  width: 24px; height: 24px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800;
  color: #17191d;
  border: 2px solid var(--card);
}
.place-badge.b1 { background: var(--gold); }
.place-badge.b2 { background: var(--silver); }
.place-badge.b3 { background: var(--bronze); }
.podium-name { font-weight: 800; font-size: 13.5px; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 4px; }
.podium-slot.p1 .podium-name { font-size: 15px; }
.podium-score { font-weight: 800; font-size: 14px; color: var(--accent-text); font-variant-numeric: tabular-nums; }
.podium-slot.p1 .podium-score { font-size: 16px; }
.podium-lvl { font-size: 10.5px; color: var(--faint); font-weight: 700; }
.podium-slot.me-slot .podium-name { color: var(--accent-dim); }

.pinned-me {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  background: var(--accent);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.avatar-btn img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

/* profile head extras */
.avatar-edit { position: relative; background: none; border: 0; padding: 0; cursor: pointer; }
.avatar-edit-hint {
  position: absolute;
  bottom: -2px; left: 50%;
  transform: translateX(-50%);
  font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em;
  background: var(--card-2); color: var(--muted);
  border: 1px solid var(--line);
  padding: 1px 7px; border-radius: 99px;
}
.profile-head .grow { min-width: 0; }
.xp-row { display: flex; align-items: center; gap: 8px; }
.lvl-chip {
  font-size: 11px; font-weight: 800;
  background: var(--accent); color: var(--accent-ink);
  padding: 2px 8px; border-radius: 99px;
  flex-shrink: 0;
}
.lvl-chip-top { font-size: 12px; font-weight: 800; }
.xp-track { flex: 1; height: 6px; border-radius: 99px; background: var(--card-2); overflow: hidden; max-width: 140px; }
.xp-fill { height: 100%; background: var(--accent); border-radius: 99px; }

/* measurements */
.delta { font-weight: 800; font-size: 13px; font-variant-numeric: tabular-nums; }
.delta.down { color: var(--green); }
.delta.up { color: var(--muted); }

/* ---------- theme swatches ---------- */
.swatch-row { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch-wrap { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.swatch {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
}
.swatch.sel { border-color: var(--text); box-shadow: 0 0 0 2px var(--bg); }
.swatch.locked { opacity: 0.32; filter: saturate(0.5); cursor: not-allowed; }
.swatch-lv { font-size: 9px; font-weight: 800; color: var(--faint); text-transform: uppercase; }

.streak-badge, .lvl-chip-top { cursor: pointer; }

/* ---------- push banner ---------- */
.push-banner { display: flex; align-items: center; gap: 10px; }

/* ---------- weekly league ---------- */
.league-card { border-left: 3px solid var(--bronze); }
.league-card.tier-1 { border-left-color: var(--silver); }
.league-card.tier-2 { border-left-color: var(--gold); }
.league-card.tier-3 { border-left-color: #8fd8e8; }
.league-card.tier-4 { border-left-color: #b79bf5; }
.league-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.tier-badge {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: var(--card-2);
  color: var(--bronze);
}
.tier-badge .ic { width: 24px; height: 24px; }
.tier-badge.tier-1 { color: var(--silver); }
.tier-badge.tier-2 { color: var(--gold); }
.tier-badge.tier-3 { color: #8fd8e8; }
.tier-badge.tier-4 { color: #b79bf5; }

/* ---------- achievements ---------- */
.badge-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.badge {
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 8px;
  text-align: center;
  opacity: 0.38;
}
.badge.earned { opacity: 1; border-color: var(--accent-dim); }
.badge .ic { width: 20px; height: 20px; color: var(--faint); margin-bottom: 4px; }
.badge.earned .ic { color: var(--accent); }
.badge .b-name { font-size: 11.5px; font-weight: 700; line-height: 1.3; }
.badge .b-desc { font-size: 9.5px; color: var(--muted); line-height: 1.35; margin-top: 2px; }

/* ---------- avatars (initials) ---------- */
.avatar {
  --h: 90;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: hsl(var(--h), 70%, 78%);
  background: hsl(var(--h), 32%, 17%);
  border: 1px solid hsl(var(--h), 30%, 28%);
  flex-shrink: 0;
  user-select: none;
}
.avatar-btn { cursor: pointer; }
.avatar-lg { width: 62px; height: 62px; font-size: 22px; }
.avatar-sm { width: 32px; height: 32px; font-size: 12px; }

.view { flex: 1; padding: 18px 18px 100px; }

.tabbar {
  /* fixed + transform drifts during scroll in iOS standalone mode —
     anchor with inset margins instead */
  position: fixed;
  bottom: 0; left: 0; right: 0;
  margin: 0 auto;
  width: 100%;
  max-width: 520px;
  display: flex;
  background: var(--bar);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 30;
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 0 9px;
  border: 0;
  background: transparent;
  color: var(--faint);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
}
.tab.active { color: var(--accent); }

/* ---------- generic ---------- */
.page-title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 2px;
}
.page-sub { color: var(--muted); font-size: 13.5px; margin-bottom: 18px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.card-title {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title .link-btn { text-transform: none; letter-spacing: 0; font-weight: 600; font-size: 13px; }

.num { font-variant-numeric: tabular-nums; }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 14px; }
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 15px;
}
.stat .n { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat .n.accent { color: var(--accent-text); }
.stat .l { color: var(--muted); font-size: 12px; margin-top: 1px; }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 26px 16px;
  font-size: 13.5px;
  line-height: 1.6;
}
.empty .ic { width: 28px; height: 28px; color: var(--faint); margin-bottom: 8px; }

/* ---------- goal ring + hero ---------- */
.hero {
  display: flex;
  align-items: center;
  gap: 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.ring { position: relative; width: 92px; height: 92px; flex-shrink: 0; }
.ring svg { transform: rotate(-90deg); }
.ring .track { stroke: var(--card-2); }
.ring .fill { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset 0.6s ease; }
.ring .ring-label {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.ring .ring-label .big { font-size: 20px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.ring .ring-label .small { font-size: 10px; color: var(--muted); }
.hero-text .headline { font-size: 16px; font-weight: 700; margin-bottom: 3px; }
.hero-text .sub { color: var(--muted); font-size: 13px; line-height: 1.5; }

/* ---------- chart ---------- */
.chart { display: flex; align-items: flex-end; gap: 4px; height: 84px; }
.chart .bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.chart .bar { width: 100%; border-radius: 3px; background: var(--card-2); min-height: 3px; }
.chart .bar.filled { background: var(--accent); opacity: 0.9; }
.chart .bar-lbl { font-size: 9px; color: var(--faint); }

.split-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.split-row .lbl { width: 78px; font-size: 12.5px; color: var(--muted); }
.split-row .track { flex: 1; height: 6px; border-radius: 99px; background: var(--card-2); overflow: hidden; }
.split-row .fill { height: 100%; border-radius: 99px; background: var(--accent); opacity: 0.85; }
.split-row .val { font-size: 12px; color: var(--muted); width: 62px; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- lists / rows ---------- */
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .name { font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .sub { color: var(--muted); font-size: 12.5px; }
.row .score { font-weight: 800; font-size: 15px; color: var(--accent-text); white-space: nowrap; font-variant-numeric: tabular-nums; }

.rank {
  width: 26px;
  font-weight: 800;
  font-size: 13.5px;
  color: var(--faint);
  text-align: center;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.rank.r1 { color: var(--gold); }
.rank.r2 { color: var(--silver); }
.rank.r3 { color: var(--bronze); }
.row.me { background: var(--accent-soft); border-radius: var(--radius-sm); padding-left: 8px; padding-right: 8px; margin: 0 -8px; }

/* ---------- pills / segmented ---------- */
.seg { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.pill {
  padding: 6px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.pill.active { background: var(--card-2); border-color: var(--faint); color: var(--text); }
.pill.accent.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ---------- workout logger ---------- */
.template-strip { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 14px; }
.template-card {
  min-width: 150px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
  flex-shrink: 0;
}
.template-card:hover { border-color: var(--faint); }
.template-card .t-name { font-weight: 700; font-size: 14px; margin-bottom: 3px; }
.template-card .t-sub { color: var(--muted); font-size: 11.5px; line-height: 1.45; }

/* exercise demos */
.ex-thumb {
  width: 46px; height: 46px;
  border-radius: 8px;
  object-fit: cover;
  background: #fff;
  flex-shrink: 0;
}
.demo-stage {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
}
.demo-stage img { width: 100%; display: block; aspect-ratio: 4/3; object-fit: contain; background: #fff; }
.demo-dots {
  position: absolute;
  bottom: 8px; left: 50%;
  transform: translateX(-50%);
  display: flex; gap: 6px;
}
.d-dot { width: 7px; height: 7px; border-radius: 50%; background: rgba(0,0,0,0.2); }
.d-dot.active { background: rgba(0,0,0,0.65); }
.demo-steps { padding-left: 20px; }
.demo-steps li { font-size: 13.5px; color: var(--muted); margin-bottom: 8px; line-height: 1.55; }
.demo-steps li::marker { color: var(--accent); font-weight: 700; }

/* workout plans */
.reco-card { border-left: 3px solid var(--accent); }
.reco-reason { font-size: 14px; line-height: 1.5; margin-bottom: 8px; }
.focus-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.muscle-tag.focus { background: var(--accent-soft); color: var(--accent-dim); }
.plan-card { min-width: 0; width: 100%; margin-bottom: 10px; }
.plan-card .focus-tags { margin: 8px 0 0; }
.plan-card:last-child { margin-bottom: 0; }

.exercise-block {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.exercise-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 4px; }
.exercise-name { font-weight: 700; font-size: 15px; }
.exercise-meta { color: var(--faint); font-size: 12px; }
.exercise-hint { color: var(--muted); font-size: 12px; margin-bottom: 10px; }
.exercise-hint b { color: var(--text); font-weight: 600; }

.set-line { display: grid; grid-template-columns: 26px 1fr 1fr 36px; gap: 8px; align-items: center; margin-bottom: 8px; }
.set-line .set-no {
  color: var(--faint); font-weight: 700; font-size: 13px; text-align: center;
  font-variant-numeric: tabular-nums;
  background: transparent; border: 0; cursor: pointer; padding: 6px 0; border-radius: 6px;
}
.set-line .set-no.type-warmup { color: #6db3e8; background: rgba(109, 179, 232, 0.12); }
.set-line .set-no.type-failure { color: var(--red); background: rgba(242, 109, 109, 0.12); }
.set-line input { padding: 9px 8px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.icon-btn {
  border: 0; background: transparent; color: var(--faint);
  cursor: pointer; padding: 6px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn .ic { width: 16px; height: 16px; }
.icon-btn:hover { color: var(--red); background: var(--card-2); }

.col-labels { display: grid; grid-template-columns: 26px 1fr 1fr 36px; gap: 8px; margin-bottom: 6px; }
.col-labels span { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); text-align: center; }

.log-actions { display: flex; gap: 8px; margin-bottom: 14px; }

.summary-bar {
  position: sticky;
  bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  z-index: 10;
}
.summary-bar .nums { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.summary-bar .nums b { color: var(--text); font-size: 14px; }

/* ---------- rest timer ---------- */
.rest-timer {
  position: fixed;
  bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  left: 0; right: 0;
  margin: 0 auto;
  width: fit-content;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card-2);
  border: 1px solid var(--accent-dim);
  border-radius: 999px;
  padding: 8px 14px;
  z-index: 40;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.rest-timer .ic { width: 16px; height: 16px; color: var(--accent); }
.rest-mini {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.72);
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal {
  width: 100%;
  max-width: 520px;
  max-height: 84vh;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 18px 18px 0 0;
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
}
.modal { position: relative; }
.modal h3 { margin-bottom: 12px; font-size: 17px; letter-spacing: -0.02em; padding-right: 40px; }
.modal-close {
  position: absolute;
  top: 14px; right: 14px;
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}
.modal-close .ic { width: 14px; height: 14px; }
.modal-close:active { transform: scale(0.94); }
.modal .list { overflow-y: auto; flex: 1; }
.muscle-tag {
  font-size: 10px; font-weight: 700;
  padding: 3px 8px; border-radius: 5px;
  background: var(--card-2); color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.05em;
  flex-shrink: 0;
}

/* ---------- feed ---------- */
.feed-card { padding: 14px 16px; }
.feed-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.feed-when { color: var(--faint); font-size: 12px; }
.feed-note { font-size: 14px; margin-bottom: 10px; }
.feed-stats { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 8px; }
.feed-stat { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.feed-stat b { color: var(--text); }
.pr-flag {
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--gold); font-weight: 700; font-size: 12.5px;
}
.pr-flag .ic { width: 14px; height: 14px; }
.feed-exercises { color: var(--faint); font-size: 12px; margin-bottom: 10px; }
.bump-btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.bump-btn .ic { width: 14px; height: 14px; }
.bump-btn.bumped { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ---------- crews & challenges ---------- */
.crew-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.15em;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 8px;
  color: var(--accent);
  cursor: pointer;
}
.chal-card { border-left: 3px solid var(--accent); }
.chal-card.ended { border-left-color: var(--line); opacity: 0.7; }
.chal-name { font-weight: 700; font-size: 15px; }
.chal-meta { color: var(--muted); font-size: 12px; margin: 2px 0 10px; }
.progress-row { display: flex; align-items: center; gap: 10px; margin-bottom: 7px; }
.progress-row .who { width: 104px; font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress-row.me-row .who { color: var(--accent); }
.progress-track { flex: 1; height: 7px; border-radius: 99px; background: var(--card-2); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 99px; background: var(--accent); }
.progress-row .val { font-size: 11.5px; color: var(--muted); width: 60px; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 0; right: 0;
  margin: 0 auto;
  width: fit-content;
  bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  background: var(--card-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  z-index: 100;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  animation: toast-in 0.22s ease;
  max-width: 90vw;
  text-align: center;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- profile ---------- */
.profile-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }

.history-item { cursor: pointer; }
.history-detail { padding: 6px 0 10px; }
.history-detail table { width: 100%; border-collapse: collapse; font-size: 13px; }
.history-detail th { text-align: left; color: var(--faint); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em; padding: 4px 6px; }
.history-detail td { padding: 5px 6px; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.pr-star { color: var(--gold); font-weight: 700; font-size: 12px; }
.history-actions { display: flex; gap: 8px; margin-top: 10px; }

/* progress chart */
.linechart { width: 100%; height: 150px; }
.linechart .grid-line { stroke: var(--line); stroke-width: 1; }
.linechart .series { stroke: var(--accent); stroke-width: 2; fill: none; }
.linechart .dot { fill: var(--accent); }
.linechart .axis-lbl { fill: var(--faint); font-size: 9.5px; font-variant-numeric: tabular-nums; }

/* share preview */
.share-canvas-wrap { display: flex; justify-content: center; margin-bottom: 14px; }
.share-canvas-wrap canvas {
  width: 100%;
  max-width: 340px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}
