:root {
  --bg: #0f1115;
  --panel: #141821;
  --text: #e6eaf2;
  --muted: #9aa5b1;
  --tile: #252c3a;
  --tile-hover: #323b4f;
  --accent: #7aa2f7;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Inter, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 600px at 20% -10%, #1a2030 10%, transparent 60%),
              radial-gradient(1000px 800px at 120% 0%, #1b2436 10%, transparent 70%),
              var(--bg);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px;
}

.builder-active .layout { grid-template-columns: 1fr; }
.builder-active .sidebar { display: none; }
.analytics-active .layout { grid-template-columns: 1fr; }
.analytics-active .sidebar { display: none; }
/* Two-column layout: sticky filters on the left */
.layout {
  display: grid;
  grid-template-columns: 290px 1fr;
  gap: 20px;
  align-items: start;
}
.layout .view-bar { grid-column: 1 / -1; margin-bottom: 0; }
.sidebar { position: sticky; top: 16px; height: fit-content; }
.content { min-width: 0; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; }
}

h1 { margin: 0 0 8px; font-weight: 700; letter-spacing: 0.2px; }
h2 { margin: 24px 0 12px; font-size: 18px; letter-spacing: 0.2px; }
.sub { margin: 0 0 16px; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.filters {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: end;
}

label { display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
select {
  color: var(--text);
  background: var(--panel);
  border: 1px solid #2a3244;
  padding: 10px 12px;
  border-radius: 10px;
  min-width: 220px;
  outline: none;
}
select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px #7aa2f733; }

input[type="text"],
input[type="number"] {
  color: var(--text);
  background: var(--panel);
  border: 1px solid #2a3244;
  padding: 10px 12px;
  border-radius: 10px;
  outline: none;
}
input[type="text"]:focus,
input[type="number"]:focus { border-color: var(--accent); box-shadow: 0 0 0 3px #7aa2f733; }

.search-sort { display: grid; gap: 12px; margin-bottom: 12px; }
.search-group { display: flex; gap: 8px; align-items: center; }
.btn.small { padding: 6px 10px; font-size: 12px; }
.sort-row { display: flex; align-items: center; gap: 8px; }
.sort-toggle { min-width: 110px; text-align: center; }
.sort-toggle.asc { background: #163922; border-color: #22c55e; color: #e8ffe8; box-shadow: inset 0 0 0 2px rgba(34,197,94,.25), 0 0 12px rgba(34,197,94,.12); }
.sort-toggle.desc { background: #3a1616; border-color: #ef4444; color: #ffe8e8; box-shadow: inset 0 0 0 2px rgba(239,68,68,.25), 0 0 12px rgba(239,68,68,.12); }
.sort-toggle.shuffled::after { content: ' ⤮'; font-size: 0.9em; margin-left: 4px; opacity: 0.85; }

.grid-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.active-filters { margin: 6px 0 12px; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0;
}
.toolbar-left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.toolbar-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  min-width: 0;
}
.toolbar #count {
  min-height: 28px;
  display: flex;
  align-items: center;
}
.custom-exercise-sync {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  min-width: 180px;
}
.custom-exercise-sync-status {
  min-height: 18px;
  text-align: right;
  color: var(--muted);
}
.custom-exercise-sync-status.success { color: #4ade80; }
.custom-exercise-sync-status.error { color: #f87171; }
.custom-exercise-sync-status.warning { color: #fbbf24; }

.view-bar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}
.view-links {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: center;
  justify-content: flex-end;
}
.view-link {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 14px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: color 120ms ease, background 120ms ease, letter-spacing 120ms ease;
}
.view-link:hover,
.view-link:focus-visible {
  color: var(--text);
  outline: none;
}
.view-link.active {
  background: #182133;
  color: #f2f5ff;
  box-shadow: inset 0 0 0 1px #2a3244;
}
.badge { background: #23324d; color: #9db6ff; padding: 2px 8px; border-radius: 999px; margin-left: 6px; font-size: 11px; }

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

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.card {
  background: var(--panel);
  border: 1px solid #22293a;
  border-radius: var(--radius);
  overflow: hidden;
  display: grid;
}

.media {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #0c0f16;
}
.media img, .media video {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
}
.media video { display: none; }
.media.playing img { opacity: 0; }
.media.playing video { display: block; }

.card-body { padding: 12px 12px 14px; display: grid; gap: 8px; }
.title { font-weight: 600; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  border: 1px solid #2a3244;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  color: var(--muted);
}

.card-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card-action {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid #2a3244;
  background: #101522;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.card-action:hover { background: #1b2335; color: var(--text); border-color: #3a4661; }
.card-action.primary { background: #173222; border-color: #22c55e; color: #defee0; }
.card-action.primary:hover { background: #1f3f2b; }
.card-action.danger { background: #3b1111; border-color: #ef4444; color: #ffe0e0; }
.card-action.danger:hover { background: #521414; border-color: #f87171; color: #ffffff; }
.card-action.icon { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 0; font-size: 16px; }
.card-action.icon::after {
  content: attr(data-label);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translate(-50%, 4px);
  background: #111628;
  color: var(--text);
  border: 1px solid #2a3244;
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 11px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease, transform 120ms ease;
  box-shadow: 0 6px 20px rgba(0,0,0,0.35);
}
.card-action.icon:hover::after,
.card-action.icon:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.toggle-active { background: #173222 !important; border-color: #22c55e !important; color: #defee0 !important; }

.card.highlight { border-color: #22c55e; box-shadow: 0 0 0 2px rgba(34,197,94,.2); }

/* Color accents per muscle group */
.accent-CHEST { --accent: #ef9a9a; }
.accent-BACK { --accent: #90caf9; }
.accent-LEGS { --accent: #a5d6a7; }
.accent-CORE { --accent: #ffcc80; }
.accent-ARMS { --accent: #ce93d8; }
.accent-SHOULDERS { --accent: #80cbc4; }
.accent-GLUTES { --accent: #f48fb1; }
.accent-NECK { --accent: #b39ddb; }
.accent-FULL_BODY { --accent: #ffd54f; }
.accent-OTHER { --accent: #b0bec5; }

.tile.accent { border-color: color-mix(in oklab, var(--accent), #1a2030 40%); }
.tile.accent:hover { border-color: var(--accent); box-shadow: 0 4px 24px color-mix(in oklab, var(--accent), transparent 80%); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 2px 10px;
  font-size: 12px;
  border-radius: 999px;
  border: 1px solid #2a3244;
  background: #0e121a;
}

.legend {
  display: flex; gap: 8px; align-items: center;
}
.swatch { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); border: 1px solid #2a3244; }

/* Filter sections with toggle buttons */
.filters-sections { display: grid; gap: 16px; }
.filter-block { display: grid; gap: 10px; background: #0e121a; border: 1px solid #202739; padding: 12px; border-radius: 12px; }
.block-head { display: flex; justify-content: space-between; align-items: center; }
.block-head .label { font-weight: 600; color: var(--text); }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  background: var(--panel);
  color: var(--text);
  border: 1px solid #2a3244;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}
.btn:hover { background: #1a2130; border-color: #3a4661; }
.btn.active {
  background: #163922;
  border-color: #22c55e;
  color: #e8ffe8;
  box-shadow: inset 0 0 0 2px rgba(34, 197, 94, 0.25), 0 0 16px rgba(34, 197, 94, 0.12);
}
.btn.primary {
  background: #1c2843;
  border-color: #4c6ef5;
  color: #e7efff;
  box-shadow: 0 0 18px rgba(76, 110, 245, 0.28);
}
.btn.primary:hover {
  background: #253257;
  border-color: #7293ff;
  color: #ffffff;
}
.btn.subtle { background: transparent; color: var(--muted); }
.btn.subtle:hover { color: var(--text); }
.btn.danger { background: #3b1111; border-color: #ef4444; color: #ffe0e0; }
.btn.danger:hover { background: #521414; border-color: #f87171; color: #ffffff; }

/* AND / OR mode bar */
.modebar { display: flex; align-items: center; gap: 8px; opacity: 0; transform: translateY(-6px); transition: opacity 120ms ease, transform 120ms ease; }
.filter-block:hover .modebar, .modebar.show { opacity: 1; transform: translateY(0); }
.seg { display: inline-flex; align-items: center; background: #121829; border: 1px solid #2a3244; border-radius: 999px; padding: 2px; }
.seg-btn { background: transparent; border: 0; color: var(--muted); padding: 6px 10px; border-radius: 999px; cursor: pointer; font-size: 12px; }
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: #243252; color: #e6eaf2; }

/* Workout builder */
.builder-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
}
.builder-info {
  display: grid;
  gap: 6px;
  min-width: 220px;
}
#builderMuscles {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}
.muscle-summary-label {
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.muscle-flag {
  font-weight: 700;
  display: inline-flex;
  align-items: center;
}
#builderMuscles .muscle-flag:not(:first-of-type)::before {
  content: '•';
  font-weight: 700;
  color: var(--muted);
  margin: 0 6px;
}
.muscle-flag.hit {
  color: #2f9e44;
}
.muscle-flag.miss {
  color: #c92a2a;
}

/* Minimal styling for shared modal helper */
.vt-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display:flex; align-items:center; justify-content:center; z-index:10000; }
.vt-modal-box { background: #0f1115; color: var(--text); border: 1px solid #22293a; border-radius: 10px; max-width: 720px; width: 92%; max-height: 80vh; overflow:auto; padding: 18px; box-shadow: 0 20px 60px rgba(0,0,0,0.6); }
.vt-modal-title { margin: 0 0 8px; font-size: 18px; }
.vt-modal-desc { color: var(--muted); margin: 0 0 12px; }
.vt-modal-list { margin: 0 0 12px 18px; max-height: 40vh; overflow:auto; }
.vt-modal-list-item { margin-bottom: 6px; }
.vt-modal-controls { display:flex; gap:8px; align-items:center; margin-top:12px; }
.vt-modal-checkbox-label { color: var(--muted); font-size:13px; display:flex; align-items:center; gap:8px; }
.vt-modal-btn { padding: 8px 12px; border-radius: 8px; border: 1px solid #2a3244; background: var(--panel); color: var(--text); cursor:pointer; }
.vt-modal-btn:hover { background:#171a21; }
.vt-modal-btn-confirm { background: var(--accent); border-color: #4c6ef5; color: #0b1220; }
.vt-modal-btn-confirm:hover { filter:brightness(1.05); }
.muscle-summary-count {
  font-size: 0.85em;
  color: var(--muted);
}
.builder-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.builder-actions .btn.small { min-width: 0; }
.builder-actions .option { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); cursor: pointer; }
.builder-actions .option input { accent-color: #22c55e; }
.builder-bulk-controls {
  display: flex;
  justify-content: flex-end;
  gap: 16px;
  margin: 6px 0 10px;
  flex-wrap: wrap;
  align-items: center;
}
.builder-bulk-controls .bulk-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}
.builder-bulk-controls label {
  font-size: 12px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.builder-bulk-controls select {
  min-width: 90px;
}
.btn-toggle-group {
  display: inline-flex;
  border: 1px solid #2a3244;
  border-radius: 999px;
  overflow: hidden;
}
.btn-toggle {
  border: none;
  background: transparent;
  color: #cbd5f5;
  padding: 4px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.btn-toggle:not(:last-child) {
  border-right: 1px solid #2a3244;
}
.btn-toggle.active {
  background: #2563eb;
  color: #fff;
}
.btn-toggle:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.builder-bulk-controls .bulk-control.disabled {
  opacity: 0.5;
}
.plan-controls {
  display: grid;
  gap: 16px;
  background: #101523;
  border: 1px solid #202a3d;
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 18px;
}
.plan-name-field { display: grid; gap: 8px; }
.plan-name-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.plan-name-header > label { margin: 0; }
.plan-sync-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.plan-name-field select {
  font-size: 14px;
  padding: 8px 38px 8px 12px;
  border-radius: 8px;
  border: 1px solid #2a3244;
  background-color: #0f1624;
  color: #f8fafc;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 12 8' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23cbd5f5' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px;
}
.plan-name-field select:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.35);
}
.plan-name-input-row { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; }
.plan-name-input-row + .plan-name-input-row { margin-top: 4px; }
.plan-name-input-row .btn.small { white-space: nowrap; }
.plan-name-hint { font-size: 12px; color: var(--muted); }
.schedule-fields {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.schedule-field { display: grid; gap: 6px; }
.schedule-field label { font-size: 12px; color: var(--muted); letter-spacing: 0.05em; text-transform: uppercase; }
.schedule-days { display: flex; flex-wrap: wrap; gap: 6px; }
.schedule-days button {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid #2a3244;
  background: #0f1524;
  color: var(--muted);
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
}
.schedule-days button:hover { color: var(--text); border-color: #3b4a6d; }
.schedule-days button.active {
  background: #1b2b4d;
  border-color: #4c6ef5;
  color: #e7efff;
  box-shadow: 0 0 12px rgba(76, 110, 245, 0.3);
}
.schedule-repeat { display: flex; align-items: center; gap: 8px; }
.schedule-repeat input { width: 70px; text-align: center; }
.schedule-calendar {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}
.schedule-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: 12px;
  background: #0f1524;
  border: 1px solid #202a3d;
  font-size: 13px;
}
.schedule-entry .date { font-weight: 600; color: #c6d4ff; }
.schedule-entry .details { color: var(--muted); font-size: 12px; }
.builder-sync-status { min-height: 18px; }
.builder-sync-status.success { color: #4ade80; }
.builder-sync-status.error { color: #f87171; }
.builder-sync-status.pending { color: #93c5fd; }
.builder-list { display: grid; gap: 16px; }
.builder-list.grouped { gap: 20px; }
.builder-group {
  position: relative;
  background: #0f1524;
  border: 1px solid #202a3d;
  border-radius: 16px;
  padding: 14px;
  display: grid;
  gap: 14px;
}
.builder-group::before {
  content: '';
  position: absolute;
  left: 0;
  top: 12px;
  bottom: 12px;
  width: 5px;
  border-radius: 999px;
  background: color-mix(in oklab, var(--group-color, #7aa2f7), transparent 10%);
  box-shadow: 0 0 20px color-mix(in oklab, var(--group-color, #7aa2f7), transparent 70%);
}
.builder-group[data-count='1']::before { bottom: 60px; }
.builder-group.dragging { opacity: 0.6; }
.builder-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-left: 10px;
}
.group-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  color: #f2f5ff;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.12em;
  white-space: nowrap;
}
.group-label::before {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--group-color, #7aa2f7);
  box-shadow: 0 0 10px color-mix(in oklab, var(--group-color, #7aa2f7), transparent 50%);
}
.builder-group-handle {
  border: 1px dashed color-mix(in oklab, var(--group-color, #7aa2f7), #1a2030 50%);
  background: #11182a;
  color: var(--muted);
  font-size: 11px;
  border-radius: 999px;
  padding: 4px 10px;
  cursor: grab;
}
.builder-group-handle:active { cursor: grabbing; }
.builder-group-body { display: grid; gap: 16px; }
.builder-card {
  background: #101523;
  border: 1px solid #202a3d;
  border-radius: 12px;
  padding: 16px;
  display: grid;
  gap: 12px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.builder-card.grouped {
  border-color: color-mix(in oklab, var(--group-color, #7aa2f7), #101523 35%);
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--group-color, #7aa2f7), transparent 75%);
  position: relative;
}
.builder-card:focus-within {
  border-color: #38bdf8;
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.6);
}
.builder-card.grouped::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 18px;
  bottom: 18px;
  width: 2px;
  border-radius: 999px;
  background: color-mix(in oklab, var(--group-color, #7aa2f7), transparent 25%);
}
.builder-card.dragging { opacity: 0.6; }
.builder-card .builder-header-main { cursor: pointer; }
.builder-card .builder-header-main:focus-visible { outline: 2px solid #22c55e; outline-offset: 2px; }
.builder-card h3 { margin: 0; font-size: 16px; }
.builder-meta { display: flex; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.builder-controls { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.builder-control-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.builder-behavior {
  display: flex;
  justify-content: flex-end;
}
.forward-fill-toggle {
  display: inline-flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
}
.forward-fill-toggle input {
  margin-top: 3px;
  width: auto;
}
.forward-fill-copy strong {
  display: block;
  color: #e2e8f0;
  font-size: 13px;
  font-weight: 600;
}
.forward-fill-copy span {
  display: block;
  line-height: 1.2;
}
.builder-move-buttons { display: inline-flex; gap: 6px; }
.btn.icon { padding: 0; width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; font-size: 16px; border-radius: 999px; }
.btn.icon.small { width: 28px; height: 28px; font-size: 14px; }
.btn.icon[disabled] { opacity: 0.45; cursor: default; }
.builder-header-main {
  position: relative;
  display: grid;
  gap: 4px;
}
.sets-table { width: 100%; border-collapse: collapse; }
.sets-table th, .sets-table td { border: 1px solid #1f2737; padding: 8px; text-align: left; font-size: 13px; vertical-align: middle; }
.sets-table th { background: #131a2a; color: var(--muted); font-weight: 500; }
.sets-table input, .sets-table select { width: 100%; }
.sets-table td.set-flag { text-align: center; }
.sets-table td.set-flag input { width: auto; }
.sets-table td:focus-within {
  background: rgba(56, 189, 248, 0.12);
  box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.45);
}
.sets-table .flag-control { display: flex; justify-content: center; }
.sets-table .flag-note { margin-top: 4px; font-size: 11px; }
.sets-table .progression-cell { min-width: 180px; }
.sets-table .progression-mode-select { margin-bottom: 4px; }
.sets-table .progression-inputs { display: flex; gap: 6px; flex-wrap: wrap; }
.sets-table .progression-inputs .progression-input { flex: 1 1 120px; }
.sets-table .progression-placeholder { display: inline-block; min-width: 40px; }
.sets-table th:nth-child(3),
.sets-table td.reps-cell {
  min-width: 80px;
  width: 95px;
}
.sets-table th:nth-child(4),
.sets-table td.weight-cell {
  min-width: 130px;
  width: 150px;
}
.sets-table th:nth-child(5),
.sets-table td.progression-cell {
  min-width: 150px;
  width: 170px;
}
.sets-table th:nth-child(6),
.sets-table td.progressive-overload-cell {
  min-width: 110px;
  width: 120px;
}
.sets-table th.rest-col,
.sets-table td.rest-cell {
  min-width: 110px;
  width: 110px;
}
.sets-table td.rest-cell.rest-expanded {
  min-width: 170px;
  width: 170px;
}
.sets-table th:nth-child(8),
.sets-table td.intensity-cell {
  min-width: 130px;
  width: 150px;
}
.sets-table td.intensity-cell select {
  min-width: 0;
}
.intensity-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.info-icon {
  border: 1px solid transparent;
  background: transparent;
  padding: 2px 5px;
  border-radius: 999px;
  font-size: 12px;
  color: #8fb3ff;
  cursor: help;
  user-select: none;
  line-height: 1;
}
.info-icon:hover {
  color: #cfe0ff;
  background: rgba(143, 179, 255, 0.08);
}
.flatpickr-current-month .numInputWrapper {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
}
.flatpickr-current-month input.cur-year {
  width: 4.5ch;
  padding: 0;
  font-weight: 600;
}
.mode-cell { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.mode-cell select { padding: 6px 8px; }
.mode-echo { display: flex; align-items: center; gap: 4px; }
.set-actions { display: flex; gap: 6px; justify-content: flex-end; }
.add-set { margin-top: 8px; }
.limit { color: #f87171; font-size: 12px; }
.empty { text-align: center; padding: 32px 0; color: var(--muted); border: 1px dashed #2a3244; border-radius: 12px; }
.custom-exercise-banner {
  margin: 16px 0 8px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid #1f2737;
  background: #0f1524;
  color: var(--muted);
  transition: border-color 0.2s, color 0.2s;
}
.custom-exercise-banner.success { border-color: #34d399; color: #bef264; }
.custom-exercise-banner.error { border-color: #f87171; color: #fecaca; }
.custom-exercise-banner.warning { border-color: #fbbf24; color: #fcd34d; }
.builder-custom-slot {
  border: 1px dashed #273146;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  padding: 6px 12px;
  margin: 6px 0;
  cursor: pointer;
  opacity: 0.45;
  transition: opacity 0.2s, border-color 0.2s, background 0.2s, color 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.builder-custom-slot .slot-label { font-weight: 600; }
.builder-custom-slot .slot-hint { display: block; font-size: 10px; letter-spacing: 0; text-transform: none; color: var(--muted); }
.builder-custom-slot:hover,
.builder-custom-slot:focus-visible {
  opacity: 1;
  border-color: #38bdf8;
  color: #e2e8f0;
  background: rgba(56, 189, 248, 0.08);
}
.builder-custom-slot.placeholder-card {
  display: grid;
  place-items: center;
  gap: 6px;
  padding: 18px;
  min-height: 140px;
  font-size: 14px;
  letter-spacing: 0.1em;
}
.builder-custom-empty-wrapper {
  margin-top: 16px;
  display: grid;
  gap: 8px;
}
.custom-exercise-modal {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 13, 0.85);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.custom-exercise-modal.hidden {
  display: none;
}
.custom-exercise-dialog {
  background: #0f1524;
  width: min(520px, 95vw);
  max-height: 90vh;
  overflow: auto;
  border-radius: 18px;
  border: 1px solid #1f2737;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.custom-exercise-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.custom-exercise-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.custom-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.custom-field span {
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.custom-field input {
  border-radius: 10px;
  border: 1px solid #273146;
  background: #0b1020;
  color: #f8fafc;
  padding: 10px 12px;
}
.custom-checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 6px;
  max-height: 150px;
  overflow: auto;
  border: 1px solid #1f2737;
  border-radius: 12px;
  padding: 8px;
  background: #0b1020;
}
.custom-checkbox-grid label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  border-radius: 8px;
  padding: 5px 8px;
  cursor: pointer;
}
.custom-checkbox-grid label:hover {
  background: rgba(56, 189, 248, 0.1);
}
.custom-checkbox-grid input {
  margin: 0;
}
.custom-exercise-message {
  min-height: 20px;
  font-size: 13px;
  color: var(--muted);
}
.custom-exercise-message.error { color: #f87171; }
.custom-exercise-message.success { color: #4ade80; }
.custom-exercise-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.builder-thumb {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 10px;
  width: 160px;
  max-width: 70vw;
  border-radius: 10px;
  border: 1px solid #242e43;
  background: #05070b;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 140ms ease, transform 140ms ease;
  pointer-events: none;
  z-index: 20;
}
.builder-header-main:hover .builder-thumb,
.builder-header-main:focus-visible .builder-thumb {
  opacity: 1;
  transform: translateY(0);
}


/* Scroll buttons */
.scroll-btn {
  position: fixed;
  right: 20px;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid #2a3244;
  background: #111628;
  color: var(--text);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 6px 30px rgba(0,0,0,0.4);
  z-index: 900;
}
.scroll-btn.up { top: 50%; transform: translateY(-60px); }
.scroll-btn.down { top: 50%; transform: translateY(20px); }
.scroll-btn.show { display: inline-flex; }

/* Analytics dashboard */
.analytics-dashboard { display: flex; flex-direction: column; gap: 24px; }
.analytics-header { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px; align-items: flex-start; background: #0e121a; border: 1px solid #1d2536; border-radius: 12px; padding: 20px; }
.analytics-sync { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; min-width: 220px; }
.analytics-sync-status { min-height: 1.2em; font-size: 12px; color: var(--muted); text-align: right; }
.analytics-dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 9, 17, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 2000;
}
.analytics-dialog {
  background: #0e121a;
  border: 1px solid #1d2536;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  width: min(420px, calc(100% - 32px));
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.analytics-dialog__title {
  margin: 0;
  font-size: 18px;
  color: var(--text);
}
.analytics-dialog__body {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}
.analytics-dialog__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}
.analytics-filter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; }
.analytics-filter { background: #0e121a; border: 1px solid #1d2536; border-radius: 12px; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.analytics-filter-label { font-weight: 600; letter-spacing: 0.08em; color: var(--muted); text-transform: uppercase; font-size: 12px; }
.analytics-select { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid #2a3244; background: var(--panel); color: var(--text); }
.analytics-filter-hint { margin: 0; font-size: 12px; color: var(--muted); }
.analytics-range-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.analytics-range-btn { border: 1px solid #2a3244; background: transparent; color: var(--muted); border-radius: 999px; padding: 6px 12px; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; cursor: pointer; }
.analytics-range-btn.is-active { background: #1c2843; border-color: #4c6ef5; color: #e7efff; }
.analytics-chart-card { background: #0e121a; border: 1px solid #1d2536; border-radius: 12px; padding: 24px; display: flex; flex-direction: column; gap: 18px; }
.analytics-chart-header { display: flex; flex-wrap: wrap; gap: 16px; justify-content: space-between; align-items: flex-start; }
.analytics-chart-header h3 { margin: 0; letter-spacing: 0.04em; }
.analytics-chart-header p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.analytics-metrics { display: flex; flex-wrap: wrap; gap: 14px; }
.analytics-metric { min-width: 150px; background: #111726; border: 1px solid #222c3f; border-radius: 10px; padding: 12px 16px; }
.analytics-metric-label { font-size: 11px; letter-spacing: 0.08em; color: var(--muted); text-transform: uppercase; }
.analytics-metric strong { display: block; font-size: 24px; margin-top: 4px; }
.analytics-metric small { color: var(--muted); font-size: 12px; }
.analytics-metric--gain { border-style: dashed; border-color: rgba(124,138,255,0.65); }
.analytics-metric--dual { min-width: 260px; }
.analytics-metric-split { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-top: 10px; }
.analytics-metric-split--compact { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.analytics-metric-split__item { border: 1px solid #1f2737; border-radius: 8px; padding: 10px 12px; background: rgba(11, 19, 36, 0.65); }
.analytics-metric-split__label { font-size: 11px; letter-spacing: 0.08em; color: var(--muted); text-transform: uppercase; display: block; }
.analytics-metric-split__item strong { font-size: 20px; margin-top: 4px; }
.analytics-metric-split__item small { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }
.analytics-metric-split__item--concentric strong { color: #7aa2f7; }
.analytics-metric-split__item--eccentric strong { color: #f472b6; }
.analytics-metric--workload { position: relative; flex: 1; min-width: 240px; }
.analytics-workload-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-top: 10px; }
.analytics-workload-cell { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; border: 1px solid #1f2737; border-radius: 8px; padding: 10px 12px; background: #0e172a; color: inherit; font: inherit; text-align: left; transition: border-color 0.2s ease, background 0.2s ease; }
.analytics-workload-cell strong { font-size: 20px; margin-top: 0; }
.analytics-workload-cell small { font-size: 11px; color: var(--muted); }
.analytics-workload-cell__label { font-size: 12px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
button.analytics-workload-cell { cursor: pointer; }
button.analytics-workload-cell:disabled { opacity: 0.45; cursor: not-allowed; }
.analytics-workload-cell--primary { border-color: rgba(124,138,255,0.65); background: rgba(17,24,39,0.85); }
.analytics-workload-cell--primary:focus-visible { outline: 2px solid rgba(124,138,255,0.9); outline-offset: 3px; }
@media (min-width: 640px) {
  .analytics-workload-cell--primary { grid-column: span 2; }
}
.analytics-workload-tooltip { position: absolute; top: calc(100% + 10px); left: 0; width: min(320px, 90vw); background: #080f1d; border: 1px solid #1f2737; border-radius: 12px; padding: 16px; box-shadow: 0 18px 36px rgba(0,0,0,0.45); opacity: 0; pointer-events: none; transition: opacity 0.12s ease, transform 0.12s ease; transform: translateY(-4px); z-index: 20; }
.analytics-workload-tooltip.is-visible { opacity: 1; pointer-events: auto; transform: translateY(0); }
.analytics-workload-tooltip__header { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
.analytics-workload-tooltip__header strong { font-size: 16px; color: #e5edff; }
.analytics-workload-tooltip__summary { display: flex; gap: 12px; margin-bottom: 12px; }
.analytics-workload-tooltip__summary-item { flex: 1; display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--muted); }
.analytics-workload-tooltip__summary-item strong { font-size: 16px; color: #e5edff; }
.analytics-workload-tooltip__summary-item--concentric strong { color: #7aa2f7; }
.analytics-workload-tooltip__summary-item--eccentric strong { color: #f472b6; }
.analytics-workload-tooltip__content { display: flex; gap: 16px; align-items: center; }
.analytics-workload-pie { width: 100px; height: 100px; border-radius: 50%; background: #182036; position: relative; flex-shrink: 0; }
.analytics-workload-pie::after { content: ''; position: absolute; inset: 20%; border-radius: 50%; background: #080f1d; }
.analytics-workload-breakdown { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.analytics-workload-breakdown__row { display: flex; flex-direction: column; gap: 4px; font-size: 13px; padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,0.05); }
.analytics-workload-breakdown__row:last-child { border-bottom: none; }
.analytics-workload-breakdown__label { display: flex; align-items: center; gap: 8px; color: #e5edff; font-weight: 600; }
.analytics-workload-breakdown__swatch { width: 10px; height: 10px; border-radius: 50%; background: currentColor; }
.analytics-workload-breakdown__percent { font-size: 16px; color: #e5edff; }
.analytics-workload-breakdown__details { margin-top: 4px; display: flex; flex-direction: column; gap: 2px; }
.analytics-workload-breakdown__details span { font-size: 11px; color: var(--muted); }
.analytics-workload-breakdown__empty { margin: 0; font-size: 12px; color: var(--muted); }
@media (max-width: 540px) {
  .analytics-workload-tooltip { width: min(280px, 90vw); }
  .analytics-workload-tooltip__content { flex-direction: column; align-items: flex-start; }
  .analytics-workload-pie { margin-inline: auto; }
  .analytics-workload-breakdown__row { width: 100%; }
}
.analytics-metrics--legend { justify-content: flex-end; gap: 10px 18px; }
.analytics-legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.analytics-legend-swatch { width: 12px; height: 12px; border-radius: 2px; border: 1px solid rgba(255,255,255,0.25); }
.analytics-chart-meta { display: flex; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--muted); letter-spacing: 0.04em; }
.analytics-chart-wrapper { min-height: 320px; position: relative; }
.analytics-chart { width: 100%; height: 360px; }
.analytics-empty-state { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 30px; color: var(--muted); font-size: 14px; }
.analytics-empty-state.hidden { display: none; }
.analytics-bar-chart { min-height: 320px; position: relative; display: flex; flex-direction: column; gap: 12px; }
.analytics-bar-chart__content { display: flex; gap: 18px; align-items: flex-end; }
.analytics-axis-column { display: flex; flex-direction: column; justify-content: flex-end; gap: 10px; min-width: 90px; }
.analytics-bar-chart__axis { min-width: 90px; display: flex; flex-direction: column; gap: 6px; color: var(--muted); }
.analytics-axis-spacer { height: 32px; width: 100%; }
.analytics-bar-chart__axis.hidden { display: none; }
.analytics-axis-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.analytics-axis-total { font-size: 12px; font-weight: 600; color: #fca5a5; text-align: right; }
.analytics-axis-rail { position: relative; width: 54px; border-left: 1px solid #2a3244; height: 240px; align-self: flex-end; }
.analytics-axis-tick { position: absolute; left: -6px; display: flex; align-items: center; gap: 6px; transform: translateY(50%); }
.analytics-axis-tick__line { width: 6px; height: 1px; background: #39425a; flex-shrink: 0; }
.analytics-axis-tick__label { font-size: 11px; color: var(--muted); white-space: nowrap; }
.analytics-bar-chart__viewport { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.analytics-bar-chart__bars-wrapper { position: relative; min-height: 260px; display: flex; align-items: flex-end; width: 100%; }
.analytics-peak-line { position: absolute; left: 0; right: 0; border-top: 1px dashed #f87171; display: none; }
.analytics-peak-line.visible { display: block; }
.analytics-peak-label { position: absolute; right: 0; transform: translateY(50%); font-size: 12px; color: #fca5a5; background: rgba(15,17,21,0.85); padding: 2px 6px; border-radius: 999px; display: none; white-space: nowrap; }
.analytics-peak-label.visible { display: inline-block; }
.analytics-bar-chart__bars { display: flex; gap: 16px; align-items: flex-end; width: 100%; }
.analytics-bar { display: flex; flex-direction: column; align-items: center; flex: 0 0 60px; min-width: 48px; }
.analytics-bar__stack { background: #111628; border: 1px solid #1f2737; border-radius: 6px; width: 42px; display: flex; flex-direction: column; justify-content: flex-end; overflow: hidden; }
.analytics-bar-segment { width: 100%; display: flex; align-items: flex-end; justify-content: center; font-size: 11px; font-weight: 600; color: rgba(255,255,255,0.9); padding: 2px 4px; box-sizing: border-box; }
.analytics-bar-chart__x { display: flex; gap: 16px; align-items: center; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; min-height: 32px; width: 100%; }
.analytics-bar-chart__x.hidden { display: none; }
.analytics-x-label { flex: 0 0 60px; min-width: 48px; text-align: center; display: flex; align-items: center; justify-content: center; height: 100%; }
.analytics-bar-tooltip {
  position: absolute;
  top: 0;
  left: 0;
  background: rgba(12, 16, 26, 0.95);
  border: 1px solid #2a3244;
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--text);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 120ms ease;
  z-index: 20;
  min-width: 160px;
}
.analytics-bar-tooltip.is-visible {
  opacity: 1;
  visibility: visible;
}
.analytics-bar-tooltip__label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.analytics-bar-tooltip__value {
  display: block;
  font-size: 18px;
  font-weight: 600;
  margin-top: 4px;
  color: #ffffff;
}
.analytics-bar-tooltip__meta {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

/* Modal */
.modal { position: fixed; inset: 0; background: #0008; display: grid; place-items: center; z-index: 1000; }
.modal.hidden { display: none; }
.dialog { width: min(1100px, 96vw); background: #0b0e14; border: 1px solid #2a3244; border-radius: 12px; padding: 10px; box-shadow: 0 20px 60px rgba(0,0,0,0.5); }
.close { position: absolute; margin-top: -6px; margin-left: -6px; transform: translate(6px, -6px); border: 1px solid #2a3244; background: #121827; color: var(--text); border-radius: 999px; width: 28px; height: 28px; cursor: pointer; }
.modal-notice { padding-top: 8px; }

/* Back to Top */
