* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: 260px;
    background: #1f2937;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #374151;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #374151;
}

.sidebar-header h2 {
    color: white;
    font-size: 18px;
    margin-bottom: 15px;
}

.new-chat-btn {
    width: 100%;
    padding: 10px 16px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.2s;
}

.new-chat-btn:hover {
    background: #5a67d8;
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.history-item {
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    color: #d1d5db;
    font-size: 14px;
    margin-bottom: 5px;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.history-item:hover {
    background: #374151;
}

.history-item.active {
    background: #667eea;
    color: white;
}

.history-item-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-item-delete {
    opacity: 0;
    background: none;
    border: none;
    color: #ef4444;
    cursor: pointer;
    padding: 4px;
    font-size: 18px;
    line-height: 1;
    transition: opacity 0.2s;
}

.history-item:hover .history-item-delete {
    opacity: 1;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
    margin: 20px;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

header {
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 15px;
}

.header-left h1 {
    font-size: 24px;
    color: #1f2937;
}

.settings {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    align-items: center;
}

.settings label {
    font-size: 14px;
    color: #374151;
    font-weight: 500;
}

.settings input[type="password"] {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    width: 200px;
}

.settings select {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    background: white;
}

.settings select:disabled {
    background: #f3f4f6;
    color: #9ca3af;
    cursor: not-allowed;
}

.settings input[type="text"] {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    width: 180px;
}

.settings input[type="text"]:focus {
    outline: none;
    border-color: #667eea;
}

.save-btn {
    padding: 8px 16px;
    background: #10b981;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
}

.save-btn:hover {
    background: #059669;
}

.custom-model-label {
    display: flex;
    align-items: center;
    gap: 5px;
}

.custom-model-input {
    display: none;
}

.custom-model-input.show {
    display: inline-block;
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #ffffff;
}

.welcome-message {
    text-align: center;
    padding: 60px 20px;
    color: #6b7280;
}

.welcome-message h2 {
    font-size: 28px;
    color: #1f2937;
    margin-bottom: 10px;
}

.welcome-message .hint {
    margin-top: 10px;
    font-size: 14px;
    color: #9ca3af;
}

.message {
    margin-bottom: 20px;
    display: flex;
    gap: 12px;
}

.message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 16px;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: #667eea;
    color: white;
}

.message.assistant .message-avatar {
    background: #10b981;
    color: white;
}

.message-content {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.6;
}

.message.user .message-content {
    background: #667eea;
    color: white;
    border-bottom-right-radius: 4px;
}

.message.assistant .message-content {
    background: #f3f4f6;
    color: #1f2937;
    border-bottom-left-radius: 4px;
}

.message-content img {
    max-width: 100%;
    border-radius: 8px;
    margin-top: 10px;
}

.message-content pre {
    background: #1f2937;
    color: #f3f4f6;
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 10px 0;
}

.message-content code {
    font-family: 'Courier New', monospace;
}

.input-area {
    padding: 20px;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
    transition: background 0.2s;
}

.input-area.drag-over {
    background: #eef2ff;
    border-top-color: #667eea;
}

.input-wrapper {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-direction: column;
}

.textarea-wrapper {
    display: flex;
    gap: 10px;
}

#userInput {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    resize: none;
    font-family: inherit;
}

#userInput:focus {
    outline: none;
    border-color: #667eea;
}

.image-upload-area {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.image-preview {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.preview-item {
    position: relative;
    width: 80px;
    height: 80px;
}

.preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid #e5e7eb;
}

.preview-item .remove-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ef4444;
    color: white;
    border: none;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.upload-btn {
    padding: 8px 16px;
    background: #f3f4f6;
    border: 2px dashed #d1d5db;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    color: #374151;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.upload-btn:hover {
    border-color: #667eea;
    background: #eef2ff;
}

.upload-btn input {
    display: none;
}

.send-btn {
    padding: 12px 24px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.send-btn:hover {
    background: #5a67d8;
}

.send-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

.options {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    align-items: center;
    font-size: 14px;
    color: #374151;
}

.options label {
    display: flex;
    align-items: center;
    gap: 8px;
}

.options input[type="range"] {
    width: 120px;
}

#tempValue {
    min-width: 30px;
    display: inline-block;
}

.typing-indicator {
    display: inline-flex;
    gap: 4px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #667eea;
    border-radius: 50%;
    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(-8px);
    }
}