:root {
  --green: #2dd4a0;
  --green-dim: #d1faf0;
  --yellow: #f5a623;
  --yellow-dim: #fef3db;
  --red: #f05252;
  --red-dim: #fee2e2;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --text-muted: #6b7280;
  --r: 16px;
  --r-sm: 10px;
  --shadow: 0 2px 8px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.14);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

/* ─── Layout ──────────────────────────────────────────── */

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

/* ─── Header ───────────────────────────────────────────── */

header {
  padding: 24px 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -.02em;
}

.date-chip {
  font-size: .8rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 4px 12px;
}

/* ─── Recommendation banner ────────────────────────────── */

.banner {
  background: var(--green-dim);
  border: 1.5px solid var(--green);
  border-radius: var(--r);
  padding: 12px 16px;
  margin-bottom: 20px;
  font-size: .9rem;
  font-weight: 600;
  color: #065f46;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
}

.banner.empty {
  background: var(--yellow-dim);
  border-color: var(--yellow);
  color: #78350f;
}

/* ─── Muscle cards ─────────────────────────────────────── */

.section-title {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 24px;
}

@media (min-width: 400px) {
  .card-grid { grid-template-columns: repeat(3, 1fr); }
}

.muscle-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow);
  transition: transform .15s, box-shadow .15s;
  cursor: default;
}

.muscle-card.ready  { border-color: var(--green);  background: #f0fdf8; }
.muscle-card.light  { border-color: var(--yellow); background: #fffbf0; }
.muscle-card.rest   { border-color: var(--red);    background: #fff5f5; }

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-emoji { font-size: 1.5rem; line-height: 1; }

.badge {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 2px 8px;
  border-radius: 99px;
}

.badge.ready  { background: var(--green);  color: #fff; }
.badge.light  { background: var(--yellow); color: #fff; }
.badge.rest   { background: var(--red);    color: #fff; }

.card-name {
  font-size: .88rem;
  font-weight: 600;
}

.card-score {
  font-size: .75rem;
  color: var(--text-muted);
}

/* readiness bar */
.card-bar {
  height: 4px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}

.card-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width .4s ease;
}

.ready  .card-bar-fill { background: var(--green); }
.light  .card-bar-fill { background: var(--yellow); }
.rest   .card-bar-fill { background: var(--red); }

/* ─── Log button ────────────────────────────────────────── */

.log-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 15px;
  font-size: 1rem;
  font-weight: 700;
  background: var(--text);
  color: #fff;
  border: none;
  border-radius: var(--r);
  cursor: pointer;
  letter-spacing: -.01em;
  box-shadow: var(--shadow);
  transition: opacity .15s, transform .1s;
  margin-bottom: 28px;
}

.log-btn:active { opacity: .85; transform: scale(.98); }

/* ─── Recent history ───────────────────────────────────── */

.history-list { display: flex; flex-direction: column; gap: 8px; }

.history-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px 14px;
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: .85rem;
}

.history-date {
  font-weight: 600;
  color: var(--text-muted);
  font-size: .78rem;
  white-space: nowrap;
  min-width: 60px;
}

.history-muscles {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.muscle-tag {
  font-size: .72rem;
  font-weight: 600;
  background: var(--border);
  color: var(--text);
  padding: 2px 8px;
  border-radius: 99px;
}

/* ─── Modal ─────────────────────────────────────────────── */

.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 100;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn .15s ease;
}

.modal-backdrop.open { display: flex; }

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

.modal {
  background: var(--surface);
  border-radius: var(--r) var(--r) 0 0;
  padding: 24px 20px 36px;
  width: 100%;
  max-width: 560px;
  box-shadow: var(--shadow-lg);
  animation: slideUp .2s ease;
}

@keyframes slideUp {
  from { transform: translateY(60px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

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

.modal h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 6px;
}

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

.muscle-picker {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 22px;
}

@media (min-width: 360px) {
  .muscle-picker { grid-template-columns: repeat(3, 1fr); }
}

.picker-label {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px 10px;
  cursor: pointer;
  font-size: .85rem;
  font-weight: 600;
  transition: border-color .1s, background .1s;
  user-select: none;
}

.picker-label input { display: none; }

.picker-label.checked {
  border-color: var(--text);
  background: var(--text);
  color: #fff;
}

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

.btn-cancel {
  flex: 1;
  padding: 13px;
  background: none;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
}

.btn-save {
  flex: 2;
  padding: 13px;
  background: var(--text);
  border: none;
  border-radius: var(--r-sm);
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;
  color: #fff;
  transition: opacity .15s;
}

.btn-save:disabled { opacity: .4; cursor: default; }

/* ─── Loading / empty states ─────────────────────────────── */

.loading {
  text-align: center;
  padding: 40px 0;
  color: var(--text-muted);
  font-size: .9rem;
}

.no-history {
  text-align: center;
  color: var(--text-muted);
  font-size: .85rem;
  padding: 16px 0;
}
