/* ==========================================================================
   Protocolo Verde — componentes (v2)
   ========================================================================== */

/* ---------- Grade e utilidades ----------
   Existem para que nenhuma tela precise de style="" (bloqueado pela CSP). */
.wrap {
  width: 100%;
  max-width: var(--max-w);
  margin-inline: auto;
  padding-inline: max(var(--s4), env(safe-area-inset-left, 0px));
}
.wrap-sm {
  max-width: 600px;
  margin-inline: auto;
  width: 100%;
}

.stack { display: grid; gap: var(--s4); }
.stack-xs { display: grid; gap: var(--s1); }
.stack-sm { display: grid; gap: var(--s2); }
.stack-md { display: grid; gap: var(--s3); }
.stack-lg { display: grid; gap: var(--s6); }
.stack-xl { display: grid; gap: var(--s8); }

.row { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.row-sm { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.row-top { align-items: flex-start; }
.row-base { align-items: baseline; }
.row-nowrap { flex-wrap: nowrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.row-center { justify-content: center; }
.row-end { justify-content: flex-end; }
.push { margin-left: auto; }
.grow { flex: 1; min-width: 0; }
.grow-140 { flex: 1 1 140px; min-width: 0; }
.grow-180 { flex: 1 1 180px; min-width: 0; }
.self-start { justify-self: start; align-self: flex-start; }
.self-end { align-self: flex-end; }
.none { flex: none; }

.grid-2 { display: grid; gap: var(--s4); }
.grid-3 { display: grid; gap: var(--s3); }
.grid-auto { display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
@media (min-width: 560px) {
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.mt-1 { margin-top: var(--s1); }
.mt-2 { margin-top: var(--s2); }
.mt-3 { margin-top: var(--s3); }
.mt-4 { margin-top: var(--s4); }
.mt-6 { margin-top: var(--s6); }
.mb-2 { margin-bottom: var(--s2); }

.eyebrow {
  font-family: var(--f-mono);
  font-size: var(--t-2xs);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
.lede { font-size: var(--t-md); color: var(--muted); max-width: 56ch; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: var(--t-sm); }
.xsmall { font-size: var(--t-xs); }
.center { text-align: center; }
.strong { font-weight: 700; color: var(--ink); }
.t-xl { font-size: var(--t-xl); }
.t-md { font-size: var(--t-md); }
.t-leaf { color: var(--leaf); }
.t-mango { color: var(--mango-ink); }
.t-danger { color: var(--danger); }
.display { font-family: var(--f-display); font-weight: 800; letter-spacing: -0.03em; line-height: 0.95; }
.nowrap { white-space: nowrap; }

/* Destaque em titulo: palavra em manga com um traco desenhado embaixo. */
.marca {
  font-style: normal;
  color: var(--mango);
  position: relative;
  white-space: nowrap;
}
.marca::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -0.04em;
  height: 0.12em;
  border-radius: 999px;
  background: currentcolor;
  opacity: 0.35;
  transform-origin: left;
  animation: pv-marca 900ms var(--e-out) 400ms both;
}
@keyframes pv-marca {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

/* ---------- Cores por refeicao ---------- */
.c-cafe { --c: var(--mango); --c-soft: var(--mango-soft); --c-ink: var(--mango-ink); --c-on: var(--on-mango); }
.c-lanche_manha { --c: var(--coral); --c-soft: var(--coral-soft); --c-ink: var(--coral-ink); }
.c-almoco { --c: var(--leaf); --c-soft: var(--leaf-soft); --c-ink: var(--leaf-strong); }
.c-lanche_tarde { --c: var(--lilac); --c-soft: var(--lilac-soft); --c-ink: var(--lilac-ink); }
.c-jantar { --c: var(--indigo); --c-soft: var(--indigo-soft); --c-ink: var(--indigo-ink); }
.c-ceia { --c: var(--slate); --c-soft: var(--slate-soft); --c-ink: var(--slate-ink); }
.c-agua { --c: var(--water); --c-soft: var(--water-soft); --c-ink: var(--water-ink); }
.c-leaf { --c: var(--leaf); --c-soft: var(--leaf-soft); --c-ink: var(--leaf-strong); }
.c-mango { --c: var(--mango); --c-soft: var(--mango-soft); --c-ink: var(--mango-ink); --c-on: var(--on-mango); }
.c-coral { --c: var(--coral); --c-soft: var(--coral-soft); --c-ink: var(--coral-ink); }
.c-lilac { --c: var(--lilac); --c-soft: var(--lilac-soft); --c-ink: var(--lilac-ink); }
.c-indigo { --c: var(--indigo); --c-soft: var(--indigo-soft); --c-ink: var(--indigo-ink); }

/* Selo colorido com icone (refeicao, categoria, beneficio) */
.selo {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--c-soft, var(--surface-2));
  color: var(--c-ink, var(--ink));
}
.selo svg { width: 24px; height: 24px; }
.selo-lg { width: 56px; height: 56px; border-radius: 18px; }
.selo-lg svg { width: 30px; height: 30px; }
.selo-sm { width: 34px; height: 34px; border-radius: 11px; }
.selo-sm svg { width: 18px; height: 18px; }

/* ---------- Botao ---------- */
.btn {
  --btn-bg: var(--surface);
  --btn-ink: var(--ink);
  --btn-line: var(--line-strong);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: 48px;
  padding: 0 var(--s6);
  border: 1px solid var(--btn-line);
  border-radius: var(--r-full);
  background: var(--btn-bg);
  color: var(--btn-ink);
  font-weight: 650;
  font-size: var(--t-base);
  letter-spacing: -0.005em;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  isolation: isolate;
  user-select: none;
  transition:
    transform var(--d-1) var(--e-out),
    box-shadow var(--d-2) var(--e-out),
    background-color var(--d-1) linear,
    border-color var(--d-1) linear,
    color var(--d-1) linear;
}
.btn svg { width: 18px; height: 18px; }
.btn:hover { transform: translateY(-1px); color: var(--btn-ink); }
.btn:active { transform: translateY(0) scale(0.97); }

.btn-primary { --btn-bg: var(--leaf); --btn-ink: var(--on-leaf); --btn-line: transparent; box-shadow: var(--sh-leaf); }
.btn-primary:hover { --btn-bg: var(--leaf-hover); box-shadow: 0 12px 28px -10px rgb(20 138 83 / 0.6); }
.btn-mango { --btn-bg: var(--mango); --btn-ink: var(--on-mango); --btn-line: transparent; box-shadow: var(--sh-mango); }
.btn-dark { --btn-bg: var(--ink); --btn-ink: var(--bg); --btn-line: transparent; }
.btn-ghost { --btn-bg: transparent; --btn-line: var(--line-strong); }
.btn-ghost:hover { --btn-bg: var(--surface-2); }
.btn-quiet { --btn-bg: transparent; --btn-line: transparent; --btn-ink: var(--muted); min-height: 40px; padding-inline: var(--s3); }
.btn-quiet:hover { --btn-bg: var(--surface-2); --btn-ink: var(--ink); }
.btn-danger { --btn-bg: transparent; --btn-ink: var(--danger); --btn-line: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn-danger:hover { --btn-bg: var(--danger-soft); }
.btn-on-dark { --btn-bg: rgb(255 255 255 / 0.1); --btn-ink: var(--hero-ink); --btn-line: rgb(255 255 255 / 0.18); }
.btn-on-dark:hover { --btn-bg: rgb(255 255 255 / 0.16); }

.btn-block { width: 100%; }
.btn-sm { min-height: 38px; padding-inline: var(--s4); font-size: var(--t-sm); }
.btn-lg { min-height: 56px; padding-inline: var(--s7); font-size: var(--t-md); }

.btn:disabled,
.btn[aria-disabled='true'] { opacity: 0.5; pointer-events: none; }

/* Onda do toque, posicionada pelo JS em --x/--y */
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(circle at var(--x, 50%) var(--y, 50%), rgb(255 255 255 / 0.35), transparent 60%);
  opacity: 0;
  transition: opacity var(--d-3) var(--e-out);
}
.btn.is-rippling::after { opacity: 1; transition: none; }

.btn.is-loading { color: transparent; pointer-events: none; }
.btn.is-loading > * { visibility: hidden; }
.btn.is-loading::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2.5px solid var(--btn-ink);
  border-top-color: transparent;
  border-radius: 50%;
  animation: pv-spin 620ms linear infinite;
}

.btn-google { --btn-bg: var(--surface); --btn-line: var(--line-strong); }
.btn-google svg { width: 20px; height: 20px; }

/* ---------- Icone circular ---------- */
.icon-btn {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: var(--r-full);
  color: var(--muted);
  transition:
    background-color var(--d-1) linear,
    color var(--d-1) linear,
    transform var(--d-2) var(--e-spring);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn:active { transform: scale(0.88); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn-solid { background: var(--surface); border: 1px solid var(--line); box-shadow: var(--sh-1); color: var(--ink); }

/* ---------- Card ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--sh-1);
}
.card-pad { padding: var(--s5); }
.card-pad-lg { padding: var(--s6); }
.card-lg { border-radius: var(--r-lg); }
.card-flat { box-shadow: none; }
.card-hover {
  transition:
    transform var(--d-2) var(--e-out),
    box-shadow var(--d-2) var(--e-out),
    border-color var(--d-2) linear;
}
.card-hover:hover { transform: translateY(-3px); box-shadow: var(--sh-2); border-color: var(--line-strong); }
.card-danger { border-color: color-mix(in srgb, var(--danger) 30%, var(--line)); }
.card-clip { overflow: hidden; }

.sec-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s4);
  flex-wrap: wrap;
}
.sec-head h2 { margin: 0; }
.sec-head p { margin: var(--s1) 0 0; color: var(--muted); max-width: 58ch; }
.sec-title { font-size: var(--t-xl); }

/* ---------- Chip ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  border-radius: var(--r-full);
  background: var(--surface-2);
  color: var(--muted);
  font-size: var(--t-xs);
  font-weight: 650;
  white-space: nowrap;
  line-height: 1.5;
}
.chip svg { width: 13px; height: 13px; }
.chip-kcal { background: var(--mango-soft); color: var(--mango-ink); font-family: var(--f-mono); font-weight: 500; }
.chip-prot { background: var(--leaf-soft); color: var(--leaf-strong); font-family: var(--f-mono); font-weight: 500; }
.chip-water { background: var(--water-soft); color: var(--water-ink); }
.chip-ok { background: var(--ok-soft); color: var(--ok); }
.chip-warn { background: var(--warn-soft); color: var(--warn); }
.chip-danger { background: var(--danger-soft); color: var(--danger); }
.chip-outline { background: transparent; box-shadow: inset 0 0 0 1px var(--line-strong); }
.chip-cor { background: var(--c-soft); color: var(--c-ink); }
.chip-tiny { font-size: 10px; padding: 2px 8px; }
.chip-dark { background: rgb(255 255 255 / 0.12); color: var(--hero-ink); }

/* Selo de sequencia (chama) */
.streak {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 6px 8px;
  border-radius: var(--r-full);
  background: var(--mango-soft);
  color: var(--mango-ink);
  font-weight: 700;
  font-size: var(--t-sm);
}
.streak svg { width: 18px; height: 18px; color: var(--mango); }
.streak.is-on svg { animation: pv-wiggle 1.6s var(--e-in-out) infinite; transform-origin: 50% 90%; }

/* ---------- Campo de formulario ---------- */
.field { display: grid; gap: 6px; }
.field > label,
.label { font-size: var(--t-sm); font-weight: 650; color: var(--ink-2); }

.input,
.select,
.textarea {
  width: 100%;
  min-height: 54px;
  padding: 0 var(--s4);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--t-md);
  transition:
    border-color var(--d-1) linear,
    box-shadow var(--d-2) var(--e-out),
    background-color var(--d-1) linear;
}
.textarea { min-height: 96px; padding: var(--s3) var(--s4); resize: vertical; line-height: 1.5; }
.input::placeholder,
.textarea::placeholder { color: var(--faint); }
.input:hover,
.select:hover,
.textarea:hover { border-color: var(--muted); }
.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--leaf);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--leaf) 16%, transparent);
}

/* Numero grande (peso, altura): o valor e o heroi do passo */
.input-xl {
  min-height: 76px;
  font-family: var(--f-display);
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* Sufixo e botao do olho presos ao campo (nao ao .field inteiro): erro ou
   dica embaixo nao empurram o "kg" para cima do texto. */
.input-wrap { position: relative; }
.field-unit .input { padding-right: var(--s9); }
.field-unit .unit {
  position: absolute;
  right: var(--s4);
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: var(--t-sm);
  font-weight: 650;
  pointer-events: none;
}
.field-unit .input-xl + .unit { font-size: var(--t-md); }

/* Campo numerico que sobrar: sem setinhas sobre o numero grande. */
.input[type='number'] { appearance: textfield; -moz-appearance: textfield; }
.input[type='number']::-webkit-inner-spin-button,
.input[type='number']::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* Safari iOS: date/time tem largura minima propria e texto centralizado. */
.input[type='date'],
.input[type='time'] {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  min-width: 0;
  max-width: 100%;
  line-height: 51px;
  text-align: left;
}
.input[type='date']::-webkit-date-and-time-value,
.input[type='time']::-webkit-date-and-time-value { text-align: left; margin: 0; min-height: 1.2em; }
.input[type='date']::-webkit-calendar-picker-indicator,
.input[type='time']::-webkit-calendar-picker-indicator { opacity: 0.6; cursor: pointer; }

.field.has-error .input,
.field.has-error .select,
.field.has-error .textarea { border-color: var(--danger); }
/* Tremor do erro vem do JS (repete a cada erro e respeita reduced-motion). */
fieldset.field.has-error .option,
fieldset.field.has-error .option-mark { border-color: var(--danger); }
.field-error {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--t-sm);
  color: var(--danger);
  animation: pv-rise var(--d-2) var(--e-out) both;
}
.field-error svg { width: 16px; height: 16px; }
.field-hint { font-size: var(--t-sm); color: var(--muted); }

.field-password .input { padding-right: 54px; }
.field-password .reveal {
  position: absolute;
  right: 7px;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: var(--r-xs);
  color: var(--muted);
}
.field-password .reveal:hover { background: var(--surface-2); color: var(--ink); }
.field-password .reveal svg { width: 19px; height: 19px; }
.field-password .reveal .i-olho-off { display: none; }
.field-password .reveal[aria-pressed='true'] .i-olho { display: none; }
.field-password .reveal[aria-pressed='true'] .i-olho-off { display: block; }

.strength { display: grid; gap: 6px; }
.strength-bars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.strength-bars i {
  height: 5px;
  border-radius: 999px;
  background: var(--surface-3);
  transform-origin: left;
  transition: background-color var(--d-2) var(--e-out), transform var(--d-2) var(--e-spring);
}
.strength[data-level='1'] .strength-bars i:nth-child(-n + 1),
.strength[data-level='2'] .strength-bars i:nth-child(-n + 2) { background: var(--danger); }
.strength[data-level='3'] .strength-bars i:nth-child(-n + 3) { background: var(--mango); }
.strength[data-level='4'] .strength-bars i { background: var(--leaf); }
.strength-text { font-size: var(--t-xs); color: var(--muted); }

/* ---------- Caixa de marcar ---------- */
.check { display: flex; align-items: flex-start; gap: var(--s3); cursor: pointer; line-height: 1.5; }
.check input[type='checkbox'] {
  appearance: none;
  flex: none;
  width: 24px;
  height: 24px;
  margin: 1px 0 0;
  border: 2px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  display: grid;
  place-content: center;
  cursor: pointer;
  transition:
    background-color var(--d-1) var(--e-out),
    border-color var(--d-1) var(--e-out),
    transform var(--d-2) var(--e-spring);
}
.check input[type='checkbox']::after {
  content: '';
  width: 11px;
  height: 6px;
  border: 2.5px solid var(--on-leaf);
  border-top: 0;
  border-right: 0;
  transform: rotate(-45deg) translate(1px, -1px) scale(0.3);
  opacity: 0;
  transition: opacity var(--d-1) linear, transform var(--d-2) var(--e-spring);
}
.check input[type='checkbox']:checked { background: var(--leaf); border-color: var(--leaf); }
.check input[type='checkbox']:checked::after { opacity: 1; transform: rotate(-45deg) translate(1px, -1px) scale(1); }
.check input[type='checkbox']:active { transform: scale(0.86); }
.check-text b { display: block; font-weight: 650; color: var(--ink); }
.check-text span { color: var(--muted); font-size: var(--t-sm); }

/* Linha de pergunta sim/nao (triagem) */
.pergunta {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s4);
  cursor: pointer;
  transition: background-color var(--d-1) linear;
}
.pergunta + .pergunta { border-top: 1px solid var(--line); }
.pergunta:hover { background: var(--surface-2); }
.pergunta-texto { flex: 1; min-width: 0; }
.pergunta-texto b { display: block; font-weight: 650; }
.pergunta-texto span { font-size: var(--t-sm); color: var(--muted); }

