:root {
  --preto: #000;
  --texto: #EDEBE6;
  --apagado: #8E8C88;
  --fraco: #55534F;
  --linha: #1D1D1D;
  --pilula: #161616;
  --alerta: #F2B8A0;
  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;
  --sans: "Onest", -apple-system, "Segoe UI", system-ui, sans-serif;
  --topo: env(safe-area-inset-top, 0px);
  --base: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--preto); color: var(--texto); }
body { font: 400 16px/1.45 var(--sans); overscroll-behavior: none; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--texto); outline-offset: 2px; }

#app { position: fixed; inset: 0; display: flex; flex-direction: column; max-width: 560px; margin: 0 auto; }

/* topo */
.topo { padding: calc(var(--topo) + 14px) 20px 6px; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.marca { margin: 0; font: italic 500 30px/1 var(--serif); letter-spacing: -0.01em; }
.topo-sub { margin: 0; color: var(--apagado); font-size: 13px; text-align: right; }

/* telas */
.tela { display: none; flex: 1; min-height: 0; }
.tela.ativa { display: flex; flex-direction: column; }
.rolagem { flex: 1; overflow-y: auto; padding: 8px 20px 24px; -webkit-overflow-scrolling: touch; }
#tela-conversa .feed { flex: 1; overflow-y: auto; padding: 12px 20px 16px; display: flex; flex-direction: column; gap: 18px; }
body:not(.na-conversa) .entrada { display: none; }

/* conversa */
.msg { max-width: 88%; }
.msg.tomy { align-self: flex-start; font: italic 400 21px/1.35 var(--serif); letter-spacing: -0.005em; }
.msg.eu { align-self: flex-end; background: var(--pilula); padding: 10px 14px; border-radius: 20px 20px 6px 20px; font-size: 16px; }
.msg.eu .audio-tag { color: var(--apagado); font-size: 13px; display: block; }
.msg .hora { display: block; color: var(--fraco); font: 400 11px/1 var(--sans); margin-top: 6px; font-style: normal; }
.msg.eu .hora { text-align: right; }
.recibo { margin-top: 10px; border-left: 2px solid var(--texto); padding: 2px 0 2px 12px; font: 400 15px/1.5 var(--sans); font-style: normal; }
.recibo b { font-weight: 600; font-variant-numeric: tabular-nums; }
.recibo span { color: var(--apagado); }
.desfazer { background: none; border: 0; padding: 6px 0 0; color: var(--apagado); font: 400 13px var(--sans); text-decoration: underline; text-underline-offset: 3px; }
.pensando { color: var(--apagado); }
.pensando::after { content: "…"; animation: pontos 1.2s steps(4) infinite; display: inline-block; width: 1.2em; overflow: hidden; vertical-align: bottom; }
@keyframes pontos { from { width: 0 } to { width: 1.2em } }
.sugestoes { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; font: 400 14px var(--sans); font-style: normal; }
.sugestoes button { background: none; border: 1px solid var(--linha); border-radius: 999px; padding: 7px 12px; color: var(--apagado); }

/* entrada */
.entrada { display: flex; align-items: flex-end; gap: 10px; padding: 8px 14px 10px; position: relative; }
.caixa { flex: 1; display: flex; align-items: center; background: var(--pilula); border-radius: 26px; min-height: 52px; padding: 0 6px 0 18px; }
.caixa { padding-left: 4px; }
.foto { width: 44px; height: 44px; display: grid; place-items: center; color: var(--apagado); flex: none; cursor: pointer; }
.foto input { display: none; }
.alternar { align-items: center; cursor: pointer; }
.alternar input { appearance: none; -webkit-appearance: none; width: 46px; height: 28px; border-radius: 14px; background: var(--linha); position: relative; margin: 0; flex: none; transition: background .15s; }
.alternar input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--apagado); transition: transform .15s, background .15s; }
.alternar input:checked { background: var(--texto); }
.alternar input:checked::after { transform: translateX(18px); background: #000; }
.msg.eu img { display: block; max-width: 180px; border-radius: 12px; margin-bottom: 6px; }
.caixa input { flex: 1; min-width: 0; border: 0; background: none; outline: 0; font-size: 17px; padding: 14px 0; }
.caixa input::placeholder { color: var(--fraco); }
.enviar[hidden] { display: none; }
.enviar { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--texto); color: #000; display: grid; place-items: center; }
.mic { width: 64px; height: 64px; flex: none; border-radius: 50%; border: 0; background: var(--texto); color: #000; display: grid; place-items: center; transition: transform .15s ease; }
.mic:active { transform: scale(.94); }
.mic.gravando { background: var(--alerta); animation: pulso 1.4s ease-in-out infinite; }
@keyframes pulso { 0%,100% { box-shadow: 0 0 0 0 rgba(242,184,160,.45) } 50% { box-shadow: 0 0 0 14px rgba(242,184,160,0) } }
.gravando { position: absolute; left: 14px; right: 88px; bottom: 10px; height: 52px; background: var(--pilula); border-radius: 26px; display: flex; align-items: center; gap: 10px; padding: 0 16px; z-index: 2; font-variant-numeric: tabular-nums; }
.gravando[hidden] { display: none; }
.gravando .ponto { width: 9px; height: 9px; border-radius: 50%; background: var(--alerta); }
.grav-dica { color: var(--apagado); font-size: 13px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cancelar { background: none; border: 0; color: var(--apagado); font-size: 14px; padding: 8px 0; }

/* abas */
.abas { display: flex; border-top: 1px solid var(--linha); padding: 0 8px var(--base); }
.aba { flex: 1; background: none; border: 0; padding: 14px 0 12px; color: var(--fraco); font: 500 14px var(--sans); }
.aba.ativa { color: var(--texto); }

/* gastos */
.mes { display: flex; align-items: center; justify-content: space-between; color: var(--apagado); font-size: 15px; margin: 4px 0 18px; }
.mes-seta { background: none; border: 0; font-size: 26px; line-height: 1; padding: 4px 14px; color: var(--apagado); }
.total { font: 400 64px/1 var(--serif); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.moeda { font-size: 24px; vertical-align: 28px; margin-right: 6px; color: var(--apagado); letter-spacing: 0; }
.total-legenda { color: var(--apagado); margin: 10px 0 26px; font-size: 14px; }
.categorias { list-style: none; margin: 0 0 30px; padding: 0; display: grid; gap: 14px; }
.cat { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-size: 15px; }
.cat .valor { font-variant-numeric: tabular-nums; }
.cat .barra { grid-column: 1 / -1; height: 4px; background: var(--linha); border-radius: 2px; overflow: hidden; }
.cat .barra i { display: block; height: 100%; background: var(--fraco); border-radius: 2px; }
.cat:first-child .barra i { background: var(--texto); }
.secao { font: 500 13px/1 var(--sans); color: var(--apagado); margin: 26px 0 10px; letter-spacing: 0.01em; }
.lista { list-style: none; margin: 0; padding: 0; }
.item { display: flex; align-items: center; gap: 14px; padding: 13px 0; border-bottom: 1px solid var(--linha); }
.item .corpo { flex: 1; min-width: 0; }
.item .titulo { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .meta { display: block; color: var(--apagado); font-size: 13px; margin-top: 2px; }
.item .valor { font-variant-numeric: tabular-nums; white-space: nowrap; }
.item .valor.entra { color: var(--apagado); }
.item button.corpo { background: none; border: 0; padding: 0; text-align: left; }
.vazio { color: var(--apagado); font: italic 400 18px/1.4 var(--serif); padding: 10px 0 4px; }

/* lembretes */
.check { width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--fraco); background: none; flex: none; padding: 0; display: grid; place-items: center; }
.check.feito { background: var(--texto); border-color: var(--texto); }
.check.feito::after { content: ""; width: 6px; height: 11px; border: solid #000; border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-1px, -1px); }
.item.feito .titulo { color: var(--fraco); text-decoration: line-through; }
.quando-dia { font: 400 12px/1.1 var(--sans); color: var(--apagado); width: 44px; flex: none; text-align: center; }
.quando-dia b { display: block; font: 400 24px/1 var(--serif); color: var(--texto); }
.item.hoje .quando-dia b { font-style: italic; }
.passados summary { color: var(--apagado); font-size: 14px; margin: 26px 0 8px; cursor: pointer; }

/* eu */
.bloco { margin-bottom: 18px; }
.voz { font: italic 400 20px/1.4 var(--serif); margin: 0 0 16px; }
.nota { color: var(--apagado); font-size: 14px; margin: 10px 0; }
.fatos { list-style: none; padding: 0; margin: 14px 0; }
.fatos li { display: flex; gap: 10px; align-items: baseline; padding: 9px 0; border-bottom: 1px solid var(--linha); font-size: 15px; }
.fatos li span { flex: 1; }
.fatos li button { background: none; border: 0; color: var(--fraco); font-size: 13px; }
.botao { display: block; width: 100%; text-align: center; background: var(--texto); color: #000; border: 0; border-radius: 14px; padding: 15px; font-weight: 500; margin: 10px 0; }
.botao.fraco { background: var(--pilula); color: var(--texto); }
.botao:disabled { opacity: .45; }
.arquivo input { display: none; }
.campo { display: block; margin: 14px 0 4px; }
.campo span { display: block; color: var(--apagado); font-size: 13px; margin-bottom: 6px; }
.campo input, .campo select { width: 100%; background: var(--pilula); border: 1px solid var(--linha); border-radius: 12px; padding: 13px 14px; font-size: 16px; outline: 0; }
.linha-status { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--linha); font-size: 15px; }
.linha-status b { font-weight: 500; color: var(--apagado); white-space: nowrap; }
.linha-status b.ok { color: var(--texto); }

/* folha (bottom sheet) */
.folha { position: fixed; inset: 0; z-index: 20; }
.folha[hidden] { display: none; }
.folha-fundo { position: absolute; inset: 0; background: rgba(0,0,0,.7); }
.folha-corpo { position: absolute; left: 0; right: 0; bottom: 0; max-width: 560px; margin: 0 auto; background: #0D0D0D; border-top: 1px solid var(--linha); border-radius: 22px 22px 0 0; padding: 22px 20px calc(var(--base) + 18px); animation: sobe .22s ease-out; }
@keyframes sobe { from { transform: translateY(40px); opacity: 0 } }
.folha-corpo h3 { margin: 0 0 4px; font: italic 400 24px/1.2 var(--serif); }
.folha-corpo .linha-botoes { display: flex; gap: 10px; }
.folha-corpo .linha-botoes .botao { flex: 1; }
.perigo { color: var(--alerta) !important; }

.aviso { position: fixed; left: 50%; top: calc(var(--topo) + 12px); transform: translateX(-50%); background: var(--texto); color: #000; padding: 10px 16px; border-radius: 999px; font-size: 14px; font-weight: 500; z-index: 30; max-width: calc(100% - 32px); text-align: center; }
.aviso[hidden] { display: none; }

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