/* ===== Animerse 灵魂对话 · 精细版（覆盖 styles.css 的 chat 部分）===== */

.chat-container,
.chat-container.expanded {
  max-width: 860px; margin: 0 auto; width: 100%;
  height: 560px;
  border-radius: 18px; overflow: hidden;
  background: rgba(13, 11, 40, .55);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  box-shadow: 0 20px 60px -20px rgba(0, 0, 0, .6), inset 0 1px 0 rgba(255, 255, 255, .05);
  display: flex; flex-direction: column;
}
.chat-container.maximized,
.chat-container.maximized.expanded {
  position: fixed; inset: 0; z-index: 1000; max-width: 100%; height: 100vh; border-radius: 0; margin: 0;
}

.chat-header {
  background: linear-gradient(120deg, rgba(99, 102, 241, .3), rgba(139, 123, 255, .28));
  padding: 14px 18px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border); flex: 0 0 auto;
}
.chat-title { display: flex; align-items: center; gap: 9px; font-weight: 600; color: var(--text); font-size: .98rem; }
.soul-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 10px var(--cyan); animation: soulPulse 2s infinite; }
@keyframes soulPulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .5; transform: scale(.8); } }
.header-buttons { display: flex; gap: 12px; }
.icon-btn { cursor: pointer; opacity: .65; transition: opacity .2s; font-size: 1rem; }
.icon-btn:hover { opacity: 1; }

.chat-messages {
  flex: 1; padding: 22px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 16px;
  scroll-behavior: smooth; max-height: none;
}
.chat-messages::-webkit-scrollbar { width: 8px; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(139, 123, 255, .3); border-radius: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }

/* 欢迎语 */
.initial-message { margin: auto; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 14px; }
.welcome-avatar { width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; font-size: 27px;
  background: linear-gradient(135deg, var(--violet), var(--cyan)); color: #fff; box-shadow: 0 8px 30px -6px rgba(139, 123, 255, .6); animation: soulPulse 3s infinite; }
.welcome-text { line-height: 1.7; }

/* 消息：头像 + 气泡 */
.message { display: flex; gap: 10px; max-width: 88%; align-items: flex-start; position: relative;
  opacity: 1; transform: none;
  animation: msgIn .32s cubic-bezier(.2, .8, .2, 1) both; padding: 0; background: none; border-radius: 0; }
.bot-message { align-self: flex-start; }
.user-message { align-self: flex-end; flex-direction: row-reverse; }
@keyframes msgIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.msg-avatar { flex: 0 0 34px; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  font-size: 15px; font-weight: 600; margin-top: 2px; user-select: none; }
.bot-avatar { background: linear-gradient(135deg, var(--violet), var(--cyan)); color: #fff; box-shadow: 0 4px 14px -4px rgba(139, 123, 255, .7); }
.user-avatar { background: linear-gradient(135deg, var(--indigo), var(--pink)); color: #fff; font-size: 12px; }

.msg-bubble { padding: 11px 15px; border-radius: 16px; line-height: 1.65; position: relative; word-wrap: break-word; overflow-wrap: anywhere; }
.bot-message .msg-bubble { background: rgba(255, 255, 255, .06); border: 1px solid var(--border); color: var(--text); border-top-left-radius: 5px; }
.user-message .msg-bubble { background: linear-gradient(120deg, var(--indigo), var(--violet)); color: #fff; border-top-right-radius: 5px; }

/* 打字光标 */
.typing-cursor { display: inline-block; width: 2px; height: 1.05em; background: var(--violet); vertical-align: text-bottom; margin-left: 2px; animation: blink 1s steps(2, start) infinite; }
@keyframes blink { 0%, 50% { opacity: 1; } 50.01%, 100% { opacity: 0; } }

/* 思考三点 */
.thinking { display: flex; gap: 5px; padding: 14px 16px; background: rgba(255, 255, 255, .06); border: 1px solid var(--border); border-radius: 16px; border-top-left-radius: 5px; align-items: center; }
.thinking span { width: 8px; height: 8px; border-radius: 50%; background: var(--violet); animation: bounce 1.3s infinite ease-in-out; }
.thinking span:nth-child(2) { animation-delay: .16s; }
.thinking span:nth-child(3) { animation-delay: .32s; }
@keyframes bounce { 0%, 70%, 100% { transform: translateY(0); opacity: .35; } 35% { transform: translateY(-7px); opacity: 1; } }

/* markdown 正文 */
.markdown-body > *:first-child { margin-top: 0; }
.markdown-body > *:last-child { margin-bottom: 0; }
.markdown-body p { margin: .45em 0; }
.markdown-body ul, .markdown-body ol { padding-left: 1.4em; margin: .45em 0; }
.markdown-body li { margin: .2em 0; }
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 { margin: .7em 0 .35em; line-height: 1.3; }
.markdown-body a { color: var(--cyan); text-decoration: none; border-bottom: 1px solid rgba(56, 224, 208, .4); }
.markdown-body blockquote { border-left: 3px solid var(--violet); padding: 2px 0 2px 12px; margin: .5em 0; color: var(--muted); }
.markdown-body :not(pre) > code { background: rgba(139, 123, 255, .16); color: #d7d0ff; padding: 2px 6px; border-radius: 6px; font-size: .86em; font-family: 'SF Mono', Consolas, Menlo, monospace; }
.markdown-body pre { background: #0d1117; border: 1px solid var(--border); border-radius: 10px; padding: 14px; overflow-x: auto; margin: .6em 0; position: relative; }
.markdown-body pre code { font-family: 'SF Mono', Consolas, Menlo, monospace; font-size: .85em; line-height: 1.55; background: none; padding: 0; }
.markdown-body table { border-collapse: collapse; margin: .5em 0; font-size: .92em; }
.markdown-body th, .markdown-body td { border: 1px solid var(--border); padding: 6px 10px; }
.markdown-body th { background: rgba(139, 123, 255, .12); }
.markdown-body hr { border: none; border-top: 1px solid var(--border); margin: .8em 0; }

/* 代码复制按钮 */
.code-copy { position: absolute; top: 8px; right: 8px; padding: 3px 10px; font-size: .72rem; color: var(--muted);
  background: rgba(255, 255, 255, .06); border: 1px solid var(--border); border-radius: 6px; cursor: pointer; opacity: 0; transition: opacity .2s; }
.markdown-body pre:hover .code-copy { opacity: 1; }
.code-copy:hover { color: var(--text); background: rgba(139, 123, 255, .2); }

/* 消息操作 */
.message-actions { position: absolute; top: -17px; display: flex; gap: 6px; opacity: 0; transition: opacity .2s; z-index: 2; }
.user-message .message-actions { right: 0; }
.message:hover .message-actions { opacity: 1; }
.message-action-btn { cursor: pointer; padding: 2px 7px; font-size: .85rem; color: var(--muted); background: rgba(13, 11, 40, .95); border: 1px solid var(--border); border-radius: 6px; line-height: 1.3; }
.message-action-btn.edit-btn:hover { color: var(--violet); }
.message-action-btn.delete-btn:hover { color: #ff6b6b; }
.message-action-btn.resend-btn:hover { color: var(--cyan); }
.msg-bubble.editing .message-content { display: none; }
.message-edit-input { width: 100%; min-width: 220px; padding: 8px 12px; border: 1px solid var(--violet); border-radius: 10px; background: rgba(7, 6, 26, .6); color: var(--text); font-family: inherit; font-size: .93rem; resize: vertical; }
.message-edit-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.message-edit-btn { padding: 4px 14px; border: none; border-radius: 6px; cursor: pointer; font-size: .85rem; }
.message-edit-btn.save { background: var(--violet); color: #fff; }
.message-edit-btn.cancel { background: rgba(255, 255, 255, .12); color: var(--text); }

/* 输入区 */
.chat-input-container { display: flex; align-items: flex-end; gap: 10px; padding: 14px 16px; background: rgba(7, 6, 26, .55); border-top: 1px solid var(--border); opacity: 1; flex: 0 0 auto; }
.chat-input { flex: 1; padding: 11px 16px; border: 1px solid var(--border); border-radius: 20px; background: rgba(255, 255, 255, .04); color: var(--text); font-family: inherit; font-size: .95rem; line-height: 1.5; resize: none; max-height: 140px; outline: none; transition: border-color .2s, box-shadow .2s; }
.chat-input::placeholder { color: var(--muted); }
.chat-input:focus { border-color: var(--violet); box-shadow: 0 0 0 3px rgba(139, 123, 255, .18); }
.send-button, .stop-button { flex: 0 0 auto; width: 44px; height: 44px; border: none; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; transition: transform .15s, box-shadow .2s; padding: 0; margin: 0; }
.send-button { background: linear-gradient(135deg, var(--indigo), var(--violet)); color: #fff; }
.send-button:hover { transform: translateY(-1px); box-shadow: 0 8px 22px -8px rgba(139, 123, 255, .9); }
.stop-button { background: rgba(255, 107, 107, .18); color: #ff6b6b; border: 1px solid rgba(255, 107, 107, .4); font-size: .85rem; }
.stop-button:hover { background: rgba(255, 107, 107, .3); }

@media (max-width: 768px) {
  .chat-container, .chat-container.expanded { height: 70vh; }
  .message { max-width: 94%; }
}
