:root {
  --bg: #0b0f14;
  --bg2: #121821;
  --card: #1a2332;
  --card2: #222d40;
  --text: #eef3f8;
  --muted: #9aa8b8;
  --accent: #3ddc97;
  --accent2: #2bb87a;
  --warn: #ffb020;
  --danger: #ff5c5c;
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
  height: 100%;
}
body {
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}
button, input { font: inherit; color: inherit; }
button {
  border: 0;
  background: none;
  cursor: pointer;
}
#app {
  min-height: 100dvh;
  padding: calc(12px + var(--safe-t)) 16px calc(20px + var(--safe-b));
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}
.screen { display: none; flex: 1; flex-direction: column; gap: 14px; }
.screen.active { display: flex; }

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
}
.topbar h1, .topbar h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  flex: 1;
  line-height: 1.25;
}
.icon-btn {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
  font-size: 1.25rem;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.muted { color: var(--muted); font-size: 0.92rem; }
.hero {
  margin: 8px 0 4px;
}
.hero h1 {
  margin: 0 0 6px;
  font-size: 1.7rem;
  letter-spacing: -0.02em;
}
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.treino-list { display: flex; flex-direction: column; gap: 10px; }
.treino-btn {
  text-align: left;
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid transparent;
  transition: border-color .15s, background .15s;
}
.treino-btn:active { background: var(--card2); }
.treino-btn.selected { border-color: var(--accent); background: #163028; }
.treino-btn .day {
  width: 52px; height: 52px;
  border-radius: 14px;
  background: var(--bg2);
  display: grid;
  place-items: center;
  font-weight: 800;
  color: var(--accent);
  font-size: 0.78rem;
  text-align: center;
  line-height: 1.1;
  flex-shrink: 0;
}
.treino-btn .meta { flex: 1; min-width: 0; }
.treino-btn .meta strong { display: block; font-size: 1.05rem; margin-bottom: 2px; }
.treino-btn .chev { color: var(--muted); font-size: 1.4rem; }

.primary, .secondary, .ghost {
  min-height: 56px;
  border-radius: 16px;
  font-weight: 700;
  font-size: 1.05rem;
  padding: 0 18px;
  width: 100%;
}
.primary {
  background: var(--accent);
  color: #062016;
}
.primary:active { background: var(--accent2); }
.secondary {
  background: var(--card2);
  color: var(--text);
}
.ghost {
  background: transparent;
  color: var(--muted);
  min-height: 44px;
  font-weight: 600;
}
.actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: auto;
  padding-top: 8px;
}
.row-actions {
  display: flex;
  gap: 10px;
}
.row-actions > * { flex: 1; }

.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.checklist li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--card);
  border-radius: 14px;
  padding: 14px;
}
.checklist input {
  width: 22px; height: 22px;
  margin-top: 2px;
  accent-color: var(--accent);
  flex-shrink: 0;
}
.checklist label { flex: 1; line-height: 1.35; }

.progress {
  height: 6px;
  background: var(--card);
  border-radius: 99px;
  overflow: hidden;
}
.progress > span {
  display: block;
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width .25s ease;
}

.imgs {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.imgs img {
  width: 100%;
  aspect-ratio: 3/2;
  object-fit: cover;
  border-radius: 12px;
  background: var(--bg2);
  border: 1px solid #2a3548;
}
.set-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg2);
  color: var(--accent);
  font-weight: 800;
  font-size: 0.95rem;
  padding: 8px 12px;
  border-radius: 999px;
  width: fit-content;
}
.ex-name {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.25;
  letter-spacing: -0.02em;
}
.reps-target {
  font-size: 1.15rem;
  font-weight: 700;
}
.cue {
  color: var(--muted);
  line-height: 1.4;
  margin: 0;
  font-size: 0.95rem;
}
.carga-row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.carga-row label { color: var(--muted); font-size: 0.9rem; white-space: nowrap; }
.carga-row input {
  flex: 1;
  min-height: 48px;
  border-radius: 12px;
  border: 1px solid #2a3548;
  background: var(--bg2);
  padding: 0 14px;
  -webkit-user-select: text;
  user-select: text;
}

.timer-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
}
.timer {
  font-size: clamp(4.5rem, 22vw, 6.5rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
  line-height: 1;
}
.timer.urgent { color: var(--warn); }
.next-preview {
  width: 100%;
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  text-align: left;
}
.next-preview strong { display: block; margin-bottom: 4px; }

.done {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 12px;
}
.done .emoji { font-size: 3rem; }
.done h2 { margin: 0; font-size: 1.8rem; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-b));
  transform: translateX(-50%);
  background: #243044;
  color: var(--text);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
  z-index: 50;
}
.toast.show { opacity: 1; }
