/* GymPace v9 */
:root {
  --bg: #0a0a0a;
  --surface: #1a1a1a;
  --surface-elev: #242424;
  --text: #f5f5f5;
  --text-dim: #888;
  --accent: #4ade80;
  --accent-dim: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;
  --radius: 14px;
  --tap: 56px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  margin: 0;
  padding: 0;
  touch-action: manipulation;
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.4;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ---- Header ---- */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  padding-top: max(16px, env(safe-area-inset-top));
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--surface);
}
.header h1 {
  font-size: 22px;
  font-weight: 700;
}
.header .btn-icon {
  background: var(--surface);
  border: none;
  color: var(--text);
  width: 40px; height: 40px;
  border-radius: 50%;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.1s;
}
.header .btn-icon:active { transform: scale(0.9); }

/* ---- Buttons ---- */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius);
  font-size: 18px;
  font-weight: 700;
  min-height: var(--tap);
  width: 100%;
  cursor: pointer;
  transition: transform 0.08s, opacity 0.08s;
}
.btn:active { transform: scale(0.96); opacity: 0.85; }
.btn-secondary { background: var(--surface-elev); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-dim); font-weight: 500; }

/* ---- Lists ---- */
.list { padding: 12px 16px; }
.list-item {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: transform 0.08s;
}
.list-item:active { transform: scale(0.98); }
.list-item .title { font-weight: 600; font-size: 17px; }
.list-item .subtitle { color: var(--text-dim); font-size: 14px; margin-top: 2px; }
.list-item .chevron { color: var(--text-dim); font-size: 22px; }

/* ---- Active Workout ---- */
.workout-header {
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.workout-header-btn {
  background: var(--surface-elev);
  border: none;
  color: var(--accent);
  min-height: 44px;
  min-width: 44px;
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.08s;
  touch-action: manipulation;
}
.workout-header-btn.cancel {
  color: var(--danger);
}
.workout-header-btn:active { transform: scale(0.92); }
.timer {
  font-size: 28px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}
.pair-indicator {
  font-size: 14px;
  color: var(--text-dim);
}

.current-exercise {
  margin: 8px 20px 0;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px 20px;
  text-align: center;
}
.current-exercise .ex-name {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 4px;
}
.current-exercise .round-info {
  font-size: 14px;
  color: var(--text-dim);
  margin-bottom: 20px;
}

.pair-tabs {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 16px;
}
.pair-tab {
  flex: 1;
  padding: 8px 4px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  background: var(--bg);
  color: var(--text-dim);
}
.pair-tab.active {
  background: var(--accent);
  color: #000;
}

.weight-section {
  margin: 0 20px;
}
.weight-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 16px;
}
.weight-btn-big {
  background: var(--surface-elev);
  border: none;
  color: var(--text);
  min-width: 64px;
  min-height: 56px;
  border-radius: 14px;
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.08s;
  touch-action: manipulation;
}
.weight-btn-big:active { transform: scale(0.9); }
.weight-btn-small {
  background: var(--surface-elev);
  border: none;
  color: var(--text);
  flex: 1;
  min-height: 48px;
  border-radius: 12px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.08s;
  touch-action: manipulation;
}
.weight-btn-small:active { transform: scale(0.9); }
.weight-display {
  font-size: 36px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  min-width: 120px;
  text-align: center;
}
.weight-unit { font-size: 16px; color: var(--text-dim); font-weight: 500; }

.reps-section {
  margin: 0 20px;
  padding-top: 8px;
}
.reps-label {
  font-size: 14px;
  color: var(--text-dim);
  text-align: center;
  margin-bottom: 8px;
}
.reps-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.rep-btn {
  background: var(--surface-elev);
  border: 2px solid transparent;
  color: var(--text);
  border-radius: var(--radius);
  min-height: var(--tap);
  font-size: 22px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.08s, border-color 0.15s;
}
.rep-btn:active { transform: scale(0.93); }
.rep-btn.custom {
  background: transparent;
  border: 2px solid var(--surface-elev);
  color: var(--text-dim);
  font-size: 16px;
}

