/* Fade-in animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.6s ease-out forwards;
}

.fade-in-delay-1 {
  animation: fadeIn 0.6s ease-out 0.15s forwards;
  opacity: 0;
}

.fade-in-delay-2 {
  animation: fadeIn 0.6s ease-out 0.3s forwards;
  opacity: 0;
}

/* Two-column grid for exercise form in Manage Exercises */
.exercise-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 24px;
  align-items: end;
}

.exercise-form-grid .input-block {
  width: 100%;
}

/* On mobile: Name and Category full-width, Duration/Sets/Reps/Rest stay 2-column */
@media (max-width: 700px) {
  .exercise-form-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px 16px;
  }
  
  /* Name and Category span both columns */
  .exercise-form-grid .input-block:nth-child(1),
  .exercise-form-grid .input-block:nth-child(2) {
    grid-column: 1 / -1;
  }
  
  /* Duration, Sets, Reps, Rest remain in 2 columns (2 rows) */
  /* These are children 3, 4, 5, 6 */
}

body {
  font-family: Arial, sans-serif;
  padding: 12px;
  max-width: 1000px;
  margin: 0 auto;
  background: #fafafa;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: hidden;
  max-width: 100vw;
}

/* White background for entire screen in focus mode */
body.voice-trainer-focus-mode {
  background: #ffffff !important;
  overflow: hidden !important;
}

html:has(body.voice-trainer-focus-mode) {
  overflow: hidden !important;
}

.app-section {
  display: none;
  padding: 12px 0 20px 0;
  padding-top: 12px;
}

.app-section[style*="display: block"] {
  animation: fadeInScale 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

html {
  overflow-x: hidden;
}

:root {
  --header-bg: #f5f5f5;
  --header-text: #111111;
}

.app-section > h1,
.app-section > h2,
.home-screen > h1 {
  background: var(--header-bg, #f5f5f5);
  color: var(--header-text, #111111);
  padding: 10px 12px;
  border-radius: 8px;
  margin: 0 0 12px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  box-sizing: border-box;
}

.app-section > h1 > span,
.app-section > h2 > span,
.home-screen > h1 > span {
  flex: 1;
  text-align: center;
}

/* Dashboard h1 has no back button, so use different layout */
.home-screen > h1 {
  justify-content: space-between;
  position: relative;
}

.home-screen {
  text-align: center;
  padding: 12px 0;
}
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
  margin-top: 20px;
}
.home-card {
  background: linear-gradient(135deg, #e0e0e0 0%, #ffffff 100%);
  color: #333333;
  padding: 25px 10px;
  border-radius: 12px;
  font-size: 16px;
  animation: fadeInScale 0.5s ease-out backwards;
  font-weight: bold;
  cursor: grab;
  transition: 0.2s;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  user-select: none;
}

/* Only prevent touch scrolling when in modify mode */
body.dashboard-modify-mode #dashboardCards .home-card {
  touch-action: none !important;
}
.home-card:active {
  cursor: grabbing;
}
.home-card:hover {
  transform: translateY(-3px);
}
.home-card-icon {
  font-size: 32px;
}
.home-card span {
  word-break: break-word;
  overflow-wrap: break-word;
  text-align: center;
  width: 100%;
  line-height: 1.2;
}
#dashboardCards:not(.list-view) .shortcut-card span {
  font-size: 13px;
  line-height: 1.3;
}

/* Stats card styling */
.stats-card {
  position: relative;
}

.stats-card-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.stats-card-icon {
  font-size: 40px;
  line-height: 1;
}

.stats-card-value {
  font-size: 28px;
  font-weight: bold;
  color: var(--accent);
  line-height: 1;
}

.stats-card-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.2;
}

.stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.2;
}

html[data-theme="dark"] .stats-card-label {
  color: #b8c1d1 !important;
}

html[data-theme="dark"] .stat-label {
  color: #b8c1d1 !important;
}

html[data-theme="dark"] .stat-card-content {
  color: #b8c1d1 !important;
}

html[data-theme="light"] .stats-card-label {
  color: #555555 !important;
}

html[data-theme="light"] .stat-label {
  color: #555555 !important;
}

html[data-theme="light"] .stat-card-content {
  color: #555555 !important;
}

html[data-theme="dark"] .stats-card-value {
  color: #4CAF50;
}

html[data-theme="dark"] .stat-value {
  color: #4CAF50;
}

html[data-theme="light"] .stats-card-value {
  color: #2196F3;
}

html[data-theme="light"] .stat-value {
  color: #2196F3;
}

.back-btn,
.temp-theme-btn {
  margin: 0;
  font-weight: bold;
  padding: 6px 10px !important;
  font-size: 14px !important;
  line-height: 1;
  height: auto;
  display: flex;
  align-items: center;
}
.global-controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
  justify-content: flex-start;
}
.global-control-btn {
  min-width: 140px;
}
html[data-theme="dark"] .home-card span,
html[data-theme="dark"] #dashboardCards .home-card span {
  color: #e8eef5 !important;
}
html[data-theme="light"] .home-card span,
html[data-theme="light"] #dashboardCards .home-card span {
  color: #222222 !important;
}

h1, h2, h3 {
  margin-bottom: 8px;
}

label {
  margin-right: 8px;
  font-weight: 600;
}

input, select, button, textarea {
  margin: 4px 0;
  padding: 4px 6px;
  font-size: 14px;
}

/* Mobile-first: larger touch targets for better usability */
input, select, button, textarea {
  margin: 4px 0;
  padding: 10px 12px;
  font-size: 16px;
  min-height: 44px;
  border-radius: 6px;
  box-sizing: border-box;
}

/* Smaller buttons for exercise library actions */
.exercise-edit-btn,
.exercise-duplicate-btn,
.exercise-delete-btn {
  padding: 6px 8px !important;
  min-height: 36px !important;
  font-size: 16px !important;
  width: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px !important;
}

button {
  cursor: pointer;
  border-radius: 6px;
  border: 1px solid #888;
  background: #f5f5f5;
  color: #000;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

button:hover {
  background: #ddd;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
  transform: translateY(-2px);
}

button:active {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  transform: translateY(0);
}

/* Exercise sets table styling for Log/Start section */
.ex-set-number,
.ex-reps-number,
.ex-weight-input {
  height: auto !important;
  min-height: 32px !important;
  padding: 4px !important;
  font-size: 13px !important;
  line-height: 1.4 !important;
  box-sizing: border-box !important;
}

.ex-set-delete-btn {
  height: 22px !important;
  max-height: 22px !important;
  line-height: 1 !important;
  width: 22px !important;
  padding: 0 !important;
  margin: 0 !important;
  vertical-align: middle !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-sizing: border-box !important;
}

.ex-set-inline-add-btn {
  height: 22px !important;
  max-height: 22px !important;
  width: 22px !important;
  min-width: 22px !important;
  line-height: 1 !important;
  padding: 0 !important;
  margin: 0 !important;
  vertical-align: middle !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-sizing: border-box !important;
}

/* Mobile: ensure consistent sizing for set/reps/weight inputs */
@media (max-width: 600px) {
  .ex-set-number,
  .ex-reps-number,
  .ex-weight-input {
    min-height: 38px !important;
    padding: 6px !important;
    font-size: 14px !important;
  }
  
  .ex-set-delete-btn {
    height: 24px !important;
    max-height: 24px !important;
    width: 24px !important;
  }

  .ex-set-inline-add-btn {
    height: 24px !important;
    max-height: 24px !important;
    width: 24px !important;
    min-width: 24px !important;
  }
}

.search-clear-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  font-size: 20px;
  color: #888;
  cursor: pointer;
  padding: 0 !important;
  margin: 0 !important;
  min-height: 0 !important;
  height: 20px;
  width: 20px;
  line-height: 20px;
  display: none !important;
  transition: color 0.2s;
  outline: none;
  box-shadow: none;
}

.search-clear-btn:hover {
  background: transparent !important;
  color: #333;
  transform: translateY(-50%) !important;
}

.search-clear-btn:active {
  transform: translateY(-50%) !important;
}

.search-clear-btn:focus {
  outline: none !important;
}

.search-clear-btn[style*="display: block"] {
  display: inline-block !important;
}

.primary-action-btn {
  background: var(--card-bg);
  color: var(--text);
  border: 1px solid var(--border);
  font-weight: 500;
  height: 36px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.primary-action-btn:hover {
  background: rgba(0, 0, 0, 0.05);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
  transform: translateY(-2px);
}

.primary-action-btn:active {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  transform: translateY(0);
}

/* Smaller buttons for compact controls */
.compact-btn {
  padding: 6px 12px !important;
  min-height: auto !important;
  font-size: 14px !important;
}

/* Card-based design system */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover {
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
  transform: translateY(-1px);
}

/* Elevated variant for modals/overlays */
.card.elevated {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.card.elevated:hover {
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.2);
  transform: translateY(-2px);
}

/* Card container for grid layouts */
.card-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

html[data-theme="dark"] .primary-action-btn {
  background: #5a9fd4;
  border-color: #5a9fd4;
  color: #ffffff !important;
}

html[data-theme="dark"] .primary-action-btn:hover {
  background: #4a8fbd;
  border-color: #4a8fbd;
  box-shadow: 0 0 12px rgba(90, 159, 212, 0.3);
}

html[data-theme="dark"] button {
  background: #2d3748 !important;
  color: #e8eef5 !important;
  border: 1px solid #4a5568 !important;
  transition: all 0.2s ease !important;
}

html[data-theme="dark"] button:hover {
  background: #3d4a5f !important;
  border-color: #5a9fd4 !important;
  box-shadow: 0 0 8px rgba(90, 159, 212, 0.2) !important;
}

html[data-theme="dark"] button:active {
  background: #2d3748 !important;
  transform: scale(0.98);
}

html[data-theme="dark"] button:disabled {
  opacity: 0.5 !important;
  cursor: not-allowed !important;
}

/* Subtle highlight when a panel opens */
.flash-open {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 2px rgba(90, 159, 212, 0.2), 0 6px 12px rgba(0, 0, 0, 0.3);
  transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

/* Override: Log pagination buttons use light/dark styling */
/* Override: Log pagination buttons use light/dark styling */
/* Override: Log pagination buttons use light/dark styling */
#dashboardModifyBtn {
  background: #ffffff !important;
  color: #000000 !important;
  border: 1px solid rgba(0,0,0,0.1) !important;
  padding: 10px 24px;
  font-size: 16px;
  font-weight: 400;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s ease;
  margin-bottom: 80px;
}

#dashboardModifyBtn:hover {
  background: #f0f0f0 !important;
  border-color: #000000 !important;
}

html[data-theme="dark"] #dashboardModifyBtn {
  background: #5a9fd4 !important;
  color: #ffffff !important;
  border-color: #5a9fd4 !important;
}

