* {
    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, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    touch-action: manipulation;
}

.container {
    width: 100%;
    max-width: 800px;
    height: 90vh;
    max-height: 800px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.header {
    background: linear-gradient(135deg, #FF6B35 0%, #FF8C42 100%);
    border-bottom: 1px solid #e5e7eb;
    color: #1f2937;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    position: relative;
}

.brand-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.brand-info .logo {
    display: flex;
    align-items: center;
}

.brand-info h1 {
    font-size: 20px;
    font-weight: 600;
    margin: 0;
    letter-spacing: 0.5px;
}

.menu-btn {
    background: none;
    border: none;
    color: #1f2937;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.menu-btn:hover {
    background: rgba(99, 102, 241, 0.1);
}

.menu-btn svg {
    display: block;
}

.brand-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}

.brand-name {
    font-size: 1.125rem;
    font-weight: 600;
    color: #1f2937;
    margin: 0;
}

.brand-subtitle {
    font-size: 0.75rem;
    color: #9ca3af;
    margin: 0;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.icon-btn {
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: #f3f4f6;
    color: #1f2937;
}

.clear-chat-btn {
    background: transparent;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    color: #666;
}

.clear-chat-btn:hover {
    background: #f5f5f5;
    border-color: #ff6b35;
    color: #ff6b35;
}

.clear-chat-btn svg {
    display: block;
}

.new-chat-btn {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.new-chat-btn:hover {
    background: #f0f4f8;
    color: #FF6B35;
}

.new-chat-btn svg {
    display: block;
}

/* 侧边栏样式 */
.sidebar {
    position: fixed;
    left: -320px;
    top: 0;
    width: 320px;
    height: 100vh;
    background: #ffffff;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.08);
    z-index: 1000;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.sidebar.open {
    left: 0;
}

.sidebar-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #ffffff;
    color: #1f2937;
}

.sidebar-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: #333;
}

.close-sidebar-btn {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.close-sidebar-btn:hover {
    background: #f0f4f8;
    color: #FF6B35;
}

.conversation-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
}

.conversation-item {
    padding: 0.875rem 1rem;
    margin-bottom: 0.375rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.conversation-item:hover {
    background: #f9fafb;
}

.conversation-item.active {
    background: #eff6ff;
    border-color: #3b82f6;
}

.conversation-title {
    font-size: 0.95rem;
    color: #333;
    margin-bottom: 0.25rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conversation-time {
    font-size: 0.8rem;
    color: #999;
}

.conversation-preview {
    font-size: 0.85rem;
    color: #666;
    margin-top: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.2);
    padding: 6px 12px;
    border-radius: 20px;
}

.logout-btn {
    background: rgba(255, 255, 255, 0.3);
    border: none;
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.3s;
}

.logout-btn:hover {
    background: rgba(255, 255, 255, 0.4);
}

.status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.2);
    padding: 6px 12px;
    border-radius: 20px;
}

/* Token配额显示样式 */
.quota-display {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-left: 20px;
    background: rgba(255,255,255,0.15);
    padding: 8px 12px;
    border-radius: 6px;
    backdrop-filter: blur(10px);
}

.quota-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
}

.quota-label {
    color: rgba(255,255,255,0.9);
    min-width: 60px;
}

.quota-value {
    color: white;
    font-weight: 600;
    min-width: 40px;
    text-align: right;
}

.quota-value.warning {
    color: #FFE066;
}

.quota-percent {
    color: rgba(255,255,255,0.8);
    font-size: 11px;
    min-width: 30px;
}