.rpe-section {
  margin: 20px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--surface);
}
.rpe-label {
  font-size: 14px;
  color: var(--text-dim);
  text-align: center;
  margin-bottom: 8px;
}
.rpe-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.rpe-btn {
  padding: 12px 4px;
  border-radius: 10px;
  border: 2px solid transparent;
  font-weight: 700;
  font-size: 14px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.08s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.rpe-btn:active { transform: scale(0.92); }
.rpe-btn[data-val="low"] { background: #1a3a1a; color: #4ade80; }
.rpe-btn[data-val="medium"] { background: #3a3a1a; color: #facc15; }
.rpe-btn[data-val="hard"] { background: #3a2a1a; color: #fb923c; }
.rpe-btn[data-val="max"] { background: #3a1a1a; color: #f87171; }
.rpe-btn.selected { border-color: #fff; transform: scale(1.05); }

.log-set-area {
  position: sticky;
  bottom: 0;
  padding: 16px 20px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  background: var(--bg);
}
.log-set-area .btn {
  font-size: 20px;
  min-height: 64px;
}

.next-hint {
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
  margin-top: 8px;
}

/* ---- History list ---- */
.stat-row {
  display: flex;
  gap: 12px;
  padding: 0 16px;
  margin-bottom: 16px;
}
.stat-card {
  flex: 1;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}
.stat-card .value { font-size: 24px; font-weight: 800; }
.stat-card .label { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

/* ---- Chart ---- */
.chart-container {
  padding: 16px 20px;
}
.chart-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.chart-card h3 { font-size: 16px; margin-bottom: 12px; }
.chart-svg {
  width: 100%;
  height: 160px;
  overflow: visible;
}

/* ---- AI Card ---- */
.ai-card {
  background: var(--surface);
  border-left: 3px solid var(--info);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 12px 16px;
}
.ai-card h3 { font-size: 16px; margin-bottom: 8px; color: var(--info); }
.ai-card .analysis { font-size: 15px; line-height: 1.5; white-space: pre-wrap; }

/* ---- Editor ---- */
.editor-section {
  padding: 12px 16px;
}
.editor-input {
  background: var(--surface);
  border: 1px solid var(--surface-elev);
  border-radius: 10px;
  padding: 12px 16px;
  color: var(--text);
  font-size: 17px;
  width: 100%;
  margin-bottom: 12px;
}
.editor-input:focus { outline: none; border-color: var(--accent); }
.exercise-edit {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
}
.exercise-edit .row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.exercise-edit .row > * { flex: 1; }
.exercise-edit label {
  font-size: 12px;
  color: var(--text-dim);
  display: block;
  margin-bottom: 4px;
}
.exercise-edit input, .exercise-edit select {
  background: var(--bg);
  border: 1px solid var(--surface-elev);
  border-radius: 8px;
  padding: 10px;
  color: var(--text);
  font-size: 16px;
  width: 100%;
}
.exercise-edit input:focus, .exercise-edit select:focus { outline: none; border-color: var(--accent); }

.pair-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 16px 12px;
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 600;
}
.pair-divider::before, .pair-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--surface-elev);
}

/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-elev);
  color: var(--text);
  padding: 12px 24px;
  border-radius: 20px;
  font-size: 15px;
  font-weight: 600;
  z-index: 999;
  animation: toast 2s ease forwards;
  pointer-events: none;
}
@keyframes toast {
  0% { opacity: 0; transform: translateX(-50%) translateY(20px); }
  15% { opacity: 1; transform: translateX(-50%) translateY(0); }
  85% { opacity: 1; }
  100% { opacity: 0; }
}

/* ---- Bottom Nav ---- */
.bottom-nav {
  display: flex;
  position: sticky;
  bottom: 0;
  background: var(--bg);
  border-top: 1px solid var(--surface);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav button {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 12px;
  padding: 12px 4px 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.bottom-nav button.active { color: var(--accent); }
.bottom-nav button .icon { font-size: 22px; }

/* ---- Misc ---- */
.empty-state {
  text-align: center;
  padding: 60px 40px;
  color: var(--text-dim);
}
.empty-state .big { font-size: 48px; margin-bottom: 8px; }
.loading { text-align: center; padding: 40px; color: var(--text-dim); }
.scrim {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--surface);
  border-radius: 20px;
  padding: 24px;
  width: 100%;
  max-width: 360px;
}
.modal h3 { margin-bottom: 16px; }
.modal input {
  background: var(--bg);
  border: 1px solid var(--surface-elev);
  border-radius: 10px;
  padding: 12px;
  color: var(--text);
  font-size: 17px;
  width: 100%;
  margin-bottom: 16px;
}
.modal input:focus { outline: none; border-color: var(--accent); }
.modal .btn { margin-bottom: 8px; }

/* Exercise Library — full view */
.lib-search-bar {
  padding: 12px 16px 8px;
}
.lib-search-bar input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--surface-elev);
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--text);
  font-size: 16px;
}
.lib-search-bar input:focus { outline: none; border-color: var(--accent); }

