:root {
  --bg: #0b0f0c;
  --card: #141a15;
  --card2: #1a221c;
  --ink: #eef4ee;
  --muted: #93a093;
  --line: #263028;
  --accent: #34d058;
  --accent-dim: #1d7a34;
  --accent2: #4da3ff;
  --accent3: #f0b429;
  --warn: #f0b429;
  --danger: #e5484d;
  --radius: 14px;
  --tab-h: 64px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  max-width: 520px;
  margin: 0 auto;
  padding-bottom: calc(var(--tab-h) + 24px);
  min-height: 100vh;
}
.app-header {
  position: sticky; top: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px;
  background: rgba(11,15,12,.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.brand-mark {
  background: var(--accent); color: #06130a; font-weight: 800; font-size: 14px;
  border-radius: 8px; padding: 4px 7px;
}
.streak { background: var(--card2); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 14px; }
.streak b { color: var(--warn); }
main { padding: 12px 12px 0; }
.view { display: none; }
.view.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px);} to { opacity: 1; transform: none;} }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.card h3 { margin: 0 0 10px; font-size: 15px; }
.card.hero h2 { margin: 4px 0 6px; font-size: 26px; }
.eyebrow { font-size: 12px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--card2); color: var(--ink);
  border-radius: 10px; padding: 11px 14px; font-size: 15px; font-weight: 600; cursor: pointer;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #06130a; }
