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

:root {
  --blue-50: #eff6ff;
  --blue-100: #dbeafe;
  --blue-500: #3b82f6;
  --blue-600: #2563eb;
  --blue-700: #1d4ed8;
  --green-50: #f0fdf4;
  --green-100: #dcfce7;
  --green-200: #bbf7d0;
  --green-light: #86efac;
  --green-dark: #16a34a;
  --green-dark-bg: #dcfce7;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --red-500: #ef4444;
  --red-50: #fef2f2;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
}

html { font-size: 16px; }
body {
  font-family: var(--font);
  color: var(--gray-900);
  background: var(--gray-50);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--blue-600); text-decoration: none; }
a:hover { text-decoration: underline; }

button {
  font-family: var(--font);
  cursor: pointer;
  border: none;
  outline: none;
}

button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--blue-500);
  outline-offset: 2px;
}

input, select, textarea {
  font-family: var(--font);
  font-size: 1rem;
  color: var(--gray-900);
  background: #fff;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  width: 100%;
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--blue-500);
  outline: none;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s, opacity 0.15s;
  white-space: nowrap;
}
.btn-primary { background: var(--blue-600); color: #fff; }
.btn-primary:hover { background: var(--blue-700); }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); }
.btn-secondary:hover { background: var(--gray-200); }
.btn-danger { background: var(--red-50); color: var(--red-500); }
.btn-danger:hover { background: #fee2e2; }
.btn-ghost { background: transparent; color: var(--gray-600); }
.btn-ghost:hover { background: var(--gray-100); }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.card {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--blue-50);
  color: var(--blue-600);
}
.tag-green { background: var(--green-50); color: var(--green-dark); }
.tag-gray { background: var(--gray-100); color: var(--gray-600); }

.form-group { display: flex; flex-direction: column; gap: 0.375rem; }
.form-group label { font-size: 0.875rem; font-weight: 500; color: var(--gray-700); }
.form-error { color: var(--red-500); font-size: 0.8rem; }

.page-header {
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  padding: 0.875rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  position: sticky;
  top: 0;
  z-index: 100;
}
.page-header h1 { font-size: 1.1rem; font-weight: 600; flex: 1; }

.container { max-width: 680px; margin: 0 auto; padding: 0 1rem; }

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--gray-500);
}
.empty-state svg { width: 3rem; height: 3rem; margin-bottom: 1rem; opacity: 0.4; }
.empty-state p { font-size: 0.95rem; }

/* Toast notifications */
.toast-container {
  position: fixed;
  bottom: calc(4rem + 0.75rem);
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
  width: calc(100% - 2rem);
  max-width: 400px;
}
.toast {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toast-in 0.2s ease;
  pointer-events: all;
}
.toast-success { background: var(--green-dark); color: #fff; }
.toast-error { background: var(--red-500); color: #fff; }
.toast-info { background: var(--blue-600); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Nav bar */
.nav-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-top: 1px solid var(--gray-200);
  display: flex;
  z-index: 500;
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  gap: 0.2rem;
  font-size: 0.7rem;
  color: var(--gray-500);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
}
.nav-item.active, .nav-item:hover { color: var(--blue-600); }
.nav-item svg { width: 1.3rem; height: 1.3rem; }

body { padding-bottom: 4rem; }

/* Completion states */
.completion-none { color: var(--gray-400); }
.completion-light { color: var(--green-dark); background: var(--green-100); }
.completion-dark { color: #fff; background: var(--green-dark); }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal-overlay.center { align-items: center; }
.modal {
  background: #fff;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.5rem;
}
.modal.center-modal {
  border-radius: var(--radius-lg);
  margin: 1rem;
}
.modal-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 1rem; }

/* Spinner */
.spinner {
  width: 1.5rem; height: 1.5rem;
  border: 2px solid var(--gray-200);
  border-top-color: var(--blue-600);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Green card overlay */
.exercise-card-wrap.light-green { background: var(--green-100); }
.exercise-card-wrap.dark-green { background: var(--green-dark-bg); }

/* Utility */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-gray { color: var(--gray-500); }
.font-semibold { font-weight: 600; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
