:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #818cf8;
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --radius: 12px;
  --font-main: "Inter", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a;
    --surface: #1e293b;
    --surface-2: #334155;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #334155;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.3);
  }
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.5;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* App-like feel */
}

/* App Header */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  z-index: 10;
}

h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
}

.level-badge {
  font-size: 0.75rem;
  padding: 4px 8px;
  background: var(--surface-2);
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
}

/* Main Content Area */
main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

/* Day Selector */
.day-selector {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
  scrollbar-width: none;
}

.day-selector::-webkit-scrollbar {
  display: none;
}

.day-btn {
  white-space: nowrap;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.day-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Dashboard / Workout View */
.workout-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}

.workout-header h2 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.workout-header p {
  opacity: 0.9;
  font-size: 0.9rem;
}

.section-title {
  font-size: 1.1rem;
  margin-bottom: 1rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Exercise List */
.exercise-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding-bottom: 80px; /* Space for timer */
}

.exercise-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: transform 0.2s;
}

.exercise-summary {
  padding: 1rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.exercise-meta {
  flex: 1;
}

.exercise-name {
  font-weight: 600;
  font-size: 1.05rem;
  margin-bottom: 0.25rem;
}

.exercise-reps {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.check-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: white;
  margin-left: 1rem;
  flex-shrink: 0;
  transition: all 0.2s;
}

.check-btn.completed {
  background: var(--success);
  border-color: var(--success);
}

.exercise-details {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
}

.exercise-details.open {
  max-height: 1000px;
}

.details-content {
  padding: 1rem;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.detail-label {
  font-weight: 600;
  color: var(--text-muted);
}

.instructions {
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.6;
}

.detail-header {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--primary-dark);
  margin-top: 1rem;
  margin-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.detail-header:first-child {
  margin-top: 0;
}

.detail-text {
  margin-bottom: 0.75rem;
}

.detail-list {
  padding-left: 1rem;
  margin-bottom: 0.75rem;
  list-style-type: none;
}

.detail-list li {
  margin-bottom: 0.4rem;
  position: relative;
  padding-left: 0.5rem;
}

.detail-list li::before {
  content: "•";
  color: var(--primary);
  font-weight: bold;
  position: absolute;
  left: -1rem;
}

/* Controls */
.action-btn {
  width: 100%;
  padding: 0.75rem;
  border: none;
  background: var(--primary);
  color: white;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1rem;
}

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

/* Modals / Overlays */
.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: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--surface);
  width: 90%;
  max-width: 400px;
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1);
}

.modal h3 {
  margin-bottom: 1rem;
  font-size: 1.25rem;
}

.level-options {
  display: grid;
  gap: 0.5rem;
}

.level-option {
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  text-align: left;
}

.level-option:hover {
  background: var(--surface-2);
}

.level-option.selected {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary-dark);
}

/* Timer Bar */
.timer-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 50;
  box-shadow: 0 -4px 6px -1px rgb(0 0 0 / 0.1);
}

.timer-bar.active {
  transform: translateY(0);
}

.timer-display {
  font-family: monospace;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin-left: 1rem;
}

.timer-controls {
  display: flex;
  gap: 0.5rem;
}

.timer-btn {
  padding: 0.5rem 1rem;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-weight: 600;
  cursor: pointer;
}

.timer-btn.primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Rest / Active Badge */
.status-badge {
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--text-muted);
}
