:root {
  --fundo: #F3ECE1;
  --papel: #FBF7F0;
  --tinta: #1B1815;
  --suave: #6B6158;
  --linha: #E1D6C6;
  --ouro: #B8892F;
  --ouro-claro: #D8AB4E;
  --escuro: #14100F;
  --balao-eu: #1B1815;
  --balao-eu-texto: #F3ECE1;
  --erro: #A33A2B;
  --chip: #EFE4D2;
  --sombra: 0 1px 2px rgba(27, 24, 21, .06), 0 8px 24px rgba(27, 24, 21, .06);
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fundo: #14100F;
    --papel: #1D1815;
    --tinta: #F1E9DD;
    --suave: #A89C8F;
    --linha: #332A24;
    --ouro: #D8AB4E;
    --balao-eu: #2C241F;
    --balao-eu-texto: #F1E9DD;
    --erro: #E0806F;
    --chip: #2A221D;
    --sombra: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--fundo); color: var(--tinta);
  font: 16px/1.55 var(--sans); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--ouro); }

.marca { font-family: var(--serif); font-weight: 500; letter-spacing: -0.01em; }
.marca.pequena { font-size: 21px; }

/* entrada ----------------------------------------------------------------------- */
.entrada { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 16px; }
.cartao { width: 100%; max-width: 420px; background: var(--papel); border: 1px solid var(--linha); border-radius: 18px; padding: 36px 28px; box-shadow: var(--sombra); }
.selo { margin: 0 0 6px; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--ouro); font-weight: 600; }
.cartao h1 { font-size: 46px; line-height: 1.05; margin: 0 0 12px; }
.lead { margin: 0 0 28px; color: var(--suave); font-size: 16px; }
.passo { display: flex; flex-direction: column; gap: 10px; }
label { font-size: 14px; font-weight: 600; }
input[type=email], input[type=text] {
  width: 100%; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--linha);
  background: var(--fundo); color: var(--tinta); font: 17px var(--sans); outline: none;
}
input:focus { border-color: var(--ouro); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ouro) 22%, transparent); }
.codigo { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 26px !important; letter-spacing: .4em; text-align: center; }
.botao {
  margin-top: 4px; padding: 14px 18px; border: 0; border-radius: 12px; background: var(--tinta); color: var(--fundo);
  font-weight: 600; font-size: 16px;
}
.botao:disabled { opacity: .55; cursor: default; }
.botao.secundario { background: transparent; color: var(--tinta); border: 1px solid var(--linha); margin: 0 0 8px; }
.nota { margin: 4px 0 0; font-size: 13.5px; color: var(--suave); }
.link { background: none; border: 0; padding: 0; color: var(--ouro); text-decoration: underline; text-underline-offset: 3px; font-size: inherit; }
.erro { margin: 16px 0 0; padding: 12px 14px; border-radius: 10px; background: color-mix(in srgb, var(--erro) 10%, transparent); color: var(--erro); font-size: 14.5px; }
.rodape-entrada { margin-top: 20px; font-size: 14px; color: var(--suave); }