html[data-theme="dark"] #dashboardModifyBtn:hover {
  background: #4a8fbd !important;
  border-color: #4a8fbd !important;
  box-shadow: 0 0 12px rgba(90, 159, 212, 0.3) !important;
}

/* Theme button and back button styling */
.temp-theme-btn,
.back-btn {
  border: none !important;
  background: var(--header-bg) !important;
  color: var(--header-text) !important;
  margin: 0 !important;
  font-weight: bold !important;
  padding: 6px 10px !important;
  font-size: 14px !important;
  line-height: 1 !important;
  height: auto !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.temp-theme-btn.hidden {
  visibility: hidden !important;
  pointer-events: none !important;
}

html[data-theme="dark"] .temp-theme-btn,
html[data-theme="dark"] .back-btn {
  padding: 10px 16px;
  background: #2d3748;
  color: #e8eef5;
  border: 1px solid #4a5568;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

html[data-theme="dark"] .temp-theme-btn:hover,
html[data-theme="dark"] .back-btn:hover {
  background: #3d4a5f;
  border-color: #5a9fd4;
}

.theme-action-btn {
  padding: 10px 16px;
  background: #f5f5f5;
  color: #000000;
  border: 1px solid #888;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

html[data-theme="dark"] .theme-action-btn {
  background: #2d3748;
  color: #e8eef5;
  border: 1px solid #4a5568;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

html[data-theme="dark"] .theme-action-btn:hover {
  background: #3d4a5f;
  border-color: #5a9fd4;
}

/* Settings and actions panel styling */
.theme-action-btn:hover {
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
  transform: translateY(-2px);
}

.theme-action-btn:active {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  transform: translateY(0);
}

/* Settings (Tools) overrides */
/* Logs overrides */
/* Styling for new frequency control buttons and import/export buttons */
/* Workout section overrides */
/* Collapsible headers: light style when collapsed, theme when expanded */
/* Inputs in Workout params: light-style */
.exercise-edit-btn,
.exercise-duplicate-btn,
.exercise-delete-btn {
  /* Match drag-handle styling */
  background: rgba(5, 5, 5, 0);
  color: var(--text);
  opacity: 0.7;
  border: none;
  padding: 4px;
  border-radius: 4px;
  cursor: pointer;
  transition: opacity 0.2s, background 0.2s;
  font-size: inherit;
}

.exercise-edit-btn:hover,
.exercise-duplicate-btn:hover,
.exercise-delete-btn:hover {
  opacity: 1;
}

html[data-theme="dark"] .exercise-edit-btn,
html[data-theme="dark"] .exercise-duplicate-btn,
html[data-theme="dark"] .exercise-delete-btn {
  /* Override global dark button styles */
  background: rgba(5, 5, 5, 0) !important;
  color: var(--text) !important;
  border: none !important;
  padding: 6px 8px !important;
  min-height: 36px !important;
  font-size: 16px !important;
  width: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Restore standard button edges for Manage Exercises action buttons */
#manageExercisesSection .exercise-edit-btn,
#manageExercisesSection .exercise-duplicate-btn,
#manageExercisesSection .exercise-delete-btn {
  background: #eee;
  color: #000;
  border: 1px solid #888;
  padding: 4px 8px;
  border-radius: 6px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

#manageExercisesSection .exercise-edit-btn:hover,
#manageExercisesSection .exercise-duplicate-btn:hover,
#manageExercisesSection .exercise-delete-btn:hover {
  background: #ddd;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
  transform: translateY(-2px);
}

#manageExercisesSection .exercise-edit-btn:active,
#manageExercisesSection .exercise-duplicate-btn:active,
#manageExercisesSection .exercise-delete-btn:active {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  transform: translateY(0);
}

html[data-theme="dark"] #manageExercisesSection .exercise-edit-btn,
html[data-theme="dark"] #manageExercisesSection .exercise-duplicate-btn,
html[data-theme="dark"] #manageExercisesSection .exercise-delete-btn {
  background: #2d3748 !important;
  color: #e8eef5 !important;
  border-color: #4a5568 !important;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

html[data-theme="dark"] #manageExercisesSection .exercise-edit-btn:hover,
html[data-theme="dark"] #manageExercisesSection .exercise-duplicate-btn:hover,
html[data-theme="dark"] #manageExercisesSection .exercise-delete-btn:hover {
  background: #5a9fd4 !important;
  border-color: #5a9fd4 !important;
  box-shadow: 0 6px 12px rgba(90, 159, 212, 0.2);
}

/* Stronger override for any exercise action buttons in dark theme */
html[data-theme="dark"] .exercise-actions button {
  background: rgba(5, 5, 5, 0) !important;
  color: var(--text) !important;
  border: none !important;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 8px 0;
}

/* Compact rows: small, left-aligned buttons */
.compact-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-start;
  margin: 6px 0;
}

.compact-row > button,
.compact-row > div {
  flex: 0 0 auto !important;
  min-height: 32px;
  padding: 6px 10px;
  font-size: 13px;
}

.row > button,
.row > div {
  flex: 1 1 auto;
}

/* Generate workout section */
#generateWorkoutContent .row {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}

#generateWorkoutSection .min-max-row {
  gap: 12px !important;
  margin: 10px 0;
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
}

#generateWorkoutSection .min-max-row .input-block {
  flex: 0 1 auto !important;
  min-width: 140px !important;
  max-width: none !important;
  margin: 0 !important;
}

/* Voice Trainer focus mode styles */
#voiceTrainerCurrentCombo {
  position: relative;
  min-height: 400px;
  transition: all 0.3s ease;
}

#voiceTrainerCurrentCombo.focus-mode {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  height: 100dvh !important; /* Dynamic viewport height for mobile browsers */
  max-width: none !important;
  max-height: none !important;
  padding: 40px 40px 140px 40px !important;
  margin: 0 !important;
  border-radius: 0 !important;
  border: none !important;
  z-index: 9999 !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  background: #ffffff !important;
  overflow: hidden !important;
  box-sizing: border-box !important;
  touch-action: none !important; /* Prevent touch scrolling on mobile */
  -webkit-overflow-scrolling: touch !important;
}

/* Add single semi-transparent background block for all text in focus mode */
#voiceTrainerCurrentCombo.focus-mode::before {
  content: '';
  position: absolute;
  background: rgba(var(--card-bg-rgb, 255, 255, 255), 0.95);
  padding: 40px 60px;
  border-radius: 16px;
  backdrop-filter: blur(8px);
  z-index: 1001;
  /* Size to contain all child elements */
  min-width: 60%;
  min-height: 40%;
  max-width: 90%;
}

/* Ensure share button is visible above background in focus mode */
#voiceTrainerCurrentCombo.focus-mode #voiceTrainerShareHistory {
  z-index: 1003 !important;
  position: absolute !important;
}

/* Ensure text appears above the background */
#voiceTrainerCurrentCombo.focus-mode > div {
  position: relative;
  z-index: 1002;
}

/* Previous/Next combo items styling */
.voice-trainer-preview-combo {
  font-size: 14px;
  color: var(--text-muted);
  opacity: 0.5;
  transition: opacity 0.3s ease;
  line-height: 1.4;
}

/* Show only 3 previous/next in normal mode */
#voiceTrainerPreviousCombos .voice-trainer-preview-combo:nth-child(n+4),
#voiceTrainerNextCombos .voice-trainer-preview-combo:nth-child(n+4) {
  display: none;
}

/* Focus mode: show all 10 with fade effect */
#voiceTrainerCurrentCombo.focus-mode #voiceTrainerPreviousCombos .voice-trainer-preview-combo,
#voiceTrainerCurrentCombo.focus-mode #voiceTrainerNextCombos .voice-trainer-preview-combo {
  display: block !important;
  font-size: 18px;
  margin: 4px 0;
}

/* Fade effect for far away combos in focus mode */
/* Previous combos: fade from oldest (top) to newest (bottom) */
#voiceTrainerCurrentCombo.focus-mode #voiceTrainerPreviousCombos .voice-trainer-preview-combo:nth-last-child(10) {
  opacity: 0.15;
}

#voiceTrainerCurrentCombo.focus-mode #voiceTrainerPreviousCombos .voice-trainer-preview-combo:nth-last-child(9) {
  opacity: 0.2;
}

#voiceTrainerCurrentCombo.focus-mode #voiceTrainerPreviousCombos .voice-trainer-preview-combo:nth-last-child(8) {
  opacity: 0.25;
}

#voiceTrainerCurrentCombo.focus-mode #voiceTrainerPreviousCombos .voice-trainer-preview-combo:nth-last-child(7) {
  opacity: 0.3;
}

#voiceTrainerCurrentCombo.focus-mode #voiceTrainerPreviousCombos .voice-trainer-preview-combo:nth-last-child(6) {
  opacity: 0.35;
}

#voiceTrainerCurrentCombo.focus-mode #voiceTrainerPreviousCombos .voice-trainer-preview-combo:nth-last-child(5) {
  opacity: 0.45;
}

#voiceTrainerCurrentCombo.focus-mode #voiceTrainerPreviousCombos .voice-trainer-preview-combo:nth-last-child(4) {
  opacity: 0.55;
}

#voiceTrainerCurrentCombo.focus-mode #voiceTrainerPreviousCombos .voice-trainer-preview-combo:nth-last-child(3) {
  opacity: 0.65;
}

#voiceTrainerCurrentCombo.focus-mode #voiceTrainerPreviousCombos .voice-trainer-preview-combo:nth-last-child(2) {
  opacity: 0.75;
}

#voiceTrainerCurrentCombo.focus-mode #voiceTrainerPreviousCombos .voice-trainer-preview-combo:nth-last-child(1) {
  opacity: 0.85;
}

/* Next combos: fade from nearest (top) to furthest (bottom) */
#voiceTrainerCurrentCombo.focus-mode #voiceTrainerNextCombos .voice-trainer-preview-combo:nth-child(1) {
  opacity: 0.85;
}

#voiceTrainerCurrentCombo.focus-mode #voiceTrainerNextCombos .voice-trainer-preview-combo:nth-child(2) {
  opacity: 0.75;
}

#voiceTrainerCurrentCombo.focus-mode #voiceTrainerNextCombos .voice-trainer-preview-combo:nth-child(3) {
  opacity: 0.65;
}

#voiceTrainerCurrentCombo.focus-mode #voiceTrainerNextCombos .voice-trainer-preview-combo:nth-child(4) {
  opacity: 0.55;
}

#voiceTrainerCurrentCombo.focus-mode #voiceTrainerNextCombos .voice-trainer-preview-combo:nth-child(5) {
  opacity: 0.45;
}

#voiceTrainerCurrentCombo.focus-mode #voiceTrainerNextCombos .voice-trainer-preview-combo:nth-child(6) {
  opacity: 0.35;
}

