/* ================================================================
   Club 1000 Plus Design System
   Inspired by Robinhood × X — Built for strength
   ================================================================ */

/* Ensure [hidden] always wins over display rules like .overlay { display: grid } */
[hidden] { display: none !important; }

/* === CSS Variables === */
:root {
  --bg: #090909;
  --surface: #131313;
  --surface-2: #1B1B1B;
  --surface-3: #232323;
  --surface-hover: #2A2A2A;
  --border: #272727;
  --border-subtle: #1D1D1D;

  --brand: #FF4500;
  --brand-hover: #FF5C1A;
  --brand-dim: rgba(255,69,0,0.1);
  --brand-glow: rgba(255,69,0,0.2);
  --brand-rgb: 255,69,0;
  --brand-strong: #CC3800;

  --gold: #F59E0B;
  --gold-dim: rgba(245,158,11,0.12);
  --silver: #94A3B8;
  --bronze: #CD853F;

  --green: #10B981;
  --green-dim: rgba(16,185,129,0.1);
  --red: #F87171;
  --red-dim: rgba(248,113,113,0.1);

  --text-1: #F2F2F2;
  --text-2: #8A8A8A;
  --text-3: #6F6F6F;

  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 10px;
  --r-xl: 14px;
  --r-full: 9999px;

  --ease: 150ms ease;
  --ease-out: 200ms cubic-bezier(0.2,0,0.1,1);

  --sidebar-w: 240px;
  --mobile-nav-h: 64px;
  --page-max-w: 1440px;
}

html[data-theme="light"] {
  --bg: #F4F4F4;
  --surface: #FFFFFF;
  --surface-2: #F0F0F0;
  --surface-3: #E8E8E8;
  --surface-hover: #EAEAEA;
  --border: #E0E0E0;
  --border-subtle: #EBEBEB;
  --brand: #D93B00;
  --brand-dim: rgba(217,59,0,0.08);
  --brand-glow: rgba(217,59,0,0.15);
  --brand-rgb: 217,59,0;
  --brand-strong: #C23500;
  --text-1: #111111;
  --text-2: #666666;
  --text-3: #757575;
  --gold: #D97706;
  --green: #059669;
  --red: #DC2626;
}

html[data-theme="blue"] {
  --bg: #06080D;
  --surface: #0E121A;
  --surface-2: #141B25;
  --surface-3: #1B2430;
  --surface-hover: #222E3D;
  --border: #273449;
  --border-subtle: #1A2535;
  --brand: #5DA9FF;
  --brand-hover: #7CB9FF;
  --brand-dim: rgba(93,169,255,0.14);
  --brand-glow: rgba(93,169,255,0.3);
  --brand-rgb: 93,169,255;
  --brand-strong: #3E7FCE;
}

html[data-theme="black-red"] {
  --bg: #0A0707;
  --surface: #140E0F;
  --surface-2: #1C1416;
  --surface-3: #251A1D;
  --surface-hover: #2F2024;
  --border: #3A252B;
  --border-subtle: #26181C;
  --brand: #FF5A5F;
  --brand-hover: #FF7A7E;
  --brand-dim: rgba(255,90,95,0.14);
  --brand-glow: rgba(255,90,95,0.28);
  --brand-rgb: 255,90,95;
  --brand-strong: #D9464A;
}

/* === Reset === */
*,*::before,*::after { box-sizing:border-box; margin:0; padding:0; }
html { -webkit-text-size-adjust:100%; scroll-behavior:smooth; }
body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;
  background: var(--bg);
  color: var(--text-1);
  line-height: 1.5;
  font-size: 15px;
  padding-left: 2px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button,input,select,textarea { font:inherit; }
a { color:var(--brand); text-decoration:none; }

/* === Layout Shell === */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  flex: 1 0 auto;
  max-width: var(--page-max-w);
  width: 100%;
  margin-inline: auto;
  border-right: 1px solid var(--border-subtle);
}

.shell.shell-guest {
  grid-template-columns: 1fr;
  border-right: 0;
  max-width: 1280px;
}

/* === Sidebar === */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 20px 12px 24px;
  border-right: 1px solid var(--border-subtle);
  background: var(--surface);
  overflow-y: auto;
  overflow-x: hidden;
}

/* === Brand === */
.brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 4px 6px 18px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 10px;
}

.brand-logo {
  display: block;
  width: min(100%, 180px);
  height: auto;
}

.brand-beta {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--r-full);
  background: var(--brand-dim);
  border: 1px solid rgba(var(--brand-rgb), 0.25);
  font-size: 10px;
  font-weight: 700;
  color: var(--brand);
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.mobile-beta-flag {
  display: none;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--r-full);
  background: var(--brand-dim);
  border: 1px solid rgba(var(--brand-rgb), 0.25);
  font-size: 10px;
  font-weight: 700;
  color: var(--brand);
  letter-spacing: 0.8px;
  text-transform: uppercase;
  flex-shrink: 0;
}

/* === Nav Buttons === */
.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--r-md);
  border: none;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  transition: background var(--ease), color var(--ease);
  white-space: nowrap;
}
.nav-btn svg { flex-shrink:0; opacity:0.65; transition:opacity var(--ease); }
.nav-btn:hover { background:var(--surface-2); color:var(--text-1); }
.nav-btn:hover svg { opacity:1; }
.nav-btn.active { background:var(--brand-dim); color:var(--brand); font-weight:600; }
.nav-btn.active svg { opacity:1; }
.activity-unread-badge {
  margin-left: auto;
  min-width: 20px;
  height: 20px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  color: #fff;
  background: var(--brand);
  border: 1px solid rgba(255,255,255,0.2);
}

/* === Profile Incomplete Badge (nav dot) === */
.profile-incomplete-badge {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f59e0b;
  border: 2px solid var(--surface-1);
  flex-shrink: 0;
  margin-left: auto;
}
.mobile-nav .profile-incomplete-badge {
  margin-left: 0;
  margin-top: -2px;
}
.profile-incomplete-tab-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #f59e0b;
  margin-left: 5px;
  vertical-align: middle;
  flex-shrink: 0;
}

/* === Profile Incomplete Notice Banner === */
.profile-incomplete-notice {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: var(--r-sm);
  color: var(--text-1);
}
.profile-incomplete-notice svg { color: #f59e0b; }
.profile-incomplete-notice-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
}
.profile-incomplete-notice-body strong { font-size: 14px; }
.profile-incomplete-notice-cta { font-size: 13px; white-space: nowrap; }

/* === Spacer === */
.spacer { flex:1; min-height:12px; }

/* === User Profile Button in Sidebar === */
#userProfileWrap {
  position: relative;
}

.user-profile-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-subtle);
  background: var(--surface-2);
  color: var(--text-1);
  cursor: pointer;
  transition: background var(--ease), border-color var(--ease);
  text-align: left;
  min-width: 0;
}
.user-profile-btn:hover {
  background: var(--surface-3);
  border-color: var(--border);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brand-dim);
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  border: 1px solid rgba(var(--brand-rgb),0.25);
  overflow: hidden;
  letter-spacing: 0.3px;
}
.user-avatar.has-image { border-color: var(--border); background: transparent; }
.user-avatar img, .user-avatar.has-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

#userProfileName {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.user-profile-chevron {
  flex-shrink: 0;
  color: var(--text-3);
  transition: transform var(--ease);
}
#userProfileWrap:has(#userPanel:not([hidden])) .user-profile-chevron {
  transform: rotate(180deg);
}

/* === User Panel (Dropdown) === */
.user-panel {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: 0 -8px 32px rgba(0,0,0,0.45);
  z-index: 200;
  overflow: hidden;
}

.user-panel-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 20px 16px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border-subtle);
}

.user-panel-avatar-wrap {
  position: relative;
  width: 64px;
  height: 64px;
  margin-bottom: 2px;
}

.user-panel-avatar-img {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  display: block;
}

.user-panel-avatar-initials {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--brand-dim);
  color: var(--brand);
  border: 2px solid rgba(var(--brand-rgb),0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.user-panel-avatar-edit {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 2px solid var(--surface-2);
  transition: filter var(--ease);
}
.user-panel-avatar-edit:hover { filter: brightness(1.15); }

.user-panel-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.2px;
}
.user-panel-role {
  font-size: 11px;
  font-weight: 600;
  color: var(--brand);
  background: var(--brand-dim);
  padding: 2px 8px;
  border-radius: var(--r-full);
  text-transform: capitalize;
  letter-spacing: 0.2px;
}

.user-panel-section {
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--border-subtle);
}
.user-panel-section-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 10px;
}
.user-panel-prefs-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 10px;
}
.user-panel-prefs-grid label {
  margin-bottom: 8px;
  font-size: 11px;
}
.user-panel-prefs-grid select {
  font-size: 13px;
  padding: 7px 30px 7px 10px;
}

.initialized-height-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 10px;
}
.initialized-height-row label {
  margin-bottom: 8px;
  font-size: 11px;
}

.user-panel-footer {
  padding: 10px 14px 14px;
}

/* === Main Content Area === */
.main {
  padding: 24px 28px 100px;
  min-width: 0;
}

/* === Page Header === */
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
.top h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text-1);
}

/* === Pages === */
.page { display:none; }
.page.active { display:block; }

.app-legal-footer {
  text-align: center;
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.45;
  padding: 10px 16px 14px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg);
  text-wrap: balance;
}
.app-legal-footer a { color: var(--brand); font-weight: 600; }

/* === Cards === */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 20px;
}
.card h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: 14px;
  letter-spacing: -0.1px;
}
.card.soft {
  background: var(--surface-2);
  border-color: var(--border-subtle);
}

/* === Metric Cards === */
.metrics {
  display: grid;
  grid-template-columns: repeat(4,1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  transition: border-color var(--ease);
}
.metric:hover { border-color: var(--brand-dim); }
.metric span {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-3);
}
.metric strong {
  display: block;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -1px;
  margin-top: 8px;
  color: var(--text-1);
  line-height: 1;
}
.metric .metric-sub {
  font-size: 12px;
  color: var(--text-2);
  margin-top: 6px;
}
.metric .change { font-size:12px; font-weight:600; margin-top:5px; }
.metric .change.up { color:var(--green); }
.metric .change.down { color:var(--red); }

/* === Workspace Grid === */
.workspace-grid {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 16px;
}
.workspace-grid .wide { grid-column:1/-1; }
.workspace-grid.body-trends { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* === Analytics Section Header === */
.analytics-section-header {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 28px 0 14px;
}

/* === Body Metrics Row === */
.metrics.body-metrics-row { margin-bottom: 16px; }

/* === Charts === */
.chart { height:260px; }

/* === Favorite Lifts === */
.fav-lift-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  min-height: 32px;
  align-items: center;
}
.fav-lift-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 4px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  color: var(--text-1);
}
.fav-lift-chip-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-3);
  display: flex;
  align-items: center;
  padding: 2px;
  border-radius: 50%;
  transition: color 0.15s, background 0.15s;
}
.fav-lift-chip-remove:hover { color: var(--text-1); background: var(--surface-3); }
.fav-lift-add-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* === Buttons === */
.btn,
.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 20px;
  border-radius: var(--r-sm);
  border: none;
  background: var(--brand);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: filter var(--ease), transform var(--ease);
  white-space: nowrap;
  letter-spacing: -0.1px;
}
.btn:hover,
.primary:hover { filter:brightness(1.1); }
.btn:active,
.primary:active { transform:scale(0.98); }

.btn--secondary,
.ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--ease), color var(--ease), border-color var(--ease);
  white-space: nowrap;
}
.btn--secondary:hover,
.ghost:hover { background:var(--surface-2); color:var(--text-1); }

.btn--cta,
.cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: var(--r-sm);
  border: none;
  background: linear-gradient(135deg, var(--brand), var(--brand-strong));
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 16px var(--brand-glow);
  transition: filter var(--ease), transform var(--ease), box-shadow var(--ease);
  letter-spacing: -0.1px;
}
.btn--cta:hover,
.cta:hover { filter:brightness(1.08); box-shadow:0 6px 22px var(--brand-glow); }
.btn--cta:active,
.cta:active { transform:scale(0.98); }

.btn:disabled,
.btn[aria-disabled="true"],
.btn.is-loading,
.primary:disabled,
.ghost:disabled,
.cta:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
  filter: none;
  transform: none;
  box-shadow: none;
}

.btn--primary,
.primary {
  background: var(--brand);
  color: #fff;
  border: none;
}

.btn--danger {
  background: rgba(248, 113, 113, 0.16);
  color: #fecaca;
  border: 1px solid rgba(248, 113, 113, 0.35);
}
.btn--danger:hover {
  background: rgba(248, 113, 113, 0.24);
}

.btn--icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 999px;
}

.auth-hint-top { margin-top: 8px; }
.auth-hint-bottom { margin-bottom: 10px; }
.auth-status-copy { margin-top: 12px; line-height: 1.4; }
.auth-submit-spaced { margin-top: 20px; }
.auth-hint-centered { margin-top: 14px; text-align: center; }
.tos-date-hint { margin: 8px 0 14px; }