/* app ----------------------------------------------------------------------------- */
.app { height: 100%; height: 100dvh; display: flex; flex-direction: column; }
.topo {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 8px) 8px 8px; background: color-mix(in srgb, var(--fundo) 92%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--linha);
}
.topo .titulo { flex: 1; display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.topo .sub { font-size: 11.5px; color: var(--suave); letter-spacing: .02em; }
.icone { width: 42px; height: 42px; display: grid; place-items: center; border: 0; background: none; border-radius: 10px; }
.icone:hover { background: var(--chip); }

.rolagem { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.boas-vindas, .mensagens { max-width: 760px; margin: 0 auto; padding: 0 16px; }
.boas-vindas { padding-top: 32px; padding-bottom: 8px; }
.boas-vindas h2 { font-family: var(--serif); font-weight: 500; font-size: 32px; margin: 0 0 8px; }
.boas-vindas p { margin: 0 0 20px; color: var(--suave); }
.sugestoes { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 560px) { .sugestoes { grid-template-columns: 1fr 1fr; } }
.sugestao {
  text-align: left; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--linha); background: var(--papel);
  display: flex; flex-direction: column; gap: 2px;
}
.sugestao:hover { border-color: var(--ouro); }
.sugestao strong { font-weight: 600; font-size: 15px; }
.sugestao span { font-size: 13.5px; color: var(--suave); }

.mensagens { padding-bottom: 24px; display: flex; flex-direction: column; gap: 18px; }
.msg { max-width: 100%; }
.msg.eu { align-self: flex-end; max-width: 85%; background: var(--balao-eu); color: var(--balao-eu-texto); padding: 11px 15px; border-radius: 18px 18px 4px 18px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.ia { align-self: stretch; }
.msg.ia .corpo { font-size: 16.5px; line-height: 1.62; overflow-wrap: anywhere; }
.msg.ia .corpo p { margin: 0 0 12px; }
.msg.ia .corpo p:last-child { margin-bottom: 0; }
.msg.ia .corpo ul, .msg.ia .corpo ol { margin: 0 0 12px; padding-left: 22px; }
.msg.ia .corpo li { margin: 4px 0; }
.msg.ia .corpo blockquote { margin: 0 0 12px; padding: 4px 0 4px 14px; border-left: 3px solid var(--ouro-claro); color: var(--suave); }
.msg.ia .corpo strong { font-weight: 600; }
.msg.ia .assinatura { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-family: var(--serif); font-size: 15px; color: var(--suave); }
.msg.ia .assinatura::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ouro-claro); }
.cit {
  display: inline-flex; align-items: center; gap: 4px; margin: 0 2px; padding: 1px 8px; border-radius: 999px;
  border: 1px solid var(--linha); background: var(--chip); font-size: 13px; line-height: 1.6; vertical-align: 1px;
  color: var(--tinta); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
}
.cit:hover { border-color: var(--ouro); }
.cit .t { color: var(--suave); }
.status { display: flex; align-items: center; gap: 10px; color: var(--suave); font-size: 14.5px; }
.pontos { display: inline-flex; gap: 4px; }
.pontos i { width: 6px; height: 6px; border-radius: 50%; background: var(--ouro-claro); animation: pulsa 1.2s infinite ease-in-out; }
.pontos i:nth-child(2) { animation-delay: .15s; } .pontos i:nth-child(3) { animation-delay: .3s; }
@keyframes pulsa { 0%, 80%, 100% { opacity: .25; transform: scale(.8); } 40% { opacity: 1; transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .pontos i { animation: none; opacity: .7; } }
.acoes { display: flex; gap: 6px; margin-top: 10px; }
.acao { border: 1px solid var(--linha); background: transparent; border-radius: 999px; padding: 4px 12px; font-size: 13px; color: var(--suave); }
.acao[aria-pressed=true] { border-color: var(--ouro); color: var(--tinta); background: var(--chip); }
.msg.falha { color: var(--erro); font-size: 15px; }

.compositor { border-top: 1px solid var(--linha); background: var(--fundo); padding: 10px 12px calc(env(safe-area-inset-bottom) + 8px); }
.compositor form { max-width: 760px; margin: 0 auto; display: flex; align-items: flex-end; gap: 8px; background: var(--papel); border: 1px solid var(--linha); border-radius: 22px; padding: 6px 6px 6px 16px; }
.compositor form:focus-within { border-color: var(--ouro); }
textarea { flex: 1; border: 0; outline: none; resize: none; background: transparent; color: var(--tinta); font: 16px/1.5 var(--sans); padding: 8px 0; max-height: 40vh; }
.enviar { width: 40px; height: 40px; flex: none; border: 0; border-radius: 50%; background: var(--tinta); color: var(--fundo); display: grid; place-items: center; }
.enviar:disabled { opacity: .35; cursor: default; }
.aviso { max-width: 760px; margin: 6px auto 0; text-align: center; font-size: 12px; color: var(--suave); }
.aviso #contador:not(:empty)::after { content: " · "; }

/* gaveta --------------------------------------------------------------------------- */
.gaveta {
  position: fixed; inset: 0 auto 0 0; width: min(320px, 86vw); z-index: 20; background: var(--papel); border-right: 1px solid var(--linha);
  display: flex; flex-direction: column; padding: calc(env(safe-area-inset-top) + 12px) 14px calc(env(safe-area-inset-bottom) + 14px);
  box-shadow: var(--sombra);
}
.gaveta-topo { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.veu { position: fixed; inset: 0; z-index: 15; background: rgba(20, 16, 15, .35); }
.lista { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; margin: 0 -6px; }
.lista button { text-align: left; border: 0; background: none; padding: 10px 10px; border-radius: 10px; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lista button:hover, .lista button[aria-current=true] { background: var(--chip); }
.lista .vazia { padding: 10px; color: var(--suave); font-size: 14px; }
.gaveta-pe { border-top: 1px solid var(--linha); padding-top: 12px; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.quem { margin: 0; font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }

/* balão da citação ------------------------------------------------------------------------ */
.balao {
  position: fixed; z-index: 30; max-width: min(340px, calc(100vw - 32px)); padding: 14px 16px; border-radius: 14px;
  background: var(--escuro); color: #F3ECE1; font-size: 14px; line-height: 1.5; box-shadow: 0 12px 32px rgba(0, 0, 0, .25);
}
.balao strong { display: block; font-family: var(--serif); font-size: 17px; font-weight: 500; margin-bottom: 4px; }
.balao a { color: var(--ouro-claro); }

@media (min-width: 1100px) {
  .gaveta[hidden] { display: flex !important; }
  .app { padding-left: 300px; }
  .gaveta { width: 300px; box-shadow: none; }
  #abrir-gaveta, #fechar-gaveta, .veu { display: none !important; }
}