/* ---------- Interruptor ---------- */
.switch { display: flex; align-items: center; gap: var(--s3); cursor: pointer; }
.switch input {
  appearance: none;
  flex: none;
  width: 52px;
  height: 32px;
  border-radius: 999px;
  background: var(--surface-3);
  position: relative;
  cursor: pointer;
  transition: background-color var(--d-2) var(--e-out);
}
.switch input::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgb(0 0 0 / 0.2);
  transition: transform var(--d-3) var(--e-spring), width var(--d-2) var(--e-out);
}
.switch input:active::after { width: 32px; }
.switch input:checked { background: var(--leaf); }
.switch input:checked::after { transform: translateX(20px); }
.switch input:checked:active::after { transform: translateX(14px); }

/* ---------- Escolha em cartoes ---------- */
.options { display: grid; gap: var(--s2); }
.options-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.options-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 420px) {
  .options-3 { grid-template-columns: 1fr; }
}

.option {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s4);
  border: 1.5px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  cursor: pointer;
  box-shadow: var(--sh-1);
  transition:
    border-color var(--d-1) linear,
    background-color var(--d-2) var(--e-out),
    transform var(--d-2) var(--e-spring),
    box-shadow var(--d-2) var(--e-out);
}
.option:hover { border-color: var(--line-strong); transform: translateY(-2px); box-shadow: var(--sh-2); }
button.option { width: 100%; text-align: left; }
.option:active { transform: scale(0.98); }
.option input { position: absolute; opacity: 0; pointer-events: none; }
.option-body { display: grid; gap: 2px; min-width: 0; flex: 1; }
.option-body b { font-weight: 700; font-size: var(--t-md); }
.option-body span { font-size: var(--t-sm); color: var(--muted); }
.option-extra { justify-self: start; margin-top: 6px; padding: 3px 10px; border-radius: var(--r-full); background: var(--c-soft, var(--surface-2)); color: var(--c-ink, var(--ink-2)); font-family: var(--f-mono); font-size: var(--t-xs); font-weight: 500; white-space: nowrap; }
.option-mark {
  flex: none;
  width: 24px;
  height: 24px;
  border: 2px solid var(--line-strong);
  border-radius: 50%;
  display: grid;
  place-items: center;
  transition: border-color var(--d-1) linear, background-color var(--d-1) linear, transform var(--d-3) var(--e-spring);
}
.option-mark::after {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--on-leaf);
  transform: scale(0);
  transition: transform var(--d-3) var(--e-spring);
}
.option-icon {
  flex: none;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--c-soft, var(--surface-2));
  color: var(--c-ink, var(--leaf));
  transition: transform var(--d-3) var(--e-spring), background-color var(--d-2) linear;
}
.option-icon svg { width: 26px; height: 26px; }

