:root {
    /* Core Colors */
    --bg-color: #ffffff;
    --sidebar-bg: #f8f9fa;
    --text-color: #1f2937;
    --text-muted: #6b7280;
    --border-color: #e5e7eb;

    /* Message Bubble Colors */
    --message-user-bg: #2563eb;
    /* Royal Blue */
    --message-user-text: #ffffff;
    --message-ai-bg: #ffffff;
    --message-ai-text: #1f2937;

    /* Input & Interactive */
    --input-bg: #ffffff;
    --accent-color: #2563eb;
    --accent-hover: #1d4ed8;

    /* Effects */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.5);
    --blur: 12px;
}

[data-theme="dark"] {
    /* Dark Mode - Premium Slate/Zinc Palette */
    --bg-color: #09090b;
    /* Zinc 950 */
    --sidebar-bg: #121215;
    /* Slightly lighter */
    --text-color: #f3f4f6;
    /* Zinc 100 */
    --text-muted: #9ca3af;
    /* Zinc 400 */
    --border-color: #27272a;
    /* Zinc 800 */

    --message-user-bg: #3b82f6;
    /* Blue 500 */
    --message-user-text: #ffffff;
    --message-ai-bg: #18181b;
    /* Zinc 900 */
    --message-ai-text: #f3f4f6;

    --input-bg: #18181b;
    --accent-color: #3b82f6;
    --accent-hover: #60a5fa;

    --glass-bg: rgba(24, 24, 27, 0.7);
    --glass-border: rgba(255, 255, 255, 0.05);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow: hidden;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* --- Animations --- */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* --- Layout --- */
.app-body {
    display: flex;
    height: 100dvh;
    width: 100vw;
}

/* --- Sidebar --- */
.sidebar {
    width: 280px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1rem;
    gap: 1rem;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 50;
    flex-shrink: 0;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 0.5rem;
}

.sidebar-header h3 {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

#new-chat-btn {
    background: var(--accent-color);
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
    margin: 0;
    flex-shrink: 0;
}

#mobile-close-sidebar {
    background: transparent;
    /* Ghost style */
    color: var(--text-color);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 0.5rem;
    cursor: pointer;
    display: flex;
    /* Ensure centering */
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

#mobile-close-sidebar:hover {
    background: rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] #mobile-close-sidebar:hover {
    background: rgba(255, 255, 255, 0.1);
}

#new-chat-btn:hover {
    background-color: var(--accent-hover);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.history-list {
    flex: 1;
    overflow-y: auto;
    margin: 0 -0.5rem;
    padding: 0 0.5rem;
}

.history-item {
    display: block;
    padding: 0.75rem 1rem;
    margin-bottom: 0.25rem;
    border-radius: 0.5rem;
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background-color 0.2s;
    border: 1px solid transparent;
}

.history-item:hover {
    background-color: rgba(0, 0, 0, 0.03);
}

[data-theme="dark"] .history-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.history-item.active {
    background-color: rgba(37, 99, 235, 0.1);
    color: var(--accent-color);
    border-color: rgba(37, 99, 235, 0.2);
}

.user-profile {
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.9rem;
    font-weight: 500;
}

.user-actions {
    display: flex;
    gap: 0.5rem;
}

.user-actions button,
.user-actions a {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    padding: 0.4rem;
    border-radius: 0.375rem;
    transition: color 0.2s, background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-actions button:hover,
.user-actions a:hover {
    color: var(--text-color);
    background-color: rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .user-actions button:hover,
[data-theme="dark"] .user-actions a:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

/* --- Main Content --- */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background-color: var(--bg-color);
    width: 100%;
    overflow: hidden;
}

.top-bar {
    height: 60px;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(var(--bg-color), 0.8);
    /* Just to keep place, glass effect handled below if needed */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 10;
}

.model-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-color);
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.model-name::before {
    content: '';
    display: block;
    width: 8px;
    height: 8px;
    background-color: #10b981;
    /* Green dot */
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.4);
}

/* --- Workspace --- */
.workspace {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
}

.chat-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    max-width: 100%;
    min-height: 0;
    /* Fix for flex container scrolling */
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    /* Fix for flex container scrolling */
    padding: 2rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    scroll-behavior: smooth;
}