.danger { color:var(--red) !important; border-color:rgba(248,113,113,0.25) !important; }
.danger:hover { background:var(--red-dim) !important; border-color:rgba(248,113,113,0.4) !important; }

/* === Forms === */
label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: 0.2px;
  margin-bottom: 14px;
}
input,select,textarea {
  padding: 11px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-1);
  font-size: 15px;
  transition: border-color var(--ease), background var(--ease), box-shadow var(--ease);
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
}
input:focus,select:focus,textarea:focus {
  outline: none;
  border-color: var(--brand);
  background: var(--surface-3);
  box-shadow: 0 0 0 3px var(--brand-dim);
}
input::placeholder,textarea::placeholder { color:var(--text-3); }
select { background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat:no-repeat; background-position:right 12px center; padding-right:36px; }
.checkbox-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  margin: 10px 0 4px;
  cursor: pointer;
}
.checkbox-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  padding: 0;
  flex: 0 0 auto;
  appearance: auto;
  -webkit-appearance: checkbox;
  accent-color: var(--brand);
}
.checkbox-row span {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}
.stay-logged-in-hint {
  margin: 0 0 10px;
}

/* Prevent iOS zoom on focus */
@media (max-width: 920px) {
  input,select,textarea { font-size:16px; }
}

/* === Registration form helpers === */
.reg-section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--brand);
  margin-bottom: 10px;
}
.reg-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.reg-row label { min-width: 0; }
.reg-lift-block {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 14px;
  margin-bottom: 10px;
}
.reg-lift-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: 10px;
}
.tab-panel.active#registerForm {
  max-height: 72vh;
  overflow-y: auto;
  padding-right: 4px;
}

/* === Tabs === */
.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border-radius: var(--r-md);
  margin-bottom: 20px;
}
.tab {
  flex: 1;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  border: none;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--ease), color var(--ease), box-shadow var(--ease);
}
.tab.active {
  background: var(--surface);
  color: var(--text-1);
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.tab-panel { display:none; }
.tab-panel.active { display:block; }

/* === Tables === */
.table-wrap {
  overflow: auto;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
}
table { width:100%; border-collapse:collapse; min-width:0; font-size:13px; }
/* Opt-in helper for views that intentionally need horizontal table scrolling. */
.table-wrap.table-scroll table { min-width:480px; }
thead { background:var(--surface-2); }
th {
  padding: 10px 14px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-2);
}
tr:last-child td { border-bottom:none; }
tr:hover td { background:var(--surface-2); color:var(--text-1); }

/* === Clickable Rows === */
.leaderboard-row { cursor:pointer; transition:background var(--ease); }
.leaderboard-row.selected td { background:var(--brand-dim); color:var(--text-1); }
.history-row { cursor:pointer; transition:background var(--ease), color var(--ease); }
.history-row:hover td { background:var(--gold-dim); }
.history-row:hover td,
.history-row:hover td div { color:var(--gold) !important; }
.history-exercise-cell {
  transition: color var(--ease), text-shadow var(--ease);
}
.history-exercise-cell:hover {
  color: var(--gold) !important;
  text-shadow: 0 0 10px rgba(245,158,11,0.28);
}
.history-row.selected td { background:var(--brand-dim); color:var(--text-1); }
.history-session-row td {
  background: rgba(245, 158, 11, 0.08);
  border-top: 1px solid rgba(245, 158, 11, 0.2);
  border-bottom: 1px solid rgba(245, 158, 11, 0.2);
  padding-top: 10px;
  padding-bottom: 10px;
}
.history-session-title {
  color: var(--gold);
  font-weight: 700;
  font-size: 13px;
}
.history-session-review {
  color: var(--text-3);
  font-size: 11px;
  margin-top: 3px;
}
.history-session-toggle {
  width: 100%;
  border: none;
  background: transparent;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.history-session-chevron {
  color: var(--gold);
  font-size: 14px;
  width: 14px;
  flex: 0 0 14px;
}
.history-row-collapsed {
  display: none;
}

/* === Exercise Hover Tooltip === */
.exercise-hover-tooltip {
  display: none;
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  background: var(--surface);
  border: 1.5px solid var(--gold);
  border-radius: var(--r-lg);
  box-shadow: 0 8px 32px rgba(0,0,0,0.35), 0 0 0 1px rgba(245,158,11,0.15);
  padding: 14px 16px;
  min-width: 220px;
  max-width: 300px;
  font-size: 13px;
}
.eht-name {
  font-size: 14px;
  font-weight: 800;
  color: var(--gold);
  letter-spacing: -0.2px;
  margin-bottom: 2px;
}
.eht-date {
  font-size: 11px;
  color: var(--text-3);
  margin-bottom: 10px;
}
.eht-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-bottom: 10px;
}
.eht-stat {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.eht-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-3);
}
.eht-val {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-1);
}
.eht-gold { color: var(--gold) !important; }
.eht-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-bottom: 8px;
}
.eht-table th {
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-3);
  padding: 3px 6px 4px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.eht-table td {
  padding: 3px 6px 3px 0;
  color: var(--text-1);
  font-weight: 600;
}
.eht-notes {
  font-size: 12px;
  color: var(--text-2);
  font-style: italic;
  border-top: 1px solid var(--border-subtle);
  padding-top: 8px;
  margin-top: 4px;
}
.eht-video-badge {
  display: inline-block;
  margin-top: 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--gold);
  background: var(--gold-dim);
  border-radius: var(--r-full);
  padding: 2px 8px;
}

/* === Detail Panel Notes & Video === */
.detail-notes {
  padding: 12px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.detail-notes-text {
  color: var(--text-1);
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.detail-video-wrap {
  margin-top: 16px;
  padding-bottom: 4px;
}

/* === Rank Badges === */
.rank-badge {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
}
.rank-1 { background:var(--gold-dim); color:var(--gold); }
.rank-2 { background:rgba(148,163,184,0.12); color:var(--silver); }
.rank-3 { background:rgba(205,133,63,0.12); color:var(--bronze); }
.rank-other { background:var(--surface-2); color:var(--text-3); font-size:10px; }

.member-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--brand-dim);
  color: var(--brand);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  border: 1px solid rgba(var(--brand-rgb),0.2);
  overflow: hidden;
}
.member-avatar.has-image { background: transparent; border-color: var(--border); }
.member-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

/* === Status Badges === */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2px;
  white-space: nowrap;
}
.badge-green    { background:var(--green-dim); color:var(--green); }
.badge-red      { background:var(--red-dim); color:var(--red); }
.badge-gold     { background:var(--gold-dim); color:var(--gold); }
.badge-muted    { background:var(--surface-2); color:var(--text-2); }
.badge-brand    { background:var(--brand-dim); color:var(--brand); }
.badge-blue     { background:var(--brand-dim); color:var(--brand); }
.badge-bronze   { background:rgba(205,133,63,0.12); color:#CD853F; }
.badge-silver   { background:rgba(148,163,184,0.12); color:#94A3B8; }
.badge-platinum { background:rgba(139,92,246,0.12); color:#8B5CF6; }

/* ===========================
   Achievement / Badge Cards
   =========================== */
.badges-section {
  margin-bottom: 20px;
}
.badges-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.badges-section-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--text-2);
}
.badges-empty {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px 20px;
}
.badges-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.badges-grid-compact {
  gap: 6px;
}
.badge-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  cursor: default;
  transition: transform var(--ease);
  min-width: 88px;
  max-width: 110px;
  text-align: center;
}
.badge-card:hover { transform: translateY(-2px); }
.badge-card-sm {
  padding: 8px 10px;
  min-width: 64px;
  max-width: 80px;
  gap: 3px;
}
.badge-card-icon {
  font-size: 26px;
  line-height: 1;
}
.badge-card-name {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1px;
  line-height: 1.3;
}
.badge-card--tier {
  background: var(--badge-bg);
  border: 1px solid var(--badge-border);
}
.badge-card-name--tier {
  color: var(--badge-text);
}
.badge-card-date {
  font-size: 10px;
  color: var(--text-3);
  line-height: 1.2;
}
.profile-tier-group {
  margin-bottom: 16px;
}
.profile-tier-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.profile-tier-group-title {
  margin: 0;
}
.badge-explorer-card--row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--explorer-bg);
  border: 1px solid var(--explorer-border);
}
.badge-explorer-icon {
  font-size: 28px;
  line-height: 1;
  opacity: var(--explorer-icon-opacity);
  flex-shrink: 0;
}
.badge-explorer-body {
  flex: 1;
  min-width: 0;
}
.badge-explorer-name {
  font-weight: 600;
  color: var(--explorer-accent);
  margin-bottom: 2px;
}
.badge-explorer-meta {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--explorer-subtle);
  margin-bottom: 4px;
  opacity: 0.8;
}
.badge-explorer-req {
  font-size: 11px;
  line-height: 1.4;
}

/* ── Clickable badge cards ── */
.badge-card--clickable {
  cursor: pointer;
}
.badge-card--clickable:focus-visible {
  outline: 2px solid var(--badge-border, rgba(255,255,255,0.3));
  outline-offset: 2px;
}

/* ── Badge detail modal ── */
.badge-detail-modal {
  max-width: 380px;
}
.badge-detail-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 4px;
}
.badge-detail-icon {
  font-size: 48px;
  line-height: 1;
  flex-shrink: 0;
}
.badge-detail-header-info {
  flex: 1;
  min-width: 0;
}
.badge-detail-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--detail-text, var(--text-1));
  margin-bottom: 6px;
  line-height: 1.2;
}
.badge-detail-tier-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.badge-detail-status {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  margin-top: 12px;
}
.badge-detail-status.earned {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
}
.badge-detail-status.locked {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
}
.badge-detail-status-icon {
  font-size: 22px;
  flex-shrink: 0;
}

/* ── Badge ladder explorer ── */
.badge-explorer-ladders {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 8px;
}
.badge-ladder-group {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}
.badge-ladder-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.badge-ladder-group-name {
  font-weight: 700;
  font-size: 13px;
  flex: 1;
  min-width: 0;
}
.badge-ladder-rungs {
  display: flex;
  flex-direction: column;
}
.badge-ladder-rung {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--rung-bg);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: filter 0.15s ease;
}
.badge-ladder-rung:last-child {
  border-bottom: none;
}
.badge-ladder-rung:hover {
  filter: brightness(1.1);
}
.badge-ladder-rung:focus-visible {
  outline: 2px solid var(--rung-border, rgba(255,255,255,0.3));
  outline-offset: -2px;
}
.badge-ladder-rung-tier {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 48px;
  text-align: center;
  flex-shrink: 0;
}
.badge-ladder-tier-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  line-height: 1;
}
.badge-ladder-rung-body {
  flex: 1;
  min-width: 0;
}
.badge-ladder-rung-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--rung-text);
  margin-bottom: 2px;
}
.badge-ladder-rung-req {
  font-size: 11px;
  line-height: 1.3;
}
.badge-ladder-rung-status {
  flex-shrink: 0;
}
.badge-ladder-status-pill {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
  letter-spacing: 0.2px;
  white-space: nowrap;
}
.badge-ladder-status-pill.pill-earned {
  background: rgba(16,185,129,0.15);
  color: #10B981;
  border: 1px solid rgba(16,185,129,0.3);
}
.badge-ladder-status-pill.pill-next {
  background: rgba(245,158,11,0.12);
  color: #F59E0B;
  border: 1px solid rgba(245,158,11,0.3);
}
.badge-ladder-status-pill.pill-locked {
  background: rgba(255,255,255,0.05);
  color: var(--text-3);
  border: 1px solid rgba(255,255,255,0.1);
}

/* ── Failure rep tracking ── */
.set-failure-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.set-failure-rep-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}
.set-failure-toggle {
  font-size: 11px;
  padding: 2px 8px;
  color: var(--text-3);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  transition: color 0.15s, border-color 0.15s;
}
.set-failure-toggle.active {
  color: #FF6B6B;
  border-color: rgba(255,107,107,0.3);
  background: rgba(255,107,107,0.08);
}
.set-failure-toggle:hover {
  color: #FF6B6B;
}
.set-failure-rep-input-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
}
.set-failure-rep {
  text-align: center;
}
.set-hint-failure {
  color: #FF6B6B;
  font-size: 10px;
}
.set-belt-toggle {
  font-size: 11px;
  padding: 2px 8px;
  color: var(--text-3);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.set-belt-toggle.set-belt-active {
  color: var(--brand);
  border-color: rgba(var(--brand-rgb, 99,102,241), 0.3);
  background: rgba(var(--brand-rgb, 99,102,241), 0.08);
}
.set-belt-toggle:hover {
  color: var(--brand);
}

.profile-card-spaced {
  margin-bottom: 16px;
}
.thousand-club-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.thousand-club-title {
  margin: 0;
}
.thousand-club-summary {
  margin-bottom: 12px;
  font-size: 12px;
}
.thousand-club-track {
  background: rgba(255,255,255,0.07);
  border-radius: 6px;
  height: 8px;
  margin-bottom: 6px;
  overflow: hidden;
}
.thousand-club-fill {
  width: var(--progress);
  height: 100%;
  background: var(--status-color);
  border-radius: 6px;
  transition: width 0.4s;
}
.thousand-club-progress-label {
  text-align: right;
  margin-bottom: 16px;
  font-size: 11px;
}
.thousand-club-lift-row {
  display: grid;
  grid-template-columns: 140px 1fr 70px;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.thousand-club-lift-name {
  font-size: 13px;
  color: var(--text-2);
}
.thousand-club-lift-track {
  background: rgba(255,255,255,0.07);
  border-radius: 4px;
  height: 6px;
  overflow: hidden;
}
.thousand-club-lift-fill {
  width: var(--lift-pct);
  height: 100%;
  background: var(--lift-color);
  border-radius: 4px;
  transition: width 0.4s;
}
.thousand-club-lift-value {
  text-align: right;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
}
.thousand-club-status {
  margin-top: 8px;
  font-size: 12px;
}
.thousand-club-status--verified {
  color: #8B5CF6;
}
.thousand-club-status--eligible {
  margin: 0;
  color: #F59E0B;
  flex: 1 1 240px;
}
.thousand-club-eligible-row {
  margin-top: 10px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  flex-wrap: wrap;
}

/* === Toast === */
#toastStack {
  position: fixed;
  right: 16px;
  bottom: 84px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
  max-width: 320px;
}
.toast {
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text-1);
  padding: 12px 16px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  animation: toastIn 0.18s ease forwards;
}
@keyframes toastIn {
  from { opacity:0; transform:translateX(12px); }
  to { opacity:1; transform:translateX(0); }
}

