:root {
    --bg-color: #ffffff;
    --text-color: #1a1a1a;
    --primary-color: #6366f1;
    --primary-hover: #5855eb;
    --secondary-color: #f8fafc;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-secondary: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

[data-theme="dark"] {
    --bg-color: #0f0f23;
    --text-color: #e2e8f0;
    --primary-color: #818cf8;
    --primary-hover: #6366f1;
    --secondary-color: #1e1e3a;
    --border-color: #374151;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.2);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.25), 0 2px 4px -2px rgb(0 0 0 / 0.25);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.25), 0 4px 6px -4px rgb(0 0 0 / 0.25);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.25), 0 8px 10px -6px rgb(0 0 0 / 0.25);
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-secondary: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: background-color 0.3s, color 0.3s;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', sans-serif;
    background: var(--bg-color);
    background-image: 
        radial-gradient(circle at 1px 1px, rgba(99, 102, 241, 0.05) 1px, transparent 0);
    background-size: 20px 20px;
    color: var(--text-color);
    height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.6;
    font-feature-settings: 'cv03', 'cv04', 'cv11';
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
    flex: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 0 32px;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    background: var(--bg-color);
    backdrop-filter: blur(8px);
    z-index: 100;
    margin-bottom: 32px;
}

/* 公告横幅样式 */
.announcement {
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
    margin-bottom: 24px;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    overflow: hidden;
    animation: slideDown 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.announcement-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
}

.announcement-text {
    flex: 1;
    font-size: 15px;
    line-height: 1.5;
}

.announcement-text a {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: underline;
}

.announcement-text a:hover {
    color: white;
    text-decoration: none;
}

.announcement-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 16px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.announcement-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

[data-theme="dark"] .announcement {
    background: linear-gradient(135deg, #818cf8, #6366f1);
}

/* 响应式公告样式 */
@media (max-width: 768px) {
    .announcement-content {
        padding: 12px 16px;
    }
    
    .announcement-text {
        font-size: 14px;
    }
    
    .announcement-close {
        width: 28px;
        height: 28px;
        font-size: 16px;
        margin-left: 12px;
    }
}

.header h1 {
    font-size: 2rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.025em;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

.model-select {
    padding: 12px 20px;
    border-radius: 12px;
    border: 2px solid var(--border-color);
    background: var(--bg-color);
    color: var(--text-color);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236366f1' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 44px;
    min-width: 200px;
}

.model-select:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.model-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.theme-toggle {
    background: var(--secondary-color);
    border: none;
    cursor: pointer;
    padding: 12px;
    border-radius: 12px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
    color: var(--text-color);
}

.theme-toggle:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px 0;
    margin: 24px 0;
    scroll-behavior: smooth;
}

/* 美化滚动条样式 */
.chat-container::-webkit-scrollbar {
    width: 6px;
}

.chat-container::-webkit-scrollbar-track {
    background: transparent;
}

.chat-container::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 6px;
    opacity: 0.3;
}

.chat-container::-webkit-scrollbar-thumb:hover {
    opacity: 0.6;
}

/* Firefox滚动条样式 */
.chat-container {
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) transparent;
}

