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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: #fff;
    color: #1a1a1a;
    height: 100vh;
    overflow: hidden;
}

/* Dark mode */
body.dark {
    background: #111;
    color: #e5e5e5;
}

/* 侧边栏样式 */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 260px;
    height: 100vh;
    background: #f9fafb;
    border-right: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    z-index: 50;
    transition: transform 0.3s;
}

.sidebar.hidden {
    transform: translateX(-260px);
}

.dark .sidebar {
    background: #1a1a1a;
    border-right-color: #333;
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.dark .sidebar-header {
    border-bottom-color: #333;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
    font-weight: 500;
}

.sidebar-toggle {
    padding: 6px;
    background: transparent;
    border: none;
    color: #6b7280;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s;
}

.sidebar-toggle:hover {
    background: #f3f4f6;
}

.dark .sidebar-toggle {
    color: #9ca3af;
}

.dark .sidebar-toggle:hover {
    background: #2a2a2a;
}

.sidebar-nav {
    padding: 8px;
    flex: 1;
    overflow-y: auto;
    /* 隐藏滚动条 */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE和Edge */
}

/* Webkit浏览器（Chrome、Safari等）隐藏滚动条 */
.sidebar-nav::-webkit-scrollbar {
    display: none;
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    margin-bottom: 4px;
    border-radius: 8px;
    text-decoration: none;
    color: #4b5563;
    transition: background 0.2s;
    border: none;
    background: transparent;
    width: 100%;
    cursor: pointer;
    font-size: 14px;
}

.dark .sidebar-nav-item {
    color: #9ca3af;
}

.sidebar-nav-item:hover {
    background: #f3f4f6;
}

.dark .sidebar-nav-item:hover {
    background: #2a2a2a;
}

.sidebar-nav-item svg {
    width: 18px;
    height: 18px;
}

.sidebar-user {
    padding: 4px 12px;
    border-top: 1px solid #e5e7eb;
    display: block;
    transition: background 0.2s;
}

.dark .sidebar-user {
    border-top-color: #333;
}

/* 设置区域样式 */
.sidebar-user .settings-section {
    width: 100%;
    padding: 0;
    margin: 0;
}

.sidebar-user .setting-item {
    margin: 0;
    padding: 0;
}

.sidebar-user .setting-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 12px;
    width: 100%;
}

/* 开关样式 */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: background-color 0.3s;
    border-radius: 22px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: transform 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: #4CAF50;
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(16px);
}

.toggle-switch input:focus + .toggle-slider {
    box-shadow: 0 0 1px #4CAF50;
}

/* 主内容区域 */
.main-content {
    margin-left: 260px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s;
}

.main-content.expanded {
    margin-left: 0;
}

/* 顶部导航栏 */
.top-nav {
    padding: 12px 20px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: white;
}

.dark .top-nav {
    background: #1a1a1a;
    border-bottom-color: #333;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.menu-toggle {
    padding: 8px;
    background: transparent;
    border: none;
    color: #6b7280;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s;
    display: none;
}

.menu-toggle.show {
    display: block;
}

.menu-toggle:hover {
    background: #f3f4f6;
}

.dark .menu-toggle {
    color: #9ca3af;
}

.dark .menu-toggle:hover {
    background: #2a2a2a;
}

.model-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    color: inherit;
}

.dark .model-selector {
    border-color: #333;
}

.model-selector svg {
    width: 12px;
    height: 12px;
}

.top-nav-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon-button {
    padding: 8px;
    border: none;
    background: transparent;
    color: #6b7280;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s;
}

.dark .icon-button {
    color: #9ca3af;
}

.icon-button:hover {
    background: #f3f4f6;
}

.dark .icon-button:hover {
    background: #2a2a2a;
}

.icon-button svg {
    width: 20px;
    height: 20px;
}

/* 聊天区域 */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
    position: relative;
    min-height: 0;
    cursor: default;
}

/* 角色标题栏 */
.chat-header {
    position: sticky;
    top: 0;
    width: 100%;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 20px;
    z-index: 40;
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.95);
}