/* === Mobile Nav === */
.mobile-nav {
  --mobile-nav-columns: 5;
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  background: rgba(19,19,19,0.96);
  border-top: 1px solid var(--border);
  padding: 8px 4px max(env(safe-area-inset-bottom,8px),8px);
  grid-template-columns: repeat(var(--mobile-nav-columns), 1fr);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
html[data-theme="light"] .mobile-nav { background:rgba(255,255,255,0.96); }

.mobile-nav .nav-btn {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
  border-radius: var(--r-sm);
  min-height: 48px;
}
.sidebar .nav-btn svg { width: 18px; height: 18px; }
.mobile-nav .nav-btn svg { width:18px; height:18px; }
.mobile-nav .activity-unread-badge {
  margin-left: 0;
  margin-top: -2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  font-size: 9px;
}

/* ========================
   AUTH PAGE
   ======================== */
#authView.active {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 48px);
  padding: 24px;
}
.auth-container {
  width: 100%;
  max-width: 1120px;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(420px, 0.9fr);
  border-radius: var(--r-xl);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 32px 80px rgba(0,0,0,0.7);
}
.auth-hero {
  background: linear-gradient(160deg, #1C0800 0%, #0D0D0D 60%);
  padding: 44px 40px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  min-height: 520px;
}
.auth-hero::before {
  content: '';
  position: absolute;
  top: -30%;
  left: -10%;
  width: 120%;
  height: 80%;
  background: radial-gradient(ellipse at 40% 30%, rgba(var(--brand-rgb),0.18) 0%, transparent 65%);
  pointer-events: none;
}
.auth-hero-brand {
  margin-bottom: auto;
  position: relative;
  z-index: 1;
}
.auth-hero-brand .brand-logo {
  width: min(100%, 240px);
}
.auth-hero-content { position:relative; z-index:1; padding-top: 32px; }
.auth-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--r-full);
  background: var(--brand-dim);
  border: 1px solid rgba(var(--brand-rgb),0.2);
  font-size: 11px;
  font-weight: 700;
  color: var(--brand);
  letter-spacing: 0.3px;
  margin-bottom: 18px;
}
.auth-hero h2 {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -1.2px;
  line-height: 1.1;
  margin-bottom: 16px;
  color: var(--text-1);
}
.auth-hero p {
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.65;
  max-width: 340px;
  margin-bottom: 28px;
}
.auth-stats {
  display: grid;
  grid-template-columns: repeat(3,1fr);
  gap: 10px;
}
.auth-stat {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--r-md);
  padding: 14px 12px;
}
.auth-stat strong {
  display: block;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.6px;
  color: var(--text-1);
  line-height: 1;
}
.auth-stat span {
  font-size: 10px;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 600;
  display: block;
  margin-top: 4px;
}
.auth-form-panel {
  background: var(--surface);
  padding: 44px 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}
.auth-form-panel h3 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}
.auth-form-panel > p {
  font-size: 14px;
  color: var(--text-2);
  margin-bottom: 28px;
}
.auth-submit {
  width: 100%;
  padding: 14px;
  font-size: 15px;
  margin-top: 6px;
  border-radius: var(--r-md);
}
.auth-link-btn {
  border: none;
  background: transparent;
  color: var(--brand);
  font-size: 12px;
  font-weight: 600;
  padding: 0;
  margin-top: 2px;
  margin-bottom: 6px;
  cursor: pointer;
  text-align: left;
}
.auth-link-btn:hover { text-decoration: underline; }
.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0 4px;
  color: var(--text-3, var(--text-2));
  font-size: 12px;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.btn--facebook {
  background: #1877F2;
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 700;
  text-decoration: none;
}
.btn--facebook::before {
  content: '';
  display: inline-block;
  width: 18px;
  height: 18px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23fff'%3E%3Cpath d='M24 12.073C24 5.405 18.627 0 12 0S0 5.405 0 12.073C0 18.1 4.388 23.094 10.125 24v-8.437H7.078v-3.49h3.047V9.41c0-3.025 1.792-4.697 4.533-4.697 1.312 0 2.686.236 2.686.236v2.97h-1.513c-1.491 0-1.956.93-1.956 1.885v2.27h3.328l-.532 3.49h-2.796V24C19.612 23.094 24 18.1 24 12.073z'/%3E%3C/svg%3E") no-repeat center/contain;
  flex-shrink: 0;
}
.btn--facebook:hover { background: #166FE5; color: #fff; }
.tos-consent-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-top: 12px;
}
.tos-consent-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 3px;
  flex-shrink: 0;
}
.tos-consent-copy { line-height: 1.45; }
.tos-inline-link {
  display: inline;
  font-size: inherit;
  margin: 0;
}
.tos-review-btn {
  margin-top: 6px;
  font-size: 13px;
}
.tos-modal {
  width: min(860px, 100%);
  max-height: min(92vh, 980px);
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 0;
  padding-bottom: 0;
}
.tos-layout {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  margin-top: 8px;
}
.tos-content {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
  padding: 16px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.tos-content section { margin-top: 14px; }
.tos-content h4 {
  font-size: 14px;
  margin-bottom: 6px;
  color: var(--text-1);
}
.tos-content p {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-2);
}
.tos-actions {
  padding: 12px 0 0;
  margin-top: 12px;
  background: linear-gradient(to bottom, transparent, var(--surface) 35%);
}
.tos-accept-btn {
  width: 100%;
  min-height: 48px;
  font-size: 15px;
}
.tos-accept-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.tos-countdown-badge {
  font-size: 13px;
  opacity: 0.8;
  margin-left: 4px;
}

/* ========================
   DASHBOARD
   ======================== */
.dashboard-hero {
  background: linear-gradient(135deg, #160800, #0D0D0D);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 28px 32px;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}
html[data-theme="light"] .dashboard-hero {
  background: linear-gradient(135deg, #FFF5F0, #FFFFFF);
}
.dashboard-hero::before {
  content: '';
  position: absolute;
  top: -40%;
  right: -10%;
  width: 60%;
  height: 200%;
  background: radial-gradient(ellipse, rgba(var(--brand-rgb),0.08) 0%, transparent 65%);
  pointer-events: none;
}
.dashboard-hero-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  align-items: center;
  position: relative;
  z-index: 1;
}
.hero-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 8px;
}
.hero-value {
  font-size: 48px;
  font-weight: 800;
  letter-spacing: -2px;
  color: var(--text-1);
  line-height: 1;
  margin-bottom: 6px;
}
.hero-sub {
  font-size: 13px;
  color: var(--text-2);
}
.hero-metrics {
  display: flex;
  gap: 32px;
}
.hero-metric { text-align: right; }
.hero-metric .hm-val {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-1);
  display: block;
}
.hero-metric .hm-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-3);
  margin-top: 2px;
  display: block;
}

/* ========================
   LOG PAGE
   ======================== */
.log-grid { display:grid; gap:16px; }
.log-grid.single { grid-template-columns: 1fr; }
.log-session-date {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-1);
  margin-bottom: 14px;
}
.log-session-add-wrap {
  display: flex;
  justify-content: center;
  margin: 12px 0 16px;
}
.log-session-add-btn {
  min-width: 220px;
  font-size: 16px;
}
.log-session-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}
.log-date-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 0 12px;
  flex-wrap: nowrap;
}
.log-date-nav .icon-btn {
  width: 36px;
  min-width: 36px;
  padding: 8px 0;
  line-height: 1;
}
.date-nav-label {
  flex: 1;
  min-width: 0;
  display: block;
}
.date-nav-input {
  width: 100%;
}
.date-nav-input::-webkit-calendar-picker-indicator {
  opacity: 1;
  cursor: pointer;
  filter: var(--date-picker-icon-filter, invert(92%) sepia(13%) saturate(216%) hue-rotate(180deg) brightness(103%) contrast(93%));
}
[data-theme="light"] .date-nav-input::-webkit-calendar-picker-indicator {
  filter: var(--date-picker-icon-filter-light, invert(13%) sepia(13%) saturate(554%) hue-rotate(173deg) brightness(96%) contrast(92%));
}
.session-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

/* Big + button */
.session-add-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  font-size: 22px;
  font-weight: 400;
  line-height: 1;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background 0.15s;
}
.session-add-btn:hover { background: var(--brand-hover); }
.session-add-btn span { font-size: 22px; line-height: 1; }

/* Action menu popup */
.session-action-menu {
  position: absolute;
  z-index: 1300;
}
.session-action-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,.45);
  min-width: 220px;
  overflow: hidden;
}
.session-action-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 16px 18px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-1);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s;
}
.session-action-item:last-child { border-bottom: none; }
.session-action-item:hover { background: var(--surface-2); }
.session-action-item-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  flex-shrink: 0;
}
.session-action-item-icon svg { width: 16px; height: 16px; color: var(--text-1); }

/* Exercise search modal */
.exercise-search-overlay {
  align-items: flex-start;
  padding: 0;
  background: rgba(8,10,20,0.55);
}
.exercise-search-modal {
  width: 100%;
  max-width: 560px;
  max-height: 100dvh;
  background: var(--surface);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* On larger screens center it */
  margin: 0 auto;
  border: 1px solid var(--border);
}
@media (min-width: 600px) {
  .exercise-search-overlay { align-items: center; padding: 16px; }
  .exercise-search-modal { border-radius: var(--r-lg); max-height: 88vh; }
}
.exercise-search-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--border);
}
.exercise-search-input-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}
.exercise-search-icon {
  position: absolute;
  left: 10px;
  width: 16px;
  height: 16px;
  color: var(--text-3);
  pointer-events: none;
}
.exercise-search-input-wrap input {
  width: 100%;
  padding: 9px 12px 9px 34px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  color: var(--text);
}
.exercise-search-cancel {
  background: none;
  border: none;
  color: var(--brand);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 2px;
  white-space: nowrap;
}
.exercise-search-subtitle {
  margin: 0;
  padding: 10px 16px 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
}
.exercise-search-results {
  flex: 1;
  overflow-y: auto;
  padding: 6px 12px 24px;
  overscroll-behavior: contain;
}
.exercise-search-group { margin-bottom: 18px; }
.exercise-search-cat-header {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-1);
  padding: 8px 4px 6px;
  text-transform: capitalize;
}
.exercise-search-cat-items {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.exercise-search-item {
  display: block;
  width: 100%;
  padding: 13px 16px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-1);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.1s;
}
.exercise-search-item:last-child { border-bottom: none; }
.exercise-search-item:hover,
.exercise-search-item:active { background: var(--brand-dim); }

/* ── Exercise search modal: create new exercise section ── */
.esm-create-section {
  border-top: 1px solid var(--border);
  padding: 12px 16px 16px;
  flex-shrink: 0;
}
.esm-create-toggle {
  background: none;
  border: none;
  color: var(--brand);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 0;
  width: 100%;
  text-align: left;
}
.esm-create-toggle:hover { opacity: 0.8; }
.esm-create-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}
.esm-create-form input[type="text"] {
  width: 100%;
  padding: 9px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  box-sizing: border-box;
}
.esm-create-row {
  display: flex;
  gap: 8px;
}
.esm-create-row select {
  flex: 1;
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text);
}
.esm-create-error {
  font-size: 12px;
  color: var(--danger, #e74c3c);
  padding: 2px 0;
}
.esm-create-submit-btn {
  padding: 10px 16px;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.esm-create-submit-btn:hover { opacity: 0.88; }
.esm-create-submit-btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* Body scroll lock when any overlay is open */
body.modal-open { overflow: hidden; }
body:has(.overlay:not([hidden])) { overflow: hidden; }
.log-session-list-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-3);
}
.log-session-item {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.log-session-item-name {
  color: var(--text-1);
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.log-session-item-meta {
  margin-top: 2px;
  color: var(--text-3);
  font-size: 12px;
}
.session-item-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.type-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 24px;
}
.type-btn {
  padding: 14px;
  border-radius: var(--r-lg);
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--ease);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  letter-spacing: -0.1px;
}
.type-btn.active {
  background: var(--brand-dim);
  color: var(--brand);
  border-color: rgba(var(--brand-rgb),0.3);
}
.type-btn:hover:not(.active) {
  background: var(--surface-3);
  color: var(--text-1);
}

