:root {
    --primary-color: #ff4444;
    --primary-hover: #ff6b64;
    --bg-color: #f5f5f5;
    --card-bg: #ffffff;
    --text-primary: #333333;
    --text-secondary: #666666;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

.model-selector, 
.current-model,
.model-card,
#sendButton,
#userInput {
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

body {
    font-family: "Inter", sans-serif;
    background: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    padding: 1rem 2rem;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-lg);
}

.header img {
    width: 38px;
    height: 38px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.header img:hover {
    transform: scale(1.1) rotate(-5deg);
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    animation: fadeIn 0.6s ease;
  }
  
  @keyframes fadeIn {
    from {
      opacity: 0;
    }
    to {
      opacity: 1;
    }
  }
  
  .header-left span {
    color: #fff;
    font-weight: 700;
  }

.logo {
    color: white;
    font-size: 1.5rem;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.model-selector {
    position: relative;
}

.current-model {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 0.75rem 1.25rem;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition);
}

.current-model:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
}

.arrow-icon {
    width: 20px;
    height: 20px;
    fill: currentColor;
    transition: var(--transition);
}

.arrow-icon.active {
    transform: rotate(180deg);
}

.model-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    width: 300px;
    max-height: 480px;
    overflow-y: auto;
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 0.75rem;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px) scale(0.98);
    transition: var(--transition);
}

.model-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.model-category {
    margin-bottom: 1rem;
}

.model-category h3 {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
    padding: 0 0.5rem;
}

.model-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
}

.model-card {
    position: relative;
    background: #f8f9fa;
    border-radius: 12px;
    padding: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
    display: flex;
    align-items: center;
}

.model-card:hover {
    background: #f0f2f5;
    border-color: var(--primary-color);
    transform: translateX(4px);
}

.model-icon {
    font-size: 1rem;
    margin-right: 0.5rem;
}

.model-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

.model-badge {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    background: var(--primary-color);
    color: white;
    font-size: 0.625rem;
    padding: 0.125rem 0.375rem;
    border-radius: 6px;
    font-weight: 500;
}

.chat-container {
    margin-top: 5rem;
    padding: 1rem;
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
}

.messages {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 1rem;
    overflow-y: auto;
    max-height: calc(100vh - 12rem);
}

.message {
    max-width: 85%;
    padding: 1.25rem;
    border-radius: 1rem;
    line-height: 1.5;
    animation: messageAppear 0.3s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    word-break: break-word;
    overflow-wrap: break-word;
}

.message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    color: white;
    border-bottom-right-radius: 0.25rem;
}

.message.bot {
    align-self: flex-start;
    background: var(--card-bg);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-bottom-left-radius: 0.25rem;
}

.input-container {
    position: fixed;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 2rem);
    max-width: 1168px;
    display: flex;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
}

#userInput {
    flex: 1;
    padding: 0.875rem 1.25rem;
    border: 2px solid #eee;
    border-radius: 0.75rem;
    font-size: 1rem;
    background: #f8f9fa;
    resize: none;
    min-height: 48px;
    line-height: 1.5;
    font-family: "Inter", sans-serif;
    transition: none;  /* Remove all transitions */
    will-change: auto; /* Remove will-change */
}

#userInput::-webkit-scrollbar {
    width: 6px;
}

#userInput::-webkit-scrollbar-track {
    background: transparent;
}

#userInput::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}

#userInput::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}

#userInput:focus {
    outline: none;
    border-color: var(--primary-color);
    background: white;
    box-shadow: 0 0 0 4px rgba(255, 68, 68, 0.1);
    transition: none; /* Remove transition on focus */
}

#sendButton {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
}

#sendButton:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

#sendButton.stop {
    background: var(--text-secondary);
}

.model-menu::-webkit-scrollbar {
    width: 6px;
}

.model-menu::-webkit-scrollbar-track {
    background: transparent;
}

.model-menu::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}

.model-menu::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}

@keyframes messageAppear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 768px) {
    .header {
        padding: 0.75rem 1rem;
    }

    .model-menu {
        width: 280px;
        max-height: 400px;
    }

    .message {
        max-width: 90%;
    }

    .input-container {
        bottom: 0.5rem;
        padding: 0.75rem;
    }
}

@media (max-width: 480px) {
    .logo {
        font-size: 1.25rem;
    }

    .current-model {
        padding: 0.5rem 1rem;
    }

    .model-menu {
        width: 260px;
    }

    .input-container {
        padding: 0.5rem;
        gap: 0.5rem;
    }

    #userInput {
        padding: 0.5rem 0.75rem;
    }

    #sendButton {
        padding: 0.5rem;
    }
}

.model-card {
    position: relative;
    background: #f8f9fa;
    border-radius: 12px;
    padding: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
    display: flex;
    align-items: center;
}

.model-card.selected {
    background: var(--primary-color);
    color: white;
}

.model-card.selected .model-name {
    color: white;
}

