:host {
  display: block;
}

.eo-bubble-row {
  display: flex;
  width: 100%;

  /* Inheritable-property reset (L2). */
  font-family: var(--eo-font, system-ui, -apple-system, 'Segoe UI', sans-serif);
  font-size: 14px;
  line-height: 1.5;
  color: var(--eo-text, #1d1d1b);
  letter-spacing: normal;
  text-transform: none;
  text-align: start;
  font-style: normal;
  font-weight: 400;
}

.eo-bubble-row--user {
  justify-content: flex-end;
}

.eo-bubble-row--assistant {
  justify-content: flex-start;
}

.eo-bubble {
  position: relative;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
}

/* Inline error state — red border ring + retry button top-right */
.eo-bubble--error {
  border: 1px solid var(--eo-danger, #b3261e);
  background: var(--eo-danger-soft, rgba(179, 38, 30, 0.08));
  border-radius: 12px;
  padding: 10px 32px 10px 14px; /* right padding = room for the icon */
}

.eo-bubble-error-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--eo-danger, #b3261e);
  color: var(--eo-white, #ffffff);
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease;
}

.eo-bubble-error-btn:hover {
  transform: scale(1.1);
  filter: brightness(1.08);
}

.eo-bubble-error-btn:focus-visible {
  outline: 2px solid var(--eo-danger, #b3261e);
  outline-offset: 2px;
}

/* User message — sunken card on the right, sharp bottom-right corner */
.eo-bubble--user {
  max-width: 80%;
  padding: 10px 14px;
  background: var(--eo-sunken, #f5f6f4);
  border: 1px solid var(--eo-border, #e3e4e0);
  color: var(--eo-text, #1d1d1b);
  border-radius: 14px 14px 4px 14px;
}

/* Assistant response — no bubble: rich text straight on the background */
.eo-bubble--assistant {
  max-width: 100%;
  width: 100%;
  background: transparent;
  color: var(--eo-text, #1d1d1b);
}

.eo-bubble-content--plain {
  white-space: pre-wrap;
}

.eo-bubble-content {
  display: block;
}

/* Markdown element styles (assistant only) */
.eo-bubble--assistant .eo-bubble-content :is(p) {
  margin: 0 0 8px;
}

.eo-bubble--assistant .eo-bubble-content :is(p):last-child {
  margin-bottom: 0;
}

.eo-bubble--assistant .eo-bubble-content :is(ul, ol) {
  margin: 4px 0 8px;
  padding-left: 20px;
}

.eo-bubble--assistant .eo-bubble-content ul {
  list-style-type: disc;
}

.eo-bubble--assistant .eo-bubble-content ::marker {
  color: var(--eo-green, #50c878);
}

.eo-bubble--assistant .eo-bubble-content :is(li) {
  margin-bottom: 2px;
}

.eo-bubble--assistant .eo-bubble-content :is(strong) {
  font-weight: 700;
}

.eo-bubble--assistant .eo-bubble-content :is(em) {
  font-style: italic;
}

.eo-bubble--assistant .eo-bubble-content :is(code) {
  font-family: 'Geist Mono', ui-monospace, monospace;
  font-size: 13px;
  background: var(--eo-sunken, #f5f6f4);
  padding: 2px 5px;
  border-radius: 4px;
}

.eo-bubble--assistant .eo-bubble-content :is(pre) {
  background: var(--eo-sunken, #f5f6f4);
  border-radius: 8px;
  padding: 10px 12px;
  overflow-x: auto;
  margin: 6px 0;
}

.eo-bubble--assistant .eo-bubble-content :is(pre code) {
  background: none;
  padding: 0;
  border-radius: 0;
}

.eo-bubble--assistant .eo-bubble-content :is(a) {
  color: var(--eo-link, #1e7a40);
  text-decoration: underline;
}

.eo-bubble--assistant .eo-bubble-content :is(blockquote) {
  border-left: 3px solid var(--eo-green, #50c878);
  padding-left: 10px;
  margin: 6px 0;
  opacity: 0.85;
}

.eo-bubble--assistant .eo-bubble-content :is(h1, h2, h3) {
  font-weight: 700;
  margin: 8px 0 4px;
  line-height: 1.3;
}

.eo-bubble--assistant .eo-bubble-content h1 {
  font-size: 18px;
}
.eo-bubble--assistant .eo-bubble-content h2 {
  font-size: 16px;
}
.eo-bubble--assistant .eo-bubble-content h3 {
  font-size: 14px;
}

.eo-bubble--assistant .eo-bubble-content :is(table) {
  border-collapse: collapse;
  margin: 6px 0;
  width: 100%;
  font-size: 13px;
}

.eo-bubble--assistant .eo-bubble-content :is(th, td) {
  border: 1px solid var(--eo-border, #e3e4e0);
  padding: 4px 8px;
  text-align: left;
}

.eo-bubble--assistant .eo-bubble-content :is(th) {
  background: var(--eo-sunken, #f5f6f4);
  font-weight: 600;
}

/* Fontes — rendered only when the message carries sources */
.eo-sources {
  margin-top: 10px;
  font-size: 12px;
  color: var(--eo-text-3, #6c6c6a);
}

.eo-sources-title {
  display: block;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 11px;
  margin-bottom: 4px;
}

.eo-sources-list {
  margin: 0;
  padding-left: 18px;
}

.eo-sources-list li {
  margin-bottom: 2px;
}

.eo-sources-list a {
  color: var(--eo-link, #1e7a40);
  text-decoration: underline;
  word-break: break-all;
}

/* Per-answer actions — copy · useful · not useful */
.eo-actions {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}

.eo-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--eo-text-3, #6c6c6a);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

.eo-action-btn:hover {
  background: var(--eo-sunken, #f5f6f4);
  color: var(--eo-text, #1d1d1b);
}

.eo-action-btn:focus-visible {
  outline: 2px solid var(--eo-green, #50c878);
  outline-offset: 1px;
}

/* Voted states — exclusive, filled */
.eo-action-btn--up {
  color: var(--eo-green-text, #1e7a40);
}

.eo-action-btn--down {
  color: var(--eo-danger, #b3261e);
}

.eo-action-btn--up svg,
.eo-action-btn--down svg {
  fill: currentColor;
}
