:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --purple: #7c3aed;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --nav-h: 56px;
  --bottom-h: 64px;
}

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

html, body {
  /* No rubber-band in standalone mode: with no Safari chrome to absorb it,
     the bounce drags the whole app — fixed bottom bar included — past the
     edge of the screen. */
  overscroll-behavior-y: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  /* Notched iPhones in standalone mode: lift content out of the
     status-bar / home-indicator areas. The viewport-fit=cover meta
     opts us into edge-to-edge; these insets restore safe spacing. */
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  /* Standalone-mode standalone styling cue (no Safari chrome to lean on) */
  background-color: var(--bg);
}

/* ── PWA install banner (5a) ───────────────────────────────────── */
#pwa-install-banner {
  display: none;
  position: fixed;
  left: 12px; right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 9999;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.18);
  padding: 12px 14px;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}
#pwa-install-banner.show { display: flex; }
#pwa-install-banner img { width: 36px; height: 36px; border-radius: 8px; }
#pwa-install-banner .pwa-msg { flex: 1; line-height: 1.35; }
#pwa-install-banner button {
  border: 0; padding: 8px 12px; border-radius: 8px;
  font-size: 14px; cursor: pointer;
  min-height: 36px;
}
#pwa-install-banner .pwa-install-btn {
  background: var(--primary); color: white;
}
#pwa-install-banner .pwa-dismiss-btn {
  background: transparent; color: var(--muted); padding: 8px;
}
#pwa-install-banner .pwa-ios-hint {
  font-size: 12px; color: var(--muted); margin-top: 4px;
}

/* Touch-target minimum on phones: keep tappable controls comfortable */
@media (max-width: 640px) {
  button, .nav-tab, .btn, input[type=submit], a.btn {
    min-height: 44px;
  }
  /* .modal-close gets a matching width override next to its own rule below —
     it has to come later in the sheet to win. */
}