.option:has(input:checked) {
  border-color: var(--leaf);
  background: var(--leaf-tint);
  box-shadow: 0 0 0 1.5px var(--leaf), var(--sh-2);
}
.option:has(input:checked) .option-mark { border-color: var(--leaf); background: var(--leaf); transform: scale(1.1); }
.option:has(input:checked) .option-mark::after { transform: scale(1); }
.option:has(input:checked) .option-icon { transform: scale(1.08) rotate(-4deg); }
.option:has(input:disabled) { opacity: 0.5; cursor: not-allowed; transform: none; }
.option:has(input:focus-visible) { outline: 2.5px solid var(--focus, var(--mango)); outline-offset: 2px; }
/* Cartao grande escolhido: aperta enquanto o check termina e o passo avanca. */
.option.is-confirmando { transform: scale(0.98); }

/* Cartao grande, vertical, para as escolhas principais do onboarding */
.option-big { flex-direction: column; align-items: flex-start; padding: var(--s5); gap: var(--s3); min-height: 132px; }
.option-big .option-mark { position: absolute; top: var(--s4); right: var(--s4); }
.option-big .option-body b { font-size: var(--t-lg); }
.option-big .option-icon { width: 54px; height: 54px; border-radius: 16px; }
.option-big .option-icon svg { width: 32px; height: 32px; }

