:root {
  --bg: #10161d;
  --surface: #172029;
  --surface-2: #1f2a35;
  --border: #2a3744;
  --text: #e8edf2;
  --muted: #8b9aa9;
  --accent: #ffb347;
  --accent-ink: #2b1c04;
  --success: #4ade80;
  --danger: #f87171;
  --radius: 14px;
  --nav-height: 64px;
  --pad: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 { letter-spacing: -0.02em; font-weight: 650; margin: 0 0 8px; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
p { margin: 0 0 12px; }
a { color: var(--accent); }

.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.error {
  color: var(--danger);
  background: rgba(248, 113, 113, 0.12);
  border-radius: 10px;
  padding: 10px 12px;
}

.app-main {
  max-width: 640px;
  margin: 0 auto;
  padding: var(--pad);
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 24px);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--pad);
  margin-bottom: 12px;
}
.card-accent { border-color: var(--accent); }

button, .btn {
  font: inherit;
  min-height: 48px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 0 20px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
}
.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
  font-weight: 650;
  width: 100%;
}
.btn-ghost { background: transparent; }
.btn-sm { min-height: 48px; padding: 0 14px; font-size: 0.9rem; }

input, select, textarea {
  font: inherit;
  width: 100%;
  min-height: 48px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
}
label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 6px; }

.bottom-nav {
  position: fixed;
  inset: auto 0 0 0;
  height: calc(var(--nav-height) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.7rem;
}
.bottom-nav a[aria-current="page"] { color: var(--accent); }
.bottom-nav svg { width: 22px; height: 22px; }

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--pad);
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.pill {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.75rem;
  background: var(--surface-2);
  color: var(--muted);
}
.pill-done { background: rgba(74, 222, 128, 0.15); color: var(--success); }
.pill-today { background: var(--accent); color: var(--accent-ink); }

summary {
  min-height: 48px;
  display: flex;
  align-items: center;
  cursor: pointer;
}

@media (min-width: 720px) {
  :root { --pad: 24px; }
}

/* Workout player */

.set-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }

.set-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
}
.set-row input { margin: 0; width: 5.5rem; text-align: center; }
.set-row .unit { font-size: 0.75rem; }
.set-row .set-number {
  width: 1.5rem;
  color: var(--muted);
  text-align: center;
}
.set-row-logged { border-color: var(--success); }

/* Most-tapped control in the app — hit dozens of times per workout with
   sweaty hands, so it gets the full 48px tap target, not the 44px iOS
   minimum. */
.btn-check {
  margin-left: auto;
  min-width: 52px;
  min-height: 48px;
  border-radius: 999px;
  font-size: 1.25rem;
  line-height: 1;
}
.set-row-logged .btn-check {
  background: var(--success);
  color: var(--accent-ink);
  border-color: var(--success);
}

.row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.row-actions form { display: flex; gap: 8px; align-items: center; margin: 0; }
.row-actions select { margin: 0; width: auto; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Finish flow: difficulty/feeling scales */

.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.scale-option {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  margin: 0;
  cursor: pointer;
}
.scale-option input { position: absolute; opacity: 0; width: 0; height: 0; }
.scale-option:has(input:checked) {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 650;
}
textarea { min-height: 88px; }
