:root {
  --bg: #0f0f13;
  --bg2: #1a1a24;
  --bg3: #24243a;
  --accent: #6c5ce7;
  --accent2: #a29bfe;
  --green: #00b894;
  --red: #e17055;
  --yellow: #fdcb6e;
  --text: #f0f0f0;
  --text2: #a0a0b0;
  --border: #2d2d44;
  --radius: 12px;
}

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

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  max-width: 480px;
  margin: 0 auto;
  padding-bottom: 80px;
  -webkit-tap-highlight-color: transparent;
}

/* Top Bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar h1 {
  font-size: 20px;
  font-weight: 700;
}

.topbar .back-btn {
  background: none;
  border: none;
  color: var(--accent2);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
}

/* Bottom Nav */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
}

.bottom-nav button {
  flex: 1;
  background: none;
  border: none;
  color: var(--text2);
  padding: 10px 4px;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: color 0.2s;
}

.bottom-nav button.active {
  color: var(--accent2);
}
.bottom-nav button .icon {
  font-size: 20px;
}

/* Pages */
.page {
  display: none;
  padding: 20px;
}
.page.active {
  display: block;
}

/* Cards */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
}

.card-subtitle {
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 4px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
  width: 100%;
}

.btn:active {
  opacity: 0.7;
}

.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-success {
  background: var(--green);
  color: white;
}
.btn-danger {
  background: var(--red);
  color: white;
}
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-sm {
  padding: 8px 14px;
  font-size: 13px;
  width: auto;
}

/* Inputs */
input,
select,
textarea {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
}

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

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

/* Stats Row */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
}

.stat-card .value {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent2);
}

.stat-card .label {
  font-size: 11px;
  color: var(--text2);
  margin-top: 4px;
  text-transform: uppercase;
}

/* Exercise Set Row */
.set-row {
  display: grid;
  grid-template-columns: 40px 1fr 1fr 50px 50px;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.set-row .set-num {
  color: var(--text2);
  font-weight: 600;
  text-align: center;
}

.set-row input {
  padding: 8px;
  text-align: center;
  font-size: 14px;
}

.set-row .check-btn,
.set-row .skip-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: transparent;
  color: var(--text2);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.set-row .check-btn.done {
  background: var(--green);
  border-color: var(--green);
  color: white;
}

.set-row .skip-btn.skipped {
  background: var(--yellow);
  border-color: var(--yellow);
  color: white;
}

.set-header {
  display: grid;
  grid-template-columns: 40px 1fr 1fr 50px 50px;
  gap: 8px;
  padding: 8px 0;
  font-size: 12px;
  color: var(--text2);
  text-transform: uppercase;
  font-weight: 600;
}

/* Exercise card in workout */
.exercise-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
}

.exercise-card .exercise-header {
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}

.exercise-card .exercise-header h3 {
  font-size: 15px;
  font-weight: 600;
}

.exercise-card .exercise-body {
  padding: 0 16px 16px;
}

.exercise-card.completed .exercise-header {
  border-left: 4px solid var(--green);
}

.exercise-card.skipped .exercise-header {
  border-left: 4px solid var(--yellow);
  opacity: 0.6;
}

/* Tags */
.tag {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  margin: 2px 4px 2px 0;
}

.tag-muscle {
  background: rgba(108, 92, 231, 0.2);
  color: var(--accent2);
}
.tag-equipment {
  background: rgba(0, 184, 148, 0.2);
  color: var(--green);
}
.tag-category {
  background: rgba(253, 203, 110, 0.2);
  color: var(--yellow);
}

/* Section */
.section-title {
  font-size: 18px;
  font-weight: 700;
  margin: 20px 0 12px;
}

/* List */
.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

/* Rest Timer */
.rest-timer {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: white;
  padding: 10px 24px;
  border-radius: 30px;
  font-size: 18px;
  font-weight: 700;
  z-index: 200;
  display: none;
  box-shadow: 0 4px 20px rgba(108, 92, 231, 0.5);
}

.rest-timer.visible {
  display: flex;
  align-items: center;
  gap: 10px;
}

.rest-timer .close-timer {
  background: none;
  border: none;
  color: white;
  font-size: 18px;
  cursor: pointer;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 300;
  display: none;
  align-items: flex-end;
  justify-content: center;
}

.modal-overlay.visible {
  display: flex;
}

.modal {
  background: var(--bg2);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px 20px;
}

.modal h2 {
  font-size: 18px;
  margin-bottom: 16px;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
}

.badge-active {
  background: var(--green);
  color: white;
}
.badge-complete {
  background: var(--accent);
  color: white;
}

/* Flex utils */
.flex {
  display: flex;
}
.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.gap-8 {
  gap: 8px;
}
.gap-12 {
  gap: 12px;
}
.mb-8 {
  margin-bottom: 8px;
}
.mb-16 {
  margin-bottom: 16px;
}
.mt-16 {
  margin-top: 16px;
}
.text-center {
  text-align: center;
}
.text-muted {
  color: var(--text2);
}
.text-sm {
  font-size: 13px;
}

/* Day selector */
.day-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 0;
  -webkit-overflow-scrolling: touch;
}

.day-chip {
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text2);
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
}

.day-chip.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* Action buttons row */
.action-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.action-row .btn {
  flex: 1;
}

/* History list */
.history-item {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  cursor: pointer;
}

.history-item .date {
  font-size: 13px;
  color: var(--accent2);
  font-weight: 600;
}

.history-item .meta {
  font-size: 12px;
  color: var(--text2);
  margin-top: 4px;
}

/* Search */
.search-box {
  position: relative;
  margin-bottom: 16px;
}

.search-box input {
  padding-left: 40px;
}

.search-box .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text2);
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 4px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

/* Exercise detail images */
.exercise-images {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 0;
}

.exercise-images img {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--bg3);
}

/* Progress bar */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg3);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 8px;
}

.progress-bar .fill {
  height: 100%;
  background: var(--green);
  border-radius: 3px;
  transition: width 0.3s;
}

/* Workout action buttons */
.workout-actions {
  display: flex;
  gap: 8px;
  padding: 16px 0;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text2);
}

.empty-state .icon {
  font-size: 48px;
  margin-bottom: 12px;
}
.empty-state p {
  font-size: 14px;
}