/* ---------- Controle segmentado ---------- */
.segmented {
  display: inline-flex;
  padding: 4px;
  gap: 2px;
  background: var(--surface-2);
  border-radius: var(--r-full);
  border: 1px solid var(--line);
}
.segmented a,
.segmented button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--r-full);
  font-size: var(--t-sm);
  font-weight: 650;
  color: var(--muted);
  text-decoration: none;
  transition: color var(--d-1) linear, background-color var(--d-2) var(--e-out), box-shadow var(--d-2) var(--e-out);
}
.segmented a:hover,
.segmented button:hover { color: var(--ink); }
.segmented [aria-current='true'],
.segmented [aria-pressed='true'] { background: var(--surface); color: var(--ink); box-shadow: var(--sh-1); }
.segmented .bandeira { width: 22px; height: 15px; border-radius: 3px; }

.bandeira { display: block; width: 32px; height: 22px; border-radius: 4px; box-shadow: 0 0 0 1px rgb(0 0 0 / 0.08); flex: none; }
.bandeira-lg { width: 48px; height: 33px; border-radius: 6px; }

/* ---------- Anel de progresso ---------- */
.ring { position: relative; display: grid; place-items: center; flex: none; }
.ring svg { transform: rotate(-90deg); overflow: visible; }
.ring .ring-track { fill: none; stroke: color-mix(in srgb, currentcolor 12%, transparent); }
.ring .ring-prog {
  fill: none;
  stroke: var(--ring-cor, var(--mango));
  stroke-linecap: round;
  stroke-dasharray: var(--len, 1000);
  stroke-dashoffset: var(--len, 1000);
  transition: stroke-dashoffset 1.2s var(--e-out), stroke var(--d-3) linear;
}
.ring.is-ready .ring-prog { stroke-dashoffset: var(--dash, var(--len)); }
.ring.is-cheio .ring-prog { animation: pv-glow 2.4s var(--e-in-out) infinite; }
.ring.is-passou { --ring-cor: var(--coral); }
.ring-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; gap: 2px; }
.ring-value {
  font-family: var(--f-display);
  font-weight: 800;
  line-height: 0.92;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  font-size: 2.6rem;
}
.ring-label { font-size: var(--t-2xs); letter-spacing: 0.12em; text-transform: uppercase; opacity: 0.72; font-weight: 600; }
.ring-sm .ring-value { font-size: 1.5rem; }
.ring-xl .ring-value { font-size: 3.4rem; }