#voiceTrainerCurrentCombo.focus-mode #voiceTrainerNextCombos .voice-trainer-preview-combo:nth-child(7) {
  opacity: 0.3;
}

#voiceTrainerCurrentCombo.focus-mode #voiceTrainerNextCombos .voice-trainer-preview-combo:nth-child(8) {
  opacity: 0.25;
}

#voiceTrainerCurrentCombo.focus-mode #voiceTrainerNextCombos .voice-trainer-preview-combo:nth-child(9) {
  opacity: 0.2;
}

#voiceTrainerCurrentCombo.focus-mode #voiceTrainerNextCombos .voice-trainer-preview-combo:nth-child(10) {
  opacity: 0.15;
}

/* Immediate previous combo (last in previous list) slightly more visible */
#voiceTrainerPreviousCombos .voice-trainer-preview-combo:last-child {
  opacity: 0.9;
  font-weight: 500;
}

#voiceTrainerCurrentCombo.focus-mode #voiceTrainerPreviousCombos .voice-trainer-preview-combo:last-child {
  opacity: 0.9 !important;
  font-weight: 500;
}

/* Next up combo (first in next list) slightly more visible */
#voiceTrainerNextCombos .voice-trainer-preview-combo:first-child {
  opacity: 0.9;
  font-weight: 500;
}

/* Focus mode: show prev/next combos */
#voiceTrainerCurrentCombo.focus-mode #voiceTrainerPreviousCombos,
#voiceTrainerCurrentCombo.focus-mode #voiceTrainerNextCombos {
  display: flex !important;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 auto;
  min-height: 0;
}

#voiceTrainerCurrentCombo.focus-mode #voiceTrainerPreviousCombos {
  margin-bottom: 20px;
  justify-content: flex-end;
}

#voiceTrainerCurrentCombo.focus-mode #voiceTrainerNextCombos {
  margin-top: 20px;
  justify-content: flex-start;
}

/* Hide countdown in focus mode (it's integrated into next combos) */
#voiceTrainerCurrentCombo.focus-mode #voiceTrainerCountdown {
  display: none !important;
}

#voiceTrainerCurrentCombo.focus-mode #voiceTrainerRoundCounter {
  margin-bottom: 2px !important;
}

#voiceTrainerCurrentCombo.focus-mode #voiceTrainerComboText {
  font-size: 56px !important;
  margin: 2px 0 !important;
}

#voiceTrainerCurrentCombo.focus-mode #voiceTrainerDuration {
  margin-top: 2px !important;
  margin-bottom: 20px !important;
}

/* Mobile landscape mode adjustments for focus mode */
@media (max-width: 926px) and (orientation: landscape) {
  #voiceTrainerCurrentCombo.focus-mode {
    bottom: 36px !important;
    height: calc(100dvh - 36px) !important;
    min-height: 0 !important;
    padding: 0 8px !important;
  }
  
  #voiceTrainerCurrentCombo.focus-mode #voiceTrainerRoundCounter {
    font-size: 10px !important;
    padding: 2px 6px !important;
    margin-bottom: 1px !important;
  }
  
  #voiceTrainerCurrentCombo.focus-mode #voiceTrainerComboText {
    font-size: 18px !important;
    padding: 6px 10px !important;
    margin: 1px 0 !important;
  }
  
  #voiceTrainerCurrentCombo.focus-mode #voiceTrainerDuration {
    font-size: 13px !important;
    padding: 2px 6px !important;
    margin-top: 1px !important;
  }
  
  #voiceTrainerCurrentCombo.focus-mode ~ .row.focus-controls {
    padding: 3px !important;
  }
  
  .row.focus-controls button {
    min-height: 20px !important;
    padding: 3px 6px !important;
    font-size: 8px !important;
  }
  
  #voiceTrainerCurrentCombo.focus-mode #voiceTrainerPreviousCombos,
  #voiceTrainerCurrentCombo.focus-mode #voiceTrainerNextCombos {
    position: absolute !important;
    left: 8px !important;
    right: 8px !important;
    overflow: hidden !important;
    gap: 1px !important;
    display: flex !important;
    flex-direction: column !important;
  }
  
  #voiceTrainerCurrentCombo.focus-mode #voiceTrainerPreviousCombos {
    justify-content: flex-end !important;
  }
  
  #voiceTrainerCurrentCombo.focus-mode #voiceTrainerNextCombos {
    justify-content: flex-start !important;
  }
  
  .voice-trainer-preview-combo {
    font-size: 7px !important;
    line-height: 1.1 !important;
  }
  
  #voiceTrainerShareHistory,
  #voiceTrainerShareCombos {
    min-height: 20px !important;
    padding: 3px 6px !important;
    font-size: 8px !important;
    line-height: 1 !important;
  }
}

/* Tablet landscape mode adjustments for focus mode */
@media (min-width: 927px) and (orientation: landscape) {
  #voiceTrainerCurrentCombo.focus-mode {
    bottom: 48px !important;
    height: calc(100dvh - 48px) !important;
    min-height: 0 !important;
    padding: 0 20px !important;
  }
  
  #voiceTrainerCurrentCombo.focus-mode #voiceTrainerRoundCounter {
    font-size: 18px !important;
    padding: 4px 12px !important;
    margin-bottom: 2px !important;
  }
  
  #voiceTrainerCurrentCombo.focus-mode #voiceTrainerComboText {
    font-size: 36px !important;
    padding: 10px 16px !important;
    margin: 2px 0 !important;
  }
  
  #voiceTrainerCurrentCombo.focus-mode #voiceTrainerDuration {
    font-size: 24px !important;
    padding: 4px 12px !important;
    margin-top: 2px !important;
  }
  
  #voiceTrainerCurrentCombo.focus-mode ~ .row.focus-controls {
    padding: 6px !important;
  }
  
  .row.focus-controls button {
    min-height: 32px !important;
    padding: 5px 10px !important;
    font-size: 12px !important;
  }
  
  #voiceTrainerCurrentCombo.focus-mode #voiceTrainerPreviousCombos,
  #voiceTrainerCurrentCombo.focus-mode #voiceTrainerNextCombos {
    position: absolute !important;
    left: 20px !important;
    right: 20px !important;
    overflow: hidden !important;
    gap: 2px !important;
    display: flex !important;
    flex-direction: column !important;
  }
  
  #voiceTrainerCurrentCombo.focus-mode #voiceTrainerPreviousCombos {
    justify-content: flex-end !important;
  }
  
  #voiceTrainerCurrentCombo.focus-mode #voiceTrainerNextCombos {
    justify-content: flex-start !important;
  }
  
  .voice-trainer-preview-combo {
    font-size: 11px !important;
    line-height: 1.15 !important;
  }
  
  #voiceTrainerShareHistory,
  #voiceTrainerShareCombos {
    min-height: 32px !important;
    padding: 5px 10px !important;
    font-size: 12px !important;
    line-height: 1 !important;
  }
}

#voiceTrainerCurrentCombo.focus-mode #voiceTrainerCountdown {
  font-size: 36px !important;
  margin-top: 12px !important;
  min-height: 45px !important;
}

/* Control buttons overlay in focus mode */
#voiceTrainerSection .row.focus-controls {
  gap: 8px;
  justify-content: center;
}

#voiceTrainerCurrentCombo.focus-mode ~ .row.focus-controls {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10000;
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  padding: 12px;
  display: flex;
}

.row.focus-controls button {
  min-height: 40px;
  padding: 8px 12px;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#generateWorkoutSection .min-max-row input,
#generateWorkoutSection .min-max-row select {
  width: 100%;
}

#generateWorkoutContent .time-rest-row {
  gap: 12px !important;
  margin: 8px 0;
  align-items: flex-end;
  display: flex;
  flex-wrap: wrap;
}

#generateWorkoutContent .time-rest-row > div,
#generateWorkoutContent .time-rest-row > .input-block {
  flex: 1 1 calc(50% - 6px) !important;
  min-width: 140px;
  max-width: none !important;
  margin-right: 0 !important;
}

#generateWorkoutContent .time-rest-row .input-block {
  margin-bottom: 0;
}

#generateWorkoutContent .time-rest-row input {
  width: 100%;
}

#generateWorkoutContent {
  max-width: 100%;
  padding: 0;
}

#generateWorkoutContent label {
  font-size: 16px;
  font-weight: 600;
}

#yourWorkoutContainer {
  padding-bottom: 20px;
}

#logPanel {
  margin-bottom: 20px;
}

#generateWorkoutContent .row > button {
  flex: 1 1 auto;
  min-width: 120px;
}

/* Log entry buttons layout */
#logList .exercise-card > div[style*="position:absolute"] {
  flex-direction: column;
  gap: 6px;
  right: 6px;
  top: 6px;
}

#logList .exercise-card {
  padding-bottom: 120px;
  min-height: 220px;
  align-items: flex-start;
  padding-right: 20px;
  position: relative;
  overflow: visible;
}


















/* Manual workout list */
.manual-exercise-list {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: var(--panel-bg, var(--card-bg));
}

.manual-category {
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.manual-category:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.manual-category-header {
  font-weight: bold;
  margin-bottom: 6px;
  color: var(--text);
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
}

.manual-exercise-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-bottom: 4px;
  color: var(--text);
}

.manual-exercise-row input {
  margin-right: 6px;
}

.manual-exercise-name {
  font-weight: 600;
}

.manual-exercise-meta {
  color: var(--muted-text, #666);
  font-size: 12px;
}

.import-json-textarea {
  width: 100%;
  min-height: 300px;
  font-family: monospace;
  font-size: 12px;
  box-sizing: border-box;
}

.exercise-main {
  flex: 1;
  font-size: 16px;
}

.exercise-details {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.exercise-detail-row {
  font-size: 12px;
  color: var(--muted-text);
  line-height: 1.35;
  padding-left: 8px;
}

.exercise-detail-row--chips {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.exercise-detail-row--table {
  padding-left: 8px;
}

.exercise-detail-label {
  font-weight: 600;
  color: var(--text);
  margin-right: 4px;
}

.exercise-detail-chips {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  vertical-align: middle;
}

.exercise-detail-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-bg);
  font-size: 12px;
}

.exercise-log-item {
  margin-bottom: 10px;
  padding-left: 10px;
  border-left: 3px solid #ccc;
}

.exercise-log-item-header {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.exercise-log-item-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.exercise-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.drag-handle {
  cursor: grab;
  padding: 8px 12px;
  border-radius: 4px;
  border: 1px solid #bbb;
  background: #eee;
  font-size: 18px;
  user-select: none;
  text-align: center;
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.exercise-actions button {
  padding: 8px 12px;
  font-size: 18px;
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}

.category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 4px;
  margin-top: 12px;
  border: 1px solid #ddd;
}

.category-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.category-header-left strong {
  font-size: 1.17em; /* Match h3 size */
}

.color-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  border: 1px solid #555;
}

#exerciseList .exercise-card {
  background: var(--card-bg); 
  color: var(--text);
}

