:root {
  --bg: #f5f4fc;
  --bg-2: #ecebf8;
  --surface: #ffffff;
  --ink: #241f3a;
  --muted: #6f6a88;
  --faint: #a7a2bd;
  --line: #e7e4f4;
  --green: #16c079;
  --amber: #f5a623;
  --shadow-c: rgba(91, 124, 250, .16);
  --roxo: #5b7cfa;
  --roxo-vivo: #a06bf5;
  --radius: 22px;
  --font: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(900px 500px at 90% -10%, rgba(255, 93, 143, .10), transparent 60%),
    radial-gradient(800px 500px at -5% 5%, rgba(91, 124, 250, .12), transparent 55%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  min-height: 100vh;
}

#confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 50;
}

/* ---- Shell: topo + telas + tabbar (padrão da família DOMÍNIO) ---- */
.topo {
  max-width: 720px; margin: 0 auto; display: flex; align-items: center; gap: 14px;
  padding: calc(14px + env(safe-area-inset-top, 0px)) clamp(18px, 5vw, 40px) 6px;
}
.topo .volta {
  flex: 0 0 auto; width: 40px; height: 40px; display: grid; place-items: center;
  text-decoration: none; font-weight: 800; font-size: 17px; color: var(--muted);
  border-radius: 999px; border: 2px solid var(--line); background: var(--surface);
  transition: color .14s, border-color .14s, transform .12s;
}
.topo .volta:hover { color: var(--ink); border-color: var(--muted); transform: translateX(-2px); }
.marca {
  margin: 0; font-size: 20px; font-weight: 800; letter-spacing: .26em;
  background: linear-gradient(90deg, var(--roxo), var(--roxo-vivo));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

main#view {
  max-width: 720px; margin: 0 auto;
  padding: 14px clamp(18px, 5vw, 40px) calc(120px + env(safe-area-inset-bottom, 0px));
}
/* telas: ficam todas no DOM, o router só troca [hidden] */
.tela[hidden] { display: none; }