.category-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.pill-btn {
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--ease);
  letter-spacing: 0.1px;
  text-transform: capitalize;
}
.pill-btn.active { background:var(--brand-dim); color:var(--brand); border-color:rgba(var(--brand-rgb),0.3); }
.pill-btn:hover:not(.active) { background:var(--surface-2); color:var(--text-1); }

.set-row,
.set-row-wide {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: var(--r-md);
  margin-bottom: 8px;
  border: 1px solid var(--border-subtle);
}
.set-row-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.set-row-inputs {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}
.set-row-inputs input {
  min-width: 0;
}
.set-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 0;
}
.set-estimate {
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
  text-align: center;
  min-width: 72px;
}
.set-estimate strong { color:var(--brand); font-size:13px; }

.e1rm-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px 18px;
  margin: 12px 0;
}
.e1rm-banner .eb-primary {
  min-width: 0;
}
.e1rm-banner .eb-label { font-size:12px; color:var(--text-2); font-weight:600; }
.e1rm-banner .eb-value { font-size:26px; font-weight:800; color:var(--brand); letter-spacing:-0.8px; white-space: nowrap; }
.e1rm-banner .eb-unit { font-size:16px; font-weight:600; color:var(--text-2); }
.e1rm-banner .eb-current-range { margin-top: 4px; }
.e1rm-banner .eb-next-goal { margin-top: 4px; }
.e1rm-banner .eb-side {
  flex: 1;
  min-width: 0;
}
.e1rm-banner .eb-focus-control {
  display: flex;
  align-items: center;
  gap: 8px;
}
.e1rm-banner .eb-focus-control select {
  max-width: 190px;
}
.e1rm-banner .eb-talk {
  margin-top: 4px;
  text-align: right;
}

/* ─── Achievements button (log view) ──────────────────────────────────────── */
.log-achievements-btn {
  display: block;
  width: 100%;
  margin: -4px 0 12px;
  font-size: 12px;
  color: var(--brand);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 6px 12px;
  text-align: center;
  cursor: pointer;
}
.log-achievements-btn:hover { background: var(--surface-2); }

/* ─── Achievements panel modal ────────────────────────────────────────────── */
.ach-panel-modal {
  width: min(500px, 100%);
  max-height: 80vh;
  overflow-y: auto;
}
.ach-section { margin-bottom: 20px; }
.ach-section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-2);
  margin-bottom: 10px;
}
.ach-all-section { border: none; }
.ach-all-section > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; }
.ach-all-section > summary::-webkit-details-marker { display: none; }
.ach-all-summary { margin-bottom: 0; }

/* Next badge goal card */
.ach-next-goal {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  border-radius: var(--r-md);
  padding: 14px 16px;
}
.ach-next-goal-icon { font-size: 32px; line-height: 1; flex-shrink: 0; }
.ach-next-goal-info { min-width: 0; flex: 1; }
.ach-next-goal-label { font-size: 10px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; color: var(--text-3); margin-bottom: 3px; }
.ach-next-goal-name { font-size: 15px; font-weight: 700; margin-bottom: 4px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ach-tier-pill {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.4px;
  padding: 2px 7px;
  border-radius: 20px;
}
.ach-next-goal-target { font-size: 12px; margin-bottom: 8px; }
.ach-next-goal-sub { font-size: 11px; margin-top: 4px; }
.ach-mastered { }

/* Progress bar */
.ach-progress-bar-wrap { display: flex; align-items: center; gap: 8px; }
.ach-progress-bar-track {
  flex: 1;
  height: 6px;
  background: var(--surface-2);
  border-radius: 3px;
  overflow: hidden;
}
.ach-progress-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}
.ach-progress-pct { font-size: 11px; font-weight: 600; white-space: nowrap; color: var(--text-2); }

.row-actions { display:flex; gap:8px; margin:4px 0 16px; }

.inline-create-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin: -4px 0 10px;
}

.form-row-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.form-row-2 > label { margin-bottom: 0; }
.workout-time-row .workout-end-time-label { display: flex; }

.cardio-stats-panel {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px;
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.cs-label { font-size:10px; font-weight:700; color:var(--text-3); text-transform:uppercase; letter-spacing:0.5px; }
.cs-value { font-size:16px; font-weight:700; color:var(--text-1); margin-top:3px; }

.cardio-distance-row { display:grid; grid-template-columns:1fr 140px; gap:8px; margin-bottom:10px; }
.cardio-distance-row > label { margin-bottom:0; }

.hint { font-size:12px; color:var(--text-3); line-height:1.5; }

/* ========================
   HISTORY PAGE
   ======================== */
.history-grid { align-items:start; }
.history-hint-top { margin-top: 4px; }
.history-cat-badge { margin-left: 6px; }
.history-empty-row {
  text-align: center;
  color: var(--text-3);
  padding: 28px;
}
.history-date-cell { white-space: nowrap; }
.history-date-primary {
  font-weight: 600;
  color: var(--text-1);
}
.history-date-secondary {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 2px;
}
.history-exercise-name {
  font-weight: 600;
  color: var(--text-1);
}
.history-work-value {
  font-weight: 700;
  color: var(--text-1);
}
.history-work-secondary { margin-top: 2px; }
.detail-header-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}
.dr-value-brand { color: var(--brand); }
.detail-section-top { margin-top: 16px; }
.detail-table-muted { color: var(--text-3); }
.detail-table-brand { color: var(--brand); }
.detail-label-spacer-sm { margin-bottom: 6px; }
.detail-label-spacer-md { margin-bottom: 8px; }

.details-panel { display:flex; flex-direction:column; gap:0; }
.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 14px;
}
.detail-row:last-of-type { border-bottom:none; }
.dr-label { color:var(--text-2); font-weight:500; }
.dr-value { color:var(--text-1); font-weight:600; text-align:right; }

.history-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
}

/* ========================
   LEADERBOARD PAGE
   ======================== */
.lb-filter-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.lb-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.lb-member-line {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.lb-rel-tag {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  background: var(--surface-2);
}

.lb-rel-tag.is-friend {
  border-color: var(--ok);
  color: var(--ok);
}

.lb-rel-tag.is-pending {
  border-color: var(--warn);
  color: var(--warn);
}

.lb-rel-cancel-btn {
  border: 1px solid var(--warn);
  background: transparent;
  color: var(--warn);
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  line-height: 1.3;
}

.lb-rel-cancel-btn:hover {
  background: color-mix(in srgb, var(--warn) 10%, transparent);
}

.lb-type-tabs {
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 0;
}

.lb-type-tabs .tab {
  font-size: 13px;
  padding: 6px 14px;
}

.lb-main-tabs {
  margin-bottom: 16px;
  overflow-x: auto;
  flex-wrap: nowrap;
}
.lb-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}
.lb-section-title { margin-bottom: 0; }
.lb-filter-pills--tight { margin-bottom: 0; }
.lb-type-tabs-row {
  margin-bottom: 12px;
  overflow-x: auto;
  flex-wrap: nowrap;
}
.lb-deep-head { margin-bottom: 16px; }
.lb-deep-title { margin-bottom: 4px; }
.lb-hint-tight { margin: 0; }
.lb-empty-state {
  padding: 20px 0;
  text-align: center;
}
.lb-section-intro { margin-bottom: 12px; }
.lb-split-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}
.lb-subhead { margin-bottom: 8px; }
.lb-verified-tag-wrap { margin-top: 3px; }
.lb-verified-badge { font-size: 10px; }
.lb-deep-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.lb-deep-entry {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--r-md);
  background: transparent;
  border: 1px solid transparent;
}
.lb-deep-entry.is-top-1 {
  background: var(--surface-2);
  border-color: rgba(245, 158, 11, 0.2);
}
.lb-deep-entry.is-top-2 {
  background: var(--surface-2);
  border-color: rgba(148, 163, 184, 0.15);
}
.lb-deep-entry.is-top-3 {
  background: var(--surface-2);
  border-color: rgba(205, 133, 63, 0.15);
}
.lb-deep-member {
  flex: 1;
  min-width: 0;
}
.lb-deep-date {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 1px;
}
.lb-deep-score { text-align: right; }
.lb-deep-score-value {
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -0.3px;
  color: var(--text-1);
}
.lb-deep-score-value.is-top-1 { color: var(--gold); }
.lb-deep-score-value.is-top-2 { color: var(--silver); }
.lb-deep-score-value.is-top-3 { color: var(--bronze); }
.lb-deep-score-label {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 2px;
}
.lb-deep-score-meta,
.lb-cell-score-meta {
  font-size: 11px;
  color: var(--text-2);
  margin-top: 4px;
}
.lb-more {
  text-align: center;
  padding: 8px 0;
}
.lb-empty-cell {
  text-align: center;
  color: var(--text-3);
  padding: 28px;
}
.lb-cell-strong {
  font-weight: 600;
  color: var(--text-1);
}
.lb-cell-bold {
  font-weight: 700;
  color: var(--text-1);
}
.lb-cell-score-value {
  font-weight: 800;
  color: var(--text-1);
}
.lb-cell-score-label {
  font-size: 11px;
  color: var(--text-3);
}
.lb-empty-inline { padding: 8px 0; }
.lb-member-inline {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ========================
   PROFILE PAGE
   ======================== */

/* Legacy form grid (kept for compat) */
.metrics-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}

/* New 2-col entry grid that stays 2-col on mobile */
.metrics-entry-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 14px;
}

.friend-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.friend-row:last-child {
  border-bottom: 0;
}

.leaderboard-member-btn {
  border: 0;
  background: transparent;
  color: var(--text-1);
  padding: 0;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  text-align: left;
}

.leaderboard-member-btn:hover {
  color: var(--brand);
  text-decoration: underline;
}

.lb-exercise-name {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}

.lb-exercise-prefix {
  color: var(--text-3);
  font-size: 12px;
  white-space: nowrap;
}

.lb-exercise-main {
  color: var(--text-1);
  font-weight: 600;
  min-width: 0;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 20, 0.72);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  z-index: 1200;
  padding: 16px;
  overflow-y: auto;
}
.overlay > .modal-card {
  /* Centre in viewport when short; starts at top when content is tall */
  margin: auto;
  flex-shrink: 0;
}

/* Custom confirm dialog */
.confirm-dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 20, 0.72);
  display: grid;
  place-items: center;
  z-index: 1500;
  padding: 16px;
}
.confirm-dialog {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 24px 20px 18px;
  width: min(340px, 100%);
  box-shadow: 0 24px 55px rgba(0,0,0,.55);
}
.confirm-dialog-msg {
  margin: 0 0 20px;
  font-size: 15px;
  color: var(--text-1);
  line-height: 1.5;
}
.confirm-dialog-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.modal-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px;
  position: relative;
  box-shadow: var(--shadow-lg);
}
.modal-title { margin: 0 0 8px; }
.modal-subtitle { margin-bottom: 12px; }

.leaderboard-member-modal {
  background: var(--surface);
  border-color: var(--brand);
  box-shadow: 0 24px 55px rgba(0, 0, 0, 0.55);
}

.modal-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  cursor: pointer;
}

.mini-stat {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
  padding: 10px;
}

.mini-stat span {
  display: block;
  color: var(--text-3);
  font-size: 11px;
  margin-bottom: 3px;
}

.mini-stat strong {
  color: var(--text-1);
  font-size: 14px;
}

/* Profile Hero */
.profile-hero {
  background: linear-gradient(135deg, #160800, #0D0D0D);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 20px 24px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
  overflow: hidden;
}
html[data-theme="light"] .profile-hero {
  background: linear-gradient(135deg, #FFF5F0, #FFFFFF);
}
.profile-hero::before {
  content: '';
  position: absolute;
  top: -40%;
  right: -10%;
  width: 60%;
  height: 200%;
  background: radial-gradient(ellipse, rgba(var(--brand-rgb),0.08) 0%, transparent 65%);
  pointer-events: none;
}
.profile-hero-left {
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
  z-index: 1;
}
.profile-hero-avatar-wrap {
  position: relative;
  width: 56px;
  height: 56px;
  flex-shrink: 0;
}
.profile-hero-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--border);
}
.profile-hero-avatar-edit {
  bottom: -2px;
  left: -2px;
  right: auto;
  border-color: var(--surface);
}
.profile-hero-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.profile-hero-avatar-initials {
  width: 100%;
  height: 100%;
  background: var(--brand-dim);
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.profile-hero-info { min-width: 0; }
.profile-hero-name {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.4px;
  color: var(--text-1);
  line-height: 1.2;
}
.profile-hero-role {
  font-size: 11px;
  font-weight: 600;
  color: var(--brand);
  background: var(--brand-dim);
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--r-full);
  text-transform: capitalize;
  margin-top: 4px;
  letter-spacing: 0.2px;
}
.profile-hero-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  position: relative;
  z-index: 1;
}
.profile-stat {
  text-align: center;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: var(--r-md);
  padding: 10px 8px;
}
html[data-theme="light"] .profile-stat {
  background: rgba(0,0,0,0.03);
  border-color: rgba(0,0,0,0.06);
}
.profile-stat-val {
  display: block;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-1);
  line-height: 1;
}
.profile-stat-label {
  display: block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-3);
  margin-top: 4px;
}