.message {
    width: 100%;
    max-width: 850px;
    margin: 0 auto;
    display: flex;
    gap: 1rem;
    animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.message.user {
    justify-content: flex-end;
}

.message .content {
    padding: 1rem 1.25rem;
    border-radius: 1rem;
    font-size: 1rem;
    line-height: 1.6;
    position: relative;
    box-shadow: var(--shadow-sm);
    max-width: 85%;
}

.message.user .content {
    background: var(--message-user-bg);
    color: var(--message-user-text);
    border-bottom-right-radius: 0.25rem;
}

.message.assistant .content {
    background: var(--message-ai-bg);
    color: var(--message-ai-text);
    border-bottom-left-radius: 0.25rem;
    border: 1px solid var(--border-color);
}

/* --- Rich Content Styling --- */
.message .content h1,
.message .content h2,
.message .content h3 {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
    line-height: 1.3;
}

.message .content h1 {
    font-size: 1.4em;
}

.message .content h2 {
    font-size: 1.25em;
}

.message .content h3 {
    font-size: 1.1em;
}

.message .content ul,
.message .content ol {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.message .content table {
    border-collapse: collapse;
    width: 100%;
    margin: 1rem 0;
    font-size: 0.9em;
    border-radius: 8px;
    overflow: hidden;
}

.message .content th,
.message .content td {
    border: 1px solid var(--border-color);
    padding: 0.6rem;
    text-align: left;
}

.message .content th {
    background-color: rgba(0, 0, 0, 0.05);
    font-weight: 600;
}

[data-theme="dark"] .message .content th {
    background-color: rgba(255, 255, 255, 0.05);
}

/* Source Cards */
.sources-section {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.sources-section h4 {
    margin: 0 0 1rem 0;
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sources-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.citation-link {
    font-size: 0.75em;
    vertical-align: super;
    color: var(--accent-color);
    text-decoration: none;
    margin: 0 2px;
    background: rgba(37, 99, 235, 0.1);
    padding: 2px 5px;
    border-radius: 4px;
    font-weight: 600;
    transition: all 0.2s;
}

.citation-link:hover {
    background: var(--accent-color);
    color: white;
}

.source-card {
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px;
    width: 100%;
    max-width: 300px;
    flex: 1 1 220px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-decoration: none;
    color: var(--text-color);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.source-card:hover {
    border-color: var(--accent-color);
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    background: var(--surface-color);
}

.source-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 2px;
}

.source-favicon {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    flex-shrink: 0;
}

.source-site-name {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.source-card-title {
    font-weight: 600;
    font-size: 0.9rem;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: var(--text-color);
}

/* Enhanced Code Blocks */
.code-wrapper {
    margin: 1rem 0;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: #1e1e1e;
    /* Always dark bg for code */
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.08);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: #e0e0e0;
    font-size: 0.8rem;
    font-family: 'Inter', sans-serif;
}

.code-lang {
    text-transform: uppercase;
    font-weight: 600;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

.copy-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #e0e0e0;
    border-radius: 4px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    padding: 4px 8px;
    transition: all 0.2s;
}

.copy-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: #fff;
    color: #fff;
}

.message .content pre {
    margin: 0;
    border-radius: 0;
    border: none;
    background: transparent;
}

code {
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 0.9em;
    background: rgba(0, 0, 0, 0.1);
    padding: 0.2em 0.4em;
    border-radius: 0.25em;
}

pre code {
    background: transparent;
    padding: 0;
}

/* Interactive Elements inside chat */
.memory-wrapper {
    margin-top: 0.5rem;
    display: block;
}

.memory-btn {
    font-size: 0.75rem;
    color: var(--accent-color);
    background: rgba(37, 99, 235, 0.1);
    padding: 0.25rem 0.6rem;
    border-radius: 1rem;
    border: 1px solid rgba(37, 99, 235, 0.2);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    transition: all 0.2s;
}

.memory-btn:hover {
    background: rgba(37, 99, 235, 0.2);
}

.memory-content {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    padding: 0.75rem;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    color: var(--text-color);
    animation: fadeIn 0.2s ease;
    display: none;
}

.memory-content.visible {
    display: block;
}


/* --- Input Area --- */
.input-area {
    padding: 1.5rem;
    background: transparent;
    display: flex;
    justify-content: center;
    width: 100%;
    position: relative;
    max-width: 100%;
    /* Edge to edge as requested */
}

.input-area form {
    width: 100%;
}

.input-wrapper-styled {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 0.75rem;
    box-shadow: var(--shadow-md);
    transition: box-shadow 0.2s, border-color 0.2s;
    width: 100%;
    position: relative;
    margin: 0 auto;
    /* Center if width < 100% */
}

.input-wrapper-styled:focus-within {
    box-shadow: var(--shadow-lg);
    border-color: var(--accent-color);
}

#chat-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-color);
    font-family: inherit;
    font-size: 1rem;
    resize: none;
    outline: none;
    padding: 0.25rem;
    min-height: 24px;
    max-height: 200px;
    line-height: 1.5;
}

#send-btn,
#upload-btn {
    background: transparent;
    color: var(--text-muted);
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

#send-btn {
    background-color: var(--accent-color);
    color: white;
}

#send-btn:hover {
    background-color: var(--accent-hover);
    transform: scale(1.05);
}

