/* ─── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* ─── Variables ──────────────────────────────────────────────────────────── */
:root {
  --bg: #0a0a0a;
  --surface: #161616;
  --surface-2: #1f1f1f;
  --border: #272727;
  --accent: #22c55e;
  --accent-dim: rgba(34, 197, 94, 0.12);
  --warning: #f59e0b;
  --warning-dim: rgba(245, 158, 11, 0.12);
  --danger: #ef4444;
  --danger-dim: rgba(239, 68, 68, 0.12);
  --text: #f0f0f0;
  --text-2: #888;
  --text-3: #444;
  --nav-h: 64px;
  --mono: 'JetBrains Mono', monospace;
  --radius: 12px;
  --radius-sm: 8px;
}

/* ─── Layout ─────────────────────────────────────────────────────────────── */
.view-container {
  min-height: 100dvh;
  padding-bottom: calc(var(--nav-h) + 24px);
}

.view {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px 0;
}

/* ─── Nav ────────────────────────────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  z-index: 100;
}
.bottom-nav::-webkit-scrollbar { display: none; }

.nav-item {
  flex: 0 0 auto;
  min-width: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-3);
  text-decoration: none;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.03em;
  transition: color 0.15s;
  padding: 0 6px;
}
.nav-item.active { color: var(--accent); }
.nav-item:active { opacity: 0.7; }

.nav-icon {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ─── Typography ─────────────────────────────────────────────────────────── */
.view-title {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--text);
}

.section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 10px;
  margin-top: 4px;
}

/* ─── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.card-title {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}

.card-value {
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}

.card-sub {
  font-size: 12px;
  color: var(--text-2);
  margin-top: 3px;
}

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 13px 20px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
  line-height: 1;
}
.btn:active { opacity: 0.75; }
.btn:disabled { opacity: 0.4; cursor: default; }

.btn-primary {
  background: var(--accent);
  color: #000;
  width: 100%;
}

.btn-outline {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border);
  width: 100%;
}

.btn-ghost {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  width: 100%;
}

.btn-sm {
  padding: 8px 14px;
  font-size: 13px;
}

/* ─── Quick actions ──────────────────────────────────────────────────────── */
.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.quick-action {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 12px;
  text-align: center;
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: background 0.15s;
}
.quick-action:active { background: var(--surface-2); }
.quick-action .qa-icon { font-size: 22px; }
.quick-action.accent {
  border-color: rgba(34, 197, 94, 0.4);
  color: var(--accent);
  background: var(--accent-dim);
}

/* ─── Stats row ──────────────────────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

/* ─── Workout view ───────────────────────────────────────────────────────── */
.workout-type-picker {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.type-btn {
  flex: 1;
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 20px;
  font-weight: 700;
  font-family: var(--mono);
  cursor: pointer;
  transition: all 0.15s;
}
.type-btn.active {
  border-color: rgba(34, 197, 94, 0.5);
  color: var(--accent);
  background: var(--accent-dim);
}

.exercise-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  transition: border-color 0.2s;
}
.exercise-card.done { border-color: rgba(34, 197, 94, 0.3); }

.exercise-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.exercise-name {
  font-size: 17px;
  font-weight: 600;
}
.exercise-card.done .exercise-name { color: var(--text-2); }

.exercise-weight-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.weight-input {
  width: 68px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  padding: 6px 2px;
}
.weight-input:focus { outline: none; border-color: var(--accent); }

.weight-unit {
  color: var(--text-2);
  font-size: 13px;
}

.progression-hint {
  font-size: 11px;
  color: var(--accent);
  margin-bottom: 10px;
  font-family: var(--mono);
}

.sets-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.set-btn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface-2);
  color: var(--text-3);
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.set-btn.completed {
  border-color: var(--accent);
  background: var(--accent);
  color: #000;
}
.set-btn.failed {
  border-color: var(--danger);
  background: var(--danger-dim);
  color: var(--danger);
}
.set-btn:active { transform: scale(0.88); }

/* ─── Complete banner ────────────────────────────────────────────────────── */
.complete-banner {
  background: var(--accent-dim);
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  margin-bottom: 12px;
}
.complete-banner-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
}
.complete-banner-sub {
  font-size: 12px;
  color: var(--text-2);
  margin-top: 4px;
}

/* ─── Form ───────────────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 14px;
}
.form-group.mb-0 { margin-bottom: 0; }

.form-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.form-input,
.form-select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 16px;
  padding: 11px 13px;
}
.form-input:focus,
.form-select:focus { outline: none; border-color: var(--accent); }
.form-input::placeholder { color: var(--text-3); }
.form-input[readonly] { color: var(--text-2); }

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  padding-right: 36px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-hint {
  font-size: 11px;
  color: var(--text-2);
  margin-top: 4px;
}

.time-pair {
  display: flex;
  align-items: center;
  gap: 4px;
}

.time-pair .time-part {
  flex: 1;
  min-width: 0;
  text-align: center;
}

.time-colon {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 600;
  color: var(--text-1);
  line-height: 1;
  flex-shrink: 0;
}

/* ─── Kettlebell set builder ─────────────────────────────────────────────── */
.set-builder {
  margin-bottom: 10px;
}

