:root {
  --bg: #14161A;
  --surface: #1D2024;
  --surface-2: #24282E;
  --line: #2E333A;
  --text: #EDEEF0;
  --text-muted: #8B909A;
  --amber: #E8B341;
  --amber-dim: #6b5628;
  --green: #5FB68A;
  --red: #D65F5F;
  --radius: 10px;
  --font-display: 'Oswald', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
  height: 100%;
}

body {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

button, input, select {
  font-family: inherit;
  color: inherit;
}

input:focus-visible, select:focus-visible, button:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

.hidden { display: none !important; }

/* ---------- Barbell mark ---------- */
.bar-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  margin: 0 auto 10px;
}
.bar-mark .bar { width: 44px; height: 4px; background: var(--amber); border-radius: 2px; }
.bar-mark .plate { background: var(--amber); border-radius: 3px; }
.bar-mark .plate-l1, .bar-mark .plate-r1 { width: 6px; height: 22px; }
.bar-mark .plate-l2, .bar-mark .plate-r2 { width: 6px; height: 16px; margin: 0 2px; }
.bar-mark.small { height: 18px; margin: 0; }
.bar-mark.small .bar { width: 26px; height: 3px; }
.bar-mark.small .plate-l1, .bar-mark.small .plate-r1 { width: 4px; height: 14px; }

/* ---------- Setup screen ---------- */
.screen.setup {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.setup-card {
  width: 100%;
  max-width: 360px;
  text-align: center;
}
.setup-card h1 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.08em;
  font-size: 28px;
  margin: 0 0 4px;
}
.setup-sub {
  color: var(--text-muted);
  margin: 0 0 28px;
  font-size: 14px;
}
.setup-card label {
  display: block;
  text-align: left;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 14px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.setup-card input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 16px;
}
.error {
  color: var(--red);
  font-size: 13px;
  margin: 4px 0 12px;
}
.btn-primary {
  width: 100%;
  padding: 14px;
  background: var(--amber);
  color: #14161A;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.04em;
  font-size: 15px;
  margin-top: 8px;
}

/* ---------- App shell ---------- */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
}
.topbar h1 {
  font-family: var(--font-display);
  font-size: 15px;
  letter-spacing: 0.12em;
  margin: 0;
  color: var(--text-muted);
  flex: 1;
}
.icon-btn {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--text-muted);
  padding: 4px;
}

.view {
  flex: 1;
  padding: 16px;
  padding-bottom: 90px;
  overflow-y: auto;
}

/* ---------- Log view ---------- */
.today-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 16px;
}
.today-date {
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: 0.02em;
}
.today-count {
  color: var(--text-muted);
  font-size: 13px;
  font-family: var(--font-mono);
}

.exercise-picker select {
  width: 100%;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 16px;
  margin-bottom: 12px;
  appearance: none;
}

.set-form {
  display: grid;
  grid-template-columns: 1fr 1fr 0.7fr;
  gap: 10px;
  margin-bottom: 8px;
}
.set-form .field { display: flex; flex-direction: column; }
.set-form label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}
.set-form input {
  padding: 12px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 17px;
  width: 100%;
}
.btn-add {
  grid-column: 1 / -1;
  padding: 13px;
  background: var(--amber);
  color: #14161A;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.04em;
  margin-top: 4px;
}
.btn-add:active { opacity: 0.85; }

.pr-banner {
  background: var(--green);
  color: #0F1A15;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-align: center;
  padding: 8px;
  border-radius: var(--radius);
  margin: 14px 0;
  font-size: 13px;
}

.today-sets { margin-top: 18px; display: flex; flex-direction: column; gap: 14px; }
.exercise-group {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.exercise-group h3 {
  font-family: var(--font-display);
  font-size: 14px;
  letter-spacing: 0.04em;
  margin: 0 0 8px;
  color: var(--amber);
}
.set-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-top: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 14px;
}
.set-row:first-of-type { border-top: none; }
.set-row .set-num { color: var(--text-muted); width: 24px; }
.set-row .set-data { flex: 1; }
.set-row button {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  padding: 4px 8px;
}

/* ---------- History ---------- */
.history-list, .records-list, .exercise-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.history-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.history-card .h-date {
  font-family: var(--font-display);
  font-size: 15px;
  letter-spacing: 0.03em;
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}
.history-card .h-date button {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
}
.history-card .h-ex {
  font-size: 13px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  padding: 2px 0;
}
.history-card .h-ex strong { color: var(--text); font-weight: 500; }
.empty-state {
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
  padding: 40px 20px;
}

/* ---------- Progress chart ---------- */
.chart-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.progress-stats {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.pstat { display: flex; flex-direction: column; gap: 2px; }
.pstat-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.pstat-value {
  font-family: var(--font-mono);
  font-size: 16px;
}
.pstat-value.pos { color: var(--green); }
.pstat-value.neg { color: var(--red); }

.chart-svg { width: 100%; height: auto; display: block; }
.chart-axis { stroke: var(--line); stroke-width: 1; }
.chart-axis-label {
  fill: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 9px;
}
.chart-line { stroke: var(--amber); stroke-width: 2; }
.chart-dot { fill: var(--amber); }
.chart-dot-pr { fill: var(--green); stroke: var(--bg); stroke-width: 1.5; }

/* ---------- Records ---------- */
.record-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.record-card .r-name { font-family: var(--font-display); font-size: 14px; letter-spacing: 0.02em; }
.record-card .r-cat { color: var(--text-muted); font-size: 11px; text-transform: uppercase; }
.record-card .r-nums { text-align: right; font-family: var(--font-mono); }
.record-card .r-max { color: var(--amber); font-size: 16px; }
.record-card .r-1rm { color: var(--text-muted); font-size: 11px; }

/* ---------- Exercises ---------- */
.exercise-form {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.exercise-form input {
  flex: 1;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 15px;
}
.exercise-form select {
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 13px;
}
.exercise-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.exercise-row .e-name { font-size: 14px; }
.exercise-row .e-cat { color: var(--text-muted); font-size: 11px; text-transform: uppercase; margin-left: 8px; }
.exercise-row button { background: none; border: none; color: var(--red); font-size: 13px; }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1;
  padding: 14px 0 10px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: 0.06em;
}
.tab.active { color: var(--amber); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
