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

body {
    font-family: 'Noto Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #212121;
    color: #ffffff;
    height: 100vh;
    overflow: hidden;
}

.app {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: #171717;
    border-right: 1px solid #2f2f2f;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 16px 12px;
    border-bottom: 1px solid #2f2f2f;
}

.new-chat-btn {
    width: 100%;
    padding: 12px 16px;
    background: transparent;
    border: 1px solid #4d4d4f;
    border-radius: 8px;
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    transition: all 0.2s ease;
}

.new-chat-btn:hover {
    background: #2a2a2a;
}

.chat-history {
    flex: 1;
    padding: 8px;
    overflow-y: auto;
}

.chat-item {
    padding: 12px 16px;
    margin: 4px 0;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    justify-content: space-between;
    group: chat-item;
}

.chat-item:hover {
    background: #2a2a2a;
}

.chat-item.active {
    background: #2a2a2a;
}

.chat-item-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-item-delete {
    opacity: 0;
    width: 20px;
    height: 20px;
    border: none;
    background: transparent;
    color: #9b9b9b;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    margin-left: 8px;
    flex-shrink: 0;
}

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

.chat-item-delete:hover {
    background: #ff4444;
    color: white;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
    color: white;
}

.user-avatar {
    background: #5436da;
}

.assistant-avatar {
    background: #10a37f;
}

.webig-avatar {
    background: #ab68ff;
}

.webcg-avatar {
    background: #ff6b35;
}

.webvg-avatar {
    background: #ff1744;
}

.assistant-avatar.error,
.webig-avatar.error,
.webcg-avatar.error,
.webvg-avatar.error {
    background: #ff4444;
}

/* Main content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #212121;
}

.chat-header {
    padding: 16px 24px;
    border-bottom: 1px solid #2f2f2f;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.ai-selector {
    position: relative;
}

.ai-selector-btn {
    background: transparent;
    border: 1px solid #4d4d4f;
    border-radius: 8px;
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    font-size: 18px;
    font-weight: 600;
    transition: all 0.2s ease;
    min-width: 120px;
    justify-content: space-between;
}

.ai-selector-btn:hover {
    background: #2a2a2a;
    border-color: #6b6b6b;
}

.ai-selector-btn.active {
    border-color: #10a37f;
}

.ai-selector-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #2f2f2f;
    border: 1px solid #4d4d4f;
    border-radius: 8px;
    margin-top: 4px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.ai-selector-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.ai-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.2s ease;
    border-radius: 6px;
    margin: 4px;
}

.ai-option:hover {
    background: #3a3a3a;
}

.ai-option.active {
    background: #10a37f;
}

.ai-option-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.webgpt-icon {
    background: #10a37f;
    color: white;
}

.webig-icon {
    background: #ab68ff;
    color: white;
}

.webcg-icon {
    background: #ff6b35;
    color: white;
}

.webvg-icon {
    background: #ff1744;
    color: white;
}

.ai-option-text {
    flex: 1;
}

.ai-option-title {
    font-size: 14px;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 2px;
}

.ai-option-subtitle {
    font-size: 12px;
    color: #9b9b9b;
}

.ai-option.active .ai-option-title,
.ai-option.active .ai-option-subtitle {
    color: white;
}

.chat-header h1 {
    font-size: 18px;
    font-weight: 600;
    color: #ffffff;
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 0 24px;
}

.messages {
    max-width: 768px;
    margin: 0 auto;
    padding: 24px 0;
}

.welcome-message {
    text-align: center;
    padding: 48px 24px;
    color: #9b9b9b;
}

.welcome-icon {
    margin-bottom: 16px;
}

.welcome-message h2 {
    font-size: 24px;
    font-weight: 400;
    color: #ffffff;
}

.message {
    margin-bottom: 24px;
    display: flex;
    gap: 16px;
    align-items: flex-start;
    position: relative;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s ease;
}

.message:hover {
    background: rgba(255, 255, 255, 0.02);
}

.message-delete {
    position: absolute;
    top: 8px;
    right: 8px;
    opacity: 0;
    width: 24px;
    height: 24px;
    border: none;
    background: rgba(255, 68, 68, 0.1);
    color: #ff4444;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
}

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

.message-delete:hover {
    background: #ff4444;
    color: white;
    transform: scale(1.1);
}

.message-content {
    flex: 1;
    line-height: 1.6;
    padding-top: 4px;
}

.message-content p {
    margin-bottom: 12px;
}

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

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9b9b9b;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% { opacity: 0.3; }
    40% { opacity: 1; }
}

.typing-text {
    margin-bottom: 0;
}

.typing-text::after {
    content: '|';
    animation: blink 1s infinite;
    color: #10a37f;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.error-message {
    color: #ff4444;
    font-size: 14px;
    text-align: center;
    margin-top: 8px;
    padding: 8px 16px;
    background: rgba(255, 68, 68, 0.1);
    border: 1px solid rgba(255, 68, 68, 0.2);
    border-radius: 8px;
    max-width: 768px;
    margin-left: auto;
    margin-right: auto;
}

.generated-image {
    max-width: 300px;
    width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 8px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    position: relative;
    display: block;
}

.image-container {
    position: relative;
    display: inline-block;
    max-width: 300px;
    width: 100%;
}

.image-container.nsfw .generated-image {
    filter: blur(20px);
}

.nsfw-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    color: #ff4444;
    font-weight: 600;
    font-size: 16px;
    text-align: center;
    pointer-events: none;
}

.video-container {
    margin: 12px 0;
    max-width: 400px;
}

.video-preview {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: #1a1a1a;
    border: 1px solid #3a3a3a;
    transition: all 0.3s ease;
}

.video-preview.playing {
    border-color: #ff1744;
    box-shadow: 0 0 20px rgba(255, 23, 68, 0.3);
}

.video-frame {
    width: 100%;
    height: auto;
    display: block;
    aspect-ratio: 16/9;
    object-fit: cover;
}

.video-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.8));
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.play-button {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: #ff1744;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.play-button:hover {
    background: #d50000;
    transform: scale(1.05);
}

.play-button.playing {
    background: #ff1744;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(255, 23, 68, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(255, 23, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 23, 68, 0); }
}

.video-description {
    color: #ffffff;
    font-size: 14px;
    font-weight: 500;
    flex: 1;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

.video-info {
    padding: 12px;
    background: #2a2a2a;
    border-radius: 0 0 12px 12px;
    margin-top: -1px;
}

.video-info p {
    margin: 4px 0;
    font-size: 13px;
    color: #9b9b9b;
}

.video-info p:first-child {
    color: #ff1744;
    font-weight: 600;
}

/* Input area */
.input-area {
    padding: 24px;
    border-top: 1px solid #2f2f2f;
}