[data-theme="dark"] .chat-header {
    background: rgba(33, 33, 33, 0.95);
}

.chat-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 800px;
    margin: 0 auto;
}

.chat-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 16px;
}

.chat-header-info {
    flex: 1;
}

.chat-header-name {
    font-weight: 600;
    font-size: 16px;
    color: var(--text-primary);
}

.chat-header-status {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 2px;
}

.chat-header-status::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    display: inline-block;
}

.welcome-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    max-width: 600px;
    width: 100%;
    height: 100%;
    gap: 30px;
}

.welcome-title {
    font-size: 30px;
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

/* 输入框区域 */
.chat-input-wrapper {
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
}

.chat-input-container {
    position: relative;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 24px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
    transition: border-color 0.2s;
}

.dark .chat-input-container {
    background: #2a2a2a;
    border-color: #444;
}

.chat-input-container:hover,
.chat-input-container:focus-within {
    border-color: #9ca3af;
}

.dark .chat-input-container:hover,
.dark .chat-input-container:focus-within {
    border-color: #666;
}

.chat-input {
    width: 100%;
    padding: 16px 20px;
    border: none;
    background: transparent;
    color: inherit;
    font-size: 15px;
    outline: none;
    resize: none;
    min-height: 56px;
    max-height: 500px;  /* 提高到500px */
    line-height: 1.5;
    overflow-y: auto;  /* 超过最大高度时显示滚动条 */
}

.chat-input::placeholder {
    color: #9ca3af;
}

.chat-input-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-top: 1px solid #f3f4f6;
}

.dark .chat-input-actions {
    border-top-color: #333;
}

.input-tools {
    display: flex;
    align-items: center;
    gap: 4px;
}

.input-tool-button {
    padding: 6px 10px;
    border: none;
    background: transparent;
    color: #6b7280;
    cursor: pointer;
    border-radius: 6px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s;
}

.dark .input-tool-button {
    color: #9ca3af;
}

.input-tool-button:hover {
    background: #f3f4f6;
}

.dark .input-tool-button:hover {
    background: #333;
}

.input-tool-button svg {
    width: 16px;
    height: 16px;
}

.send-buttons {
    display: flex;
    gap: 8px;
}

.voice-button,
.send-button {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s;
}

.voice-button {
    background: transparent;
    color: #6b7280;
}

.dark .voice-button {
    color: #9ca3af;
}

.send-button {
    background: #111;
    color: white;
}

.dark .send-button {
    background: white;
    color: #111;
}

.voice-button:hover,
.send-button:hover {
    transform: scale(1.05);
}

.voice-button svg,
.send-button svg {
    width: 20px;
    height: 20px;
}

/* 建议卡片 */
.suggestions {
    margin-top: 40px;
    max-width: 600px;
    width: 100%;
}

.suggestions-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    font-size: 12px;
    font-weight: 500;
    color: #6b7280;
}

.dark .suggestions-header {
    color: #9ca3af;
}

.suggestions-header svg {
    width: 12px;
    height: 12px;
}

.suggestions-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 160px;
    overflow-y: auto;
}

.suggestion-item {
    padding: 12px 16px;
    background: transparent;
    border: none;
    border-radius: 12px;
    text-align: left;
    cursor: pointer;
    transition: background 0.2s;
}

.suggestion-item:hover {
    background: rgba(0,0,0,0.02);
}

.dark .suggestion-item:hover {
    background: rgba(255,255,255,0.05);
}

.suggestion-title {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 4px;
}

.dark .suggestion-title {
    color: #d1d5db;
}

.suggestion-desc {
    font-size: 12px;
    color: #6b7280;
}

.dark .suggestion-desc {
    color: #9ca3af;
}

/* 响应式 - 平板设备 */
@media (max-width: 1024px) {
    /* 缩小最大宽度 */
    .message-inner {
        max-width: 90%;
    }
    
    .chat-input-wrapper {
        max-width: 90%;
    }
}

