/* Magnifit Design System — Componentes Reutilizáveis (Seção 3) */

/* 2.5 Ícones Lucide */
.lucide {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* 3.1 Botões */
button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background-color: var(--brand);
  color: var(--on-brand);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  user-select: none;
  transition:
    background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out),
    opacity var(--dur-fast) var(--ease-out);
}

button:hover:not(:disabled),
.btn:hover:not(:disabled) {
  background-color: var(--brand-hover);
  color: var(--on-brand);
}

button:active:not(:disabled),
.btn:active:not(:disabled) {
  transform: scale(0.98);
}

button:focus-visible,
.btn:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

button:disabled,
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

/* Variações de Botão */
/* KB Magnifit, 6.3: botão principal com 52 px, raio 14 px, degradê Brasa, texto escuro e sombra colorida.
   Apenas um por tela (KB Magnifit, 4.1). */
.btn-primary {
  background-color: var(--brand);
  background-image: var(--brand-grad);
  color: var(--on-brand);
  border-color: transparent;
  border-radius: var(--radius-btn);
  box-shadow: var(--shadow-brand);
  font-size: 15px;
}

.btn-primary:not(.btn-sm) {
  min-height: 52px;
  padding: 0 var(--space-5);
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--brand-hover);
  background-image: var(--brand-grad);
  color: var(--on-brand);
  filter: brightness(1.06);
}

/* KB Magnifit, 6.4: botão secundário com 48 px, fundo transparente e borda --border */
button.secondary,
.btn-secondary {
  background-color: transparent;
  color: var(--text);
  border-color: var(--border);
  border-radius: var(--radius-btn);
  font-size: 15px;
}

button.secondary:not(.btn-sm),
.btn-secondary:not(.btn-sm) {
  min-height: 48px;
}

button.secondary:hover:not(:disabled),
.btn-secondary:hover:not(:disabled) {
  background-color: var(--surface-2);
  color: var(--text);
  border-color: var(--text-2);
}

button.ghost,
.btn-ghost {
  background-color: transparent;
  color: var(--brand);
  border-color: transparent;
  padding: 0 var(--space-3);
}

button.ghost:hover:not(:disabled),
.btn-ghost:hover:not(:disabled) {
  background-color: var(--brand-soft);
  color: var(--brand-hover);
}

button.danger,
.btn-danger {
  background-color: var(--surface);
  color: var(--danger);
  border-color: var(--danger);
}

button.danger:hover:not(:disabled),
.btn-danger:hover:not(:disabled) {
  background-color: var(--danger-soft);
  color: var(--danger);
}

button.danger-solid,
.btn-danger-solid {
  background-color: var(--danger);
  color: var(--surface);
  border-color: var(--danger);
}

button.danger-solid:hover:not(:disabled),
.btn-danger-solid:hover:not(:disabled) {
  opacity: 0.92;
  color: var(--surface);
}

button.accent {
  background-color: var(--brand);
  color: var(--on-brand);
}

/* Tamanho compacto (36 px, apenas tabelas admin no desktop) */
.btn-compact,
button.sm {
  min-height: 36px;
  padding: 0 var(--space-3);
  font-size: 13px;
}

@media (max-width: 900px) {
  button.sm {
    min-height: 44px;
    padding: 0 var(--space-4);
    font-size: 14px;
  }
}

/* 3.2 Campos e Formulários */
.field-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

label,
.field-label {
  display: block;
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--space-1);
}

input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background-color: var(--input-bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 24px;
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}

textarea {
  min-height: 92px;
  resize: vertical;
}

input:not([type="checkbox"]):not([type="radio"]):focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

input:disabled,
select:disabled,
textarea:disabled {
  background-color: var(--surface-2);
  color: var(--muted);
  cursor: not-allowed;
}

input[type="checkbox"],
input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
  cursor: pointer;
  flex-shrink: 0;
}

.field-help {
  font-size: 12px;
  line-height: 16px;
  color: var(--muted);
  margin-top: var(--space-1);
}

.field-error {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: 12px;
  line-height: 16px;
  color: var(--danger);
  font-weight: 600;
  margin-top: var(--space-1);
}