#workoutOutput .exercise-card {
  background: var(--card-bg); 
  color: var(--text);
}

textarea {
  width: 100%;
  min-height: 80px;
  padding: 8px;
  font-family: monospace;
}

.category-color-border {
  border-left-width: 5px;
  border-left-style: solid;
}

.section-header {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 20px;
  align-items: stretch;
}

.section-header > .input-block {
  width: 100%;
  margin-right: 0;
}

.section-header > .row {
  display: flex;
  flex-direction: row;
  gap: 8px;
  width: 100%;
  align-items: flex-end;
  flex-wrap: wrap;
}

.section-header > .row .input-block {
  flex: 1 1 auto;
  min-width: 200px;
}

.section-header > .row .input-block:last-child {
  flex: 0 0 auto;
  min-width: 120px;
}

.section-header > .row button {
  flex: 0 0 auto;
  white-space: normal;
  max-width: 140px;
  line-height: 1.3;
}

.section-header > .row .input-block:first-child {
  flex: 1;
}

.section-header > .row .input-block input,
.section-header > .row .input-block button {
  width: 100%;
}

.section-header > .row .input-block input[type="text"] {
  flex: 1;
}

.section-header > .row .input-block input[type="color"] {
  width: 60px;
  height: 44px;
}

.small-input {
  max-width: 120px;
}

.input-block {
  display: flex;
  flex-direction: column;
  margin-right: 12px;
  margin-bottom: 16px;
  gap: 8px;
}

.input-block label {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 0;
}

.input-block input,
.input-block select,
.input-block textarea {
  min-height: 44px;
  padding: 10px 12px;
  font-size: 16px;
}

/* Generator content specific layout */
#generateWorkoutContent .row .input-block {
  flex: 1 1 auto;
  min-width: 0;
  margin-right: 0;
}

#generateWorkoutContent .row .input-block:last-child {
  flex: 0 0 auto;
  min-width: 120px;
}

#generateWorkoutContent .row .input-block label {
  font-size: 14px;
  margin-bottom: 4px;
}

#generateWorkoutContent .row .input-block input,
#generateWorkoutContent .row .input-block select {
  min-height: 44px;
  font-size: 16px;
}




select[multiple] {
  min-width: 180px;
  min-height: 120px;
}

.flex-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.divider {
  margin: 16px 0;
  border-bottom: 1px solid #ccc;
}

h1, h2, h3 {
  font-size: 1.5em;
  margin-top: 12px;
  margin-bottom: 8px;
}

h1 {
  font-size: 1.75em;
}

@media print {
  body * {
    visibility: hidden !important;
  }

  .print-section, .print-section * {
    visibility: visible !important;
  }

  .print-section {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
  }
}

.exercise-note-block {
  border: 1px solid #ddd;
  padding: 10px;
  border-radius: 6px;
  margin-bottom: 10px;
  background: #fafafa;
  box-sizing: border-box; /* ensure padding is included in width calculations */
  width: 100%;
}

.exercise-note-block strong {
  color: #333;
  font-weight: bold;
}

.exercise-category {
  color: #555;
}

/* Dark theme: make note block use panel styles */
html[data-theme="dark"] .exercise-note-block {
  background: var(--panel-bg, #1b1f26) !important;
  border: 1px solid rgba(255, 255, 255, 0.14) !important;
  color: var(--text) !important;
}

html[data-theme="dark"] .exercise-note-block strong {
  color: var(--text);
}

html[data-theme="dark"] .exercise-category {
  color: var(--muted-text, #bbb);
}

html[data-theme="dark"] .exercise-note-block textarea {
  background: var(--panel-bg, #1b1f26) !important;
  color: var(--text) !important;
  border: 1px solid rgba(255, 255, 255, 0.14) !important;
}

/* Exercise form styling */
.exercise-note-block textarea {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  margin-top: 6px !important;
}

.drag-handle {
  cursor: grab;
  font-size: 20px;
  padding: 4px 8px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none; 
}
.drag-handle:active {
  cursor: grabbing;
}

.exercise-card {
  display: flex;
  justify-content: space-between; /* left + right */
  align-items: center;            /* vertical alignment */
  padding: 8px;
  gap: 12px;                      /* optional spacing */
  border: 1px solid var(--border, #d0d0d0);
  border-radius: 6px;
  margin-bottom: 8px;
  background: var(--section-bg, var(--card-bg));
  touch-action: none;
}

.exercise-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drag-ghost { opacity: 0.4; }

.exercise-actions {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: 8px; /* space between buttons */
  min-width: 80px; /* prevents wrapping */
  white-space: nowrap; /* keeps them on one line */
}

/* Workout List Styles */
.workout-category-group {
  margin-bottom: 24px;
}

.workout-category-header {
  color: var(--text);
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--border);
}

.workout-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 8px;
  background: var(--card-bg);
  transition: all 0.2s ease;
}

.workout-list-item:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.workout-item-name {
  flex: 1;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 4px;
  align-items: baseline;
}

.workout-item-name strong {
  color: var(--text);
  font-size: 16px;
}

.workout-item-count {
  color: var(--muted-text);
  font-size: 13px;
  margin-left: 4px;
}

.workout-item-name > div {
  width: 100%;
}

.workout-item-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.workout-action-btn {
  background: var(--card-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  min-height: 36px;
  height: 36px;
}

.workout-action-btn:hover {
  background: var(--border);
  transform: scale(1.1);
}

.workout-action-btn:active {
  transform: scale(0.95);
}

#workoutSearch {
  width: 100% !important;
  min-width: 200px;
  box-sizing: border-box;
}

.exercise-actions button {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.category-checkbox-container {
  display: block;
  columns: 2;
  column-gap: 0;
  width: 100%;
  max-width: 600px;
}

.category-checkbox-container label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px 0;
  break-inside: avoid;
  font-size: 16px;
  min-height: 44px;
}

#generateWorkoutContent .category-checkbox-container input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
  flex-shrink: 0;
  margin: 0;
}

.category-checkbox-container .color-dot {
  flex-shrink: 0;
  align-self: center;
}

.category-checkbox-container input[type="checkbox"] {
  flex-shrink: 0;
  margin: 0;
  width: 16px;
  height: 16px;
}

html[data-theme="light"] input[type="checkbox"],
html[data-theme="light"] .category-checkbox-container input[type="checkbox"] {
  accent-color: #000000;
}

html[data-theme="dark"] input[type="checkbox"],
html[data-theme="dark"] .category-checkbox-container input[type="checkbox"] {
  accent-color: #5a9fd4;
}

html[data-theme="dark"] input[type="text"],
html[data-theme="dark"] input[type="number"],
html[data-theme="dark"] input[type="email"],
html[data-theme="dark"] input[type="password"],
html[data-theme="dark"] input[type="date"],
html[data-theme="dark"] input[type="datetime-local"],
html[data-theme="dark"] input[type="time"],
html[data-theme="dark"] textarea,
html[data-theme="dark"] select {
  background: #1a1f2a !important;
  color: #e8eef5 !important;
  border: 1px solid #3d4556 !important;
  border-radius: 4px;
}

html[data-theme="dark"] input[type="text"]:focus,
html[data-theme="dark"] input[type="number"]:focus,
html[data-theme="dark"] input[type="email"]:focus,
html[data-theme="dark"] input[type="password"]:focus,
html[data-theme="dark"] input[type="date"]:focus,
html[data-theme="dark"] input[type="datetime-local"]:focus,
html[data-theme="dark"] input[type="time"]:focus,
html[data-theme="dark"] textarea:focus,
html[data-theme="dark"] select:focus {
  border-color: #5a9fd4 !important;
  box-shadow: 0 0 0 3px rgba(90, 159, 212, 0.1) !important;
  outline: none !important;
}

html[data-theme="dark"] input::placeholder {
  color: #8a94a8 !important;
}

html[data-theme="dark"] textarea::placeholder {
  color: #8a94a8 !important;
}

/* Keep category labels horizontal in both views */

/* Smaller checkboxes in list view generator */



:root {
  --text: #000000;
  --card-bg: #f2f2f2;
  --border: #d0d0d0;
  --panel-bg: #f7f7f7;
  --muted-text: #555555;
}

html[data-theme="dark"] {
  --bg: #0f1117;
  --text: #e8eef5;
  --text-secondary: #b8c1d1;
  --text-tertiary: #8a94a8;
  --card-bg: #252d39;
  --border: #3d4556;
  --panel-bg: #1a1f2a;
  --muted-text: #b8c1d1;
  --header-bg: #1a1f2a;
  --header-text: #e8eef5;
  --accent: #5a9fd4;
  --success: #4caf50;
  --error: #f44336;
  --warning: #ff9800;
  --info: #2196f3;
}

body {
  background: var(--bg);
  color: var(--text);
}

.home-card {
  background: linear-gradient(135deg, #e0e0e0 0%, #ffffff 100%);
}

.exercise-card,
.category-header {
  background: var(--card-bg);
}

.drag-handle {
  color: var(--text);
  opacity: 0.7;
  cursor: grab;
  padding: 4px;
  border-radius: 4px;
  touch-action: none;
  transition: opacity 0.2s, background 0.2s;
}

.drag-handle:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .drag-handle:hover, .drag-handle {
  background: rgba(5, 5, 5, 0);
}

.home-card {
  background: linear-gradient(135deg, #e0e0e0 0%, #ffffff 100%);
  color: #333333;
  border: 1px solid var(--border);
  cursor: grab;
  -webkit-user-select: none; 
  user-select: none; 
  -webkit-touch-callout: none;
  pointer-events: auto;
  align-items: center; 
  position: relative;
  transition: all 0.2s ease;
}

.home-card:hover span {
  color: var(--text);
}

.home-card:hover {
  background: rgba(255,255,255,0.1);
}

html[data-theme="dark"] .home-card:hover {
  background: #303a4a;
  border-color: #5a9fd4;
  box-shadow: 0 4px 12px rgba(90, 159, 212, 0.15);
}

/* Light theme gradient for dashboard tiles */
html[data-theme="light"] .home-card,
html[data-theme="light"] #dashboardCards .home-card,
.home-card,
#dashboardCards .home-card,
#dashboardCards [data-tile-id="manageMuscleGroups"],
#dashboardCards [data-tile-id="help"] {
  background: linear-gradient(135deg, #e0e0e0 0%, #ffffff 100%) !important;
  color: #333333 !important;
}

/* Dark theme gradient for dashboard tiles */
html[data-theme="dark"] .home-card,
html[data-theme="dark"] #dashboardCards .home-card,
html[data-theme="dark"] #dashboardCards [data-tile-id="manageMuscleGroups"],
html[data-theme="dark"] #dashboardCards [data-tile-id="help"] {
  background: linear-gradient(135deg, #3a4556 0%, #1c222c 100%) !important;
  color: #e8eef5 !important;
}

/* In dark theme, use light gray backgrounds for inputs/textareas/selects (similar to button color)
   and use dark text for readability against the light background. */
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
  background: #2a2d35;
  color: #f4f6f8;
  border: 1px solid #5a6370;
}

#toggleLogViewBtn { display: none; }

.calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-top: 10px;
}

.calendar-day {
  padding: 6px 4px;
  text-align: center;
  border-radius: 6px;
  cursor: pointer;
  background: var(--card-bg);
  color: var(--text);
  border: 1px solid rgba(0,0,0,0.1);
  position: relative;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  word-wrap: break-word;
  overflow: hidden;
}

html[data-theme="dark"] .calendar-day {
  border: 1px solid rgba(255,255,255,0.1);
}

/* Days from adjacent months appear lighter */
.calendar-day.other-month {
  opacity: 0.4;
  font-style: italic;
}

.calendar-day.has-workout::after {
  content: '★';
  position: absolute;
  top: 4px;
  right: 4px;
  color: #4caf50;
  font-size: 14px;
  line-height: 1;
  background: var(--card-bg);
  border-radius: 50%;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.calendar-day.has-workout {
  position: relative;
}

/* Heatmap colors based on workout frequency */
.calendar-day.heatmap-1 {
  background: rgba(76, 175, 80, 0.2);
}

.calendar-day.heatmap-2 {
  background: rgba(76, 175, 80, 0.4);
}

.calendar-day.heatmap-3 {
  background: rgba(76, 175, 80, 0.6);
}

.calendar-day.heatmap-4 {
  background: rgba(76, 175, 80, 0.8);
}

/* Dark theme heatmap adjustments */
html[data-theme="dark"] .calendar-day.heatmap-1 {
  background: rgba(76, 175, 80, 0.25);
}

html[data-theme="dark"] .calendar-day.heatmap-2 {
  background: rgba(76, 175, 80, 0.45);
}

html[data-theme="dark"] .calendar-day.heatmap-3 {
  background: rgba(76, 175, 80, 0.65);
}

html[data-theme="dark"] .calendar-day.heatmap-4 {
  background: rgba(76, 175, 80, 0.85);
}

.calendar-day:hover {
  opacity: 0.8;
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-weight: bold;
  margin-top: 10px;
  margin-bottom: 4px;
  color: var(--text);
}

.calendar-day.selected {
  outline: 2px solid #858585;
  outline-offset: -2px;
  border-radius: 6px;
}

html[data-theme="dark"] .calendar-day.selected {
  outline: 2px solid #7c7c7c;
}

.calendar-day.today {
  outline: 3px solid #4caf50;
  outline-offset: -2px;
  border-radius: 6px;
}

html[data-theme="dark"] .calendar-day.today {
  outline: 2px solid #ffffff;
}

html[data-theme="light"] .calendar-day.today {
  outline: 2px solid #000000;
}

/* Mobile: constrain calendar day height and prevent text wrapping */
@media (max-width: 768px) {
  .calendar-day {
    min-height: 80px;
    max-height: 80px;
    overflow: hidden;
  }
  
  .calendar-day > div {
    overflow: hidden;
  }
  
  .calendar-day div[style*="white-space: pre"] {
    white-space: pre !important;
    overflow: hidden !important;
    word-break: normal !important;
    line-height: 1.2em;
    max-height: calc(1.2em * 4);
  }
}

.home-card, .card-grid {
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

.card-grid {
  pointer-events: auto;
}

/* Responsive grid: 4 columns on desktop, 2 on mobile */
#dashboardCards { 
  display: grid; 
  grid-template-columns: repeat(4, 1fr); 
  grid-auto-rows: 150px; 
  gap: 12px; 
}

/* Tiles can specify their column span (1-4) */
#dashboardCards .home-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
  margin: 0;
  padding: 20px 10px;
  border-radius: 8px;
  box-sizing: border-box;
  background: linear-gradient(135deg, #e0e0e0 0%, #ffffff 100%);
  color: #333333;
}

/* Stretch trend cards so charts use full width (matches reporting tiles) */
#dashboardCards .trend-card {
  align-items: stretch;
  justify-content: stretch;
  padding: 12px;
}

#dashboardCards .trend-card > div {
  width: 100%;
}

