/* Projeto Carol Gostosa — tokens do DESIGN.md */
:root {
  --canvas: #F7F3EC;
  --surface: #FFFDF9;
  --sunk: #EFE8DC;
  --ink: #1E1915;
  --body: #4A423B;
  --muted: #8A8076;
  --hairline: #E4DBCD;
  --espresso: #221C18;
  --on-dark: #F7F3EC;
  --on-dark-muted: #A89C8F;
  --primary: #D6492A;
  --primary-press: #B93A1F;
  --protein: #C4553A;
  --carb: #D9A441;
  --fat: #7E8B5A;
  --water: #5B8AA6;
  --success: #5F7A45;
  --warning: #C98A1B;

  --serif: "Fraunces", "Iowan Old Style", Georgia, serif;
  --sans: -apple-system, "SF Pro Text", system-ui, "Helvetica Neue", sans-serif;

  --r-sm: 10px; --r-md: 16px; --r-lg: 24px; --r-xl: 32px;
  --gutter: 20px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tab-h: 64px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; background: var(--canvas); color: var(--ink); }
body {
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.47;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
img { display: block; max-width: 100%; }
h1, h2, h3, p { margin: 0; }
svg.i { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.entrada-oculta { position: fixed; left: -100px; top: 0; width: 1px; height: 1px; opacity: 0; }

/* Tipografia */
.display-lg { font-family: var(--serif); font-weight: 400; font-size: 34px; line-height: 1.1; letter-spacing: -0.01em; word-spacing: 0.06em; font-variation-settings: "opsz" 72; }
.display-md { font-family: var(--serif); font-weight: 400; font-size: 26px; line-height: 1.15; letter-spacing: -0.005em; word-spacing: 0.05em; font-variation-settings: "opsz" 60; }
.overline { font-size: 11px; line-height: 1.2; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.title { font-size: 17px; line-height: 1.3; font-weight: 600; }
.callout { font-size: 15px; line-height: 1.4; color: var(--body); }
.caption { font-size: 13px; line-height: 1.3; font-weight: 500; color: var(--muted); }
.num { font-family: var(--serif); font-weight: 400; font-variant-numeric: tabular-nums lining-nums; letter-spacing: -0.01em; }

/* Estrutura */
#app { max-width: 480px; margin: 0 auto; min-height: 100dvh; }
.tela {
  padding: calc(var(--safe-top) + 18px) var(--gutter) calc(var(--tab-h) + var(--safe-bottom) + 40px);
  animation: entrar .35s var(--ease);
}
@keyframes entrar { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.topo { margin-bottom: 22px; }
.topo .overline { margin-bottom: 6px; }
.secao { margin-top: 32px; }
.secao > .overline { margin-bottom: 12px; display: flex; justify-content: space-between; align-items: baseline; }
.pilha > * + * { margin-top: 10px; }

/* Cartões */
.card { background: var(--surface); border-radius: var(--r-lg); padding: 20px; }
.card-dark { background: var(--espresso); color: var(--on-dark); border-radius: var(--r-lg); padding: 24px 20px 22px; }
.card-dark .caption { color: var(--on-dark-muted); }

/* Anel de calorias */
.anel-wrap { display: grid; place-items: center; position: relative; margin: 4px auto 18px; width: 200px; height: 200px; }
.anel-wrap svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.anel-trilho { stroke: rgba(247, 243, 236, .12); }
.anel-progresso { stroke: var(--on-dark); transition: stroke-dashoffset .9s var(--ease); }
.anel-progresso.acima { stroke: var(--primary); }
.anel-centro { text-align: center; position: relative; }
.anel-centro .num { font-size: 56px; line-height: 1; display: block; }
.anel-centro .caption { margin-top: 6px; display: block; }
.linha-meta { display: flex; justify-content: space-between; padding-top: 14px; border-top: 1px solid rgba(247, 243, 236, .1); }
.linha-meta div { text-align: center; flex: 1; }
.linha-meta .num { font-size: 22px; display: block; }

/* Macros */
.macros { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 18px; }
.macro .rotulo { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; color: var(--on-dark-muted); }
.macro .ponto { width: 7px; height: 7px; border-radius: 50%; }
.macro .valor { font-family: var(--serif); font-size: 19px; margin: 4px 0 8px; font-variant-numeric: tabular-nums; }
.macro .valor small { font-family: var(--sans); font-size: 12px; color: var(--on-dark-muted); }
.barra { height: 4px; border-radius: 4px; background: rgba(247, 243, 236, .12); overflow: hidden; }
.barra i { display: block; height: 100%; border-radius: 4px; transition: width .8s var(--ease); }
.claro .macro .rotulo, .claro .macro .valor small { color: var(--muted); }
.claro .barra { background: var(--sunk); }

/* Ações rápidas */
.acoes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.btn-sec {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 14px; border-radius: var(--r-md);
  background: var(--surface); color: var(--ink); font-size: 15px; font-weight: 600;
  transition: transform .12s, background .2s;
}
.btn-sec svg.i { width: 20px; height: 20px; color: var(--primary); }
.btn-sec:active, .btn:active, .tocavel:active { transform: scale(.97); }

/* Botões */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  min-height: 54px; border-radius: 999px; background: var(--primary); color: #fff;
  font-size: 17px; font-weight: 600; transition: transform .12s, background .2s, opacity .2s;
}
.btn:active { background: var(--primary-press); }
.btn[disabled] { opacity: .35; pointer-events: none; }
.btn.fantasma { background: transparent; color: var(--ink); border: 1px solid var(--hairline); }
.btn.perigo { background: transparent; color: var(--primary); border: 1px solid var(--hairline); }
.link { color: var(--primary); font-weight: 600; font-size: 15px; min-height: 44px; display: inline-flex; align-items: center; gap: 6px; }

/* Água */
.agua-topo { display: flex; justify-content: space-between; align-items: flex-end; }
.agua-topo .num { font-size: 30px; line-height: 1; }
.gotas { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; margin: 16px 0; }
.gotas i { height: 26px; border-radius: 8px; background: var(--sunk); transition: background .3s; }
.gotas i.cheia { background: var(--water); }
.agua-botoes { display: grid; grid-template-columns: 52px 1fr 1fr; gap: 8px; }
.chip-btn { min-height: 46px; border-radius: var(--r-md); background: var(--sunk); font-weight: 600; font-size: 15px; display: grid; place-items: center; transition: transform .12s; }
.chip-btn:active { transform: scale(.96); }

/* Refeições */
.refeicao { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; background: var(--surface); border-radius: var(--r-lg); padding: 10px 16px 10px 10px; transition: transform .12s; }
.refeicao img, .refeicao .sem-foto { width: 64px; height: 64px; border-radius: 16px; object-fit: cover; flex: none; background: var(--sunk); display: grid; place-items: center; color: var(--muted); }
.refeicao .meio { flex: 1; min-width: 0; }
.refeicao .meio .caption { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.refeicao .kcal { text-align: right; }
.refeicao .kcal .num { font-size: 22px; display: block; line-height: 1; }
.refeicao .kcal small { font-size: 12px; color: var(--muted); }
.vazio { text-align: center; padding: 34px 24px; border: 1px dashed var(--hairline); border-radius: var(--r-lg); }
.vazio .display-md { margin-bottom: 6px; }

/* Barra inferior */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  padding-bottom: var(--safe-bottom);
  background: rgba(247, 243, 236, .88);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--hairline);
}
.tabbar nav { max-width: 480px; margin: 0 auto; height: var(--tab-h); display: grid; grid-template-columns: repeat(5, 1fr); align-items: center; }
.tab { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; font-weight: 500; color: var(--muted); min-height: 48px; justify-content: center; }
.tab.ativa { color: var(--ink); }
.tab.ativa svg.i { stroke-width: 2; }
.camera-fab {
  justify-self: center; margin-top: -30px;
  width: 66px; height: 66px; border-radius: 50%;
  background: var(--primary); color: #fff; display: grid; place-items: center;
  box-shadow: 0 10px 30px rgba(214, 73, 42, .35), 0 0 0 6px var(--canvas);
  transition: transform .12s, background .2s; cursor: pointer;
}
.camera-fab svg.i { width: 28px; height: 28px; stroke-width: 1.8; }
.camera-fab:active { transform: scale(.94); background: var(--primary-press); }

/* Overlay: folhas e tela cheia */
#overlay:empty, #folhas:empty { display: none; }
#folhas .fundo { z-index: 50; } #folhas .folha { z-index: 51; }
.fundo { position: fixed; inset: 0; z-index: 40; background: rgba(30, 25, 21, .38); animation: aparecer .25s ease; }
@keyframes aparecer { from { opacity: 0; } }
.folha {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-width: 480px; margin: 0 auto;
  background: var(--canvas); border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: 10px var(--gutter) calc(var(--safe-bottom) + 20px);
  box-shadow: 0 -10px 40px rgba(30, 25, 21, .18);
  animation: subir .32s var(--ease); max-height: 92dvh; overflow-y: auto;
}
@keyframes subir { from { transform: translateY(100%); } }
.folha .alca { width: 38px; height: 5px; border-radius: 5px; background: var(--hairline); margin: 0 auto 18px; }
.folha h2 { margin-bottom: 6px; }
.folha .callout { margin-bottom: 18px; }
.folha .btn + .btn { margin-top: 10px; }

.tela-cheia { position: fixed; inset: 0; z-index: 30; background: var(--canvas); overflow-y: auto; -webkit-overflow-scrolling: touch; animation: subir .38s var(--ease); }
.tela-cheia.estatica { animation: none; }
.tela-cheia .conteudo { max-width: 480px; margin: 0 auto; padding: calc(var(--safe-top) + 8px) var(--gutter) calc(var(--safe-bottom) + 150px); }
.barra-topo { display: flex; align-items: center; justify-content: space-between; height: 48px; margin-bottom: 8px; }
.barra-topo .title { font-size: 16px; }
.icone-btn { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); transition: transform .12s; }
.icone-btn:active { transform: scale(.94); }

/* Foto e análise */
.foto-grande { position: relative; border-radius: var(--r-lg); overflow: hidden; aspect-ratio: 4 / 3; background: var(--sunk); }
.foto-grande img { width: 100%; height: 100%; object-fit: cover; }
.analisando { position: absolute; inset: 0; background: rgba(34, 28, 24, .35); display: grid; place-items: end start; padding: 18px; color: var(--on-dark); }
.analisando::before { content: ""; position: absolute; left: 0; right: 0; height: 30%; top: -30%; background: linear-gradient(180deg, transparent, rgba(247, 243, 236, .22), transparent); animation: varrer 1.8s ease-in-out infinite; }
@keyframes varrer { to { top: 100%; } }
.analisando .display-md { font-size: 22px; }
.chips { scroll-behavior: auto; display: flex; gap: 8px; overflow-x: auto; margin: 16px calc(var(--gutter) * -1) 0; padding: 0 var(--gutter); scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; min-height: 40px; padding: 0 16px; border-radius: 999px; background: var(--surface); font-size: 15px; font-weight: 500; color: var(--body); transition: background .2s, color .2s; }
.chip.ativo { background: var(--ink); color: var(--canvas); }
.prato-titulo { margin-top: 24px; }
.observacao { margin-top: 8px; font-size: 15px; line-height: 1.4; color: var(--body); }

.item { background: var(--surface); border-radius: var(--r-lg); padding: 14px 14px 14px 16px; }
.item-topo { display: flex; align-items: flex-start; gap: 10px; }
.item-topo input { flex: 1; min-width: 0; border: 0; background: transparent; font-size: 17px; font-weight: 600; padding: 0; outline: none; }
.item-topo .num { font-size: 22px; line-height: 1.1; white-space: nowrap; }
.item-topo .num small { font-family: var(--sans); font-size: 12px; color: var(--muted); }
.item-meio { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; gap: 10px; }
.item-macros { font-size: 13px; color: var(--muted); font-weight: 500; display: flex; gap: 10px; flex-wrap: wrap; }
.item-macros b { font-weight: 600; color: var(--body); }
.confianca { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); margin-top: 4px; }
.confianca i { width: 6px; height: 6px; border-radius: 50%; }
.stepper { display: flex; align-items: center; background: var(--sunk); border-radius: 999px; flex: none; }
.stepper button { width: 44px; height: 40px; display: grid; place-items: center; }
.stepper button svg.i { width: 18px; height: 18px; }
.stepper input { width: 58px; text-align: center; border: 0; background: transparent; font-family: var(--serif); font-size: 17px; padding: 0; outline: none; font-variant-numeric: tabular-nums; }
.stepper span { font-size: 13px; color: var(--muted); margin-right: 2px; }
.remover { width: 32px; height: 32px; margin: -4px -6px 0 0; border-radius: 50%; display: grid; place-items: center; color: var(--muted); }
.remover svg.i { width: 18px; height: 18px; }

