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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    min-height: 100vh;
    color: #fff;
}

.page {
    display: none;
}

.page.active {
    display: block;
}

.home-header {
    text-align: center;
    padding: 60px 20px 40px;
}

.home-header .logo {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: bold;
    box-shadow: 0 10px 40px rgba(99, 102, 241, 0.3);
}

.home-header h1 {
    font-size: 36px;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #fff, #e0e0e0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.home-header .subtitle {
    font-size: 16px;
    color: #888;
}

.model-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    max-width: 1000px;
    width: 100%;
    margin: 0 auto;
    padding: 0 20px;
}

.model-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 24px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
}

.model-card:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(99, 102, 241, 0.5);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.model-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
}

.model-icon.gpt {
    background: linear-gradient(135deg, #10a37f, #0d8a6e);
}

.model-icon.gemini {
    background: linear-gradient(135deg, #4285f4, #ea4335, #fbbc05, #34a853);
}

.model-icon.grok {
    background: linear-gradient(135deg, #000, #333);
    color: #1da1f2;
}

.model-icon.claude {
    background: linear-gradient(135deg, #00bfff, #1e90ff);
}

.model-icon.llama {
    background: linear-gradient(135deg, #0066ff, #9900ff);
}

.model-icon.mistral {
    background: linear-gradient(135deg, #ff6b35, #f7c59f);
}

.model-card h3 {
    font-size: 18px;
    margin-bottom: 8px;
    color: #fff;
}

.model-card p {
    font-size: 13px;
    color: #888;
    margin-bottom: 16px;
}

.chat-btn {
    padding: 12px 32px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.model-card:hover .chat-btn {
    transform: scale(1.05);
    box-shadow: 0 10px 25px rgba(99, 102, 241, 0.4);
}

.chat-container {
    display: flex;
    height: 100vh;
}

.chat-sidebar {
    width: 280px;
    background: rgba(255, 255, 255, 0.03);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
}

.back-btn {
    padding: 12px 20px;
    background: transparent;
    border: none;
    color: #6366f1;
    font-size: 14px;
    cursor: pointer;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

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

.sidebar-title {
    padding: 12px 20px;
    font-size: 12px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.conversation-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.conversation-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    margin-bottom: 4px;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    color: #fff;
    width: 100%;
    transition: all 0.2s ease;
}

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

.conversation-item.active {
    background: rgba(99, 102, 241, 0.2);
}

.conversation-item .title {
    flex: 1;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 12px;
}

.conversation-item .time {
    font-size: 12px;
    color: #666;
}

.conversation-item .delete-btn {
    opacity: 0;
    font-size: 14px;
    background: none;
    border: none;
    color: #ff4444;
    cursor: pointer;
    padding: 4px;
    transition: opacity 0.2s ease;
}

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

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #0f0f1a;
}

.chat-header {
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.title-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

#conversation-title {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 4px;
    width: 200px;
}

#conversation-title:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.1);
}

#conversation-title[readonly] {
    cursor: default;
}

.edit-btn {
    background: none;
    border: none;
    font-size: 14px;
    cursor: pointer;
    padding: 4px;
    opacity: 0.5;
}

.edit-btn:hover {
    opacity: 1;
}

.model-select {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: #fff;
    padding: 8px 12px;
    font-size: 14px;
    cursor: pointer;
}

.model-select option {
    background: #1a1a2e;
    color: #fff;
}

.message-list {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.message {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.message.user {
    flex-direction: row-reverse;
}

.message.user .message-content {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 16px 16px 4px 16px;
}

.message.assistant {
    flex-direction: row;
}

.message.assistant .message-content {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 16px 16px 16px 4px;
}

.message-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    flex-shrink: 0;
}

.message.user .message-icon {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
}

.message.assistant .message-icon {
    background: linear-gradient(135deg, #4285f4, #ea4335);
}

.message-content {
    max-width: 70%;
    padding: 12px 16px;
    font-size: 15px;
    line-height: 1.5;
}

.chat-input-area {
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.03);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    gap: 12px;
}

#message-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: #fff;
    padding: 12px 16px;
    font-size: 15px;
    resize: none;
    min-height: 44px;
    max-height: 200px;
}

#message-input:focus {
    outline: none;
    border-color: rgba(99, 102, 241, 0.5);
}

#message-input::placeholder {
    color: #666;
}

.send-btn {
    padding: 12px 24px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.send-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4);
}

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

::-webkit-scrollbar {
    width: 6px;
}

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

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