/* Dashboard modify mode: hide add-tile and remove buttons by default */
.add-tile-card {
  display: none !important;
}

#dashboardCards .remove-tile-btn {
  display: none !important;
}

#dashboardCards .settings-tile-btn {
  display: none !important;
}

/* Show add-tile and remove buttons when dashboard is in modify mode */
body.dashboard-modify-mode .add-tile-card {
  display: flex !important;
  border: 2px dashed rgba(0, 0, 0, 0.3) !important;
  background: var(--card-bg) !important;
}

html[data-theme="dark"] body.dashboard-modify-mode .add-tile-card {
  border: 2px dashed rgba(255, 255, 255, 0.3) !important;
}

body.dashboard-modify-mode #dashboardCards .remove-tile-btn {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 !important;
  width: 28px !important;
  height: 28px !important;
  font-size: 20px !important;
  min-height: auto !important;
  line-height: 1 !important;
}

body.dashboard-modify-mode #dashboardCards .settings-tile-btn {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 !important;
  width: 28px !important;
  height: 28px !important;
  font-size: 16px !important;
  min-height: auto !important;
  line-height: 1 !important;
  background: none !important;
  border: none !important;
  cursor: pointer !important;
}

body.dashboard-modify-mode #dashboardCards .settings-tile-btn:hover {
  background: rgba(33, 150, 243, 0.2) !important;
  border-radius: 4px !important;
}

body.dashboard-modify-mode #dashboardCards .remove-tile-btn:hover {
  background: var(--panel-bg, var(--card-bg)) !important;
  filter: brightness(1.06);
}

/* Normalize dashboard tile panel buttons so Save/Add matches Cancel sizing */
.tile-panel-cancel,
.tile-panel-confirm {
  min-height: 40px;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.2;
  min-width: 120px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Legacy tile modal buttons (Add/Cancel) */
#cancelTileModal,
#confirmTileModal {
  min-height: 40px;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.2;
  min-width: 120px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Home card icon styling */
#dashboardCards .home-card .home-card-icon {
  font-size: 36px;
  margin-bottom: 8px;
}

/* Home card text/label */
#dashboardCards .home-card span {
  text-align: center;
  font-size: 14px;
  font-weight: 500;
}

/* Reporting card: block layout to accommodate charts */
#dashboardCards .reporting-card.home-card {
  display: flex !important;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 0 !important;
  overflow: visible;
}

.pie-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  padding: 20px;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  overflow: hidden;
  box-sizing: border-box;
}

.pie-wrap canvas {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  pointer-events: auto;
}

/* Chart wrapper for frequency/bar charts */
.chart-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  padding: 20px;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.chart-wrap canvas {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
}

/* Mobile: 2-column grid for better proportions on small screens */
@media (max-width: 600px) {
  #dashboardCards {
    grid-template-columns: repeat(2, 1fr) !important;
    grid-auto-rows: 180px !important;
    gap: 8px !important;
  }
  
  #dashboardCards .reporting-card.mobile-full {
    grid-column: 1 / -1 !important;
    grid-row: span 2 !important;
    width: 100% !important;
  }
  
  .home-screen {
    padding: 12px 0 !important;
  }
}

/* Reporting card - larger tile with charts */
.reporting-card {
  cursor: default !important;
  padding: 15px !important;
  overflow: visible; /* allow message banner to display above charts */
}

.reporting-card.reporting-compact {
  padding: 10px !important;
}

/* On mobile, remove padding from reporting cards */
@media (max-width: 600px) {
  .reporting-card {
    padding: 0 !important;
  }
  
  .reporting-card.reporting-compact {
    padding: 0 !important;
  }
}

.reporting-card:hover {
  transform: none;
}

/* Internal reporting grid layout and chart box styles */
.reporting-card .reporting-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  height: auto; /* avoid stretching grid to full tile height */
  min-height: 300px; /* baseline in grid view */
  align-items: center; /* vertical centering of chart boxes */
}

.reporting-card .reporting-grid > div {
  background: var(--bg);
  padding: 10px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.reporting-card canvas {
  width: 100% !important;
  height: auto !important; /* avoid height:100% causing giant canvases */
  max-height: 280px; /* grid view cap */
  display: block;
  margin: 0 auto;
}

.reporting-card.reporting-compact canvas {
  max-height: 120px;
  min-height: 120px;
}

.reporting-card.reporting-compact .reporting-grid {
  min-height: 0;
  height: 100%;
  align-items: center;
}

@media (max-width: 768px) {
  .reporting-card .reporting-grid {
    grid-template-columns: 1fr !important; /* stack charts vertically on small screens */
  }
  .reporting-card canvas {
    width: 100% !important;
    height: auto !important;
    max-height: 240px !important;
    min-height: 0 !important;
  }
  #dashboardCards .reporting-card.home-card {
    justify-content: center !important;
    align-items: center !important;
    padding: 10px !important;
  }
  .pie-wrap {
    position: relative;
    width: 100%;
    height: 100%;
    padding: 15px;
    margin: 0 auto;
    box-sizing: border-box;
  }
  .pie-wrap canvas {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
  }
}

@media (max-width: 480px) {
  .reporting-card canvas {
    max-height: 140px !important;
  }
}

/* Center the add-shortcut tile icon */
.add-tile-card {
  justify-content: center;
}

/* Dashboard modify mode: hide add-tile and remove buttons by default */
.add-tile-card {
  display: none !important;
}

#dashboardCards .remove-tile-btn {
  display: none !important;
}

#dashboardCards .settings-tile-btn {
  display: none !important;
}

/* Show add-tile and remove buttons when dashboard is in modify mode */
body.dashboard-modify-mode .add-tile-card {
  display: flex !important;
  border: 2px dashed rgba(0, 0, 0, 0.3) !important;
  background: var(--card-bg) !important;
}

html[data-theme="dark"] body.dashboard-modify-mode .add-tile-card {
  border: 2px dashed rgba(255, 255, 255, 0.3) !important;
}

body.dashboard-modify-mode #dashboardCards .remove-tile-btn:hover {
  background: rgba(255, 0, 0, 0.2);
}

/* Collapsible Sections */
.collapsible-section {
  margin: 10px 0;
}

.collapsible-header {
  width: 100%;
  text-align: left;
  padding: 10px;
  background: #f0f0f0;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
  font-size: 18px;
  transition: background 0.2s;
  min-height: 44px;
  display: flex;
  align-items: center;
}

