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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e8eb 100%);
    height: 100vh;
    color: #2c3e50;
}

.container {
    max-width: 1200px;
    margin: 20px auto;
    padding: 0 20px;
    height: calc(100vh - 40px);
}

.chat-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
    height: 100%;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    will-change: transform;
    scroll-behavior: smooth;
}

.chat-header {
    padding: 24px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    background: rgba(255, 255, 255, 0.9);
    border-radius: 16px 16px 0 0;
}

.chat-header h1 {
    font-size: 1.5rem;
    color: #1a1a1a;
    text-align: center;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-gutter: stable;
}

.chat-messages::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

.chat-messages::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 6px;
    margin: 6px 0;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 122, 255, 0.3);
    border-radius: 6px;
    border: 3px solid transparent;
    background-clip: padding-box;
    min-height: 50px;
    transition: all 0.3s ease;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 122, 255, 0.5);
    border: 2px solid transparent;
}

.chat-messages::-webkit-scrollbar-thumb:active {
    background: rgba(0, 122, 255, 0.7);
    border: 2px solid transparent;
}

.chat-messages {
    scrollbar-color: rgba(0, 122, 255, 0.3) rgba(0, 0, 0, 0.05);
}

.message {
    margin-bottom: 24px;
    display: flex;
    flex-direction: column;
    max-width: 92%;
    transition: transform 0.2s ease;
}

.message-content {
    padding: 16px 20px;
    border-radius: 16px;
    line-height: 1.6;
    font-size: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    position: relative;
}

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

.ai-message {
    align-items: flex-start;
    margin-right: auto;
}

.user-message .message-content {
    background: linear-gradient(135deg, #007AFF, #0056b3);
    color: white;
}

.ai-message .message-content {
    background: #ffffff;
    color: #1a1a1a;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

/* AI消息内容样式优化 */
.ai-message .message-content {
    font-size: 15px;
    line-height: 1.8;
    color: #2c3e50;
    letter-spacing: 0.3px;
    padding: 24px 28px;
    max-width: 100%;
}

/* 段落样式优化 */
.ai-message .message-content p {
    margin: 16px 0;
    text-align: justify;
    text-justify: inter-ideograph;
    hyphens: auto;
    max-width: 66ch;
    margin-left: auto;
    margin-right: auto;
}

.ai-message .message-content p:first-child {
    margin-top: 0;
}

.ai-message .message-content p:last-child {
    margin-bottom: 0;
}

/* 标题样式优化 */
.ai-message .message-content h1,
.ai-message .message-content h2,
.ai-message .message-content h3,
.ai-message .message-content h4,
.ai-message .message-content h5,
.ai-message .message-content h6 {
    margin: 28px auto 20px;
    max-width: 66ch;
    line-height: 1.4;
    letter-spacing: -0.02em;
}

.ai-message .message-content h1 { font-size: 1.8em; }
.ai-message .message-content h2 { font-size: 1.5em; }
.ai-message .message-content h3 { font-size: 1.3em; }
.ai-message .message-content h4 { font-size: 1.2em; }
.ai-message .message-content h5 { font-size: 1.1em; }
.ai-message .message-content h6 { font-size: 1em; }

/* 列表样式优化 */
.ai-message .message-content ul,
.ai-message .message-content ol {
    margin: 16px auto;
    padding-left: 24px;
    max-width: 66ch;
}

.ai-message .message-content li {
    margin: 8px 0;
    line-height: 1.7;
}

/* 引用块样式优化 */
.ai-message .message-content blockquote {
    margin: 16px auto;
    padding: 16px 24px;
    background: rgba(0, 122, 255, 0.05);
    border-left: 4px solid #007AFF;
    border-radius: 4px;
    color: #4a5568;
    max-width: 66ch;
}

/* 强调文本样式 */
.ai-message .message-content strong {
    font-weight: 600;
    color: #1a1a1a;
}

.ai-message .message-content em {
    font-style: italic;
    color: #2d3748;
}

/* 链接样式 */
.ai-message .message-content a {
    color: #007AFF;
    text-decoration: none;
    border-bottom: 1px solid rgba(0, 122, 255, 0.2);
    transition: all 0.2s ease;
}

.ai-message .message-content a:hover {
    border-bottom-color: #007AFF;
    background: rgba(0, 122, 255, 0.05);
}

/* 代码样式优化 */
.ai-message .message-content code {
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 14px;
    padding: 2px 6px;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 4px;
    color: #1a1a1a;
}

.ai-message .message-content pre code {
    padding: 20px 24px;
    background: transparent;
    color: #ffffff;
}

/* 分隔线样式优化 */
.ai-message .message-content hr {
    margin: 28px auto;
    max-width: 66ch;
    height: 1px;
    background: rgba(0, 0, 0, 0.1);
}

/* 表格样式优化 */
.ai-message .message-content table {
    width: auto;
    max-width: 66ch;
    margin: 20px auto;
    font-size: 14px;
}

/* 优化消息气泡样式 */
.ai-message .message-content {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
    transition: all 0.3s ease;
}

.ai-message .message-content:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
    transform: translateY(-1px);
}

/* 代码块顶部栏 */
.md-code-block {
    position: relative;
    margin: 20px auto;
    max-width: 66ch;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    background: #282c34;
    transition: all 0.3s ease;
}

.md-code-block:hover {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
    transform: translateY(-1px);
}

.md-code-block-banner-wrap {
    position: relative;
    background: #343942;
    border-bottom: 1px solid #3d434d;
}

.md-code-block-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    font-size: 13px;
    color: #abb2bf;
}

