:root {
  --bg: #0d0d0f; --surface: #18181b; --surface-2: #232327; --border: #2e2e33;
  --text: #fafafa; --muted: #a1a1aa; --accent: #c6f432; --accent-ink: #0d0d0f;
  --good: #22c55e; --bad: #ef4444; --warn: #f59e0b; --radius: 16px;
  --tab-h: 60px;
  color-scheme: dark; /* native date pickers, checkboxes and selects render dark */
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overscroll-behavior: none; }
body {
  overflow: hidden; font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; touch-action: manipulation; cursor: pointer; border: 0; background: none; padding: 0; }
button:active, a.tab:active, .chip:active { transform: scale(.97); }
button:disabled { opacity: .35; pointer-events: none; }
input, select { font: inherit; font-size: 16px; color: var(--text); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.accent { color: var(--accent); }

/* ---------- layout ---------- */
#app { position: relative; max-width: 430px; height: 100dvh; margin: 0 auto; display: flex; flex-direction: column; background: var(--bg); }
#hdr { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 56px;
  padding: calc(env(safe-area-inset-top) + 6px) 16px 6px 16px; flex: none; }
#hdr h1 { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
#hdr h1.small { font-size: 19px; }
#hdr .back { display: flex; align-items: center; justify-content: center; width: 40px; height: 48px; margin-left: -10px; }
.hright { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.hbtn { display: flex; align-items: center; justify-content: center; width: 48px; height: 48px; color: var(--muted); }
.dot { width: 48px; height: 48px; position: relative; }
.dot::after { content: ""; position: absolute; inset: 0; margin: auto; width: 10px; height: 10px; border-radius: 50%; background: #6b6b73; }
.dot.pending::after { background: var(--warn); }
.dot.error::after { background: var(--bad); }
.dot.ok::after { background: #6b6b73; }
.ico { width: 24px; height: 24px; display: block; }
#main { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 4px 12px 24px; }
.screen { display: flex; flex-direction: column; gap: 12px; }
#tabs { flex: none; display: flex; height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--border); }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); font-size: 11px; min-height: 48px; }
.tab.on { color: var(--accent); }
#app.login #hdr, #app.login #tabs { display: none; }

/* timer bar */
#timerbar { display: none; position: relative; flex: none; align-items: center; justify-content: space-between; gap: 8px;
  height: 64px; padding: 0 8px 0 16px; background: var(--surface-2); border-top: 1px solid var(--border); overflow: hidden; }
#app.has-timer #timerbar { display: flex; }
#timerbar .fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: rgba(198,244,50,.16); transition: width .25s linear; }
#timerbar .count { position: relative; font-size: 32px; font-weight: 700; margin-right: auto; }
#timerbar .tbtn { position: relative; height: 48px; min-width: 64px; padding: 0 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); font-weight: 600; }
#timerbar.flash { background: var(--accent); color: var(--accent-ink); }
#timerbar.flash .tbtn { background: transparent; border-color: rgba(13,13,15,.4); }

#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(90px + env(safe-area-inset-bottom)); z-index: 50;
  background: var(--accent); color: var(--accent-ink); font-weight: 600; padding: 12px 18px; border-radius: 999px; }

/* ---------- cards + buttons ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.card.bad { border-color: var(--bad); background: rgba(239,68,68,.10); }
.card.outline { border-color: var(--accent); background: transparent; }
.card h3 { margin: 0 0 4px; font-size: 17px; }
.btn-primary { width: 100%; height: 56px; border-radius: var(--radius); background: var(--accent); color: var(--accent-ink); font-size: 17px; font-weight: 700; }
.btn-secondary { width: 100%; min-height: 52px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); font-weight: 600; padding: 0 16px; }
.btn-danger { width: 100%; min-height: 52px; border-radius: var(--radius); background: transparent; border: 1px solid var(--bad); color: var(--bad); font-weight: 600; }
.field { width: 100%; height: 52px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); padding: 0 14px; }
.field.hl { border-color: var(--accent); }
.field.code { letter-spacing: .4em; text-align: center; font-size: 24px; font-weight: 700; }
label.lbl { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; min-width: 0; }

/* ---------- today ---------- */
.titleblock { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; padding: 4px 4px 0; }
.titleblock .t1 { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.chip { height: 40px; padding: 0 14px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: 14px; font-weight: 600; white-space: nowrap; }
.ex-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.ex-name { font-size: 17px; font-weight: 600; }
.sug { margin-top: 8px; color: var(--accent); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.sug-msg { color: var(--accent); font-size: 13px; opacity: .85; margin-top: 2px; }
.trend { font-size: 18px; }
.set { display: flex; flex-direction: column; gap: 8px; padding: 12px 0 4px; margin-top: 8px; border-top: 1px solid var(--border); }
.set-label { font-size: 13px; color: var(--muted); }
.steppers { display: flex; gap: 8px; align-items: center; }
.grp { display: flex; align-items: center; min-width: 0; }
.grp.kg { flex: 1.25; } .grp.reps { flex: 1; }
.stp { width: 52px; height: 52px; flex: none; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); font-size: 26px; font-weight: 600; line-height: 1; }
.val { flex: 1; min-width: 0; height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 700; line-height: 1; text-align: center; background: transparent; }
.val small { font-size: 11px; font-weight: 500; color: var(--muted); margin-top: 3px; }
.val.sm { font-size: 19px; }
input.val { font-size: 16px; font-weight: 700; border: 1px solid var(--accent); border-radius: 10px; width: 100%; padding: 0; }
.log { width: 100%; height: 56px; border-radius: 12px; background: var(--accent); color: var(--accent-ink); font-size: 17px; font-weight: 700; }
.log.off { opacity: .35; }
.set.logged { flex-direction: row; align-items: center; background: rgba(34,197,94,.12); border: 0; border-left: 3px solid var(--good);
  border-radius: 8px; padding: 0 0 0 12px; margin-top: 8px; min-height: 52px; gap: 0; }
.logged-main { flex: 1; display: flex; align-items: center; gap: 14px; min-height: 52px; text-align: left; }
.logged-main .num { width: 22px; color: var(--muted); font-weight: 600; }
.logged-main .lv { font-size: 22px; font-weight: 700; }
.x { width: 52px; height: 52px; font-size: 26px; color: var(--muted); flex: none; }
.editbar { display: flex; gap: 8px; }
.editbar > * { flex: 1; }
.set.editing { background: rgba(34,197,94,.08); border-left: 3px solid var(--good); border-radius: 8px; padding: 10px 10px 10px 12px; margin-top: 8px; }
.toggle { width: 100%; height: 56px; margin-top: 10px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); font-size: 17px; font-weight: 700; }
.toggle.on { background: rgba(34,197,94,.14); border-color: var(--good); color: var(--good); }
.done-line { display: flex; align-items: center; justify-content: space-between; width: 100%; text-align: left; min-height: 24px; }
.done-line b { color: var(--good); }
.footer-note { text-align: center; font-size: 13px; color: var(--muted); margin: -4px 0 4px; }
.summary h3 { color: var(--accent); }
.summary ul { margin: 6px 0 0; padding-left: 18px; }

/* bottom sheet */
.overlay { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 430px; background: var(--surface); border-radius: 20px 20px 0 0; border: 1px solid var(--border); border-bottom: 0;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); animation: up .22s ease-out; }
@keyframes up { from { transform: translateY(100%); } to { transform: none; } }
.sheet h3 { margin: 0 0 10px; }
.sheet button.opt { width: 100%; display: flex; justify-content: space-between; align-items: center; min-height: 56px; padding: 0 16px; margin-bottom: 8px;
  border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); font-weight: 600; font-size: 17px; }