/* ---------- Barras ---------- */
.bar { height: 10px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar > i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--c, var(--leaf));
  width: 0;
  transition: width 1s var(--e-out);
  transition-delay: calc(var(--i, 0) * 90ms + 150ms);
}
.bar-thin { height: 6px; }
.bar-grad > i { background: linear-gradient(90deg, var(--leaf), var(--mango)); }
.bar-on-dark { background: rgb(255 255 255 / 0.12); }

/* Barra de macro com rotulo (estilo apps de dieta) */
.macro { display: grid; gap: 6px; }
.macro-top { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s2); font-size: var(--t-sm); }
.macro-top b { font-weight: 700; }
.macro-top span { font-family: var(--f-mono); font-size: var(--t-xs); color: var(--muted); }
.macros-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s4); }

/* Barra de macros empilhada */
.macros { display: flex; height: 12px; gap: 2px; border-radius: 999px; overflow: hidden; background: var(--surface-3); }
.macros > i { display: block; height: 100%; width: 0; transition: width 1s var(--e-out); }
.macros .m-prot { background: var(--m-prot); }
.macros .m-carb { background: var(--m-carb); transition-delay: 90ms; }
.macros .m-gord { background: var(--m-gord); transition-delay: 180ms; }

.legenda { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s4); font-size: var(--t-xs); color: var(--muted); }
.legenda span { display: inline-flex; align-items: center; gap: 6px; }
.legenda i { width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.k-prot { --c: var(--m-prot); }
.k-carb { --c: var(--m-carb); }
.k-gord { --c: var(--m-gord); }
.k-mango { --c: var(--mango); }
.k-mango-meio { --c: color-mix(in srgb, var(--mango) 42%, transparent); }
.k-vazio { --c: color-mix(in srgb, var(--hero-ink) 22%, transparent); }
.k-leaf { --c: var(--leaf); }

/* ---------- Numero grande ---------- */
.stat { display: grid; gap: 2px; }
.stat b {
  font-family: var(--f-display);
  font-size: var(--t-2xl);
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}
.stat small { font-size: var(--t-2xs); text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); font-weight: 600; }
.stat-kcal b { color: var(--mango-ink); }
.stat-prot b { color: var(--leaf); }
.stat-water b { color: var(--water-ink); }
.unid { font-size: 0.55em; font-weight: 600; letter-spacing: 0; opacity: 0.7; margin-left: 2px; }

