* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f0fdf4;
  background-image:
    radial-gradient(circle at 20% 50%, rgba(16,185,129,0.04) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(5,150,105,0.04) 0%, transparent 50%),
    radial-gradient(circle at 50% 80%, rgba(52,211,153,0.03) 0%, transparent 50%);
  background-attachment: fixed;
  color: #1f2937;
  padding-bottom: 70px;
  -webkit-tap-highlight-color: transparent;
}

.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 16px 12px;
}

/* ——— Nav ——— */
.nav-bar {
  display: flex;
  justify-content: space-around;
  align-items: center;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid #e5e7eb;
  padding: 8px 0;
  z-index: 100;
}

.nav-bar a {
  text-decoration: none;
  color: #9ca3af;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 10px;
  transition: all 0.2s ease;
}

.nav-bar a.active {
  color: #10b981;
  font-weight: 700;
  background: rgba(16, 185, 129, 0.08);
}

.nav-bar a:hover {
  color: #10b981;
}

/* ——— Cards ——— */
.card {
  background: #fff;
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06), 0 0 0 1px rgba(0,0,0,0.02);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.08), 0 0 0 1px rgba(0,0,0,0.03);
}

h2 {
  font-size: 22px;
  font-weight: 800;
  color: #111827;
}

h3 {
  font-size: 15px;
  font-weight: 600;
}