#upload-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: var(--text-color);
}

[data-theme="dark"] #upload-btn:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

/* Image Preview */
.image-preview {
    position: absolute;
    bottom: 100%;
    left: 0;
    margin-bottom: 0.5rem;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    padding: 0.5rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: var(--shadow-md);
    animation: fadeIn 0.2s;
}

/* --- Settings Modal --- */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100dvh;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s;
}

.modal[style*="display"] {
    opacity: 1;
}

.modal-content.settings-modal-content {
    background-color: var(--bg-color);
    width: 800px;
    max-width: 90vw;
    height: 600px;
    max-height: 90vh;
    border-radius: 1rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    overflow: hidden;
    display: flex;
    animation: fadeIn 0.3s ease-out;
}

.settings-sidebar {
    width: 240px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}

.settings-sidebar h3 {
    margin-top: 0;
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
    font-weight: 700;
}

.settings-tab-btn {
    text-align: left;
    background: transparent;
    border: none;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    color: var(--text-muted);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 0.25rem;
}

.settings-tab-btn:hover {
    color: var(--text-color);
    background-color: rgba(0, 0, 0, 0.03);
}

.settings-tab-btn.active {
    background-color: var(--accent-color);
    color: white;
}

.settings-body {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    position: relative;
}

.setting-group {
    margin-bottom: 2rem;
}

/* Initial state for settings pages */
.settings-page {
    display: none;
    animation: fadeIn 0.3s ease;
}

.settings-page.active {
    display: block;
}

.setting-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.95rem;
}

