:root {
  color-scheme: light dark;
  --bg: #0d0d0f;
  --fg: #f2f0ea;
  --accent: #d4af37;
  --card: #17171a;
  --muted: #9a978d;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--fg);
  height: 100vh;
}

.hidden { display: none !important; }

.screen { height: 100vh; display: flex; align-items: center; justify-content: center; }

.card {
  background: var(--card);
  border: 1px solid #2a2a2e;
  border-radius: 12px;
  padding: 2rem;
  max-width: 420px;
}

/* Centralizar SÓ o card de login (30/jul). Antes o `text-align: center` vivia
   no `.card` global, e como a grade de Referências/Treino/Decisões cria os
   cards com a MESMA classe, todo texto de card nascia centralizado — o Felipe
   pediu alinhamento à esquerda várias vezes e a causa era esta linha, não o
   CSS de cada tela. Login continua centralizado; conteúdo de app, nunca. */
.screen .card { text-align: center; }

/* Nav única no topo do chat (26/jul): a tela do chat era 100vh cheia, então
   pôr a barra de navegação acima empurrava tudo e criava scroll na página.
   Agora o body é uma coluna (nav + app), e o app ocupa o que sobra. */
body { display: flex; flex-direction: column; }
#ares-nav { flex-shrink: 0; }
/* #app herda .screen (que centraliza pra tela de login). No chat isso deixava
   o sidebar flutuando no meio em vez de esticar a coluna inteira. */
#app { display: flex; flex-direction: row; flex: 1; height: auto; min-height: 0;
       align-items: stretch; justify-content: flex-start; }
#app > #sidebar, #app > #main-panel { height: auto; }

#sidebar {
  width: 220px;
  flex-shrink: 0;
  border-right: 1px solid #2a2a2e;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 1rem;
  gap: 0.75rem;
  overflow-y: auto;
}

#new-conversation {
  width: 100%;
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 0.5rem;
  font-size: 0.85rem;
}

#new-conversation:hover { background: rgba(212, 175, 55, 0.1); }

#conversation-list { display: flex; flex-direction: column; gap: 0.25rem; }

/* Item da conversa: título + ações (renomear/arquivar) na mesma linha, com
   as ações só aparecendo no hover pra não poluir a lista (26/jul). */
.conversation-item {
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 0.15rem;
}