/* Profile Tab Panels */
.profile-tab-panel { }
.profile-tab-panel + .card,
.profile-tab-panel .card:first-child {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.profile-overview-highlights {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}

.profile-disclosure summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--text-1);
  list-style: none;
}

.profile-disclosure summary::-webkit-details-marker {
  display: none;
}

.profile-disclosure summary::after {
  content: '▾';
  float: right;
  color: var(--text-3);
}

.profile-disclosure[open] summary::after {
  content: '▴';
}

/* Progress Photos */
.progress-photos-section {
  margin-bottom: 20px;
}
.progress-photos-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.progress-photos-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-2);
  letter-spacing: -0.1px;
}
.progress-photos-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
  padding-bottom: 4px;
}
.progress-photos-strip::-webkit-scrollbar { height: 3px; }
.progress-photos-strip::-webkit-scrollbar-track { background: transparent; }
.progress-photos-strip::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.progress-photo-thumb {
  flex-shrink: 0;
  width: 100px;
  height: 140px;
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid var(--border);
  scroll-snap-align: start;
  background: var(--surface-2);
}
.progress-photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Upload Zones */
.progress-upload-section {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border-subtle);
}
.upload-section-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 12px;
}
.upload-section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-2);
  letter-spacing: 0.2px;
  text-transform: uppercase;
}
.upload-section-hint {
  font-size: 11px;
  color: var(--text-3);
}
.upload-zones {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.initialized-upload-zones {
  grid-template-columns: repeat(3, minmax(0, 72px));
  justify-content: start;
}
.initialized-upload-zones .upload-zone {
  aspect-ratio: 1 / 1.25;
}
.upload-zone {
  position: relative;
  border-radius: var(--r-md);
  border: 1.5px dashed var(--border);
  background: var(--surface-2);
  overflow: hidden;
  aspect-ratio: 3/4;
  transition: border-color var(--ease), background var(--ease);
  cursor: pointer;
}
.upload-zone:hover { border-color: var(--brand); background: var(--brand-dim); }
.upload-zone.has-image { border-style: solid; border-color: var(--brand); }
.upload-zone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  height: 100%;
  cursor: pointer;
  color: var(--text-3);
}
.upload-zone-icon { display: flex; align-items: center; }
.upload-zone-preview-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: calc(var(--r-md) - 2px);
}
.upload-zone-label-text {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  position: relative;
  z-index: 1;
}
.upload-zone.has-image .upload-zone-label-text {
  background: rgba(0,0,0,0.55);
  color: #fff;
  padding: 2px 7px;
  border-radius: var(--r-full);
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
}
.upload-zone.has-image .upload-zone-icon { display: none; }
.upload-zone-clear {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  transition: background var(--ease);
}
.upload-zone-clear:hover { background: var(--red); }

.checkin-compare-controls {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 8px;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.checkin-compare-angle-controls {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}
.checkin-compare-board {
  margin-top: 12px;
  display: block;
}
.checkin-compare-card {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
  padding: 8px;
}
.checkin-compare-card--single {
  width: 100%;
}
.checkin-compare-photo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.checkin-compare-pane {
  min-width: 0;
}
.checkin-compare-photo-wrap {
  margin-top: 6px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  background: var(--surface);
}
.checkin-compare-photo {
  width: 100%;
  display: block;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  cursor: zoom-in;
}
.checkin-compare-photo-empty {
  aspect-ratio: 3 / 4;
  display: grid;
  place-items: center;
  color: var(--text-3);
  font-size: 12px;
}
.checkin-compare-metrics {
  margin-top: 8px;
  display: grid;
  gap: 6px;
}
.checkin-compare-metrics > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}
.checkin-compare-metrics span { color: var(--text-3); }
.checkin-compare-metrics strong { color: var(--text-1); font-size: 13px; }
.checkin-compare-share-mark {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
}
.checkin-compare-share-mark img {
  width: 18px;
  height: 18px;
  object-fit: contain;
}

.checkin-calendar-wrap {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  background: var(--surface-2);
  margin-bottom: 14px;
}
.checkin-calendar-title {
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: 8px;
}
.checkin-calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 6px;
}
.checkin-calendar-weekdays span {
  font-size: 11px;
  color: var(--text-3);
  text-align: center;
}
.checkin-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}
.checkin-calendar-day {
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-2);
  border-radius: 10px;
  min-height: 36px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.checkin-calendar-day--empty {
  background: transparent;
  border-color: transparent;
  min-height: 36px;
}
.checkin-calendar-day.is-measured {
  background: #19de80;
  border-color: #19de80;
  color: #04110b;
  cursor: pointer;
}
.checkin-calendar-day:disabled {
  opacity: 0.35;
}
.checkin-calendar-day.is-measured:hover {
  filter: brightness(0.95);
}
.checkin-calendar-day.has-photos {
  position: relative;
}
.checkin-calendar-day.has-photos::after {
  content: '';
  position: absolute;
  right: 5px;
  bottom: 5px;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 0 0 1px rgba(4, 17, 11, 0.35);
}

.checkin-photo-flag {
  font-size: 15px;
  line-height: 1;
}
.checkin-photo-flag--empty {
  color: var(--text-3);
}

[data-checkin-history-row] {
  cursor: pointer;
}
[data-checkin-history-row]:hover {
  background: var(--surface-2);
}
[data-checkin-history-row].checkin-compare-selected {
  background: color-mix(in srgb, var(--brand) 18%, var(--surface-1));
}
tr[data-checkin-history-row].checkin-compare-selected > td {
  background: color-mix(in srgb, var(--brand) 18%, var(--surface-1));
  color: var(--text-1);
}
.checkin-calendar-day.checkin-compare-selected {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 55%, #ffffff);
}

.checkin-details-modal {
  width: min(860px, 100%);
  max-height: min(86vh, 900px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.checkin-details-section {
  margin-top: 14px;
}
.checkin-details-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.checkin-details-section-title {
  font-size: 13px;
}
.checkin-details-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.checkin-details-grid > div {
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 8px 10px;
  background: var(--surface-2);
}
.checkin-details-grid span {
  display: block;
  color: var(--text-3);
  font-size: 11px;
  margin-bottom: 4px;
}
.checkin-details-grid strong {
  color: var(--text-1);
  font-size: 14px;
}
.checkin-details-photo-grid {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 10px;
  padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.checkin-details-photo-btn {
  border: 1px solid var(--border-subtle);
  background: var(--surface-2);
  border-radius: 10px;
  padding: 0;
  overflow: hidden;
  cursor: zoom-in;
  flex: 0 0 clamp(108px, 28vw, 180px);
}
.checkin-details-photo-btn img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  display: block;
}
.checkin-details-photo-btn span {
  display: block;
  padding: 6px 8px;
  text-align: center;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
}
.checkin-details-cta-wrap {
  margin-bottom: 10px;
}
.checkin-details-compare-cta {
  width: 100%;
}

.reauth-modal {
  max-width: 420px;
}
.reauth-modal-message {
  color: var(--text-2);
  margin-bottom: 16px;
  font-size: 14px;
}
.reauth-modal-field {
  display: block;
  margin-bottom: 14px;
}
.reauth-modal-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--text-3);
}
.reauth-modal-input {
  margin-top: 6px;
  width: 100%;
}
.reauth-modal-actions {
  display: flex;
  gap: 10px;
}
.reauth-modal-btn { flex: 1; }
.reauth-modal-error {
  color: #f87171;
  font-size: 12px;
  margin-top: 10px;
}
.checkin-photo-viewer-overlay { padding: 20px; }
.checkin-photo-viewer-modal {
  max-width: min(96vw, 1200px);
  width: auto;
  padding: 0;
  background: rgba(0,0,0,0.92);
  border: 1px solid rgba(255,255,255,0.16);
}
.checkin-photo-viewer-image {
  display: block;
  width: 100%;
  height: auto;
  max-width: min(96vw, 1200px);
  max-height: 90vh;
  object-fit: contain;
}

/* ========================
   ADMIN PAGE
   ======================== */