.collapsible-header:hover {
  background: #e0e0e0;
}

/* Collapsible content styling */
.collapsible-content {
  padding: 0;
}


/* Improve touch behavior for dashboard tiles */
#dashboardCards .home-card {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: pan-y;
}





/* Shortcut delete (✕) button should visually blend with the tile */
#dashboardCards .home-card .remove-tile-btn {
  background: var(--panel-bg, var(--card-bg));
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px;
  min-width: 28px;
  min-height: 28px;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: 2px;
  right: 4px;
  line-height: 1;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  z-index: 10;
  pointer-events: auto;
}

#dashboardCards .home-card .settings-tile-btn {
  background: var(--panel-bg, var(--card-bg));
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px;
  min-width: 28px;
  min-height: 28px;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: 2px;
  right: 36px;
  line-height: 1;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  z-index: 10;
  pointer-events: auto;
}

html[data-theme="dark"] #dashboardCards .home-card .remove-tile-btn {
  background: var(--panel-bg, #1b1f26) !important;
  color: var(--text) !important;
  border: 1px solid rgba(255,255,255,0.14) !important;
}

html[data-theme="dark"] #dashboardCards .home-card .settings-tile-btn {
  background: var(--panel-bg, #1b1f26) !important;
  color: var(--text) !important;
  border: 1px solid rgba(255,255,255,0.14) !important;
}


#dashboardCards .home-card .remove-tile-btn:hover {
  filter: brightness(1.06);
}

#dashboardCards .home-card .settings-tile-btn:hover {
  background: var(--panel-bg, var(--card-bg)) !important;
  filter: brightness(1.06);
}

.collapsible-content {
  padding: 0;
  overflow: hidden;
  box-sizing: border-box;
  border-top: 1px solid transparent; /* prevents margin collapse from children showing when collapsed */
  max-height: 0;
  transition: max-height 0.28s ease, padding 0.2s ease;
}

.collapsible-content.open {
  padding: 10px 0;
  max-height: 1200px; /* large enough for content, allows smooth expand */
}

/* Accessibility focus outline */
.collapsible-header:focus {
  outline: 2px solid #007bff;
  outline-offset: 2px;
}

.action-message {
  font-size: 13px;
  min-height: 18px;
}

.action-message:empty {
  display: none;
  min-height: 0;
  margin: 0 !important;
  padding: 0 !important;
}

/* Tile colors handled in inline <style> in HTML head for maximum priority */

/* Chart containers responsive layout */
.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin: 20px 0;
}

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

/* Dummy data banner: keep compact and single-line */
.reporting-card #dummyDataMessage {
  display: inline-block; /* allow JS to toggle display */
  margin: 0 auto 6px auto; /* center horizontally with tighter gap */
  padding: 4px 8px;
  white-space: nowrap; /* avoid wrapping */
  overflow: hidden;
  text-overflow: ellipsis; /* truncate if extremely narrow */
  max-width: 100%;
  line-height: 1.2;
}

/* Reporting section chart canvases - constrain to fit container */
#reporting7DayCategoryChart,
#reporting7DayFrequencyChart {
  max-width: 90%;
  height: auto;
  display: block;
  margin: 0 auto;
}

/* ========================= */
/*     NAVIGATION BAR        */
/* ========================= */
.nav-bar {
  position: fixed;
  left: 0;
  right: 0;
  width: 100%;
  background: #ffffff;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  z-index: 1000;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
}

html[data-theme="dark"] .nav-bar {
  background: #1f232b;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.3);
}

.nav-bar.position-bottom {
  bottom: 0;
}

.nav-bar.position-top {
  top: 0;
  border-top: none;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

html[data-theme="dark"] .nav-bar.position-top {
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.nav-bar.position-topbottom {
  position: relative;
  border: none;
  box-shadow: none;
  background: transparent;
}

.nav-bar.position-topbottom .nav-items-top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  max-width: none;
  margin: 0;
  z-index: 1000;
  background: white;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.nav-bar.position-topbottom .nav-items-bottom {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  max-width: none;
  margin: 0;
  z-index: 1000;
  background: white;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
}

html[data-theme="dark"] .nav-bar.position-topbottom .nav-items-top {
  background: #1e1e1e;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

html[data-theme="dark"] .nav-bar.position-topbottom .nav-items-bottom {
  background: #1e1e1e;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.3);
}

.nav-items {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-around;
  align-items: center;
  padding: 8px 0;
  max-width: 1000px;
  margin: 0 auto;
  gap: 4px;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 16px;
  background: linear-gradient(135deg, #e0e0e0 0%, #ffffff 100%);
  border: 1px solid rgba(0, 0, 0, 0.1);
  cursor: pointer;
  color: #333333;
  transition: background 0.2s, transform 0.1s;
  border-radius: 8px;
  flex: 0 1 auto;
  min-width: 80px;
  width: 100px;
  min-height: 90px;
}

.nav-item:hover {
  background: rgba(0, 0, 0, 0.05);
}

html[data-theme="dark"] .nav-item:hover {
  background: rgba(0, 0, 0, 0.4) !important;
}

.nav-item:active {
  transform: scale(0.95);
}

.nav-item.active {
  background: linear-gradient(135deg, #c5c5c5 0%, #e5e5e5 100%);
  font-weight: bold;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15);
}

/* Landscape: compact navigation bar (non-focus modes, mobile/tablet only) */
@media (orientation: landscape) and (max-width: 900px) {
  body:not(.workout-focus-mode):not(.voice-trainer-focus-mode) .nav-items {
    padding: 2px 0 !important;
    gap: 2px !important;
  }

  body:not(.workout-focus-mode):not(.voice-trainer-focus-mode) .nav-item {
    padding: 2px 6px !important;
    min-width: 56px !important;
    width: 68px !important;
    min-height: 42px !important;
    gap: 2px !important;
    border-radius: 6px !important;
  }

  body:not(.workout-focus-mode):not(.voice-trainer-focus-mode) .nav-icon {
    font-size: 16px !important;
    line-height: 1 !important;
  }

  body:not(.workout-focus-mode):not(.voice-trainer-focus-mode) .nav-label {
    font-size: 9px !important;
    line-height: 1.1 !important;
    -webkit-line-clamp: 1 !important;
    line-clamp: 1 !important;
  }

  body.nav-bar-visible.nav-bar-bottom:not(.workout-focus-mode):not(.voice-trainer-focus-mode) {
    padding-bottom: 42px !important;
  }

  body.nav-bar-visible.nav-bar-top:not(.workout-focus-mode):not(.voice-trainer-focus-mode) {
    padding-top: 42px !important;
  }
}

/* Exercise Sets Table Default Styling */
.exercise-sets-table {
  max-width: 320px;
}

/* Hide exercise info button by default (only shown in focus mode) */
.ex-info-toggle {
  display: none !important;
}

/* Edit Modal Exercise List Styles */
#editModalExerciseList {
  background: var(--card-bg);
}

.edit-exercise-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-bottom: 6px;
  background: var(--card-bg);
  transition: box-shadow 0.2s;
}

.edit-exercise-item:hover {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.edit-exercise-item .drag-handle {
  font-size: 18px;
  color: var(--muted-text);
  cursor: grab;
  padding: 4px;
  margin: -4px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.edit-exercise-item .drag-handle:active {
  cursor: grabbing;
}

.edit-exercise-drag-handle {
  cursor: grab;
  user-select: none;
  font-size: 18px;
  color: var(--text-secondary, #666);
  padding: 4px;
  margin: -4px;
  touch-action: none;
  -webkit-user-select: none;
}

.edit-exercise-name {
  flex: 1;
  font-weight: 500;
  color: var(--text);
}

.edit-exercise-clone-btn {
  background: transparent;
  border: 1px solid #ccc;
  font-size: 16px;
  cursor: pointer;
  color: #555;
  padding: 4px 8px;
  border-radius: 4px;
  line-height: 1;
  transition: background 0.2s;
  margin-right: 4px;
}

.edit-exercise-clone-btn:hover {
  background: #f0f0f0;
}

.edit-exercise-remove-btn {
  background: transparent;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: #666;
  padding: 4px;
  line-height: 1;
  transition: opacity 0.2s;
}

.edit-exercise-remove-btn:hover {
  opacity: 0.6;
}

html[data-theme="dark"] .edit-exercise-item {
  background: #1c222c;
  border-color: rgba(255, 255, 255, 0.1);
}

html[data-theme="dark"] .edit-exercise-drag-handle {
  color: rgba(255, 255, 255, 0.5);
}

html[data-theme="dark"] .edit-exercise-clone-btn {
  border-color: rgba(255, 255, 255, 0.15);
}

html[data-theme="dark"] .edit-exercise-clone-btn:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* Dark theme nav item styling: darker chips with lighter text/icons */
html[data-theme="dark"] .nav-item {
  background: linear-gradient(135deg, #2a3240 0%, #1c222c 100%) !important;
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  box-shadow: none !important;
}

html[data-theme="dark"] .nav-item.active {
  background: linear-gradient(135deg, #2a3240 0%, #1a2028 100%) !important;
  font-weight: bold;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.4) !important;
}

html[data-theme="dark"] .nav-icon,
html[data-theme="dark"] .nav-label {
  color: #f5f7fb;
}

.nav-icon {
  font-size: 24px;
}

.nav-label {
  font-size: 12px;
  font-weight: 500;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
}

/* Add padding to body when nav bar is shown */
body.nav-bar-visible.nav-bar-bottom {
  padding-bottom: 70px;
}

body.nav-bar-visible.nav-bar-top {
  padding-top: 0;
  /* Padding is set dynamically by JavaScript based on actual nav bar height */
}

/* Adjust home screen for nav bar */
body.nav-bar-visible.nav-bar-bottom .home-screen,
body.nav-bar-visible.nav-bar-bottom .app-section {
  padding-bottom: 20px;
}

#logStartWorkoutSection .input-block:has(#logStartDurationInput) {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
}

#logStartWorkoutSection .input-block:has(#logStartDurationInput) p {
  margin: 0;
  white-space: nowrap;
}

#logStartWorkoutSection .input-block:has(#logStartDurationInput) > div {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0;
}

/* When nav is bottom on small screens, tighten top padding on content */
@media (max-width: 600px) {
  body.nav-bar-visible.nav-bar-bottom .home-screen,
  body.nav-bar-visible.nav-bar-bottom .app-section {
    padding-top: 4px;
  }
  body.nav-bar-visible.nav-bar-bottom .home-screen {
    padding-top: 8px;
  }
}

body.nav-bar-visible.nav-bar-top .home-screen,
body.nav-bar-visible.nav-bar-top .app-section {
  padding-top: 18px;
}

/* Dashboard (home-screen) needs less padding since it's the home page */
body.nav-bar-visible.nav-bar-top .home-screen {
  padding-top: 22px;
}

/* Tighter top spacing on small screens when nav is top-docked */
@media (max-width: 600px) {
  body.nav-bar-visible.nav-bar-top {
    padding-top: 80px;
  }

  body.nav-bar-visible.nav-bar-top .home-screen,
  body.nav-bar-visible.nav-bar-top .app-section {
    padding-top: 14px;
  }


}

/* Ensure h1/h2 title bars have consistent spacing from top when nav bar is at top */
body.nav-bar-visible.nav-bar-top .home-screen > h1,
body.nav-bar-visible.nav-bar-top .app-section > h1,
body.nav-bar-visible.nav-bar-top .app-section > h2 {
  margin-top: 0;
}

/* Add spacing to Reset App button when nav bar is visible */
body.nav-bar-visible.nav-bar-bottom #resetAppBtn {
  margin-bottom: 20px;
}

/* Nav tab order customization in settings */
#navTabOrderList .nav-order-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  background: var(--bg);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 6px;
  cursor: move;
  touch-action: none;
}

html[data-theme="dark"] #navTabOrderList .nav-order-item {
  border-color: rgba(255, 255, 255, 0.1);
}