/* ——— Forms ——— */
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid #e5e7eb;
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, select:focus, textarea:focus {
  border-color: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

input[type="number"] {
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

textarea {
  resize: vertical;
}

/* ——— Buttons ——— */
.btn-primary {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(16, 185, 129, 0.3);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(16, 185, 129, 0.35);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(16, 185, 129, 0.3);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-secondary {
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #e5e7eb;
}

.btn-secondary:hover {
  background: #e5e7eb;
}

.btn-danger {
  background: #fee2e2;
  color: #dc2626;
  border: 1px solid #fecaca;
}

.btn-danger:hover {
  background: #fecaca;
}

/* ——— Flash ——— */
.flash {
  padding: 10px 14px;
  border-radius: 10px;
  margin-bottom: 12px;
  font-size: 14px;
  animation: slideDown 0.3s ease;
}

.flash.error {
  background: #fee2e2;
  color: #dc2626;
  border: 1px solid #fecaca;
}

.flash.success {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.empty {
  text-align: center;
  color: #9ca3af;
  padding: 32px 16px;
  font-size: 14px;
}

/* ——— Workout cards ——— */
.workout-card {
  transition: transform 0.15s ease;
  animation: fadeIn 0.3s ease;
}

.workout-card:active {
  transform: scale(0.97);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ——— Exercise cards ——— */
.exercise-card {
  animation: fadeIn 0.3s ease;
  position: relative;
}

.exercise-card.dragging {
  opacity: 0.5;
  transform: scale(0.95);
}

.reorder-btn {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
  color: #9ca3af;
  transition: color 0.15s;
  touch-action: manipulation;
}

.reorder-btn:hover {
  color: #10b981;
}

/* ——— Sets table ——— */
.sets-table {
  width: 100%;
  font-size: 14px;
  border-collapse: collapse;
}

.sets-table th {
  text-align: left;
  font-size: 11px;
  color: #9ca3af;
  font-weight: 600;
  padding: 6px 6px;
  border-bottom: 1px solid #f3f4f6;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sets-table td {
  padding: 5px 6px;
  vertical-align: middle;
}

.sets-table tr {
  transition: background 0.15s;
}

.sets-table tr:hover {
  background: #f9fafb;
}

.set-input {
  width: auto;
  padding: 6px 8px;
  font-size: 15px;
  text-align: center;
  border: 1.5px solid #e5e7eb;
  border-radius: 8px;
  transition: all 0.2s ease;
  font-weight: 500;
}

.set-input:focus {
  border-color: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.set-input.saved {
  border-color: #10b981;
  background: #ecfdf5;
}

/* ——— Set type badges ——— */
.set-type-badge {
  display: inline-block;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.set-type-badge.warmup { background: #fef3c7; color: #d97706; }
.set-type-badge.dropset { background: #ede9fe; color: #7c3aed; }
.set-type-badge.failure { background: #fee2e2; color: #dc2626; }

.set-type-select {
  font-size: 11px;
  padding: 3px 4px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  width: auto;
  min-width: 75px;
}

/* Nutrition input with label overlay */
.nutrition-field input[type="number"] {
  padding-right: 28px;
}

/* ——— Totals card ——— */
.totals-card {
  background: linear-gradient(135deg, #ecfdf5, #d1fae5);
  border: 1px solid #a7f3d0;
}

/* ——— Rest Timer ——— */
.timer-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.timer-overlay.active {
  display: flex;
}

.timer-box {
  background: #fff;
  border-radius: 20px;
  padding: 32px 40px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  animation: scaleIn 0.3s ease;
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1); }
}

.timer-display {
  font-size: 64px;
  font-weight: 800;
  color: #10b981;
  font-variant-numeric: tabular-nums;
  margin: 16px 0;
  line-height: 1;
}

.timer-display.warning {
  color: #f59e0b;
}

.timer-display.done {
  color: #10b981;
  animation: pulse 0.5s ease infinite alternate;
}

@keyframes pulse {
  from { transform: scale(1); }
  to { transform: scale(1.05); }
}

.timer-presets {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 12px 0;
}

.timer-preset {
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.timer-preset:hover, .timer-preset.active {
  background: #10b981;
  color: #fff;
  border-color: #10b981;
}

.timer-btn-start {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  border: none;
  padding: 12px 32px;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 12px;
  transition: all 0.2s;
}

.timer-btn-start:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
}

.timer-btn-skip {
  background: none;
  border: none;
  color: #9ca3af;
  font-size: 14px;
  cursor: pointer;
  margin-top: 8px;
  padding: 8px;
}

/* ——— Previous results ——— */
.prev-results {
  font-size: 12px;
  color: #9ca3af;
  margin-bottom: 8px;
  padding: 6px 10px;
  background: #f9fafb;
  border-radius: 8px;
  border-left: 3px solid #e5e7eb;
}

/* ——— Records table ——— */
.records-grid {
  display: grid;
  gap: 8px;
}

.record-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: #fff;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
}

.record-item .record-name {
  font-weight: 600;
  font-size: 14px;
}

.record-item .record-value {
  font-weight: 800;
  font-size: 16px;
  color: #10b981;
}

.record-item .record-detail {
  font-size: 12px;
  color: #9ca3af;
}

/* ——— Food search ——— */
.food-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  max-height: 250px;
  overflow-y: auto;
  z-index: 50;
  display: none;
}

.food-suggestions.show {
  display: block;
  animation: slideDown 0.2s ease;
}

.food-suggestion {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid #f3f4f6;
  transition: background 0.1s;
}

.food-suggestion:hover {
  background: #ecfdf5;
}

.food-suggestion:last-child {
  border-bottom: none;
}

.food-suggestion .food-name {
  font-weight: 500;
  font-size: 14px;
}

.food-suggestion .food-macros {
  font-size: 12px;
  color: #6b7280;
  margin-top: 2px;
}

/* ——— Details/summary ——— */
details summary {
  outline: none;
}

details[open] > summary {
  margin-bottom: 8px;
}

/* ——— Export page ——— */
.export-grid {
  display: grid;
  gap: 12px;
}

.export-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background: #fff;
  border-radius: 14px;
  border: 1px solid #e5e7eb;
}

.export-card .export-title {
  font-weight: 600;
  font-size: 15px;
}

.export-card .export-btns {
  display: flex;
  gap: 8px;
}

/* ——— Hero card ——— */
.hero-card {
  animation: fadeIn 0.4s ease;
}

/* ——— Responsive ——— */
@media (max-width: 400px) {
  .container { padding: 12px 8px; }
  .card { padding: 10px 12px; }
  .timer-box { padding: 24px 20px; }
  .timer-display { font-size: 48px; }
}