/* ── Analytics (Phase 6) ─────────────────────────────────────── */
.analytics-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  position: relative;
}
.analytics-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.analytics-card-title {
  font-weight: 600;
  font-size: 15px;
}
.cal-stats {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--muted);
}
.cal-stats b { color: var(--text); font-weight: 600; }
.cal-heatmap-wrap { overflow-x: auto; padding-bottom: 4px; }
.cal-grid {
  display: grid;
  grid-template-rows: repeat(7, 14px);
  grid-auto-flow: column;
  gap: 3px;
}
.cal-cell {
  width: 14px; height: 14px;
  border-radius: 3px;
  background: #e2e8f0;
  cursor: pointer;
}
.cal-cell.c1 { background: #c6f6d5; }
.cal-cell.c2 { background: #68d391; }
.cal-cell.c3 { background: #2f855a; }
.cal-cell.c4 { background: #22543d; }
.cal-cell.future { background: transparent; cursor: default; }
.cal-tooltip {
  position: absolute;
  display: none;
  background: var(--text);
  color: white;
  font-size: 12px;
  padding: 6px 8px;
  border-radius: 6px;
  pointer-events: none;
  z-index: 100;
  white-space: nowrap;
  transform: translate(-50%, -100%);
  margin-top: -4px;
}
.cal-tooltip.show { display: block; }

/* 6b: movement frequency bars */
.mov-row {
  display: grid;
  grid-template-columns: 140px 1fr 50px 90px;
  gap: 8px;
  align-items: center;
  padding: 4px 0;
  font-size: 13px;
}
.mov-bar-track {
  background: var(--bg);
  border-radius: 3px;
  height: 14px;
  position: relative;
}
.mov-bar-fill {
  background: var(--primary);
  height: 100%;
  border-radius: 3px;
  transition: width 250ms ease-out;
}
.mov-name { color: var(--text); }
.mov-count { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.mov-stale { color: var(--amber); font-size: 11px; text-align: right; }
.mov-fresh { color: var(--muted); font-size: 11px; text-align: right; }
.mov-untouched { color: var(--red); font-size: 11px; text-align: right; font-weight: 600; }
.mov-toggle {
  margin-top: 12px;
  background: none; border: 0; color: var(--primary);
  font-size: 13px; cursor: pointer; padding: 4px 0;
}

/* 6d: benchmark list rows */
.bm-row {
  display: grid;
  grid-template-columns: 1fr 70px 90px 80px;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  background: var(--surface);
  cursor: pointer;
}
.bm-row:hover { border-color: var(--primary); }
.bm-row.open { border-color: var(--primary); }
.bm-title { font-weight: 600; }
.bm-meta { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bm-pill {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 600;
}
.bm-pill.pr     { background: #dcfce7; color: #166534; }
.bm-pill.plateau { background: #fef3c7; color: #92400e; }
.bm-pill.fresh   { background: #e0e7ff; color: #3730a3; }
.bm-chart {
  background: var(--bg);
  border-radius: 8px;
  padding: 8px;
  margin: -4px 0 12px 0;
  height: 240px;
}

/* 6e: body-part load rows */
.bpl-row {
  display: grid;
  grid-template-columns: 120px 1fr 60px;
  gap: 10px;
  align-items: center;
  padding: 5px 0;
  font-size: 13px;
}
.bpl-name { color: var(--text); }
.bpl-name.injured {
  border-left: 3px solid var(--red);
  padding-left: 6px;
  font-weight: 600;
}
.bpl-bar-track {
  background: var(--bg);
  border-radius: 3px;
  height: 14px;
  position: relative;
}
.bpl-bar-fill { height: 100%; border-radius: 3px; }
.bpl-bar-fill.ok    { background: #16a34a; }
.bpl-bar-fill.warn  { background: #d97706; }
.bpl-bar-fill.high  { background: #dc2626; }
.bpl-pct { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.bpl-untouched-note {
  margin-top: 12px;
  padding: 8px 12px;
  background: #fef3c7;
  border-radius: 6px;
  font-size: 12px;
  color: #92400e;
}

/* 6h: movement-pair table */
.mp-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.mp-table th, .mp-table td {
  padding: 6px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.mp-table th { color: var(--muted); font-weight: 600; font-size: 12px; }
.mp-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.mp-lift {
  display: inline-block; padding: 1px 6px; border-radius: 10px;
  font-size: 11px; font-weight: 600;
}
.mp-lift.strong { background: #dcfce7; color: #166534; }
.mp-lift.medium { background: #e0e7ff; color: #3730a3; }
.mp-lift.weak   { background: #f1f5f9; color: var(--muted); }

/* Backend connection indicator (top-right of the header) */
.conn-indicator {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #94a3b8;
  margin-right: 4px;
  flex-shrink: 0;
  transition: background 0.25s, box-shadow 0.25s;
}
.conn-indicator.online {
  background: #16a34a;
  box-shadow: 0 0 0 3px rgba(22,163,74,0.18);
}
.conn-indicator.offline {
  background: #dc2626;
  box-shadow: 0 0 0 3px rgba(220,38,38,0.18);
  animation: conn-pulse 1.6s ease-in-out infinite;
}
.conn-indicator.unknown { background: #94a3b8; }
@keyframes conn-pulse {
  0%,100% { opacity: 1; } 50% { opacity: 0.4; }
}

/* Refresh-progress strip shown under the two Studio refresh buttons */
.refresh-progress {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e3a8a;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  margin: 0 0 12px 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.refresh-progress.error {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}
.refresh-progress.done {
  background: #ecfdf5;
  border-color: #bbf7d0;
  color: #065f46;
}
.refresh-progress .rp-spinner {
  width: 12px; height: 12px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: rp-spin 0.8s linear infinite;
}
.refresh-progress.done .rp-spinner,
.refresh-progress.error .rp-spinner { display: none; }
@keyframes rp-spin { to { transform: rotate(360deg); } }

/* ── Offline indicator (5b) ──────────────────────────────────── */
#pwa-offline-bar {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 10000;
  background: var(--amber);
  color: white;
  text-align: center;
  font-size: 13px;
  padding: 6px 12px;
  padding-top: calc(6px + env(safe-area-inset-top));
}
body.is-offline #pwa-offline-bar { display: block; }

/* ── Login ───────────────────────────────────────────────────── */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,.12);
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
}

.login-logo {
  font-size: 32px;
  text-align: center;
  margin-bottom: 4px;
}

.login-title {
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 4px;
}

.login-sub {
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  margin-bottom: 28px;
}

.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  outline: none;
  transition: border-color .15s;
}

.form-control:focus { border-color: var(--primary); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
  text-decoration: none;
}

.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--green); color: #fff; }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-full { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

.error-msg {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: var(--red);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 12px;
  display: none;
}

/* ── App shell ───────────────────────────────────────────────── */
#app { display: none; min-height: 100vh; }

header {
  position: sticky;
  top: 0;
  z-index: 100;
  /* Pinned to the visual viewport while pinch-zoomed — see pinChrome(). */
  transform-origin: 0 0;
  height: var(--nav-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
}

.header-logo { font-size: 22px; font-weight: 800; color: var(--primary); }
.header-logo span { color: var(--text); font-weight: 400; font-size: 16px; margin-left: 4px; }

.header-nav {
  display: flex;
  gap: 4px;
  flex: 1;
}

.nav-tab {
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  color: var(--muted);
  border: none;
  background: none;
  transition: background .15s, color .15s;
  white-space: nowrap;
}

.nav-tab:hover { background: var(--bg); color: var(--text); }
.nav-tab.active { background: var(--primary); color: #fff; }

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.user-badge {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

/* Bottom nav (mobile) */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  /* box-sizing is border-box globally, so a fixed height here would let the
     home-indicator inset eat the bar's content box and clip the labels.
     Keep the content row at --bottom-h and add the inset underneath it. */
  min-height: var(--bottom-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 100;
  padding: 0 2px env(safe-area-inset-bottom);
  /* The bar has no scrollable content — but a drag that *starts* on a fixed
     element is still handed to the document, so on iOS the page slides and
     rubber-bands under your thumb and the bar looks like it is scrolling.
     touch-action:none makes a touch here a tap and nothing else. */
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  /* Bottom-left, so cancelling the zoom keeps the bar on the bottom edge
     rather than shrinking it towards the middle — see pinChrome(). */
  transform-origin: 0 100%;
}

.bottom-nav-inner {
  display: flex;
  width: 100%;
  height: var(--bottom-h);
  /* Structural guarantee, not just an arithmetic one: a longer label in a
     future section can never turn the bar into a scroller. */
  overflow: hidden;
}

.bottom-tab {
  /* All tabs share the width evenly — the bar must never scroll */
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  border: none;
  background: none;
  color: var(--muted);
  font-weight: 500;
  transition: color .15s;
  padding: 4px 1px;
}

.bottom-tab .icon { font-size: 21px; line-height: 1.15; }
.bottom-tab .lab {
  /* Five tabs, so the label can be legible again — it was 9px when ten of
     them had to share a phone's width. */
  font-size: 11px;
  line-height: 1.15;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bottom-tab.active { color: var(--primary); }

@media (max-width: 640px) {
  .rec-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  .rec-hist-note { display: none; }
  .today-card { padding: 16px; }
  .today-strip { gap: 8px; }
  .today-stat-v { font-size: 20px; }
  .today-row { flex-direction: column; gap: 0; }
  .header-nav { display: none; }
  .bottom-nav { display: flex; }
  #app { padding-bottom: calc(var(--bottom-h) + env(safe-area-inset-bottom)); }
  .user-badge { display: none; }
}

/* ── Section sub-navigation (segments inside a destination) ──── */
.section-seg {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
/* Same pill as .seg-opt, but driven by a class instead of a radio, because
   these are buttons that navigate rather than inputs that hold state. */
.seg-opt.seg-on {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  font-weight: 600;
}
.section-seg .seg-opt { background: var(--surface); }
.section-seg .seg-opt.seg-on { background: var(--primary); }

/* ── More: a drill-down list, the way a phone settings screen reads ── */
.more-list {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.more-row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 16px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: none;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  transition: background .12s;
}
.more-row:last-child { border-bottom: none; }
.more-row:hover { background: var(--bg); }
.more-icon { font-size: 20px; flex-shrink: 0; }
.more-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.more-label { font-size: 15px; font-weight: 600; }
.more-hint { font-size: 12px; color: var(--muted); }
.more-chevron { color: var(--muted); font-size: 20px; flex-shrink: 0; }

/* ── Today ───────────────────────────────────────────────────── */
.today-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 14px;
}
.today-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.today-head-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.today-when { font-size: 19px; font-weight: 700; }
.today-stale {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
}
.today-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.today-others { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.today-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}
.today-chip:hover { border-color: var(--primary); }

.today-strip {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}
.today-stat {
  flex: 1;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 10px;
  text-align: center;
  min-width: 0;
}
.today-stat-v { display: block; font-size: 24px; font-weight: 800; color: var(--primary); }
.today-stat-l { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }

.today-row { display: flex; gap: 14px; flex-wrap: wrap; }
.today-row .today-card { flex: 1 1 240px; margin-bottom: 14px; }
.today-card-head {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: 8px;
}
.today-next-body { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.today-next-when { font-size: 15px; font-weight: 700; }
.today-next-name { font-size: 15px; }
.today-next-who { font-size: 13px; color: var(--muted); }

/* ── Records ─────────────────────────────────────────────────── */
.rec-group { margin-bottom: 22px; }
.rec-group-head {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: 10px;
}
.rec-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.rec-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  text-align: left;
  cursor: pointer;
  color: var(--text);
  transition: border-color .12s;
}
.rec-card:hover { border-color: var(--primary); }
.rec-card-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.rec-card-value { font-size: 24px; font-weight: 800; color: var(--primary); margin: 4px 0 2px; }
.rec-card-meta { font-size: 11px; color: var(--muted); }
.rec-card-e1rm { font-size: 11px; color: var(--muted); margin-top: 4px; font-style: italic; }

.rec-hist { display: flex; flex-direction: column; gap: 2px; }
.rec-hist-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.rec-hist-row:last-child { border-bottom: none; }
.rec-hist-val { font-weight: 700; min-width: 72px; }
.rec-hist-date { color: var(--muted); font-size: 13px; }
.rec-hist-note { color: var(--muted); font-size: 12px; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.rec-club-note {
  font-size: 13px;
  color: var(--muted);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 16px;
}
.rec-club-event {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  margin-bottom: 10px;
}
.rec-club-label { font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.rec-club-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 6px 0;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}
.rec-club-row:last-child { border-bottom: none; }
.rec-club-row.is-me { font-weight: 700; color: var(--primary); }
.rec-club-rank { width: 18px; color: var(--muted); font-size: 12px; flex-shrink: 0; }
.rec-club-name { flex: 1; min-width: 0; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.rec-club-val { font-weight: 700; }
.rec-club-date { color: var(--muted); font-size: 12px; flex-shrink: 0; }

/* The one-tap capture from the day's class — the whole feature lives or dies
   on this being easier than opening a form. */
.today-pr-prompt {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  padding: 9px 14px;
  font-size: 14px;
  font-weight: 600;
  border: 1.5px dashed var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}
.today-pr-prompt:hover { border-color: var(--primary); color: var(--primary); }

/* ── "New version available" bar ─────────────────────────────── */
.update-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--bottom-h) + env(safe-area-inset-bottom) + 12px);
  z-index: 300;                 /* above modals: it is about the whole page */
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: 0 4px 16px rgba(0,0,0,.16);
  padding: 8px 10px 8px 16px;
  max-width: calc(100vw - 24px);
}
.update-bar-text { font-size: 14px; white-space: nowrap; }
@media (max-width: 640px) {
  .update-bar-text { white-space: normal; font-size: 13px; }
}

/* ── Source badge ────────────────────────────────────────────── */
.source-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
}

/* ── Main content ────────────────────────────────────────────── */
main { max-width: 1100px; margin: 0 auto; padding: 24px 16px; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  border-radius: var(--radius);
  padding: 18px 16px;
  color: #fff;
  text-align: center;
}

.stat-card .stat-value { font-size: 28px; font-weight: 700; }
.stat-card .stat-label { font-size: 12px; opacity: .85; margin-top: 2px; }
.stat-blue { background: var(--primary); }
.stat-green { background: var(--green); }
.stat-amber { background: var(--amber); }
.stat-purple { background: var(--purple); }

.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 700px) { .chart-grid { grid-template-columns: 1fr; } }

.chart-box {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.chart-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* ── Workout cards ───────────────────────────────────────────── */
.workout-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  margin-bottom: 10px;
  border-left: 4px solid var(--border);
  cursor: pointer;
  transition: box-shadow .15s, transform .1s;
}

.workout-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.12); transform: translateY(-1px); }
.workout-card.track-wod { border-left-color: var(--primary); }
.workout-card.track-hyrox { border-left-color: var(--green); }
.workout-card.track-special { border-left-color: var(--amber); }

.workout-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.workout-date { font-size: 13px; font-weight: 600; color: var(--text); }
.workout-day { font-size: 12px; color: var(--muted); }

.track-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  margin-left: auto;
  flex-shrink: 0;
}

.badge-wod { background: #dbeafe; color: var(--primary); }
.badge-hyrox { background: #dcfce7; color: var(--green); }
.badge-special { background: #fef3c7; color: var(--amber); }
.badge-generator { background: #ede9fe; color: #7c3aed; }

/* ── Planner ─────────────────────────────────────────────── */
.planner-controls { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.planner-meta { font-size: 12px; color: var(--muted); }
.planner-checks { display: flex; gap: 6px; flex-wrap: wrap; }
.check-chip {
  padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  cursor: default;
}
.check-chip.ok { background: #dcfce7; color: var(--green); }
.check-chip.fail { background: #fee2e2; color: #dc2626; }
.planner-day {
  border: 1px solid var(--border); border-radius: 12px; background: var(--card);
  padding: 14px 16px; margin-bottom: 10px;
}
.planner-day-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; margin-bottom: 6px; }
.planner-day-title { font-weight: 700; font-size: 14px; }
.planner-day-fmt { font-size: 12px; color: var(--muted); }
.planner-item { font-size: 13px; padding: 2px 0; }
.planner-item .scaling { color: var(--muted); font-size: 12px; }
.planner-note { font-size: 12.5px; color: var(--muted); margin-top: 6px; white-space: pre-wrap; }
.planner-extra { font-size: 12.5px; margin-top: 8px; white-space: pre-wrap;
  border-top: 1px dashed var(--border); padding-top: 8px; }
.sev-badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; }
.sev-hoch { background: #fee2e2; color: #dc2626; }
.sev-mittel { background: #fef3c7; color: var(--amber); }
.sev-niedrig { background: #e5e7eb; color: var(--muted); }
.planner-finding { border-left: 3px solid var(--border); padding: 6px 10px; margin-bottom: 8px; font-size: 13px; }
.planner-settings-head { display: flex; justify-content: space-between; cursor: pointer; user-select: none; }
.planner-approved { opacity: .75; pointer-events: none; }
.planner-chat-history { max-height: 300px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.chat-msg { display: flex; }
.chat-msg.user { justify-content: flex-end; }
.chat-msg .bubble {
  max-width: 85%; padding: 8px 12px; border-radius: 12px; font-size: 13px;
  white-space: pre-wrap; background: var(--bg); border: 1px solid var(--border);
}
.chat-msg.user .bubble { background: var(--primary); color: #fff; border: none; }
.chat-note { margin-top: 6px; font-size: 12px; opacity: .85;
  border-top: 1px dashed currentColor; padding-top: 4px; }

.workout-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.workout-desc {
  font-size: 13px;
  color: var(--muted);
  white-space: pre-wrap;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.fav-btn {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  transition: transform .15s;
  line-height: 1;
  flex-shrink: 0;
  margin-left: 6px;
  color: var(--muted);
}
.fav-btn:hover { transform: scale(1.25); }
.fav-btn.active { color: #f59e0b; }

/* ── Day grouping in Browse ──────────────────────────────────── */
.day-group { margin-bottom: 20px; }
.day-label {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

/* ── Filters ─────────────────────────────────────────────────── */
.filter-bar {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}

.filter-group { display: flex; flex-direction: column; gap: 4px; min-width: 120px; }
.filter-group label { font-size: 12px; font-weight: 600; color: var(--muted); }

.filter-input {
  padding: 7px 10px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  background: var(--surface);
  transition: border-color .15s;
}
.filter-input:focus { border-color: var(--primary); }
.filter-input.wide { min-width: 220px; }

.filter-actions { display: flex; gap: 8px; align-items: flex-end; }

/* ── Mobile reflow (Phase D) ───────────────────────────────── */
@media (max-width: 640px) {
  main { padding: 16px 12px; }
  /* Filter bars stack, controls go full-width */
  .filter-bar { flex-direction: column; align-items: stretch; gap: 10px; }
  .filter-group { width: 100%; min-width: 0; }
  .filter-input, .filter-input.wide { width: 100%; min-width: 0; }
  .filter-actions { width: 100%; }
  .filter-actions .btn { flex: 1; }
  /* View/segment + week-nav rows wrap cleanly */
  .studio-view-bar, .coverage-bar { flex-wrap: wrap; gap: 10px; }
  .week-nav { width: 100%; }
  .week-nav select { flex: 1; }
  /* Wide tables scroll instead of overflowing the page */
  .user-table, .sched-runs table { display: block; overflow-x: auto; white-space: nowrap; }
  /* Modal fills the small screen */
  .modal { max-width: 100%; max-height: 92vh; padding: 18px 16px; }
  /* Scheduler builder: inputs don't get squished */
  [data-job] .sched-time, [data-job] .sched-n { max-width: 100%; }
  /* Header actions never overflow */
  .header-right { gap: 6px; flex-wrap: nowrap; }
  /* Bottom nav never scrolls: tabs share the width and use short labels.
     (overflow-x:auto here also made the bar scroll *vertically*, because a
     visible cross-axis computes to auto — that hid the labels entirely.) */
}

/* Tight variant used by the bookings filter so Sort + Show + From + To +
   Include-past + buttons all fit on one row on a desktop viewport. */
.bookings-filter-bar .filter-group.narrow { min-width: 0; }
.bookings-filter-bar .filter-group.narrow .filter-input { min-width: 90px; }

/* ── Movement chips ──────────────────────────────────────────── */
.movement-bar {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  margin-bottom: 16px;
}
.movement-bar-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.movement-bar-head label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.match-toggle { display: flex; gap: 12px; font-size: 13px; }
.match-opt { display: flex; align-items: center; gap: 4px; cursor: pointer; color: var(--muted); }
.match-opt input { accent-color: var(--primary); }

.movement-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 5px 11px;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  transition: all .12s;
  color: var(--muted);
}
.chip:hover { border-color: var(--primary); color: var(--text); }
.chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  font-weight: 600;
}

/* ── Injury profile ──────────────────────────────────────────── */

.injury-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  padding: 8px 14px;
  margin: 0 16px 12px;
  border-radius: 10px;
  font-size: 13px;
}
.banner-icon { font-size: 16px; }
.banner-text { flex: 1; font-weight: 500; }
.injury-banner.hide-mode { background: #fee2e2; border-color: #fca5a5; }

.injury-modal { max-width: 560px; }
.injury-section { margin-top: 16px; }
.injury-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 8px;
}
.injury-mode-row { display: flex; flex-direction: column; gap: 8px; }
.mode-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color .12s;
}
.mode-opt:hover { border-color: var(--primary); }
.mode-opt input { accent-color: var(--primary); }
.mode-opt span { font-weight: 600; }
.mode-opt em { font-style: normal; color: var(--muted); font-size: 12px; }
.mode-opt:has(input:checked) {
  background: #eff6ff;
  border-color: var(--primary);
}
.injury-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* ── Workout log / PR tracker ────────────────────────────────── */
.log-entry {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  margin-bottom: 10px;
  border-left: 4px solid var(--green);
}
.log-entry-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.log-entry-title { font-weight: 600; font-size: 15px; flex: 1; }
.log-entry-score {
  font-weight: 700;
  font-size: 16px;
  color: var(--primary);
  white-space: nowrap;
}
.log-entry-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}
.log-entry-notes {
  font-size: 13px;
  color: var(--text);
  margin-top: 6px;
  white-space: pre-wrap;
}
.log-entry-notes .md-table-wrap { overflow-x: auto; margin: 6px 0; }
.md-table { border-collapse: collapse; font-size: 12px; white-space: normal; }
.md-table th, .md-table td {
  border: 1px solid var(--border); padding: 3px 8px; text-align: left; white-space: nowrap;
}
.md-table th { background: var(--bg); font-weight: 700; }
#log-notes-preview { font-size: 13px; }
#log-notes-preview .md-table-wrap { overflow-x: auto; margin: 6px 0; }
.md-toggle {
  display: inline-flex; border: 1px solid var(--border); border-radius: 6px;
  overflow: hidden; background: var(--bg);
}
.md-toggle .md-tab {
  border: 0; background: transparent; color: var(--muted);
  font: inherit; font-size: 11px; font-weight: 600; padding: 3px 10px; cursor: pointer;
}
.md-toggle .md-tab + .md-tab { border-left: 1px solid var(--border); }
.md-toggle .md-tab.active { background: var(--accent, #2563eb); color: #fff; }

/* iOS-style on/off switch — used for every Settings toggle. The real
   checkbox stays in the DOM (hidden) so keyboard focus, :checked and the
   existing onchange handlers keep working unchanged. */
.switch {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
  width: 44px;
  height: 26px;
}
.switch input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}
.switch .slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 999px;
  transition: background .2s ease;
  pointer-events: none;
}
.switch .slider::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
  transition: transform .2s ease;
}
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider::before { transform: translateX(18px); }
.switch input:focus-visible + .slider { box-shadow: 0 0 0 3px rgba(37, 99, 235, .35); }
.switch input:disabled { cursor: default; }
.switch input:disabled + .slider { opacity: .5; }
@media (prefers-reduced-motion: reduce) {
  .switch .slider, .switch .slider::before { transition: none; }
}

/* Class leaderboard table */
.lb-group-label { font-size: 12px; font-weight: 700; color: var(--muted); margin: 10px 0 4px; }
.lb-table td.lb-rank { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.lb-table tr.lb-me td { background: rgba(37, 99, 235, 0.14); font-weight: 700; }
.lb-table tr.lb-me td.lb-rank { color: var(--accent, #2563eb); }
.log-entry-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.scale-badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
}
.scale-badge.rx { background: #dcfce7; color: #15803d; border-color: #bbf7d0; }
.scale-badge.rxp { background: #fef3c7; color: #92400e; border-color: #fde68a; }

.log-form {
  background: var(--bg);
  border-radius: 10px;
  padding: 12px 14px;
  margin-top: 12px;
}
.log-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}
.log-form-row.single { grid-template-columns: 1fr; }
.log-form .form-control { width: 100%; box-sizing: border-box; }
.log-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin: 18px 0 8px;
}

.pr-chart { height: 200px; margin-top: 8px; }

/* ── Studio classes (eversports mirror) ─────────────────────── */
.studio-day {
  margin-bottom: 18px;
}
.studio-day-head {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
  padding: 4px 0;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.studio-class {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-left: 4px solid var(--green);
}
.studio-class.full { border-left-color: var(--muted); opacity: 0.7; }
.studio-class.cancelled { border-left-color: var(--muted); opacity: 0.6; }
.studio-class.cancelled .studio-class-name,
.studio-class.cancelled .studio-class-time { text-decoration: line-through; }
.studio-cap.cancelled-tag {
  background: var(--bg);
  color: var(--muted);
  font-weight: 600;
}
.studio-class.clickable, .studio-grid-class.clickable { cursor: pointer; }
.studio-class.clickable:hover { box-shadow: 0 0 0 2px var(--accent, #2563eb) inset; }
.studio-grid-class.clickable:hover { filter: brightness(1.05); }
.studio-class-time {
  font-weight: 700;
  font-size: 15px;
  min-width: 80px;
  color: var(--primary);
}
.studio-class-body { flex: 1; min-width: 0; }
.studio-class-name { font-weight: 600; font-size: 15px; }
.studio-class-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}
.studio-cap {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.studio-cap.open { background: #dcfce7; color: #15803d; }
.studio-cap.full { background: #fee2e2; color: #991b1b; }
.studio-cap.few  { background: #fef3c7; color: #92400e; }

/* "Booked" marker — distinct green border + small pill in the title */
.studio-class.booked {
  background: linear-gradient(to right, #ecfdf5, var(--surface) 40%);
  border-left-color: #15803d !important;
}
.booked-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
  margin-left: 6px;
  vertical-align: middle;
}
.studio-grid-class.booked {
  background: #ecfdf5 !important;
  border-left-color: #15803d !important;
  box-shadow: inset 0 0 0 1px #bbf7d0;
}

/* Agent / subscription status dot — used in both list and grid views */
.sub-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  vertical-align: middle;
  margin-left: 6px;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
}
.sub-dot.active   { background: #15803d; }
.sub-dot.paused   { background: #9ca3af; }
.sub-dot.error    { background: #ef4444; }
.sub-dot.skipped  { background: #ffffff; border: 1px solid #cbd5e1; }
.sub-dot--inline  { width: 8px; height: 8px; }

/* ── Account banner (eversports) ────────────────────────────── */
.account-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 12px;
}
.account-banner.error  { background: #fef2f2; border-color: #fecaca; }
.account-banner.connected { background: #ecfdf5; border-color: #bbf7d0; }
.account-banner.no-key { background: #fef3c7; border-color: #fde68a; }
.account-icon { font-size: 18px; }
.account-text { flex: 1; font-size: 13px; line-height: 1.35; }
.account-actions { display: flex; gap: 6px; }

/* ── Studio grid view ───────────────────────────────────────── */
.studio-view-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 8px 14px;
  margin-bottom: 12px;
}
.studio-week-nav { display: flex; align-items: center; gap: 8px; }

.studio-grid-wrap {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 6px;
  overflow-x: auto;
}
.studio-grid {
  display: grid;
  /* time column + 7 day columns */
  grid-template-columns: 64px repeat(7, minmax(140px, 1fr));
  gap: 2px;
  min-width: 800px;       /* enables horizontal scroll on small screens */
}
.studio-grid-cell {
  background: var(--bg);
  border-radius: 6px;
  padding: 4px;
  min-height: 38px;
  font-size: 12px;
}
.studio-grid-head {
  position: sticky;
  top: 0;
  background: var(--surface);
  font-weight: 700;
  text-align: center;
  padding: 8px 4px;
  z-index: 2;
  border-bottom: 2px solid var(--border);
  font-size: 13px;
}
.studio-grid-head.today { color: var(--primary); }
.studio-grid-time {
  background: var(--surface);
  text-align: right;
  padding: 4px 8px;
  font-weight: 600;
  font-size: 12px;
  color: var(--muted);
  align-self: start;
  position: sticky;
  left: 0;
  z-index: 1;
}
.studio-grid-class {
  background: #dcfce7;
  border-left: 3px solid var(--green);
  border-radius: 4px;
  padding: 4px 6px;
  margin-bottom: 6px;
  font-size: 11px;
  line-height: 1.25;
  cursor: default;
}
.studio-grid-class:last-child { margin-bottom: 0; }
.studio-grid-class.full {
  background: #fee2e2;
  border-left-color: #ef4444;
  opacity: 0.75;
}
.studio-grid-class.few {
  background: #fef3c7;
  border-left-color: #f59e0b;
}
.studio-grid-class .gc-name { font-weight: 600; }
.studio-grid-class .gc-meta { color: var(--muted); font-size: 10px; }
.studio-grid-class .gc-preview {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.3;
  margin-top: 3px;
  white-space: pre-line;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 7;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-height: 9.1em;          /* 7 lines × 1.3 line-height */
}
@media (max-width: 720px) {
  .studio-grid { grid-template-columns: 56px repeat(7, minmax(110px, 1fr)); }
  .studio-grid-head, .studio-grid-time { font-size: 11px; padding: 4px; }
}

/* ── Coverage controls ───────────────────────────────────────── */
.coverage-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 16px;
  margin-bottom: 12px;
}
.coverage-source { display: flex; gap: 4px; }
.seg-opt {
  padding: 6px 14px;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  color: var(--muted);
  user-select: none;
  transition: all .12s;
}
.seg-opt input { display: none; }
.seg-opt:hover { border-color: var(--primary); }
.seg-opt:has(input:checked) {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  font-weight: 600;
}

.coverage-slider {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 240px;
  max-width: 420px;
}
.coverage-slider label {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}
.coverage-slider input[type="range"] {
  flex: 1;
  accent-color: var(--primary);
}
#cov-weeks-label { color: var(--primary); font-weight: 700; }
@media (max-width: 640px) {
  .coverage-bar { flex-direction: column; align-items: stretch; }
  .coverage-slider { max-width: none; }
}

.coverage-chip-bar {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 14px;
  margin-bottom: 12px;
}
.coverage-chip-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.cov-chip-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-right: 4px;
}

/* Workout-card injury badge */
.affected-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  margin-left: 6px;
}

/* ── Week selector ───────────────────────────────────────────── */
.week-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.week-nav select {
  flex: 1;
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
}

/* ── Pagination ──────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
}

.page-info { font-size: 13px; color: var(--muted); }

/* ── Scrape panel ────────────────────────────────────────────── */
.scrape-form {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.scrape-form h3 { font-size: 16px; font-weight: 700; margin-bottom: 16px; }

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
}

.form-row .form-group { flex: 1; min-width: 140px; margin-bottom: 0; }

.checkboxes { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  cursor: pointer;
}

.checkbox-item input { width: 16px; height: 16px; cursor: pointer; }

.scrape-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg);
  border-radius: 8px;
  margin-bottom: 14px;
  font-size: 14px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}

.status-dot.running {
  background: var(--green);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}

.log-box {
  background: #0f172a;
  color: #94a3b8;
  border-radius: 8px;
  padding: 14px;
  font-family: "JetBrains Mono", "Fira Mono", monospace;
  font-size: 12px;
  line-height: 1.6;
  height: 360px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.log-box .log-line-done { color: #4ade80; }
.log-box .log-line-err { color: #f87171; }
.log-box .log-line-warn { color: #fbbf24; }

/* ── Admin panel ─────────────────────────────────────────────── */
.user-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.user-table th, .user-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.user-table th { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; }

.role-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
}
.role-admin { background: #ede9fe; color: var(--purple); }
.role-user  { background: var(--bg); color: var(--muted); }

/* ── Modal ───────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px;
  overflow-y: auto;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 24px 80px rgba(0,0,0,.2);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  margin: auto;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.modal-header-text { flex: 1; min-width: 0; }

.modal-close {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  color: var(--muted);
  transition: background .15s;
  margin-top: 2px;
}
.modal-close:hover { background: var(--border); }
/* On phones the global 44px touch-target minimum stretches this 32px box
   into an oval, so grow the width to match and keep the circle. */
@media (max-width: 640px) {
  .modal-close { width: 44px; height: 44px; font-size: 16px; }
}

.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.modal-meta { font-size: 13px; color: var(--muted); margin-bottom: 0; }
.source-row {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.source-row:last-child { border-bottom: 0; }
.source-main { flex: 1; min-width: 0; }
.source-title {
  font-size: 14px; font-weight: 600; margin-bottom: 3px;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.source-off .source-main { opacity: .55; }
.source-actions { display: flex; gap: 4px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.src-tag {
  font-size: 11px; font-weight: 500; padding: 1px 7px; border-radius: 10px;
  background: var(--bg-alt, rgba(127,127,127,.15)); color: var(--muted);
}
.src-tag-ok { color: var(--green, #2e9e5b); }
/* Below the phone breakpoint the actions wrap under the text rather than
   squeezing the label into a two-character column. */
@media (max-width: 560px) {
  .source-row { flex-direction: column; gap: 6px; }
  .source-actions { justify-content: flex-start; }
}
.sess-head { display: flex; align-items: center; gap: 6px; }
.sess-title { flex: 1; min-width: 0; }
.sess-fav {
  flex-shrink: 0; background: none; border: 0; cursor: pointer;
  font-size: 15px; line-height: 1; padding: 2px 4px; opacity: .45;
}
.sess-fav.active, .sess-fav:hover { opacity: 1; }
.sess-chip .sess-fav { margin-left: 6px; }
.modal-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin: 14px 0 6px;
}
.modal-desc {
  font-size: 14px;
  white-space: pre-wrap;
  background: var(--bg);
  border-radius: 8px;
  padding: 12px;
  line-height: 1.6;
}

.modal-fav { margin-top: 16px; }

/* ── Class session blocks (warm-up / strength / WOD of one day) ── */
.sess-block { margin: 14px 0; }
.sess-head {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: 6px;
}
.sess-head .sess-role { flex-shrink: 0; }
.sess-anchor .sess-head { color: var(--primary); }
.sess-anchor > .modal-desc {
  border-left: 3px solid var(--primary);
  padding-left: 12px;
}
.sess-sub {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin: 8px 0 4px;
}
.sess-chip {
  font-size: 13px;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  margin-top: 8px;
}
.sess-chip summary { cursor: pointer; font-weight: 600; }
.sess-chip .modal-desc { margin-top: 8px; background: var(--surface); }
.card-session {
  font-size: 12px;
  color: var(--muted);
  margin: 2px 0 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Utilities ───────────────────────────────────────────────── */
.section-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-sub-title {
  font-size: 15px;
  font-weight: 600;
  margin: 26px 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.settings-sub-title:first-of-type { margin-top: 8px; }

/* ── Notification bell ─────────────────────────────────────── */
.notif-wrap { position: relative; display: inline-block; }
.notif-btn { position: relative; font-size: 16px; }
.notif-badge {
  position: absolute; top: -2px; right: -2px;
  background: var(--red, #dc2626); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 1;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
}
.notif-dropdown {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 200;
  width: 360px; max-width: 92vw; max-height: 70vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 8px 28px rgba(0,0,0,0.18);
}
.notif-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface);
}
.notif-item {
  display: flex; gap: 10px; padding: 10px 14px;
  border-bottom: 1px solid var(--border); cursor: pointer;
}
.notif-item:hover { background: var(--bg); }
.notif-item.unread { background: color-mix(in srgb, var(--primary) 7%, transparent); }
.notif-dot { flex: 0 0 8px; width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; }
.notif-dot.info { background: #2563eb; }
.notif-dot.warning { background: #d97706; }
.notif-dot.error { background: #dc2626; }
.notif-title { font-size: 13px; font-weight: 600; }
.notif-body { font-size: 12px; color: var(--muted); margin-top: 2px; word-break: break-word; }
.notif-time { font-size: 11px; color: var(--muted); margin-top: 3px; }
.notif-empty { padding: 22px 14px; text-align: center; color: var(--muted); font-size: 13px; }

/* ── Similar workouts (modal) ──────────────────────────────── */
.similar-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; margin-top: 6px; cursor: pointer;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg);
}
.similar-item:hover { border-color: var(--primary); }
.similar-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.similar-go { color: var(--muted); font-size: 18px; flex: 0 0 auto; }

.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--muted);
}
.empty-state .icon { font-size: 40px; margin-bottom: 8px; }

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2.5px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #fff;
  padding: 10px 20px;
  border-radius: 99px;
  font-size: 14px;
  z-index: 300;
  opacity: 0;
  transition: opacity .25s;
  pointer-events: none;
  white-space: nowrap;
}
.toast.show { opacity: 1; }

@media (max-width: 640px) {
  .toast { bottom: calc(var(--bottom-h) + env(safe-area-inset-bottom) + 12px); }
  .filter-bar { flex-direction: column; }
  .filter-input.wide { min-width: unset; }
}
