.hecate-ai {
  --hecate-border: #d7d4cf;
  --hecate-soft: #f7f5f1;
  --hecate-text: #24221f;
  max-width: 880px;
  margin: 1.5rem auto;
  border: 1px solid var(--hecate-border);
  border-radius: 14px;
  background: #fff;
  overflow: hidden;
  box-shadow: 0 8px 28px rgba(0,0,0,.06);
  color: var(--hecate-text);
}

.hecate-ai__header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--hecate-border);
  background: var(--hecate-soft);
}

.hecate-ai__mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border: 1px solid #77716a;
  border-radius: 50%;
  font-family: Georgia, serif;
  font-size: 23px;
}

.hecate-ai__title {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.2;
}

.hecate-ai__subtitle {
  margin: 4px 0 0;
  font-size: .9rem;
  opacity: .72;
}

.hecate-ai__clear {
  margin-left: auto;
  border: 0;
  background: transparent;
  text-decoration: underline;
  cursor: pointer;
  font-size: .85rem;
  opacity: .75;
}

.hecate-ai__messages {
  min-height: 320px;
  max-height: 620px;
  overflow-y: auto;
  padding: 20px;
  background: #fff;
}

.hecate-ai__message {
  display: flex;
  margin: 0 0 14px;
}

.hecate-ai__message--user {
  justify-content: flex-end;
}

.hecate-ai__bubble {
  max-width: 82%;
  padding: 11px 13px;
  border-radius: 12px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.hecate-ai__message--user .hecate-ai__bubble {
  white-space: pre-wrap;
}

.hecate-ai__message--assistant .hecate-ai__bubble {
  white-space: normal;
}

.hecate-ai__message--assistant .hecate-ai__bubble > :first-child {
  margin-top: 0;
}

.hecate-ai__message--assistant .hecate-ai__bubble > :last-child {
  margin-bottom: 0;
}

.hecate-ai__message--assistant .hecate-ai__bubble p {
  margin: 0 0 .8em;
}

.hecate-ai__message--assistant .hecate-ai__bubble ul,
.hecate-ai__message--assistant .hecate-ai__bubble ol {
  margin: .35em 0 .9em 1.25em;
  padding: 0;
}

.hecate-ai__message--assistant .hecate-ai__bubble li {
  margin: .2em 0;
}

.hecate-ai__message--assistant .hecate-ai__bubble h3,
.hecate-ai__message--assistant .hecate-ai__bubble h4,
.hecate-ai__message--assistant .hecate-ai__bubble h5,
.hecate-ai__message--assistant .hecate-ai__bubble h6 {
  margin: .95em 0 .45em;
  line-height: 1.3;
}

.hecate-ai__message--assistant .hecate-ai__bubble code {
  padding: .08em .3em;
  border-radius: 4px;
  background: rgba(0,0,0,.06);
  font-size: .9em;
}

.hecate-ai__message--assistant .hecate-ai__bubble a {
  text-decoration: underline;
}

.hecate-ai__message--assistant .hecate-ai__bubble {
  background: var(--hecate-soft);
  border: 1px solid #e7e3dd;
}

.hecate-ai__message--user .hecate-ai__bubble {
  background: #292724;
  color: #fff;
}

.hecate-ai__sources {
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid rgba(0,0,0,.12);
  font-size: .82rem;
  opacity: .78;
  white-space: normal;
}

.hecate-ai__form {
  padding: 16px 20px 18px;
  border-top: 1px solid var(--hecate-border);
  background: var(--hecate-soft);
}

.hecate-ai__input {
  display: block;
  width: 100%;
  min-height: 92px;
  box-sizing: border-box;
  resize: vertical;
  border: 1px solid #aaa49c;
  border-radius: 10px;
  padding: 12px 13px;
  background: #fff;
  color: #1f1e1c;
  font: inherit;
  line-height: 1.45;
}

.hecate-ai__input:focus {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

.hecate-ai__actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}

.hecate-ai__status {
  min-height: 1.2em;
  font-size: .86rem;
  opacity: .7;
}

.hecate-ai__submit {
  margin-left: auto;
  border: 1px solid #292724;
  border-radius: 8px;
  padding: 9px 18px;
  background: #292724;
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}

.hecate-ai__submit:disabled {
  opacity: .55;
  cursor: wait;
}

.hecate-ai__notice {
  margin: 0;
  padding: 0 20px 17px;
  background: var(--hecate-soft);
  font-size: .76rem;
  opacity: .65;
}

@media (max-width: 620px) {
  .hecate-ai {
    border-radius: 10px;
  }
  .hecate-ai__header,
  .hecate-ai__messages,
  .hecate-ai__form {
    padding-left: 14px;
    padding-right: 14px;
  }
  .hecate-ai__subtitle {
    display: none;
  }
  .hecate-ai__bubble {
    max-width: 92%;
  }
}

/* Markdown robusto: bloques de código y separadores */
.hecate-ai__message--assistant .hecate-ai__bubble pre {
  margin: .75em 0;
  padding: .75em .9em;
  overflow-x: auto;
  border-radius: 7px;
  background: rgba(0,0,0,.055);
  white-space: pre-wrap;
  word-break: break-word;
}

.hecate-ai__message--assistant .hecate-ai__bubble pre code {
  padding: 0;
  background: transparent;
}

.hecate-ai__message--assistant .hecate-ai__bubble hr {
  margin: 1em 0;
  border: 0;
  border-top: 1px solid rgba(0,0,0,.15);
}

.hecate-ai__sources a {
  overflow-wrap: anywhere;
}


/* Hécate IA 0.5.0: sources, tables and answer tools */
.hecate-ai__sources {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(0,0,0,.12);
  font-size: .79rem;
  opacity: .9;
}
.hecate-ai__sources summary {
  cursor: pointer;
  font-weight: 600;
  user-select: none;
}
.hecate-ai__sources ol {
  margin: .6em 0 0 1.2em !important;
  padding: 0;
}
.hecate-ai__sources li { margin: .28em 0 !important; }
.hecate-ai__source-domain { opacity: .62; font-size: .92em; }
.hecate-ai__message-tools {
  display: flex;
  justify-content: flex-end;
  margin-top: .5rem;
}
.hecate-ai__copy {
  border: 0;
  background: transparent;
  padding: 2px 0;
  font: inherit;
  font-size: .72rem;
  opacity: .55;
  cursor: pointer;
  text-decoration: underline;
}
.hecate-ai__copy:hover { opacity: .9; }
.hecate-ai__message--assistant blockquote {
  margin: .7em 0;
  padding: .15em 0 .15em .8em;
  border-left: 3px solid rgba(0,0,0,.22);
  opacity: .92;
}
.hecate-ai__message--assistant pre {
  overflow-x: auto;
  padding: .7em;
  border-radius: 7px;
  background: rgba(0,0,0,.055);
}

/* Hécate IA 0.6.0: interacción, métricas, tablas y accesibilidad */
.hecate-ai__suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 20px 14px;
  background: #fff;
}
.hecate-ai__suggestions[hidden] { display: none !important; }
.hecate-ai__suggestions button {
  border: 1px solid var(--hecate-border);
  border-radius: 999px;
  padding: 6px 10px;
  background: var(--hecate-soft);
  color: inherit;
  font: inherit;
  font-size: .78rem;
  cursor: pointer;
}
.hecate-ai__suggestions button:hover,
.hecate-ai__suggestions button:focus-visible {
  border-color: currentColor;
}
.hecate-ai__input-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 6px;
  font-size: .7rem;
  opacity: .58;
}
.hecate-ai__stop {
  border: 1px solid #77716a;
  border-radius: 8px;
  padding: 8px 12px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-size: .82rem;
}
.hecate-ai__stop[hidden] { display: none !important; }
.hecate-ai__meta {
  margin-top: .65rem;
  padding-top: .55rem;
  border-top: 1px solid rgba(0,0,0,.08);
  font-size: .7rem;
  opacity: .58;
}
.hecate-ai__source-badge {
  display: inline-block;
  padding: .08rem .35rem;
  border: 1px solid rgba(0,0,0,.18);
  border-radius: 999px;
  font-size: .68rem;
  line-height: 1.35;
  white-space: nowrap;
  vertical-align: .08em;
}
.hecate-ai__source-badge.is-verified {
  font-weight: 600;
  border-color: rgba(0,0,0,.35);
}
.hecate-ai__table-wrap {
  max-width: 100%;
  margin: .8em 0;
  overflow-x: auto;
  border: 1px solid rgba(0,0,0,.12);
  border-radius: 7px;
}
.hecate-ai__table-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88em;
}
.hecate-ai__table-wrap th,
.hecate-ai__table-wrap td {
  padding: .5em .65em;
  border-bottom: 1px solid rgba(0,0,0,.1);
  border-right: 1px solid rgba(0,0,0,.08);
  text-align: left;
  vertical-align: top;
}
.hecate-ai__table-wrap th:last-child,
.hecate-ai__table-wrap td:last-child { border-right: 0; }
.hecate-ai__table-wrap tbody tr:last-child td { border-bottom: 0; }
.hecate-ai__table-wrap th { background: rgba(0,0,0,.04); font-weight: 700; }
.hecate-ai[aria-busy="true"] .hecate-ai__messages { cursor: progress; }
.hecate-ai__input { max-height: 220px; }