/* Campo com unidade interna à direita ("kg", "s", "reps") */
.input-with-unit {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.input-with-unit input {
  padding-right: 44px;
}

.input-unit {
  position: absolute;
  right: var(--space-3);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  pointer-events: none;
}

/* Stepper de carga e repetições (− / +) */
.stepper-control {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.stepper-btn {
  min-width: 44px;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: var(--radius-sm);
  background-color: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
}

.stepper-btn:hover:not(:disabled) {
  background-color: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand);
}

/* 3.3 Cards e Superfícies */
/* KB Magnifit, 6.1: card em --surface-1, borda de 1 px, raio 20 px e padding 16 px */
.card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: var(--space-4);
  box-shadow: var(--shadow-1);
}

/* KB Magnifit, 6.2: card de destaque (treino do dia): borda Brasa a 35%, degradê Brasa a 8% no topo e brilho a 25% */
.card-highlight {
  border-color: var(--brasa-line);
  background-image: linear-gradient(180deg, var(--brasa-tint) 0%, transparent 70%);
  box-shadow: 0 0 32px var(--brasa-glow);
}

.card-subtle {
  background-color: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: var(--space-4);
  box-shadow: var(--shadow-0);
}

.card-recommended {
  border: 2px solid var(--brand);
}

@media (max-width: 900px) {
  .card {
    padding: var(--space-4);
  }
}

/* Card de Métrica (Seção 3.3) */
.metric-card,
.stat-box {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  box-shadow: var(--shadow-1);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--space-2);
}

.metric-card .metric-label,
.stat-box .stat-lbl {
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.metric-card .metric-value,
.stat-box .stat-val {
  font-family: var(--font-metric);
  font-size: 32px;
  line-height: 36px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.metric-card .metric-context {
  font-size: 14px;
  line-height: 20px;
  color: var(--text-2);
}

/* 3.4 Navegação — Cabeçalho (56 px celular / 64 px desktop) */
.top-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 64px;
  background-color: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.brand-area {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-sans);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--brand);
  cursor: pointer;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background-color: var(--brand);
  color: var(--on-brand);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
}

/* Abas de navegação no cabeçalho desktop */
.nav-bar {
  background-color: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 var(--space-6);
  display: flex;
  align-items: center;
  gap: var(--space-1);
  overflow-x: auto;
  scrollbar-width: none;
}

.nav-bar::-webkit-scrollbar {
  display: none;
}

.nav-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 48px;
  padding: 0 var(--space-4);
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.nav-tab:hover:not(:disabled) {
  background-color: transparent;
  color: var(--text);
}

.nav-tab.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}

.nav-tab .nav-icon {
  display: none;
}

/* Avatar e Menu do Usuário (Seção 3.4) */
.header-controls {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.context-switcher {
  display: flex;
  background-color: var(--surface-2);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.ctx-btn {
  min-height: 32px;
  padding: 0 var(--space-3);
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
}

.ctx-btn:hover:not(:disabled) {
  background: transparent;
  color: var(--text);
}

.ctx-btn.active {
  background-color: var(--surface);
  color: var(--brand);
  box-shadow: var(--shadow-1);
}

.avatar-menu-wrapper {
  position: relative;
}

.avatar-trigger {
  min-height: 40px;
  padding: 4px 10px 4px 4px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background-color: var(--surface);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.avatar-trigger:hover:not(:disabled) {
  background-color: var(--surface-2);
  color: var(--text);
}

.avatar-circle {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-pill);
  background-color: var(--brand-soft);
  color: var(--brand);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.avatar-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 260px;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-2);
  padding: var(--space-3);
  z-index: 250;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.avatar-dropdown-item {
  width: 100%;
  justify-content: flex-start;
  min-height: 40px;
  padding: 0 var(--space-3);
  background: transparent;
  color: var(--text);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
}

.avatar-dropdown-item:hover:not(:disabled) {
  background-color: var(--surface-2);
  color: var(--text);
}

/* Barra Inferior no Celular (Seção 3.4: 5 itens máx., ícone acima de 1 palavra) */
@media (max-width: 900px) {
  .top-header {
    height: 56px;
    padding: 0 var(--space-4);
  }

  .header-desktop-only {
    display: none !important;
  }

  .nav-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 120;
    height: calc(64px + env(safe-area-inset-bottom, 0px));
    padding: 4px var(--space-2) env(safe-area-inset-bottom, 0px);
    background-color: var(--surface);
    border-top: 1px solid var(--border);
    border-bottom: none;
    justify-content: space-around;
    overflow-x: hidden;
  }

  .nav-tab {
    flex: 1 1 0%;
    min-width: 0;
    min-height: 52px;
    padding: 4px 2px;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    border-bottom: none;
    font-size: 11px;
    line-height: 14px;
    font-weight: 600;
    color: var(--muted);
  }

  .nav-tab .nav-icon {
    display: inline-flex;
  }

  .nav-tab.active {
    color: var(--brand);
  }

  .nav-tab.active .lucide {
    stroke-width: 2.25;
  }
}

/* 3.5 Janelas (Modais / Bottom Sheet) e Avisos (Toasts) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 300;
  background-color: var(--backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}

.modal-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  max-width: var(--form-max);
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* KB Magnifit, 6.5: alça de 36 × 4 px */
.modal-handle {
  display: none;
  width: 36px;
  height: 4px;
  border-radius: var(--radius-pill);
  background-color: var(--border-strong);
  margin: 0 auto var(--space-2);
}

@media (max-width: 900px) {
  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }

  /* KB Magnifit, 6.5: folha que sobe de baixo em --surface-2, raio de 24 px no topo */
  .modal-card {
    max-width: 100%;
    background-color: var(--surface-2);
    border-top-left-radius: var(--radius-sheet);
    border-top-right-radius: var(--radius-sheet);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    padding: var(--space-4) var(--space-5) calc(var(--space-6) + env(safe-area-inset-bottom, 0px));
    max-height: 92vh;
  }

  .modal-handle {
    display: block;
  }
}