.input-container {
    max-width: 768px;
    margin: 0 auto;
    position: relative;
    background: #2f2f2f;
    border-radius: 12px;
    border: 1px solid #4d4d4f;
    display: flex;
    align-items: flex-end;
    padding: 12px 52px 12px 12px;
    transition: border-color 0.2s ease;
}

.input-container:focus-within {
    border-color: #10a37f;
}

#messageInput {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #ffffff;
    font-size: 16px;
    line-height: 1.5;
    resize: none;
    max-height: 200px;
    font-family: inherit;
}

#messageInput::placeholder {
    color: #9b9b9b;
}

.send-button {
    position: absolute;
    right: 12px;
    bottom: 12px;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: #10a37f;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.send-button:disabled {
    background: #4d4d4f;
    cursor: not-allowed;
}

.send-button:not(:disabled):hover {
    background: #0d8a6b;
}

.input-footer {
    text-align: center;
    font-size: 12px;
    color: #9b9b9b;
    margin-top: 12px;
    max-width: 768px;
    margin-left: auto;
    margin-right: auto;
}

.code-block {
    position: relative;
    margin: 16px 0;
    border-radius: 8px;
    background: #1a1a1a;
    border: 1px solid #3a3a3a;
    overflow: hidden;
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #2a2a2a;
    border-bottom: 1px solid #3a3a3a;
    font-size: 12px;
    color: #9b9b9b;
}

.code-language {
    font-weight: 500;
    text-transform: uppercase;
}

.copy-btn {
    background: transparent;
    border: 1px solid #4d4d4f;
    border-radius: 4px;
    color: #9b9b9b;
    cursor: pointer;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

.copy-btn:hover {
    background: #3a3a3a;
    border-color: #6b6b6b;
    color: #ffffff;
}

.copy-btn.copied {
    background: #10a37f;
    border-color: #10a37f;
    color: white;
}

.code-content {
    padding: 16px;
    overflow-x: auto;
    font-family: 'Space Mono', 'Monaco', 'Menlo', monospace;
    font-size: 14px;
    line-height: 1.5;
    color: #e6e6e6;
    white-space: pre;
}

.code-content::-webkit-scrollbar {
    height: 8px;
}

.code-content::-webkit-scrollbar-track {
    background: #1a1a1a;
}

.code-content::-webkit-scrollbar-thumb {
    background: #4d4d4f;
    border-radius: 4px;
}

.code-content::-webkit-scrollbar-thumb:hover {
    background: #6b6b6b;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -260px;
        top: 0;
        height: 100vh;
        z-index: 1000;
    }
    
    .sidebar.open {
        transform: translateX(260px);
    }
    
    .main-content {
        width: 100%;
    }
    
    .chat-container,
    .input-area {
        padding-left: 16px;
        padding-right: 16px;
    }

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

/* Scrollbar */
::-webkit-scrollbar {
    width: 4px;
}

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

::-webkit-scrollbar-thumb {
    background: #4d4d4f;
    border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
    background: #6b6b6b;
}