:root {
  --bg: #111214;
  --card: #1b1d21;
  --card2: #24272c;
  --line: #2e3238;
  --text: #f2f3f5;
  --muted: #8b919a;
  --accent: #c6f432;
  --accent-ink: #151a02;
  --danger: #ff5c5c;
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  padding-bottom: calc(110px + var(--safe-bottom));
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; touch-action: manipulation; }
input { font: inherit; color: inherit; }

header {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  padding: calc(var(--safe-top) + 10px) 16px 10px;
  background: rgba(17,18,20,.92);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
header h1 { flex: 1; margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { font-size: 32px; line-height: 1; width: 36px; height: 36px; margin-left: -8px; color: var(--accent); }
#sync { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
#sync.ok { background: #3ddc84; }
#sync.pending { background: #f5b13d; }
#sync.err { background: var(--danger); }

main { padding: 16px; max-width: 640px; margin: 0 auto; }

.card {
  background: var(--card); border-radius: var(--radius);
  padding: 14px 14px 12px; margin-bottom: 12px;
}
.card h2 { margin: 0; font-size: 17px; font-weight: 650; }
.row { display: flex; align-items: center; gap: 10px; }
.row .grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 4px 8px; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 54px; padding: 0 18px;
  border-radius: 14px; font-weight: 650; font-size: 17px;
  background: var(--card2);
}
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 40px; font-size: 15px; width: auto; }
.btn:active, .chip:active, .add-quick:active, .step:active { transform: scale(.97); }

.fab-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 4;
  padding: 12px 16px calc(12px + var(--safe-bottom));
  background: linear-gradient(transparent, var(--bg) 35%);
}
.fab-bar > div { max-width: 640px; margin: 0 auto; display: flex; gap: 10px; }

/* exercise card in workout */
.ex-head { display: flex; align-items: baseline; gap: 8px; }
.ex-head h2 { flex: 1; }
.last { margin: 4px 0 10px; font-size: 13px; color: var(--muted); }
.last b { color: #c2c7ce; font-weight: 500; }
.sets { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: baseline; gap: 3px;
  padding: 9px 12px; border-radius: 12px; background: var(--card2);
  font-variant-numeric: tabular-nums; font-size: 16px;
}
.chip .x { color: var(--muted); font-size: 13px; }
.chip .w { font-weight: 600; }
.chip .r { font-weight: 700; }
.chip.up { box-shadow: inset 0 0 0 1.5px var(--accent); }
.add-row { display: flex; gap: 8px; margin-top: 10px; }
.add-quick {
  flex: 1; min-height: 48px; border-radius: 12px;
  background: rgba(198,244,50,.12); color: var(--accent); font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.add-more { width: 56px; min-height: 48px; border-radius: 12px; background: var(--card2); font-size: 22px; }

.timer {
  text-align: center; font-variant-numeric: tabular-nums;
  color: var(--muted); font-size: 14px; margin: -4px 0 12px;
}
.timer b { color: var(--text); font-size: 18px; }

/* list items */
.item { display: flex; align-items: center; gap: 12px; padding: 14px; background: var(--card); border-radius: 14px; margin-bottom: 8px; width: 100%; text-align: left; }
.item .grow { flex: 1; min-width: 0; }
.item .title { font-weight: 600; }
.item .sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .chev { color: var(--muted); font-size: 22px; }
.badge { font-size: 12px; padding: 3px 8px; border-radius: 99px; background: var(--accent); color: var(--accent-ink); font-weight: 700; }

/* bottom sheet */
#sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 20; }
#sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21;
  background: var(--card); border-radius: 22px 22px 0 0;
  padding: 10px 18px calc(18px + var(--safe-bottom));
  max-width: 640px; margin: 0 auto;
  animation: up .18s ease-out;
  max-height: 90vh; overflow-y: auto;
}
@keyframes up { from { transform: translateY(40px); opacity: .4 } to { transform: none; opacity: 1 } }
#sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
#sheet h3 { margin: 0 0 14px; font-size: 18px; text-align: center; }
.stepper { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.stepper label { width: 92px; color: var(--muted); font-size: 14px; }
.step { width: 60px; height: 60px; border-radius: 16px; background: var(--card2); font-size: 28px; font-weight: 500; flex: none; }
.stepper input {
  flex: 1; min-width: 0; height: 60px; text-align: center;
  background: var(--bg); border: 1px solid var(--line); border-radius: 16px;
  font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.stepper .unit { color: var(--muted); width: 26px; font-size: 14px; }
.sheet-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 6px 2px; }
.field input, .field select {
  width: 100%; height: 50px; padding: 0 14px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px; font-size: 17px; color: var(--text);
}
input[type="date"] { -webkit-appearance: none; appearance: none; }

.pick { display: flex; flex-direction: column; gap: 8px; max-height: 50vh; overflow-y: auto; margin-bottom: 12px; }
.pick button { text-align: left; padding: 14px; border-radius: 12px; background: var(--card2); font-weight: 550; }

.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.history-line { font-size: 14px; font-variant-numeric: tabular-nums; }
svg.spark { width: 100%; height: 90px; display: block; margin: 6px 0 4px; }
.reorder button { width: 34px; height: 34px; border-radius: 10px; background: var(--card2); color: var(--muted); }
pre.export { white-space: pre-wrap; background: var(--bg); border-radius: 12px; padding: 12px; font-size: 14px; margin: 0 0 12px; }
