:root {
  --bg: #f6f8fa;
  --surface: #ffffff;
  --text: #1c2430;
  --muted: #5d6b7a;
  --border: #dde3ea;
  --accent: #0f6e8c;
  --accent-text: #ffffff;
  --user-bg: #e6f2f6;
  --warn-bg: #fff7e6;
  --warn-border: #f0d39a;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11161c;
    --surface: #182029;
    --text: #e6edf3;
    --muted: #9aa8b6;
    --border: #2a3542;
    --accent: #3fa9c9;
    --accent-text: #0b1117;
    --user-bg: #1d3340;
    --warn-bg: #2a2416;
    --warn-border: #5c4a22;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
}

.topo {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.marca { display: flex; align-items: center; gap: 10px; }
.marca small { display: block; color: var(--muted); font-size: 13px; }
.logo {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-text); font-weight: 700;
}
.topo-acoes { display: flex; align-items: center; gap: 10px; }
.usuario { color: var(--muted); font-size: 13px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.conversa { flex: 1; overflow-y: auto; padding: 20px 16px; }
.conversa > * { max-width: 820px; margin-left: auto; margin-right: auto; }

.inicio { text-align: center; padding: 6vh 0 20px; }
.inicio h1 { font-size: 24px; margin: 0 0 8px; }
.inicio p { color: var(--muted); margin: 0 0 22px; }
.exemplos { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; text-align: left; }
.exemplo {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px;
  color: var(--text); font: inherit; font-size: 14px; cursor: pointer; box-shadow: var(--shadow); text-align: left;
}
.exemplo:hover { border-color: var(--accent); }

.msg { margin: 14px auto; }
.msg.user .bolha {
  background: var(--user-bg); margin-left: auto; max-width: 85%; width: fit-content;
  border-radius: 14px 14px 4px 14px; padding: 10px 14px; white-space: pre-wrap;
}
.msg.assistant .bolha {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow);
}
.bolha p { margin: 0 0 10px; }
.bolha p:last-child { margin-bottom: 0; }
.bolha ul, .bolha ol { margin: 0 0 10px; padding-left: 22px; }
.bolha h3, .bolha h4 { margin: 12px 0 6px; font-size: 16px; }
.bolha table { border-collapse: collapse; margin: 8px 0 12px; font-size: 14px; display: block; overflow-x: auto; }
.bolha th, .bolha td { border: 1px solid var(--border); padding: 6px 8px; text-align: left; vertical-align: top; }
.bolha code { background: var(--bg); padding: 1px 4px; border-radius: 4px; }
.digitando::after { content: "▍"; animation: pisca 1s steps(2) infinite; color: var(--muted); }
@keyframes pisca { 50% { opacity: 0; } }

.fontes { margin-top: 10px; font-size: 13px; color: var(--muted); }
.fontes summary { cursor: pointer; }
.fontes ul { margin: 6px 0 0; padding-left: 18px; }
.acoes { display: flex; gap: 6px; margin-top: 8px; }
.acoes button {
  background: none; border: 1px solid var(--border); border-radius: 8px; padding: 3px 9px;
  color: var(--muted); font-size: 13px; cursor: pointer;
}
.acoes button:hover, .acoes button.ativo { border-color: var(--accent); color: var(--accent); }
.erro { color: #b42318; }

.rodape { background: var(--surface); border-top: 1px solid var(--border); padding: 10px 16px 14px; }
.rodape > * { max-width: 820px; margin-left: auto; margin-right: auto; }
.aviso {
  font-size: 12.5px; color: var(--muted); background: var(--warn-bg); border: 1px solid var(--warn-border);
  border-radius: 8px; padding: 6px 10px; margin-top: 0; margin-bottom: 8px;
}
.form { display: flex; gap: 8px; align-items: flex-end; }
textarea {
  flex: 1; resize: none; max-height: 200px; min-height: 44px; padding: 11px 12px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit;
}
textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.botao, .botao-sec { border-radius: 10px; font: inherit; cursor: pointer; padding: 10px 16px; }
.botao { background: var(--accent); color: var(--accent-text); border: none; font-weight: 600; }
.botao:disabled { opacity: 0.5; cursor: default; }
.botao-sec { background: none; border: 1px solid var(--border); color: var(--text); padding: 6px 12px; font-size: 14px; white-space: nowrap; }

@media (max-width: 560px) {
  .usuario { display: none; }
  .inicio h1 { font-size: 20px; }
  .msg.user .bolha { max-width: 92%; }
}
