* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    background-color: #FFFFFF;
    color: #000000;
    line-height: 1.5;
}

.header {
    background-color: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(8px);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
}

.container {
    max-width: 1024px;
    margin: 0 auto;
    padding: 0.75rem 1rem;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 0;
}

.logo {
    flex-shrink: 0;
    font-size: 1.25rem;
    font-weight: 500;
    color: #000000;
}

.author-link {
    color: #666666;
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.2s;
}

.author-link:hover {
    color: #000000;
}

.chat-container {
    padding-left: 1rem;
    padding-right: 1rem;
    height: calc(100vh - 64px);
    display: flex;
    flex-direction: column;
    z-index: 1;
    padding-top: 4rem;
    transition: padding-left 0.3s ease;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    max-width: 1024px;
    margin: 0 auto;
    width: 100%;
}

.messages::-webkit-scrollbar {
    width: 4px;
}

.messages::-webkit-scrollbar-track {
    background: transparent;
}

.messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.welcome-message {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.welcome-content {
    max-width: 400px;
}

.welcome-content h2 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    color: #000000;
}

.welcome-content p {
    font-size: 0.875rem;
    color: #666666;
}

.message {
    padding: 1.5rem 0;
    opacity: 0;
    transform: translateY(10px);
    animation: messageAppear 0.2s ease forwards;
}

.message.ai {
    background-color: rgba(0, 0, 0, 0.03);
}

.message-content {
    max-width: 1024px;
    margin: 0 auto;
    display: flex;
    align-items: flex-start;
}

.avatar {
    width: 2rem;
    height: 2rem;
    margin-right: 1rem;
    flex-shrink: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
}

.user .avatar {
    background-color: #2563EB;
}

.ai .avatar {
    background-color: rgba(255, 255, 255, 0.1);
}

.message-text {
    flex: 1;
    font-size: 0.875rem;
    line-height: 1.5rem;
    color: #000000;
}

.input-container {
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    background-color: rgba(255, 255, 255, 0.05);
    padding: 1rem;
}

.chat-form {
    max-width: 1024px;
    margin: 0 auto;
    position: relative;
}

#userInput {
    width: 100%;
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    background-color: rgba(0, 0, 0, 0.05);
    border: none;
    border-radius: 0.5rem;
    color: #000000;
    font-size: 0.875rem;
}

#userInput:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.5);
}

#userInput::placeholder {
    color: #666666;
}

#sendButton {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    color: #9CA3AF;
    transition: color 0.2s;
}

#sendButton:hover {
    color: #2563EB;
}

#sendButton:disabled {
    color: #4B5563;
    cursor: not-allowed;
}

.send-icon {
    width: 1.25rem;
    height: 1.25rem;
    fill: currentColor;
}

.loading {
    display: flex;
    gap: 0.5rem;
}

.loading-dot {
    width: 0.5rem;
    height: 0.5rem;
    background-color: rgba(37, 99, 235, 0.5);
    border-radius: 50%;
    animation: bounce 0.5s infinite;
}

.loading-dot:nth-child(2) {
    animation-delay: 0.1s;
}

.loading-dot:nth-child(3) {
    animation-delay: 0.2s;
}

