:root {
  --bg: #f2f2f7;
  --card: #ffffff;
  --text: #1c1c1e;
  --text-secondary: #8e8e93;
  --separator: rgba(60, 60, 67, 0.12);
  --accent: #ff2d55;
  --accent-soft: #ffe3e9;
  --green: #34c759;
  --blue: #007aff;
  --radius: 16px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 16px 40px;
}

.hidden { display: none !important; }

/* ===== Login ===== */
.login-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
}
.login-card {
  width: 100%;
  max-width: 360px;
  text-align: center;
}
.login-logo { font-size: 56px; margin-bottom: 12px; }
.login-title { font-size: 26px; font-weight: 800; margin-bottom: 24px; }
.login-error {
  background: rgba(255, 45, 85, 0.1);
  color: var(--accent);
  border-radius: 10px;
  padding: 10px;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 12px;
}
.input {
  display: block;
  width: 100%;
  background: var(--card);
  border: none;
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 16px;
  font-family: inherit;
  color: var(--text);
  margin-bottom: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  outline: none;
}
.input:focus { box-shadow: 0 0 0 2px var(--accent); }

/* ===== Header ===== */
.header { padding: 24px 4px 16px; }
.header-row { display: flex; align-items: center; justify-content: space-between; }
.header h1 { font-size: 32px; font-weight: 800; letter-spacing: -0.5px; }
.header p { color: var(--text-secondary); font-size: 15px; margin-top: 4px; }
.logout-btn {
  border: none;
  background: rgba(120,120,128,0.12);
  color: var(--text-secondary);
  font-size: 14px;
  font-family: inherit;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
}

.nav-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 0;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
}
.nav-back {
  border: none;
  background: none;
  color: var(--blue);
  font-size: 17px;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  padding: 6px 8px 6px 0;
}
.nav-back::before { content: '‹'; font-size: 28px; line-height: 1; margin-right: 2px; }

/* ===== Cards de treino (home) ===== */
.workout-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px 16px;
  margin-bottom: 12px;
  border: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  transition: transform 0.1s;
}
.workout-card:active { transform: scale(0.98); }
.workout-emoji {
  font-size: 28px;
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.workout-info { flex: 1; min-width: 0; }
.workout-info h3 { font-size: 17px; font-weight: 600; }
.workout-info p { font-size: 14px; color: var(--text-secondary); margin-top: 2px; }
.workout-count { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.chevron { color: #c7c7cc; font-size: 22px; }

.badge-active {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--green);
  background: rgba(52, 199, 89, 0.12);
  border-radius: 6px;
  padding: 2px 8px;
  margin-top: 4px;
}

/* ===== Tela do treino ===== */
.workout-title { padding: 4px 4px 4px; }
.workout-title h1 { font-size: 28px; font-weight: 800; letter-spacing: -0.5px; }
.workout-title p { color: var(--text-secondary); font-size: 15px; margin-top: 2px; }

.progress-wrap { padding: 16px 4px 20px; }
.progress-track {
  height: 10px;
  background: rgba(120, 120, 128, 0.16);
  border-radius: 5px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 5px;
  width: 0;
  transition: width 0.35s ease;
}
.progress-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 8px;
  text-align: center;
}

.exercise-list {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.exercise-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 0.5px solid var(--separator);
}
.exercise-row:last-child { border-bottom: none; }

.check {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #c7c7cc;
  background: none;
  flex-shrink: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: transparent;
  transition: all 0.15s;
}
.check.checked {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}
.check:disabled { opacity: 0.35; cursor: default; }

.exercise-main { flex: 1; min-width: 0; cursor: pointer; }
.exercise-main h4 { font-size: 16px; font-weight: 600; }
.exercise-row.done .exercise-main h4 {
  text-decoration: line-through;
  color: var(--text-secondary);
}
.exercise-main p { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }

.info-btn {
  border: none;
  background: none;
  color: var(--blue);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  flex-shrink: 0;
}

/* ===== Botões ===== */
.btn {
  display: block;
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 16px;
  font-size: 17px;
  font-weight: 600;
  font-family: inherit;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  margin-top: 12px;
  transition: transform 0.1s, opacity 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-finish { background: var(--green); color: #fff; }
.btn-secondary { background: rgba(120, 120, 128, 0.12); color: var(--text); }
.btn-danger-text {
  background: none;
  color: var(--accent);
  font-weight: 500;
  padding: 12px;
}
.btn-video { background: var(--blue); color: #fff; }
.btn:disabled { opacity: 0.5; cursor: default; transform: none; }

.actions { margin-top: 20px; }

/* ===== Tela de parabéns ===== */
.congrats {
  text-align: center;
  padding: 60px 20px;
}
.congrats .big { font-size: 64px; }
.congrats h2 { font-size: 26px; font-weight: 800; margin-top: 16px; }
.congrats p { color: var(--text-secondary); margin-top: 8px; font-size: 15px; }

/* ===== Histórico ===== */
.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 24px 4px 8px;
}
.history-list {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.history-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 0.5px solid var(--separator);
  font-size: 15px;
}
.history-row:last-child { border-bottom: none; }
.history-row .h-emoji { font-size: 20px; }
.history-row .h-info { flex: 1; }
.history-row .h-info small { display: block; color: var(--text-secondary); font-size: 13px; margin-top: 1px; }
.history-row .h-done { color: var(--green); font-weight: 600; font-size: 14px; }
.empty-note { color: var(--text-secondary); font-size: 14px; padding: 16px; text-align: center; }

/* ===== Bottom sheet ===== */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 20;
}
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-width: 480px;
  margin: 0 auto;
  background: var(--card);
  border-radius: 20px 20px 0 0;
  padding: 12px 20px calc(24px + env(safe-area-inset-bottom));
  z-index: 21;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.15);
  animation: slideUp 0.25s ease;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.sheet-handle {
  width: 36px;
  height: 5px;
  border-radius: 3px;
  background: #d1d1d6;
  margin: 0 auto 16px;
}
.sheet h2 { font-size: 20px; font-weight: 700; }
.sheet-meta { color: var(--accent); font-weight: 600; font-size: 14px; margin-top: 4px; }
#sheet-description { color: var(--text); font-size: 15px; line-height: 1.5; margin-top: 12px; }

/* ===== Confirm modal ===== */
.confirm-modal {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: calc(100% - 64px);
  max-width: 320px;
  background: var(--card);
  border-radius: 20px;
  padding: 24px 20px 20px;
  z-index: 21;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,0.18);
  animation: popIn 0.2s ease;
}
@keyframes popIn {
  from { transform: translate(-50%, -50%) scale(0.92); opacity: 0; }
  to   { transform: translate(-50%, -50%) scale(1);    opacity: 1; }
}
.confirm-icon { font-size: 36px; margin-bottom: 10px; }
.confirm-modal h3 { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.confirm-modal p  { font-size: 14px; color: var(--text-secondary); line-height: 1.45; margin-bottom: 4px; }
.confirm-modal .btn { margin-top: 10px; }
.confirm-modal .btn-primary { background: var(--accent); }

.loading { text-align: center; color: var(--text-secondary); padding: 40px; }
