:root {
  --bg: #FFF7F3; --card: #FFFFFF; --texto: #2B1B24; --suave: #8A7480; --linha: #F1E4DE;
  --coral: #FF4D6D; --agua: #1FB6C9; --cal: #FF9F1C; --peso: #7B61FF; --ok: #2BB673; --erro: #D93A55;
  --coral-fraco: #FFE3E9; --agua-fraco: #DDF4F7; --cal-fraco: #FFEFD6; --peso-fraco: #ECE8FF; --ok-fraco: #D9F3E6;
  --sombra: 0 4px 18px rgba(80, 30, 50, .08); --raio: 18px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17111A; --card: #241B27; --texto: #F8EDF1; --suave: #B39FAA; --linha: #3A2E3E;
    --coral-fraco: #4A2230; --agua-fraco: #153B42; --cal-fraco: #4A3513; --peso-fraco: #2E2750; --ok-fraco: #174030;
    --sombra: 0 4px 18px rgba(0, 0, 0, .35);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--texto); font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif; font-size: 15px; line-height: 1.4; }
body { min-height: 100dvh; }
#app { max-width: 520px; margin: 0 auto; min-height: 100dvh; position: relative; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 24px; font-weight: 800; }
h2 { font-size: 18px; font-weight: 800; }
h3 { font-size: 15px; font-weight: 800; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
:focus-visible { outline: 3px solid var(--coral); outline-offset: 2px; }
.suave { color: var(--suave); }
.peq { font-size: 13px; }
.centro { text-align: center; }
.oculto { display: none !important; }

.tela { padding: 18px 16px 110px; }
.topo { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card { background: var(--card); border-radius: var(--raio); box-shadow: var(--sombra); padding: 16px; margin-bottom: 14px; }
.card h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.linha { display: flex; align-items: center; gap: 10px; }
.entre { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: 10px; }
.grade2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grade3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

/* botões e chips */
.btn { min-height: 46px; padding: 0 20px; border-radius: 999px; background: var(--coral); color: #fff; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.bloco { width: 100%; }
.btn.sec { background: var(--coral-fraco); color: var(--coral); }
.btn.cinza { background: var(--linha); color: var(--texto); }
.btn.agua { background: var(--agua); }
.btn.peq { min-height: 44px; padding: 0 14px; font-size: 14px; }
.btn.perigo { background: var(--erro); }
.chip { min-height: 44px; padding: 0 16px; border-radius: 999px; background: var(--card); border: 1.5px solid var(--linha); font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.chip[aria-pressed="true"], .chip.on { background: var(--coral); border-color: var(--coral); color: #fff; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip.agua { border-color: var(--agua); color: var(--agua); background: var(--agua-fraco); }
.icone-btn { width: 44px; height: 44px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; background: var(--card); box-shadow: var(--sombra); }

/* formulários */
label.campo { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 13px; color: var(--suave); }
.campo input, .campo select, .campo textarea, input.in, select.in, textarea.in { width: 100%; min-height: 46px; padding: 10px 14px; border-radius: 14px; border: 1.5px solid var(--linha); background: var(--bg); color: var(--texto); font-size: 16px; font-weight: 400; }
textarea.in, .campo textarea { min-height: 80px; resize: vertical; }
.campo input:focus, .campo select:focus, .campo textarea:focus, .in:focus { outline: 2px solid var(--coral); border-color: var(--coral); }
.ia-tag { display: inline-block; font-size: 11px; font-weight: 800; color: var(--cal); background: var(--cal-fraco); border-radius: 999px; padding: 1px 8px; }
.campo.ia input { border-color: var(--cal); background: var(--cal-fraco); }
.erro-msg { color: var(--erro); font-weight: 600; font-size: 13px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.switch input { width: 46px; height: 28px; appearance: none; border-radius: 999px; background: var(--linha); position: relative; transition: background .2s; flex: none; }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked { background: var(--ok); }
.switch input:checked::after { transform: translateX(18px); }

/* navegação */
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: center; pointer-events: none; }
.nav-in { width: 100%; max-width: 520px; background: var(--card); border-radius: 22px 22px 0 0; box-shadow: 0 -4px 20px rgba(80, 30, 50, .1); display: grid; grid-template-columns: 1fr 1fr 86px 1fr 1fr; align-items: end; padding: 6px 4px calc(8px + env(safe-area-inset-bottom)); pointer-events: auto; }
.nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 52px; font-size: 11px; font-weight: 600; color: var(--suave); text-decoration: none; }
.nav a[aria-current="page"] { color: var(--coral); font-weight: 800; }
.nav svg { width: 24px; height: 24px; }
.nav .mais { align-self: center; justify-self: center; width: 62px; height: 62px; margin-top: -30px; border-radius: 50%; background: var(--coral); color: #fff; display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 18px rgba(255, 77, 109, .5); }
.nav .mais svg { width: 30px; height: 30px; }

/* bottom sheet */
.fundo { position: fixed; inset: 0; background: rgba(20, 8, 16, .5); z-index: 40; display: flex; align-items: flex-end; justify-content: center; animation: fade .2s; }
.sheet { width: 100%; max-width: 520px; max-height: 92dvh; overflow-y: auto; background: var(--card); border-radius: 26px 26px 0 0; padding: 10px 18px calc(24px + env(safe-area-inset-bottom)); animation: sobe .25s ease-out; }
.sheet .puxa { width: 44px; height: 5px; border-radius: 99px; background: var(--linha); margin: 0 auto 12px; }
.sheet h2 { margin-bottom: 14px; }
.sheet .fechar { position: absolute; }
@keyframes sobe { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
.menu-mais { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.menu-mais button { min-height: 96px; border-radius: 18px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; font-weight: 800; font-size: 15px; }
.menu-mais .emo { font-size: 30px; }

/* toasts */
#toasts { position: fixed; left: 0; right: 0; top: calc(12px + env(safe-area-inset-top)); z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast { background: var(--texto); color: var(--bg); padding: 12px 18px; border-radius: 999px; font-weight: 600; box-shadow: var(--sombra); max-width: 100%; animation: fade .2s; }
.toast.erro { background: var(--erro); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }

/* avatar */
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--coral-fraco); color: var(--coral); display: inline-flex; align-items: center; justify-content: center; font-weight: 800; flex: none; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.g { width: 84px; height: 84px; font-size: 30px; }
.avatar.p { width: 32px; height: 32px; font-size: 13px; }

/* Hoje */
.anel-box { display: flex; align-items: center; gap: 16px; }
.anel { position: relative; width: 132px; height: 132px; flex: none; }
.anel svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.anel .centro-txt { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.anel .big { font-size: 24px; font-weight: 800; color: var(--agua); line-height: 1; }
.barra { height: 12px; border-radius: 99px; background: var(--linha); overflow: hidden; }
.barra > i { display: block; height: 100%; border-radius: 99px; background: var(--cal); transition: width .4s; }
.barra.estourou > i { background: var(--erro); }
.num { font-weight: 800; font-size: 20px; }
.kpi { background: var(--bg); border-radius: 14px; padding: 10px; text-align: center; }
.kpi .num { display: block; }
.imc-faixa { display: flex; height: 10px; border-radius: 99px; overflow: hidden; position: relative; margin: 10px 0 4px; }
.imc-faixa i { display: block; height: 100%; }
.imc-marca { position: absolute; top: -4px; width: 4px; height: 18px; border-radius: 4px; background: var(--texto); transform: translateX(-2px); }
.streak { display: flex; align-items: center; gap: 10px; background: var(--cal-fraco); border-radius: var(--raio); padding: 12px 16px; margin-bottom: 14px; font-weight: 600; }
.streak b { font-size: 22px; font-weight: 800; color: var(--cal); }
.item-lista { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--linha); min-height: 44px; }
.item-lista:first-of-type { border-top: 0; }
.vazio { text-align: center; padding: 26px 12px; color: var(--suave); }
.vazio .emo { font-size: 40px; display: block; margin-bottom: 6px; }

/* Feed */
.post { padding: 14px 0 0; overflow: hidden; }
.post-topo { display: flex; align-items: center; gap: 10px; padding: 0 16px 10px; }
.post-topo .nome { font-weight: 800; }
.post-corpo { padding: 0 16px; }
.carrossel { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 4px; margin: 10px 0 0; scrollbar-width: none; }
.carrossel::-webkit-scrollbar { display: none; }
.carrossel img { flex: 0 0 100%; width: 100%; max-height: 420px; object-fit: cover; scroll-snap-align: center; background: var(--linha); }
.metricas { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 10px 0 0; font-weight: 600; }
.tag { font-size: 12px; font-weight: 800; border-radius: 999px; padding: 3px 10px; background: var(--coral-fraco); color: var(--coral); }
.tag.refeicao { background: var(--cal-fraco); color: var(--cal); }
.tag.gm { background: var(--peso-fraco); color: var(--peso); }
.reacoes { display: flex; gap: 6px; padding: 12px 16px; flex-wrap: wrap; align-items: center; }
.reacao { min-height: 44px; min-width: 52px; border-radius: 999px; border: 1.5px solid var(--linha); display: inline-flex; align-items: center; justify-content: center; gap: 4px; padding: 0 10px; background: var(--card); font-weight: 800; }
.reacao[aria-pressed="true"] { background: var(--coral-fraco); border-color: var(--coral); color: var(--coral); }
.coment { border-top: 1px solid var(--linha); padding: 10px 16px 14px; }
.coment p { margin-bottom: 6px; }
.coment .linha { margin-top: 8px; }

/* Desafios */
.podio { display: grid; grid-template-columns: 1fr 1fr 1fr; align-items: end; gap: 8px; margin: 6px 0 14px; }
.podio .p { text-align: center; }
.podio .bloco { border-radius: 14px 14px 0 0; color: #fff; font-weight: 800; display: flex; align-items: flex-start; justify-content: center; padding-top: 6px; font-size: 20px; margin-top: 6px; }
.podio .p1 .bloco { height: 84px; background: var(--cal); }
.podio .p2 .bloco { height: 62px; background: var(--peso); }
.podio .p3 .bloco { height: 46px; background: var(--agua); }
.rank { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--linha); }
.rank:first-of-type { border-top: 0; }
.rank .pos { width: 26px; font-weight: 800; color: var(--suave); text-align: center; }
.rank .pts { margin-left: auto; text-align: right; font-weight: 800; }
.cal-wrap { overflow-x: auto; }
.cal-tab { border-collapse: separate; border-spacing: 3px; }
.cal-tab th { font-size: 10px; font-weight: 600; color: var(--suave); min-width: 20px; }
.cal-tab td.nome { font-size: 12px; font-weight: 600; white-space: nowrap; padding-right: 6px; position: sticky; left: 0; background: var(--card); }
.cal-tab td.d { width: 20px; height: 20px; border-radius: 6px; background: var(--linha); }
.cal-tab td.d.ok { background: var(--coral); }
.cal-tab td.d.fut { background: transparent; border: 1px dashed var(--linha); }

/* Auth / onboarding */
.auth { padding: 40px 20px 30px; min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; gap: 16px; }
.logo { width: 72px; height: 72px; border-radius: 22px; background: var(--coral); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 40px; font-weight: 800; box-shadow: 0 8px 22px rgba(255, 77, 109, .4); }
.passos { display: flex; gap: 6px; margin-bottom: 10px; }
.passos i { flex: 1; height: 6px; border-radius: 99px; background: var(--linha); }
.passos i.on { background: var(--coral); }
.foto-prev { position: relative; width: 84px; height: 84px; border-radius: 14px; overflow: hidden; flex: none; background: var(--linha); }
.foto-prev img { width: 100%; height: 100%; object-fit: cover; }
.foto-prev button.x { position: absolute; top: 2px; right: 2px; width: 28px; height: 28px; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; font-size: 16px; line-height: 1; }
.foto-linha { display: flex; gap: 10px; align-items: flex-start; }
.item-ia { background: var(--bg); border-radius: 14px; padding: 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.item-ia .full { grid-column: 1 / -1; }
.item-ia input { min-height: 44px; padding: 8px 10px; border-radius: 10px; border: 1.5px solid var(--linha); background: var(--card); width: 100%; font-size: 15px; }
.mini-grafico { width: 100%; height: 60px; }
.spinner { width: 18px; height: 18px; border: 3px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: gira .8s linear infinite; display: inline-block; }
.btn.sec .spinner, .btn.cinza .spinner { border-color: var(--linha); border-top-color: var(--coral); }
@keyframes gira { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