/* Avisos / Toasts (Seção 3.5: topo no celular, canto inferior direito no desktop) */
#toast-container {
  position: fixed;
  right: var(--space-6);
  bottom: var(--space-6);
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: 380px;
  width: calc(100% - 32px);
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background-color: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-left: 4px solid var(--brand);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-2);
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
}

.toast.error {
  border-left-color: var(--danger);
}

.toast.warn {
  border-left-color: var(--warning);
}

@media (max-width: 900px) {
  #toast-container {
    top: calc(var(--space-3) + env(safe-area-inset-top, 0px));
    bottom: auto;
    left: var(--space-4);
    right: var(--space-4);
    max-width: none;
    width: auto;
  }
}

/* 3.6 Selos de Estado (Tabela 3.6 — Cor fixa por significado) */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* Ativo / concluído / verificado */
.badge-success,
.badge-active {
  background-color: var(--brand-soft);
  color: var(--brand);
}

/* Em andamento / aguardando */
.badge-neutral,
.badge-progress,
.badge-info {
  background-color: var(--surface-2);
  color: var(--text-2);
}

/* Atenção */
.badge-warn {
  background-color: var(--warning-soft);
  color: var(--warning);
}

/* Problema */
.badge-danger {
  background-color: var(--danger-soft);
  color: var(--danger);
}

/* Conquista / Fundador / Pro */
.badge-gold,
.badge-pro {
  background-color: var(--gold-soft);
  color:var(--gold-text);
}

/* Origem da ficha ("Do seu personal" / "Criada por você") */
.badge-origin {
  background-color: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border);
}

/* 3.7 Estados de Tela (Esqueleto, Vazio, Erro, Bloqueado Pro) */
/* KB Magnifit, 6.8: esqueleto no formato dos cards, com brilho passando a cada 1,4 s */
@keyframes skeleton-shine {
  from { background-position: 150% 0; }
  to { background-position: -50% 0; }
}

.skeleton {
  background-color: var(--surface-2);
  background-image: linear-gradient(100deg, transparent 30%, var(--border) 50%, transparent 70%);
  background-size: 200% 100%;
  border-radius: var(--radius-sm);
  animation: skeleton-shine 1.4s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
}

.empty-state {
  text-align: center;
  padding: var(--space-10) var(--space-6);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background-color: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  color: var(--text-2);
}

.empty-state-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-pill);
  background-color: var(--surface-2);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pro-locked-container {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
}

.pro-locked-preview {
  opacity: 0.25;
  pointer-events: none;
  user-select: none;
  filter: blur(1px);
  padding: var(--space-5);
}

.pro-locked-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  background-color: var(--backdrop);
}

.pro-locked-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  max-width: 380px;
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  box-shadow: var(--shadow-2);
}

