:root {
  --bg: #0b1220;
  --card: #131c2e;
  --card-2: #1a2540;
  --text: #e8edf7;
  --muted: #8b96ad;
  --line: #26314a;
  --accent: #3b82f6;
  --accent-soft: #16233d;
  --accent-ink: #7fb2ff;
  --green: #34d399;
  --green-soft: #103428;
  --shoulder: #a78bfa;
  --shoulder-soft: #241f3d;
  --knee: #38bdf8;
  --knee-soft: #10283a;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
.app { max-width: 520px; margin: auto; min-height: 100vh; padding-bottom: 90px; }

header { padding: 24px 20px 14px; background: var(--bg); position: sticky; top: 0; z-index: 3; }
h1 { margin: 0; font-size: 30px; }
.sub { color: var(--muted); margin-top: 4px; }

nav { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: min(520px, 100%); background: var(--card); border-top: 1px solid var(--line); display: flex; z-index: 5; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
nav button { flex: 1; border: 0; background: none; padding: 8px 4px; color: var(--muted); font-size: 12px; }
nav button.active { color: var(--accent-ink); font-weight: 700; }

.page { padding: 0 16px; }
.hidden { display: none; }

.hero { background: linear-gradient(160deg, #182545, #0e1626); border: 1px solid var(--line); color: #fff; border-radius: 24px; padding: 22px; margin-bottom: 16px; }
.hero small { color: var(--muted); }
.hero h2 { margin: 7px 0 4px; font-size: 25px; color: #fff; }
.hero-sub { color: var(--muted); margin-bottom: 16px; font-size: 14px; }

button.primary { background: var(--accent); color: #fff; border: 0; border-radius: 14px; padding: 14px 18px; font-weight: 700; font-size: 15px; width: 100%; }
button.ghost { border: 0; background: var(--card-2); color: var(--text); border-radius: 10px; padding: 10px 14px; font-weight: 600; }
button.ghost.full { width: 100%; margin-top: 4px; }
button.orange { background: var(--accent); color: #fff; border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 700; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 16px; margin: 12px 0; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row.wrap { flex-wrap: wrap; }
.pill { background: var(--accent-soft); color: var(--accent-ink); border-radius: 999px; padding: 6px 10px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.pill.focus-shoulder { background: var(--shoulder-soft); color: var(--shoulder); }
.pill.focus-knee { background: var(--knee-soft); color: var(--knee); }

.tight { margin: 3px 0 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; margin-bottom: 0; }

.exercise { margin: 12px 0; }
.exercise h3 { margin: 0 0 4px; font-size: 17px; }
.exercise .meta { color: var(--muted); font-size: 13px; }
.exercise .note { font-size: 12.5px; color: var(--muted); background: var(--card-2); border-radius: 10px; padding: 8px 10px; margin-top: 10px; line-height: 1.45; }
.exercise .exhead { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }

.sets { display: grid; grid-template-columns: 34px 1fr 1fr 48px; gap: 7px; align-items: center; margin-top: 12px; }
.sets.hold { grid-template-columns: 34px 1fr 48px; }
.sets input { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px; background: var(--card-2); color: var(--text); font-size: 15px; }
.sets button { border: 0; border-radius: 10px; padding: 10px; background: var(--card-2); color: var(--text); }
.sets button.done { background: var(--green-soft); color: var(--green); }
.sets b { font-size: 12px; color: var(--muted); font-weight: 600; }

.timer { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: none; align-items: center; justify-content: center; z-index: 10; padding: 20px; }
.timer.show { display: flex; }
.timerbox { background: var(--card); border: 1px solid var(--line); border-radius: 28px; width: min(390px, 100%); padding: 28px; text-align: center; }
.clock { font-size: 64px; font-weight: 800; margin: 18px 0; color: var(--accent-ink); }

.statgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--card); border-radius: 16px; padding: 15px; border: 1px solid var(--line); }
.stat b { display: block; font-size: 24px; }

.list button { width: 100%; text-align: left; border: 0; background: transparent; color: var(--text); border-bottom: 1px solid var(--line); padding: 15px 0; font-size: 15px; }
.list button:last-child { border-bottom: 0; }
.empty { padding: 30px 10px; text-align: center; color: var(--muted); }

.toast { position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%) translateY(20px); background: var(--card-2); color: var(--text); border: 1px solid var(--line); padding: 12px 18px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 20; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Auth gate / onboarding ---------- */
#authGate h2 { padding: 4px 0 6px; }
#profileButtons button.profile-btn { width: 100%; text-align: left; border: 0; background: none; padding: 14px 4px; font-size: 16px; font-weight: 600; border-bottom: 1px solid var(--line); }
#profileButtons button.profile-btn:last-child { border-bottom: 0; }

.card input[type="text"], .card input[type="number"], .card input[type="password"], .card select {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: var(--card-2); color: var(--text); font-size: 15px; margin-top: 8px;
}
.card select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 22px, calc(100% - 13px) 22px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
.card select option { background: var(--card); color: var(--text); }

.pininput { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 16px; background: var(--card-2); color: var(--text); font-size: 28px; letter-spacing: 12px; text-align: center; }

#restButtons button, .sets ~ button { border: 0; border-radius: 10px; padding: 10px 14px; background: var(--card-2); color: var(--text); font-weight: 600; }
#restButtons button.active { background: var(--accent); color: #fff; }

/* ---------- Weight chart ---------- */
#weightChart { width: 100%; height: 90px; margin-top: 10px; display: block; }