/* 响应式 - 手机横屏 */
@media (max-width: 768px) {
    .sidebar {
        z-index: 200;
        width: 240px;
    }
    
    .sidebar.hidden {
        transform: translateX(-240px);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .menu-toggle {
        display: block !important;
    }
    
    /* 调整顶部导航 */
    .top-nav {
        padding: 10px 15px;
    }
    
    /* 调整消息区域 */
    .message-inner {
        padding: 0 16px;
        gap: 16px;
        max-width: 100%;
    }
    
    /* 调整输入框 */
    .chat-input-wrapper {
        padding: 15px;
        max-width: 100%;
    }
    
    .chat-input-container {
        border-radius: 20px;
    }
    
    .chat-input {
        padding: 14px 16px;
        font-size: 14px;
    }
    
    /* 调整建议卡片 */
    .suggestions {
        padding: 0 15px;
    }
    
    .suggestion-item {
        padding: 10px 14px;
    }
}

/* 响应式 - 手机竖屏 */
@media (max-width: 480px) {
    /* 修复消息左右不对称问题 */
    .messages-container {
        padding: 0;
        width: 100%;
    }
    
    .message {
        padding: 16px 0;
    }
    
    .message-inner {
        padding: 0 15px;
        max-width: 100%;
        gap: 10px;
    }
    
    .message-content {
        padding-right: 10px;
    }
    /* 侧边栏50%宽度 */
    .sidebar {
        width: 50%;
    }
    
    .sidebar.hidden {
        transform: translateX(-100%);
    }
    
    /* 优化字体大小 */
    body {
        font-size: 14px;
    }
    
    /* 顶部导航调整 */
    .model-selector {
        font-size: 13px;
        padding: 6px 10px;
    }
    
    .top-nav-actions {
        gap: 4px;
    }
    
    .icon-button {
        padding: 6px;
    }
    
    .icon-button svg {
        width: 18px;
        height: 18px;
    }
    
    /* 聊天头部调整 */
    .chat-header {
        z-index: 40;
        padding: 10px 12px;
    }
    
    .chat-header-content {
        gap: 10px;
        padding: 0;
    }
    
    .chat-header-avatar {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }
    
    .chat-header-name {
        font-size: 15px;
    }
    
    /* 消息样式调整 */
    .message {
        padding: 16px 0;
    }
    
    .message-inner {
        padding: 0 12px;
        gap: 12px;
        max-width: 100%;
    }
    
    .message-avatar {
        width: 26px;
        height: 26px;
        font-size: 11px;
    }
    
    .message-content {
        font-size: 14px;
        line-height: 1.6;
    }
    
    /* 消息操作按钮调整 */
    .message-actions {
        gap: 3px;
    }
    
    .message-header {
        min-height: 24px;
        margin-bottom: 6px;
    }
    
    .message-btn {
        width: 24px;
        height: 24px;
    }
    
    .message-btn svg {
        width: 12px;
        height: 12px;
    }
    
    /* 输入区域调整 */
    .chat-input-wrapper {
        padding: 12px;
    }
    
    .chat-input-container {
        border-radius: 18px;
    }
    
    .chat-input {
        padding: 12px 14px;
        font-size: 14px;
        min-height: 48px;
    }
    
    .chat-input-actions {
        padding: 6px 10px;
    }
    
    .input-tool-button {
        padding: 5px 8px;
        font-size: 12px;
    }
    
    .input-tool-button svg {
        width: 14px;
        height: 14px;
    }
    
    .voice-button,
    .send-button {
        width: 28px;
        height: 28px;
    }
    
    .voice-button svg,
    .send-button svg {
        width: 16px;
        height: 16px;
    }
    
    /* 欢迎界面调整 */
    .welcome-title {
        font-size: 24px;
        margin-bottom: 20px;
    }
    
    /* 建议卡片调整 */
    .suggestions {
        margin-top: 30px;
    }
    
    .suggestion-title {
        font-size: 13px;
    }
    
    .suggestion-desc {
        font-size: 11px;
    }
    
    /* 模态框调整 */
    .modal-content {
        width: 95%;
        border-radius: 12px;
    }
    
    .modal-header {
        padding: 16px;
    }
    
    .modal-header h3 {
        font-size: 16px;
    }
    
    .modal-body {
        padding: 16px;
        max-height: 70vh;
    }
    
    /* 历史面板调整 */
    .history-panel {
        padding: 12px;
    }
    
    .history-item {
        padding: 8px;
    }
    
    .history-title {
        font-size: 12px;
    }
    
    .history-meta {
        font-size: 10px;
    }
}

/* 超小屏幕设备 */
@media (max-width: 360px) {
    /* 进一步减小内边距 */
    .message-inner {
        padding: 0 10px;
        max-width: 100%;
    }
    
    .chat-input-wrapper {
        padding: 10px;
    }
    
    .chat-input {
        padding: 10px 12px;
        font-size: 13px;
    }
    
    /* 隐藏次要按钮文字，只显示图标 */
    .input-tool-button span {
        display: none;
    }
    
    .input-tool-button {
        padding: 6px;
    }
    
    /* 调整侧边栏 */
    .sidebar-nav-item {
        font-size: 13px;
        padding: 8px 10px;
    }
    
    .sidebar-nav-item svg {
        width: 16px;
        height: 16px;
    }
}

/* 消息容器 - ChatGPT风格 */
.messages-container {
    flex: 1;
    width: 100%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* 当有消息时，调整chat-container布局 */
.chat-container:has(.messages-container) {
    justify-content: flex-start;
    align-items: center;
    padding: 0;
}

/* 当有消息时，输入框固定在底部 */
.chat-container:has(.messages-container) .chat-input-wrapper {
    position: sticky;
    bottom: 0;
    background: inherit;
    padding: 20px;
    z-index: 10;
}

/* 当有角色标题栏显示时，调整容器 */
.chat-container:has(.chat-header[style*="display: block"]) {
    padding-top: 0;
}

/* 消息样式 - ChatGPT风格 */
.message {
    width: 100%;
    padding: 24px 0;
    animation: fadeIn 0.3s ease;
}

.user-message {
    background: white;
}

.assistant-message {
    background: #f7f7f8;
    border-top: 1px solid rgba(0,0,0,0.05);
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.dark .user-message {
    background: #212121;
}

.dark .assistant-message {
    background: #2a2a2a;
    border-color: rgba(255,255,255,0.05);
}

.message-inner {
    max-width: 768px;
    margin: 0 auto;
    padding: 0 24px;
    width: 100%;
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 30px;
    margin-bottom: 8px;
}

.message-body {
    width: 100%;
}

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

.message-avatar {
    width: 30px;
    height: 30px;
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}

.user-message .message-avatar {
    background: #5436DA;
    color: white;
}

.assistant-message .message-avatar {
    background: #19c37d;
    color: white;
}

.message-content {
    flex: 1;
    line-height: 1.7;
    font-size: 15px;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: #2d2d2d;
    min-width: 0;
    overflow-wrap: break-word;
}

/* HTML代码块样式 - 确保长代码换行 */
.message-content pre.html-code-block {
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    overflow-x: auto;
}

.message-content pre.html-code-block code {
    white-space: pre-wrap;
    word-break: break-all;
    overflow-wrap: break-word;
}

/* 停止模式的发送按钮 */
.send-button.stop-mode {
    background-color: #000;
    color: white;
}

.send-button.stop-mode:hover {
    background-color: #333;
    transform: scale(1.05);
}

.send-button.stop-mode svg {
    width: 14px;
    height: 14px;
}

.dark .message-content {
    color: #ececec;
}

/* 消息操作按钮 */
.message-actions {
    display: flex;
    gap: 5px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}

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

.message-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: rgba(0, 0, 0, 0.05);
    color: #666;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.message-btn svg {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
}

.dark .message-btn {
    background: rgba(255, 255, 255, 0.1);
    color: #999;
}

.message-btn:hover {
    transform: scale(1.1);
}

.edit-btn:hover {
    background: #3b82f6;
    color: white;
}

.delete-btn:hover {
    background: #ef4444;
    color: white;
}

.regenerate-btn:hover {
    background: #10b981;
    color: white;
}

/* 消息编辑框 */
.message-edit-textarea {
    width: 100%;
    min-height: 100px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: white;
    color: #333;
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
}

.dark .message-edit-textarea {
    border-color: #444;
    background: #1a1a1a;
    color: #e5e5e5;
}

.edit-buttons {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.save-edit-btn,
.cancel-edit-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.save-edit-btn {
    background: #10b981;
    color: white;
}

.save-edit-btn:hover {
    background: #059669;
}

.cancel-edit-btn {
    background: #6b7280;
    color: white;
}

.cancel-edit-btn:hover {
    background: #4b5563;
}

/* 加载动画 */
.loading-dots {
    display: flex;
    gap: 4px;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    background: #6b7280;
    border-radius: 50%;
    animation: loadingDot 1.4s infinite;
}

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

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

@keyframes loadingDot {
    0%, 60%, 100% {
        opacity: 0.3;
    }
    30% {
        opacity: 1;
    }
}

/* 模态框 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

.modal-content {
    background: white;
    border-radius: 16px;
    max-width: 600px;
    width: 90%;
    max-height: none;
    overflow: visible;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
}

.dark .modal-content {
    background: #1a1a1a;
}

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

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.dark .modal-header {
    border-bottom-color: #333;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    font-size: 24px;
    cursor: pointer;
    color: #6b7280;
    border-radius: 8px;
    transition: background 0.2s;
}

.modal-close:hover {
    background: #f3f4f6;
}

.dark .modal-close:hover {
    background: #333;
}

.modal-body {
    padding: 20px;
    max-height: 80vh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #d1d5db transparent;
}

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

.modal-body::-webkit-scrollbar-track {
    background: transparent;
}

.modal-body::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

.dark .modal-body {
    scrollbar-color: #4b5563 transparent;
}

.dark .modal-body::-webkit-scrollbar-thumb {
    background: #4b5563;
}

.dark .modal-body::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}

/* 设置表单 */
.settings-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 14px;
    font-weight: 500;
    color: #374151;
}

.dark .form-group label {
    color: #d1d5db;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"] {
    padding: 8px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    background: white;
    color: #111;
}

.dark .form-group input[type="text"],
.dark .form-group input[type="password"],
.dark .form-group input[type="number"] {
    background: #2a2a2a;
    border-color: #444;
    color: #e5e5e5;
}

.form-group input[type="range"] {
    width: 100%;
}

.form-group input[type="checkbox"] {
    margin-right: 8px;
}

.form-buttons {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 16px;
}

.form-buttons button {
    padding: 8px 16px;
    border-radius: 8px;
    border: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.2s;
}

.form-buttons button:first-child {
    background: #3b82f6;
    color: white;
}

.form-buttons button:last-child {
    background: #e5e7eb;
    color: #374151;
}

.dark .form-buttons button:last-child {
    background: #333;
    color: #d1d5db;
}

.form-buttons button:hover {
    opacity: 0.9;
}

/* 模型列表 */
.model-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.model-item {
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 14px;
}

.model-item:hover {
    background: #f3f4f6;
}

.dark .model-item:hover {
    background: #333;
}

/* Toast 提示 */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 8px;
    background: #111;
    color: white;
    font-size: 14px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 2000;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast-success {
    background: #10b981;
}

.toast-warning {
    background: #f59e0b;
}

.toast-error {
    background: #ef4444;
}

.toast-info {
    background: #3b82f6;
}

/* 历史对话面板 */
.history-panel {
    margin-top: 20px;
    padding: 16px;
    border-top: 1px solid #e5e7eb;
}

.dark .history-panel {
    border-top-color: #333;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.history-header span {
    font-size: 14px;
    font-weight: 500;
    color: #374151;
}

.dark .history-header span {
    color: #d1d5db;
}

.history-actions {
    display: flex;
    gap: 8px;
}

.history-actions button {
    padding: 6px;
    border: none;
    background: transparent;
    color: #6b7280;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.history-actions button:hover {
    background: #f3f4f6;
    color: #3b82f6;
}

.dark .history-actions button {
    color: #9ca3af;
}

.dark .history-actions button:hover {
    background: #2a2a2a;
    color: #60a5fa;
}

.history-actions button svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
}

.history-edit-btn {
    padding: 4px !important;
}

.history-edit-btn svg {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 400px;
    overflow-y: auto;
    /* 隐藏滚动条 */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE和Edge */
}

/* Webkit浏览器（Chrome、Safari等）隐藏滚动条 */
.history-list::-webkit-scrollbar {
    display: none;
}

.history-item {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
    background: #f9fafb;
    border-radius: 8px;
    transition: background 0.2s;
}

.dark .history-item {
    background: #2a2a2a;
}

.history-item:hover {
    background: #f3f4f6;
}

.dark .history-item:hover {
    background: #333;
}

.history-content {
    flex: 1;
    cursor: pointer;
}

.history-delete-btn {
    padding: 4px;
    border: none;
    background: transparent;
    color: #9ca3af;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.history-item:hover .history-delete-btn {
    opacity: 1;
}

.history-delete-btn:hover {
    background: #fee2e2;
    color: #dc2626;
}

.dark .history-delete-btn:hover {
    background: #7f1d1d;
    color: #f87171;
}

.history-delete-btn svg {
    width: 14px;
    height: 14px;
}

.history-item.active {
    background: #dbeafe;
    border-left: 3px solid #3b82f6;
}

.dark .history-item.active {
    background: #1e3a8a;
    border-left-color: #60a5fa;
}

.history-title {
    font-size: 13px;
    font-weight: 500;
    color: #111827;
    margin-bottom: 4px;
}

.dark .history-title {
    color: #f3f4f6;
}

.history-meta {
    font-size: 11px;
    color: #6b7280;
}

.dark .history-meta {
    color: #9ca3af;
}

/* 前端修饰面板样式 */
.frontend-decorator-panel .badge-beta {
    display: inline-block;
    padding: 2px 6px;
    background: #f59e0b;
    color: white;
    font-size: 10px;
    font-weight: 600;
    border-radius: 4px;
    margin-left: 8px;
}

.code-input {
    width: 100%;
    padding: 8px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    background: #f9fafb;
    resize: vertical;
}

.dark .code-input {
    background: #1f2937;
    border-color: #374151;
    color: #e5e7eb;
}

.action-btn {
    padding: 8px 16px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: white;
    color: #374151;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    margin-right: 8px;
}

.action-btn:hover {
    background: #f3f4f6;
}

.action-btn.primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
}