.conversation-title {
  display: block;
  flex: 1;
  min-width: 0;
  padding: 0.5rem 0.6rem;
  border-radius: 6px;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-item.active .conversation-title {
  background: #201c10;
  color: var(--accent);
}

.conversation-title:hover { background: #1c1c1f; }

.conversation-acoes { display: flex; gap: 0.1rem; opacity: 0; transition: opacity .12s; flex-shrink: 0; }
.conversation-item:hover .conversation-acoes { opacity: 1; }
.conv-acao {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  padding: 0.3rem 0.25rem;
  border-radius: 4px;
}
.conv-acao:hover { background: #26262b; color: var(--fg); }
.conv-acao-excluir:hover { background: #3a1f1f; color: #e07a7a; }

.arquivadas-header {
  margin-top: 0.5rem;
  padding: 0.45rem 0.6rem;
  font-size: 0.78rem;
  color: var(--dim, #6f6f77);
  cursor: pointer;
  border-top: 1px solid #24242a;
  user-select: none;
}
.arquivadas-header:hover { color: var(--fg); }

#main-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-width: 0;
}

header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid #2a2a2e;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.header-title { display: flex; align-items: baseline; gap: 0.75rem; flex-shrink: 0; }
.header-actions { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.nav-link { color: var(--accent); text-decoration: none; font-size: 0.85rem; font-weight: 600; border: 1px solid #2a2a2e; border-radius: 6px; padding: 0.35rem 0.7rem; }
.nav-link:hover { background: #1f1f23; }

header h1 { margin: 0; color: var(--accent); font-size: 1.25rem; }
.subtitle { color: var(--muted); font-size: 0.85rem; }
#escopo-projeto { color: #17171a; background: var(--accent); font-size: 0.72rem; font-weight: 600; border-radius: 4px; padding: 2px 8px; }

.custo-total {
  font-size: 0.8rem;
  color: var(--muted);
  border: 1px solid #2a2a2e;
  border-radius: 6px;
  padding: 0.35rem 0.6rem;
  white-space: nowrap;
}

/* Contexto obrigatório por conversa (26/jul): seletor de projeto + info da
   subconta resolvida no cabeçalho, e o painel de confirmação de contas de
   anúncio dentro do chat. */
.seletor-projeto {
  background: #0d0d0f;
  color: var(--fg);
  border: 1px solid #2a2a2e;
  border-radius: 6px;
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
  max-width: 220px;
}
.subconta-info {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
}

#sem-projeto-aviso {
  padding: 2rem 1.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.contas-anuncio-box { max-width: 560px; }
.contas-anuncio-lista {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 0.8rem 0;
  max-height: 260px;
  overflow-y: auto;
}
.contas-anuncio-item { font-size: 0.85rem; display: flex; align-items: center; gap: 0.4rem; cursor: pointer; }

#chat {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.msg {
  max-width: 75%;
  padding: 0.6rem 0.9rem;
  border-radius: 10px;
  line-height: 1.4;
}

.msg.user { align-self: flex-end; background: var(--accent); color: #0d0d0f; white-space: pre-wrap; position: relative; }

/* Editar a última pergunta (26/jul) — lápis discreto que só aparece no hover
   da bolha, fora do texto (canto), pra não parecer parte da pergunta. */
.msg-editar {
  position: absolute;
  top: -0.6rem;
  left: -0.6rem;
  background: #1a1a1d;
  color: var(--fg);
  border: 1px solid #2a2a2e;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  font-size: 0.75rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity .12s;
}
.msg.user:hover .msg-editar { opacity: 1; }
.msg-editar:hover { border-color: var(--accent); color: var(--accent); }
.msg.assistant { align-self: flex-start; background: var(--card); border: 1px solid #2a2a2e; max-width: 92%; }
.msg.system { align-self: center; color: var(--muted); font-size: 0.85rem; }

.msg.assistant .table-wrap { overflow-x: auto; margin: 0 0 0.6rem; }
.msg.assistant table { border-collapse: collapse; width: 100%; font-size: 0.85rem; }
.msg.assistant th, .msg.assistant td {
  border: 1px solid #2a2a2e;
  padding: 0.4rem 0.6rem;
  text-align: left;
  white-space: nowrap;
}
.msg.assistant th { color: var(--accent); background: #1c1a10; }

.feedback-row { display: flex; gap: 0.3rem; margin-top: 0.5rem; }
.feedback-btn {
  background: transparent;
  border: 1px solid #2a2a2e;
  border-radius: 6px;
  padding: 0.3rem 0.5rem;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  color: var(--fg);
  opacity: 0.6;
}
.feedback-btn.girado svg { transform: rotate(180deg); }
.feedback-btn:hover { opacity: 1; border-color: var(--accent); }
.feedback-row.sent .feedback-btn { opacity: 0.25; cursor: default; }
.feedback-row.sent .feedback-btn.selecionado { opacity: 1; border-color: var(--accent); background: #2a2510; }
/* Reação em documento (20/jul) — ao contrário do chat, pode mudar a
   qualquer momento, então "selecionado" vale mesmo fora de .sent. */
.feedback-btn.selecionado { opacity: 1; border-color: var(--accent); background: #2a2510; }

.msg.assistant p { margin: 0 0 0.6rem; }
.msg.assistant p:last-child { margin-bottom: 0; }
.msg.assistant ul, .msg.assistant ol { margin: 0 0 0.6rem; padding-left: 1.25rem; }
.msg.assistant li { margin-bottom: 0.25rem; }
.msg.assistant h4, .msg.assistant h5, .msg.assistant h6 {
  margin: 0.4rem 0 0.4rem;
  color: var(--accent);
  font-size: 0.95rem;
}
.msg.assistant strong { color: var(--accent); }
.msg.assistant code {
  background: #0d0d0f;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.85em;
}

form {
  display: flex;
  gap: 0.5rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid #2a2a2e;
  align-items: flex-end;
}

input, #input {
  flex: 1;
  padding: 0.7rem 1rem;
  border-radius: 8px;
  border: 1px solid #2a2a2e;
  background: #0d0d0f;
  color: var(--fg);
  font-size: 1rem;
}

/* Campo cresce conforme digita (26/jul, pedido do Felipe: "igual aqui no
   Claude") — textarea de 1 linha que sobe até um teto e aí rola por dentro.
   max-height é um cinto-e-suspensório contra o bug já visto (achado real:
   textarea de altura calculada num momento em que o layout ainda não tinha
   assentado explodiu pra 137.000px) — nunca deixar sem teto. */
#input {
  resize: none;
  overflow-y: auto;
  max-height: 40vh;
  line-height: 1.4;
  font-family: inherit;
}

button {
  padding: 0.7rem 1.2rem;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #0d0d0f;
  font-weight: 600;
  cursor: pointer;
}

button:disabled { opacity: 0.5; cursor: not-allowed; }

/* Botão "Parar" (28/jul) — some enquanto o Ares não está processando nada,
   aparece no lugar do Enviar assim que uma pergunta sai. Vermelho porque é
   uma ação de corte, não a ação principal do form. */
#btn-parar { background: #e07a7a; color: #17171a; }
#btn-parar:hover { filter: brightness(1.08); }
