:root {
  --bg: #1a1a1a;
  --fg: #f5f5f5;
  --muted: #9a9a9a;
  --accent: #4caf50;
  --error: #d76f2e;
  --border: #333;
  --card: #242424;
  --input-bg: #2e2e2e;
}

* { box-sizing: border-box; }

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

body {
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}

/* ───── Login page ───── */

body.login-body {
  padding-bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
}

.login {
  text-align: center;
  padding: 24px;
  max-width: 320px;
  width: 100%;
}

.login h1 {
  font-size: 28px;
  font-weight: 600;
  margin: 0 0 32px 0;
  color: var(--fg);
}

.login form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login input {
  padding: 18px;
  font-size: 24px;
  background: var(--input-bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-align: center;
  letter-spacing: 10px;
  -moz-appearance: textfield;
}

.login input::-webkit-outer-spin-button,
.login input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.login input:focus {
  outline: none;
  border-color: var(--accent);
}

.login button {
  padding: 16px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 10px;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
}

.login button:disabled {
  background: #2a2a2a;
  color: var(--muted);
  cursor: default;
}

.login .error {
  color: var(--error);
  font-size: 14px;
  margin-top: 8px;
  min-height: 18px;
}

/* ───── App ───── */

header {
  position: sticky;
  top: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 14px 18px 12px 18px;
  padding-top: calc(14px + env(safe-area-inset-top));
  z-index: 10;
}

#workout-title {
  font-size: 20px;
  font-weight: 600;
}

#workout-meta {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}

main {
  padding: 14px;
}

.exercise {
  background: var(--card);
  border-radius: 12px;
  padding: 14px 14px 8px 14px;
  margin-bottom: 14px;
}

.exercise > header {
  position: static;
  padding: 0;
  border-bottom: none;
  background: transparent;
}

.exercise h2 {
  font-size: 16px;
  margin: 0 0 4px 0;
  font-weight: 600;
}

.exercise h2 a {
  color: var(--fg);
  text-decoration: none;
  border-bottom: 1px dashed var(--muted);
}

.target {
  font-size: 13px;
  color: var(--muted);
}

.notes {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
  font-style: italic;
}

.sets-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}

.sets-table th {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
  text-align: left;
  padding: 4px 4px 8px 4px;
  border-bottom: 1px solid var(--border);
}

.sets-table td {
  padding: 6px 4px;
  vertical-align: middle;
}

.sets-table .set-no {
  width: 42px;
  color: var(--muted);
  font-size: 13px;
}

.sets-table .side {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  color: #fff;
}

.sets-table .side-l { background: #2e7dd7; }
.sets-table .side-r { background: #d76f2e; }

.sets-table tr.right-side {
  border-bottom: 1px solid var(--border);
}
.sets-table tr.right-side td {
  padding-bottom: 10px;
}

.sets-table .prev {
  font-size: 12px;
  color: var(--muted);
  width: 84px;
}

.sets-table input {
  width: 100%;
  padding: 12px 6px;
  font-size: 17px;
  background: var(--input-bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-align: center;
  -moz-appearance: textfield;
}
.sets-table input::-webkit-outer-spin-button,
.sets-table input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.sets-table input:focus {
  outline: none;
  border-color: var(--accent);
  background: #353535;
}

footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 12px 18px calc(12px + env(safe-area-inset-bottom)) 18px;
}

#finish-btn {
  width: 100%;
  padding: 16px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 10px;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
}

#finish-btn:disabled {
  background: #2a2a2a;
  color: var(--muted);
  cursor: default;
}

#toast {
  position: fixed;
  bottom: calc(96px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: #444;
  color: var(--fg);
  padding: 10px 18px;
  border-radius: 22px;
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
  font-size: 14px;
  z-index: 20;
  max-width: calc(100vw - 32px);
  text-align: center;
}

#toast.visible {
  opacity: 1;
}