.action-btn.primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.dark .action-btn {
    background: #374151;
    border-color: #4b5563;
    color: #e5e7eb;
}

.dark .action-btn:hover {
    background: #4b5563;
}

/* HTML渲染内容样式 */
.html-rendered-content {
    position: relative;
    margin: 8px 0;
}

.html-rendered-content[data-depth="0"] {
    border-left: 3px solid #667eea;
    padding-left: 10px;
}

.test-message {
    background: #f0f9ff;
    border: 1px dashed #3b82f6;
}

.dark .test-message {
    background: #1e3a8a;
    border-color: #60a5fa;
}

/* iframe渲染样式 */
.html-iframe-render {
    width: 100%;
    min-height: 300px;
    max-height: 800px;
    border: none;
    border-radius: 8px;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin: 10px 0;
}

.dark .html-iframe-render {
    box-shadow: 0 2px 8px rgba(255, 255, 255, 0.1);
}

/* ==================== 文档上传样式 ==================== */

/* 拖放区域 */
.document-drop-zone {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(4px);
}

.drop-zone-content {
    text-align: center;
    color: white;
    pointer-events: none;
}

.drop-zone-content svg {
    margin-bottom: 20px;
}

.drop-zone-content p {
    font-size: 24px;
    margin: 10px 0;
}

