* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  background: #f5f5f5;
}

#app {
  max-width: 900px;
  margin: 0 auto;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: white;
}

.header {
  padding: 20px;
  border-bottom: 1px solid #e0e0e0;
  background: #fff;
}

.header h1 {
  font-size: 24px;
  color: #333;
}

.config {
  margin-top: 15px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.config-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.config input {
  flex: 1;
  min-width: 200px;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
}

.config button {
  padding: 8px 16px;
  background: #4caf50;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}

.config button:hover {
  background: #45a049;
}

.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #fafafa;
}

.message {
  margin-bottom: 20px;
  display: flex;
  gap: 12px;
}

.message.user {
  flex-direction: row-reverse;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: white;
  flex-shrink: 0;
}

.message.user .avatar {
  background: #2196f3;
}

.message.assistant .avatar {
  background: #4caf50;
}

.message-content {
  max-width: 70%;
  padding: 12px 16px;
  border-radius: 12px;
  line-height: 1.6;
  word-wrap: break-word;
}

.message.user .message-content {
  background: #2196f3;
  color: white;
}

.message.assistant .message-content {
  background: white;
  color: #333;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.message-content pre {
  background: #f5f5f5;
  padding: 12px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 10px 0;
}

.message-content code {
  font-family: "Courier New", monospace;
  background: #f5f5f5;
  padding: 2px 6px;
  border-radius: 3px;
}

.message-content pre code {
  background: none;
  padding: 0;
}

.input-container {
  padding: 20px;
  border-top: 1px solid #e0e0e0;
  background: white;
}

.input-wrapper {
  display: flex;
  gap: 10px;
}

.input-wrapper textarea {
  flex: 1;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  resize: none;
  font-size: 14px;
  font-family: inherit;
  height: 60px;
}

.input-wrapper textarea:focus {
  outline: none;
  border-color: #2196f3;
}

.input-wrapper button {
  padding: 12px 24px;
  background: #2196f3;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}

.input-wrapper button:hover:not(:disabled) {
  background: #1976d2;
}

.input-wrapper button:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 8px 0;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: #999;
  border-radius: 50%;
  animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) {
  animation-delay: 0s;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%,
  60%,
  100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-10px);
  }
}

.status {
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  margin-top: 10px;
}

.status.connected {
  background: #e8f5e9;
  color: #2e7d32;
}

.status.disconnected {
  background: #ffebee;
  color: #c62828;
}

/* Markdown 样式 */
.message-body {
  line-height: 1.8;
}

.message-body h1,
.message-body h2,
.message-body h3,
.message-body h4,
.message-body h5,
.message-body h6 {
  margin: 16px 0 12px 0;
  font-weight: 600;
  line-height: 1.4;
}

.message-body h1 {
  font-size: 1.5em;
  border-bottom: 2px solid #e0e0e0;
  padding-bottom: 8px;
}

.message-body h2 {
  font-size: 1.3em;
  border-bottom: 1px solid #e0e0e0;
  padding-bottom: 6px;
}

.message-body h3 {
  font-size: 1.15em;
}

.message-body h4 {
  font-size: 1.1em;
}

.message-body h5,
.message-body h6 {
  font-size: 1em;
}

.message-body strong {
  font-weight: 600;
}

.message-body em {
  font-style: italic;
}

.message-body del {
  text-decoration: line-through;
  opacity: 0.7;
}

.message-body a {
  color: #2196f3;
  text-decoration: none;
}

.message-body a:hover {
  text-decoration: underline;
}

.message-body ul,
.message-body ol {
  margin: 12px 0;
  padding-left: 24px;
}

.message-body li {
  margin: 4px 0;
}

.message-body blockquote {
  border-left: 4px solid #e0e0e0;
  padding-left: 16px;
  margin: 12px 0;
  color: #666;
  font-style: italic;
}

.message-body hr {
  border: none;
  border-top: 1px solid #e0e0e0;
  margin: 16px 0;
}

.message-body table {
  border-collapse: collapse;
  width: 100%;
  margin: 12px 0;
}

.message-body th,
.message-body td {
  border: 1px solid #ddd;
  padding: 8px 12px;
  text-align: left;
}

.message-body th {
  background: #f5f5f5;
  font-weight: 600;
}

/* 代码块样式 */
.code-block {
  position: relative;
  margin: 16px 0;
  background: #f8f9fa;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #e0e0e0;
}

.code-lang {
  background: #e9ecef;
  padding: 6px 12px;
  font-size: 12px;
  color: #666;
  font-family: "Courier New", monospace;
  border-bottom: 1px solid #e0e0e0;
}

.code-block pre {
  background: transparent;
  padding: 12px;
  margin: 0;
  overflow-x: auto;
}

.code-block pre code {
  background: transparent;
  padding: 0;
  font-size: 14px;
  line-height: 1.5;
}

/* 消息操作区域 */
.message-actions {
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid #f0f0f0;
  display: flex;
  justify-content: flex-end;
}

.copy-btn {
  padding: 4px 12px;
  background: transparent;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 12px;
  color: #666;
  cursor: pointer;
  transition: all 0.2s;
}

.copy-btn:hover {
  background: #f5f5f5;
  border-color: #ccc;
}

.copy-btn.copied {
  background: #4caf50;
  color: white;
  border-color: #4caf50;
}

/* 用户消息中的 Markdown 样式调整 */
.message.user .message-body a {
  color: #fff;
  text-decoration: underline;
}

.message.user .message-body code {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

.message.user .message-body .code-block {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.message.user .message-body .code-lang {
  background: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.9);
  border-color: rgba(255, 255, 255, 0.2);
}