/* 3.8 Gráficos e Progresso */
.progress-track {
  width: 100%;
  height: 6px;
  background-color: var(--surface-2);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background-color: var(--brand);
  border-radius: var(--radius-pill);
  transition: width var(--dur-slow) var(--ease-out);
}

.progress-fill.gold {
  background-color: var(--gold);
}

.ring-progress-wrap {
  display: inline-flex;
  align-items: center;
  gap: var(--space-4);
}

.ring-svg {
  transform: rotate(-90deg);
}

/* KB Magnifit, 6.7: traço de 10 px, trilho em --border, cantos arredondados */
.ring-bg {
  fill: none;
  stroke: var(--border);
  stroke-width: 10;
}

.ring-meter {
  fill: none;
  stroke: var(--brand);
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset var(--dur-reward) var(--ease-out), stroke var(--dur-reward) var(--ease-out);
}

.ring-meter.completed {
  stroke: var(--verde);
}

/* Tabelas e Listas (Seção 4.7 e 4.9) */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background-color: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  line-height: 20px;
}

th,
td {
  text-align: left;
  padding: 10px var(--space-4);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

th {
  background-color: var(--surface-2);
  color: var(--text-2);
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  position: sticky;
  top: 0;
}

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

.table-admin td {
  height: 36px;
  padding: 6px var(--space-3);
}

/* Lista de itens e exercícios */
.item-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.item-row {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

/* 4.4 Execução de treino — Cronômetro de descanso fixo na base */
.rest-timer-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: var(--space-5);
  z-index: 150;
  max-width: 560px;
  width: calc(100% - 32px);
  background-color: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

@media (max-width: 900px) {
  .rest-timer-bar {
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  }
}

/* Acordeão (FAQ e filtros recolhidos) */
details.accordion-item {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
}

details.accordion-item + details.accordion-item {
  margin-top: var(--space-3);
}

details.accordion-item summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

details.accordion-item summary::-webkit-details-marker {
  display: none;
}

details.accordion-item[open] summary {
  margin-bottom: var(--space-2);
  color: var(--brand);
}

/* Mockup de celular na Landing Page (Seção 4.1) */
.phone-preview {
  background-color: var(--surface);
  border: 2px solid var(--border-strong);
  border-radius: 24px;
  padding: var(--space-4);
  box-shadow: var(--shadow-2);
  max-width: 360px;
  width: 100%;
}

/* Gaveta de demonstração recolhida (apenas ambiente de desenvolvimento) */
.demo-drawer {
  position: fixed;
  bottom: var(--space-4);
  left: var(--space-4);
  z-index: 200;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-2);
  font-size: 13px;
  max-width: 320px;
}

.demo-drawer summary {
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 600;
  color: var(--text-2);
  list-style: none;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.demo-drawer-body {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

@media (max-width: 900px) {
  .demo-drawer {
    bottom: calc(74px + env(safe-area-inset-bottom, 0px));
  }
}

/* EP-22 (KB 11.5 e 16.3.6): celebração curta do recorde pessoal */
@keyframes record-pop {
  0% { transform: scale(0.96); opacity: 0; }
  60% { transform: scale(1.02); opacity: 1; }
  100% { transform: scale(1); }
}
.record-celebration { animation: record-pop var(--dur-reward, 600ms) var(--ease-out, ease-out) both; }
@media (prefers-reduced-motion: reduce) {
  .record-celebration { animation: none; }
}

/* KB v3.4, 6.5 e 7.7: painéis com gráficos, indicadores e tabelas */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--space-3); margin: var(--space-3) 0; }
.dash-kpi { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--space-3) var(--space-4); min-width: 0; }
.dash-kpi-label { font-size: 13px; color: var(--text-secondary); }
.dash-kpi-value { font-family: var(--font-metric); font-size: 24px; font-weight: 700; color: var(--text); line-height: 1.2; margin-top: 2px; }
.dash-kpi-delta { display: block; font-size: 12px; line-height: 1.4; color: var(--text-secondary); margin-top: 4px; }
.dash-kpi-delta.is-up::before { content: "\2191\00a0"; color: var(--brand); font-weight: 700; }
.dash-kpi-delta.is-down::before { content: "\2193\00a0"; color: var(--danger); font-weight: 700; }
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: var(--space-3); }
.chart-card { margin: 0; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--space-3) var(--space-4); min-width: 0; }
.chart-title { font-weight: 600; font-size: 14px; margin-bottom: var(--space-2); color: var(--text); }
.chart-axis { font-size: 10px; fill: var(--text-secondary); }
.chart-value { font-size: 10px; font-weight: 700; fill: var(--text); }
.chart-legend { display: flex; gap: var(--space-3); flex-wrap: wrap; font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.legend-swatch { display: inline-block; width: 16px; height: 0; border-top: 2px solid var(--brand); margin-right: 6px; vertical-align: middle; }
.legend-swatch.is-dashed { border-top: 2px dashed var(--muted); }
.chart-data { margin-top: var(--space-2); font-size: 13px; }
.chart-data summary { cursor: pointer; color: var(--text-secondary); min-height: 32px; display: flex; align-items: center; }
.chart-csv { margin-top: var(--space-2); }
.table-scroll { overflow-x: auto; max-width: 100%; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table th { color: var(--text-secondary); font-weight: 600; }
.funnel { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
.funnel-label { display: flex; justify-content: space-between; gap: var(--space-2); font-size: 13px; }
.funnel-track { height: 8px; background: var(--surface-2); border-radius: var(--radius-pill); overflow: hidden; margin-top: 4px; }
.funnel-fill { height: 100%; background: var(--brand); border-radius: var(--radius-pill); }
.period-picker { margin: 0 0 var(--space-2); flex-wrap: wrap; }
.dash-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-3); flex-wrap: wrap; }
.todo-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
.todo-list button { width: 100%; justify-content: space-between; }
.status-pill { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 2px 8px; border-radius: var(--radius-pill); border: 1px solid var(--border); white-space: nowrap; }
.status-pill.is-risk { border-color: var(--danger); color: var(--danger); }
.status-pill.is-paused { color: var(--text-secondary); }
.spark-cells { display: inline-flex; gap: 2px; vertical-align: middle; }
.spark-cells i { display: inline-block; width: 6px; border-radius: 1px; background: var(--brand); }
.cohort-table td.is-empty { color: var(--muted); }
.nav-tabs.nav-scroll { overflow-x: auto; scrollbar-width: none; }
@media (max-width: 767px) {
  body.app-logged .nav-tabs.nav-scroll { justify-content: flex-start; }
  body.app-logged .nav-tabs.nav-scroll .nav-tab { flex: 0 0 auto; min-width: 68px; }
}
.flag-list { list-style: none; margin: 0; padding: 0; }
.flag-row { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); padding: var(--space-3) 0; border-bottom: 1px solid var(--border); }
.flag-row:last-child { border-bottom: none; }
.switch-row { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; white-space: nowrap; font-size: 13px; }
.switch-row input { width: 20px; height: 20px; accent-color: var(--brand); }