.drop-zone-content small {
    opacity: 0.8;
}

/* 拖拽悬停效果 */
.chat-messages.drag-over {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(139, 92, 246, 0.1) 100%);
    border: 2px dashed #6366f1;
    transition: all 0.3s ease;
}

/* 上传状态 */
.document-upload-status {
    padding: 12px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px;
    margin-bottom: 10px;
    animation: slideDown 0.3s ease;
}

.upload-status-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.upload-status-content .spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

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

/* 文档预览卡片 */
.document-preview-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    animation: slideDown 0.3s ease;
}

.dark .document-preview-card {
    background: #1f2937;
    border-color: #374151;
}

.doc-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e5e7eb;
}

.dark .doc-card-header {
    border-bottom-color: #374151;
}

.doc-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.doc-icon {
    font-size: 20px;
}

.doc-name {
    font-weight: 600;
    color: #1f2937;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dark .doc-name {
    color: #f3f4f6;
}

.doc-size {
    color: #6b7280;
    font-size: 12px;
}

.doc-remove {
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    font-size: 20px;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.doc-remove:hover {
    background: #fee2e2;
    color: #dc2626;
}

.dark .doc-remove:hover {
    background: rgba(220, 38, 38, 0.2);
}

.doc-card-body {
    margin-bottom: 12px;
}

.doc-preview-text {
    color: #4b5563;
    font-size: 14px;
    line-height: 1.5;
    max-height: 60px;
    overflow: hidden;
    margin-bottom: 8px;
}

.dark .doc-preview-text {
    color: #9ca3af;
}

.doc-stats {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: #6b7280;
}

.doc-stats span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.doc-card-actions {
    display: flex;
    gap: 8px;
}

.doc-action-btn {
    flex: 1;
    padding: 8px 16px;
    border: 1px solid #e5e7eb;
    background: white;
    color: #4b5563;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.dark .doc-action-btn {
    background: #374151;
    border-color: #4b5563;
    color: #d1d5db;
}

.doc-action-btn:hover {
    background: #f3f4f6;
}

.dark .doc-action-btn:hover {
    background: #4b5563;
}

.doc-action-btn.primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
}