/* ---------- Aviso ---------- */
.notice {
  display: flex;
  gap: var(--s3);
  padding: var(--s4);
  border-radius: var(--r-sm);
  font-size: var(--t-base);
  line-height: 1.5;
  background: var(--surface-2);
  color: var(--ink-2);
}
.notice > svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.notice b { font-weight: 700; }
.notice-warn { background: var(--warn-soft); color: var(--warn); }
.notice-danger { background: var(--danger-soft); color: var(--danger); }
.notice-leaf { background: var(--leaf-soft); color: var(--leaf-strong); }
.notice-water { background: var(--water-soft); color: var(--water-ink); }

/* ---------- Esqueleto ---------- */
.skeleton {
  border-radius: var(--r-xs);
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 200% 100%;
  animation: pv-shimmer 1.3s linear infinite;
  color: transparent;
  user-select: none;
  min-height: 56px;
}

/* ---------- Aviso flutuante ---------- */
.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + var(--safe-b) + var(--s4));
  translate: -50% 0;
  z-index: 90;
  display: grid;
  gap: var(--s2);
  width: min(420px, calc(100vw - var(--s7)));
  pointer-events: none;
}
@media (min-width: 900px) {
  .toasts { bottom: var(--s6); }
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) var(--s5) var(--s3) var(--s3);
  border-radius: var(--r-full);
  background: var(--ink);
  color: var(--bg);
  font-size: var(--t-base);
  font-weight: 600;
  box-shadow: var(--sh-3);
  animation: pv-pop var(--d-3) var(--e-spring) both;
  pointer-events: auto;
}
.toast.is-out { animation: pv-fade var(--d-2) var(--e-out) reverse both; }
.toast-icone {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--leaf);
  color: var(--on-leaf);
}
.toast-icone svg { width: 16px; height: 16px; }
.toast-erro { background: var(--danger); color: #fff; }
.toast-erro .toast-icone { background: rgb(255 255 255 / 0.2); color: #fff; }
.toast-info .toast-icone { background: var(--water); color: #fff; }

/* ---------- Folha que sobe ---------- */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  align-items: end;
  margin: 0;
  padding: 0;
  border: 0;
  max-width: none;
  max-height: none;
  width: 100%;
  height: 100%;
  background: rgb(6 16 11 / 0.48);
  backdrop-filter: blur(4px);
  animation: pv-fade var(--d-2) var(--e-out) both;
}
.sheet::backdrop { background: transparent; }
.sheet.is-saindo { animation: pv-fade var(--d-2) var(--e-out) reverse both; }
.sheet-panel {
  background: var(--surface);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: var(--s3) var(--s5) calc(var(--s6) + var(--safe-b));
  max-height: 88dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  animation: pv-slide-up var(--d-4) var(--e-out) both;
  box-shadow: var(--sh-3);
}
.sheet.is-saindo .sheet-panel { animation: pv-slide-up var(--d-2) var(--e-in-out) reverse both; }
.sheet-grip { width: 44px; height: 5px; border-radius: 999px; background: var(--line-strong); margin: 0 auto var(--s4); }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s4); }
.sheet-head h3 { font-size: var(--t-xl); }
.sheet-head p { margin: var(--s1) 0 0; color: var(--muted); font-size: var(--t-sm); }
@media (min-width: 720px) {
  .sheet { place-items: center; }
  .sheet-panel { width: min(560px, calc(100vw - var(--s8))); border-radius: var(--r-lg); max-height: 84dvh; padding-top: var(--s5); animation-name: pv-pop; animation-timing-function: var(--e-spring); }
  .sheet.is-saindo .sheet-panel { animation-name: pv-fade; }
  .sheet-grip { display: none; }
}