.message {
    display: flex;
    gap: 16px;
    margin-bottom: 32px;
    max-width: 900px;
    opacity: 0;
    animation: messageSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.avatar {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--gradient-primary);
    flex-shrink: 0;
    background-size: cover;
    background-position: center;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.avatar::before {
    content: '';
    position: absolute;
    inset: 2px;
    border-radius: 10px;
    background: white;
    z-index: 1;
}

.avatar::after {
    content: '';
    position: absolute;
    inset: 2px;
    border-radius: 10px;
    background-image: inherit;
    background-size: cover;
    background-position: center;
    z-index: 2;
}

.content {
    padding: 20px 24px;
    border-radius: 16px;
    background: var(--secondary-color);
    max-width: 70%;
    line-height: 1.7;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    position: relative;
    font-size: 15px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    overflow-x: hidden;
}

.user-message .content {
    background: var(--gradient-primary);
    color: white;
    border: none;
    box-shadow: var(--shadow-md);
}

.content::before {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    border-style: solid;
}

.message:not(.user-message) .content::before {
    left: -8px;
    top: 20px;
    border-width: 8px 8px 8px 0;
    border-color: transparent var(--secondary-color) transparent transparent;
}

.user-message .content::before {
    right: -8px;
    top: 20px;
    border-width: 8px 0 8px 8px;
    border-color: transparent transparent transparent var(--primary-color);
}

.input-container {
    position: relative;
    margin-top: auto;
    background: var(--bg-color);
    border-radius: 16px;
    padding: 8px;
    border: 2px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(8px);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.input-container:focus-within {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-xl), 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.input-box {
    width: 100%;
    padding: 16px 130px 16px 20px;
    border: none;
    border-radius: 12px;
    background: transparent;
    color: var(--text-color);
    resize: none;
    min-height: 24px;
    max-height: 200px;
    font-size: 15px;
    line-height: 1.5;
    font-family: inherit;
    outline: none;
    transition: all 0.2s ease;
}

.input-box::placeholder {
    color: var(--text-color);
    opacity: 0.5;
}

.send-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    padding: 12px 24px;
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-md);
    min-width: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.send-btn:hover:not(:disabled) {
    transform: translateY(-50%) translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.send-btn:active {
    transform: translateY(-50%) translateY(0px);
}

.send-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Markdown 样式 */
.content h1 { font-size: 1.8em; font-weight: 700; margin: 1em 0 0.5em; }
.content h2 { font-size: 1.5em; font-weight: 600; margin: 1em 0 0.5em; }
.content h3 { font-size: 1.3em; font-weight: 600; margin: 1em 0 0.5em; }
.content h4 { font-size: 1.2em; font-weight: 600; margin: 1em 0 0.5em; }
.content h5 { font-size: 1.1em; font-weight: 600; margin: 1em 0 0.5em; }
.content h6 { font-size: 1em; font-weight: 600; margin: 1em 0 0.5em; }

.content p { margin: 0.5em 0; }
.content ul, .content ol { margin: 0.5em 0; padding-left: 1.5em; }
.content li { margin: 0.3em 0; }

.content code {
    background-color: rgba(0, 0, 0, 0.1);
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-family: 'Consolas', monospace;
}

.content pre {
    background-color: rgba(0, 0, 0, 0.05);
    padding: 1em;
    border-radius: 5px;
    overflow-x: hidden;
    word-wrap: break-word;
    white-space: pre-wrap;
    margin: 1em 0;
}

.content pre code {
    background-color: transparent;
    padding: 0;
}

.content blockquote {
    border-left: 4px solid var(--primary-color);
    margin: 1em 0;
    padding-left: 1em;
    color: var(--text-color);
    opacity: 0.8;
}

.content table {
    border-collapse: collapse;
    width: 100%;
    margin: 1em 0;
}

.content th, .content td {
    border: 1px solid var(--border-color);
    padding: 0.5em;
    text-align: left;
}

.content th {
    background-color: rgba(0, 0, 0, 0.05);
}

.content img {
    max-width: 100%;
    height: auto;
    border-radius: 5px;
    margin: 1em 0;
}

.content a {
    color: var(--primary-color);
    text-decoration: none;
}

.content a:hover {
    text-decoration: underline;
}

/* 暗色主题适配 */
[data-theme="dark"] .content code {
    background-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .content pre {
    background-color: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .content th {
    background-color: rgba(255, 255, 255, 0.05);
}

/* 简化后的页脚样式 */
.footer {
    background-color: var(--secondary-color);
    border-top: 1px solid var(--border-color);
    padding: 1rem 0;
    margin-top: auto;
}

.footer-bottom {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.copyright {
    color: var(--text-color);
    opacity: 0.7;
    font-size: 0.85rem;
}

.copyright a {
    color: var(--text-color);
    text-decoration: none;
    opacity: 0.8;
}

.copyright a:hover {
    opacity: 1;
    color: var(--primary-color);
}

.beian {
    color: var(--text-color);
    opacity: 0.7;
    font-size: 0.85rem;
}

.beian a {
    color: var(--text-color);
    text-decoration: none;
    opacity: 0.8;
}

.beian a:hover {
    opacity: 1;
    color: var(--primary-color);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 10px;
        padding-bottom: 30px;
    }

    .header {
        padding: 15px 0;
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }

    .header h1 {
        font-size: 1.5em;
    }

    .header-controls {
        width: 100%;
        justify-content: space-between;
    }

    .model-select {
        padding: 10px 14px;
        padding-right: 35px;
        font-size: 13px;
        border-radius: 20px;
        background-size: 14px;
        background-position: right 10px center;
    }

    .message {
        max-width: 100%;
        gap: 10px;
        margin-bottom: 20px;
    }

    .content {
        max-width: 85%;
        padding: 12px 15px;
        font-size: 0.95em;
    }

    .avatar {
        width: 35px;
        height: 35px;
    }

    .input-box {
        padding: 12px 100px 12px 15px;
        font-size: 0.95em;
    }

    .send-btn {
        padding: 6px 15px;
        font-size: 0.9em;
    }

    /* 移动端 Markdown 样式调整 */
    .content h1 { font-size: 1.5em; }
    .content h2 { font-size: 1.3em; }
    .content h3 { font-size: 1.2em; }
    .content h4 { font-size: 1.1em; }
    .content h5 { font-size: 1em; }
    .content h6 { font-size: 0.95em; }

    .content pre {
        font-size: 0.9em;
        padding: 0.8em;
    }

    .content table {
        font-size: 0.9em;
    }

    .footer-bottom {
        flex-direction: column;
        text-align: center;
        padding: 0 15px;
        gap: 0.5rem;
    }

    .copyright,
    .beian {
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.3em;
    }

    .content {
        max-width: 90%;
        padding: 10px 12px;
        font-size: 0.9em;
    }

    .avatar {
        width: 30px;
        height: 30px;
    }

    .input-box {
        padding: 10px 90px 10px 12px;
        min-height: 45px;
    }

    .send-btn {
        padding: 5px 12px;
        font-size: 0.85em;
    }
}

/* 添加触摸设备优化 */
@media (hover: none) {
    .send-btn:hover {
        opacity: 1;
    }

    .theme-toggle:hover {
        background-color: transparent;
    }
}

/* 确保在移动设备上输入框不会被键盘遮挡 */
@media (max-height: 600px) {
    .input-container {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background-color: var(--bg-color);
        padding: 10px;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
        z-index: 100;
    }

    [data-theme="dark"] .input-container {
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
    }

    .chat-container {
        margin-bottom: 80px;
    }
}