/* 配额警告样式 */
.quota-warning {
    background: linear-gradient(135deg, #ff9800, #f57c00);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    margin: 10px 0;
    box-shadow: 0 2px 8px rgba(255, 152, 0, 0.3);
    animation: slideInDown 0.3s ease-out;
}

.warning-content {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.warning-icon {
    font-size: 18px;
    animation: pulse 1s infinite;
}

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

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4CAF50;
    animation: pulse 2s infinite;
}

.status.offline .status-dot {
    background: #f44336;
    animation: none;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    background: #ffffff;
}

.welcome-message {
    max-width: 800px;
    margin: 3rem auto;
    padding: 0 1rem;
}

.welcome-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.greeting-text {
    font-size: 1.5rem;
    font-weight: 500;
    color: #1f2937;
    margin: 0;
    text-align: center;
}

.search-suggestions {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.suggestion-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.875rem;
    color: #374151;
    transition: all 0.2s;
}

.suggestion-item:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.suggestion-icon {
    font-size: 1rem;
}

.example-message {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 1rem;
}

.example-text {
    color: #374151;
    font-size: 0.9375rem;
    line-height: 1.6;
}

.message {
    margin-bottom: 1.5rem;
    display: flex;
    gap: 0.75rem;
    animation: slideIn 0.3s ease-out;
}

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

.message.user {
    justify-content: flex-end;
}

.message-content {
    max-width: 70%;
    padding: 0.875rem 1rem;
    border-radius: 12px;
    line-height: 1.6;
    word-wrap: break-word;
    font-size: 0.9375rem;
}

.message.user .message-content {
    background: #3b82f6;
    color: white;
    border-bottom-right-radius: 4px;
}

.message.bot .message-content {
    background: #f9fafb;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
}

.message.bot .message-content strong {
    color: #FF6B35;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 18px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #95a5a6;
    animation: typing 1.4s infinite;
}

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

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

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

.input-container {
    padding: 1.25rem 1.5rem;
    background: linear-gradient(to top, #ffffff 0%, #f8f9fa 100%);
    border-top: 1px solid #e0e0e0;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.bottom-toolbar {
    display: flex;
    gap: 0.625rem;
    margin-bottom: 1rem;
    padding: 0.5rem 0;
    justify-content: center;
    flex-wrap: wrap;
}

.toolbar-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.125rem;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border: 1.5px solid #e0e0e0;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.8125rem;
    color: #374151;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.toolbar-btn:hover {
    background: linear-gradient(135deg, #f0f2f5 0%, #e8eaed 100%);
    border-color: #c0c4cc;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
}

.toolbar-btn svg {
    flex-shrink: 0;
}

.quick-question {
    font-size: 0.875rem;
    white-space: nowrap;
}

.quick-question span:first-child {
    font-size: 1.1rem;
}

.input-wrapper {
    display: flex;
    gap: 0.625rem;
    max-width: 900px;
    margin: 0 auto;
    align-items: center;
    background: #ffffff;
    border: 2px solid #e0e0e0;
    border-radius: 28px;
    padding: 0.625rem 0.875rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    transition: all 0.3s ease;
}

.input-wrapper:focus-within {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.input-btn {
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    width: 40px;
    height: 40px;
}

.input-btn:hover {
    background: #f0f2f5;
    color: #374151;
    transform: scale(1.08);
}

.input-btn:active {
    transform: scale(0.95);
}

.input-btn.send-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.3);
}

.input-btn.send-btn:hover {
    background: linear-gradient(135deg, #5568d3 0%, #63408b 100%);
    transform: translateY(-2px) scale(1.08);
    box-shadow: 0 4px 10px rgba(102, 126, 234, 0.4);
}

.input-btn.send-btn:active {
    transform: translateY(0) scale(0.95);
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.25);
}

.input-btn.voice-btn:hover {
    color: #667eea;
}

.input-btn svg {
    width: 20px;
    height: 20px;
}

#userInput {
    flex: 1;
    padding: 0.625rem 0.75rem;
    border: none;
    background: transparent;
    font-size: 0.9375rem;
    outline: none;
    color: #1f2937;
    font-weight: 400;
}

#userInput::placeholder {
    color: #a0a0a0;
    font-weight: 400;
}