.tela-head { margin-bottom: 22px; }
.tela-titulo {
  font-size: clamp(26px, 5.5vw, 34px); line-height: 1.05; letter-spacing: -.03em;
  margin: 0 0 6px; font-weight: 800; text-wrap: balance;
}
.tela-titulo.grande { font-size: clamp(30px, 7vw, 46px); margin-bottom: 12px; }
.tela-titulo .pop {
  background: linear-gradient(90deg, var(--roxo), var(--roxo-vivo));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.tela-sub { margin: 0; color: var(--muted); font-size: 14.5px; font-weight: 500; }
.tela-sub b { color: var(--ink); font-weight: 800; }
.tela-vazio {
  margin: 8px 0 0; padding: 44px 24px; text-align: center;
  color: var(--muted); font-size: 14.5px; font-weight: 600;
  border: 2px dashed var(--line); border-radius: 20px;
}
.tela-vazio b { color: var(--roxo); font-weight: 800; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; align-items: stretch; justify-content: space-around;
  background: rgba(255, 255, 255, .92); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 2px solid var(--line);
  padding: 6px 8px calc(14px + env(safe-area-inset-bottom, 0px));
}
.tabbar button {
  background: none; border: none; color: var(--faint); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px; flex: 1;
  font: inherit; font-size: 10.5px; font-weight: 700; letter-spacing: .04em;
  padding: 4px 0; transition: color .14s;
}
.tabbar button svg { width: 22px; height: 22px; }
.tabbar button.ativa { color: var(--roxo); }
.tabbar button.ativa svg { filter: drop-shadow(0 0 6px rgba(91, 124, 250, .5)); }
.meta-fab {
  flex: 0 0 auto !important; width: 62px; height: 62px; margin-top: -26px;
  border-radius: 50%; border: 3px solid var(--bg) !important;
  background: radial-gradient(circle at 30% 25%, var(--roxo-vivo), var(--roxo)) !important;
  color: #fff !important; display: grid !important; place-items: center;
  box-shadow: 0 0 20px rgba(91, 124, 250, .45), 0 6px 18px -8px rgba(36, 31, 58, .5);
  transition: transform .12s;
}
.meta-fab svg { width: 28px; height: 28px; }
.meta-fab:active { transform: scale(.94); }

/* badge/painel do sync (sync.js injeta fixo em bottom:12px): sobe acima da tabbar */
.ds-badge { bottom: calc(84px + env(safe-area-inset-bottom, 0px)) !important; }
.ds-panel { bottom: calc(124px + env(safe-area-inset-bottom, 0px)) !important; }
body.sheet-aberta .ds-badge, body.sheet-aberta .ds-panel { display: none !important; }

/* ---- Hero da tela Progresso (pílula e título saíram em 2026-09-10; .eyebrow segue em uso nos KPIs) ---- */
.eyebrow {
  display: inline-block;
  font-size: 12px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #fff;
  font-weight: 800;
  margin: 0 0 16px;
  background: linear-gradient(90deg, #ff5d8f, #ff8f3f);
  padding: 6px 14px;
  border-radius: 999px;
  box-shadow: 0 8px 18px -8px rgba(255, 93, 143, .6);
}
.lede {
  color: var(--muted);
  font-size: 16px;
  margin: 6px 0 0;
  max-width: 46ch;
  font-weight: 500;
}

/* ---- Progress panel ---- */
.panel {
  margin-top: 32px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: 0 24px 48px -28px var(--shadow-c), 0 2px 0 rgba(36, 31, 58, .02);
}
.panel-top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px 24px;
}
.field label {
  display: block;
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 8px;
  font-weight: 800;
}
.amount-input {
  display: flex;
  align-items: baseline;
  gap: 6px;
  background: var(--bg);
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 10px 16px;
  transition: border-color .18s, box-shadow .18s;
}
.amount-input:focus-within {
  border-color: #5b7cfa;
  box-shadow: 0 0 0 4px rgba(91, 124, 250, .16);
}
.amount-input .prefix { color: var(--muted); font-size: 20px; font-weight: 800; }
.amount-input .suffix { color: var(--muted); font-size: 15px; font-weight: 700; }
.amount-input input {
  background: transparent;
  border: 0;
  color: var(--ink);
  font-size: 27px;
  font-weight: 800;
  width: 8ch;
  padding: 0;
  outline: none;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
}
.amount-input input::-webkit-outer-spin-button,
.amount-input input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.amount-input input[type=number] { -moz-appearance: textfield; }

.save-row {
  display: flex;
  align-items: stretch;
  gap: 10px;
  flex-wrap: wrap;
}
#saveBtn {
  border: 0;
  border-radius: 16px;
  padding: 0 20px;
  font: inherit;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: .01em;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(90deg, #5b7cfa, #a06bf5);
  box-shadow: 0 10px 22px -10px rgba(91, 124, 250, .7);
  transition: transform .14s, box-shadow .14s, filter .14s;
  white-space: nowrap;
}
#saveBtn:hover { transform: translateY(-2px); filter: saturate(1.1); }
#saveBtn:active { transform: translateY(0); }
#saveBtn:focus-visible { outline: 3px solid rgba(91, 124, 250, .45); outline-offset: 2px; }
#saveBtn.dirty {
  background: linear-gradient(90deg, #ff5d8f, #ff8f3f);
  box-shadow: 0 10px 22px -10px rgba(255, 93, 143, .7);
  animation: nudge 1.4s ease-in-out infinite;
}
@keyframes nudge {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}
.save-status {
  margin-top: 9px;
  font-size: 12.5px;
  font-weight: 600;
  min-height: 1em;
  color: var(--muted);
}
.save-status.ok { color: var(--green); }
.save-status.err { color: #d61f4c; }

.stat { text-align: right; }
.stat .num {
  font-size: 34px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
  line-height: 1;
}
.stat .num #doneCount {
  background: linear-gradient(90deg, #16c079, #37c98b);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.stat .num .sep { color: var(--faint); font-weight: 600; }
.stat .lbl {
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--faint);
  margin-top: 9px;
  font-weight: 800;
}

.next-line {
  margin-top: 24px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 14px;
}
.next-line .caption { color: var(--muted); font-weight: 500; }
.next-line .caption b { color: var(--ink); font-weight: 700; }
.next-line .pct {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(90deg, #ff5d8f, #ff8f3f);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.bar {
  margin-top: 11px;
  height: 14px;
  background: var(--bg-2);
  border-radius: 999px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #5b7cfa, #a06bf5, #ff5d8f);
  background-size: 220% 100%;
  transition: width .7s cubic-bezier(.22, .61, .36, 1);
  position: relative;
  overflow: hidden;
}
.bar-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(45deg, rgba(255, 255, 255, .28) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .28) 50%, rgba(255, 255, 255, .28) 75%, transparent 75%);
  background-size: 22px 22px;
  animation: stripes 1s linear infinite;
}
@keyframes stripes { from { background-position: 0 0; } to { background-position: 22px 0; } }

.all-done {
  margin-top: 18px;
  font-weight: 800;
  font-size: 15px;
  background: linear-gradient(90deg, #16c079, #5b7cfa);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---- Timeline ---- */
.timeline { margin-top: 32px; display: flex; flex-direction: column; gap: 16px; }

.node { position: relative; }
.card {
  --c: #5b7cfa;
  background: var(--surface);
  border-radius: 20px;
  padding: 16px 18px 16px 16px;
  display: flex;
  align-items: center;
  gap: 15px;
  box-shadow: 0 12px 26px -20px rgba(36, 31, 58, .5);
  border: 2px solid var(--line);
  transition: transform .16s, box-shadow .16s, border-color .16s;
}
.card:hover { transform: translateY(-3px) rotate(-.4deg); box-shadow: 0 18px 30px -18px color-mix(in srgb, var(--c) 55%, transparent); }

.badge {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  font-size: 24px;
  background: color-mix(in srgb, var(--c) 14%, #fff);
  border: 2px solid color-mix(in srgb, var(--c) 35%, transparent);
  position: relative;
}
.badge .lvl {
  position: absolute;
  top: -8px;
  right: -8px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--c);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 8px -3px color-mix(in srgb, var(--c) 70%, transparent);
  font-variant-numeric: tabular-nums;
}

.info { flex: 1; min-width: 0; }
.goal {
  font-size: 12px;
  letter-spacing: .02em;
  color: var(--c);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}
.reward {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.01em;
  margin-top: 2px;
}
.reward.placeholder { color: var(--faint); font-style: italic; font-weight: 500; }
.reward a {
  color: inherit;
  text-decoration: none;
  border-bottom: 2px solid color-mix(in srgb, var(--c) 40%, transparent);
  transition: border-color .15s, color .15s;
}
.reward a:hover { color: var(--c); border-color: var(--c); }
.reward a .ext { font-size: 12px; opacity: .7; margin-left: 3px; }

.pill {
  flex-shrink: 0;
  font-size: 10.5px;
  letter-spacing: .06em;
  text-transform: uppercase;
  font-weight: 800;
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
}
.pill.pending { color: var(--faint); background: var(--bg-2); }
.pill.next { color: #fff; background: linear-gradient(90deg, var(--c), color-mix(in srgb, var(--c) 60%, #ff8f3f)); box-shadow: 0 6px 14px -6px color-mix(in srgb, var(--c) 70%, transparent); }
.pill.done { color: #fff; background: linear-gradient(90deg, #16c079, #37c98b); box-shadow: 0 6px 14px -6px rgba(22, 192, 121, .6); }

/* States */
.node.est-resgatada .card { border-color: color-mix(in srgb, #16c079 40%, transparent); }
.node.est-resgatada .badge { background: linear-gradient(135deg, #16c079, #37c98b); border-color: transparent; }
.node.est-resgatada .goal { color: #16c079; }

.node.is-next .card {
  border-color: var(--c);
  box-shadow: 0 16px 30px -16px color-mix(in srgb, var(--c) 60%, transparent);
}
.node.is-next .badge { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

/* ---- Botão de editar no card ---- */
.edit-btn {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  border: 2px solid var(--line);
  background: transparent;
  color: var(--faint);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  transition: color .15s, border-color .15s, background .15s, transform .12s;
}
.edit-btn svg { width: 16px; height: 16px; }
.edit-btn:hover { color: var(--c); border-color: var(--c); background: color-mix(in srgb, var(--c) 8%, transparent); transform: translateY(-1px); }
.edit-btn:focus-visible { outline: 3px solid color-mix(in srgb, var(--c) 45%, transparent); outline-offset: 2px; }

/* ---- Card em edição ---- */
.card-edit { display: block; border-color: var(--c); box-shadow: 0 16px 30px -16px color-mix(in srgb, var(--c) 55%, transparent); }
.card-edit:hover { transform: none; }
.btn-save {
  border: 0;
  border-radius: 14px;
  padding: 11px 20px;
  font: inherit;
  font-weight: 800;
  font-size: 14px;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(90deg, #16c079, #37c98b);
  box-shadow: 0 10px 22px -10px rgba(22, 192, 121, .7);
  transition: transform .14s, filter .14s;
}
.btn-save:hover { transform: translateY(-2px); filter: saturate(1.08); }
.btn-save:focus-visible { outline: 3px solid rgba(22, 192, 121, .45); outline-offset: 2px; }
.btn-cancel {
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 11px 18px;
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  transition: border-color .14s, color .14s;
}
.btn-cancel:hover { border-color: var(--muted); color: var(--ink); }
.btn-cancel:focus-visible { outline: 3px solid var(--line); outline-offset: 2px; }

.btn-delete {
  --c: #e0245e;
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 2px solid color-mix(in srgb, #e0245e 28%, var(--line));
  background: transparent;
  color: #d61f4c;
  border-radius: 14px;
  padding: 10px 15px;
  font: inherit;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  transition: background .14s, border-color .14s, transform .12s;
}
.btn-delete svg { width: 16px; height: 16px; }
.btn-delete:hover { background: #ffeef2; border-color: #e0245e; transform: translateY(-1px); }
.btn-delete:focus-visible { outline: 3px solid rgba(224, 36, 94, .4); outline-offset: 2px; }

/* ---- Indicador de salto (pulo > 10 mil entre metas) ---- */
.gap {
  --c: #5b7cfa;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 18px;
  border: 2px dashed color-mix(in srgb, var(--c) 32%, var(--line));
  border-radius: 18px;
  background: color-mix(in srgb, var(--c) 5%, transparent);
}
.gap-track {
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  gap: 6px;
  max-width: 108px;
  flex-shrink: 0;
}
.gap-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--c) 45%, transparent);
}
.gap-label { display: flex; flex-direction: column; gap: 2px; }
.gap-jump { font-weight: 800; font-size: 13.5px; color: var(--c); }
.gap-steps {
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 700;
}

/* ---- Folha "Adicionar meta": sobe da tabbar, no padrão dos irmãos ---- */
.sheet-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(36, 31, 58, .38); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
  animation: fadeIn .15s ease;
}
.sheet-overlay[hidden] { display: none; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 61;
  max-width: 560px; margin: 0 auto;
  background: var(--surface); border: 2px solid var(--line); border-bottom: none;
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -20px 50px -24px rgba(36, 31, 58, .45);
  padding: 10px clamp(16px, 5vw, 22px) calc(22px + env(safe-area-inset-bottom, 0px));
  max-height: 88vh; overflow-y: auto;
  animation: sheetIn .22s cubic-bezier(.2, .8, .3, 1) both;
}
.sheet[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes sheetIn { from { transform: translateY(100%); } }
.sheet-alca { width: 42px; height: 4px; border-radius: 999px; background: var(--line); margin: 0 auto 12px; }
.sheet-topo { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.sheet-topo h2 { margin: 0; font-size: 19px; font-weight: 800; letter-spacing: -.01em; }
.sheet-fechar {
  margin-left: auto; width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: 999px; border: 2px solid var(--line); background: var(--surface);
  color: var(--muted); font: inherit; font-size: 14px; font-weight: 800; cursor: pointer;
  transition: color .14s, border-color .14s;
}
.sheet-fechar:hover { color: var(--ink); border-color: var(--muted); }

.add-form { margin: 0; }
.add-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
}
.ff.ff-emoji { grid-column: auto; }
.ff label {
  display: block;
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 7px;
  font-weight: 800;
}
.ff input {
  width: 100%;
  background: var(--bg);
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 11px 14px;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  outline: none;
  transition: border-color .16s, box-shadow .16s;
}
.ff input::placeholder { color: var(--faint); font-weight: 500; }
.ff input:focus {
  border-color: #5b7cfa;
  box-shadow: 0 0 0 4px rgba(91, 124, 250, .16);
}
.add-actions {
  margin-top: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
#addBtn {
  border: 0;
  border-radius: 15px;
  padding: 12px 22px;
  font: inherit;
  font-weight: 800;
  font-size: 14px;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(90deg, #16c079, #37c98b);
  box-shadow: 0 10px 22px -10px rgba(22, 192, 121, .7);
  transition: transform .14s, filter .14s;
}
#addBtn:hover { transform: translateY(-2px); filter: saturate(1.08); }
#addBtn:active { transform: translateY(0); }
#addBtn:focus-visible { outline: 3px solid rgba(22, 192, 121, .45); outline-offset: 2px; }

@media (max-width: 480px) {
  .add-grid { grid-template-columns: 1fr; }
}

/* ---- Campo de emoji + seletor ---- */
.emoji-field { display: inline-flex; }
.emoji-button {
  width: auto;
  min-width: 96px;
  padding: 0 20px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 2px solid var(--line);
  background: var(--bg);
  border-radius: 14px;
  font-family: inherit;
  font-size: 24px;
  line-height: 1;
  color: var(--ink);
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .12s;
}
.emoji-button::after {
  content: "▾";
  font-size: 12px;
  color: var(--faint);
}
.emoji-button:hover { border-color: #5b7cfa; background: rgba(91, 124, 250, .08); transform: translateY(-1px); }
.emoji-button:hover::after { color: #5b7cfa; }
.emoji-button:focus-visible { outline: 3px solid rgba(91, 124, 250, .4); outline-offset: 2px; }

.emoji-pop {
  position: fixed;
  z-index: 200;
  width: 350px;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 24px 50px -18px rgba(36, 31, 58, .45);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
/* garante que o atributo [hidden] realmente esconda (display:flex acima o venceria) */
.emoji-pop[hidden] { display: none; }
.emoji-search {
  width: 100%;
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 9px 12px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  background: var(--bg);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.emoji-search:focus { border-color: #5b7cfa; box-shadow: 0 0 0 3px rgba(91, 124, 250, .15); }
.emoji-search::placeholder { color: var(--faint); font-weight: 500; }

.emoji-tabs {
  display: flex;
  gap: 3px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
}
.emoji-tab {
  flex-shrink: 0;
  border: 0;
  background: transparent;
  border-radius: 10px;
  padding: 6px 8px;
  font-size: 17px;
  cursor: pointer;
  opacity: .55;
  transition: opacity .14s, background .14s;
}
.emoji-tab:hover { opacity: 1; background: var(--bg-2); }
.emoji-tab.active { opacity: 1; background: rgba(91, 124, 250, .14); box-shadow: inset 0 0 0 2px rgba(91, 124, 250, .35); }

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  max-height: 208px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-gutter: stable; /* reserva espaço da barra p/ não cortar a última coluna */
}
.emoji-cell {
  border: 0;
  background: transparent;
  border-radius: 10px;
  aspect-ratio: 1;
  font-size: 21px;
  line-height: 1;
  cursor: pointer;
  transition: background .12s, transform .1s;
}
.emoji-cell:hover { background: var(--bg-2); transform: scale(1.15); }
.emoji-cell:focus-visible { outline: 2px solid rgba(91, 124, 250, .5); outline-offset: 1px; }
.emoji-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--faint);
  font-size: 13px;
  font-weight: 600;
  padding: 24px 0;
}

/* ---- Tela Config: linhas de ação ---- */
.cfg-card {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 24px 48px -32px var(--shadow-c);
}
.cfg-row {
  width: 100%; display: flex; align-items: center; gap: 14px;
  padding: 16px 18px; background: none; border: 0; border-top: 2px solid var(--line);
  font: inherit; color: var(--ink); text-align: left; cursor: pointer;
  transition: background .14s;
}
.cfg-row:first-child { border-top: 0; }
.cfg-row:hover { background: var(--bg-2); }
.cfg-row:focus-visible { outline: 3px solid rgba(91, 124, 250, .4); outline-offset: -3px; }
.cfg-ico { font-size: 22px; line-height: 1; flex: 0 0 auto; }
.cfg-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cfg-txt b { font-size: 15px; font-weight: 800; }
.cfg-txt small { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.cfg-txt code {
  background: var(--bg-2); color: var(--muted);
  padding: 1px 5px; border-radius: 5px; font-size: 11.5px;
}
.cfg-seta { color: var(--faint); font-size: 22px; font-weight: 700; flex: 0 0 auto; }

.error {
  margin: 0 0 22px;
  background: #fff0f3;
  border: 2px solid #ffc2d0;
  color: #b3123b;
  border-radius: 16px;
  padding: 18px 20px;
  font-size: 14px;
  font-weight: 500;
}
.error code {
  background: #ffe1e8;
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 13px;
}

.footnote {
  margin-top: 28px;
  text-align: center;
  color: var(--faint);
  font-size: 12.5px;
  font-weight: 500;
}
.footnote code {
  background: var(--bg-2);
  color: var(--muted);
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 12px;
}

@media (max-width: 480px) {
  .card { flex-wrap: wrap; }
  .info { flex-basis: calc(100% - 67px); }
  .pill, .btn-resgatar { margin-left: 67px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  #confetti { display: none; }
}

/* ---- Lembrete: só quando a última atualização passou do prazo ---- */
.lembrete {
  width: 100%; display: flex; align-items: center; gap: 14px; text-align: left;
  margin: 0 0 18px; padding: 14px 16px; border-radius: 18px; cursor: pointer;
  font: inherit; color: var(--ink);
  background: linear-gradient(135deg, #fff4df, #ffe9c2);
  border: 2px solid rgba(245, 166, 35, .45);
  box-shadow: 0 14px 28px -20px rgba(245, 166, 35, .8);
  transition: transform .14s, box-shadow .14s;
}
.lembrete[hidden] { display: none; } /* a classe tem display:flex, que venceria o [hidden] do navegador */
.lembrete:hover { transform: translateY(-2px); }
.lembrete:focus-visible { outline: 3px solid rgba(245, 166, 35, .5); outline-offset: 2px; }
.lembrete-ico { font-size: 24px; line-height: 1; flex: 0 0 auto; }
.lembrete-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.lembrete-txt b { font-size: 14.5px; font-weight: 800; line-height: 1.3; }
.lembrete-txt small { color: #7a5a10; font-size: 12.5px; font-weight: 600; }
.lembrete-seta { color: #b9820f; font-size: 22px; font-weight: 700; flex: 0 0 auto; }

/* ---- Início: valor atual só leitura (a edição mora na Config) ---- */
.current-view { display: flex; align-items: baseline; gap: 6px; }
.current-view .prefix { color: var(--muted); font-size: 20px; font-weight: 800; }
.current-view .suffix { color: var(--muted); font-size: 15px; font-weight: 700; }
.current-view #currentView { font-size: 34px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
#currentQuando { min-height: 0; color: var(--faint); font-size: 12px; font-weight: 600; }
.stat .lbl.disp { color: #b9820f; margin-top: 4px; text-transform: none; letter-spacing: 0; font-size: 12.5px; }

/* ---- Card: resgate ---- */
.quando { color: var(--faint); font-size: 12px; font-weight: 600; margin-top: 2px; }
.btn-resgatar {
  flex-shrink: 0; border: 0; border-radius: 999px; padding: 10px 18px; cursor: pointer;
  font: inherit; font-size: 12.5px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: #fff;
  background: linear-gradient(90deg, var(--c), color-mix(in srgb, var(--c) 55%, #ff8f3f));
  box-shadow: 0 10px 22px -10px color-mix(in srgb, var(--c) 80%, transparent);
  animation: pulse 1.6s ease-in-out infinite;
  transition: transform .14s, filter .14s;
}
.btn-resgatar:hover { transform: translateY(-2px); filter: saturate(1.1); animation: none; }
.btn-resgatar:focus-visible { outline: 3px solid color-mix(in srgb, var(--c) 45%, transparent); outline-offset: 2px; }
.node.est-disponivel .card { border-color: color-mix(in srgb, var(--c) 55%, transparent); box-shadow: 0 18px 34px -22px color-mix(in srgb, var(--c) 70%, transparent); }
.node.est-disponivel .badge { animation: pulse 1.6s ease-in-out infinite; }

/* ---- Gráficos ---- */
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--surface); border: 2px solid var(--line); border-radius: 18px; padding: 14px 14px 12px; min-width: 0; }
.kpi-l { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); font-weight: 800; }
.kpi-v { font-size: clamp(16px, 4.6vw, 22px); font-weight: 800; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-s { color: var(--muted); font-size: 11.5px; font-weight: 600; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi.up .kpi-v { color: #0f9a60; }
.kpi.down .kpi-v { color: #d61f4c; }
.viz-card {
  background: var(--surface); border-radius: var(--radius); padding: 18px 18px 14px; margin-bottom: 14px;
  box-shadow: 0 24px 48px -28px var(--shadow-c), 0 2px 0 rgba(36, 31, 58, .02);
}
.viz-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.viz-head h3 { margin: 0; font-size: 15px; font-weight: 800; }
.viz-sub { color: var(--faint); font-size: 12px; font-weight: 600; }
.viz-host { width: 100%; }
.viz-svg { display: block; width: 100%; height: auto; font-family: var(--font); touch-action: pan-y; }
.viz-svg text { font-variant-numeric: tabular-nums; }
.viz-tip {
  position: fixed; z-index: 60; pointer-events: none;
  background: #241f3a; color: #fff; border-radius: 12px; padding: 8px 12px;
  display: flex; flex-direction: column; gap: 1px; font-size: 12px; font-weight: 600;
  box-shadow: 0 12px 28px -12px rgba(36, 31, 58, .7);
}
.viz-tip[hidden] { display: none; }
.viz-tip b { font-size: 14px; font-weight: 800; font-variant-numeric: tabular-nums; }
.viz-tip span { color: #cfcbe6; }
.viz-tip small { font-size: 11.5px; color: #cfcbe6; }
.viz-tip small.up { color: #6fe3b1; }
.viz-tip small.down { color: #ff8fae; }
.tabela-wrap { overflow-x: auto; }
.registros { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.registros th { text-align: left; font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); font-weight: 800; padding: 6px 8px; border-bottom: 2px solid var(--line); }
.registros td { padding: 9px 8px; border-bottom: 1px solid var(--line); font-weight: 600; }
.registros tr:last-child td { border-bottom: 0; }
.registros .num { text-align: right; font-variant-numeric: tabular-nums; }
.registros th:not(:first-child) { text-align: right; }
.registros .muted { color: var(--faint); }
.registros .up { color: #0f9a60; }
.registros .down { color: #d61f4c; }
.registros[hidden] { display: none; }

/* ---- Conquistas: sala de troféus ---- */
.trofeus { display: flex; flex-direction: column; gap: 12px; }
.trofeu {
  --c: #16c079;
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border-radius: 20px; padding: 14px 16px;
  border: 2px solid color-mix(in srgb, var(--c) 35%, transparent);
  box-shadow: 0 14px 28px -22px color-mix(in srgb, var(--c) 70%, transparent);
  transition: transform .16s, box-shadow .16s;
}
.trofeu:hover { transform: translateY(-3px) rotate(.4deg); box-shadow: 0 18px 30px -18px color-mix(in srgb, var(--c) 60%, transparent); }
.trofeu-emoji {
  position: relative; flex-shrink: 0; width: 60px; height: 60px; border-radius: 18px; display: grid; place-items: center; font-size: 30px;
  background: radial-gradient(circle at 30% 25%, color-mix(in srgb, var(--c) 30%, #fff), color-mix(in srgb, var(--c) 10%, #fff));
  border: 2px solid color-mix(in srgb, var(--c) 40%, transparent);
}
.trofeu-emoji .lvl {
  position: absolute; top: -8px; right: -8px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px;
  background: var(--c); color: #fff; font-size: 11px; font-weight: 800; display: grid; place-items: center; font-variant-numeric: tabular-nums;
}
.trofeu-info { flex: 1; min-width: 0; }
.trofeu-nome { font-size: 17px; font-weight: 800; letter-spacing: -.01em; }
.trofeu-nome.placeholder { color: var(--faint); font-style: italic; font-weight: 500; }
.trofeu-nome a { color: inherit; text-decoration: none; border-bottom: 2px solid color-mix(in srgb, var(--c) 40%, transparent); }
.trofeu-nome a .ext { font-size: 12px; opacity: .7; margin-left: 3px; }
.trofeu-meta { color: var(--muted); font-size: 12.5px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.trofeu-selo { flex-shrink: 0; font-size: 22px; filter: drop-shadow(0 4px 8px rgba(22, 192, 121, .45)); }

/* ---- Config: valor + lembrete ---- */
.panel.cfg-valor { margin-top: 0; margin-bottom: 14px; }
.cfg-quando { margin: 10px 0 0; color: var(--muted); font-size: 13px; font-weight: 600; }
.cfg-card + .cfg-card { margin-top: 14px; }
.cfg-row-select { cursor: pointer; }
.cfg-select {
  flex: 0 0 auto; font: inherit; font-size: 13px; font-weight: 700; color: var(--ink);
  background: var(--bg); border: 2px solid var(--line); border-radius: 12px; padding: 8px 10px; max-width: 46%;
}
.cfg-select:focus-visible { outline: 3px solid rgba(91, 124, 250, .4); outline-offset: 1px; }
.status-link { color: #b9820f; font-weight: 800; text-decoration: none; border-bottom: 2px solid rgba(185, 130, 15, .4); }
.status-link:hover { border-color: #b9820f; }

@media (max-width: 480px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi:first-child { grid-column: 1 / -1; }
}

/* ---- Bloco do avatar (humor) ----
 * O avatar aparece da cintura pra cima com a cabeça saindo do topo do bloco: a figura
 * (.humor-fig) começa --fig-top acima do card e corta só embaixo (overflow hidden), a
 * imagem fica ancorada no topo dela. Abrir só aumenta a altura do card — nada se move,
 * o resto do shape vai aparecendo. Cores e ícone por data-humor. */
.humor {
  --fig-top: 34px;
  --img-h: 372px;             /* altura da imagem inteira */
  --h: 186px;                 /* fechado: até o cós do shorts */
  --h-aberto: calc(var(--img-h) - var(--fig-top) + 6px);
  --tinta: #6f6a88; --fundo-1: #efeef8; --fundo-2: #e4e2f3;
  position: relative; display: grid; grid-template-columns: 54% 1fr; align-items: center;
  width: 100%; height: var(--h); margin: calc(20px + var(--fig-top)) 0 0; padding: 18px 18px 18px 0;
  border: 0; border-radius: 26px; cursor: pointer; text-align: left; font: inherit; color: var(--ink);
  background: linear-gradient(135deg, var(--fundo-1), var(--fundo-2));
  box-shadow: 0 22px 44px -28px var(--shadow-c), inset 0 1px 0 rgba(255, 255, 255, .7);
  transition: height .5s cubic-bezier(.22, .61, .36, 1), background .4s;
  -webkit-tap-highlight-color: transparent;
}
.humor:focus-visible { outline: 3px solid rgba(91, 124, 250, .45); outline-offset: 3px; }
.humor.aberto { height: var(--h-aberto); }
.humor-fig {
  position: absolute; left: 0; top: calc(-1 * var(--fig-top)); bottom: 0; width: 56%;
  overflow: hidden; border-radius: 0 0 0 26px; pointer-events: none;
}
.humor-fig img {
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  height: var(--img-h); width: auto; max-width: none;
  filter: drop-shadow(0 14px 18px rgba(36, 31, 58, .28));
  transition: opacity .25s;
}
.humor-fig img.trocando { opacity: 0; }
.humor-txt { grid-column: 2; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; z-index: 1; padding-left: 8px; }
.humor-ico {
  width: 46px; height: 46px; display: grid; place-items: center; margin-bottom: 8px;
  border-radius: 14px; background: rgba(255, 255, 255, .78); color: var(--tinta);
  box-shadow: 0 8px 18px -10px rgba(36, 31, 58, .35);
}
.humor-ico svg { width: 26px; height: 26px; }
.humor-txt b { font-size: 21px; font-weight: 800; line-height: 1.1; letter-spacing: -.02em; text-wrap: balance; }
.humor-txt small { font-size: 13px; font-weight: 600; color: var(--muted); line-height: 1.35; }
.humor-extra {
  display: none; margin-top: 8px; padding-top: 8px; border-top: 1px solid rgba(36, 31, 58, .1);
  color: var(--ink) !important;
}
.humor.aberto .humor-extra { display: block; }
.humor-extra b { color: var(--tinta); font-weight: 800; }
.humor-cta {
  display: inline-block; margin-top: 8px; padding: 7px 12px; border: 0; border-radius: 999px;
  font: inherit; font-size: 12px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
  color: #fff; background: var(--tinta); cursor: pointer;
}
.humor-seta {
  position: absolute; right: 12px; bottom: 10px; width: 22px; height: 22px; color: var(--tinta); opacity: .55;
  transition: transform .4s;
}
.humor-seta svg { width: 22px; height: 22px; }
.humor.aberto .humor-seta { transform: rotate(180deg); }

/* paleta por humor (mesmo espírito do concept) */
.humor[data-humor="waiting"] { --tinta: #7a6cf0; --fundo-1: #ece9fb; --fundo-2: #dcd8f6; }
.humor[data-humor="happy"]   { --tinta: #16c079; --fundo-1: #e3f7ec; --fundo-2: #cfeedd; }
.humor[data-humor="worried"] { --tinta: #e0405f; --fundo-1: #fde5ea; --fundo-2: #f9d4dc; }
.humor[data-humor="won"]     { --tinta: #c98a05; --fundo-1: #fff1c2; --fundo-2: #ffe08a; }
.humor[data-humor="won"] .humor-ico { color: #b9820f; }
.humor[data-humor="won"]::before {
  /* chuva de dourado atrás do texto */
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background:
    radial-gradient(circle at 78% 18%, rgba(255, 255, 255, .55) 0 3px, transparent 4px),
    radial-gradient(circle at 92% 62%, rgba(255, 255, 255, .5) 0 2px, transparent 3px),
    radial-gradient(circle at 66% 82%, rgba(255, 255, 255, .45) 0 2.5px, transparent 3.5px),
    radial-gradient(circle at 60% 30%, rgba(255, 190, 40, .55) 0 2px, transparent 3px),
    radial-gradient(circle at 86% 40%, rgba(255, 170, 20, .5) 0 3px, transparent 4px);
}
.humor[data-humor="won"] .humor-txt b { color: #7a5a10; }

@media (max-width: 480px) {
  .humor { --img-h: 330px; --h: 176px; grid-template-columns: 55% 1fr; padding-right: 14px; }
  .humor-fig { width: 54%; }
  .humor-txt b { font-size: 19px; }
  .humor-txt small { font-size: 12.5px; }
}
@media (prefers-reduced-motion: reduce) {
  .humor, .humor-seta, .humor-fig img { transition: none; }
}

/* ---- Painel "Já guardei": duas colunas fixas (valor | contador), como no concept.
 * Antes era flex com wrap — no iPhone o rótulo "Recompensas resgatadas" não cabia ao lado
 * do valor e o contador caía pra linha de baixo, deixando o painel alto e quebrado. ---- */
.tela[data-tela="inicio"] .panel { margin-top: 22px; }
.tela[data-tela="inicio"] .panel-top {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 8px 18px;
}
.tela[data-tela="inicio"] .stat { text-align: right; justify-self: end; }
.tela[data-tela="inicio"] .stat .lbl { max-width: 13ch; margin-left: auto; line-height: 1.3; text-wrap: balance; }
.tela[data-tela="inicio"] .stat .lbl.disp { max-width: 16ch; }
.tela[data-tela="inicio"] .next-line { align-items: flex-start; margin-top: 20px; }
.tela[data-tela="inicio"] .next-line .pct { flex: 0 0 auto; }
@media (max-width: 480px) {
  .tela[data-tela="inicio"] .panel { padding: 20px 20px 22px; }
  .tela[data-tela="inicio"] .current-view #currentView { font-size: 30px; }
  .tela[data-tela="inicio"] .stat .num { font-size: 30px; }
  .tela[data-tela="inicio"] .stat .lbl { font-size: 10.5px; margin-top: 7px; }
  .tela[data-tela="inicio"] .next-line { font-size: 13.5px; margin-top: 16px; }
  .tela[data-tela="inicio"] .bar { height: 12px; margin-top: 9px; }
}
