:root {
  color-scheme: dark;
  --bg: #0e0f11;
  --surface: #17181b;
  --surface-2: #202125;
  --border: #2a2b30;
  --text: #ececea;
  --muted: #8a8b90;
  --good: #3ddc97;
  --warn: #f2c14e;
  --bad: #ff6b6b;
  --radius: 14px;
  --gutter: 16px;
}

* { box-sizing: border-box; }

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

main {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(env(safe-area-inset-top) + 12px) var(--gutter) calc(env(safe-area-inset-bottom) + 16px);
}

.screen { display: flex; flex-direction: column; min-height: calc(100dvh - 28px); }
.screen[hidden] { display: none; }

h1 { font-size: 22px; font-weight: 600; margin: 8px 0 16px; }
.muted { color: var(--muted); font-size: 13px; }
.center { text-align: center; }

.btn {
  font: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 52px;
  padding: 0 18px;
  cursor: pointer;
}
.btn:active { background: var(--surface-2); }
.btn.primary { background: var(--good); color: #062517; border-color: var(--good); font-weight: 600; }
.btn.ghost { background: none; border-color: transparent; color: var(--muted); }
.btn.icon { width: 52px; padding: 0; display: grid; place-items: center; }
.btn.back { min-height: 40px; padding: 0; }

.stack { display: flex; flex-direction: column; gap: 10px; margin-top: auto; }
.home-hero { margin: 25vh 0 32px; text-align: center; }
.logo { font-size: 56px; font-weight: 700; letter-spacing: 0.04em; color: var(--good); }
.notice { background: var(--surface); border: 1px solid var(--warn); color: var(--warn); border-radius: var(--radius); padding: 12px 14px; font-size: 14px; }

.bar { display: flex; justify-content: space-between; align-items: center; min-height: 40px; }

.hero { text-align: center; margin: 24px 0 12px; }
.hero-value {
  font-size: clamp(72px, 26vw, 120px);
  font-weight: 600;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  color: var(--good);
}
.hero-value.warn { color: var(--warn); }
.hero-value.flash { animation: flash 0.5s ease-out; }
@keyframes flash { from { transform: scale(1.06); } to { transform: none; } }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 8px; margin: 12px 0 20px; }
.tile { background: var(--surface); border-radius: var(--radius); padding: 12px 14px; }
.tile .value { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 2px; }
.tile .value small { font-size: 13px; font-weight: 400; color: var(--muted); margin-left: 3px; }
.tile .value.warn { color: var(--warn); }

/* The live screen never scrolls as a page: the rep list scrolls inside, buttons stay in thumb reach. */
#live { height: calc(100dvh - 28px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); min-height: 0; }
#live .reps-wrap { flex: 1; min-height: 0; overflow-y: auto; }
#live .actions { padding-top: 12px; }

.reps-head { display: flex; justify-content: space-between; margin-bottom: 6px; }
.reps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.reps li { display: grid; grid-template-columns: 22px 1fr 52px; align-items: center; gap: 10px; font-variant-numeric: tabular-nums; font-size: 15px; }
.reps .n { color: var(--muted); font-size: 13px; }
.reps .track { height: 10px; background: var(--surface); border-radius: 5px; overflow: hidden; }
.reps .fill { height: 100%; background: var(--good); border-radius: 5px; }
.reps .warn .fill { background: var(--warn); }
.reps .v { text-align: right; }

.actions { display: flex; gap: 8px; margin-top: auto; padding-top: 20px; }
.actions .btn:not(.icon) { flex: 1; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 20px; }
.field .hint { font-size: 12px; line-height: 1.4; }
select, input[type="number"] {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-height: 48px;
  padding: 0 12px;
}
input[type="number"] { width: 76px; min-height: 40px; text-align: right; }
.group-label { margin: 8px 0 4px; }
.row-field, .toggles label {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  min-height: 52px; border-bottom: 1px solid var(--border); font-size: 15px;
}
.toggles { margin-bottom: 16px; }

.switch { appearance: none; width: 46px; height: 28px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); position: relative; cursor: pointer; flex: none; margin: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--muted); transition: transform 0.15s; }
.switch:checked { background: var(--good); border-color: var(--good); }
.switch:checked::after { transform: translateX(18px); background: var(--bg); }

.set-card { background: var(--surface); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.set-card h2 { font-size: 16px; font-weight: 600; margin: 0 0 8px; display: flex; justify-content: space-between; }
.set-card .stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.set-card .stats b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }

.history { list-style: none; margin: 0; padding: 0; }
.history li { border-bottom: 1px solid var(--border); }
.history button { all: unset; display: flex; justify-content: space-between; width: 100%; min-height: 60px; align-items: center; cursor: pointer; }