/* ---------- Barra de cima ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  view-transition-name: pv-topo;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.5) blur(16px);
  border-bottom: 1px solid transparent;
  transition: border-color var(--d-2) linear, box-shadow var(--d-2) linear;
}
.topbar.is-stuck { border-bottom-color: var(--line); box-shadow: 0 6px 20px -16px rgb(0 0 0 / 0.3); }
.topbar-in { display: flex; align-items: center; gap: var(--s2); min-height: 64px; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  font-family: var(--f-display);
  font-weight: 800;
  letter-spacing: -0.03em;
  font-size: var(--t-md);
}
.brand:hover { color: var(--ink); }
.brand svg { width: 32px; height: 32px; flex: none; }
.brand em { font-style: normal; color: var(--leaf); }
.brand-on-dark { color: var(--hero-ink); }
.brand-on-dark:hover { color: var(--hero-ink); }
.brand-on-dark em { color: var(--mango); }
.brand-lg svg { width: 44px; height: 44px; }
.brand-lg { font-size: var(--t-lg); gap: 12px; }

/* Logo que se desenha (anel) e brota (folha) */
.logo-anim .logo-anel { stroke-dashoffset: 84; animation: pv-draw 1.2s var(--e-out) 0.15s forwards; }
.logo-anim .logo-folha { transform-origin: 16px 22px; transform-box: view-box; animation: pv-pop 700ms var(--e-spring) 0.6s both; }

#pv-tema .i-lua { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) #pv-tema .i-sol { display: none; }
  :root:not([data-theme='light']) #pv-tema .i-lua { display: block; }
}
:root[data-theme='dark'] #pv-tema .i-sol { display: none; }
:root[data-theme='dark'] #pv-tema .i-lua { display: block; }
#pv-tema svg { transition: transform var(--d-4) var(--e-spring); }
#pv-tema:active svg { transform: rotate(-90deg) scale(0.8); }

