:root {
  --bg: #0F1115;
  --surface: #171A20;
  --surface-2: #1E222A;
  --border: #262B33;
  --text: #F2F3F0;
  --text-dim: #8A8F98;
  --text-mute: #565B66;
  --volt: #D6FF3B;
  --volt-dim: #A8CC2F;
  --red: #FF4B3E;
  --blue: #4B9EFF;

  --g-peito: #FF4B3E;
  --g-ombro: #FFA23E;
  --g-triceps: #FFD23E;
  --g-costas: #4B9EFF;
  --g-biceps: #7A6BFF;
  --g-pernas: #D6FF3B;
  --g-cardio: #3EFFC0;
  --g-quadriceps: #B6FF3E;
  --g-posterior: #FF9F3E;
  --g-gluteos: #FF5FA8;
  --g-panturrilha: #29D9FF;
  --g-abdomen: #FFE066;
  --g-trapezio: #9B8CFF;
  --g-antebraco: #6BD98A;

  --radius: 10px;
  --nav-h: 64px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  height: 100%;
}

body {
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 10px);
  min-height: 100vh;
}

h1, h2, h3 {
  font-family: "Arial Black", "Helvetica Neue", Arial, sans-serif;
  letter-spacing: -0.02em;
  margin: 0;
}

button {
  font-family: inherit;
}

a { color: inherit; }

.hidden { display: none !important; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px 10px;
  background: linear-gradient(var(--bg) 70%, transparent);
}

.topbar h1 {
  font-size: 22px;
  flex: 1;
}

.icon-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.icon-btn:active { background: var(--surface-2); }

/* ---------- Layout / screens ---------- */
.screen {
  padding: 0 18px 24px;
  max-width: 560px;
  margin: 0 auto;
}

.screen-header {
  padding: 16px 18px 4px;
}

.screen-header .eyebrow {
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 2px;
}

.screen-header h1 {
  font-size: 26px;
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.date-line {
  color: var(--text-dim);
  font-size: 14px;
  text-transform: capitalize;
  margin: 4px 0 18px;
}

.btn-primary {
  display: block;
  width: 100%;
  background: var(--volt);
  color: #0F1115;
  border: none;
  border-radius: var(--radius);
  padding: 18px;
  font-size: 17px;
  font-weight: 800;
  text-align: center;
  cursor: pointer;
}

.btn-primary:active { background: var(--volt-dim); }

.btn-secondary {
  display: block;
  width: 100%;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
}

.btn-ghost {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 14px;
  padding: 8px 0;
  cursor: pointer;
}

.btn-danger {
  color: var(--red);
}

/* ---------- Workout type list ---------- */
.workout-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 18px 0;
}

.workout-row {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--volt);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
}

.workout-row .wname {
  font-size: 17px;
  font-weight: 700;
}

.workout-row .wgroups {
  color: var(--text-dim);
  font-size: 13px;
}

.workout-row .chev {
  margin-left: auto;
  color: var(--text-mute);
}

/* ---------- Stats summary grid ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 6px 0 18px;
}

.stat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 10px;
  text-align: center;
}

.stat-box .num {
  font-family: "Arial Black", sans-serif;
  font-size: 24px;
  color: var(--volt);
  line-height: 1;
}

.stat-box .label {
  color: var(--text-dim);
  font-size: 11.5px;
  margin-top: 6px;
}

.section-title {
  font-size: 13px;
  color: var(--text-dim);
  margin: 20px 2px 8px;
  font-weight: 600;
}

/* ---------- Exercise icons (pictograms) ---------- */
.ex-icon-wrap {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.05);
  border-radius: 10px;
}

/* ---------- Exercise photos (real demonstration photos) ---------- */
.ex-photo-wrap {
  flex-shrink: 0;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid var(--border);
  background: var(--surface-2);
}

.ex-photo-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ex-demo {
  display: flex;
  gap: 8px;
  margin: 12px 0 16px;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.ex-demo-img {
  flex: 1;
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  line-height: 0;
}

.ex-demo-img img {
  width: 100%;
  height: 108px;
  object-fit: cover;
  display: block;
}

.ex-demo-img span {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  padding: 3px 0;
  line-height: 1.3;
}

.ex-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 2px;
}