.link-btn { background: none; border: none; padding: 0; min-height: 32px; color: var(--brand); font-weight: 600; text-align: left; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

/* KB v3.4, 9A: biblioteca e folha Como fazer */
.lib-filters { display: flex; gap: var(--space-3); flex-wrap: wrap; align-items: flex-end; margin: var(--space-2) 0; }
.lib-filters label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; min-width: 0; }
.lib-filters label.switch-row { flex-direction: row; }
.lib-editor-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4); }
@media (min-width: 1024px) { .lib-editor-grid { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); } .lib-preview { position: sticky; top: 80px; align-self: start; } }
.lib-editor-grid textarea, .lib-editor-grid input, .lib-editor-grid select { width: 100%; }
.howto-block { margin-top: var(--space-2); }
.howto-list { padding-left: 18px; margin-top: 6px; }
.howto-guidance { border: 1px solid var(--brand); background: var(--brand-soft); border-radius: var(--radius-md); padding: var(--space-3); margin-top: var(--space-2); }
.howto-guidance-head { display: flex; gap: var(--space-2); align-items: center; margin-bottom: 6px; }
.howto-guidance p { color: var(--text); margin: 0; }
/* Avisos em faixa (segurança da sessão, lembrete no treino, prazos vencidos no admin). O estado vem do texto e do
   ícone; a cor só reforça (KB v3.4, 4.1). Texto na cor normal sobre fundo suave, para manter o contraste AA. */