#navTabOrderList .nav-order-item .drag-handle {
  font-size: 18px;
  color: var(--muted-text);
  cursor: grab;
  padding: 4px;
  margin: -4px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#navTabOrderList .nav-order-item .drag-handle:active {
  cursor: grabbing;
}

#navTabOrderList .nav-order-item .nav-order-label {
  flex: 1;
  font-weight: 500;
}

#navTabOrderList .nav-remove-btn {
  background: #ffffff;
  border: 1px solid #888;
  border-radius: 4px;
  color: #000000;
  padding: 4px 8px;
  cursor: pointer;
  font-weight: bold;
  font-size: 14px;
  line-height: 1;
}

#navTabOrderList .nav-remove-btn:hover {
  background: #f0f0f0;
}

html[data-theme="dark"] #navTabOrderList .nav-remove-btn {
  background: rgba(244, 67, 54, 0.15);
  border-color: rgba(244, 67, 54, 0.4);
}

#navTabOrderList .nav-separator-item {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  font-weight: 600;
  text-align: center;
  border: 2px dashed rgba(255, 255, 255, 0.5);
}

#navTabOrderList .nav-separator-item .drag-handle {
  color: rgba(255, 255, 255, 0.8);
}

#navTabOrderList .nav-separator-item .nav-order-label {
  color: white;
  text-align: center;
  letter-spacing: 1px;
}

/* Navigation and UI panel styling */
/* Removed obsolete color theme references */

/* Dashboard add tile modal buttons (inline styled) - override with IDs */
/* Nav add shortcut dialog buttons */
/* Removed obsolete color theme references */

/* ===== ELEMENT STYLING FOR LIGHT AND DARK THEMES ===== */
/* These elements maintain consistent styling across both themes */

/* Manage Workouts section */
/* Workout card action buttons - Log/Start, Edit, Clone, Delete */
/* Dashboard tile buttons */
/* Edit Workout modal buttons - override theme colors */
/* Generate Workout section */
/* Log/Start Workout section buttons - but preserve inline styles for timer buttons */
/* Manual Select section */
/* Edit Workout section (Manual Edit mode) */
/* Edit Log section */
/* Force timer buttons to white for all non-dark themes */
/* Override global button rule for workout action buttons in all non-dark themes */
/* Manual Workout Name Block - visually distinct from exercise list */
#manualWorkoutNameBlock {
  background: var(--input-bg, rgba(255, 255, 255, 0.05));
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px;
  margin-bottom: 16px;
}

#manualWorkoutNameBlock .input-block {
  margin-bottom: 12px;
}

#manualWorkoutNameBlock .input-block:last-of-type {
  margin-bottom: 0;
}

/* Category-specific row styling (like Manage Exercises) */
#manualWorkoutNameBlock .input-block:first-of-type > label,
#manualWorkoutNameBlock .input-block:nth-of-type(2) > label {
  font-size: 15px;
  font-weight: 700;
}

/* Force radio buttons in dashboard modal to use black accent across all themes */
#dashboardModal input[type="radio"] {
  accent-color: #000 !important;
}

/* ========================= */
/*    TOAST NOTIFICATIONS    */
/* ========================= */
.toast-container {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 400px;
  pointer-events: none;
}

