:root {
  --bg: #f4f6f2;
  --card: #ffffff;
  --text: #1b1f1a;
  --muted: #6b7366;
  --line: #e4e8e0;
  --primary: #15803d;
  --primary-soft: #dcfce7;
  --accent: #f59e0b;
  --danger: #dc2626;
  --protein: #2563eb;
  --carbs: #f59e0b;
  --fat: #db2777;
  --radius: 16px;
  --tabs-h: 64px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1210; --card: #181d19; --text: #eef2ec; --muted: #9aa494; --line: #2a312b;
    --primary: #22c55e; --primary-soft: #133a22;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { min-height: 100dvh; padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom)); }
main { max-width: 640px; margin: 0 auto; padding: calc(12px + env(safe-area-inset-top)) 14px 24px; }
h1 { font-size: 1.5rem; margin: 6px 0 14px; }
h2 { font-size: 1.1rem; margin: 0; }
h3 { font-size: 1rem; margin: 0; }
p { line-height: 1.45; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 10px; }
.hidden, [hidden] { display: none !important; }

.card { background: var(--card); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; border: 1px solid var(--line); }

button, .btn {
  font: inherit; border: 0; cursor: pointer; border-radius: 12px; padding: 11px 14px;
  background: var(--primary); color: #fff; font-weight: 600;
}
button:disabled { opacity: .5; }
.btn-ghost { background: transparent; color: var(--primary); padding: 8px 10px; }
.btn-soft { background: var(--primary-soft); color: var(--primary); }
.btn-danger { background: transparent; color: var(--danger); }
.btn-block { width: 100%; }
.icon-btn { background: transparent; color: var(--text); padding: 6px 10px; font-size: 1.1rem; }

input, select, textarea {
  font: inherit; width: 100%; padding: 11px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); border-color: transparent; }
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

/* Abas inferiores */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--card); border-top: 1px solid var(--line);
}
.tabs button { background: none; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: .7rem; font-weight: 500; border-radius: 0; padding: 0; }
.tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs button.active { color: var(--primary); }

/* Data */
.date-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.date-nav strong { font-size: 1.05rem; }

/* Resumo */
.summary { display: flex; align-items: center; gap: 16px; }
.ring { position: relative; width: 120px; height: 120px; flex: none; }
.ring svg { transform: rotate(-90deg); }
.ring .center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.ring .big { font-size: 1.5rem; font-weight: 700; }
.ring .lbl { font-size: .72rem; color: var(--muted); }
.macros { flex: 1; min-width: 0; }
.macro { margin-bottom: 8px; }
.macro .row { font-size: .82rem; }
.bar { height: 7px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 3px; }
.bar > i { display: block; height: 100%; border-radius: 99px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.stats b { display: block; font-size: 1.05rem; }
.stats span { font-size: .75rem; color: var(--muted); }

/* Refeições */
.meal-head { display: flex; align-items: center; justify-content: space-between; }
.meal-head .kcal { font-weight: 600; }
.entry { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); cursor: pointer; }
.entry:first-of-type { margin-top: 8px; }
.entry .name { font-weight: 500; }
.entry .kcal { font-weight: 600; white-space: nowrap; }
.meal-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.meal-actions button { padding: 8px 10px; font-size: .85rem; }
.tag { display: inline-block; font-size: .7rem; padding: 2px 7px; border-radius: 99px; background: var(--primary-soft); color: var(--primary); font-weight: 600; vertical-align: middle; margin-left: 4px; }

/* Lista de resultados */
.list-item { display: flex; align-items: center; gap: 10px; padding: 11px 2px; border-bottom: 1px solid var(--line); cursor: pointer; }
.list-item:last-child { border-bottom: 0; }
.list-item .name { font-weight: 500; }
.list-item .right { text-align: right; white-space: nowrap; }

/* Bottom sheet */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--card); width: 100%; max-width: 640px; max-height: 92dvh; border-radius: 20px 20px 0 0; display: flex; flex-direction: column; animation: up .2s ease; }
@keyframes up { from { transform: translateY(40px); opacity: .5; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 6px; }
.sheet-body { overflow-y: auto; padding: 6px 14px calc(18px + env(safe-area-inset-bottom)); }

.preview { display: grid; grid-template-columns: repeat(4, 1fr); text-align: center; background: var(--bg); border-radius: 12px; padding: 10px 4px; margin: 10px 0 14px; }
.preview b { display: block; font-size: 1.1rem; }
.preview span { font-size: .72rem; color: var(--muted); }
.seg { display: flex; background: var(--bg); border-radius: 12px; padding: 3px; gap: 3px; margin-bottom: 12px; }
.seg button { flex: 1; background: transparent; color: var(--muted); padding: 8px; font-weight: 500; }
.seg button.active { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chips button { background: var(--bg); color: var(--text); font-weight: 500; padding: 7px 11px; font-size: .85rem; border: 1px solid var(--line); }
.chips button.active { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }

/* Ingredientes do prato */
.ing { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.ing input { width: 80px; padding: 8px; text-align: right; }

/* Claude */
a.btn { display: block; text-align: center; text-decoration: none; }
.step-n { width: 26px; height: 26px; border-radius: 50%; background: var(--primary); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; flex: none; }
.steps { margin: 0 0 12px; padding-left: 20px; line-height: 1.55; }
.steps li { margin-bottom: 4px; }
.prompt-list { display: flex; flex-direction: column; gap: 8px; }
.prompt { display: block; padding: 11px 12px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); color: var(--text); text-decoration: none; font-size: .92rem; line-height: 1.35; }
.prompt::after { content: ' ↗'; color: var(--primary); }
.warn { background: #fef3c7; color: #78350f; border-color: #fcd34d; font-size: .92rem; line-height: 1.45; }
@media (prefers-color-scheme: dark) { .warn { background: #3a2c0a; color: #fde68a; border-color: #6b4f12; } }

/* Plano */
.plan-main { text-align: center; margin: 12px 0 10px; }
.plan-main b { display: block; font-size: 2.2rem; color: var(--primary); line-height: 1.1; }
.plan-main span { color: var(--muted); font-size: .85rem; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.tile { background: var(--bg); border-radius: 12px; padding: 9px 4px; text-align: center; }
.tile b { display: block; }
.tile span { font-size: .75rem; color: var(--muted); }
.plan-rows > div { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: .9rem; }
.plan-rows span { color: var(--muted); }
.plan-rows b { text-align: right; }
.plan-rows .eta b { color: var(--primary); }
.warn-line { font-size: .88rem; margin: 10px 0 0; line-height: 1.4; }

/* Histórico */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 120px; position: relative; }
.bars .col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bars .col i { width: 100%; background: var(--primary); border-radius: 6px 6px 2px 2px; min-height: 2px; }
.bars .col i.over { background: var(--accent); }
.bars .col span { font-size: .68rem; color: var(--muted); margin-top: 4px; }
.goal-line { position: absolute; left: 0; right: 0; border-top: 2px dashed var(--muted); opacity: .5; }

/* Auth */
.auth { max-width: 380px; margin: 8vh auto 0; }
.logo { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 18px; }
.logo img { width: 52px; height: 52px; border-radius: 14px; }
.logo h1 { margin: 0; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabs-h) + 16px + env(safe-area-inset-bottom)); background: #1b1f1a; color: #fff; padding: 10px 16px; border-radius: 12px; z-index: 60; font-size: .9rem; max-width: 90vw; }
.empty { text-align: center; padding: 26px 10px; color: var(--muted); }
