:root, [data-theme="light"] {
  --bg: #ffffff;
  --surface: #f5f5f5;
  --surface-warm: #f5f2ef;
  --surface-warm-80: rgba(245, 242, 239, 0.8);
  --fg: #000000;
  --fg-2: #4e4e4e;
  --muted: #777169;
  --accent: #000000;
  --accent-fg: #ffffff;
  --border: #e5e5e5;
  --bolha-usuario: #f5f2ef;
  --bolha-assistente: #ffffff;
  --erro: #b00020;
  --radius-pill: 9999px;
  --radius-card: 16px;
  --radius-input: 12px;
  --elev-ring:
    rgba(0, 0, 0, 0.06) 0px 0px 0px 1px,
    rgba(0, 0, 0, 0.04) 0px 1px 2px,
    rgba(0, 0, 0, 0.04) 0px 2px 4px;
  --elev-raised:
    rgba(0, 0, 0, 0.06) 0px 0px 0px 1px,
    rgba(0, 0, 0, 0.04) 0px 2px 4px,
    rgba(0, 0, 0, 0.04) 0px 4px 8px,
    0px 0px 0px 0.5px inset rgba(0, 0, 0, 0.06);
  --elev-warm: rgba(78, 50, 23, 0.04) 0px 6px 16px;
  --focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px rgba(0, 0, 0, 0.12);
  --font-display: "Outfit", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
  --font-mono: "Geist Mono", "SF Mono", monospace;
  --grad-azul: linear-gradient(135deg, #dbeafe 0%, #eff6ff 100%);
  --grad-roxo: linear-gradient(135deg, #ede9fe 0%, #fae8ff 100%);
  --grad-verde: linear-gradient(135deg, #d1fae5 0%, #ecfdf5 100%);
  --grad-ambar: linear-gradient(135deg, #fef3c7 0%, #fffbeb 100%);
  --cor-azul: #3b82f6;
  --cor-roxo: #a855f7;
  --cor-verde: #22c55e;
  --cor-ambar: #f59e0b;
  --aba-bg: #ffffff;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --scrollbar-thumb: rgba(0, 0, 0, 0.16);
  --scrollbar-thumb-hover: rgba(0, 0, 0, 0.28);
}

[data-theme="dark"] {
  --bg: #141312;
  --surface: #1e1d1b;
  --surface-warm: #262421;
  --surface-warm-80: rgba(38, 36, 33, 0.8);
  --fg: #f5f2ef;
  --fg-2: #a8a5a0;
  --muted: #777169;
  --accent: #f5f2ef;
  --accent-fg: #141312;
  --border: rgba(255, 255, 255, 0.08);
  --bolha-usuario: #262421;
  --bolha-assistente: #1e1d1b;
  --erro: #ff6b6b;
  --elev-ring:
    rgba(255, 255, 255, 0.06) 0px 0px 0px 1px,
    rgba(0, 0, 0, 0.2) 0px 1px 2px,
    rgba(0, 0, 0, 0.15) 0px 2px 4px;
  --elev-raised:
    rgba(255, 255, 255, 0.06) 0px 0px 0px 1px,
    rgba(0, 0, 0, 0.25) 0px 2px 4px,
    rgba(0, 0, 0, 0.2) 0px 4px 8px,
    0px 0px 0px 0.5px inset rgba(255, 255, 255, 0.04);
  --elev-warm: rgba(0, 0, 0, 0.3) 0px 6px 16px;
  --focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px rgba(255, 255, 255, 0.12);
  --grad-azul: linear-gradient(135deg, #1e3a5f 0%, #1a2a40 100%);
  --grad-roxo: linear-gradient(135deg, #3b1f5c 0%, #2a1a3a 100%);
  --grad-verde: linear-gradient(135deg, #1a3d2e 0%, #1a3028 100%);
  --grad-ambar: linear-gradient(135deg, #3d3018 0%, #302818 100%);
  --cor-azul: #60a5fa;
  --cor-roxo: #c084fc;
  --cor-verde: #4ade80;
  --cor-ambar: #fbbf24;
  --aba-bg: #1e1d1b;
  --scrollbar-thumb: rgba(255, 255, 255, 0.16);
  --scrollbar-thumb-hover: rgba(255, 255, 255, 0.28);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141312;
    --surface: #1e1d1b;
    --surface-warm: #262421;
    --surface-warm-80: rgba(38, 36, 33, 0.8);
    --fg: #f5f2ef;
    --fg-2: #a8a5a0;
    --muted: #777169;
    --accent: #f5f2ef;
    --accent-fg: #141312;
    --border: rgba(255, 255, 255, 0.08);
    --bolha-usuario: #262421;
    --bolha-assistente: #1e1d1b;
    --erro: #ff6b6b;
    --elev-ring:
      rgba(255, 255, 255, 0.06) 0px 0px 0px 1px,
      rgba(0, 0, 0, 0.2) 0px 1px 2px,
      rgba(0, 0, 0, 0.15) 0px 2px 4px;
    --elev-raised:
      rgba(255, 255, 255, 0.06) 0px 0px 0px 1px,
      rgba(0, 0, 0, 0.25) 0px 2px 4px,
      rgba(0, 0, 0, 0.2) 0px 4px 8px,
      0px 0px 0px 0.5px inset rgba(255, 255, 255, 0.04);
    --elev-warm: rgba(0, 0, 0, 0.3) 0px 6px 16px;
    --focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px rgba(255, 255, 255, 0.12);
    --grad-azul: linear-gradient(135deg, #1e3a5f 0%, #1a2a40 100%);
    --grad-roxo: linear-gradient(135deg, #3b1f5c 0%, #2a1a3a 100%);
    --grad-verde: linear-gradient(135deg, #1a3d2e 0%, #1a3028 100%);
    --grad-ambar: linear-gradient(135deg, #3d3018 0%, #302818 100%);
    --cor-azul: #60a5fa;
    --cor-roxo: #c084fc;
    --cor-verde: #4ade80;
    --cor-ambar: #fbbf24;
    --aba-bg: #1e1d1b;
    --scrollbar-thumb: rgba(255, 255, 255, 0.16);
    --scrollbar-thumb-hover: rgba(255, 255, 255, 0.28);
  }
}

* {
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) transparent;
}

/* Custom scrollbars for webkit-based browsers (Chrome, Safari, Edge, Opera) */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border: 2px solid transparent;
  background-clip: padding-box;
  border-radius: 9999px;
  transition: background 0.15s;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
  border: 2px solid transparent;
  background-clip: padding-box;
}

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--font-body);
  font-size: 15px;
  letter-spacing: 0.14px;
  background: var(--bg);
  color: var(--fg);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.tela {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: flex;
}
.tela[hidden] { display: none !important; }

#tela-login { align-items: center; justify-content: center; padding: 16px; }

.cartao-login {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 28px 24px;
  border: none;
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--elev-raised);
  width: min(360px, 100%);
}
.cartao-login h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 300;
  letter-spacing: -0.02em;
}
.cartao-login .muted { color: var(--muted); margin: 0; font-size: 14px; }
.cartao-login input {
  padding: 12px 14px;
  border-radius: var(--radius-input);
  border: none;
  box-shadow: var(--elev-ring);
  font-size: 16px;
  font-family: inherit;
  background: var(--bg);
  color: var(--fg);
}
.cartao-login input:focus {
  outline: none;
  box-shadow: var(--focus-ring);
}
.cartao-login button {
  padding: 12px 20px;
  border-radius: var(--radius-pill);
  border: none;
  background: var(--accent);
  color: var(--accent-fg);
  font-size: 15px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.15s;
}
.cartao-login button:hover { opacity: 0.9; }
.erro { color: var(--erro); font-size: 13px; margin: 0; }

/* App shell mobile-first */
#tela-app { flex-direction: column; align-items: center; }

.app-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 720px;
  height: 100%;
  height: 100dvh;
  background: var(--bg);
}

.topo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 8px;
}
.topo-esq { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.topo-dir { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.marca {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}
.usuario-nome {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.status { color: var(--muted); font-size: 12px; }
.btn-icone {
  border: none;
  background: transparent;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-pill);
  line-height: 1;
  color: var(--fg-2);
  transition: background 0.15s;
}
.btn-icone:hover { background: var(--surface); }

.conteudo-principal {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

.painel-aba {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.painel-aba[hidden] { display: none !important; }

.painel-cabecalho {
  padding: 20px 16px 10px;
  flex-shrink: 0;
}
.painel-cabecalho h2 {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 300;
  letter-spacing: -0.02em;
}
.painel-cabecalho .muted { margin: 0; font-size: 13px; color: var(--muted); }
.historico-cabecalho {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.thread-titulo {
  padding: 10px 16px 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.mensagens {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
}

.mensagem {
  max-width: 85%;
  padding: 12px 16px;
  line-height: 1.5;
  font-size: 15px;
  word-wrap: break-word;
}
.mensagem-usuario {
  align-self: flex-end;
  background: var(--bolha-usuario);
  border-radius: 18px 18px 4px 18px;
}
.mensagem-assistente {
  align-self: flex-start;
  background: var(--bolha-assistente);
  border-radius: 18px 18px 18px 4px;
  box-shadow: var(--elev-ring);
  max-width: 92%;
}
.mensagem.carregando::after { content: "…"; color: var(--muted); }
.mensagem code {
  font-family: var(--font-mono);
  background: var(--surface);
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 0.88em;
}

.imagem-mensagem { max-width: 100%; border-radius: 12px; margin-top: 6px; display: block; }

.opcoes-checkpoint { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.opcoes-checkpoint button {
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  border: none;
  background: var(--accent);
  color: var(--accent-fg);
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  font-weight: 500;
  transition: opacity 0.15s;
}
.opcoes-checkpoint button:hover:not(:disabled) { opacity: 0.9; }
.opcoes-checkpoint button:disabled { opacity: 0.5; cursor: default; }

.rodape-chat {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  padding: 10px 12px calc(10px + var(--safe-bottom));
  background: var(--bg);
}

.dropzone {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  border: none;
  border-radius: var(--radius-card);
  padding: 6px 8px 6px 12px;
  background: var(--surface);
  box-shadow: var(--elev-ring);
  transition: box-shadow 0.15s;
}
.dropzone:focus-within { box-shadow: var(--focus-ring); }
.dropzone.arrastando {
  background: var(--surface-warm);
  box-shadow: var(--elev-raised);
}
.dropzone textarea {
  flex: 1;
  resize: none;
  border: none;
  background: transparent;
  color: var(--fg);
  font-size: 16px;
  font-family: inherit;
  line-height: 1.5;
  padding: 10px 4px;
  min-height: 40px;
  max-height: 200px;
  overflow-y: hidden;
  white-space: pre-wrap;
  word-break: break-word;
}
.dropzone textarea:focus { outline: none; }
.btn-enviar {
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  border: none;
  background: var(--accent);
  color: var(--accent-fg);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.btn-enviar:hover { opacity: 0.9; }

.preview-imagem {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-input);
  background: var(--surface);
  box-shadow: var(--elev-ring);
  width: fit-content;
}
.preview-imagem[hidden] { display: none !important; }
.preview-imagem img { max-height: 56px; max-width: 120px; border-radius: 8px; object-fit: cover; }
#remover-imagem {
  border: none; background: transparent; color: var(--muted);
  cursor: pointer; font-size: 20px; line-height: 1; padding: 2px 6px; border-radius: var(--radius-pill);
}
#remover-imagem:hover { background: var(--surface-warm); color: var(--fg); }

/* Barra de abas inferior */
.barra-abas {
  display: flex;
  border-top: 1px solid var(--border);
  background: var(--aba-bg);
  padding-bottom: var(--safe-bottom);
  flex-shrink: 0;
}
.aba {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 4px 12px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  font-family: inherit;
  transition: color 0.15s;
}
.aba-icone {
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.aba-icone svg {
  width: 21px;
  height: 21px;
  color: inherit;
  transition: transform 0.15s ease;
}
.aba-label { font-weight: 500; }
.aba.ativa { color: var(--fg); }
.aba.ativa .aba-icone svg { transform: scale(1.05); }

/* Comandos */
#painel-comandos {
  overflow: hidden;
}

.lista-comandos {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 12px calc(20px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 20px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* Secao por categoria: rotulo fixo (nao clicavel), lista sempre visivel --
   sem acordeao, pra achar e usar um comando em um toque so. */
.secao-categoria {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.secao-rotulo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 4px;
}

.secao-label {
  font-weight: 500;
  font-size: 13px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
  flex: 1;
  min-width: 0;
}

.card-icone {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.card-icone-azul { background: var(--grad-azul); }
.card-icone-roxo { background: var(--grad-roxo); }
.card-icone-verde { background: var(--grad-verde); }
.card-icone-ambar { background: var(--grad-ambar); }

.card-contador {
  font-size: 11px;
  color: var(--muted);
  background: var(--surface);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  flex-shrink: 0;
}

.secao-lista {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Cada comando: um unico alvo de toque grande (title + descricao sempre
   visiveis, sem precisar expandir) + um botao pequeno secundario de copiar. */
.comando-linha {
  display: flex;
  align-items: stretch;
  gap: 6px;
  border-radius: var(--radius-input);
  background: var(--bg);
  box-shadow: var(--elev-ring);
  overflow: hidden;
}

.comando-principal {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  padding: 12px 14px;
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: background 0.15s;
}
.comando-principal:hover, .comando-principal:active { background: var(--surface-warm-80); }

.comando-textos {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.comando-titulo {
  font-weight: 500;
  font-size: 14px;
  line-height: 1.3;
  color: var(--fg);
}

.comando-descricao {
  font-size: 12.5px;
  color: var(--fg-2);
  line-height: 1.4;
}

.comando-copiar {
  flex-shrink: 0;
  width: 40px;
  border: none;
  border-left: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.comando-copiar:hover { background: var(--surface-warm-80); color: var(--fg); }

/* Arquivos */
#painel-arquivos { overflow: hidden; }

.arquivos-cabecalho {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.arquivos-cabecalho .btn-icone.girando {
  animation: arquivos-girar 0.6s linear infinite;
}

@keyframes arquivos-girar {
  to { transform: rotate(360deg); }
}

.arquivos-breadcrumb {
  flex-shrink: 0;
  padding: 0 16px 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  font-family: var(--font-mono);
}
.breadcrumb-item {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 2px;
  font-family: inherit;
  font-size: inherit;
}
.breadcrumb-item:hover:not(.ativo) { color: var(--fg); text-decoration: underline; }
.breadcrumb-item.ativo { color: var(--fg); font-weight: 500; cursor: default; }
.breadcrumb-sep { color: var(--border); }

.arquivos-lista {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 12px calc(20px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 2px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.arquivos-lista[hidden] { display: none; }

.arquivos-vazio {
  padding: 24px 12px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.arquivos-linha {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
  border: none;
  background: transparent;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  color: var(--fg);
  font-family: inherit;
  transition: background 0.15s;
}
.arquivos-linha:hover { background: var(--surface-warm-80); }

.arquivos-icone {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
}
.arquivos-icone svg { width: 100%; height: 100%; }

.arquivos-nome {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.arquivos-tamanho {
  flex-shrink: 0;
  font-size: 11px;
  color: var(--muted);
  font-family: var(--font-mono);
}

.arquivos-conteudo {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0 16px calc(16px + var(--safe-bottom));
}
.arquivos-conteudo[hidden] { display: none; }

.arquivos-conteudo-cabecalho {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 10px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.arquivos-viewer-acoes {
  flex-shrink: 0;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.arquivos-tabs {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.arquivos-tab {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  font-family: inherit;
  padding: 5px 10px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.arquivos-tab + .arquivos-tab {
  border-left: 1px solid var(--border);
}

.arquivos-tab.ativo {
  background: var(--accent);
  color: var(--accent-fg);
}

.arquivos-panes {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.arquivos-pane[hidden] { display: none; }

.arquivos-conteudo-titulo {
  font-weight: 500;
  font-size: 13.5px;
  font-family: var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.arquivos-conteudo-texto {
  flex: 1;
  min-height: 0;
  overflow: auto;
  margin: 0;
  padding: 12px 14px;
  background: var(--surface);
  border-radius: var(--radius-input);
  font-size: 12.5px;
  font-family: var(--font-mono);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--fg-2);
  -webkit-overflow-scrolling: touch;
}

.markdown-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 14px 16px;
  background: var(--surface);
  border-radius: var(--radius-input);
  line-height: 1.65;
  font-size: 14px;
  color: var(--fg);
  -webkit-overflow-scrolling: touch;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
  margin-top: 1.2em;
  margin-bottom: 0.5em;
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: -0.02em;
}

.markdown-body h1 { font-size: 1.5em; }
.markdown-body h2 { font-size: 1.25em; }
.markdown-body h3 { font-size: 1.1em; }

.markdown-body p { margin: 0.6em 0; }

.markdown-body code {
  background: var(--surface-warm-80);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 0.9em;
  font-family: var(--font-mono);
}

.markdown-body pre {
  background: var(--surface-warm-80);
  padding: 12px 14px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 0.8em 0;
}

.markdown-body pre code {
  background: none;
  padding: 0;
}

.markdown-body blockquote {
  border-left: 3px solid var(--accent);
  margin: 0.8em 0;
  padding: 2px 14px;
  color: var(--muted);
}

.markdown-body ul,
.markdown-body ol {
  padding-left: 1.4em;
  margin: 0.6em 0;
}

.markdown-body table {
  border-collapse: collapse;
  width: 100%;
  margin: 0.8em 0;
}

.markdown-body th,
.markdown-body td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  font-size: 0.92em;
}

.markdown-body img { max-width: 100%; border-radius: 6px; }
.markdown-body a { color: var(--accent); }

.btn-primario, .btn-secundario {
  padding: 9px 16px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
}
.btn-primario {
  background: var(--accent);
  color: var(--accent-fg);
  border: none;
  flex: 1;
}
.btn-primario:hover { opacity: 0.9; }
.btn-secundario {
  background: transparent;
  color: var(--fg);
  border: none;
  box-shadow: var(--elev-ring);
}
.btn-secundario:hover { background: var(--surface); }

/* Histórico */
.lista-historico {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px 20px;
  -webkit-overflow-scrolling: touch;
}
.historico-item {
  display: flex;
  align-items: stretch;
  gap: 0;
  margin-bottom: 8px;
  border-radius: var(--radius-input);
  background: var(--surface);
  box-shadow: var(--elev-ring);
  overflow: hidden;
  transition: box-shadow 0.15s;
}
.historico-item.ativo {
  box-shadow: var(--elev-raised);
  background: var(--surface-warm);
}
.historico-corpo {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border: none;
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: var(--fg);
  font-family: inherit;
  min-width: 0;
}
.historico-corpo strong {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.historico-preview {
  font-size: 13px;
  color: var(--fg-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.historico-data { font-size: 11px; color: var(--muted); }
.historico-acoes {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
}
.historico-acoes button {
  flex: 1;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0 12px;
  font-size: 14px;
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
}
.historico-acoes button:hover { background: var(--surface-warm); color: var(--fg); }

.muted { color: var(--muted); }
.vazio, .carregando-lista { padding: 24px 16px; text-align: center; font-size: 14px; }

/* Modal campos */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal[hidden] { display: none !important; }
.modal-corpo {
  background: var(--bg);
  border-radius: var(--radius-card) var(--radius-card) 0 0;
  padding: 24px 20px;
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--elev-raised);
}
.modal-corpo strong {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.1rem;
}
.modal-corpo label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}
.modal-corpo input, .modal-corpo textarea {
  padding: 12px 14px;
  border-radius: var(--radius-input);
  border: none;
  box-shadow: var(--elev-ring);
  background: var(--surface);
  color: var(--fg);
  font-family: inherit;
  font-size: 15px;
}
.modal-corpo input:focus, .modal-corpo textarea:focus {
  outline: none;
  box-shadow: var(--focus-ring);
}
.modal-botoes { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.modal-botoes button {
  padding: 9px 16px;
  border-radius: var(--radius-pill);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--fg-2);
}
.modal-botoes button:hover { background: var(--surface); }

@media (min-width: 721px) {
  .app-shell {
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
  .modal {
    align-items: center;
  }
  .modal-corpo {
    border-radius: var(--radius-card);
  }
}
