:root {
  --bg: #0e1014;
  --card: #181b22;
  --card2: #20242d;
  --line: #2a2f3a;
  --text: #f2f4f7;
  --muted: #8b93a3;
  --accent: #c8f542;
  --accent-ink: #141a00;
  --danger: #ff6b6b;
  --r: 16px;
  --tabh: 58px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior-y: none;
  -webkit-user-select: none; user-select: none;
  -webkit-text-size-adjust: 100%;
}
input { -webkit-user-select: text; user-select: text; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; touch-action: manipulation; }

#app {
  max-width: 560px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 14px) 16px calc(var(--tabh) + env(safe-area-inset-bottom) + 24px);
}

h1 { font-size: 28px; line-height: 1.15; margin: 4px 0 6px; letter-spacing: -.02em; }
h2 { font-size: 22px; margin: 6px 0 14px; letter-spacing: -.01em; }
h3 { font-size: 13px; margin: 22px 4px 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.eyebrow { color: var(--accent); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.num { font-variant-numeric: tabular-nums; }

.card { background: var(--card); border-radius: var(--r); padding: 16px; margin-bottom: 12px; }
.card.focus { padding: 20px 16px; border: 1px solid var(--line); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 16px; border-radius: 12px;
  background: var(--card2); font-weight: 600;
}
.btn:active { transform: scale(.98); opacity: .85; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.big { width: 100%; min-height: 60px; font-size: 19px; border-radius: 14px; }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn.danger { color: var(--danger); }
.btn.icon { min-height: 36px; width: 36px; padding: 0; border-radius: 10px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.mt { margin-top: 12px; }

/* lists */
.list { list-style: none; margin: 10px 0 0; padding: 0; }
.list li, .list > button {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 10px 0; border-top: 1px solid var(--line);
}
.list li:first-child, .list > button:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .meta { color: var(--muted); font-size: 14px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); flex: none; display: grid; place-items: center; font-size: 12px; font-weight: 800; }
.dot.done { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.dot.cur { border-color: var(--accent); }
.dot.skip { opacity: .4; }

/* workout */
.wk-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.progress { height: 4px; background: var(--card2); border-radius: 2px; overflow: hidden; margin-bottom: 14px; }
.progress i { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.setline { font-size: 18px; margin-bottom: 10px; }
.setline b { color: var(--accent); font-size: 22px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip { background: var(--card2); border-radius: 999px; padding: 6px 12px; font-size: 14px; font-variant-numeric: tabular-nums; }
.chip.ok { background: rgba(200, 245, 66, .14); color: var(--accent); }
.chip.pr { background: var(--accent); color: var(--accent-ink); font-weight: 700; padding: 2px 8px; font-size: 12px; }
.last { color: var(--muted); font-size: 14px; margin: 6px 0 14px; }
.steppers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.stepper label { display: block; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 6px; text-align: center; }
.stepper > div { display: flex; align-items: stretch; background: var(--card2); border-radius: 14px; overflow: hidden; }
.stepper button { width: 44px; font-size: 26px; font-weight: 500; color: var(--accent); flex: none; }
.stepper button:active { background: var(--line); }
.stepper input {
  flex: 1; min-width: 0; width: 100%; height: 64px; border: 0; background: transparent; text-align: center;
  font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; outline: none; padding: 0;
}
.nextup { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 15px; }
.nextup b { color: var(--text); }
.rest {
  position: sticky; top: calc(env(safe-area-inset-top) + 8px); z-index: 5;
  background: var(--card2); border: 1px solid var(--accent); border-radius: 14px;
  padding: 10px 12px; margin-bottom: 12px; display: flex; align-items: center; gap: 12px; overflow: hidden;
}
.rest[hidden] { display: none; }
.rest b { font-size: 22px; font-variant-numeric: tabular-nums; }
.rest .bar { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--accent); width: 0; }

/* plan editor */
.field { width: 100%; height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); padding: 0 12px; outline: none; }
.field:focus { border-color: var(--accent); }
.ex-edit { padding: 12px 0; border-top: 1px solid var(--line); }
.ex-edit:first-of-type { border-top: 0; }
.ex-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 8px; }
.ex-grid label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; display: block; margin-bottom: 3px; }
.ex-grid .field { text-align: center; padding: 0 4px; }

/* history */
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--card); border-radius: 12px; padding: 4px; margin-bottom: 14px; }
.seg button { min-height: 38px; border-radius: 9px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--card2); color: var(--text); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.stat { background: var(--card); border-radius: 14px; padding: 12px; }
.stat b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); }
.hhead { display: flex; width: 100%; align-items: center; gap: 10px; text-align: left; }
.spark { flex: none; }
.spark polyline { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.spark circle { fill: var(--accent); }
.exhist { margin-top: 10px; }
.exhist .ename { font-weight: 600; margin-top: 10px; display: flex; gap: 8px; align-items: center; }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }

/* tabs */
#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(14, 16, 20, .92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
#tabs button { height: var(--tabh); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: 11px; font-weight: 600; }
#tabs button.on { color: var(--accent); }
#tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabh) + env(safe-area-inset-bottom) + 16px); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-weight: 600; font-size: 14px; z-index: 20;
  white-space: nowrap;
}