.barra-acao {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 35;
  background: var(--espresso); color: var(--on-dark);
  padding: 16px var(--gutter) calc(var(--safe-bottom) + 14px);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
}
.barra-acao .dentro { max-width: 440px; margin: 0 auto; }
.totais { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; }
.totais .num { font-size: 30px; line-height: 1; }
.totais .caption { color: var(--on-dark-muted); }
.totais .mini { display: flex; gap: 12px; font-size: 13px; color: var(--on-dark-muted); }
.totais .mini b { color: var(--on-dark); font-weight: 600; }

/* Campos */
.campo { display: block; width: 100%; min-height: 56px; border: 0; border-radius: var(--r-md); background: var(--surface); padding: 14px 16px; font-size: 17px; outline: none; -webkit-appearance: none; appearance: none; }
.campo:focus { box-shadow: 0 0 0 2px var(--ink); }
textarea.campo { min-height: 110px; resize: none; line-height: 1.4; }
.campo-num { display: flex; align-items: baseline; gap: 10px; border-bottom: 1px solid var(--hairline); padding-bottom: 8px; }
.campo-num input { flex: 1; min-width: 0; border: 0; background: transparent; font-family: var(--serif); font-size: 64px; line-height: 1.1; padding: 0; outline: none; font-variant-numeric: tabular-nums; }
.campo-num span { font-size: 20px; color: var(--muted); }
.erro { color: var(--primary); font-size: 15px; margin-top: 10px; min-height: 21px; }