.admin-controls {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.admin-actions { display:flex; gap:6px; flex-wrap:wrap; }
.admin-actions .ghost { padding:5px 10px; font-size:11px; }
.admin-action-select {
  min-width: 160px;
  font-size: 12px;
  padding: 6px 8px;
}

.admin-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.admin-table-wrap table {
  min-width: 760px;
}

/* ========================
   SIDEBAR PREFERENCES
   ======================== */
.sidebar .card.compact {
  margin-top: 10px;
  padding: 14px;
  background: var(--surface-2);
  border-color: var(--border-subtle);
}
.sidebar .card.compact h3 {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 12px;
}
.sidebar .card.compact label { font-size:11px; margin-bottom:10px; }
.sidebar .card.compact input,
.sidebar .card.compact select { padding:7px 10px; font-size:13px; }
.sidebar .card.compact .primary { width:100%; font-size:13px; padding:9px; margin-top:4px; }

/* ========================
   RESPONSIVE
   ======================== */
@media (max-width: 920px) {
  body.checkin-details-open {
    overflow: hidden;
  }
  body.workout-history-details-open {
    overflow: hidden;
  }
  .checkin-details-overlay {
    padding: 0;
    align-items: end;
    place-items: end stretch;
  }
  .history-details-overlay {
    padding: 0;
    align-items: end;
    place-items: end stretch;
  }
  .checkin-details-modal {
    width: 100%;
    max-width: 100%;
    height: min(84vh, 760px);
    max-height: min(84vh, 760px);
    border-radius: 18px 18px 0 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    padding: 16px 14px calc(14px + env(safe-area-inset-bottom));
  }
  .history-details-overlay .history-details-modal {
    width: 100%;
    max-width: 100%;
    height: min(84vh, 760px);
    max-height: min(84vh, 760px);
    border-radius: 18px 18px 0 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    padding: 16px 14px calc(14px + env(safe-area-inset-bottom));
  }
  #authView.active { padding: 16px; align-items: flex-start; }
  .shell { grid-template-columns:1fr; border-right:0; }
  .sidebar { display:none; }
  .mobile-nav { display:grid; }
  .mobile-beta-flag { display:inline-flex; }
  .main { padding: 0 0 84px; }
  .app-legal-footer {
    font-size: 11px;
    padding: 10px 12px calc(var(--mobile-nav-h) + env(safe-area-inset-bottom, 0px) + 14px);
    margin: 0 auto;
    max-width: 100%;
    position: relative;
    z-index: 1;
  }
  .top {
    margin-bottom: 6px;
    padding: 8px 10px 0;
  }
  .top h1 { font-size:15px; }
  .page { width: 100%; }
  #dashboardView,
  #feedView,
  #logView,
  #historyView,
  #checkinsView,
  #leaderboardsView,
  #profileView,
  #adminView {
    padding-inline: 0;
  }
  #dashboardView .card,
  #feedView .card,
  #logView .card,
  #historyView .card,
  #checkinsView .card,
  #leaderboardsView .card,
  #profileView .card,
  #adminView .card {
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    padding-left: 0;
    padding-right: 0;
    width: 100%;
    box-sizing: border-box;
  }
  #logView .tabs {
    border-radius: 0;
    margin-bottom: 0;
    padding-left: 0;
    padding-right: 0;
    width: 100%;
  }
  .metrics { grid-template-columns:repeat(2,1fr); }
  .workspace-grid,
  .workspace-grid.body-trends { grid-template-columns:1fr; }
  .log-grid { grid-template-columns:1fr; }
  .auth-container { grid-template-columns:1fr; border-radius:var(--r-lg); }
  .auth-hero { min-height:auto; padding:28px 24px; }
  .auth-hero h2 { font-size:26px; }
  .auth-form-panel { padding:28px 24px; }
  .tos-modal {
    width: 100%;
    max-height: calc(100vh - 12px);
    padding: 16px 14px 0;
  }
  .tos-actions {
    position: sticky;
    bottom: 0;
    padding: 12px 0 max(12px, env(safe-area-inset-bottom));
  }
  .tos-accept-btn {
    min-height: 52px;
    font-size: 16px;
  }
  .admin-controls { grid-template-columns:1fr; }

  .admin-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .admin-tabs::-webkit-scrollbar { display: none; }
  .admin-tabs .tab {
    flex: 0 0 auto;
    white-space: nowrap;
  }
  .admin-log-toolbar {
    display: grid !important;
    grid-template-columns: 1fr;
    gap: 10px !important;
  }
  .admin-log-summary {
    width: 100%;
  }
  .admin-exercise-grid {
    grid-template-columns: 1fr !important;
  }
  .admin-merge-form {
    grid-template-columns: 1fr !important;
  }
  #adminView .admin-table-wrap table {
    min-width: 640px;
  }
  #adminView .admin-members-table th:nth-child(4),
  #adminView .admin-members-table td:nth-child(4),
  #adminView .admin-members-table th:nth-child(5),
  #adminView .admin-members-table td:nth-child(5) {
    display: none;
  }
  #adminView .admin-achievements-table th:nth-child(5),
  #adminView .admin-achievements-table td:nth-child(5),
  #adminView .admin-achievements-table th:nth-child(7),
  #adminView .admin-achievements-table td:nth-child(7) {
    display: none;
  }
  #adminView .admin-logs-table th:nth-child(4),
  #adminView .admin-logs-table td:nth-child(4),
  #adminView .admin-logs-table th:nth-child(6),
  #adminView .admin-logs-table td:nth-child(6) {
    display: none;
  }
  .hero-metrics { display:none; }
  .dashboard-hero-grid { grid-template-columns:1fr; }
  #toastStack { bottom:76px; right:12px; }
  .metrics-form-grid { grid-template-columns:1fr; }
  .metrics-entry-grid { grid-template-columns:repeat(2, minmax(0, 1fr)); }
  .cardio-stats-panel { grid-template-columns: 1fr 1fr; }
  .profile-hero-stats { grid-template-columns: repeat(2,1fr); }
  .profile-stat-val { font-size:16px; }
  .progress-photo-thumb { width:80px; height:110px; }
  .upload-zones { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .checkin-details-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .checkin-details-photo-btn { flex-basis: min(32vw, 160px); }
  .checkin-compare-angle-controls { margin-left: 0; width: 100%; justify-content: flex-start; }
  .form-row-2 { grid-template-columns: 1fr; }
  .workout-time-row .workout-end-time-label { display: none; }
  /* cardio-distance-row stays 2-col so distance value + unit are always side by side */
  .set-row-inputs { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
  .set-row-wide { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
  .set-failure-wrap { grid-column: 1 / -1; }
  .set-estimate { text-align: center; min-width: 68px; }

  /* Leaderboard mobile */
  #leaderboardsView .workspace-grid { gap: 10px; }
  #leaderboardsView .card { padding: 10px; border-color: transparent; }
  #leaderboardsView .tabs { gap: 2px; padding: 2px; margin-bottom: 10px; }
  #leaderboardsView .tab { padding: 8px 6px; font-size: 11px; letter-spacing: -0.2px; }
  #leaderboardsView .tab.active { box-shadow: none; }
  /* Hide avatars in exercise table to free up horizontal space */
  #lbTable .member-avatar { display: none; }
  #leaderboardsView .lb-rel-tag { display: none; } /* hide friend tags to save space */
  /* Truncate long exercise names and member names to prevent overflow */
  #lbTable { table-layout: fixed; width: 100%; }
  #lbTable td:nth-child(1),
  #lbTable td:nth-child(2) { overflow: hidden; text-overflow: ellipsis; }
  #lbTable .lb-exercise-name { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; }
  #lbTable .lb-exercise-prefix { font-size: 10px; line-height: 1.2; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #lbTable .lb-exercise-main { line-height: 1.2; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #lbTable .leaderboard-member-btn { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  /* Match history tab behavior: allow leaderboard tables to shrink to viewport width */
  #leaderboardsView .table-wrap { border: 0; }
  #leaderboardsView .table-wrap table { min-width: 0; }
  /* Leaderboard table density tuned for narrow screens */
  #leaderboardsView .table-wrap table th,
  #leaderboardsView .table-wrap table td { padding: 6px 8px; font-size: 12px; }
  /* Hide date column in Biggest Loser on mobile to avoid horizontal overflow */
  #leaderboardsView #biggestLoserMonth th:nth-child(4),
  #leaderboardsView #biggestLoserMonth td:nth-child(4),
  #leaderboardsView #biggestLoserYear th:nth-child(4),
  #leaderboardsView #biggestLoserYear td:nth-child(4) { display: none; }
  /* 1000+ Leaders: hide individual lift columns, keep combined */
  #leaderboardsView #thousandPlusMount th:nth-child(4),
  #leaderboardsView #thousandPlusMount td:nth-child(4),
  #leaderboardsView #thousandPlusMount th:nth-child(5),
  #leaderboardsView #thousandPlusMount td:nth-child(5),
  #leaderboardsView #thousandPlusMount th:nth-child(6),
  #leaderboardsView #thousandPlusMount td:nth-child(6) { display: none; }
  /* Deep rankings: fix row selector and tighten padding; truncate member names */
  #deepLeaderboardContent > div > div { gap: 8px !important; padding: 6px !important; border: 0 !important; }
  #deepLeaderboardContent .leaderboard-member-btn { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .leaderboard-member-btn { font-size: 13px; }
  .rank-badge { width: 22px; height: 22px; font-size: 10px; }
  .member-avatar { width: 24px; height: 24px; font-size: 10px; }

  /* History: remove min-width so tables fit mobile viewport */
  .history-grid .table-wrap table,
  #historyDetailsBody .table-wrap table { min-width: 0; }

  /* History: hide Type column on mobile */
  .history-grid .table-wrap table th:nth-child(3),
  .history-grid .table-wrap table td:nth-child(3) { display: none; }

  /* History detail sets table: compact on mobile */
  #historyDetailsBody .table-wrap table th,
  #historyDetailsBody .table-wrap table td { padding: 6px 8px; font-size: 12px; }

  /* Log workout: category pills scroll horizontally instead of wrapping */
  .category-pills { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; padding-bottom: 4px; }
  .category-pills::-webkit-scrollbar { display: none; }
  .pill-btn { padding: 4px 8px; border-radius: 7px; }

  /* Log workout: compact type toggle buttons */
  .type-btn { padding: 10px 8px; font-size: 13px; }

  /* Log workout: compact e1RM banner */
  .e1rm-banner {
    padding: 10px 14px;
    margin: 6px 0 10px;
    display: grid;
    grid-template-columns: minmax(0, auto) minmax(0, 1fr);
    align-items: center;
    column-gap: 10px;
  }
  .e1rm-banner .eb-value { font-size: 20px; }
  .e1rm-banner .eb-focus-control { flex-direction: column; align-items: flex-start; gap: 4px; }
  .e1rm-banner .eb-talk { text-align: left; }

  /* Log workout: hide verbose cardio hint to save space */
  #cardioForm .hint { display: none; }

  /* Log workout: collapsible create-exercise row (hidden until toggled) */
  .log-create-wrap { display: none; }
  .log-create-wrap.open { display: block; }
  .log-create-toggle { display: block; font-size: 12px; padding: 4px 10px; margin-bottom: 8px; }

  /* Log workout: collapsible optional fields (notes/video, hidden until toggled) */
  .log-optional-fields-wrap { display: none; }
  .log-optional-fields-wrap.open { display: block; }
  .log-optional-toggle { display: block; margin-bottom: 4px; }
}

@media (min-width: 921px) and (max-width: 1100px) {
  .auth-container {
    grid-template-columns: minmax(0, 1fr) minmax(380px, 0.9fr);
  }
  .auth-hero,
  .auth-form-panel {
    padding: 36px 32px;
  }
}

@media (max-width: 640px) {
  .auth-stats { grid-template-columns:repeat(2,1fr); }
  .hero-value { font-size:36px; }
  .metric strong { font-size:24px; }
}

@media (max-width: 480px) {
  .upload-zones { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .checkin-details-grid { grid-template-columns: 1fr; }
  .checkin-details-photo-btn { flex-basis: min(40vw, 150px); }
  .initialized-upload-zones {
    grid-template-columns: repeat(3, minmax(0, 72px));
    overflow-x: auto;
    padding-bottom: 2px;
  }
}

@media (max-width: 380px) {
  .auth-stats { grid-template-columns: 1fr; }
}

/* ========================
   DESKTOP ENHANCEMENTS
   ======================== */

/* Desktop baseline (≥ 921px): fixes & layout improvements */
@media (min-width: 921px) {
  /* Keep all authenticated views — and the page header — at the same desktop width.
     Change --page-max-w in :root to resize every page at once. */
  

  /* Toast no longer needs to clear the mobile nav bar */
  #toastStack { bottom: 24px; right: 20px; }

  /* Log workout: create-exercise rows and optional fields always visible on desktop */
  .log-create-wrap { display: block; }
  .log-create-toggle { display: none; }
  .log-optional-fields-wrap { display: block; }
  .log-optional-toggle { display: none; }

  /* Cap progress photo upload zones so they don't stretch too tall on desktop */
  .upload-zones { max-width: 360px; }

  /* Progress photos: larger thumbnails on desktop */
  .progress-photo-thumb { width: 150px; height: 210px; }

  /* Profile hero: horizontal layout — avatar+name left, stats right */
  .profile-hero {
    flex-direction: row;
    align-items: center;
    padding: 24px 32px;
    gap: 28px;
  }
  .profile-hero-left { flex-shrink: 0; min-width: 180px; }
  .profile-hero-stats { flex: 1; }

  /* History: single-column layout */
  .history-grid { grid-template-columns: minmax(0, 1fr); }

  /* Leaderboard: exercise table wider, deep-rankings panel fixed */
  #leaderboardsView .workspace-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 380px); }
}

/* Large desktop ≥ 1280px */
@media (min-width: 1280px) {
  .main { padding: 28px 40px 80px; }
  .chart { height: 300px; }
  .dashboard-hero { padding: 32px 40px; }
  .workspace-grid { gap: 20px; }
  .metrics { gap: 14px; }
}

/* Extra-large desktop ≥ 1600px */
@media (min-width: 1600px) {
  .main { padding: 32px 48px 80px; }
  .chart { height: 320px; }
  .dashboard-hero { padding: 36px 48px; }
  .hero-value { font-size: 56px; letter-spacing: -2.5px; }
}

/* ─── 1000 Club ─────────────────────────────────────────────────── */
.thousand-club-modal { max-width: 520px; width: 100%; }
.tc-header { text-align: center; margin-bottom: 20px; }
.tc-trophy {
  font-size: 52px;
  line-height: 1;
  margin-bottom: 10px;
  filter: drop-shadow(0 0 16px rgba(245,158,11,0.5));
}
.tc-title {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 800;
  color: var(--gold, #F59E0B);
  letter-spacing: -0.5px;
}
.tc-subtitle { color: var(--text-2); font-size: 15px; margin: 0; }
.tc-subtitle strong { color: var(--brand); }
.video-link {
  color: var(--brand);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  padding: 3px 8px;
  border: 1px solid rgba(99,102,241,0.4);
  border-radius: 6px;
  transition: background 0.15s;
}
.video-link:hover { background: rgba(99,102,241,0.1); }
.tc-admin-notes {
  width: 100%;
  box-sizing: border-box;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
  color: var(--text-1);
  font-size: 12px;
}

/* === Activity Feed === */
.feed-shell {
  display: grid;
  gap: 12px;
}
.feed-topbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.feed-filters {
  display: grid;
  gap: 8px;
}
.feed-scope-tabs {
  margin-bottom: 0;
}
.feed-scope-tabs .tab {
  text-transform: capitalize;
}
.feed-scroll {
  display: grid;
  gap: 14px;
  max-height: none;
  overflow: visible;
  padding-right: 0;
}
.feed-day-group,
.feed-day-group-inner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}
.feed-day-group-header {
  display: block;
  list-style: none;
  font-weight: 700;
  color: var(--text-1);
  padding: 12px 14px;
}
.feed-day-group-body,
.feed-day-group-inner > .feed-day-group-body {
  display: grid;
  gap: 10px;
  padding: 0 10px 10px;
}
.feed-day-group--today {
  background: transparent;
  border: 0;
  border-radius: 0;
}
.feed-day-group--plain,
.feed-day-group-inner.feed-day-group--plain {
  background: transparent;
  border: 0;
  border-radius: 0;
}
.feed-day-group--today > .feed-day-group-header {
  color: var(--text-2);
  font-weight: 600;
  padding: 2px 2px 8px;
}
.feed-day-group--plain > .feed-day-group-header {
  color: var(--text-2);
  font-weight: 600;
  padding: 2px 2px 8px;
}
.feed-day-group--today > .feed-day-group-body {
  padding: 0;
}
.feed-day-group--plain > .feed-day-group-body {
  padding: 0;
}
.feed-session-duration {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  font-size: 12px;
  color: var(--text-2);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 3px 9px;
  background: var(--surface-2);
}
.feed-session-post {
  display: grid;
  gap: 10px;
}
.feed-session-exercises {
  display: grid;
  gap: 8px;
}
.feed-exercise-card {
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 8px 10px;
  background: var(--surface-2);
}
.feed-exercise-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
}
.feed-exercise-summary,
.feed-exercise-note {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--text-2);
}
.feed-exercise-note {
  color: var(--text-3);
}
.feed-card {
  scroll-snap-align: start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px;
}
@keyframes feed-card-pulse {
  0%   { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 25%, transparent); }
  60%  { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 25%, transparent); }
  100% { border-color: var(--border); box-shadow: none; }
}
.feed-card-linked {
  animation: feed-card-pulse 2.5s ease forwards;
}
.feed-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.feed-card-head > div:nth-child(2) {
  flex: 1;
  min-width: 0;
}
.feed-member {
  color: var(--text-1);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.feed-member-link {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font: inherit;
  text-align: left;
  transition: color var(--ease);
}
.feed-member-link:hover,
.feed-member-link:focus-visible {
  color: var(--brand);
}
.feed-meta {
  color: var(--text-3);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.feed-exercise-link {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.feed-exercise-link:hover {
  color: var(--text-1);
}
.feed-media {
  margin-top: 10px;
}
.feed-video {
  width: 100%;
  max-height: 60vh;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: #000;
}
.feed-video-embed {
  aspect-ratio: 16 / 9;
  height: auto;
}
.feed-video-short {
  aspect-ratio: 9 / 16;
  max-height: 70vh;
}
.feed-video-placeholder {
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  background: var(--surface-2);
}
.feed-body-placeholder {
  margin-top: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  color: var(--text-3);
  background: var(--surface-2);
  font-size: 12px;
}
.feed-body-photo-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.feed-body-photo {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: var(--surface-2);
  cursor: zoom-in;
}
.feed-photo-viewer-overlay { padding: 20px; }
.feed-photo-viewer-modal {
  max-width: min(96vw, 1200px);
  width: auto;
  padding: 0;
  background: rgba(0,0,0,0.92);
  border: 1px solid rgba(255,255,255,0.16);
}
.feed-photo-viewer-image {
  display: block;
  width: 100%;
  height: auto;
  max-width: min(96vw, 1200px);
  max-height: 90vh;
  object-fit: contain;
}
.feed-summary {
  margin-top: 10px;
  color: var(--text-2);
  font-size: 13px;
}
.feed-note {
  margin-top: 8px;
  color: var(--text-2);
  font-size: 13px;
}
.feed-note-present {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--brand);
  background: var(--brand-dim);
  color: var(--text-1);
}
.feed-note-label {
  font-weight: 700;
  color: var(--brand);
}
.feed-awards {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.feed-award-badge {
  cursor: pointer;
  box-shadow: none;
  filter: none;
  min-width: 34px;
  min-height: 34px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
}
.workout-details-modal {
  max-width: 460px;
  width: 100%;
}
.history-details-modal {
  max-width: 760px;
  max-height: min(86vh, 860px);
  overflow: auto;
}
.workout-details-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.workout-sets-table-wrap table {
  min-width: 0;
  width: 100%;
}

@media (max-width: 920px) {
  body.mobile-comment-compose-open {
    overflow: hidden;
  }
  .feed-shell {
    gap: 8px;
  }
  .feed-scroll {
    max-height: none;
    gap: 10px;
    padding-right: 0;
  }
  .feed-topbar {
    flex-direction: column;
    align-items: flex-start;
  }
  .feed-topbar .feed-scope-tabs {
    align-self: stretch;
  }
  .feed-topbar .feed-scope-tabs .tab {
    flex: 1;
  }
  .feed-filters {
    width: 100%;
  }
  .feed-day-group > summary,
  .feed-day-group-inner > summary {
    padding: 10px 0;
  }
  .feed-day-group-body,
  .feed-day-group-inner > .feed-day-group-body {
    gap: 8px;
    padding: 0 0 8px;
  }
  .feed-day-group,
  .feed-day-group-inner,
  .feed-card,
  .feed-exercise-card {
    border-left: 0;
    border-right: 0;
    border-radius: 0;
  }
  .feed-card {
    padding: 10px 0;
  }
  .feed-exercise-card {
    padding: 7px 0;
  }
  .feed-video {
    max-height: 45vw;
    min-height: 160px;
  }
  .feed-video-short {
    max-height: 72vw;
  }
  /* Prevent iOS auto-zoom on comment input focus */
  .comment-textarea { font-size: 16px; }
  /* Always show delete button on touch (no hover state) */
  .comment-delete-btn { opacity: 1; }
  .comment-item {
    transition: transform 0.18s ease;
    touch-action: pan-y;
  }
}

/* === Mobile Comment Tray === */
.comment-tray-backdrop {
  display: none;
}
@media (max-width: 920px) {
  .comment-tray-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 290;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    transition: opacity 0.22s ease;
  }
  .comment-tray-backdrop.is-visible {
    opacity: 1;
  }
  .comment-tray {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 300;
    background: var(--surface);
    border-top: 1px solid var(--border);
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.26s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .comment-tray.is-visible {
    transform: translateY(0);
  }
  .comment-tray-handle {
    width: 36px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 10px auto 0;
    flex-shrink: 0;
  }
  .comment-tray-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px 6px;
    flex-shrink: 0;
  }
  .comment-tray-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--hint);
    letter-spacing: 0.02em;
    text-transform: uppercase;
  }
  .comment-tray-close {
    background: none;
    border: none;
    font-size: 18px;
    line-height: 1;
    padding: 6px 8px;
    cursor: pointer;
    color: var(--hint);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .comment-tray-body {
    position: relative;
    padding: 4px 16px max(16px, env(safe-area-inset-bottom));
    flex: 1;
  }
  .comment-tray-compose-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
  }
  .comment-tray-textarea {
    width: auto;
    flex: 1;
    min-height: 44px;
    max-height: min(120px, calc(var(--tray-avail-h, 60vh) - 170px));
    resize: none;
    border: 1px solid var(--border);
    background: var(--surface-2);
    border-radius: var(--r-sm);
    font-size: 16px;
    line-height: 1.4;
    color: var(--text);
    outline: none;
    box-sizing: border-box;
    padding: 9px 10px;
    font-family: inherit;
  }
  .comment-tray-mention-dropdown {
    position: absolute;
    bottom: calc(100% + 4px);
    left: 16px;
    right: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    max-height: 200px;
    overflow-y: auto;
    z-index: 310;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.35);
  }
  .comment-tray-post-btn {
    min-height: 44px;
    padding: 0 16px;
    font-size: 14px;
    flex-shrink: 0;
  }
}
}