.sheet button.opt.sel { border-color: var(--accent); }
.rest h2 { margin: 0 0 4px; font-size: 26px; }

/* ---------- week ---------- */
.big { font-size: 64px; font-weight: 700; line-height: 1; letter-spacing: -.03em; }
.days { display: flex; justify-content: space-between; }
.day { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 1; font-size: 12px; color: var(--muted); }
.day.today .dl { color: var(--accent); font-weight: 700; }
.circ { width: 32px; height: 32px; border-radius: 50%; border: 2px solid #4a4a52; }
.circ.done { background: var(--good); border-color: var(--good); }
.circ.miss { border-color: var(--bad); }
.wk { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; }
.wk.now { background: var(--surface-2); outline: 1px solid var(--accent); }
.wk .wl { flex: 1; font-size: 15px; }
.wk .tag { font-size: 11px; color: var(--warn); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.pips { display: flex; gap: 6px; }
.pip { width: 12px; height: 12px; border-radius: 50%; border: 2px solid #4a4a52; }
.pip.f { background: var(--good); border-color: var(--good); }

/* ---------- progress / lists ---------- */
select.field { appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 22px, calc(100% - 15px) 22px; background-size: 5px 5px; background-repeat: no-repeat; }
.chart { width: 100%; height: 200px; display: block; }
.chart .ct { fill: var(--muted); font-size: 11px; }
.chart .cl { fill: var(--accent); font-size: 12px; font-weight: 700; }
.list a, .list .li { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 52px; padding: 8px 0; border-top: 1px solid var(--border); }
.list a:first-child, .list .li:first-child { border-top: 0; }
.tagshort { font-size: 11px; color: var(--warn); border: 1px solid var(--warn); border-radius: 999px; padding: 1px 8px; margin-left: 6px; }
.sec { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 10px 4px 0; }

/* ---------- detail / settings ---------- */
.dset { display: flex; flex-direction: column; gap: 4px; padding-top: 8px; border-top: 1px solid var(--border); margin-top: 8px; }
.dset-top { display: flex; align-items: center; justify-content: space-between; }
.dset-top .x { height: 36px; width: 44px; margin: -6px -8px -6px 0; }
.ex-row { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 56px; text-align: left; padding: 6px 0; }
.ex-form { padding: 4px 0 8px; }
.sw { display: flex; align-items: center; justify-content: space-between; min-height: 52px; }
.sw input { width: 28px; height: 28px; accent-color: var(--accent); }
.reorder { display: flex; gap: 8px; margin-top: 12px; }
.reorder button { flex: 1; min-height: 52px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); font-weight: 600; }
.addbtn { width: 100%; min-height: 52px; color: var(--accent); font-weight: 600; text-align: left; padding: 0 4px; }

/* ---------- login ---------- */
.login { display: flex; flex-direction: column; gap: 14px; padding: 18vh 8px 0; }
.login h1 { font-size: 44px; margin: 0; letter-spacing: -.03em; }
.err { color: var(--bad); min-height: 1.4em; margin: 0; }