/* Cadastro */
.cadastro { min-height: 100dvh; display: flex; flex-direction: column; padding: calc(var(--safe-top) + 10px) var(--gutter) calc(var(--safe-bottom) + 20px); }
.cad-topo { display: flex; align-items: center; gap: 14px; height: 48px; }
.progresso-cad { flex: 1; height: 3px; background: var(--hairline); border-radius: 3px; overflow: hidden; }
.progresso-cad i { display: block; height: 100%; background: var(--ink); transition: width .4s var(--ease); }
.cad-corpo { flex: 1; padding-top: 28px; animation: entrar .35s var(--ease); }
.cad-corpo .display-lg { margin-bottom: 10px; }
.cad-corpo > .callout { margin-bottom: 28px; }
.opcoes { display: flex; flex-direction: column; gap: 10px; }
.opcao { text-align: left; width: 100%; min-height: 60px; padding: 14px 18px; border-radius: var(--r-md); background: var(--surface); display: flex; align-items: center; justify-content: space-between; gap: 12px; transition: transform .12s, box-shadow .2s; }
.opcao .caption { margin-top: 2px; }
.opcao .marca { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--hairline); flex: none; display: grid; place-items: center; }
.opcao.ativa { box-shadow: 0 0 0 2px var(--ink); }
.opcao.ativa .marca { background: var(--ink); border-color: var(--ink); color: var(--canvas); }
.opcao.ativa .marca svg.i { width: 14px; height: 14px; stroke-width: 2.4; }
.boas-vindas { min-height: 100dvh; display: flex; flex-direction: column; justify-content: flex-end; padding: calc(var(--safe-top) + 24px) var(--gutter) calc(var(--safe-bottom) + 24px); background: var(--espresso); color: var(--on-dark); }
.boas-vindas .marca-app { font-family: var(--serif); font-size: 46px; line-height: 1.02; letter-spacing: -0.03em; font-weight: 300; font-variation-settings: "opsz" 144; }
.boas-vindas .marca-app em { font-style: italic; color: var(--primary); }
.boas-vindas p.callout { color: var(--on-dark-muted); margin: 18px 0 36px; font-size: 17px; }
.prato-ilustra { flex: 1; display: grid; place-items: center; }
.prato-ilustra svg { width: 72%; max-width: 280px; }