.md-code-block-infostring {
    user-select: none;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    text-transform: lowercase;
    font-weight: 500;
}

.md-code-block-action {
    display: flex;
    align-items: center;
}

.ds-markdown-code-copy-button {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #abb2bf;
    cursor: pointer;
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 6px;
    transition: all 0.2s;
    user-select: none;
    font-weight: 500;
}

.ds-markdown-code-copy-button:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

/* 输入区域样式 */
.chat-input {
    padding: 24px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 0 0 16px 16px;
}

.input-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
}

textarea {
    width: 100%;
    padding: 16px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    resize: none;
    font-size: 15px;
    line-height: 1.5;
    background: #ffffff;
    color: #1a1a1a;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.02);
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    -webkit-border-radius: 12px;
    -webkit-tap-highlight-color: transparent;
}

textarea:focus {
    outline: none;
    border-color: #007AFF;
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.1);
}

/* 字数统计样式 */
.char-count {
    font-size: 14px;
    color: #999;
    user-select: none;
}

.char-count.warning {
    color: #ff4d4f;
}

button {
    padding: 0 28px;
    height: 40px;
    background: linear-gradient(135deg, #007AFF, #0056b3);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(0, 122, 255, 0.2);
}

button:hover {
    background: linear-gradient(135deg, #0056b3, #003d80);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
}

button:disabled {
    background: #cccccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* 加载动画 */
.typing {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.typing span {
    width: 8px;
    height: 8px;
    background: linear-gradient(135deg, #007AFF, #0056b3);
    border-radius: 50%;
    animation: typing 1s infinite ease-in-out;
}

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

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

@keyframes typing {
    0%, 100% { transform: scale(1); opacity: 0.4; }
    50% { transform: scale(1.2); opacity: 1; }
}

/* 优化文本间距 */
.ai-message .message-content * + * {
    margin-top: 1em;
}

/* 优化段落缩进 */
.ai-message .message-content p + p {
    text-indent: 2em;
}

/* 优化列表项间距 */
.ai-message .message-content li + li {
    margin-top: 0.8em;
}

/* 序号步骤样式优化 */
.ai-message .message-content p {
    margin: 16px 0;
    text-align: justify;
    text-justify: inter-ideograph;
    hyphens: auto;
    max-width: 66ch;
    margin-left: auto;
    margin-right: auto;
}

/* 序号段落样式 */
.ai-message .message-content p + p {
    margin-bottom: 1.5em;
}

/* 带序号的段落样式 */
.ai-message .message-content p[data-number] {
    position: relative;
    padding-left: 2em;
    margin: 0.5em 0;
}

.ai-message .message-content p[data-number]::before {
    content: attr(data-number);
    position: absolute;
    left: 0;
    color: #666;
    font-weight: 500;
}

.ai-message .message-content p[data-number] + p:not([data-number]) {
    margin-left: 2em;
    margin-bottom: 1em;
}

/* 序号列表样式优化 */
.ai-message .message-content ol {
    margin: 20px auto;
    padding-left: 2em;
    max-width: 66ch;
    counter-reset: item;
}

.ai-message .message-content ol li {
    margin: 1em 0;
    line-height: 1.7;
    position: relative;
    padding-left: 0.5em;
}

.ai-message .message-content ol li::before {
    position: absolute;
    left: -2em;
    width: 2em;
    text-align: right;
    padding-right: 0.5em;
}

/* 序号间距优化 */
.ai-message .message-content p[data-number] + p:not([data-number]) {
    margin-top: 0.5em;
    padding-left: 2.5em;
}

/* 移动端适配 */
@media screen and (max-width: 768px) {
    .message {
        max-width: 95%;
    }
    
    .ai-message .message-content {
        padding: 20px 24px;
    }
    
    .ai-message .message-content p,
    .ai-message .message-content ul,
    .ai-message .message-content ol,
    .ai-message .message-content blockquote,
    .ai-message .message-content table,
    .md-code-block {
        max-width: 100%;
    }
    
    .ai-message .message-content p[data-number],
    .ai-message .message-content p[data-number] + p:not([data-number]) {
        padding-left: 2em;
    }
}

@media (max-width: 768px) {
    textarea {
        font-size: 16px; /* 防止iOS自动缩放 */
        padding: 12px;
        min-height: 44px; /* iOS默认点击区域最小高度 */
        line-height: 1.4;
    }
    
    .chat-input {
        padding: 10px;
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }
    
    .input-container {
        margin: 0;
    }
    
    .textarea-wrapper {
        margin-bottom: env(safe-area-inset-bottom, 0);
    }
    
    #sendButton {
        height: 44px; /* iOS默认点击区域最小高度 */
        min-width: 60px;
        padding: 0 15px;
    }
} 