.picker-hint {
  padding: 8px 16px;
  font-size: 14px;
  color: var(--text-dim);
  text-align: center;
}

.lib-pick-btn {
  font-size: 12px;
  padding: 4px 10px;
  min-height: 32px;
  margin-top: 6px;
  width: auto;
  flex: 0 0 auto;
}

.lib-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--surface);
}

.lib-item-main {
  flex: 1;
  cursor: pointer;
}

.lib-item-main:active {
  opacity: 0.7;
}

.lib-group {
  margin-bottom: 8px;
}

.lib-group-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 16px 4px;
}

.lib-item-name {
  font-weight: 600;
  font-size: 16px;
}

.lib-item-meta {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 2px;
}

.lib-item-edit {
  flex: 0 0 auto;
  font-size: 18px;
  padding: 8px;
  background: none;
  border: none;
  cursor: pointer;
}

.lib-item-delete {
  flex: 0 0 auto;
  font-size: 16px;
  padding: 8px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--danger);
}

/* Library inline form (add/edit) */
.lib-form {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  margin: 12px 16px;
  border: 1px solid var(--surface-elev);
}

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

.lib-form-row > div {
  flex: 1;
}

.lib-form-row label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.lib-form input,
.lib-form select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--surface-elev);
  border-radius: 8px;
  padding: 10px;
  color: var(--text);
  font-size: 16px;
}

.lib-form input:focus,
.lib-form select:focus {
  outline: none;
  border-color: var(--accent);
}

.lib-form-actions {
  display: flex;
  gap: 12px;
  margin-top: 4px;
}

.lib-form-actions .btn {
  flex: 1;
}

/* ============================================================
   AI COACH — Chat UI
   ============================================================ */
.coach-content {
  position: fixed;
  top: 56px;
  bottom: 70px;
  left: 0;
  right: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 0;
}

.coach-messages {
  padding: 0 12px;
}

.coach-welcome {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  margin: 8px 12px 16px;
  font-size: 15px;
  color: var(--text-dim);
  line-height: 1.5;
  border: 1px solid var(--surface-elev);
}

.quick-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 12px;
}

.quick-action {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--surface-elev);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
  text-align: left;
  transition: transform 0.1s;
}

.quick-action:active {
  transform: scale(0.97);
  background: var(--surface-elev);
}

.quick-icon {
  font-size: 20px;
  flex-shrink: 0;
}

/* Chat bubbles */
.chat-bubble {
  max-width: 85%;
  margin-bottom: 10px;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.45;
  word-wrap: break-word;
}

.chat-user {
  margin-left: auto;
  background: var(--accent);
  color: #0a0a0a;
  border-bottom-right-radius: 4px;
  font-weight: 500;
}

.chat-assistant {
  margin-right: auto;
  background: var(--surface-elev);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.chat-text {
  white-space: pre-wrap;
}

/* Typing indicator */
.chat-typing .chat-text {
  display: flex;
  gap: 4px;
  align-items: center;
  min-height: 20px;
}

.typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* Input bar — fixed at bottom */
.coach-input-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--bg);
  border-top: 1px solid var(--surface-elev);
  z-index: 100;
}

.coach-input-bar input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--surface-elev);
  border-radius: 20px;
  padding: 10px 16px;
  color: var(--text);
  font-size: 16px;
  outline: none;
}

.coach-input-bar input:focus {
  border-color: var(--accent);
}

