:root {
    --bg-dark: #0f172a;
    --sidebar-bg: #1e293b;
    --accent: #f39c12;
    --text-main: #f8fafc;
    --text-dim: #94a3b8;
    --card-bg: #334155;
    --glass: rgba(30, 41, 59, 0.7);
}

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

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* 侧边栏样式 */
.sidebar {
    width: 280px;
    background-color: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.3s ease;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    /* 增加一条细边框分割 */
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.sidebar-logo {
    height: 100px;
    /* 放大 50% */
    width: auto;
    object-fit: contain;
    margin-bottom: 5px;
    filter: drop-shadow(0 0 10px rgba(243, 156, 18, 0.2));
}

#new-chat-btn {
    width: 100%;
    padding: 12px;
    background: transparent;
    border: 1px dashed var(--text-dim);
    border-radius: 8px;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s;
}

#new-chat-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(243, 156, 18, 0.05);
}

.chat-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.chat-item {
    padding: 12px;
    margin-bottom: 8px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-dim);
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.chat-item.active {
    background: var(--card-bg);
    color: var(--text-main);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.delete-chat {
    opacity: 0;
    font-size: 0.8rem;
    color: #ef4444;
}

.chat-item:hover .delete-chat {
    opacity: 1;
}

/* 主对话区域 */
.main-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-dark);
}

.chat-header {
    padding: 16px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    display: inline-block;
    margin-right: 8px;
    box-shadow: 0 0 8px #22c55e;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 40px 20%;
    scroll-behavior: smooth;
}

.welcome-card {
    text-align: center;
    margin-top: 10vh;
}

.welcome-card h1 {
    font-size: 3rem;
    letter-spacing: -1px;
    line-height: 1.1;
    margin-bottom: 16px;
    background: linear-gradient(to right, #f39c12, #f1c40f);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.welcome-card p {
    color: var(--text-dim);
    font-size: 1.1rem;
}

/* 气泡样式 */
.message {
    margin-bottom: 32px;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

.message .content {
    max-width: 85%;
    padding: 16px 20px;
    border-radius: 16px;
    line-height: 1.7;
    /* 稍微增加行高 */
    font-size: 1rem;
    white-space: normal;
}

/* Markdown 内部样式精修 */
.message .content p {
    margin-bottom: 14px;
    /* 增加段落间距 */
}

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

.message .content h1,
.message .content h2,
.message .content h3 {
    margin: 20px 0 10px 0;
    color: var(--accent);
    font-weight: 600;
}

.message .content h1 {
    font-size: 1.4rem;
}

.message .content h2 {
    font-size: 1.25rem;
}

.message .content h3 {
    font-size: 1.1rem;
}

.message .content ul,
.message .content ol {
    margin: 10px 0 16px 25px;
    /* 增加左侧缩进 */
}

.message .content li {
    margin-bottom: 8px;
    /* 增加列表项间距 */
}

.message .content strong {
    color: var(--accent);
    /* 加粗改用主题色呈现，不使用背景色 */
    font-weight: 600;
}

.message.user .content {
    background: var(--accent);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.message.ai .content {
    background: var(--card-bg);
    color: var(--text-main);
    border-bottom-left-radius: 4px;
}

/* 输入框区域 */
.input-area {
    padding: 24px 20% 16px 20%;
    background: linear-gradient(to top, var(--bg-dark) 80%, transparent);
}

.input-wrapper {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-main);
    padding: 12px 0;
    resize: none;
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    max-height: 200px;
}

#send-btn {
    padding: 8px 20px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    margin-left: 12px;
    transition: all 0.2s;
}

#send-btn:hover {
    filter: brightness(1.1);
    transform: scale(1.05);
}

#send-btn:disabled {
    background: var(--text-dim);
    cursor: not-allowed;
}

.disclaimer {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-top: 12px;
}

/* 移动端菜单按钮（桌面端隐藏） */
.menu-toggle {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 1.5rem;
    margin-right: 15px;
    cursor: pointer;
}

/* 侧边栏遮罩 */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 998;
}

/* 适配移动端 */
@media (max-width: 1024px) {

    .messages-container,
    .input-area {
        padding-left: 5%;
        padding-right: 5%;
    }
}

@media (max-width: 768px) {
    .menu-toggle {
        display: block;
    }

    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        z-index: 999;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 20px 0 50px rgba(0, 0, 0, 0.5);
    }

    .sidebar.open {
        transform: translateX(280px);
    }

    .sidebar-overlay.visible {
        display: block;
    }

    .welcome-card h1 {
        font-size: 2rem;
    }

    .message .content {
        max-width: 95%;
    }
}

/* 消息操作工具栏 */
.message {
    position: relative;
}

.message-actions {
    display: flex;
    gap: 8px;
    position: absolute;
    bottom: -25px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.message.ai .message-actions {
    left: 20px;
}

.message.user .message-actions {
    right: 20px;
}

.message:hover .message-actions {
    opacity: 1;
}

.action-btn {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
}

.action-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: rgba(243, 156, 18, 0.05);
}

/* 滚动条美化 */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}