.bubble-text { white-space: pre-wrap; }

.message {
  display: flex;
  flex-direction: column;
  animation: fadeUp .28s var(--ease);
}

.message.user { align-items: flex-end; }

.user-bubble {
  background: var(--bubble-user);
  color: var(--bubble-txt);
  padding: 11px 17px;
  border-radius: var(--r-xl) var(--r-xl) var(--r-sm) var(--r-xl);
  max-width: 72%;
  word-break: break-word;
  font-size: 15px;
  line-height: 1.6;
  box-shadow: var(--shadow-sm);
}

.bubble-attachment {
  margin-bottom: 8px;
}

.bubble-attachment img {
  display: block;
  max-width: 220px;
  max-height: 165px;
  border-radius: var(--r);
  object-fit: cover;
}

.bubble-file {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  background: rgba(0,0,0,.07);
  border-radius: var(--r-sm);
  font-size: 13px;
  color: var(--text-2);
}

.bubble-file .material-symbols-outlined { font-size: 17px; color: var(--iris); flex-shrink: 0; }
.bubble-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }

.bubble-file + .bubble-file,
.bubble-file + .bubble-text { margin-top: 6px; }

.message.ai { align-items: flex-start; width: 100%; }

.reasoning-block {
  width: 100%;
  margin-bottom: 10px;
}

.reasoning-block summary {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  list-style: none;
  cursor: pointer;
  color: var(--text-3);
  font-size: 12.5px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: var(--r-sm);
  user-select: none;
  transition: background var(--t) var(--ease), color var(--t) var(--ease);
  letter-spacing: .01em;
}

.reasoning-block summary::-webkit-details-marker { display: none; }
.reasoning-block summary:hover { background: var(--surface-hover); color: var(--text-2); }

.reasoning-block summary .rsn-icon { font-size: 15px; }

.reasoning-chevron {
  font-size: 15px;
  transition: transform .2s var(--ease);
}

.reasoning-block[open] summary .reasoning-chevron { transform: rotate(90deg); }

.reasoning-body {
  margin-top: 8px;
  padding: 12px 16px;
  border-left: 2px solid var(--border);
  background: var(--surface);
  border-radius: 0 var(--r) var(--r) 0;
  color: var(--text-2);
  font-size: 13.5px;
  line-height: 1.7;
}

.reasoning-body p { margin: 0 0 8px; }
.reasoning-body p:last-child { margin-bottom: 0; }
.reasoning-body strong { font-weight: 600; }
.reasoning-body em { font-style: italic; }
.reasoning-body h1,
.reasoning-body h2,
.reasoning-body h3 { font-size: 14px; font-weight: 600; margin: 12px 0 6px; }
.reasoning-body ul,
.reasoning-body ol { padding-left: 22px; margin: 6px 0 10px; }
.reasoning-body li { margin: 3px 0; }
.reasoning-body li > ul,
.reasoning-body li > ol { margin: 3px 0; }
.reasoning-body code {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 12.5px;
  background: var(--bg-main);
  padding: 2px 6px;
  border-radius: 5px;
  border: 1px solid var(--border);
  color: var(--iris);
}
.reasoning-body .code-block { background: var(--bg-main); }
.reasoning-body .code-block pre { margin: 0; padding: 12px 14px; overflow-x: auto; }
.reasoning-body .code-block pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.6;
}
.reasoning-body blockquote { border-left: 3px solid var(--iris); padding: 4px 12px; margin: 8px 0; }
.reasoning-body hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }

.ai-text {
  font-size: 15px;
  line-height: 1.75;
  color: var(--text);
  word-break: break-word;
  width: 100%;
}

.ai-text.streaming::after {
  content: '';
  display: inline-block;
  width: 2px;
  height: .95em;
  background: var(--iris);
  margin-left: 2px;
  vertical-align: text-bottom;
  border-radius: 2px;
  animation: blink .75s ease infinite;
}

.ai-actions {
  display: flex;
  gap: 2px;
  margin-top: 8px;
  opacity: 0;
  transition: opacity .2s;
}

.ai-text.streaming + .ai-actions {
  display: none;
}

.message.ai:hover .ai-actions { opacity: 1; }

.ai-action-btn {
  width: 34px; height: 34px;
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3);
  transition: background var(--t) var(--ease), color var(--t) var(--ease);
  flex-shrink: 0;
}

.ai-action-btn:hover  { background: var(--surface-hover); color: var(--text-2); }
.ai-action-btn:active { transform: scale(.91); }

.ai-action-btn .material-symbols-outlined { font-size: 17px; }

.ai-action-btn.active {
  color: var(--iris);
  background: var(--iris-dim);
}

.ai-action-btn.copied {
  color: #2e7d32;
  background: rgba(46,125,50,.1);
}

.message.user.editando .user-bubble { opacity: .45; }

.msg-menu {
  position: fixed;
  z-index: 600;
  min-width: 170px;
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  animation: menuPop .15s var(--ease);
}

.msg-menu-opt {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  text-align: left;
  font-size: 14px;
  color: var(--text);
  transition: background var(--t) var(--ease);
}

.msg-menu-opt:hover { background: var(--surface-hover); }
.msg-menu-opt .material-symbols-outlined { font-size: 20px; color: var(--iris); }

@media (pointer: coarse) {
  .user-bubble {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
  }
}