.coach-send-btn {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  padding: 0;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================================================
   POST-WORKOUT SUMMARY SCREEN
   ============================================================ */
.post-workout-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.post-workout-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 32px 24px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  border: 1px solid var(--surface-elev);
}

.post-workout-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.post-workout-sub {
  color: var(--text-dim);
  margin-bottom: 20px;
}

.post-workout-summary {
  margin: 16px 0;
  text-align: left;
}

/* ============================================================
   PROACTIVE SUGGESTIONS (Coach home)
   ============================================================ */
.proactive-suggestions {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 8px 12px 16px;
  border: 1px solid var(--surface-elev);
}

.proactive-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
}

.proactive-tip {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--surface-elev);
  font-size: 14px;
  line-height: 1.4;
}

.proactive-tip:last-child {
  border-bottom: none;
}

.proactive-icon {
  flex-shrink: 0;
  font-size: 18px;
}

/* ============================================================
   WORKOUT OPTIMIZER
   ============================================================ */
/* ============================================================
   RESISTANCE BAND
   ============================================================ */
.weight-type-toggle {
  display: flex;
  gap: 8px;
  width: 100%;
}

.wt-btn {
  flex: 1;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--surface-elev);
  background: var(--bg);
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
}

.wt-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.band-color-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 8px;
}

.band-color-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 6px;
  border-radius: 12px;
  border: 2px solid var(--surface-elev);
  background: var(--bg);
  cursor: pointer;
  min-height: 44px;
}

.band-color-btn.selected {
  background: var(--surface);
  border-width: 2px;
}

.band-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-block;
  border: 1px solid rgba(255,255,255,0.2);
}

.band-dot-small {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  border: 1px solid rgba(255,255,255,0.2);
}

.band-label,
.band-kg {
  font-size: 12px;
  color: var(--text-dim);
}

.band-color-btn.selected .band-label {
  color: var(--text);
  font-weight: 700;
}

/* Active workout band buttons */
.band-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.band-select-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 6px;
  border-radius: 12px;
  border: 2px solid var(--surface-elev);
  background: var(--bg);
  cursor: pointer;
  min-height: 44px;
  touch-action: manipulation;
}

.band-select-btn.selected {
  background: var(--surface);
  border-width: 3px;
}

.band-select-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.band-select-kg {
  font-size: 11px;
  color: var(--text-dim);
}

.band-select-btn.selected .band-select-label {
  color: var(--accent);
}

.ex-name-container {
  position: relative;
}

.editor-band-display {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--surface-elev);
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  min-height: 42px;
}

.ex-autocomplete {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--surface-elev);
  border-radius: 0 0 12px 12px;
  z-index: 100;
  max-height: 240px;
  overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.ex-autocomplete-item {
  display: flex;
  flex-direction: column;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--surface-elev);
  touch-action: manipulation;
}

.ex-autocomplete-item:last-child {
  border-bottom: none;
}

.ex-autocomplete-item:hover {
  background: var(--surface-elev);
}

.ex-ac-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.ex-ac-meta {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* ============================================================
   LOGGED SETS (in active workout)
   ============================================================ */
.logged-sets-section {
  margin: 16px 20px 40px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--surface-elev);
  overflow: hidden;
}

.logged-sets-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  color: var(--text-dim);
}

.logged-sets-toggle {
  font-size: 12px;
  transition: transform 0.2s;
}

.logged-sets-body {
  padding: 0 16px 12px;
}

.logged-exercise {
  padding: 10px 0;
  border-bottom: 1px solid var(--surface-elev);
}

.logged-exercise:last-child {
  border-bottom: none;
}

.logged-ex-name {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text);
}

.logged-set-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  font-size: 13px;
  color: var(--text-dim);
}

.logged-set-num {
  flex: 1;
}

.logged-set-data {
  flex: 1;
  text-align: center;
  color: var(--text);
}

.logged-set-rpe {
  flex: 0 0 auto;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 8px;
  font-weight: 600;
}

.rpe-badge-low {
  background: rgba(34, 197, 94, 0.2);
  color: #4ade80;
}

.rpe-badge-medium {
  background: rgba(234, 179, 8, 0.2);
  color: #fbbf24;
}

.rpe-badge-hard {
  background: rgba(249, 115, 22, 0.2);
  color: #fb923c;
}

