:root {
  --bg:          #0a0a0b;
  --surface:     #141416;
  --surface2:    #1c1c1f;
  --surface3:    #26262a;
  --border:      #2a2a2e;
  --border-hi:   #3a3a3f;
  --text:        #f4f4f5;
  --text-dim:    #a1a1aa;
  --text-muted:  #71717a;
  --accent:      #d4ff3a;
  --accent-dim:  rgba(212,255,58,0.14);
  --ui:   'Inter', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-family: var(--ui);
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; text-decoration: none; }

#app {
  flex: 1;
  display: flex;
  flex-direction: column;
}

button {
  font-family: inherit;
  transition: background 0.12s, color 0.12s, transform 0.05s;
}

button:active, a:active { transform: scale(0.98); }

/* ── Routines view ── */

.routines-view {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 88px;
}

.routines-header {
  padding: 24px 22px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.routines-title {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -1.2px;
}

.list-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 4px 22px 10px;
}

.list-count {
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 600;
}

.list-hint {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
}

.card-list {
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Routine card */
.routine-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: transform 0.1s, border-color 0.1s;
}

.routine-card:active { transform: scale(0.99); }

.routine-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--surface3);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.5px;
  flex-shrink: 0;
  text-transform: uppercase;
}

.routine-info {
  flex: 1;
  min-width: 0;
}

.routine-name {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.routine-meta {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 2px;
  display: flex;
  gap: 8px;
}

.mono { font-family: var(--mono); }
.muted { color: var(--text-muted); }

.routine-chev { color: var(--text-muted); flex-shrink: 0; }

/* Add routine */
.add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px;
  border-radius: 18px;
  border: 1px dashed var(--border-hi);
  background: transparent;
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s;
}

.add-btn:active { transform: scale(0.99); }

.add-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--accent);
}

.add-form input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: var(--ui);
  font-size: 16px;
  font-weight: 600;
  outline: none;
  padding: 6px 4px;
}

.add-form input::placeholder { color: var(--text-muted); }

