:root {
  --bg: #121212;
  --surface: #1c1c1e;
  --raised: #27272b;
  --ink: #f4f4f2;
  --steel: #8e8e93;
  --line: #2f2f34;
  --accent: #ff5a1f;
  --accent-soft: rgb(255 90 31 / 0.14);
  --danger: #ff6b5e;
  --display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --body: 'Barlow', system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 17px/1.45 var(--body);
  -webkit-tap-highlight-color: transparent;
}

main { max-width: 34rem; margin: 0 auto; padding: 1.25rem 1rem 9rem; }

h1, h2, h3 { font-family: var(--display); font-weight: 700; line-height: 1.05; margin: 0; }
h1 { font-size: 2.5rem; text-transform: uppercase; letter-spacing: 0.01em; }
h2 { font-size: 1.5rem; }
/* The Repz wordmark: heavy italic, the Z in orange. */
.brand { font-style: italic; font-weight: 900; font-size: 2.8rem; letter-spacing: 0.01em; }
.brand span { color: var(--accent); }
h3 { font-size: 1.3rem; }

p { margin: 0; }
.muted { color: var(--steel); }
.small { font-size: 0.9rem; }
.accent { color: var(--accent); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  min-height: 3rem; padding: 0 1.2rem;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--raised); color: var(--ink);
  font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.quiet { background: transparent; }