.banner { border: 1px solid var(--border); border-left-width: 4px; border-radius: var(--radius-md); padding: var(--space-3); background: var(--card); color: var(--text); }
.banner p, .banner li { color: var(--text); }
.banner-info { border-color: var(--brand); background: var(--brand-soft); }
.banner-warn { border-color: var(--warning); background: var(--warning-soft); }
.banner-danger { border-color: var(--danger); background: var(--danger-soft); }

/* KB v3.4, seção 8: execução do treino */
.workout-bar-adjust { padding: 4px 8px; min-height: 36px; }
body.in-workout #toast-container { top: calc(var(--header-h, 64px) + var(--space-2)); bottom: auto; }
/* KB v3.4, seção 5: gamificação visual */
.home-today { display: flex; gap: var(--space-2); align-items: stretch; flex-wrap: nowrap; margin-bottom: var(--space-3); }
.home-today .today-rings { flex: 1 1 0; min-width: 0; gap: var(--space-2); }
.home-today .today-rings-values { font-size: 12px; }
.today-rings-svg { flex: 0 0 auto; }
.today-ring-value { white-space: normal; }
.home-today { max-width: 100%; min-width: 0; }
.home-today-chips { display: flex; flex-direction: column; gap: 6px; flex: 0 0 112px; justify-content: center; min-width: 0; }
.home-chip { display: inline-flex; align-items: center; gap: 4px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 4px 8px; min-height: 36px; color: var(--text); cursor: pointer; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.home-chip .lucide, .home-chip svg { color: var(--gold-text); }
.today-rings { display: flex; align-items: center; gap: var(--space-3); background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--space-2) var(--space-3); color: var(--text); text-align: left; cursor: pointer; min-width: 0; width: 100%; }
.today-rings-values { display: flex; flex-direction: column; gap: 2px; font-size: 13px; min-width: 0; }
.today-ring-value strong { font-family: var(--font-metric); font-size: 15px; }
.ring-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.ring-week { background: var(--brand); }
.ring-water { background: var(--info); }
.ring-sleep { background: var(--sleep); }
.journey-rings { padding: var(--space-2); }
.journey-rings .today-rings { border: none; padding: 0; background: transparent; }
.streak-card { padding: var(--space-3) var(--space-4); }
.streak-main { display: flex; align-items: center; gap: var(--space-3); }
.streak-number { font-family: var(--font-metric); font-size: 32px; line-height: 1; color: var(--text); }
.streak-flame { display: inline-flex; }
.flame-off { color: var(--muted); }
.flame-warm { color: var(--warning); }
.flame-gold { color: var(--gold); }
.flame-gold-glow { color: var(--gold); filter: drop-shadow(0 0 6px var(--gold-soft)); }
.streak-shields { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; color: var(--info); font-weight: 600; }
.week-dots { list-style: none; display: flex; justify-content: space-between; gap: 4px; padding: 0; margin: var(--space-2) 0 0; }
.week-dots li { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; border: 2px solid var(--border-strong); color: var(--text-secondary); }
.week-dots li.is-done { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.week-dots li.is-today { box-shadow: 0 0 0 2px var(--focus-ring); font-weight: 700; }
.level-card { display: flex; gap: var(--space-3); align-items: center; padding: var(--space-3) var(--space-4); }
.level-body { flex: 1; min-width: 0; display: grid; gap: 4px; }
.level-hex-text { font-family: var(--font-metric); font-size: 18px; font-weight: 700; fill: var(--text); }
.medal-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-2); }
.medal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: var(--space-2); }
.medal-tile { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: var(--space-2); border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--card); color: var(--text); text-align: center; cursor: pointer; min-width: 0; white-space: normal; overflow: hidden; }
.medal-tile .medal-name { font-size: 12px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 100%; }
.medal-tile small { font-size: 11px; line-height: 1.3; max-width: 100%; overflow-wrap: anywhere; }
.medal-tile.is-locked .medal-name { color: var(--text-secondary); }
.medal-detail { text-align: center; }
.journey-links { display: flex; justify-content: center; gap: var(--space-4); flex-wrap: wrap; font-size: 14px; }
.journey-v34 .card { margin-bottom: var(--space-2); }
.journey-medals { padding: var(--space-2) var(--space-3); }
.journey-medals .medal-tile { padding: 4px; }
.celebration { position: fixed; inset: 0; z-index: 500; display: grid; place-items: center; background: var(--backdrop); pointer-events: none; animation: celebration-in var(--dur-med, 200ms) var(--ease-out, ease-out); }
.celebration-card { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); background: var(--surface); color: var(--text); border: 2px solid var(--gold); border-radius: var(--radius-lg); padding: var(--space-5) var(--space-6); box-shadow: var(--shadow-2); text-align: center; color: var(--gold-text); }
.celebration-card strong { font-size: 20px; color: var(--text); }
.celebration-card span { color: var(--text-secondary); }
.celebration:not(.is-reduced) .celebration-card { animation: celebration-pop 600ms var(--ease-out, ease-out); }
@keyframes celebration-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes celebration-pop { 0% { transform: scale(0.8); opacity: 0; } 60% { transform: scale(1.05); opacity: 1; } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .celebration, .celebration-card { animation: none !important; } }
/* EP-24: botão do Google (fundo claro com borda, regras de marca do Google) */
.google-btn { display: flex; width: 100%; align-items: center; justify-content: center; gap: 10px; min-height: 44px; background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); font-weight: 600; text-decoration: none; }
.google-btn:hover { border-color: var(--brand); }
.auth-divider { display: flex; align-items: center; gap: var(--space-2); color: var(--text-secondary); font-size: 13px; margin: var(--space-3) 0; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.role-pick { border: none; padding: 0; margin: var(--space-2) 0; display: flex; gap: var(--space-4); flex-wrap: wrap; }
.role-pick legend { font-size: 14px; margin-bottom: 4px; }
.form-narrow { max-width: var(--form-max); margin: var(--space-6) auto; }
.form-narrow form { display: grid; gap: var(--space-2); }

/* EP-25: editor do "Tá pago!" em tela cheia */
.tapago-editor { position: fixed; inset: 0; z-index: 450; background: var(--backdrop); display: grid; place-items: center; padding: var(--space-3); }
.tapago-panel { background: var(--surface); color: var(--text); border-radius: var(--radius-lg); padding: var(--space-4); width: min(960px, 100%); max-height: 100%; overflow-y: auto; box-shadow: var(--shadow-2); }
.tapago-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4); }
@media (min-width: 768px) { .tapago-body { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.tapago-preview { position: relative; display: grid; place-items: center; background: var(--surface-2); border-radius: var(--radius-md); padding: var(--space-2); }
.tapago-preview canvas { max-width: 100%; max-height: 60vh; width: auto; height: auto; border-radius: var(--radius-sm); touch-action: none; cursor: grab; }
.tapago-hint { position: absolute; }
.tapago-controls { display: grid; gap: var(--space-2); align-content: start; }
.tapago-controls label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.tapago-controls label.switch-row { flex-direction: row; }
.tapago-badges { border: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.tapago-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.tapago-photo { justify-content: center; flex-direction: row !important; }
/* KB v3.4, 9 (RF-251): primeiros passos do personal */
.first-steps { padding: var(--space-3) var(--space-4); }
.first-steps-head { display: flex; justify-content: space-between; align-items: center; }
.first-steps-dots { list-style: none; display: flex; gap: 6px; padding: 0; margin: 6px 0; }
.first-steps-dots li { flex: 1; height: 6px; border-radius: var(--radius-pill); background: var(--surface-2); }
.first-steps-dots li.is-done { background: var(--brand); }
.first-steps-dots li.is-next { background: var(--brand-soft); border: 1px solid var(--brand); }
.first-steps-next { display: flex; justify-content: space-between; align-items: center; gap: var(--space-2); }
.first-steps-all summary { cursor: pointer; font-size: 13px; color: var(--text-secondary); min-height: 32px; display: flex; align-items: center; }
.first-steps-all ol { list-style: none; padding: 0; margin: 4px 0 0; display: grid; gap: 4px; font-size: 14px; }
/* EP-23: Jornada › Progresso cabe em 360 × 780 com a barra de treino */
.journey-v34 .streak-card, .journey-v34 .level-card { padding: var(--space-2) var(--space-3); }
.journey-v34 .week-dots li { width: 26px; height: 26px; font-size: 11px; }
.journey-v34 .week-dots { margin-top: 6px; }
.journey-medals svg { width: 26px; height: 32px; }
.journey-medals .medal-name { -webkit-line-clamp: 1; }
.journey-medals h3 { font-size: 15px; }
.journey-rings .today-rings-svg { width: 56px; height: 56px; }
.journey-v34 .card { margin-bottom: 6px; }