:root {
    --primary: #1310ed;
    --primary-hover: #1809ec;
    --bg-dark: #0f1115;
    --bg-card: rgba(25, 27, 33, 0.7);
    --bg-glass: rgba(255, 255, 255, 0.03);
    --border-glass: rgba(255, 255, 255, 0.08);
    --text-main: #e2e8f0;
    --text-muted: #f2f3f5;
    --radius-lg: 16px;
    --radius-md: 10px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow: hidden;
    height: 100vh;
}

.brand {
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    letter-spacing: -1px;
}

.brand span {
    color: var(--primary);
}

.glass {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
}

.hidden {
    display: none !important;
}

/* Auth Views */
#auth-view {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
}

.auth-card {
    padding: 40px;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 400px;
    text-align: center;
    animation: fadeIn 0.5s ease-out;
}

.auth-card h1 {
    font-size: 2.5rem;
    margin-bottom: 30px;
}

.auth-card h2 {
    font-size: 1.2rem;
    margin-bottom: 20px;
    color: var(--text-muted);
}

input,
select,
textarea {
    width: 100%;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    color: white;
    margin-bottom: 15px;
    outline: none;
    transition: 0.2s;
}

input:focus {
    border-color: var(--primary);
}

.primary-btn {
    width: 100%;
    padding: 12px;
    background: var(--primary);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: 0.3s;
}

.primary-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.reset-link {
    margin-top: 15px;
    font-size: 0.9rem;
    color: var(--text-muted);
    cursor: pointer;
}

/* Main Layout */
#main-view {
    display: flex;
    height: 100vh;
}

#sidebar {
    width: 280px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-glass);
}

.sidebar-header {
    padding: 25px;
}

.sidebar-content {
    flex: 1;
    padding: 0 15px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.new-chat-btn {
    width: 100%;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    color: white;
    cursor: pointer;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.history-list {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    padding-bottom: 20px;
}

.history-item {
    padding: 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-muted);
    transition: 0.2s;
    background: rgba(255, 255, 255, 0.02);
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: space-between;
}

.chat-title {
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 10px;
}

.delete-chat-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    opacity: 0;
    transition: 0.2s;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.history-item:hover .delete-chat-btn {
    opacity: 1;
}

.delete-chat-btn:hover {
    color: #ff4d4d;
    background: rgba(255, 77, 77, 0.1);
}

.history-item:hover,
.history-item.active {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
}

#chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: radial-gradient(circle at center, #1a1c22 0%, #0f1115 100%);
}

.chat-header {
    height: 60px;
    padding: 0 25px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#messages {
    flex: 1;
    overflow-y: auto;
    padding: 40px 20%;
}

.message {
    margin-bottom: 30px;
    line-height: 1.6;
    animation: slideUp 0.3s ease-out;
}

.message.user {
    text-align: right;
}

.message.user .content {
    background: var(--primary);
    display: inline-block;
    padding: 12px 20px;
    border-radius: 20px 20px 4px 20px;
}

.message.ai .content {
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: 4px 20px 20px 20px;
}

.input-area {
    padding: 20px 20%;
}

.input-container {
    position: relative;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    border-radius: 24px;
    padding: 10px 15px;
    display: flex;
    align-items: flex-end;
}

#chat-input {
    background: transparent;
    border: none;
    margin-bottom: 0;
    resize: none;
    max-height: 200px;
    resize: none;
    max-height: 200px;
    padding: 8px;
}

#chat-input:disabled {
    cursor: wait;
    background: rgba(255, 255, 255, 0.03);
}

#chat-input:disabled::placeholder {
    color: var(--text-main);
    opacity: 1;
    font-style: italic;
    animation: textPulse 1.5s infinite ease-in-out;
}

@keyframes textPulse {
    0% {
        opacity: 0.4;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.4;
    }
}

#send-btn {
    background: var(--primary);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    flex-shrink: 0;
}

/* User Pill */
.user-pill {
    margin: 15px;
    padding: 10px;
    border-radius: 30px;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    position: relative;
}

.user-menu {
    position: absolute;
    bottom: 60px;
    left: 0;
    width: 100%;
    border-radius: var(--radius-md);
    overflow: hidden;
}

.user-menu button {
    width: 100%;
    padding: 12px;
    background: transparent;
    border: none;
    color: white;
    text-align: left;
    cursor: pointer;
}

.user-menu button:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.scrollable::-webkit-scrollbar {
    width: 6px;
}

.scrollable::-webkit-scrollbar-thumb {
    background: var(--border-glass);
    border-radius: 3px;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    width: 90%;
    max-width: 600px;
    padding: 30px;
    border-radius: var(--radius-lg);
}

.user-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.user-table th,
.user-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-glass);
}

/* Loading Spinner */
.loading-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-muted);
    font-size: 0.9rem;
    padding: 10px 0;
}

.loading-indicator span {
    animation: textPulse 1.5s infinite ease-in-out;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Markdown Styles */
.markdown-body {
    line-height: 1.6;
}

.markdown-body p {
    margin-bottom: 10px;
}

/* Model Lab Enhanced UI */
.lab-mode-toggle {
    display: flex;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 4px;
    margin-bottom: 20px;
    width: fit-content;
}

.lab-mode-toggle button {
    background: transparent;
    border: none;
    padding: 8px 20px;
    color: var(--text-muted);
    border-radius: 6px;
    cursor: pointer;
    transition: 0.2s;
    font-size: 0.9rem;
}

.lab-mode-toggle button.active {
    background: var(--primary);
    color: white;
}

.lab-mode-toggle button:hover:not(.active) {
    color: white;
}

.form-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

#lab-system-prompt {
    font-family: inherit;
    line-height: 1.5;
    resize: vertical;
}

#lab-temp,
#lab-ctx {
    width: 100%;
}

/* Range Input Styling */
input[type=range] {
    -webkit-appearance: none;
    background: transparent;
    appearance: none;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 16px;
    width: 16px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    margin-top: -6px;
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}