.ex-header .ex-title-wrap { flex: 1; min-width: 0; }

/* ---------- Exercise entry (treino ativo) ---------- */
.exercise-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--muscle-color, var(--volt));
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

.exercise-card .exname {
  font-size: 18px;
  font-weight: 800;
}

.exercise-card .last-time {
  color: var(--text-dim);
  font-size: 13.5px;
  margin: 3px 0 0;
}

.exercise-card .sets-wrap { margin-top: 14px; }

.set-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 10px;
}

.set-row .set-num {
  width: 48px;
  color: var(--text-dim);
  font-size: 13px;
  padding-bottom: 12px;
}

.field {
  flex: 1;
}

.field label {
  display: block;
  color: var(--text-mute);
  font-size: 11px;
  margin-bottom: 4px;
}

.field input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 18px;
  padding: 10px 10px;
  text-align: center;
  -moz-appearance: textfield;
}

.field input:focus {
  outline: none;
  border-color: var(--volt);
}

.set-check {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: none;
  background: var(--volt);
  color: #0F1115;
  font-size: 20px;
  font-weight: 900;
  flex-shrink: 0;
}

.set-row.done {
  opacity: 0.55;
}

.set-row.done .set-check {
  background: var(--surface-2);
  color: var(--volt);
  border: 1px solid var(--border);
}

.add-set-btn {
  width: 100%;
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--text-dim);
  padding: 10px;
  font-size: 14px;
  margin-top: 4px;
}

.finish-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding: 10px 18px;
  background: linear-gradient(transparent, var(--bg) 30%);
  z-index: 15;
}

.finish-bar .btn-primary {
  background: var(--red);
  color: #fff;
}

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--nav-h);
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 30;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-mute);
  font-size: 11px;
  background: transparent;
  border: none;
}

.nav-item .nav-icon {
  font-size: 20px;
  line-height: 1;
}

.nav-item.active {
  color: var(--volt);
}

/* ---------- History ---------- */
.history-group-label {
  color: var(--text-dim);
  font-size: 12px;
  margin: 18px 2px 6px;
}

.history-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
  cursor: pointer;
}

.history-row .htitle {
  font-weight: 700;
  font-size: 15.5px;
}

.history-row .hsub {
  color: var(--text-dim);
  font-size: 13px;
  margin-top: 3px;
}

/* ---------- Evolution ---------- */
.select-row select, .select-row input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px;
  border-radius: var(--radius);
  font-size: 15px;
  margin-bottom: 14px;
}

table.evo-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

table.evo-table th {
  text-align: left;
  color: var(--text-dim);
  font-weight: 600;
  font-size: 12px;
  padding: 6px 6px;
  border-bottom: 1px solid var(--border);
}

table.evo-table td {
  padding: 9px 6px;
  border-bottom: 1px solid var(--border);
}

table.evo-table tr:last-child td { border-bottom: none; }

.evo-up { color: var(--volt); }
.evo-down { color: var(--red); }

canvas#evoChart {
  width: 100%;
  height: 180px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 10px 0 4px;
}

/* ---------- Mais / lists ---------- */
.list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
}

.list-item .li-main { flex: 1; }
.list-item .li-name { font-weight: 700; font-size: 15px; }
.list-item .li-sub { color: var(--text-dim); font-size: 12.5px; }

.drag-handle {
  color: var(--text-mute);
  font-size: 16px;
  padding: 4px 6px;
  cursor: grab;
}

.li-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 16px;
  padding: 6px;
}

.li-btn.danger { color: var(--red); }

/* ---------- Forms / modal sheet ---------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 40;
  display: flex;
  align-items: flex-end;
}

.sheet {
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
}

.sheet h2 {
  font-size: 19px;
  margin-bottom: 16px;
}

.form-row { margin-bottom: 14px; }

.form-row label {
  display: block;
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 6px;
}

.form-row input, .form-row select, .form-row textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px;
  border-radius: 8px;
  font-size: 15px;
}

.form-row textarea { resize: vertical; min-height: 60px; }

.sheet-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.sheet-actions .btn-secondary, .sheet-actions .btn-primary {
  margin: 0;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 18px;
  right: 18px;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 14px);
  background: var(--volt);
  color: #0F1115;
  font-weight: 700;
  padding: 13px 16px;
  border-radius: 10px;
  text-align: center;
  z-index: 60;
  animation: toast-in-out 2.2s ease forwards;
}

@keyframes toast-in-out {
  0% { opacity: 0; transform: translateY(10px); }
  10% { opacity: 1; transform: translateY(0); }
  85% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-6px); }
}

/* ---------- Finish summary ---------- */
.summary-hero {
  text-align: center;
  padding: 30px 10px 10px;
}