/* === Badge Earned Popup === */
.badge-popup-modal {
  max-width: 480px;
  width: 100%;
  text-align: center;
}
.badge-popup-header {
  margin-bottom: 20px;
}
.badge-popup-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}
.badge-popup-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 18px;
  border-radius: var(--r-md);
  min-width: 120px;
  max-width: 160px;
  text-align: center;
  animation: badgeCardIn 0.3s cubic-bezier(0.2,0,0.1,1) forwards;
}
@keyframes badgeCardIn {
  from { opacity:0; transform:scale(0.85) translateY(8px); }
  to   { opacity:1; transform:scale(1) translateY(0); }
}

/* ================================================================
   Activity Feed Interactions: Reactions, Comments, @Mentions
   ================================================================ */

/* Reaction bar */
.reaction-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.reaction-picker-wrap {
  position: relative;
  display: inline-flex;
}
.reaction-trigger-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  padding: 4px 8px;
  cursor: pointer;
  color: var(--text-3);
  transition: background var(--ease), border-color var(--ease), color var(--ease);
  line-height: 1;
}
.reaction-trigger-btn:hover,
.reaction-picker-wrap:hover .reaction-trigger-btn {
  background: var(--surface-3);
  border-color: var(--brand);
  color: var(--brand);
}
.reaction-picker-popup {
  display: none;
  position: absolute;
  bottom: calc(100% + 1px);
  left: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  padding: 4px 6px;
  gap: 2px;
  flex-direction: row;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
  white-space: nowrap;
  z-index: 10;
}
.reaction-picker-wrap:hover .reaction-picker-popup {
  display: flex;
}
.reaction-picker-wrap:focus-within .reaction-picker-popup {
  display: flex;
}
.reaction-picker-wrap.is-open .reaction-picker-popup {
  display: flex;
}
.reaction-btn {
  display: inline-flex;
  align-items: center;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--r-full);
  padding: 3px 7px;
  font-size: 18px;
  cursor: pointer;
  transition: background var(--ease), border-color var(--ease), transform var(--ease);
  line-height: 1;
}
.reaction-btn:hover {
  background: var(--surface-3);
  border-color: var(--brand);
  transform: scale(1.2);
}
.reaction-btn.active {
  background: var(--brand-dim);
  border-color: var(--brand);
}
.reaction-summary {
  font-size: 13px;
  color: var(--text-2);
  letter-spacing: 0.03em;
}

/* Feed card footer (comment button) */
.feed-card-footer {
  margin-top: 8px;
  border-top: 1px solid var(--border-subtle);
  padding-top: 8px;
}
.feed-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--r-sm);
  transition: color var(--ease), background var(--ease);
}
.feed-action-btn:hover {
  color: var(--text-1);
  background: var(--surface-2);
}

/* Comments section */
.comments-section {
  margin-top: 8px;
  border-top: 1px solid var(--border-subtle);
  padding-top: 8px;
}
.comments-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}
.comments-empty {
  padding: 6px 0;
}
.comment-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.comment-header {
  display: flex;
  align-items: center;
  gap: 7px;
}
.comment-meta {
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}
.comment-author {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: color var(--ease);
  text-decoration: none;
}
.comment-author:hover {
  color: var(--brand);
}
.comment-time {
  font-size: 11px;
  color: var(--text-3);
  white-space: nowrap;
}
.comment-reply-btn {
  font-size: 11px;
  font-weight: 700;
  color: var(--brand);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}
.comment-reply-btn:hover,
.comment-reply-btn:focus-visible {
  text-decoration: underline;
}
.comment-body {
  font-size: 13px;
  color: var(--text-2);
  margin: 0 0 0 33px;
  line-height: 1.5;
  word-break: break-word;
}
.comment-delete-btn {
  display: inline-flex;
  align-items: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-3);
  padding: 3px;
  border-radius: 4px;
  opacity: 0.55;
  transition: color var(--ease), opacity var(--ease);
  flex-shrink: 0;
}
.comment-item:hover .comment-delete-btn,
.comment-item:focus-within .comment-delete-btn {
  opacity: 1;
}
.comment-delete-btn:hover {
  color: var(--red);
}

/* @mention highlight */
.mention {
  color: var(--brand);
  font-weight: 600;
}
.mention-link {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--brand) 45%, transparent);
}
.mention-link:hover,
.mention-link:focus-visible {
  text-decoration-color: var(--brand);
}

/* Comment input area */
.comment-input-area {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}
.comment-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}
.comment-mention-wrap {
  flex: 1;
  position: relative;
  min-width: 0;
}
.comment-textarea {
  width: 100%;
  min-height: 44px;
  max-height: 120px;
  resize: none;
  border-radius: var(--r-sm);
  font-size: 14px;
  line-height: 1.4;
  overflow-y: auto;
  box-sizing: border-box;
  padding: 9px 10px;
}
.comment-post-btn {
  padding: 9px 14px;
  font-size: 14px;
  flex-shrink: 0;
}


/* @mention dropdown */
.mention-dropdown {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 50;
  overflow: hidden;
  max-height: 200px;
  overflow-y: auto;
}
.mention-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: none;
  border: none;
  padding: 8px 12px;
  cursor: pointer;
  color: var(--text-1);
  font-size: 13px;
  text-align: left;
  transition: background var(--ease);
}
.mention-item:hover {
  background: var(--surface-2);
}
.mention-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.mention-initials {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 10px;
  font-weight: 700;
}

/* History comments section */
.history-comments-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
}
.history-comments-header {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 10px;
}
.history-comments-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

/* === Onboarding Tour === */
.tour-overlay {
  position: fixed;
  inset: 0;
  z-index: 9990;
}

.tour-tooltip {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px 20px 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.55), 0 2px 8px rgba(0,0,0,0.35);
}

.tour-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.tour-progress {
  font-size: 11px;
  font-weight: 700;
  color: var(--brand);
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

.tour-skip {
  font-size: 12px !important;
  padding: 3px 8px !important;
  color: var(--text-3) !important;
  border-color: transparent !important;
}
.tour-skip:hover { color: var(--text-2) !important; }

.tour-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-1);
  margin: 0 0 8px;
  line-height: 1.3;
}

.tour-body {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.6;
  margin: 0 0 16px;
}

.tour-footer {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tour-footer-spacer { flex: 1; }

.tour-prev {
  font-size: 13px !important;
  padding: 6px 12px !important;
}

.tour-next {
  min-width: 72px;
}

/* Birthday confetti celebration */
.birthday-confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 9999;
  overflow: hidden;
}

.birthday-confetti-piece {
  position: absolute;
  top: -60px;
  animation: birthdayFall linear forwards;
  user-select: none;
  line-height: 1;
}

@keyframes birthdayFall {
  0% {
    transform: translateY(0) rotate(0deg) scale(1);
    opacity: 1;
  }
  80% {
    opacity: 1;
  }
  100% {
    transform: translateY(110vh) rotate(720deg) scale(0.6);
    opacity: 0;
  }
}

.birthday-toast {
  background: linear-gradient(135deg, #FF4500, #ff8c00) !important;
  font-weight: 700;
  font-size: 15px;
}

.feed-birthday-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0 6px;
  padding: 8px 12px;
  background: linear-gradient(135deg, rgba(255,69,0,0.15), rgba(255,140,0,0.12));
  border: 1px solid rgba(255,140,0,0.35);
  border-radius: 10px;
  font-weight: 700;
  font-size: 14px;
  color: #ff8c00;
}