.btn-cancel {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

.btn-submit {
  background: var(--accent);
  border: none;
  color: #0a0a0b;
  border-radius: 10px;
  padding: 8px 14px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
}

/* ── Exercises view ── */

.exercises-view {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 88px;
  display: flex;
  flex-direction: column;
}

.exercises-topbar {
  padding: 8px 8px 12px;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.icon-btn:active { transform: scale(0.98); }

.exercises-heading {
  padding: 0 22px 16px;
  flex-shrink: 0;
}

.routine-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 500;
}

.exercises-title {
  margin: 4px 0 0;
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -1.2px;
}


/* Set counter */
.set-counter-card {
  margin: 0 16px 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.set-counter-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.set-counter-label {
  font-size: 9px;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
}

.set-counter-num {
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 800;
  color: var(--text-dim);
  letter-spacing: -1px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.set-counter-num.active { color: var(--accent); }

.btn-count {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.btn-count:active { transform: scale(0.96); }

.btn-count-add {
  background: var(--accent);
  border-color: var(--accent);
  color: #0a0a0b;
}

.btn-count-reset {
  height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  font-family: var(--ui);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  flex-shrink: 0;
}

.btn-count-reset:active { transform: scale(0.96); }

.exercise-list {
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Exercise row */
.exercise-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.ex-index {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
}

.ex-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.ex-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ex-last {
  margin-top: 3px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
}

.ex-weight-wrap {
  display: flex;
  align-items: baseline;
  gap: 3px;
  flex-shrink: 0;
}

.weight-input {
  width: 72px;
  height: 44px;
  padding: 0 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  outline: none;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.weight-input::placeholder { color: var(--text-muted); }

.weight-input:not(:placeholder-shown) {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

.weight-input:focus {
  border-color: var(--border-hi);
}

.weight-input:not(:placeholder-shown):focus {
  border-color: var(--accent);
}

.weight-unit {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
}


/* ── Edit mode ── */

.topbar-spacer { flex: 1; }

.icon-btn-accent {
  background: var(--accent-dim);
  color: var(--accent);
}

.edit-list {
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.edit-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.btn-delete {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  flex-shrink: 0;
  background: rgba(239,68,68,0.12);
  color: #ef4444;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-delete:active { transform: scale(0.94); }

.btn-delete-confirm {
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  flex-shrink: 0;
  background: rgba(239,68,68,0.18);
  color: #ef4444;
  border: 1px solid rgba(239,68,68,0.3);
  cursor: pointer;
  font-family: var(--ui);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.btn-delete-confirm:active { transform: scale(0.94); }

.edit-name-muted { color: var(--text-dim); }

.edit-name {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.edit-name-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--accent);
  color: var(--text);
  font-family: var(--ui);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.2px;
  outline: none;
  padding: 2px 0;
}

.edit-move {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
}

.btn-move {
  width: 32px;
  height: 28px;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-move:active { transform: scale(0.94); }

/* Add exercise section */
.add-exercise-section {
  padding: 8px 16px 0;
  display: flex;
  flex-direction: column;
}

.add-exercise-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--accent);
  width: 100%;
}

.add-exercise-form input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: var(--ui);
  font-size: 15px;
  font-weight: 600;
  outline: none;
  padding: 6px 4px;
}

.add-exercise-form input::placeholder { color: var(--text-muted); }

/* ── Bottom nav ── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 8px 16px;
  display: flex;
  gap: 8px;
  z-index: 10;
}

.nav-item {
  flex: 1;
  padding: 10px 8px;
  border-radius: 14px;
  background: transparent;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.2px;
  transition: background 0.12s, color 0.12s;
}

.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
}

/* ── Stats view ── */

.stats-view {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding-bottom: 40px;
}

.stats-topbar {
  padding: 8px 8px 0;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.stats-heading {
  padding: 12px 22px 8px;
  flex-shrink: 0;
}

.stats-title {
  margin: 4px 0 0;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -1px;
}

.stats-hero {
  padding: 8px 22px 16px;
  flex-shrink: 0;
}

.stats-hero-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.stats-big-weight {
  font-family: var(--mono);
  font-size: 56px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -2px;
  line-height: 1;
}

.stats-big-unit {
  font-family: var(--mono);
  font-size: 18px;
  color: var(--text-dim);
  font-weight: 600;
}

.stats-gain {
  margin-left: 8px;
  padding: 4px 8px;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
}

.gain-pos {
  background: rgba(34, 197, 94, 0.14);
  color: #22c55e;
}

.gain-neg {
  background: rgba(239, 68, 68, 0.14);
  color: #ef4444;
}

.stats-since {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--mono);
}

.stats-chart-wrap {
  padding: 0 16px;
  flex-shrink: 0;
}

.stats-chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
}

.stats-chart-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}

.chart-label {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 600;
  font-family: var(--mono);
}

.chart-sessions {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--mono);
}

.stats-svg {
  width: 100%;
  height: auto;
  display: block;
}

.stats-x-labels {
  margin-top: 6px;
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 9px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  padding: 0 14px;
}

.stats-row {
  padding: 12px 16px;
  display: flex;
  gap: 8px;
}

.big-stat {
  flex: 1;
  padding: 12px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.big-stat-label {
  font-size: 9px;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
  margin-bottom: 4px;
}

.big-stat-value {
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.5px;
}

.big-stat-accent .big-stat-value {
  color: var(--accent);
}

.stats-history-header {
  padding: 8px 22px 6px;
  display: flex;
  justify-content: space-between;
}

.history-label {
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 700;
  letter-spacing: -0.2px;
}

.history-hint {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
}

.history-list {
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.history-row {
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.history-date-box {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  font-family: var(--mono);
  flex-shrink: 0;
}

.history-day {
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
}

.history-month {
  color: var(--text-muted);
  font-size: 8px;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.history-body {
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.history-weight {
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}

.history-unit {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
}

.pr-badge {
  margin-left: auto;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 9px;
  font-weight: 800;
  font-family: var(--mono);
  letter-spacing: 1px;
}

.history-diff {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.diff-pos { color: #22c55e; }
.diff-neg { color: #ef4444; }

.stats-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 14px;
}

a.ex-name {
  display: block;
}
