/* ── Variables ──────────────────────────────────────────────────────────────── */
:root {
  --bg:          #0d1117;
  --surface:     #161b22;
  --card:        #1c2230;
  --border:      #2d3550;
  --text:        #e6e8ef;
  --text-muted:  #8b92a5;
  --olive:       #7ab227;
  --olive-dim:   #3d5814;
  --amber:       #c27d1a;
  --amber-dim:   #5c3a09;
  --rest:        #4a6fa5;
  --rest-dim:    #1e2f45;
  --red:         #e05252;
  --green:       #3fb950;
  --radius:      10px;
  --shadow:      0 2px 12px rgba(0,0,0,.45);
}

/* ── Reset base ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button { cursor: pointer; font-family: inherit; }
input, textarea, select {
  font-family: inherit;
  font-size: 1rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--olive);
}

/* ── Layout ─────────────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-logo {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--olive);
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.topbar-right {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}
.progress-bar-wrap {
  flex: 1;
  max-width: 240px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--olive);
  border-radius: 3px;
  transition: width .6s ease;
}
.progress-text {
  font-size: .72rem;
  color: var(--text-muted);
  text-align: right;
}

.container {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 14px 80px;
}

/* ── Cards ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: .82rem;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.card-header.olive  { background: var(--olive-dim); color: var(--olive); border-bottom-color: var(--olive-dim); }
.card-header.amber  { background: var(--amber-dim); color: var(--amber); border-bottom-color: var(--amber-dim); }
.card-header.rest   { background: var(--rest-dim);  color: var(--rest);  border-bottom-color: var(--rest-dim); }
.card-header i { font-size: 1.1rem; }
.card-body { padding: 12px 14px; }
.card-body p { margin: 0 0 8px; font-size: .94rem; color: var(--text-muted); }
.card-body p:last-child { margin-bottom: 0; }

/* ── Day header ─────────────────────────────────────────────────────────────── */
.day-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 14px 10px;
}
.day-number {
  font-size: 3.2rem;
  font-weight: 800;
  color: var(--olive);
  line-height: 1;
  min-width: 54px;
  font-variant-numeric: tabular-nums;
}
.day-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.day-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  width: fit-content;
}
.badge-etapa   { background: rgba(122,178,39,.18); color: var(--olive); }
.badge-semana  { background: var(--border); color: var(--text-muted); }
.badge-fuerza  { background: rgba(122,178,39,.22); color: var(--olive); }
.badge-aerobico { background: rgba(194,125,26,.22); color: var(--amber); }
.badge-descanso_activo { background: rgba(74,111,165,.22); color: var(--rest); }
.badge-descanso_completo { background: rgba(74,111,165,.15); color: var(--rest); }

/* ── Exercise items ─────────────────────────────────────────────────────────── */
.exercise-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.exercise-item:last-child { border-bottom: none; }
.exercise-img {
  width: 52px;
  height: 52px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--border);
  flex-shrink: 0;
}
.exercise-img-placeholder {
  width: 52px;
  height: 52px;
  border-radius: 6px;
  background: var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}
.exercise-info { flex: 1; min-width: 0; }
.exercise-name {
  font-size: .92rem;
  font-weight: 600;
  margin-bottom: 2px;
}
.exercise-sets {
  font-size: .79rem;
  color: var(--text-muted);
}
.exercise-check {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 2px solid var(--border);
  background: none;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, border-color .15s;
  padding: 0;
  color: transparent;
}
.exercise-check.checked {
  background: var(--olive);
  border-color: var(--olive);
  color: #fff;
}
.exercise-check i { font-size: .85rem; }

/* ── PM block ───────────────────────────────────────────────────────────────── */
.pm-img-wrap {
  position: relative;
  width: 100%;
  height: 120px;
  overflow: hidden;
  border-radius: 6px;
  margin-bottom: 10px;
  background: var(--amber-dim);
}
.pm-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.pm-text {
  font-size: .93rem;
  color: var(--text);
  line-height: 1.55;
}

/* ── Eval / pesaje form ─────────────────────────────────────────────────────── */
.eval-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.eval-field label {
  display: block;
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 4px;
}
.eval-field input {
  width: 100%;
  padding: 7px 10px;
}
.eval-full { grid-column: 1 / -1; }

/* ── Notes ──────────────────────────────────────────────────────────────────── */
.notes-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.notes-grid .notes-full { grid-column: 1 / -1; }
.note-field label {
  display: block;
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 4px;
}
.note-field select, .note-field textarea {
  width: 100%;
  resize: vertical;
}
.note-field textarea { min-height: 60px; }

.toggle-group {
  display: flex;
  gap: 6px;
}
.toggle-btn {
  flex: 1;
  padding: 7px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: none;
  color: var(--text-muted);
  font-size: .87rem;
  font-weight: 600;
  transition: background .15s, border-color .15s, color .15s;
}
.toggle-btn.active-yes { background: rgba(63,185,80,.18); border-color: var(--green); color: var(--green); }
.toggle-btn.active-no  { background: rgba(224,82,82,.18);  border-color: var(--red);   color: var(--red);   }

/* ── Complete button ────────────────────────────────────────────────────────── */
.complete-section {
  padding: 8px 0 0;
  text-align: center;
}
.btn-complete {
  display: block;
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: var(--radius);
  background: var(--olive);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  transition: background .15s, transform .1s;
}
.btn-complete:hover  { background: #8dcf30; }
.btn-complete:active { transform: scale(.98); }

/* ── Waiting / Finish screens ───────────────────────────────────────────────── */
.waiting-screen, .finish-screen {
  text-align: center;
  padding: 48px 24px;
}
.waiting-icon, .finish-icon { font-size: 3.2rem; margin-bottom: 14px; }
.waiting-screen h2 { font-size: 1.4rem; margin: 0 0 8px; }
.waiting-sub { color: var(--text-muted); margin: 0 0 20px; }
.countdown {
  font-size: 3rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--amber);
  letter-spacing: .06em;
  margin-bottom: 16px;
}
.waiting-note {
  font-size: .9rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}
.btn-edit {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  padding: 8px 16px;
  font-size: .84rem;
}
.btn-edit:hover { border-color: var(--amber); color: var(--amber); }

.finish-screen .finish-title { font-size: 1.8rem; font-weight: 800; color: var(--olive); margin: 0 0 12px; }
.finish-screen .finish-sub   { color: var(--text-muted); margin: 0 0 24px; }
.btn-reset {
  background: none;
  border: 1px solid var(--red);
  color: var(--red);
  border-radius: 6px;
  padding: 8px 16px;
  font-size: .84rem;
}
.btn-reset:hover { background: rgba(224,82,82,.12); }

/* ── Misc ───────────────────────────────────────────────────────────────────── */
.loading {
  text-align: center;
  padding: 48px;
  color: var(--text-muted);
}
.error {
  background: rgba(224,82,82,.15);
  border: 1px solid var(--red);
  border-radius: var(--radius);
  color: var(--red);
  padding: 14px;
  margin: 16px 0;
}

@media (max-width: 400px) {
  .eval-grid, .notes-grid { grid-template-columns: 1fr; }
  .eval-full, .notes-full  { grid-column: 1; }
}