.summary-hero .check {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--volt);
  color: #0F1115;
  font-size: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.summary-hero h2 { font-size: 22px; }
.summary-hero .sub { color: var(--text-dim); margin-top: 4px; }

.summary-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 20px 0;
}

/* ---------- Cardio form ---------- */
.cardio-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ---------- Empty states ---------- */
.empty-state {
  text-align: center;
  color: var(--text-dim);
  padding: 40px 20px;
  font-size: 14.5px;
}

.empty-state .emoji { font-size: 32px; margin-bottom: 10px; }

/* ---------- Offline badge ---------- */
.offline-badge {
  display: none;
  background: var(--red);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  padding: 6px;
}

.offline-badge.show { display: block; }

/* ---------- Visualizador de foto em tela cheia ---------- */
.photo-viewer {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.94);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: photo-viewer-fade 0.15s ease;
}

@keyframes photo-viewer-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.photo-viewer img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 10px;
}

.photo-viewer-close {
  position: fixed;
  top: calc(16px + env(safe-area-inset-top));
  right: 16px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.12);
  color: #fff;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

img.zoomable {
  cursor: zoom-in;
}

/* ---------- Seletor de programa (Mike 1, Mike 2...) ---------- */
.programa-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 14px;
  color: var(--text);
  text-align: left;
}

.programa-switch .prog-label {
  color: var(--text-dim);
  font-size: 12px;
  display: block;
}

.programa-switch .prog-nome {
  font-size: 15px;
  font-weight: 700;
}

.programa-switch .prog-main { flex: 1; min-width: 0; }
.programa-switch .chev { color: var(--text-mute); font-size: 14px; }

.programa-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
}

.programa-row .li-name { font-weight: 700; font-size: 15px; }
.programa-row .radio-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.programa-row.active .radio-dot {
  border-color: var(--volt);
}
.programa-row.active .radio-dot::after {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--volt);
}

/* ---------- Calendário (Histórico) ---------- */
.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 4px 0 14px;
}

.cal-mes-label {
  font-size: 16px;
  font-weight: 800;
  text-transform: capitalize;
}

.cal-nav-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 18px;
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  margin-bottom: 6px;
}

.cal-weekday {
  text-align: center;
  color: var(--text-dim);
  font-size: 11.5px;
  font-weight: 600;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 24px;
}

.cal-day {
  aspect-ratio: 1 / 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid transparent;
}

.cal-day.muted {
  color: var(--text-mute);
  background: transparent;
}

.cal-day.today {
  border-color: var(--volt);
  font-weight: 800;
}

.cal-day.has-session {
  cursor: pointer;
  background: var(--surface-2);
}

.cal-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--volt);
}

/* ---------- Seletor de exercícios (catálogo) ---------- */
.cat-search {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 15px;
  margin-bottom: 12px;
}

.cat-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 10px;
  margin-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}

.cat-chips::-webkit-scrollbar { display: none; }

.cat-chip {
  flex-shrink: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 7px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.cat-chip.active {
  background: var(--volt);
  color: #0F1115;
  border-color: var(--volt);
}

.cat-list {
  max-height: 52vh;
  overflow-y: auto;
  margin-top: 6px;
}

.cat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 4px;
  border-bottom: 1px solid var(--border);
}

.cat-item .li-name { font-weight: 700; font-size: 14.5px; }
.cat-item .li-sub { color: var(--text-dim); font-size: 12px; margin-top: 1px; }

.cat-empty {
  text-align: center;
  color: var(--text-dim);
  padding: 30px 10px;
  font-size: 14px;
}

.cat-custom-link {
  display: block;
  width: 100%;
  text-align: center;
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--text-dim);
  padding: 12px;
  border-radius: 10px;
  font-size: 13.5px;
  margin-top: 12px;
}