.action-btn {
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.action-btn:hover {
    background: #f0f2f5;
    color: #374151;
    transform: scale(1.05);
}

.action-btn:active {
    transform: scale(0.95);
}

.action-btn.recording {
    background: #ef4444;
    color: white;
}

.action-btn.recording:hover {
    background: #dc2626;
}

.send-button {
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.send-button:hover {
    background: #f0f2f5;
    color: #374151;
    transform: scale(1.05);
}

.send-button:active {
    transform: scale(0.95);
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.send-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.3);
}

.send-btn:hover {
    background: linear-gradient(135deg, #5568d3 0%, #63408b 100%);
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 4px 10px rgba(102, 126, 234, 0.4);
}

.send-btn:active {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.25);
}



/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        height: 100vh;
        max-height: none;
        border-radius: 0;
    }

    .header h1 {
        font-size: 20px;
    }

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

    .quick-questions {
        justify-content: center;
    }
}

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

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

.chat-container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.chat-container::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* 移动端响应式设计 */
@media screen and (max-width: 768px) {
    body {
        padding: 0;
        align-items: stretch;
    }
    
    .container {
        max-width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .header {
        padding: 0.875rem 1rem;
    }
    
    .brand-name {
        font-size: 1rem;
    }
    
    .brand-subtitle {
        font-size: 0.7rem;
    }
    
    .icon-btn {
        padding: 0.375rem;
    }
    
    .icon-btn svg {
        width: 20px;
        height: 20px;
    }
    
    .welcome-message {
        padding: 2rem 1rem;
    }
    
    .welcome-greeting {
        font-size: 1.25rem;
        margin-bottom: 1.5rem;
    }
    
    .search-suggestion {
        font-size: 0.875rem;
        padding: 0.625rem 1rem;
    }
    
    .example-messages {
        padding: 1rem;
    }
    
    .example-card {
        padding: 0.875rem;
        font-size: 0.875rem;
    }
    
    .bottom-toolbar {
        padding: 0.625rem 0.75rem;
        gap: 0.5rem;
    }
    
    .toolbar-item {
        padding: 0.5rem 0.875rem;
        font-size: 0.8rem;
    }
    
    .input-wrapper {
        padding: 0.625rem 0.875rem;
        gap: 0.625rem;
    }
    
    #userInput {
        font-size: 0.9375rem;
        min-height: 36px;
    }
    
    .action-btn {
        width: 36px;
        height: 36px;
        min-width: 36px;
    }
    
    .action-btn svg {
        width: 20px;
        height: 20px;
    }
    
    .message {
        padding: 0.5rem 0.75rem;
    }
    
    .message-content {
        padding: 0.625rem 0.875rem;
        font-size: 0.9375rem;
        max-width: 85%;
    }
    
    .sidebar {
        width: 280px;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    /* 优化触摸目标大小 */
    .toolbar-item,
    .action-btn,
    .icon-btn,
    .menu-btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* 优化文本选择 */
    .message-content {
        -webkit-user-select: text;
        user-select: text;
    }
}

/* 小屏手机优化 */
@media screen and (max-width: 375px) {
    .header {
        padding: 0.75rem 0.875rem;
    }
    
    .brand-name {
        font-size: 0.9375rem;
    }
    
    .brand-subtitle {
        font-size: 0.65rem;
    }
    
    .bottom-toolbar {
        padding: 0.5rem;
        gap: 0.375rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .toolbar-item {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
        white-space: nowrap;
    }
    
    .input-wrapper {
        padding: 0.5rem 0.75rem;
        gap: 0.5rem;
    }
    
    #userInput {
        font-size: 0.875rem;
    }
    
    .message-content {
        font-size: 0.875rem;
        max-width: 90%;
    }
    
    .sidebar {
        width: 260px;
    }
}

/* 横屏模式优化 */
@media screen and (max-height: 500px) and (orientation: landscape) {
    .container {
        height: 100vh;
    }
    
    .header {
        padding: 0.5rem 1rem;
    }
    
    .welcome-message {
        padding: 1rem;
    }
    
    .bottom-toolbar {
        padding: 0.5rem;
    }
    
    .input-wrapper {
        padding: 0.5rem;
    }
    
    .message {
        padding: 0.375rem 0.75rem;
    }
}