/* BrGym — tokens e componentes do protótipo aprovado (docs/prototipo). */
@font-face { font-family: 'Barlow'; font-weight: 400; font-display: swap; src: url('../fonts/barlow-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 500; font-display: swap; src: url('../fonts/barlow-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 600; font-display: swap; src: url('../fonts/barlow-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Barlow Semi Condensed'; font-weight: 600; font-display: swap; src: url('../fonts/barlow-semi-condensed-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Barlow Semi Condensed'; font-weight: 700; font-display: swap; src: url('../fonts/barlow-semi-condensed-latin-700-normal.woff2') format('woff2'); }

:root, [data-tema="escuro"] {
  --bg: #141518; --surface: #1E2024; --surface2: #2A2D33; --line: #30333A;
  --text: #EDEBE6; --muted: #A4A39D; --accent: #F2B33D; --accent-text: #F2B33D;
  --on-accent: #1C1406; --accent-soft: rgba(242, 179, 61, 0.14); --scrim: rgba(8, 8, 10, 0.55);
  --desenho-filtro: none;
  color-scheme: dark;
}
[data-tema="claro"] {
  --bg: #F5F3EF; --surface: #FFFFFF; --surface2: #E9E6E0; --line: #DCD8D0;
  --text: #1B1C1F; --muted: #5C5B56; --accent-text: #8A5506; --accent-soft: rgba(242, 179, 61, 0.22);
  --desenho-filtro: invert(1);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { font: 400 16px/1.4 'Barlow', system-ui, sans-serif; -webkit-tap-highlight-color: transparent; }
::selection { background: var(--accent); color: var(--on-accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
h1, h2 { margin: 0; font-family: 'Barlow Semi Condensed', sans-serif; font-weight: 700; }
.num { font-variant-numeric: tabular-nums; }
.cond { font-family: 'Barlow Semi Condensed', sans-serif; font-weight: 700; }
.muted { color: var(--muted); }
.pequeno { font-size: 14px; }
.mini { font-size: 13px; }
.rotulo { font: 700 14px 'Barlow Semi Condensed', sans-serif; letter-spacing: 0.04em; color: var(--muted); }
.destaque { font: 700 15px 'Barlow Semi Condensed', sans-serif; letter-spacing: 0.04em; color: var(--accent-text); }

#app { position: relative; max-width: 480px; height: 100dvh; margin: 0 auto; display: flex; flex-direction: column; overflow: hidden; }
.rolagem { flex: 1; overflow-y: auto; padding: 20px 20px 24px; display: flex; flex-direction: column; gap: 22px; }
.rolagem.justa { padding-top: 12px; gap: 20px; }
.rodape { padding: 12px 20px calc(16px + env(safe-area-inset-bottom)); display: flex; gap: 10px; }
.pilha { display: flex; flex-direction: column; gap: 6px; }
.linha { display: flex; align-items: center; gap: 12px; }
.entre { justify-content: space-between; }

.h-xl { font-size: 44px; line-height: 1; }
.h-l { font-size: 34px; line-height: 1.05; }
.h-m { font-size: 30px; line-height: 1.05; }

/* Botões */
.btn { min-height: 48px; padding: 0 16px; border-radius: 24px; border: 1px solid var(--line); background: transparent; font-weight: 600; font-size: 15px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: transform 120ms ease-out, background 160ms ease-out; }
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn-primario { flex: 1; min-height: 56px; border-radius: 28px; border: 0; background: var(--accent); color: var(--on-accent); font: 700 20px 'Barlow Semi Condensed', sans-serif; letter-spacing: 0.02em; }
.btn-sec { flex: 1; min-height: 56px; border-radius: 28px; font-size: 17px; }
.btn-texto { min-height: 44px; padding: 0 4px; border: 0; background: transparent; color: var(--accent-text); font-weight: 600; font-size: 15px; }
.btn-icone { width: 48px; height: 48px; border: 0; background: transparent; display: inline-flex; align-items: center; justify-content: center; }
.btn-redondo { width: 44px; height: 44px; border-radius: 22px; border: 1px solid var(--line); background: transparent; font-size: 20px; font-weight: 600; }
.voltar { margin-left: -12px; }

/* Cartões de escolha, chips, segmentado, interruptor */
.cartao { padding: 16px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); }
.escolha { text-align: left; min-height: 72px; padding: 14px 16px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; gap: 4px; width: 100%; }
.escolha[aria-pressed="true"] { border: 2px solid var(--accent); background: var(--accent-soft); padding: 13px 15px; }
.escolha .titulo { font: 700 22px 'Barlow Semi Condensed', sans-serif; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 44px; padding: 0 16px; border-radius: 22px; border: 1px solid var(--line); background: transparent; color: var(--muted); font-weight: 600; font-size: 15px; }
.chip[aria-pressed="true"] { border-color: transparent; background: var(--accent); color: var(--on-accent); }
.seg { display: grid; grid-auto-columns: minmax(0, 1fr); grid-auto-flow: column; gap: 4px; padding: 4px; border-radius: 24px; background: var(--surface2); }
.seg button { min-height: 44px; border-radius: 20px; border: 0; background: transparent; color: var(--muted); font-weight: 600; font-size: 15px; }
.seg button[aria-pressed="true"] { background: var(--bg); color: var(--text); }
.interruptor { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; padding: 8px 0; border: 0; border-top: 1px solid var(--line); background: transparent; text-align: left; width: 100%; }
.interruptor .trilho { width: 48px; height: 28px; border-radius: 14px; position: relative; flex: none; background: var(--surface2); transition: background 160ms ease-out; }
.interruptor .trilho::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 11px; background: #fff; transition: transform 200ms cubic-bezier(0.2, 0.8, 0.2, 1); }
.interruptor[aria-checked="true"] .trilho { background: var(--accent); }
.interruptor[aria-checked="true"] .trilho::after { transform: translateX(20px); }
.campo { min-height: 52px; padding: 0 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); font-size: 17px; width: 100%; }
.campo-curto { min-height: 44px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); width: 100%; }
label.rot { font-weight: 600; }

/* Listas */
.lista > * { border-top: 1px solid var(--line); }
.item-ex { display: flex; align-items: center; gap: 14px; padding: 12px 0; }
.mini-desenho { width: 64px; height: 48px; border-radius: 8px; background: var(--surface2); flex: none; object-fit: contain; filter: var(--desenho-filtro); }
.ponto { width: 10px; height: 10px; border-radius: 5px; flex: none; display: inline-block; }
.nota { font-size: 14px; padding: 12px 14px; border-radius: 12px; background: var(--accent-soft); }
.vazio { text-align: center; padding: 32px 0; color: var(--muted); }

/* Semana na tela Hoje */
.semana { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; text-align: center; }
.semana .dia { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.semana .bola { width: 36px; height: 36px; border-radius: 18px; display: flex; align-items: center; justify-content: center; font: 700 14px 'Barlow Semi Condensed', sans-serif; color: var(--muted); }
.bola.feito { background: var(--surface2); color: var(--text); }
.bola.hoje { background: var(--accent); color: var(--on-accent); }
.bola.plano { border: 1.5px dashed var(--muted); }

/* Treino em andamento */
.topo-treino { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px 4px 8px; }
.progresso { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; padding: 0 20px; }
.progresso span { height: 4px; border-radius: 2px; background: var(--surface2); }
.progresso span.ok { background: var(--accent); }
.desenho { position: relative; height: 220px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); overflow: hidden; }
.desenho img { position: absolute; inset: 12px; width: calc(100% - 24px); height: calc(100% - 24px); object-fit: contain; opacity: 0; filter: var(--desenho-filtro); animation: 2.8s steps(1, end) infinite; }
.desenho img:nth-child(1) { animation-name: q1; }
.desenho img:nth-child(2) { animation-name: q2; }
.desenho img:nth-child(3) { animation-name: q3; }
@keyframes q1 { 0% { opacity: 1; } 25% { opacity: 0; } }
@keyframes q2 { 0% { opacity: 0; } 25% { opacity: 1; } 50% { opacity: 0; } 75% { opacity: 1; } }
@keyframes q3 { 0% { opacity: 0; } 50% { opacity: 1; } 75% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .desenho img { animation: none; } .desenho img:nth-child(1) { opacity: 1; } }
.desenho .legenda { position: absolute; left: 12px; right: 12px; bottom: 8px; font-size: 12px; color: var(--muted); text-align: center; }
.sem-desenho { height: 160px; border-radius: 16px; border: 1px dashed var(--line); display: flex; flex-direction: column; gap: 8px; align-items: center; justify-content: center; text-align: center; padding: 24px; color: var(--muted); }
.etiqueta { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 6px 0 12px; border-radius: 18px; background: var(--surface2); font-size: 14px; font-weight: 500; }
.etiqueta button { width: 32px; height: 32px; border-radius: 16px; border: 0; background: transparent; font-size: 18px; }
.serie { display: flex; align-items: center; gap: 12px; padding: 10px 0; }
.serie .n { width: 56px; font: 600 15px 'Barlow Semi Condensed', sans-serif; color: var(--muted); }
.serie .valor { min-width: 64px; text-align: center; font: 700 22px 'Barlow Semi Condensed', sans-serif; font-variant-numeric: tabular-nums; }
.check { width: 52px; height: 52px; border-radius: 26px; border: 1.5px solid var(--line); background: transparent; color: var(--muted); display: flex; align-items: center; justify-content: center; transition: transform 160ms ease-out, background 160ms ease-out; }
.check[aria-pressed="true"] { border: 0; background: var(--accent); color: var(--on-accent); }
.check:active { transform: scale(0.94); }

/* Folhas (bottom sheets) e descanso */
.folha-fundo { position: absolute; inset: 0; z-index: 5; background: var(--scrim); display: flex; flex-direction: column; justify-content: flex-end; }
.folha-fundo > .fechar { flex: 1; border: 0; background: transparent; }
.folha { padding: 20px 20px calc(24px + env(safe-area-inset-bottom)); border-radius: 24px 24px 0 0; background: var(--surface); display: flex; flex-direction: column; gap: 4px; max-height: 85%; overflow-y: auto; }
.opcao { text-align: left; min-height: 60px; padding: 10px 0; border: 0; border-top: 1px solid var(--line); background: transparent; display: flex; align-items: center; gap: 12px; width: 100%; }
.opcao:disabled { color: var(--muted); }
.descanso { position: absolute; left: 0; right: 0; bottom: 0; z-index: 4; padding: 20px 20px calc(24px + env(safe-area-inset-bottom)); border-radius: 24px 24px 0 0; background: var(--surface); box-shadow: 0 -12px 32px rgba(0, 0, 0, 0.35); display: flex; flex-direction: column; gap: 14px; }
.relogio { font: 700 64px/1 'Barlow Semi Condensed', sans-serif; font-variant-numeric: tabular-nums; }
.barra { height: 8px; border-radius: 4px; background: var(--surface2); overflow: hidden; }
.barra > span { display: block; height: 100%; background: var(--accent); transform-origin: left; transition: transform 250ms linear; }

/* Histórico */
.calendario { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; text-align: center; }
.calendario .cab { font-size: 12px; color: var(--muted); }
.calendario button, .calendario span.d { height: 44px; border-radius: 12px; border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; color: var(--muted); font-size: 14px; }
.calendario .feito { background: var(--surface2); color: var(--text); }
.calendario .hoje { border: 2px solid var(--accent); color: var(--text); }
.calendario .futuro { opacity: 0.55; }
.calendario small { font: 700 10px 'Barlow Semi Condensed', sans-serif; }
.barras { height: 180px; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 8px; align-items: end; border-bottom: 1px solid var(--line); }
.barras > div { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.barras i { width: 100%; border-radius: 6px 6px 0 0; display: block; }
.trilha { height: 10px; border-radius: 5px; background: var(--surface2); overflow: hidden; }
.trilha > span { display: block; height: 100%; border-radius: 5px; background: var(--accent); }

/* Navegação e aviso */
.nav { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 6px 8px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--bg); }
.nav button { min-height: 56px; border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
.nav button[aria-current="page"] { color: var(--text); }
.nav .pilula { width: 56px; height: 30px; border-radius: 15px; display: flex; align-items: center; justify-content: center; }
.nav button[aria-current="page"] .pilula { background: var(--accent-soft); }
#aviso { position: fixed; left: 16px; right: 16px; bottom: 96px; max-width: 448px; margin: 0 auto; padding: 14px 16px; border-radius: 12px; background: var(--text); color: var(--bg); font-size: 15px; z-index: 10; opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity 200ms ease-out, transform 200ms ease-out; }
#aviso.visivel { opacity: 1; transform: none; }