@media (max-width: 620px) {
  .hecate-ai__suggestions { padding-left: 14px; padding-right: 14px; }
  .hecate-ai__input-meta span:first-child { display: none; }
  .hecate-ai__input-meta { justify-content: flex-end; }
  .hecate-ai__actions { flex-wrap: wrap; }
  .hecate-ai__status { flex: 1 1 100%; }
}

/* Hécate IA 0.7.0: auditoría bibliográfica y utilidades de fuentes */
.hecate-ai__message-tools {
  gap: 10px;
}
.hecate-ai__audit {
  margin-top: .7rem;
  padding-top: .55rem;
  border-top: 1px solid rgba(0,0,0,.1);
  font-size: .78rem;
}
.hecate-ai__audit summary {
  cursor: pointer;
  font-weight: 700;
  user-select: none;
}
.hecate-ai__audit p {
  margin: .55em 0 !important;
}
.hecate-ai__audit-stats {
  margin: .45em 0;
  font-size: .92em;
  opacity: .78;
}
.hecate-ai__audit ul,
.hecate-ai__audit ol {
  margin: .45em 0 .25em 1.2em !important;
}
.hecate-ai__audit-records li {
  margin: .4em 0 !important;
}
.hecate-ai__audit-badge {
  display: inline-block;
  padding: .08rem .35rem;
  border: 1px solid rgba(0,0,0,.2);
  border-radius: 999px;
  font-size: .68rem;
  font-weight: 600;
  line-height: 1.35;
  white-space: nowrap;
}
.hecate-ai__audit-badge.is-verified { border-color: rgba(0,0,0,.42); }
.hecate-ai__audit-badge.is-partial { border-style: dashed; }
.hecate-ai__audit-badge.is-unverified,
.hecate-ai__audit-badge.is-conflict { font-weight: 700; }
.hecate-ai__audit--issues summary,
.hecate-ai__audit--warnings summary { text-decoration: underline; text-decoration-style: dotted; }