.btn.danger { background: transparent; border-color: transparent; color: var(--danger); padding: 0; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: 0.5; }
.btn svg { width: 0.9em; height: 0.9em; fill: currentColor; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.topbar .back { text-decoration: none; font-weight: 600; min-height: 3rem; display: inline-flex; align-items: center; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 1.1rem; }

/* Week strip: this week's days, trained ones filled. */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.25rem; margin-bottom: 1rem; text-align: center; }
.week .d { display: grid; justify-items: center; gap: 0.25rem; }
.week .n {
  width: 2.5rem; height: 2.5rem; border-radius: 50%; display: grid; place-items: center;
  font: 600 1.15rem var(--display); color: var(--steel);
}
.week .trained .n { background: var(--accent); color: #fff; }
.week .today .n { box-shadow: 0 0 0 2px var(--accent); color: var(--ink); }
.week .trained.today .n { color: #fff; box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent); }
.week .wd { font-size: 0.75rem; color: var(--steel); }

/* Today card */
.today-card { display: grid; gap: 0.35rem; margin-bottom: 1rem; }
.today-card .label { color: var(--accent); font-weight: 600; font-size: 0.9rem; }
.today-card h2 { font-size: 2.6rem; text-transform: uppercase; }
.today-card .row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.today-card .exercises { color: var(--steel); font-size: 0.95rem; margin-top: 0.2rem; }
.today-card .btn { margin-top: 0.8rem; min-height: 3.4rem; font-size: 1.1rem; }

.others { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: 0.5rem; margin-bottom: 0.5rem; }
.others .btn { border-radius: 14px; flex-direction: column; align-items: flex-start; padding: 0.7rem 0.9rem; min-height: 0; }
.others .btn strong { font: 700 1.3rem var(--display); text-transform: uppercase; }
.others .btn span { font-weight: 400; font-size: 0.8rem; color: var(--steel); }

.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 2rem 0 0.5rem; }

.history { list-style: none; margin: 0; padding: 0; }
.history a { display: flex; align-items: center; gap: 0.8rem; padding: 0.85rem 0; border-bottom: 1px solid var(--line); text-decoration: none; }
.history .dot { width: 0.6rem; height: 0.6rem; border-radius: 50%; background: var(--accent); flex: none; }
.history .meta { flex: 1; }
.history strong { font-weight: 600; }

.empty { padding: 1rem 0; }

/* Body map: body shapes, muscles, and the two highlight levels. */
.body { flex: none; display: block; }
.body .b { fill: #2e2e34; }
.body .m { fill: #42424a; }
.body .p { fill: var(--accent); }
.body .s { fill: rgb(255 90 31 / 0.42); }

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

.week-muscles { display: flex; gap: 1rem; align-items: center; }
.week-muscles dl { margin: 0; display: grid; gap: 0.6rem; }
.week-muscles dt { font-size: 0.8rem; color: var(--steel); }
.week-muscles dd { margin: 0; font-weight: 500; }

/* Workout */
.workout-head { margin-bottom: 1.25rem; }
.workout-head p { margin-top: 0.2rem; }

.exercise { margin-bottom: 0.9rem; padding: 1rem 0.9rem 0.8rem; }
.exercise .head { display: flex; align-items: center; gap: 0.75rem; }
.exercise .head .title { flex: 1; min-width: 0; }
.exercise .head .muscles { color: var(--steel); font-size: 0.85rem; margin-top: 0.1rem; }
.exercise .side { align-self: flex-start; display: grid; justify-items: end; gap: 0.3rem; }
.exercise .rest { color: var(--steel); font-size: 0.85rem; white-space: nowrap; }
.badge { background: var(--accent); color: #fff; font-weight: 600; font-size: 0.85rem; padding: 0.15rem 0.6rem; border-radius: 999px; white-space: nowrap; }
.badge.soft { background: var(--accent-soft); color: var(--accent); }
.notice { margin-bottom: 0.9rem; border-color: var(--accent); background: var(--accent-soft); }

.log { width: 100%; border-collapse: collapse; margin-top: 0.7rem; }
.log th, .log th.no { font: 500 0.75rem var(--body); font-size: 0.75rem; color: var(--steel); text-align: left; padding: 0 0.2rem 0.3rem; }
.log td { padding: 0.2rem; }
.log .no { width: 1.8rem; font: 600 1.05rem var(--display); color: var(--steel); text-align: center; }
.log .prev { color: var(--steel); font-size: 0.95rem; white-space: nowrap; }
.log td.in { width: 4.6rem; }
.log td.ok { width: 2.9rem; }
.log input {
  width: 100%; height: 2.7rem; padding: 0 0.5rem;
  border: 1px solid transparent; border-radius: 10px; background: var(--raised);
  font: 600 1.3rem/1 var(--display); text-align: center;
}
.log input::placeholder { color: var(--steel); opacity: 0.6; }
.log tr.done td { background: var(--accent-soft); }
.log tr.done td:first-child { border-radius: 10px 0 0 10px; }
.log tr.done td:last-child { border-radius: 0 10px 10px 0; }
.log tr.done input { background: transparent; }

.check {
  width: 2.7rem; height: 2.7rem; border-radius: 10px;
  border: 1px solid var(--line); background: var(--raised); cursor: pointer;
  display: grid; place-items: center;
}
.check svg { width: 1.3rem; height: 1.3rem; stroke: var(--steel); stroke-width: 3; fill: none; }
tr.done .check { background: var(--accent); border-color: var(--accent); animation: press 180ms ease-out; }
tr.done .check svg { stroke: #fff; }
@keyframes press { 50% { transform: scale(0.88); } }

.set-actions { display: flex; gap: 1.25rem; margin-top: 0.4rem; }
.set-actions button { background: none; border: 0; padding: 0.5rem 0; color: var(--accent); font-weight: 600; cursor: pointer; }
.set-actions button.minor { color: var(--steel); }

.bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom));
  background: rgb(18 18 18 / 0.92); border-top: 1px solid var(--line); backdrop-filter: blur(10px);
}
.bottom .inner { max-width: 32rem; margin: 0 auto; display: grid; gap: 0.75rem; }
.bottom .row { display: flex; gap: 0.75rem; align-items: center; }
.bottom .progress { flex: 1; font: 600 1.25rem var(--display); }

/* Rest timer */
.restbar { display: flex; align-items: center; gap: 0.6rem; padding: 0.55rem 0.6rem 0.55rem 1rem; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); position: relative; overflow: hidden; }
.restbar .fill { position: absolute; inset: 0 auto 0 0; background: var(--accent-soft); transition: width 250ms linear; }
.restbar > :not(.fill) { position: relative; }
.restbar .time { flex: 1; font: 700 1.9rem/1 var(--display); font-variant-numeric: tabular-nums; }
.restbar .time small { font: 500 0.85rem var(--body); color: var(--steel); margin-left: 0.4rem; }
.restbar .btn { min-height: 2.6rem; padding: 0 0.85rem; font-size: 0.95rem; }
.restbar.over { border-color: var(--accent); }
.restbar.over .time { color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  tr.done .check { animation: none; }
  .restbar .fill { transition: none; }
}

/* Finished workout */
.summary { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin-bottom: 1rem; }
.summary .card { padding: 0.9rem 1rem; }
.summary strong { display: block; font: 700 2rem/1.1 var(--display); }
.logged { list-style: none; padding: 0; margin: 0.4rem 0 0; font: 600 1.3rem/1.5 var(--display); }

/* Schema editor */
.editor label { display: block; font-weight: 600; margin: 1rem 0 0.35rem; }
.editor .text {
  width: 100%; height: 3rem; padding: 0 0.9rem;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
}
.ex-row { display: grid; grid-template-columns: 1fr 3.3rem 3.3rem 4.6rem 2.2rem; gap: 0.35rem; align-items: end; padding: 0.6rem 0; border-bottom: 1px solid var(--line); }
.ex-row label { margin: 0 0 0.2rem; font-size: 0.75rem; font-weight: 500; color: var(--steel); }
.ex-row input, .ex-row select { width: 100%; height: 2.8rem; padding: 0 0.5rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.ex-row .remove { height: 2.8rem; border: 0; background: none; color: var(--danger); font-size: 1.4rem; cursor: pointer; }
.ex-row .step { grid-column: 4 / -1; }
.ex-row .muscle-line { grid-column: 1 / 4; display: flex; align-items: center; gap: 0.6rem; background: none; border: 0; padding: 0.2rem 0; text-align: left; cursor: pointer; color: var(--steel); font-size: 0.9rem; }
.ex-row .muscle-line strong { color: var(--ink); font-weight: 500; }
.picker { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 0.4rem; padding-bottom: 0.3rem; }
.picker p { width: 100%; font-size: 0.8rem; color: var(--steel); }
.chip { min-height: 2.4rem; padding: 0 0.85rem; border-radius: 999px; border: 1px solid var(--line); background: var(--raised); cursor: pointer; font-size: 0.9rem; }
.chip.p { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.s { background: var(--accent-soft); border-color: var(--accent); }
.editor .row { display: flex; gap: 0.75rem; margin-top: 1.25rem; flex-wrap: wrap; }

.plan-list { display: grid; gap: 0.6rem; margin: 1.25rem 0; }
.plan-list a { text-decoration: none; display: block; }
.plan-list h2 { text-transform: uppercase; }

/* Profiel: profile, measurement form, charts */
.profile { margin-top: 1rem; }
.profile .stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5rem; text-align: center; }
.profile .stats strong { display: block; font: 700 1.8rem/1.1 var(--display); }
.edit-profile { margin-top: 0.9rem; border-top: 1px solid var(--line); padding-top: 0.7rem; }
details summary { cursor: pointer; color: var(--accent); font-weight: 600; padding: 0.3rem 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; align-items: end; }
.form-grid .span, .form-grid > .btn { grid-column: 1 / -1; }
.form-grid.inner { margin-top: 0.6rem; }
.edit-profile .form-grid { margin-top: 0.6rem; }
.field-block { display: grid; gap: 0.3rem; font-size: 0.85rem; color: var(--steel); }
.field-block input { width: 100%; height: 3rem; padding: 0 0.8rem; border: 1px solid var(--line); border-radius: 12px; background: var(--raised); color: var(--ink); font: 600 1.25rem var(--display); color-scheme: dark; }
.with-unit { position: relative; display: block; }
.with-unit em { position: absolute; right: 0.8rem; top: 50%; transform: translateY(-50%); font-style: normal; color: var(--steel); pointer-events: none; }
select.text { width: 100%; height: 3rem; padding: 0 0.8rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); margin-bottom: 0.75rem; }

.chart-card { margin-bottom: 0.75rem; }
.chart-head { display: flex; justify-content: space-between; align-items: baseline; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 0.4rem; }
.chart-head strong { font: 700 1.5rem var(--display); }
.chart { position: relative; height: 170px; }
.chart svg { display: block; touch-action: pan-y; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--steel); font: 400 11px var(--body); }
.chart .cross { stroke: var(--steel); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .dot, .chart .focus { stroke: var(--surface); stroke-width: 2; }
.chart .tip {
  position: absolute; pointer-events: none; background: var(--raised); border: 1px solid var(--line);
  border-radius: 10px; padding: 0.3rem 0.6rem; display: grid; font-size: 0.8rem; color: var(--steel); white-space: nowrap;
}
.chart .tip strong { color: var(--ink); font-size: 0.95rem; }
.chart .tip[hidden] { display: none; }

.measurements li { display: flex; align-items: center; gap: 0.8rem; padding: 0.75rem 0; border-bottom: 1px solid var(--line); }
.measurements .meta { flex: 1; }

.toast {
  position: fixed; left: 50%; bottom: 9rem; transform: translateX(-50%); z-index: 10;
  background: var(--ink); color: var(--bg); padding: 0.6rem 1rem; border-radius: 999px;
  max-width: calc(100% - 2rem); font-weight: 500;
}

/* Login */
.login { min-height: 100vh; display: grid; place-content: center; gap: 1.5rem; padding: 1rem; text-align: center; }
.login .mark { width: 5.5rem; height: 5.5rem; margin: 0 auto; }
.login h1 { font-size: 3.4rem; }
.login form { display: grid; gap: 0.75rem; width: min(20rem, 100vw - 2rem); }
.login input { height: 3.2rem; padding: 0 1rem; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-size: 1.1rem; }
.login .error { color: var(--danger); }