@keyframes messageAppear {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes bounce {
    50% {
        transform: translateY(-4px);
    }
}

.message.thought {
    background-color: transparent;
    margin-bottom: 0;
}

.message.answer {
    background-color: rgba(255, 255, 255, 0.05);
}

.thought-label {
    position: absolute;
    top: -0.5rem;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.75rem;
    color: #9CA3AF;
    background-color: rgba(13, 15, 17, 0.8);
    padding: 0.125rem 0.5rem;
    border-radius: 1rem;
    white-space: nowrap;
}

.message-text.thought {
    color: #666666;
    font-size: 0.8125rem;
    opacity: 0.8;
}

/* 修改光标样式 */
.message.ai .message-text:not(.completed)::after {
    content: '|';
    animation: cursor 1s infinite;
    font-weight: 100;
    color: #9CA3AF;
    margin-left: 1px;
}

@keyframes cursor {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* 调整间距 */
.message.thought {
    padding-bottom: 0.5rem;
}

.message.answer {
    padding-top: 1rem;
}

/* 思考过程和答案之间的分隔 */
.message.thought + .message.answer {
    position: relative;
}

.message.thought + .message.answer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
}

.message-text code {
    background-color: rgba(255, 255, 255, 0.1);
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
    font-family: monospace;
}

/* 当文本输入完成后隐藏光标 */
.message.ai .message-text.completed::after {
    display: none;
}

.left-section {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.model-selector {
    position: relative;
    width: auto;
}

.model-select-button {
    background: none;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 0.5rem;
    padding: 0.875rem 1.25rem;
    color: #000000;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.2s;
    height: 3rem;
}

.model-select-button:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.menu-icon {
    width: 1.5rem;
    height: 1.5rem;
}

.model-dropdown {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 360px;
    background: #FFFFFF;
    border-right: 1px solid rgba(0, 0, 0, 0.1);
    padding: 2rem 1.5rem;
    box-shadow: 4px 0 6px -1px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transform: translateX(-100%);
    transition: all 0.2s;
    overflow-y: auto;
}

.model-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

.model-category {
    margin-bottom: 2rem;
}

.model-category h4 {
    color: #666666;
    font-size: 1rem;
    margin-bottom: 1rem;
    padding: 0 0.5rem;
}

.model-option {
    width: 100%;
    background: none;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 0.75rem;
    padding: 1.25rem;
    margin-bottom: 0.75rem;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
}

.model-option:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.model-option.active {
    background-color: rgba(37, 99, 235, 0.1);
    border-color: #2563EB;
}

.model-option strong {
    display: block;
    color: #000000;
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
}

.model-option span {
    display: block;
    color: #666666;
    font-size: 0.875rem;
    line-height: 1.5;
}

.message-text.image {
    text-align: center;
}

.generated-image {
    max-width: 100%;
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* 图片查看器样式 */
.image-viewer {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.9);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9998;
    cursor: pointer;
}

.image-viewer.active {
    display: flex;
}

.image-viewer-content {
    position: relative;
    max-width: 90%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.image-viewer-content img {
    max-width: 100%;
    max-height: calc(90vh - 60px);
    object-fit: contain;
    border-radius: 0.5rem;
}

.save-button {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background-color: #2563eb;
    color: white;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.2s;
}

.save-button:hover {
    background-color: #1d4ed8;
}

.download-icon {
    width: 1.25rem;
    height: 1.25rem;
    fill: currentColor;
}

/* 移动端样式调整 */
@media (max-width: 768px) {
    /* 头部样式调整 */
    .header-content {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 0.5rem;
    }

    .left-section {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .model-selector {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        width: 100%;
        margin-left: 0;
        padding-left: 0;
        border-left: none;
        gap: 0.5rem;
    }

    .model-button {
        width: 100%;
        text-align: center;
        padding: 0.5rem 0.25rem;
        font-size: 0.75rem;
        white-space: nowrap;
    }

    /* 消息内容调整 */
    .message-content {
        padding: 0 0.5rem;
    }

    .avatar {
        width: 1.75rem;
        height: 1.75rem;
        margin-right: 0.75rem;
        font-size: 0.75rem;
    }

    .message-text {
        font-size: 0.875rem;
    }

    /* 输入框调整 */
    .input-container {
        padding: 0.75rem;
    }

    #userInput {
        padding: 0.625rem 2.25rem 0.625rem 0.75rem;
        font-size: 0.875rem;
    }

    /* 图片查看器调整 */
    .image-viewer-content {
        max-width: 95%;
    }

    .save-button {
        padding: 0.625rem 1.25rem;
        font-size: 0.875rem;
    }

    /* 欢迎消息调整 */
    .welcome-content {
        padding: 0 1rem;
    }

    .welcome-content h2 {
        font-size: 1.125rem;
    }

    .welcome-content p {
        font-size: 0.8125rem;
    }

    .model-dropdown {
        width: 100%;
    }

    .header {
        top: 90px;
    }

    .chat-container {
        padding-left: 0;
        padding-top: calc(90px + 4rem);
    }
}

/* 超小屏幕设备 */
@media (max-width: 360px) {
    .model-selector {
        grid-template-columns: 1fr;
    }

    .model-button {
        font-size: 0.75rem;
    }
}

.thinking-text {
    color: #9CA3AF;
    font-size: 0.875rem;
}

.thinking-dots {
    display: inline-block;
    animation: dotsAnimation 1.4s infinite;
    color: #9CA3AF;
}

@keyframes dotsAnimation {
    0%, 20% { opacity: 0; }
    40% { opacity: 0.2; }
    60% { opacity: 0.7; }
    80% { opacity: 1; }
}

/* 模型选择按钮 */
.model-select-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: none;
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: #000000;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    margin-left: 1.5rem;
}

.model-select-button:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.model-arrow {
    width: 1rem;
    height: 1rem;
    transition: transform 0.2s;
}

/* 模态框样式 */
.model-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.model-modal.active {
    display: flex;
}

.model-modal-content {
    background-color: #FFFFFF;
    border-radius: 0.75rem;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.model-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.model-modal-header h3 {
    font-size: 1.125rem;
    font-weight: 500;
    color: #000000;
}

.close-modal {
    background: none;
    border: none;
    color: #9CA3AF;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
}

.close-modal:hover {
    color: #E5E7EB;
}

.model-list {
    padding-top: 1rem;
}

.model-category:last-child {
    margin-bottom: 0;
}

.model-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.model-info strong {
    color: #000000;
    font-size: 0.875rem;
}

.model-info span {
    color: #666666;
    font-size: 0.75rem;
}

/* 移动端适配 */
@media (max-width: 768px) {
    .model-modal-content {
        width: 95%;
        margin: 1rem;
    }

    .model-option {
        padding: 0.75rem;
    }
}

.loading-message {
    transition: opacity 0.5s;
}

.loading-message.fade-out {
    opacity: 0;
}

/* 分辨率选择模态框 */
.resolution-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.resolution-modal.active {
    display: flex;
}

.resolution-modal-content {
    background-color: #1F2937;
    border-radius: 0.75rem;
    width: 90%;
    max-width: 400px;
}

.resolution-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.resolution-modal-header h3 {
    font-size: 1.125rem;
    font-weight: 500;
    color: #E5E7EB;
}

.resolution-list {
    padding: 1rem;
    display: grid;
    gap: 0.5rem;
}

.resolution-option {
    width: 100%;
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.5rem;
    padding: 0.75rem;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.resolution-option:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.resolution-option strong {
    color: #E5E7EB;
    font-size: 0.875rem;
}

.resolution-option span {
    color: #9CA3AF;
    font-size: 0.75rem;
}

/* Markdown 样式 */
.message-text pre {
    background-color: #1a1a1a;
    border-radius: 6px;
    padding: 1rem;
    margin: 0.5rem 0;
    overflow-x: auto;
    position: relative;
}

.message-text code {
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 0.9em;
}

.message-text p code {
    background-color: rgba(255, 255, 255, 0.1);
    padding: 0.2em 0.4em;
    border-radius: 3px;
}

.message-text blockquote {
    border-left: 4px solid #4a5568;
    margin: 0.5rem 0;
    padding-left: 1rem;
    color: #a0aec0;
}

.copy-button {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    color: #e2e8f0;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s;
}

.copy-button:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* 数学公式样式 */
.math-block {
    overflow-x: auto;
    padding: 1rem;
    margin: 0.5rem 0;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
}

.katex-display {
    margin: 0 !important;
}

.katex {
    font-size: 1.1em;
}

/* 删除之前的下拉菜单相关样式，改用新的布局 */
.model-select-page {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #FFFFFF;
    display: none;
}

.model-select-page.active {
    display: flex;
    flex-direction: column;
}

.model-select-header {
    padding: 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.model-select-header h3 {
    font-size: 1.25rem;
    font-weight: 500;
    color: #000000;
}

.model-select-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #666666;
    cursor: pointer;
    padding: 0.5rem;
    line-height: 1;
}

.model-select-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.model-category {
    margin-bottom: 2rem;
}

.model-category h4 {
    color: #666666;
    font-size: 1rem;
    margin-bottom: 1rem;
    padding: 0 0.5rem;
}

.model-item {
    width: 100%;
    background: none;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 0.75rem;
    padding: 1rem;
    margin-bottom: 0.75rem;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
}

.model-item:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.model-item.active {
    background-color: rgba(37, 99, 235, 0.1);
    border-color: #2563EB;
}

.model-item strong {
    display: block;
    color: #000000;
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.model-item span {
    display: block;
    color: #666666;
    font-size: 0.875rem;
    line-height: 1.5;
}

/* 主题切换按钮样式 */
.theme-toggle {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: #9CA3AF;
    transition: color 0.2s;
    position: relative;
    width: 2rem;
    height: 2rem;
}

.theme-toggle:hover {
    color: #E5E7EB;
}

.theme-toggle svg {
    width: 1.25rem;
    height: 1.25rem;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: opacity 0.2s, transform 0.2s;
}

.sun-icon {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(-90deg);
}

.moon-icon {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(0);
}

[data-theme="light"] .sun-icon {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(0);
}

[data-theme="light"] .moon-icon {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(90deg);
}

/* 修复移动端样式 */
@media (max-width: 768px) {
    .dropdown-menu {
        width: 100%;
        left: 0;
        padding: 1rem;
    }

    .dropdown-item {
        padding: 1rem;
    }
}

/* 确保聊天容器在菜单下方 */
.chat-container {
    z-index: 1;
}

/* 确保其他模态框不会覆盖菜单 */
.image-viewer,
.resolution-modal {
    z-index: 9998;
}

/* 顶部模型选择标签样式 */
.model-tabs {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding: 0.5rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
    flex: 1;
    justify-content: center;
}

.model-tabs::-webkit-scrollbar {
    display: none; /* Chrome, Safari */
}

.model-tab {
    background: none;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 0.5rem;
    padding: 0.5rem 1rem;
    color: #666666;
    font-size: 0.875rem;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.model-tab:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: #000000;
}

.model-tab.active {
    background-color: rgba(37, 99, 235, 0.1);
    border-color: #2563EB;
    color: #2563EB;
}

/* 头部布局 */
.header-content {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.right-section {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* 清空历史记录按钮 */
.clear-history-button {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: #666666;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
    margin-right: 1rem;
}

.clear-history-button:hover {
    color: #ff4444;
}

.trash-icon {
    width: 1.25rem;
    height: 1.25rem;
}

/* 移动端适配 */
@media (max-width: 768px) {
    .header-content {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 0.5rem;
    }

    .model-tabs {
        flex: 1;
        width: 100%;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        padding: 0.5rem 0;
    }

    .model-tab {
        font-size: 0.75rem;
        padding: 0.375rem 0.75rem;
    }
}