
:root {
  --bg: #0b0d10;
  --panel: #14171b;
  --panel-2: #1b1f24;
  --text: #f6f7f8;
  --muted: #8d97a3;
  --line: #262c33;
  --accent: #b5f34a;
  --danger: #ff6b6b;
  --warning: #ffd166;
  --radius: 20px;
  --shadow: 0 12px 30px rgba(0,0,0,.25);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { overscroll-behavior-y: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.app-shell { max-width: 520px; margin: 0 auto; min-height: 100vh; padding-bottom: 88px; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(16px + env(safe-area-inset-top)) 18px 12px;
  background: linear-gradient(to bottom, rgba(11,13,16,.98), rgba(11,13,16,.88), transparent);
  backdrop-filter: blur(10px);
}
.eyebrow { color: var(--accent); font-size: 11px; letter-spacing: .18em; font-weight: 800; margin: 0 0 4px; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 28px; margin-bottom: 0; }
main { padding: 8px 16px 24px; }
.card {
  background: linear-gradient(180deg, var(--panel), #111419);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px;
}
.card.hero { padding: 18px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stack { display: grid; gap: 12px; }
.grid-2 { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.stat {
  background: var(--panel-2); border-radius: 16px; padding: 14px;
  border: 1px solid var(--line);
}
.stat strong { display:block; font-size:22px; margin-top:4px; }
.muted { color: var(--muted); }
.accent { color: var(--accent); }
.pill {
  display:inline-flex; padding:7px 10px; border-radius:999px;
  background: rgba(181,243,74,.12); color: var(--accent); font-size:12px; font-weight:700;
}
.primary, .secondary, .danger {
  width:100%; border:0; border-radius:16px; padding:14px 16px; font-weight:800;
}
.primary { background:var(--accent); color:#0b0d10; }
.secondary { background:var(--panel-2); color:var(--text); border:1px solid var(--line); }
.danger { background:rgba(255,107,107,.12); color:var(--danger); border:1px solid rgba(255,107,107,.2); }
.icon-btn {
  width:42px; height:42px; border-radius:14px; border:1px solid var(--line);
  background:var(--panel-2); color:var(--text); font-size:22px;
}
.bottom-nav {
  position:fixed; left:50%; transform:translateX(-50%); bottom:0; z-index:40;
  width:min(520px,100%); display:grid; grid-template-columns:repeat(6,1fr);
  padding:9px 10px calc(9px + env(safe-area-inset-bottom));
  background:rgba(15,18,22,.96); border-top:1px solid var(--line); backdrop-filter:blur(14px);
}
.nav-item {
  border:0; background:transparent; color:var(--muted); padding:6px 2px; border-radius:14px;
  display:grid; place-items:center; gap:3px;
}
.nav-item span { font-size:20px; }
.nav-item small { font-size:10px; }
.nav-item.active { color:var(--accent); background:rgba(181,243,74,.08); }
.section-title { display:flex; justify-content:space-between; align-items:center; margin:18px 2px 10px; }
.section-title h2 { font-size:17px; margin:0; }
.week { display:grid; grid-template-columns:repeat(7,1fr); gap:6px; }
.day {
  text-align:center; padding:10px 2px; border-radius:14px; background:var(--panel-2); border:1px solid var(--line);
}
.day small { display:block; color:var(--muted); margin-bottom:6px; }
.day.done { border-color:rgba(181,243,74,.4); }
.day.done b { color:var(--accent); }
.exercise { padding:14px 0; border-bottom:1px solid var(--line); }
.exercise:last-child { border-bottom:0; }
.exercise h3 { font-size:16px; margin-bottom:4px; }
.meta { font-size:12px; color:var(--muted); }
.form-group { display:grid; gap:7px; margin-bottom:12px; }
label { font-size:12px; font-weight:700; color:#c7cdd4; }
input, select, textarea {
  width:100%; color:var(--text); background:#0f1216; border:1px solid var(--line);
  border-radius:14px; padding:12px 13px; outline:none;
}
input:focus, select:focus, textarea:focus { border-color:var(--accent); }
textarea { min-height:80px; resize:vertical; }
.inline-fields { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.set-row {
  display:grid; grid-template-columns:38px 1fr 1fr 44px; gap:8px; align-items:center; margin:8px 0;
}
.set-num { width:34px; height:34px; border-radius:50%; display:grid; place-items:center; background:var(--panel-2); color:var(--muted); font-weight:800; }
.check-set { width:42px; height:42px; border-radius:12px; border:1px solid var(--line); background:var(--panel-2); color:var(--text); }
.check-set.checked { background:var(--accent); color:#0b0d10; }
dialog {
  width:min(500px, calc(100% - 20px)); max-height:90vh; border:1px solid var(--line);
  background:var(--panel); color:var(--text); border-radius:24px; padding:0; overflow:auto;
}
dialog::backdrop { background:rgba(0,0,0,.72); backdrop-filter:blur(4px); }
#modalForm { padding:18px; }
.modal-head { display:flex; justify-content:space-between; align-items:center; margin-bottom:14px; }
.modal-head h2 { margin:0; font-size:20px; }
.modal-actions { display:grid; gap:10px; margin-top:16px; }
.empty-state { text-align:center; color:var(--muted); padding:40px 18px; }
.empty-icon { font-size:34px; color:var(--accent); margin-bottom:10px; }
.list-item {
  display:flex; justify-content:space-between; gap:12px; align-items:center;
  padding:13px 0; border-bottom:1px solid var(--line);
}
.list-item:last-child { border-bottom:0; }
.small-btn {
  border:1px solid var(--line); background:var(--panel-2); color:var(--text);
  border-radius:12px; padding:8px 10px; font-weight:700;
}
.progress-bar { height:9px; border-radius:999px; background:#242a31; overflow:hidden; }
.progress-fill { height:100%; background:var(--accent); border-radius:999px; }
canvas { width:100%; height:220px; background:#0f1216; border-radius:16px; border:1px solid var(--line); }
.toast {
  position:fixed; left:50%; bottom:96px; transform:translateX(-50%) translateY(20px);
  opacity:0; pointer-events:none; background:#f4f6f8; color:#111; padding:11px 14px;
  border-radius:14px; font-weight:800; z-index:60; transition:.2s;
}
.toast.show { opacity:1; transform:translateX(-50%) translateY(0); }
hr { border:0; border-top:1px solid var(--line); margin:14px 0; }

.timer-done { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(181,243,74,.25), var(--shadow); }
.timer-done #restTime { color: var(--accent); }

.day.today { outline: 2px solid rgba(181,243,74,.35); outline-offset: 2px; }

.validation-box {
  margin-bottom: 14px;
  padding: 13px 14px;
  border-radius: 14px;
  background: rgba(255,107,107,.10);
  border: 1px solid rgba(255,107,107,.35);
  color: #ff8d8d;
  font-size: 13px;
  line-height: 1.45;
}
.validation-box b { color: #ff6b6b; }
.validation-box ul { margin: 7px 0 0 18px; padding: 0; }
.validation-box li + li { margin-top: 4px; }

.pr-pill {
  background: rgba(255,209,102,.12);
  color: var(--warning);
  border: 1px solid rgba(255,209,102,.18);
  white-space: nowrap;
}

.check-set.pr-new {
  animation: prPulse .9s ease;
  box-shadow: 0 0 0 5px rgba(181,243,74,.18);
}
.check-set.pr-equal {
  animation: prPulseEqual .9s ease;
  box-shadow: 0 0 0 5px rgba(255,209,102,.16);
}
@keyframes prPulse {
  0% { transform: scale(1); }
  35% { transform: scale(1.18); }
  100% { transform: scale(1); }
}
@keyframes prPulseEqual {
  0% { transform: scale(1); }
  35% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

.exercise-pick-item {
  width:100%;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:13px 4px;
  border:0;
  border-bottom:1px solid var(--line);
  background:transparent;
  color:var(--text);
  text-align:left;
}
.exercise-pick-item:last-child { border-bottom:0; }
.exercise-pick-item div { display:grid; gap:4px; }
.exercise-pick-item span { color:var(--muted); font-size:12px; }
.exercise-pick-item strong { color:var(--accent); font-size:22px; }

.picker-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  background: rgba(11,13,16,.96);
  backdrop-filter: blur(8px);
  padding: 18px;
  overflow-y: auto;
  border-radius: 24px;
}
.picker-sheet {
  min-height: 100%;
}
#modalForm {
  position: relative;
}

.exercise-edit:focus-within {
  border-color: rgba(181,243,74,.35);
}

.program-card { overflow: hidden; }
.program-workouts {
  display:flex;
  flex-wrap:wrap;
  gap:7px;
  margin:10px 0 14px;
}
.program-workout-chip {
  display:inline-flex;
  padding:6px 9px;
  border-radius:999px;
  background:var(--panel-2);
  border:1px solid var(--line);
  color:var(--muted);
  font-size:11px;
  font-weight:700;
}
.program-weeks {
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  gap:8px;
  margin-top:12px;
}
.program-week {
  border:1px solid var(--line);
  background:var(--panel-2);
  color:var(--muted);
  border-radius:14px;
  padding:9px 4px;
  display:grid;
  place-items:center;
  gap:3px;
}
.program-week span {
  width:28px;
  height:28px;
  border-radius:50%;
  display:grid;
  place-items:center;
  font-weight:900;
  background:#0f1216;
}
.program-week small { font-size:9px; }
.program-week.checked {
  color:var(--accent);
  border-color:rgba(181,243,74,.4);
  background:rgba(181,243,74,.07);
}
.program-week.checked span {
  background:var(--accent);
  color:#0b0d10;
}
.program-workout-selector {
  display:grid;
  gap:8px;
}
.program-workout-option {
  display:flex;
  align-items:center;
  gap:10px;
  padding:12px;
  border-radius:14px;
  background:#0f1216;
  border:1px solid var(--line);
}
.program-workout-option input { width:auto; }
.program-workout-option span { display:grid; gap:3px; }
.program-workout-option small { color:var(--muted); }
.program-complete-message {
  margin-top:12px;
  padding:11px 12px;
  text-align:center;
  border-radius:14px;
  background:rgba(181,243,74,.10);
  color:var(--accent);
  font-weight:800;
}
.program-done-pill {
  background:rgba(181,243,74,.15);
}
@media (min-width:420px) {
  .program-weeks { grid-template-columns:repeat(5,minmax(0,1fr)); }
}

.program-history-card {
  padding: 0;
  overflow: hidden;
}
.program-history-summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  cursor: pointer;
}
.program-history-summary::-webkit-details-marker {
  display: none;
}
.program-history-list {
  border-top: 1px solid var(--line);
  padding: 0 16px;
}
.program-history-item {
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}
.program-history-item:last-child {
  border-bottom: 0;
}

.exercise-note {
  margin-top: 8px;
  padding: 10px 11px;
  border-radius: 12px;
  background: rgba(141,151,163,.08);
  border: 1px solid var(--line);
  color: #c7cdd4;
  font-size: 12px;
  line-height: 1.45;
}