.set-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.set-row .form-input {
  flex: 1;
  padding: 10px 10px;
  font-size: 16px;
}

.set-row-num {
  font-size: 12px;
  color: var(--text-2);
  min-width: 36px;
  font-family: var(--mono);
}

.remove-set-btn {
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 6px;
  line-height: 1;
  border-radius: 4px;
}
.remove-set-btn:active { color: var(--danger); }

.add-set-btn {
  background: none;
  border: 1px dashed var(--border);
  color: var(--text-2);
  border-radius: var(--radius-sm);
  width: 100%;
  padding: 10px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  margin-top: 2px;
}
.add-set-btn:active { background: var(--surface-2); }

/* ─── History list ───────────────────────────────────────────────────────── */
.history-list .card { margin-bottom: 0; }

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.history-item:last-child { border-bottom: none; }

.history-date {
  color: var(--text-2);
  font-size: 11px;
  font-family: var(--mono);
  flex-shrink: 0;
  margin-left: 10px;
}

.history-main {
  font-size: 14px;
  font-weight: 500;
}

.history-sub {
  color: var(--text-2);
  font-size: 12px;
  margin-top: 2px;
}

/* ─── Charts ─────────────────────────────────────────────────────────────── */
.chart-wrap {
  position: relative;
  height: 200px;
}

.chart-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.chart-tab {
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}
.chart-tab.active {
  border-color: rgba(34, 197, 94, 0.5);
  color: var(--accent);
  background: var(--accent-dim);
}

.range-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
}

.range-tab {
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text-2);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
}
.range-tab.active { border-color: rgba(34, 197, 94, 0.5); color: var(--accent); }

.chart-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--text-3);
  font-size: 14px;
}

/* ─── Timer overlay ──────────────────────────────────────────────────────── */
.timer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  padding: 16px;
  padding-bottom: calc(var(--nav-h) + 20px);
}
.timer-overlay.hidden { display: none; }

.timer-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px 20px;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  text-align: center;
}

.timer-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 16px;
}

.timer-ring-wrap {
  position: relative;
  width: 148px;
  height: 148px;
  margin: 0 auto 20px;
}

.timer-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.timer-ring-bg {
  fill: none;
  stroke: var(--surface-2);
  stroke-width: 8;
}

.timer-ring-fg {
  fill: none;
  stroke: var(--warning);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 301.6;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear, stroke 0.3s;
}
.timer-ring-fg.done { stroke: var(--accent); }

.timer-time {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--mono);
  font-size: 38px;
  font-weight: 700;
  color: var(--text);
}

.timer-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 10px;
}

.timer-action-btn {
  flex: 1;
  font-size: 13px;
  padding: 10px 8px;
}

/* ─── Stat PR card ───────────────────────────────────────────────────────── */
.pr-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ─── Empty state ────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-3);
  font-size: 14px;
}

/* ─── Divider ────────────────────────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* ─── Icon buttons (edit / delete in history rows) ───────────────────────── */
.icon-btn {
  background: none;
  border: none;
  padding: 4px 5px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  border-radius: 6px;
  opacity: 0.5;
  transition: opacity 0.15s, background 0.15s;
}
.icon-btn:hover { opacity: 1; background: var(--surface-2); }
.icon-btn:active { opacity: 1; }

/* ─── Small select (long exercise lists) ─────────────────────────────────── */
.form-select-sm {
  font-size: 13px;
  padding: 11px 30px 11px 10px;
}

/* ─── Body measurements chips ────────────────────────────────────────────── */
.measure-chip {
  display: inline-block;
  font-size: 12px;
  color: var(--text-2);
  margin-right: 8px;
}
.measure-chip strong { color: var(--text); }

/* ─── Auth screen ────────────────────────────────────────────────────────── */
.auth-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-inner {
  width: 100%;
  max-width: 320px;
  text-align: center;
}

.auth-mark {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  margin-bottom: 18px;
}

.auth-title {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.auth-sub {
  color: var(--text-2);
  font-size: 14px;
  margin-top: 6px;
  margin-bottom: 28px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}

.auth-error {
  color: var(--danger);
  font-size: 13px;
  text-align: center;
  margin-top: 2px;
}

/* ─── Utility ────────────────────────────────────────────────────────────── */
.hidden { display: none; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-0 { margin-bottom: 0 !important; }
.text-accent { color: var(--accent); }
.text-muted { color: var(--text-2); }
.mono { font-family: var(--mono); }
.bold { font-weight: 600; }