.model-card.selected:hover {
    background: var(--primary-hover);
    border-color: white;
}

#sendButton.stop {
    background: var(--text-secondary);
    position: relative;
    transition: all 0.3s ease;
}

#sendButton.stop:hover {
    background: #ff4444;
    transform: scale(1.05);
}

#sendButton.stop svg {
    transform: scale(1.1);
}


.chat-container {
    margin-top: 5rem;
    padding: 1rem;
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    position: relative;
    height: calc(100vh - 5rem);
    display: flex;
    flex-direction: column;
}

.messages {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 2rem;
    overflow-y: auto;
    max-height: calc(100vh - 12rem);
    scroll-behavior: smooth;
}

.message {
    max-width: 85%;
    padding: 1.25rem;
    border-radius: 1rem;
    line-height: 1.5;
    text-wrap: wrap;
    animation: messageAppear 0.3s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.input-container {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 3rem);
    max-width: 1168px;
    display: flex;
    gap: 1rem;
    padding: 1.25rem;
    background: var(--card-bg);
    border-radius: 1rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

#userInput {
    flex: 1;
    padding: 0.875rem 1.25rem;
    border: 2px solid #eee;
    border-radius: 0.75rem;
    font-size: 1rem;
    transition: var(--transition);
    background: #f8f9fa;
}

#userInput:focus {
    outline: none;
    border-color: var(--primary-color);
    background: white;
    box-shadow: 0 0 0 4px rgba(255, 68, 68, 0.1);
}

#sendButton {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 0.75rem;
    padding: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#sendButton:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

/* Custom scrollbar for messages */
.messages::-webkit-scrollbar {
    width: 8px;
}

.messages::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
}

.messages::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
    opacity: 0.8;
}

.messages::-webkit-scrollbar-thumb:hover {
    background: var(--primary-hover);
}

/* Enhanced loading animation */
.loading-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 500;
    color: var(--text-secondary);
}

.loading-dots::after {
    content: '';
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: currentColor;
    animation: dotPulse 1.5s infinite;
    box-shadow: 8px 0 0 0 currentColor, 16px 0 0 0 currentColor;
}

@keyframes dotPulse {
    0% { opacity: 0.2; }
    20% { opacity: 1; }
    100% { opacity: 0.2; }
}

/* Smooth scroll behavior */
.messages {
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) rgba(0, 0, 0, 0.05);
}

/* Loading text animation */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.loading-dots {
    background: linear-gradient(90deg, 
        var(--text-secondary) 25%, 
        var(--primary-color) 50%, 
        var(--text-secondary) 75%
    );
    background-size: 200% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: shimmer 2s infinite;
}

@media (max-width: 768px) {
    .header {
        padding: 0.75rem 1rem;
    }

    .model-menu {
        width: 320px;
        max-height: 70vh;
        right: -10px;
    }

    .chat-container {
        margin-top: 4.5rem;
    }

    .messages {
        padding: 1.5rem;
        gap: 1.25rem;
        max-height: calc(100vh - 10rem);
    }

    .message {
        max-width: 85%;
        padding: 1rem 1.25rem;
    }

    .input-container {
        bottom: 1rem;
        padding: 1rem;
        width: calc(100% - 2rem);
    }
}

@media (max-width: 480px) {
    .header-left img {
        width: 34px;
        height: 34px;
    }

    .logo {
        font-size: 1.25rem;
    }

    .current-model {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }

    .model-menu {
        width: 280px;
        right: -15px;
        max-height: 65vh;
    }

    .model-card {
        padding: 0.75rem;
    }

    .messages {
        padding: 1rem;
        gap: 1rem;
    }

    .message {
        max-width: 90%;
        padding: 1rem;
        font-size: 0.95rem;
    }

    .input-container {
        padding: 0.875rem;
        gap: 0.75rem;
        bottom: 0.75rem;
    }

    #userInput {
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
    }

    #sendButton {
        width: 44px;
        height: 44px;
    }
}

@media (max-width: 360px) {
    .header {
        padding: 0.625rem;
    }

    .header-left img {
        width: 32px;
        height: 32px;
    }

    .logo {
        font-size: 1.15rem;
    }

    .current-model {
        padding: 0.5rem 0.625rem;
        font-size: 0.85rem;
    }

    .model-menu {
        width: 260px;
        right: -12px;
        max-height: 60vh;
    }

    .messages {
        padding: 0.875rem;
        gap: 0.875rem;
    }

    .message {
        max-width: 95%;
        padding: 0.875rem;
        font-size: 0.9rem;
        line-height: 1.35;
    }

    .input-container {
        padding: 0.75rem;
        gap: 0.625rem;
        bottom: 0.5rem;
        width: calc(100% - 1.5rem);
    }

    #userInput {
        padding: 0.625rem 0.875rem;
        font-size: 0.9rem;
    }

    #sendButton {
        width: 40px;
        height: 40px;
        padding: 0.625rem;
    }
}