:root {
  /* dataviz reference palette — dark mode tokens */
  --surface-1: #1a1a19;
  --page: #0d0d0d;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255,255,255,0.10);
  --series-dl: #3987e5;   /* deadlift — blue */
  --series-sq: #199e70;   /* squat — aqua */
  --good: #0ca30c;
  --warn: #fab219;
  --accent: #3987e5;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; background: var(--page); color: var(--text-primary);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
header {
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px 16px 10px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--page); z-index: 5;
}
h1 { margin: 0; font-size: 20px; }
nav { display: flex; gap: 6px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
nav button {
  background: var(--surface-1); color: var(--text-secondary); border: 1px solid var(--border);
  padding: 10px 16px; border-radius: 999px; cursor: pointer; font-size: 15px;
  flex: 0 0 auto; min-height: 44px;
}
nav button.active { background: var(--accent); border-color: var(--accent); color: #0d0d0d; font-weight: 600; }

main { padding: 16px; max-width: 760px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; }

.card {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px; margin-bottom: 14px;
}
.card h2 { margin: 0 0 8px; font-size: 17px; }
.card h3 { margin: 0 0 6px; font-size: 14px; color: var(--text-secondary); font-weight: 600; }
.small { font-size: 13px; color: var(--muted); }
.note {
  font-size: 13px; color: var(--text-secondary); background: var(--page);
  border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-top: 10px;
}

.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 13px; background: var(--page); color: var(--text-secondary);
  border: 1px solid var(--border); margin-left: 6px; vertical-align: middle;
}
.badge.deload { border-color: var(--warn); color: var(--warn); }
.badge.rest   { border-color: var(--good); color: var(--good); }
.badge.phase  { border-color: var(--accent); color: var(--accent); }

.deload-banner {
  border: 1px solid var(--warn); border-radius: 10px; padding: 12px 14px;
  color: var(--warn); font-weight: 600; margin-bottom: 14px; background: rgba(250,178,25,0.07);
}

/* --- session logging --- */
.exercise { background: var(--page); border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin-top: 12px; }
.exercise-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.exercise-head .name { font-weight: 700; font-size: 16px; }
.exercise-head .target { color: var(--text-secondary); font-size: 14px; }
.exercise-head .target strong { color: var(--accent); font-size: 16px; }

.sets-grid { display: grid; grid-template-columns: 34px 1fr 1fr 52px; gap: 8px; margin-top: 10px; align-items: center; }
.sets-grid .h { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.sets-grid .n { color: var(--muted); text-align: center; }
.sets-grid .done {
  background: var(--surface-1); border: 1px solid var(--baseline); border-radius: 8px;
  min-height: 48px; width: 100%; cursor: pointer; color: var(--muted); font-size: 20px;
}
.sets-grid .done.on { background: var(--good); border-color: var(--good); color: #0d0d0d; font-weight: 700; }
input, select, textarea {
  background: var(--surface-1); border: 1px solid var(--baseline); color: var(--text-primary);
  border-radius: 8px; padding: 12px; font-size: 17px; width: 100%; min-height: 48px;
  font-variant-numeric: tabular-nums;
}
textarea { min-height: 64px; font-size: 15px; }
label { font-size: 13px; color: var(--muted); display: block; margin-bottom: 4px; }

.rpe-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.rpe-row button {
  flex: 1 0 40px; min-height: 48px; border-radius: 8px; border: 1px solid var(--baseline);
  background: var(--surface-1); color: var(--text-secondary); font-size: 16px; cursor: pointer;
}
.rpe-row button.on { background: var(--accent); color: #0d0d0d; border-color: var(--accent); font-weight: 700; }

button.primary {
  background: var(--accent); color: #0d0d0d; border: none; padding: 14px 20px;
  border-radius: 10px; font-weight: 700; cursor: pointer; font-size: 17px; min-height: 52px;
  width: 100%;
}
button.secondary {
  background: var(--surface-1); color: var(--text-primary); border: 1px solid var(--baseline);
  padding: 10px 14px; border-radius: 8px; cursor: pointer; font-size: 15px; min-height: 44px;
}
.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.row > div { flex: 1 1 120px; }

/* --- plan table --- */
.plan-table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.plan-table th { text-align: left; color: var(--muted); font-weight: 500; padding: 6px 8px; border-bottom: 1px solid var(--grid); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.plan-table td { padding: 8px; border-bottom: 1px solid var(--grid); }
.plan-table tr.deload td { color: var(--warn); }
.plan-table tr.current td { background: rgba(57,135,229,0.10); }
.plan-table tr.past td { color: var(--muted); }
.plan-table input { min-height: 36px; padding: 6px 8px; font-size: 14px; width: 72px; }
.plan-wrap { overflow-x: auto; }

/* --- charts --- */
.chart-card svg { display: block; width: 100%; height: auto; }
.legend { display: flex; gap: 16px; margin: 4px 0 10px; font-size: 13px; color: var(--text-secondary); flex-wrap: wrap; }
.legend .key { display: inline-flex; align-items: center; gap: 6px; }
.legend .swatch { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.legend .dot-hollow { width: 8px; height: 8px; border-radius: 50%; border: 2px solid var(--muted); display: inline-block; }

.tooltip {
  position: fixed; z-index: 20; pointer-events: none;
  background: var(--surface-1); border: 1px solid var(--baseline); border-radius: 8px;
  padding: 8px 10px; font-size: 13px; color: var(--text-primary);
  box-shadow: 0 4px 14px rgba(0,0,0,0.5); max-width: 220px;
}
.tooltip .t-date { color: var(--muted); font-size: 12px; }

/* --- history / lists --- */
.history-item { border-left: 3px solid var(--series-dl); padding: 2px 0 2px 12px; margin-bottom: 14px; }
.history-item.squat { border-left-color: var(--series-sq); }
.history-item.deload { border-left-color: var(--warn); }
.history-item .date { font-weight: 600; }
.history-item ul { margin: 4px 0; padding-left: 18px; color: var(--text-secondary); font-size: 14px; }
.list-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--grid); font-variant-numeric: tabular-nums; }
.list-row button { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 16px; min-height: 40px; min-width: 40px; }

.stat-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.stat { flex: 1 1 140px; background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 14px; }
.stat .label { font-size: 13px; color: var(--muted); }
.stat .value { font-size: 26px; font-weight: 600; margin-top: 2px; }
.stat .sub { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