.feed-birthday-banner-sub {
  font-weight: 400;
  font-size: 13px;
  color: #cfcfcf;
}

/* ─── Routines ─────────────────────────────────────────────────────────────── */

.routines-modal {
  max-width: 520px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
}

.routine-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.routine-list-info {
  flex: 1;
  min-width: 0;
}

.routine-list-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-1);
}

.routine-list-meta {
  font-size: 12px;
  margin-top: 2px;
}

.routine-list-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.routine-ex-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--surface-2);
  border-radius: 6px;
  font-size: 13px;
}

.routine-ex-name {
  font-weight: 500;
  color: var(--text-1);
}

/* Routine queue in session shell */

.routine-queue-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.routine-queue-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}

#routineQueue {
  margin-bottom: 12px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.routine-queue-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
}

.routine-queue-item:last-child {
  border-bottom: none;
}

.routine-queue-item-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.routine-queue-item-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-1);
}

/* ─── Rest Timer ───────────────────────────────────────────────────────────── */

.rest-timer-widget {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 14px;
}

.rest-timer-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.rest-timer-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.rest-timer-countdown {
  font-size: 28px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-1);
  min-width: 64px;
  text-align: center;
}

.rest-timer-countdown.rest-timer-running {
  color: var(--brand);
}

.rest-timer-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.rest-timer-select {
  height: 34px;
  padding: 0 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-1);
  font-size: 13px;
  cursor: pointer;
}

/* ─── Inline Rest Timer (inside exercise entry panel) ───────────────────────── */

.inline-rest-timer-wrap {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 10px 0 4px;
}

.inline-rest-timer-wrap .rest-timer-countdown {
  font-size: 22px;
  min-width: 52px;
}

/* ─── e1RM rep selector ──────────────────────────────────────────────────────── */

.eb-rep-selector {
  margin-top: 6px;
}

.eb-rep-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-2);
}

.eb-rep-select {
  height: 26px;
  padding: 0 6px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-1);
  font-size: 11px;
  cursor: pointer;
}

/* ─── Routine status badge ───────────────────────────────────────────────────── */

.routine-status-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  background: rgba(var(--brand-rgb, 99,102,241), 0.15);
  color: var(--brand);
  vertical-align: middle;
}

.routine-queue-item--done .routine-queue-item-name {
  color: var(--text-2);
  text-decoration: line-through;
  text-decoration-color: var(--text-3, var(--text-2));
}

.routine-done-check {
  color: var(--brand);
  font-style: normal;
}

/* ─── Set last session hint button ───────────────────────────────────────────── */

.set-last-session-btn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 11px;
  color: var(--brand);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.set-last-session-btn:hover {
  opacity: 0.75;
}

/* ─── Weight history modal ───────────────────────────────────────────────────── */

.wh-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-height: 340px;
  overflow-y: auto;
}

.wh-row {
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 12px;
  align-items: baseline;
}

.wh-row:last-child {
  border-bottom: none;
}

.wh-date {
  font-size: 12px;
  color: var(--text-2);
  white-space: nowrap;
  min-width: 100px;
}

.wh-sets {
  font-size: 13px;
  color: var(--text-1);
  flex: 1;
}

/* ═══════════════════════════════════════════════════════════════════════════
   APP-STYLE EXERCISE ENTRY (Titan-inspired redesign)
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Exercise entry header ──────────────────────────────────────────────── */

.ex-entry-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0 10px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 10px;
}

.ex-header-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  cursor: pointer;
  transition: background var(--ease), color var(--ease);
}

.ex-header-btn:hover {
  background: var(--surface-hover);
  color: var(--text-1);
}

.ex-header-confirm-btn {
  color: var(--brand);
  border-color: rgba(var(--brand-rgb), 0.4);
  background: var(--brand-dim);
  font-size: 16px;
  font-weight: 700;
}

.ex-header-confirm-btn:hover {
  background: rgba(var(--brand-rgb), 0.2);
}

.ex-header-center {
  flex: 1;
  min-width: 0;
  text-align: center;
}

.ex-header-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ex-header-change-btn {
  display: inline-block;
  margin-top: 3px;
  font-size: 11px;
  font-weight: 600;
  color: var(--brand);
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background var(--ease);
  letter-spacing: 0.2px;
}

.ex-header-change-btn:hover {
  background: var(--brand-dim);
}

/* ─── Compact type toggle ────────────────────────────────────────────────── */

.type-toggle-sm {
  margin: 0 0 12px;
  border-radius: var(--r-md);
  overflow: hidden;
  display: flex;
}

.type-toggle-sm .type-btn {
  flex: 1;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  border: none;
  background: var(--surface-2);
  color: var(--text-3);
  cursor: pointer;
  transition: background var(--ease), color var(--ease);
}

.type-toggle-sm .type-btn.active {
  background: var(--surface-3);
  color: var(--text-1);
}

/* ─── Session stats circles ──────────────────────────────────────────────── */

.ex-session-stats {
  display: flex;
  gap: 16px;
  margin: 10px 0 14px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
}

.ex-stats-col {
  flex: 1;
  min-width: 0;
}

.ex-stats-col-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 8px;
}

.ex-stats-circles {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.ex-stat-bubble {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  padding: 6px 8px;
  border-radius: 50px;
  border: 1.5px solid;
  text-align: center;
}

.ex-stat-past {
  border-color: rgba(245, 158, 11, 0.5);
  background: rgba(245, 158, 11, 0.06);
}

.ex-stat-current {
  border-color: rgba(96, 165, 250, 0.5);
  background: rgba(96, 165, 250, 0.06);
}

.ex-stat-val {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text-1);
}

.ex-stat-past .ex-stat-val { color: var(--gold); }
.ex-stat-current .ex-stat-val { color: #60A5FA; }

.ex-stat-key {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: var(--text-3);
  margin-top: 2px;
  text-transform: uppercase;
  white-space: nowrap;
}

/* ─── New-style set rows (NSR) ───────────────────────────────────────────── */

.set-row.nsr {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  margin-bottom: 6px;
  overflow: hidden;
  transition: border-color var(--ease);
}

.set-row.nsr.nsr-set-done {
  border-color: rgba(var(--brand-rgb), 0.35);
  background: rgba(var(--brand-rgb), 0.03);
}

.nsr-main {
  display: flex;
  align-items: stretch;
  gap: 0;
}

.nsr-num-col {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  flex-shrink: 0;
  background: var(--surface-3);
  border-right: 1px solid var(--border-subtle);
}

.nsr-num {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-2);
}

.nsr-body {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
}

.nsr-hint-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  min-height: 16px;
}

.nsr-e1rm {
  font-size: 11px;
  color: var(--text-3);
  white-space: nowrap;
}

.nsr-e1rm strong {
  color: var(--brand);
  font-size: 11px;
}

.nsr-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nsr-weight {
  width: 80px;
  flex-shrink: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-1);
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 5px 8px;
  text-align: center;
}

.nsr-weight:focus {
  border-color: var(--brand);
  outline: none;
}

.nsr-reps-stepper {
  display: flex;
  align-items: center;
  gap: 0;
  flex: 1;
  max-width: 140px;
}

.nsr-step-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-3);
  color: var(--text-1);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--ease);
  font-weight: 300;
}

.nsr-step-btn:hover {
  background: var(--surface-hover);
}

.nsr-reps-input {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-1);
  background: transparent;
  border: none;
  padding: 4px 4px;
}

.nsr-reps-input:focus {
  outline: none;
  background: var(--surface-3);
  border-radius: 4px;
}

.nsr-done-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text-3);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color var(--ease), background var(--ease), color var(--ease);
  margin-left: auto;
}

.nsr-done-btn:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.nsr-done-btn.nsr-done-active {
  border-color: var(--brand);
  background: var(--brand-dim);
  color: var(--brand);
  font-weight: 700;
}

/* ─── NSR set controls (+/- row) ────────────────────────────────────────── */

.nsr-set-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 8px 0 12px;
}

.nsr-ctrl-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-1);
  font-size: 20px;
  font-weight: 300;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--ease);
}

.nsr-ctrl-btn:hover {
  background: var(--surface-hover);
}

.nsr-ctrl-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-3);
}

/* ─── IRT (Inline Rest Timer) — preset-bubble style ─────────────────────── */

.irt-wrap {
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  padding: 12px 14px;
  margin: 4px 0 12px;
}

.irt-layout {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.irt-countdown {
  font-size: 30px;
  font-weight: 800;
  color: var(--text-1);
  font-variant-numeric: tabular-nums;
  min-width: 68px;
  letter-spacing: -1px;
}

.irt-countdown.rest-timer-running {
  color: var(--brand);
}

.irt-presets {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  flex: 1;
}

.irt-preset-btn {
  padding: 4px 10px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--ease), border-color var(--ease), color var(--ease);
}

.irt-preset-btn:hover {
  background: var(--surface-hover);
  color: var(--text-1);
}

.irt-preset-btn.irt-preset-active {
  border-color: rgba(var(--brand-rgb), 0.5);
  background: var(--brand-dim);
  color: var(--brand);
}

.irt-play-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--surface-3);
  color: var(--text-1);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--ease), border-color var(--ease);
  padding-left: 2px; /* optical centering of play icon */
}

.irt-play-btn:hover {
  background: var(--surface-hover);
  border-color: var(--brand);
}

.irt-done-btn {
  font-size: 12px;
  color: var(--text-3);
}

/* ─── Compact e1RM banner ────────────────────────────────────────────────── */

.e1rm-banner-compact {
  padding: 10px 14px;
  margin: 8px 0;
}

.e1rm-banner-compact .eb-value {
  font-size: 20px;
}

/* ─── NSR failure row (matches existing behaviour) ───────────────────────── */

.set-row.nsr .set-failure-row {
  padding: 4px 10px 8px 10px;
  border-top: 1px solid var(--border-subtle);
}

.set-row.nsr .set-failure-wrap,
.set-row.nsr .set-failure-rep-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ─── Hide old set-row styles when using NSR ────────────────────────────── */

.set-row.nsr .set-row-header,
.set-row.nsr .set-row-inputs {
  display: none;
}

/* ─── Games ──────────────────────────────────────────────────────────────── */

.games-hub { padding: 20px; max-width: 1000px; margin: 0 auto; }
.games-hub-head { margin-bottom: 24px; }
.games-hub-head h2 { margin: 0 0 8px 0; font-size: 24px; }
.games-hub-head .hint { margin: 0; }

.games-timer-row { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; }
.games-timer-row .hint { white-space: nowrap; }
.games-timer-row .pill-btn { padding: 6px 14px; font-size: 12px; }

.games-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.game-card { display: flex; flex-direction: column; gap: 12px; padding: 16px; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface-2); cursor: pointer; transition: all var(--ease); }
.game-card:hover { border-color: var(--brand); background: var(--surface-3); }
.game-card-emoji { font-size: 32px; text-align: center; }
.game-card-body { flex: 1; }
.game-card-name { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.game-card-best { font-size: 12px; color: var(--brand); margin-top: 6px; font-weight: 600; }

.games-bests { border-top: 1px solid var(--border); padding-top: 16px; margin-top: 16px; }
.games-bests-title { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--text-2); margin-bottom: 12px; }
.games-bests-list { display: grid; gap: 8px; }
.games-bests-row { display: flex; justify-content: space-between; padding: 10px; border-radius: var(--r-sm); background: var(--surface-2); font-size: 13px; }
.games-bests-row strong { color: var(--brand); }

.game-view { display: flex; flex-direction: column; gap: 12px; padding: 0; height: 100%; }
.game-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.game-header .game-back-btn { flex-shrink: 0; }
.game-header .game-title { flex: 1; font-weight: 600; text-align: center; }
.game-header div { font-size: 13px; white-space: nowrap; }

.game-canvas-wrap { position: relative; flex: 1; display: flex; align-items: center; justify-content: center; min-height: 300px; background: #000; border-radius: 0; overflow: hidden; }
.game-canvas { display: block; width: 100%; height: 100%; }

.game-timer-hud { position: absolute; top: 8px; right: 8px; display: flex; align-items: center; gap: 6px; padding: 8px 12px; background: rgba(0,0,0,0.6); border-radius: var(--r-md); color: white; font-size: 14px; font-weight: 600; border: 1px solid rgba(255,255,255,0.2); }
.game-timer-hud svg { width: 12px; height: 12px; }
.game-timer-display { font-family: 'Courier New', monospace; }
.gtimer-up { color: #ff6b6b; }

.game-hint { margin: 0; padding: 12px 16px; font-size: 12px; border-top: 1px solid var(--border); text-align: center; }

.game-dpad { display: flex; flex-direction: column; gap: 8px; align-items: center; padding: 16px; }
.game-dpad > div { display: flex; gap: 8px; }
.dpad-btn { width: 48px; height: 48px; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface-2); color: var(--text-1); font-size: 18px; cursor: pointer; transition: all var(--ease); }
.dpad-btn:active { background: var(--brand); border-color: var(--brand); color: white; }

@media (max-width: 768px) {
  .games-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .dpad-btn { width: 44px; height: 44px; font-size: 16px; }
}