@media (max-width: 600px) {
  .toast-container {
    top: 70px;
    right: 12px;
    left: 12px;
    max-width: none;
  }
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  pointer-events: auto;
  opacity: 0;
  transform: translateX(400px);
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.toast-show {
  opacity: 1;
  transform: translateX(0);
}

.toast-hide {
  opacity: 0;
  transform: translateX(400px);
  transition: all 0.3s ease-in;
}

.toast-content {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.toast-icon {
  font-size: 18px;
  font-weight: bold;
  flex-shrink: 0;
}

.toast-message {
  font-size: 14px;
  line-height: 1.4;
  word-wrap: break-word;
}

.toast-action,
.toast-close {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  padding: 6px 12px;
  border-radius: 4px;
  transition: background 0.2s;
  min-height: auto;
}

.toast-action {
  color: #1976d2;
}

.toast-action:hover {
  background: rgba(25, 118, 210, 0.1);
}

.toast-close {
  font-size: 20px;
  color: #666;
  padding: 4px 8px;
  line-height: 1;
}

.toast-close:hover {
  background: rgba(0, 0, 0, 0.05);
  color: #333;
}

/* Toast types */
.toast-success {
  background: #4caf50;
  color: white;
}

.toast-success .toast-icon {
  color: white;
}

.toast-success .toast-action {
  color: white;
  background: rgba(255, 255, 255, 0.2);
}

.toast-success .toast-action:hover {
  background: rgba(255, 255, 255, 0.3);
}

.toast-success .toast-close {
  color: rgba(255, 255, 255, 0.8);
}

.toast-success .toast-close:hover {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

.toast-error {
  background: #f44336;
  color: white;
}

.toast-error .toast-icon {
  color: white;
}

.toast-error .toast-action {
  color: white;
  background: rgba(255, 255, 255, 0.2);
}

.toast-error .toast-action:hover {
  background: rgba(255, 255, 255, 0.3);
}

.toast-error .toast-close {
  color: rgba(255, 255, 255, 0.8);
}

.toast-error .toast-close:hover {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

.toast-warning {
  background: #ff9800;
  color: white;
}

.toast-warning .toast-icon {
  color: white;
}

.toast-warning .toast-action {
  color: white;
  background: rgba(255, 255, 255, 0.2);
}

.toast-warning .toast-action:hover {
  background: rgba(255, 255, 255, 0.3);
}

.toast-warning .toast-close {
  color: rgba(255, 255, 255, 0.8);
}

.toast-warning .toast-close:hover {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

.toast-info {
  background: #2196f3;
  color: white;
}

.toast-info .toast-icon {
  color: white;
}

.toast-info .toast-action {
  color: white;
  background: rgba(255, 255, 255, 0.2);
}

.toast-info .toast-action:hover {
  background: rgba(255, 255, 255, 0.3);
}

.toast-info .toast-close {
  color: rgba(255, 255, 255, 0.8);
}

.toast-info .toast-close:hover {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

/* Dark theme adjustments */
html[data-theme="dark"] .toast:not(.toast-success):not(.toast-error):not(.toast-warning):not(.toast-info) {
  background: #2a2d35;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

html[data-theme="dark"] .toast:not(.toast-success):not(.toast-error):not(.toast-warning):not(.toast-info) .toast-close {
  color: rgba(255, 255, 255, 0.6);
}

html[data-theme="dark"] .toast:not(.toast-success):not(.toast-error):not(.toast-warning):not(.toast-info) .toast-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

/* ========================= */
/*     LOADING SPINNER       */
/* ========================= */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}

.loading-overlay.show {
  opacity: 1;
  visibility: visible;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spinner-rotate 0.8s linear infinite;
}

.spinner-inline {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(0, 0, 0, 0.2);
  border-top-color: #333;
  border-radius: 50%;
  animation: spinner-rotate 0.6s linear infinite;
  vertical-align: middle;
  margin-left: 8px;
}

html[data-theme="dark"] .spinner-inline {
  border-color: rgba(255, 255, 255, 0.3);
  border-top-color: #ffffff;
}

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

/* ========================= */
/*    SMOOTH TRANSITIONS     */
/* ========================= */

/* Global transitions for interactive elements */
button,
.nav-item,
.home-card,
input,
select,
textarea {
  transition: all 0.2s ease;
}

/* Section transitions */
.app-section,
.home-screen {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Card hover effects */
.home-card,
.workout-card,
.exercise-card,
.category-card,
.log-card {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.home-card:hover,
.workout-card:hover,
.exercise-card:hover,
.category-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* Button hover effects */
button:not(:disabled):hover {
  transform: translateY(-1px);
}

button:not(:disabled):active {
  transform: translateY(0);
}

/* Input focus effects */
input:focus,
select:focus,
textarea:focus {
  outline: 2px solid #1976d2;
  outline-offset: 0;
}

/* Modal animations */
.modal {
  animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ========================= */
/*       EMPTY STATES        */
/* ========================= */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted-text, #666);
}

.empty-state-icon {
  font-size: 64px;
  margin-bottom: 20px;
  opacity: 0.5;
}

.empty-state-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text);
}

.empty-state-message {
  font-size: 15px;
  margin-bottom: 24px;
  line-height: 1.5;
}

.empty-state-action {
  margin-top: 20px;
}

.empty-state-action button {
  padding: 12px 24px;
  font-size: 16px;
  font-weight: 600;
  background: var(--primary-color, #1976d2);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  min-height: 44px;
}

.empty-state-action button:hover {
  background: var(--primary-color-hover, #1565c0);
}

html[data-theme="dark"] .empty-state {
  color: #888;
}

html[data-theme="dark"] .empty-state-title {
  color: #e0e0e0;
}

/* ========================= */
/*    CONFIRMATION MODAL     */
/* ========================= */
.confirm-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10001;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.confirm-modal-overlay.show {
  opacity: 1;
  visibility: visible;
}

.confirm-modal {
  background: var(--card-bg, #ffffff);
  border-radius: 12px;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  transform: scale(0.9);
  transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.confirm-modal-overlay.show .confirm-modal {
  transform: scale(1);
}

.confirm-modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border, #e0e0e0);
}

.confirm-modal-title {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}

.confirm-modal-body {
  padding: 24px;
}

.confirm-modal-message {
  margin: 0;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
}

.confirm-modal-footer {
  padding: 16px 24px;
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  border-top: 1px solid var(--border, #e0e0e0);
}

.confirm-modal-cancel,
.confirm-modal-confirm {
  padding: 10px 24px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  min-height: 44px;
  border: none;
  transition: all 0.2s;
}

.confirm-modal-cancel {
  background: var(--bg, #f5f5f5);
  color: var(--text);
  border: 1px solid var(--border, #ddd);
}

.confirm-modal-cancel:hover {
  background: var(--border, #e0e0e0);
}

.confirm-modal-confirm {
  background: #1976d2;
  color: white;
}

.confirm-modal-confirm:hover {
  background: #1565c0;
}

.confirm-modal-confirm.danger {
  background: #d32f2f;
}

.confirm-modal-confirm.danger:hover {
  background: #c62828;
}

html[data-theme="dark"] .confirm-modal {
  background: #2a2d35;
}

html[data-theme="dark"] .confirm-modal-header,
html[data-theme="dark"] .confirm-modal-footer {
  border-color: rgba(255, 255, 255, 0.1);
}

html[data-theme="dark"] .confirm-modal-cancel {
  background: #1f232b;
  border-color: #4a5568;
}

html[data-theme="dark"] .confirm-modal-cancel:hover {
  background: #353942;
}

/* ========================= */
/*    SUCCESS ANIMATIONS     */
/* ========================= */
@keyframes successPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

@keyframes successCheckmark {
  0% { transform: scale(0) rotate(45deg); opacity: 0; }
  50% { transform: scale(1.1) rotate(45deg); opacity: 1; }
  100% { transform: scale(1) rotate(45deg); opacity: 1; }
}

.success-pulse {
  animation: successPulse 0.4s ease;
}

.success-flash {
  animation: successFlash 0.5s ease;
}

@keyframes successFlash {
  0% { background: var(--card-bg); }
  50% { background: #4caf50; color: white; }
  100% { background: var(--card-bg); }
}

/* Success checkmark icon */
.success-icon {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid #4caf50;
  border-radius: 50%;
  position: relative;
  margin-left: 8px;
  vertical-align: middle;
}

.success-icon::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 2px;
  width: 5px;
  height: 10px;
  border: solid #4caf50;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  animation: successCheckmark 0.4s ease;
}

/* ========================= */
/*  SMOOTH TRANSITIONS       */
/* ========================= */
/* Section transitions */
.section {
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.section.active {
  animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Button transitions */
button {
  transition: background-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}

button:active {
  transform: scale(0.98);
}

/* Input focus transitions */
input,
select,
textarea {
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

/* Card hover transitions */
.workout-item,
.exercise-item,
.log-entry,
.dashboard-tile {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  animation: fadeIn 0.4s ease-out backwards;
}

.workout-item:hover,
.exercise-item:hover,
.log-entry:hover,
.dashboard-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Modal transitions */
.confirm-modal-overlay {
  transition: opacity 0.2s ease, backdrop-filter 0.2s ease;
}

.confirm-modal {
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s ease;
  transform: scale(0.9) translateY(-20px);
  opacity: 0;
}

.confirm-modal-overlay.show .confirm-modal {
  transform: scale(1) translateY(0);
  opacity: 1;
}

/* Toast transitions */
.toast {
  transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55), opacity 0.2s ease;
}

/* Loading spinner transitions */
.loading-overlay {
  transition: opacity 0.2s ease, backdrop-filter 0.2s ease;
}

.loading-spinner {
  animation: spin 1s linear infinite;
}

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

/* Nav transitions */
.nav-bar a {
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* Calendar day transitions */
.cal-day {
  transition: background-color 0.2s ease, transform 0.1s ease;
}

.cal-day:hover {
  transform: scale(1.05);
}

/* Chart transitions */
.chart-container {
  animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ========================= */
/* PULL TO REFRESH           */
/* ========================= */
.pull-to-refresh-indicator {
  position: fixed;
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  opacity: 0;
  transition: opacity 0.2s ease, top 0.2s ease;
  pointer-events: none;
}

.pull-to-refresh-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(76, 175, 80, 0.3);
  border-top-color: #4CAF50;
  border-radius: 50%;
  transition: transform 0.1s ease;
}

.pull-to-refresh-spinner.spinning {
  animation: spin 1s linear infinite;
}

.pull-to-refresh-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  text-align: center;
}

/* ===== FILTER MODAL STYLES ===== */
.filter-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10002;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.filter-modal {
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  width: 90%;
  max-width: 500px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.3s ease;
  overflow: hidden;
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

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

.filter-modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.filter-modal-close {
  background: none;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: var(--text);
  padding: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.2s ease;
}

.filter-modal-close:hover {
  background: rgba(0, 0, 0, 0.1);
}

html[data-theme="dark"] .filter-modal-close:hover {
  background: rgba(255, 255, 255, 0.1);
}

.filter-modal-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.filter-modal-section {
  border: none;
  overflow: visible;
  margin: 0;
  border-bottom: none;
}

.filter-modal-section:last-child {
  border-bottom: none;
}

.filter-section-header {
  width: 100%;
  padding: 4px 12px;
  background: none;
  border: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
  transition: background 0.15s ease;
  min-width: 0;
  gap: 8px;
  box-sizing: border-box;
}

.filter-header-left {
  display: flex;
  align-items: center;
  gap: 0;
  flex: 1;
  min-width: 0;
}

.filter-header-left > span {
  display: inline-block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex-shrink: 1;
}

.filter-count {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted-text);
  margin-left: 4px;
  white-space: nowrap;
}

.filter-section-controls {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
  margin-left: 4px;
}

.filter-section-controls button {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 2px 10px;
  color: var(--muted-text);
  transition: color 0.15s ease;
  line-height: 1;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.filter-section-controls button:hover {
  color: var(--text);
}

.filter-section-header:hover {
  background: rgba(0, 0, 0, 0.05);
}

html[data-theme="dark"] .filter-section-header:hover {
  background: rgba(255, 255, 255, 0.05);
}

.filter-section-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  font-size: 12px;
  white-space: nowrap;
}

.toggle-label::before {
  content: "Expand";
}

.toggle-arrow {
  display: inline-flex;
  align-items: center;
  transition: transform 0.2s ease;
}

.filter-section-header[aria-expanded="true"] .toggle-label::before {
  content: "Minimize";
}

.filter-section-header[aria-expanded="true"] .toggle-arrow {
  transform: rotate(90deg);
}

.filter-section-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 16px 12px 16px;
  animation: none;
  max-height: none;
}

@keyframes slideDown {
  from {
    opacity: 0;
    max-height: 0;
  }
  to {
    opacity: 1;
    max-height: 500px;
  }
}

.filter-checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease;
  user-select: none;
}

.filter-checkbox-item:hover {
  background: rgba(0, 0, 0, 0.05);
}

html[data-theme="dark"] .filter-checkbox-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.filter-checkbox-item input[type="checkbox"] {
  cursor: pointer;
  width: 18px;
  height: 18px;
  min-width: 18px;
}

.filter-checkbox-label {
  flex: 1;
  font-size: 14px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.filter-color-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.filter-modal-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.filter-btn-count {
  font-size: 12px;
}

.applied-filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-left: 8px;
  border-left: 3px solid rgba(37, 99, 235, 0.4);
  margin-bottom: 8px;
}

.applied-filter-group:last-child {
  margin-bottom: 0;
}

.applied-filter-break {
  flex-basis: 100%;
  height: 0;
}

/* Applied filter tags */
.applied-filter-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0px 10px;
  background: rgba(37, 99, 235, 0.1);
  border: 1px solid rgba(37, 99, 235, 0.3);
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.2;
  color: var(--text);
  animation: slideIn 0.2s ease;
  height: 30px;
  overflow: hidden;
  flex-shrink: 0;
  width: fit-content;
  max-width: 100%;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.applied-filter-tag-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.applied-filter-tag-remove {
  background: transparent !important;
  background-color: transparent !important;
  border: none !important;
  color: var(--text);
  cursor: pointer;
  padding: 0 !important;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  min-width: 14px;
  min-height: 14px;
  max-width: 14px;
  max-height: 14px;
  line-height: 14px;
  opacity: 0.7;
  transition: opacity 0.2s ease;
  flex-shrink: 0;
  overflow: hidden;
  appearance: none;
  -webkit-appearance: none;
  box-shadow: none !important;
  border-radius: 0;
  outline: none !important;
}

.applied-filter-tag-remove:hover {
  background: transparent !important;
  opacity: 1;
}

.applied-filter-tag-remove:focus,
.applied-filter-tag-remove:focus-visible {
  outline: none;
  box-shadow: none;
}

/* Preset Buttons */
.preset-btn {
  padding: 8px 12px;
  font-size: 13px;
  background: var(--card-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  min-height: 36px;
}

.preset-btn:hover {
  background: var(--panel-bg);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
  transform: translateY(-2px);
}

.preset-btn:active {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  transform: translateY(0);

.preset-tab-add {
  color: var(--text);
  font-weight: 600;
  border-bottom-color: transparent;
}
}

.preset-btn.empty {
  opacity: 0.5;
  color: var(--muted-text);
}

.preset-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.preset-btn:disabled:hover {
  background: var(--card-bg);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transform: none;
}

.preset-btn.active {
  border-color: rgba(104, 104, 104, 0.8);
  border-width: 2px;
  font-weight: 525;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12);
}

.preset-edit-btn {
  padding: 4px 10px;
  font-size: 13px;
  background: var(--card-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: auto;
  height: 26px;
  display: flex;
  align-items:center;
}

.preset-edit-btn:hover {
  background: var(--panel-bg);
  border-color: var(--accent);
}

/* Preset Edit Modal Tabs */
.preset-tabs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  row-gap: 12px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

.preset-tab {
  padding: 8px 12px;
  font-size: 13px;
  background: none;
  border: none;
  color: var(--muted-text);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
  margin-bottom: -13px;
  padding-bottom: 12px;
}

.preset-tab:hover {
  color: var(--text);
}

.preset-tab.active {
  color: var(--text);
  border-bottom-color: rgba(37, 99, 235, 0.6);
  font-weight: 600;
}

.preset-edit-content {
  padding: 16px;
}

/* Landscape warning overlay for workout sections */
.landscape-warning-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.95);
  z-index: 200000;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  gap: 24px;
  padding: 24px;
  text-align: center;
}

.landscape-warning-overlay.show {
  display: flex;
}

.landscape-warning-icon {
  font-size: 64px;
  animation: rotate-phone 2s ease-in-out infinite;
}

@keyframes rotate-phone {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(90deg); }
}

.landscape-warning-text {
  font-size: 20px;
  font-weight: 600;
  color: white;
  max-width: 400px;
}

.landscape-warning-subtext {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
  max-width: 400px;
}