.btn.big { width: 100%; margin-top: 12px; padding: 14px; font-size: 16px; }
.btn.subtle { width: 100%; margin-top: 8px; background: transparent; }
.btn-row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; }
.btn.on { background: var(--accent-dim); border-color: var(--accent-dim); color: #fff; }
.seg { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; margin-bottom: 10px; }
.seg button { flex: 1; border: 0; background: transparent; color: var(--muted); border-radius: 8px; padding: 9px 4px; font-size: 14px; font-weight: 600; cursor: pointer; }
.seg button.on { background: var(--accent-dim); color: #fff; }
.field { margin: 10px 0; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.field input, .field select {
  width: 100%; background: var(--bg); border: 1px solid var(--line); color: var(--ink);
  border-radius: 10px; padding: 11px 12px; font-size: 16px;
}
.field input:focus, .field select:focus { outline: 2px solid var(--accent-dim); border-color: var(--accent); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check-row {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 12px; margin: 8px 0; font-size: 14px; cursor: pointer;
}
.check-row input { width: 20px; height: 20px; margin-top: 1px; accent-color: var(--accent); flex-shrink: 0; }
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stat { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 6px; text-align: center; }
.stat b { display: block; font-size: 19px; color: var(--accent); }
.stat span { font-size: 11.5px; color: var(--muted); }
.list .item { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 9px 2px; border-bottom: 1px solid var(--line); font-size: 14px; }
.list .item:last-child { border-bottom: 0; }
.list .item .tag { font-size: 11px; font-weight: 700; background: var(--accent-dim); color: #fff; border-radius: 6px; padding: 3px 7px; margin-right: 8px; white-space: nowrap; }
.list .item .del { background: transparent; border: 1px solid var(--line); color: var(--muted); border-radius: 8px; padding: 5px 9px; font-size: 12px; cursor: pointer; }
.list .item .del:hover { color: var(--danger); border-color: var(--danger); }
.empty { color: var(--muted); font-size: 13.5px; padding: 8px 2px; }

/* rings */
.rings { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0 4px; }
.ring { text-align: center; }
.ring svg { width: 96px; height: 96px; display: block; margin: 0 auto; }
.ring .ring-bg { fill: none; stroke: var(--line); stroke-width: 9; }
.ring .ring-fg { fill: none; stroke: var(--accent); stroke-width: 9; stroke-linecap: round; transform: rotate(-90deg); transform-origin: center; transition: stroke-dashoffset .3s ease; }
.ring.done .ring-fg { stroke: var(--warn); }
.ring .ring-num { fill: var(--ink); font-size: 20px; font-weight: 800; text-anchor: middle; }
.ring .ring-den { fill: var(--muted); font-size: 11px; text-anchor: middle; }
.ring b { display: block; font-size: 13px; margin-top: 4px; }
.ring span { font-size: 11.5px; color: var(--muted); }

/* exercise cards */
.ex { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.ex-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.ex-head b { font-size: 16px; }
.ex-head .count { font-size: 14px; color: var(--muted); }
.ex-head .count b { color: var(--accent); font-size: 16px; }
.bar { background: var(--line); border-radius: 999px; height: 8px; overflow: hidden; margin: 10px 0; }
.bar-fill { background: var(--accent); height: 100%; border-radius: 999px; transition: width .25s ease; }
.quick-row { display: flex; gap: 8px; margin: 8px 0; }
.quick-row .btn { flex: 1; padding: 9px 4px; font-size: 14px; }
.log-row { display: flex; gap: 8px; align-items: flex-end; margin-top: 8px; }
.log-row .field { flex: 1; margin: 0; }
.log-row select { flex: 1.4; }
.var-note { font-size: 12px; color: var(--muted); margin: 6px 0 0; }

/* banners */
.warn-banner { border-color: var(--warn); background: rgba(240,180,41,.08); }
.warn-banner b { color: var(--warn); }

/* timer */
.timer-display { font-size: 44px; font-weight: 800; text-align: center; font-variant-numeric: tabular-nums; margin: 4px 0 10px; }

/* calendar */
.cal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.cal-head .btn { padding: 8px 14px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { text-align: center; font-size: 11px; color: var(--muted); padding: 4px 0; }
.cal-day {
  aspect-ratio: 1; border-radius: 8px; background: var(--bg); border: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 13px; cursor: pointer; gap: 1px; padding: 2px;
}
.cal-day .tot { font-size: 10px; color: var(--muted); }
.cal-day.hit { background: rgba(52,208,88,.18); border-color: var(--accent-dim); }
.cal-day.hit .tot { color: var(--accent); }
.cal-day.rest { border-style: dashed; }
.cal-day.today { outline: 2px solid var(--accent); }
.cal-day.sel { background: var(--accent-dim); border-color: var(--accent-dim); color: #fff; }
.cal-day.sel .tot { color: #d8f5dd; }
.cal-day.blank { visibility: hidden; }

/* bar charts */
.bars { display: flex; align-items: flex-end; gap: 8px; height: 120px; padding-top: 8px; }
.bars .bcol { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.bars .bval { font-size: 11px; font-weight: 700; color: var(--accent); }
.bars .bbar { width: 100%; background: var(--accent-dim); border-radius: 5px 5px 0 0; min-height: 3px; }
.bars .blab { font-size: 10.5px; color: var(--muted); text-align: center; }

/* badges */
.badges { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.badge {
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px;
  font-size: 13px; color: var(--muted);
}
.badge b { display: block; color: var(--ink); font-size: 13.5px; margin-bottom: 2px; }
.badge.earned { border-color: var(--accent-dim); color: var(--ink); }
.badge.earned b { color: var(--accent); }

/* form tips */
.form-tip { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; margin: 8px 0; }
.form-tip b { font-size: 14px; }
.form-tip p { margin: 4px 0 0; font-size: 13.5px; color: var(--muted); line-height: 1.45; }

.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 520px; height: var(--tab-h);
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(15,20,16,.96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  border: 0; background: transparent; color: var(--muted);
  font-size: 14px; font-weight: 600; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer;
}
.tabbar button.on { color: var(--accent); }
.toast {
  position: fixed; bottom: calc(var(--tab-h) + 16px); left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--accent); color: #06130a; font-weight: 700; font-size: 14px;
  padding: 11px 18px; border-radius: 999px; opacity: 0; pointer-events: none; transition: all .25s ease;
  max-width: 90vw; text-align: center; z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.toast button {
  margin-left: 10px; background: #06130a; color: var(--accent); border: 0; border-radius: 999px;
  padding: 5px 12px; font-weight: 800; font-size: 13px; cursor: pointer;
}
.danger-zone .btn { font-size: 13px; padding: 9px 10px; }