.avatar {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--leaf), var(--hero-3));
  color: #fff;
  font-family: var(--f-display);
  font-weight: 700;
  font-size: var(--t-sm);
  text-decoration: none;
  flex: none;
  box-shadow: 0 0 0 3px var(--bg), 0 0 0 4.5px color-mix(in srgb, var(--leaf) 40%, transparent);
  transition: transform var(--d-2) var(--e-spring);
}
.avatar:hover { transform: scale(1.08); color: #fff; }
.avatar-lg { width: 56px; height: 56px; font-size: var(--t-lg); }

/* ---------- Navegacao inferior (celular) ---------- */
.tabbar {
  position: fixed;
  left: var(--s3);
  right: var(--s3);
  bottom: calc(var(--s3) + var(--safe-b));
  z-index: 50;
  border-radius: 24px;
  background: var(--glass);
  backdrop-filter: saturate(1.6) blur(20px);
  border: 1px solid var(--line);
  box-shadow: var(--sh-3);
}
.tabbar ul { display: grid; grid-template-columns: repeat(5, 1fr); height: 64px; padding: 6px; }
.tabbar a {
  position: relative;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 2px;
  text-decoration: none;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 650;
  border-radius: 18px;
  transition: color var(--d-1) linear;
}
.tabbar a svg { width: 23px; height: 23px; position: relative; z-index: 1; transition: transform var(--d-3) var(--e-spring); }
.tabbar a span { position: relative; z-index: 1; }
.tabbar a:hover { color: var(--ink-2); }
.tabbar a:active svg { transform: scale(0.85); }
.tabbar a[aria-current='page'] { color: var(--leaf-strong); }
.tabbar a[aria-current='page'] svg { transform: translateY(-1px) scale(1.06); }
/* A pilula da aba ativa tem nome de transicao: entre uma pagina e outra o
   navegador a desliza da aba antiga para a nova. */
.tabbar a[aria-current='page']::before {
  content: '';
  position: absolute;
  inset: 2px 4px;
  border-radius: 16px;
  background: var(--leaf-soft);
  view-transition-name: pv-aba;
}
@media (min-width: 900px) {
  .tabbar { display: none; }
}

/* ---------- Navegacao lateral (desktop) ---------- */
.sidenav { display: none; }
@media (min-width: 900px) {
  .app-shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); gap: var(--s8); align-items: start; }
  .sidenav { display: grid; gap: var(--s6); position: sticky; top: 84px; }
  .sidenav ul { display: grid; gap: 4px; }
  .sidenav a {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--s3);
    padding: 12px var(--s4);
    border-radius: var(--r-sm);
    text-decoration: none;
    color: var(--muted);
    font-weight: 650;
    transition: color var(--d-1) linear, transform var(--d-2) var(--e-out);
  }
  .sidenav a svg { width: 21px; height: 21px; flex: none; position: relative; z-index: 1; }
  .sidenav a span { position: relative; z-index: 1; }
  .sidenav a:hover { color: var(--ink); transform: translateX(3px); }
  .sidenav a::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: var(--surface-2);
    opacity: 0;
    transition: opacity var(--d-1) linear;
  }
  .sidenav a:hover::before { opacity: 1; }
  .sidenav a[aria-current='page'] { color: var(--on-leaf); }
  .sidenav a[aria-current='page']::before { opacity: 1; background: var(--leaf); box-shadow: var(--sh-leaf); view-transition-name: pv-aba; }
  .sidenav-card { padding: var(--s4); border-radius: var(--r); background: var(--hero); color: var(--hero-ink); display: grid; gap: var(--s2); }
  .sidenav-card p { color: var(--hero-muted); font-size: var(--t-sm); }
}

/* ---------- Conteudo principal ---------- */
main { padding-block: var(--s5) calc(var(--nav-h) + var(--safe-b) + var(--s9)); }
@media (min-width: 900px) {
  main { padding-bottom: var(--s9); }
}

/* ---------- Rodape ---------- */
.foot { margin-top: var(--s9); padding: var(--s6) 0; border-top: 1px solid var(--line); color: var(--muted); font-size: var(--t-sm); display: grid; gap: var(--s2); }
.foot a { color: var(--muted); }
.foot a:hover { color: var(--ink); }

/* ---------- Estado vazio ---------- */
.empty { display: grid; justify-items: center; gap: var(--s4); padding: var(--s9) var(--s5); text-align: center; }
.empty h3 { font-size: var(--t-xl); }
.empty p { color: var(--muted); max-width: 42ch; }

.divider { display: flex; align-items: center; gap: var(--s3); color: var(--muted); font-size: var(--t-sm); }
.divider::before,
.divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* Lista de itens com check verde */
.lista-check { display: grid; gap: var(--s2); }
.lista-check li { display: flex; gap: 10px; align-items: flex-start; }
.lista-check li svg { width: 18px; height: 18px; flex: none; margin-top: 2px; color: var(--leaf); }
.lista-x li svg { color: var(--danger); }
.lista-check-dark li svg { color: var(--mango); }

/* ---------- Confete ---------- */
.confete {
  position: fixed;
  z-index: 100;
  width: 9px;
  height: 14px;
  border-radius: 2px;
  pointer-events: none;
  animation: pv-confete var(--dur, 900ms) var(--e-out) forwards;
}
.confete-redondo { border-radius: 50%; width: 9px; height: 9px; }

/* ---------- Faixa de offline ---------- */
.offline-bar {
  position: fixed;
  left: 50%;
  top: var(--s3);
  translate: -50% 0;
  z-index: 95;
  display: none;
  align-items: center;
  gap: var(--s2);
  padding: 8px var(--s4);
  border-radius: var(--r-full);
  background: var(--warn-soft);
  color: var(--warn);
  font-size: var(--t-sm);
  font-weight: 650;
  box-shadow: var(--sh-2);
}
.offline-bar svg { width: 16px; height: 16px; }
body.is-offline .offline-bar, .offline-bar.is-visible { display: flex; animation: pv-rise var(--d-2) var(--e-out) both; }

/* ---------- Tabela ---------- */
.tabela th,
.tabela td { padding: 11px var(--s4); text-align: left; }
.tabela th { font-size: var(--t-xs); font-weight: 650; color: var(--muted); }
.tabela tbody tr { border-top: 1px solid var(--line); transition: background-color var(--d-1) linear; }
.tabela tbody tr:hover { background: var(--surface-2); }
.tabela .dir { text-align: right; }
.tabela .is-off { opacity: 0.45; }
.tabela-wrap { overflow-x: auto; }
