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

:root {
  --bg: #111111;
  --surface: #1a1a1a;
  --surface-hover: #222222;
  --border: #2a2a2a;
  --text: #e8e8e8;
  --text-muted: #888888;
  --accent: #4ade80;
  --accent-hover: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius-card: 12px;
  --radius-btn: 8px;
  --nav-height: 60px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 16px calc(var(--nav-height) + var(--safe-bottom) + 20px);
  min-height: 100dvh;
  animation: fadeIn 0.2s ease;
}

/* ============================================================
   Bottom Navigation
   ============================================================ */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(17, 17, 17, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  z-index: 100;
}

.nav-item {
  flex: 1;
  max-width: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: 100%;
  min-height: 48px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.7rem;
  cursor: pointer;
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.nav-icon {
  font-size: 1.4rem;
  line-height: 1;
}

.nav-label {
  font-weight: 500;
}

.nav-item.active {
  color: var(--accent);
}

/* ============================================================
   App Header
   ============================================================ */

.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(17, 17, 17, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 12px 0 16px;
  margin: -16px -16px 16px;
  padding-left: 16px;
  padding-right: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-header h1 {
  font-size: 1.25rem;
  font-weight: 700;
}

/* ============================================================
   Week Selector
   ============================================================ */

.week-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border-radius: var(--radius-btn);
  padding: 4px 8px;
  border: 1px solid var(--border);
}

.week-selector button {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.week-selector button:active {
  background: var(--surface-hover);
}

.week-selector span {
  font-size: 0.85rem;
  font-weight: 600;
  min-width: 48px;
  text-align: center;
  color: var(--text-muted);
}

/* ============================================================
   Cards
   ============================================================ */

.card {
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  transition: background 0.15s;
}

.card:active {
  background: var(--surface-hover);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
}

.tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 100px;
  background: var(--surface-hover);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.tag--green {
  background: rgba(74, 222, 128, 0.15);
  color: var(--accent);
}

.tag--yellow {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
}

.tag--red {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  padding: 12px 20px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

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

.btn--primary {
  background: var(--accent);
  color: #111111;
}

.btn--primary:active {
  background: var(--accent-hover);
}

.btn--secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn--secondary:active {
  background: var(--surface-hover);
}

.btn--danger {
  background: var(--danger);
  color: #fff;
}

.btn--danger:active {
  background: #dc2626;
}

.btn--sm {
  width: auto;
  min-height: 36px;
  padding: 8px 16px;
  font-size: 0.85rem;
}

/* ============================================================
   Exercise Card (Workout View)
   ============================================================ */

.exercise-card {
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
}

.exercise-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 4px;
}

.exercise-header h3 {
  font-size: 0.95rem;
  font-weight: 700;
}

.exercise-header .target {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.exercise-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  line-height: 1.5;
}

.set-bubbles {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.set-bubble {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  background: transparent;
  -webkit-tap-highlight-color: transparent;
  line-height: 1.1;
}

.set-bubble .set-weight {
  font-size: 0.65rem;
  font-weight: 400;
  opacity: 0.8;
}

.set-bubble--done {
  background: var(--accent);
  border-color: var(--accent);
  color: #111111;
}

.set-bubble--done .set-weight {
  color: #111111;
}

.set-bubble--active {
  border-color: var(--accent);
  color: var(--accent);
  animation: pulse 1.5s ease-in-out infinite;
}

/* ============================================================
   Set Input Modal (Bottom Sheet)
   ============================================================ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 200;
  animation: fadeIn 0.15s ease;
}

.modal-content {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 24px 20px calc(20px + var(--safe-bottom));
  z-index: 201;
  animation: slideUp 0.25s ease;
  max-width: 480px;
  margin: 0 auto;
}

.modal-content h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.modal-content .modal-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.modal-handle {
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 16px;
}

.input-group {
  margin-bottom: 16px;
}

.input-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.input-group input,
.input-group textarea {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  color: var(--text);
  font-size: 1.2rem;
  font-weight: 600;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

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

.input-group textarea {
  font-size: 1rem;
  font-weight: 400;
  resize: vertical;
  min-height: 80px;
}

.input-row {
  display: flex;
  gap: 12px;
}

.input-row .input-group {
  flex: 1;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

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

/* ============================================================
   Workout Header & Progress
   ============================================================ */

.workout-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}

.workout-header h2 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.workout-timer {
  font-size: 0.85rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  padding: 4px 10px;
  white-space: nowrap;
}

.workout-header .exercise-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.workout-progress {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin-bottom: 20px;
  overflow: hidden;
}

.workout-progress .progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.4s ease;
}

.section-divider {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 16px 0 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

/* ============================================================
   Completion Form
   ============================================================ */

.completion-form {
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: 20px;
  margin-top: 20px;
  border: 1px solid var(--border);
}

.completion-form h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.notes-input {
  width: 100%;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
  min-height: 80px;
  outline: none;
  transition: border-color 0.15s;
}

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

/* ============================================================
   History Items
   ============================================================ */

.history-item {
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: 16px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.history-item:active {
  background: var(--surface-hover);
}

.history-date {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.history-item h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.history-stats {
  display: flex;
  gap: 16px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.history-stats span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.history-notes {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 8px;
  font-style: italic;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-detail {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  animation: fadeIn 0.2s ease;
}

.history-detail .section-divider {
  padding-top: 8px;
}

.history-detail .exercise-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 6px 0;
  font-size: 0.85rem;
}

.history-detail .exercise-row .name {
  font-weight: 600;
}

.history-detail .exercise-row .sets-display {
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* ============================================================
   Empty State & Loading
   ============================================================ */

.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  display: block;
}

.empty-state p {
  font-size: 0.9rem;
  line-height: 1.5;
}

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
}

.loading::after {
  content: '';
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* ============================================================
   Today Card (Home View)
   ============================================================ */

.today-card {
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: 20px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
}

.today-card h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.today-card .subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.exercise-preview {
  list-style: none;
  margin-bottom: 16px;
}

.exercise-preview li {
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 4px 0;
  padding-left: 16px;
  position: relative;
}

.exercise-preview li::before {
  content: '•';
  position: absolute;
  left: 0;
  color: var(--border);
}

.day-picker {
  display: flex;
  gap: 8px;
}

.day-picker .btn {
  flex: 1;
  min-height: 36px;
  font-size: 0.8rem;
}

.day-pick-btn--active {
  border-color: var(--accent) !important;
  color: var(--accent) !important;
}

/* ============================================================
   Rest Timer
   ============================================================ */

.rest-timer {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 12px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 100px;
  padding: 8px 20px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  z-index: 90;
  animation: fadeIn 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  font-variant-numeric: tabular-nums;
}

.rest-timer button {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 0 4px;
}

/* ============================================================
   Animations
   ============================================================ */

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.3); }
  50% { box-shadow: 0 0 0 8px rgba(74, 222, 128, 0); }
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

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

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

/* ============================================================
   Utility Classes
   ============================================================ */

.text-muted { color: var(--text-muted); }

/* ============================================================
   Exercise Info Modal
   ============================================================ */

.exercise-info-btn {
  background: none;
  border: none;
  color: var(--text);
  font-size: inherit;
  font-weight: inherit;
  font-family: inherit;
  cursor: pointer;
  padding: 0;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
}

.exercise-info-btn:active {
  opacity: 0.7;
}

.info-modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: var(--bg);
  overflow-y: auto;
  animation: fadeIn 0.2s ease;
  padding: env(safe-area-inset-top, 0) 0 env(safe-area-inset-bottom, 0);
}

.info-modal-header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  position: sticky;
  top: 0;
  background: rgba(17, 17, 17, 0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 1;
}

.info-modal-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  text-align: center;
}

.info-close-btn {
  position: absolute;
  right: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.info-gif {
  width: 60%;
  max-width: 280px;
  margin: 16px auto;
  display: block;
  border-radius: var(--radius-card);
}

.info-body {
  padding: 16px;
  max-width: 480px;
  margin: 0 auto;
}

.info-section {
  margin-bottom: 20px;
}

.info-section h3 {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.info-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.info-instructions {
  list-style: none;
  counter-reset: step;
}

.info-instructions li {
  counter-increment: step;
  padding: 8px 0;
  padding-left: 32px;
  position: relative;
  font-size: 0.9rem;
  line-height: 1.5;
  border-bottom: 1px solid var(--border);
}

.info-instructions li:last-child {
  border-bottom: none;
}

.info-instructions li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 8px;
  width: 24px;
  height: 24px;
  background: var(--surface);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
}

.info-unavailable {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-muted);
}

.info-unavailable .empty-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  display: block;
}
.text-center { text-align: center; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.hidden { display: none !important; }
