:root {
  --bg: #16181d;
  --surface: #1f232b;
  --surface2: #262c36;
  --text: #eef1f6;
  --muted: #9aa3b2;
  --accent: #4da3ff;
  --green: #3ecf6f;
  --amber: #ffb020;
  --red: #ff5d5d;
  --border: #2e3540;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(22, 24, 29, 0.95);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 560px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { font-weight: 700; font-size: 18px; }
.nav { display: flex; gap: 4px; }
.nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 14px;
}
.nav a.active, .nav a:active { color: var(--text); background: var(--surface2); }

.view { max-width: 560px; margin: 0 auto; padding: 16px 16px 48px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.card h2, .card h3 { margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.btn {
  display: block;
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #0a0f16;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 12px;
}
.btn:active { transform: scale(0.98); }
.btn.secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: transparent; color: var(--red); border: 1px solid var(--red); }
.btn:disabled { opacity: 0.5; }

.userpick { display: flex; gap: 8px; margin: 12px 0; }
.userpick button {
  flex: 1;
  padding: 16px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  text-transform: capitalize;
}
.userpick button.sel { border-color: var(--accent); }

input[type="text"], input[type="number"], select {
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 16px;
  margin-top: 6px;
}
label.field { display: block; margin-top: 12px; font-size: 14px; color: var(--muted); }

.lift-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}
.lift-row:first-of-type { border-top: none; }
.lift-weight { font-weight: 700; font-size: 18px; }
.streak { color: var(--amber); font-size: 13px; }

.sets { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.set {
  flex: 1 1 0;
  min-width: 56px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 4px;
  text-align: center;
}
.set .reps { font-size: 22px; font-weight: 700; }
.set button.reps {
  width: 100%;
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.set button:disabled { opacity: 0.55; cursor: wait; }
.set.done { border-color: var(--green); }
.set.missed { border-color: var(--amber); }
.stepper { display: flex; justify-content: center; gap: 10px; margin-top: 4px; }
.stepper button {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
}

.plates { font-size: 13px; color: var(--muted); margin-top: 6px; }

.timer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin: 12px 0;
  position: sticky;
  bottom: 12px;
}
.timer .time { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.timer .tbtns { display: flex; gap: 8px; }
.timer button {
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}

.result-up { color: var(--green); font-weight: 700; }
.result-repeat { color: var(--amber); font-weight: 700; }
.result-deload { color: var(--accent); font-weight: 700; }

.hist-item { padding: 12px 0; border-top: 1px solid var(--border); }
.hist-item:first-child { border-top: none; }

canvas.chart { width: 100%; height: 220px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }

.row2 { display: flex; gap: 8px; }
.row2 > * { flex: 1; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 10px;
  z-index: 50;
  max-width: 90vw;
  text-align: center;
}

.passkey-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}
.passkey-row button {
  background: transparent;
  border: 1px solid var(--red);
  color: var(--red);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
}
