:root {
  --bg: #111318;
  --card-bg: #1b1e26;
  --text: #f2f3f5;
  --muted: #9aa0ab;
  --border: #2a2e38;
  --accent: #3d8bfd;
  --magenta: #e6007e;
  --danger: #ff5c5c;
  --radius: 14px;
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

/* ---- Auth overlay ---- */
.auth-overlay[hidden] {
  display: none !important;
}
.auth-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1000;
}
.auth-card {
  width: 100%;
  max-width: 320px;
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 28px 22px;
  text-align: center;
}
.auth-card h1 { margin: 0 0 4px; font-size: 1.6rem; }
.auth-card p { color: var(--muted); margin: 0 0 16px; }
.auth-card input {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #12141a;
  color: var(--text);
  font-size: 1rem;
  margin-bottom: 12px;
}
.auth-card button {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  font-size: 1rem;
  font-weight: 600;
}
.auth-error { color: var(--danger); margin-top: 10px; }

/* ---- App shell ---- */
.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}
.app-header {
  padding: env(safe-area-inset-top) 16px 8px;
  border-bottom: 1px solid var(--border);
}
.app-header h1 { margin: 8px 0; font-size: 1.3rem; }

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

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 12px;
}

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

input[type="text"],
input[type="number"],
input[type="password"],
input[type="date"],
select {
  width: 100%;
  margin-top: 6px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #12141a;
  color: var(--text);
  font-size: 1rem;
}

.row { display: flex; gap: 10px; }
.row label { flex: 1; }

button[type="submit"] {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  font-size: 1rem;
  font-weight: 600;
  margin-top: 4px;
}

.pr-banner {
  margin-top: 12px;
  text-align: center;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--magenta);
}

/* ---- Set list / history ---- */
.set-list { list-style: none; padding: 0; margin: 8px 0 0; }
.set-list li, .exercise-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.set-list li:last-child, .exercise-list li:last-child { border-bottom: none; }

.set-row-delete, .exercise-row-delete {
  color: var(--danger);
  background: none;
  border: none;
  font-size: 0.85rem;
  padding: 4px 8px;
}

.history-day {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.history-day h2 {
  margin: 0 0 10px;
  font-size: 1.05rem;
}
.history-exercise { margin-bottom: 10px; }
.history-exercise-name { font-weight: 600; margin-bottom: 4px; }
.history-sets { color: var(--muted); font-size: 0.92rem; }

/* ---- Progress tab ---- */
.progress-1rm-card { text-align: center; }
.progress-1rm {
  font-size: 3.4rem;
  font-weight: 800;
  color: var(--magenta);
  line-height: 1.1;
}
.progress-1rm-label {
  color: var(--muted);
  margin-top: 6px;
  font-size: 0.9rem;
}

.table-scroll { overflow-x: auto; }
.rep-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 1rem;
}
.rep-table th, .rep-table td {
  padding: 10px 8px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  min-width: 42px;
}
.rep-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
}
.rep-table td { font-weight: 600; }

/* ---- Tab bar ---- */
.tab-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--muted);
  padding: 12px 4px;
  font-size: 0.8rem;
}
.tab-btn.active { color: var(--accent); font-weight: 700; }