.resumo-kcal { text-align: center; padding: 26px 20px; }
.resumo-kcal .num { font-size: 64px; line-height: 1; display: block; }
.grade-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.metrica { background: var(--surface); border-radius: var(--r-md); padding: 14px 16px; }
.metrica .num { font-size: 24px; display: block; margin-top: 4px; }
.metrica .num small { font-family: var(--sans); font-size: 13px; color: var(--muted); }

/* Diário */
.semana { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.dia { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 0 12px; border-radius: var(--r-md); font-size: 12px; color: var(--muted); font-weight: 500; }
.dia .num { font-size: 19px; color: var(--ink); }
.dia .pt { width: 6px; height: 6px; border-radius: 50%; background: transparent; }
.dia .pt.ok { background: var(--success); } .dia .pt.alto { background: var(--primary); } .dia .pt.baixo { background: var(--carb); }
.dia.ativo { background: var(--ink); color: var(--on-dark-muted); }
.dia.ativo .num { color: var(--canvas); }
.nav-semana { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }

/* Progresso */
.grafico svg { width: 100%; height: 170px; display: block; overflow: visible; }
.grafico .eixo { font-size: 11px; fill: var(--muted); font-family: var(--sans); }
.barras { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end; height: 130px; position: relative; }
.barras .b { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; font-size: 12px; color: var(--muted); }
.barras .b i { width: 100%; max-width: 28px; border-radius: 8px 8px 4px 4px; background: var(--ink); min-height: 3px; transition: height .8s var(--ease); }
.barras .b i.acima { background: var(--primary); }
.linha-alvo { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--muted); }

.lista-config .linha { display: flex; justify-content: space-between; align-items: center; min-height: 52px; border-bottom: 1px solid var(--hairline); font-size: 17px; }
.lista-config .linha:last-child { border-bottom: 0; }
.lista-config .linha span:last-child { color: var(--muted); }
.lista-config button.linha { width: 100%; text-align: left; }
.dicas li { margin-bottom: 10px; color: var(--body); font-size: 15px; line-height: 1.45; }
.dicas { padding-left: 20px; margin: 0; }
.aviso { font-size: 13px; color: var(--muted); line-height: 1.45; margin-top: 18px; }

/* Toast */
#toast { position: fixed; left: 50%; top: calc(var(--safe-top) + 12px); transform: translate(-50%, -140%); z-index: 60; background: var(--ink); color: var(--canvas); padding: 12px 18px; border-radius: 999px; font-size: 15px; font-weight: 500; max-width: calc(100% - 40px); transition: transform .35s var(--ease); pointer-events: none; text-align: center; }
#toast.visivel { transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) { *, *::before { animation: none !important; transition: none !important; } }
