@import url('https://fonts.googleapis.com/css2?family=Frank+Ruhl+Libre:wght@500;700&family=Heebo:wght@400;500;700&family=JetBrains+Mono:wght@500;700&display=swap');

:root {
  --ink: #1c231c;
  --paper: #f6f5ef;
  --surface: #ffffff;
  --forest: #23412f;
  --moss: #5c7a5a;
  --lime: #9fc93f;
  --gold: #d9a441;
  --wine: #7a2e3a;
  --muted: #6b7266;
  --border: #dcdccf;
  --danger: #b8433f;
  --radius: 16px;
  --shadow: 0 2px 10px rgba(28, 35, 28, 0.06);
  --font-heading: 'Frank Ruhl Libre', serif;
  --font-body: 'Heebo', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  direction: rtl;
}

body {
  padding-bottom: 76px; /* space for bottom nav */
  min-height: 100vh;
}

h1, h2, h3 { font-family: var(--font-heading); margin: 0 0 6px; color: var(--forest); }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 8px; line-height: 1.5; }

.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

#app { max-width: 640px; margin: 0 auto; padding: 16px; }

.header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
}
.header .brand { font-family: var(--font-heading); font-size: 1.3rem; color: var(--forest); font-weight: 700; }
.header .subtitle { color: var(--muted); font-size: 0.85rem; }

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

.card-tight { padding: 12px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 12px;
  padding: 12px 18px;
  font-size: 0.95rem;
  font-weight: 700;
  background: var(--forest);
  color: #fff;
  transition: opacity 0.15s ease;
}
.btn:hover { opacity: 0.9; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary { background: var(--paper); color: var(--forest); border: 1px solid var(--border); }
.btn-danger { background: var(--danger); }
.btn-gold { background: var(--gold); color: var(--ink); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 12px; font-size: 0.85rem; border-radius: 10px; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; }
.chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 500;
}
.chip.active { background: var(--forest); color: #fff; border-color: var(--forest); }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
.field input[type="text"], .field input[type="number"], .field select, .field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.95rem;
}
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }

.muted { color: var(--muted); font-size: 0.85rem; }
.error-box { background: #fbeceb; border: 1px solid var(--danger); color: var(--danger); border-radius: 12px; padding: 10px 14px; margin-bottom: 14px; font-size: 0.9rem; }

/* Bottom nav */
.bottom-nav {
  position: fixed;
  bottom: 0; right: 0; left: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  max-width: 640px;
  margin: 0 auto;
  z-index: 20;
}
.bottom-nav button {
  flex: 1;
  border: none;
  background: none;
  padding: 10px 4px 8px;
  font-size: 0.72rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.bottom-nav button .icon { font-size: 1.15rem; }
.bottom-nav button.active { color: var(--forest); font-weight: 700; }

/* Onboarding */
.progress-track { height: 6px; background: var(--border); border-radius: 4px; margin-bottom: 18px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--lime); }
.step-count { font-size: 0.8rem; color: var(--muted); margin-bottom: 4px; }

/* Program / week view */
.day-list { display: flex; flex-direction: column; gap: 10px; }
.day-row {
  display: flex; align-items: center; justify-content: space-between;
  border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; background: var(--surface);
}
.day-row.completed { border-color: var(--moss); background: #f1f6ee; }
.day-focus { font-weight: 700; }
.day-meta { font-size: 0.8rem; color: var(--muted); }

/* Workout mode */
.exercise-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 10px; }
.exercise-tabs button {
  flex: 0 0 auto; border: 1px solid var(--border); background: var(--surface);
  border-radius: 10px; padding: 6px 10px; font-size: 0.78rem; color: var(--muted);
}
.exercise-tabs button.active { background: var(--forest); color: #fff; border-color: var(--forest); }
.exercise-tabs button.done { border-color: var(--moss); color: var(--moss); }

.target-box { display: flex; gap: 16px; background: var(--paper); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; }
.target-box .stat { text-align: center; flex: 1; }
.target-box .stat .value { font-family: var(--font-mono); font-size: 1.15rem; font-weight: 700; color: var(--forest); }
.target-box .stat .label { font-size: 0.7rem; color: var(--muted); }

.last-time { font-size: 0.8rem; color: var(--muted); margin-bottom: 10px; }

.set-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.set-row .set-index { width: 22px; font-family: var(--font-mono); color: var(--muted); font-size: 0.85rem; }
.set-row input { width: 100%; padding: 9px; border: 1px solid var(--border); border-radius: 8px; text-align: center; font-family: var(--font-mono); }
.set-row.completed { opacity: 0.75; }
.set-row .set-label { font-size: 0.68rem; color: var(--muted); text-align: center; display: block; margin-bottom: 2px; }

.rest-timer { text-align: center; padding: 10px; background: var(--paper); border-radius: 12px; margin-bottom: 12px; }
.rest-timer .num { font-size: 1.4rem; color: var(--wine); }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(28,35,28,0.5);
  display: flex; align-items: flex-end; justify-content: center; z-index: 50;
}
.modal-sheet {
  background: var(--surface); border-radius: 18px 18px 0 0; width: 100%; max-width: 640px;
  max-height: 82vh; overflow-y: auto; padding: 18px;
}
.replacement-item {
  border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.replacement-item .reason { font-size: 0.75rem; color: var(--muted); }

/* Progress screen */
.history-item { border-bottom: 1px solid var(--border); padding: 10px 0; }
.history-item:last-child { border-bottom: none; }

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.stat-tile { background: var(--paper); border-radius: 12px; padding: 10px; text-align: center; }
.stat-tile .value { font-family: var(--font-mono); font-size: 1.2rem; font-weight: 700; color: var(--forest); }
.stat-tile .label { font-size: 0.7rem; color: var(--muted); }

@media (min-width: 720px) {
  .field-row { gap: 16px; }
}