.setting-group select,
.setting-group textarea {
    width: 100%;
    padding: 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: inherit;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.setting-group select:focus,
.setting-group textarea:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.primary-btn {
    background-color: var(--accent-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.primary-btn:hover {
    background-color: var(--accent-hover);
}

.close-modal {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.2s;
}

.close-modal:hover {
    color: var(--text-color);
}


/* Toggle switches & specific UI polish */
.hidden {
    display: none !important;
}

/* Canvas Section (for Code) */
.canvas-section {
    width: 0;
    border-left: 1px solid var(--border-color);
    background: var(--bg-color);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.canvas-section.open {
    width: 50%;
}

.canvas-header {
    height: 60px;
    padding: 0 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-color);
}

.tabs {
    display: flex;
    gap: 1rem;
}

.tab-btn {
    background: none;
    border: none;
    padding: 0.5rem 0.25rem;
    color: var(--text-muted);
    font-weight: 600;
    cursor: pointer;
    position: relative;
}

.tab-btn.active {
    color: var(--text-color);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -18px;
    /* Align with header bottom */
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--accent-color);
}

.canvas-actions button {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    width: 32px;
    height: 32px;
    border-radius: 0.375rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.canvas-actions button:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

/* Mobile */
@media (max-width: 768px) {
    .app-body {
        flex-direction: column;
    }

    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        height: 100dvh;
        z-index: 999;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.2);
        transform: none;
        /* Reset transform based slide */
    }

    .sidebar.active {
        left: 0;
        transform: none;
    }

    .workspace {
        flex-direction: column;
    }

    /* Modal Mobile */
    .modal-content.settings-modal-content {
        width: 95%;
        height: 85dvh;
        max-height: 85dvh;
        flex-direction: column;
    }

    .settings-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 10px;
        display: flex;
        overflow-x: auto;
        gap: 10px;
        flex-shrink: 0;
    }

    .settings-sidebar h3 {
        display: none;
        /* Hide header to save space */
    }

    .settings-tab-btn {
        padding: 8px 12px;
        white-space: nowrap;
        margin-bottom: 0;
        flex: 0 0 auto;
    }

    .settings-body {
        padding: 15px;
    }

    /* Chat & Sources Mobile */
    .message .content {
        max-width: 92%;
    }

    .sources-grid {
        flex-direction: column;
        gap: 8px;
    }

    .source-card {
        max-width: 100%;
        flex: 1 1 auto;
    }

    .input-wrapper-styled {
        padding: 0.5rem;
    }

    #chat-input {
        min-height: 48px;
    }

    /* Hide canvas section by default on mobile, only show when .open */
    .canvas-section {
        display: none;
    }

    .canvas-section.open {
        display: flex;
        /* Restore flex display when open */
        position: fixed;
        width: 100%;
        height: 100dvh;
        z-index: 60;
        top: 0;
        left: 0;
    }

    .mobile-only {
        display: block;
    }

    .hidden-desktop {
        display: inline-block;
    }

    #sidebar-toggle {
        background: none;
        border: none;
        font-size: 1.25rem;
        color: var(--text-color);
        cursor: pointer;
    }

    /* Refined Mobile Sidebar Header */
    .sidebar-header {
        justify-content: flex-start;
        /* Title left */
        gap: 1rem;
        padding-right: 0.5rem;
        /* Space for buttons */
    }

    .sidebar-header h3 {
        flex: 1;
        /* Push buttons to right */
    }

    .sidebar-header button {
        margin-left: 4px;
    }
}

@media (min-width: 769px) {
    .mobile-only {
        display: none !important;
    }

    .hidden-desktop {
        display: none;
    }

    #sidebar-toggle {
        display: none;
    }
}

/* --- Authentication Pages --- */
.auth-body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: var(--bg-color);
}

.auth-container {
    width: 100%;
    max-width: 400px;
    padding: 1rem;
}

.auth-card {
    background: var(--input-bg);
    padding: 2.5rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    text-align: center;
}

.auth-card h2 {
    margin-top: 0;
    margin-bottom: 2rem;
    color: var(--text-color);
    font-weight: 700;
}

.auth-card form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.input-group i {
    position: absolute;
    left: 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    pointer-events: none;
}

.input-group input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    background: transparent;
    color: var(--text-color);
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.input-group input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.remember-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    justify-content: flex-start;
}

.auth-btn {
    background: var(--accent-color);
    color: white;
    padding: 0.75rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 0.5rem;
}

.auth-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.auth-switch {
    margin-top: 1.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.auth-switch a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 500;
}

.auth-switch a:hover {
    text-decoration: underline;
}

/* Flash Messages */
.flashes {
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.flash {
    padding: 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    text-align: left;
    animation: fadeIn 0.3s ease;
}

.flash.error {
    background-color: rgba(220, 38, 38, 0.1);
    color: #ef4444;
    /* Red 500 */
    border: 1px solid rgba(220, 38, 38, 0.2);
}

.flash.success {
    background-color: rgba(22, 163, 74, 0.1);
    color: #22c55e;
    /* Green 500 */
    border: 1px solid rgba(22, 163, 74, 0.2);
}

[data-theme="dark"] .flash.error {
    background-color: rgba(127, 29, 29, 0.2);
    /* Darker Red */
    color: #fca5a5;
    /* Red 300 */
}

[data-theme="dark"] .flash.success {
    background-color: rgba(20, 83, 45, 0.2);
    color: #86efac;
    /* Green 300 */
}

/* Fix for HTML Preview Width */
.canvas-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Prevent scrollbars from parent */
    position: relative;
}

.tab-content {
    display: none;
    flex: 1;
    height: 100%;
}

.tab-content.active {
    display: block;
}

/* Ensure preview tab specifically fills space if needed */
#preview-tab {
    width: 100%;
    height: 100%;
}

#preview-frame {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}