.rpe-badge-max {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
}

.optimizer-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.optimizer-loading {
  text-align: center;
}

.optimizer-loading p {
  margin-top: 16px;
  font-size: 16px;
}

.spinner {
  width: 44px;
  height: 44px;
  border: 4px solid var(--surface-elev);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto;
  animation: spin 0.8s linear infinite;
}

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

.optimizer-results {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  margin: 12px 0;
  border: 1px solid var(--surface-elev);
}

.optimizer-results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.optimizer-results-header h3 {
  font-size: 18px;
}

.optimizer-summary {
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.5;
  margin-bottom: 16px;
  padding: 12px;
  background: var(--bg);
  border-radius: 10px;
}

.optimizer-section-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  margin: 16px 0 8px;
}

.optimizer-suggestion {
  background: var(--bg);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
  border: 1px solid var(--surface-elev);
}

.opt-sug-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.opt-sug-icon {
  font-size: 20px;
}

.opt-sug-name {
  font-weight: 700;
  font-size: 16px;
}

.opt-sug-changes {
  margin-bottom: 8px;
}

.opt-change {
  font-size: 14px;
  padding: 2px 0;
}

.opt-sug-reason {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.4;
  margin-bottom: 8px;
  font-style: italic;
}

.opt-apply-btn {
  width: 100%;
  font-size: 14px;
  min-height: 38px;
}

.optimizer-actions {
  margin-top: 16px;
  display: flex;
  gap: 8px;
}

.optimizer-actions .btn {
  flex: 1;
}

/* Swap Exercise Modal */
.swap-modal {
  background: var(--surface);
  border-radius: var(--radius);
  width: 100%;
  max-width: 500px;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  margin: 16px;
}

.swap-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--surface-elev);
}

.swap-modal-header h3 {
  font-size: 18px;
}

.swap-search-bar {
  padding: 8px 16px;
}

.swap-search-bar input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--surface-elev);
  border-radius: 10px;
  color: var(--text);
  font-size: 15px;
}

.swap-list {
  overflow-y: auto;
  padding: 0 16px 16px;
  flex: 1;
}

.swap-item {
  cursor: pointer;
  transition: background 0.15s;
}

.swap-item:active {
  background: var(--surface-elev);
}

/* ============================================================
   RESUME BANNER (Home)
   ============================================================ */
.resume-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 16px;
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.15), rgba(34, 197, 94, 0.05));
  border: 1px solid rgba(34, 197, 94, 0.4);
  border-radius: var(--radius);
  cursor: pointer;
  touch-action: manipulation;
}

.resume-banner-paused {
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.15), rgba(234, 179, 8, 0.05));
  border-color: rgba(234, 179, 8, 0.4);
}

.resume-banner-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.resume-banner-text {
  flex: 1;
  min-width: 0;
}

.resume-banner-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
}

.resume-banner-sub {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* ============================================================
   UNDO BUTTON (active workout)
   ============================================================ */
.log-set-area {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.log-set-area .btn:not(.undo-btn) {
  flex: 1;
}

.undo-btn {
  flex: 0 0 auto;
  min-width: 90px;
  font-size: 14px !important;
}

/* ============================================================
   EDIT EXERCISE MODAL (active workout)
   ============================================================ */
#edit-ex-overlay .swap-modal {
  max-height: 88vh;
}

#edit-ex-overlay input[type="text"],
#edit-ex-overlay input[type="number"] {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--surface-elev);
  border-radius: 10px;
  color: var(--text);
  font-size: 15px;
}

#edit-ex-overlay label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 4px;
}

#edit-ex-overlay .lib-form-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

#edit-ex-overlay .lib-form-actions .btn {
  flex: 1;
}

/* ============================================================
   BAND PICKER IN TEMPLATE EDITOR
   ============================================================ */
.editor-band-select {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.band-color-btn-compact {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border-radius: 10px;
  border: 2px solid var(--surface-elev);
  background: var(--bg);
  cursor: pointer;
  min-height: 36px;
  touch-action: manipulation;
  font-size: 12px;
}

.band-color-btn-compact .band-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.band-color-btn-compact.selected {
  border-width: 2px;
  background: var(--surface);
}