.doc-action-btn.primary:hover {
    opacity: 0.9;
}

/* 文档模态框 */
.document-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

.dark .modal-content {
    background: #1f2937;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
}

.dark .modal-header {
    border-bottom-color: #374151;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    color: #1f2937;
}

.dark .modal-header h3 {
    color: #f3f4f6;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #6b7280;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: #f3f4f6;
}

.dark .modal-close:hover {
    background: #374151;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.modal-body pre {
    margin: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    font-size: 14px;
    line-height: 1.6;
    color: #1f2937;
}

.dark .modal-body pre {
    color: #d1d5db;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 20px;
    border-top: 1px solid #e5e7eb;
}

.dark .modal-footer {
    border-top-color: #374151;
}

/* 上传按钮样式 */
#doc-upload-btn {
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

#doc-upload-btn:hover {
    background: #f3f4f6;
    color: #4b5563;
}

.dark #doc-upload-btn:hover {
    background: #374151;
    color: #d1d5db;
}

#doc-upload-btn svg {
    width: 20px;
    height: 20px;
}

/* 响应式调整 */
@media (max-width: 640px) {
    .document-preview-card {
        padding: 12px;
    }

    .doc-name {
        max-width: 150px;
    }

    .modal-content {
        width: 95%;
        max-height: 90vh;
    }

    .doc-action-btn {
        font-size: 12px;
        padding: 6px 12px;
    }
}

/* ==================== Swipe 控制按钮样式 ==================== */

.swipe-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 12px;
    padding: 8px;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 8px;
}

.dark .swipe-controls {
    background: rgba(255, 255, 255, 0.05);
}

.swipe-btn {
    padding: 6px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
}

.swipe-btn:hover {
    background: #f9fafb;
    border-color: #d1d5db;
    color: #374151;
}

.dark .swipe-btn {
    background: #1f2937;
    border-color: #374151;
    color: #9ca3af;
}

.dark .swipe-btn:hover {
    background: #374151;
    border-color: #4b5563;
    color: #d1d5db;
}

.swipe-counter {
    font-size: 13px;
    color: #6b7280;
    font-weight: 500;
    min-width: 60px;
    text-align: center;
}

.dark .swipe-counter {
    color: #9ca3af;
}

