:root {
    /* LAYOUT */
    --sidebar-width: 280px;
    
    /* FONTS */
    --font-main: 'Nunito', sans-serif;
    --font-header: 'Poppins', sans-serif;
    --font-code: 'JetBrains Mono', monospace;
    
    /* LIGHT THEME — Clean neutrals + pink accent */
    --bg-body: #f9fafb;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --bg-glass: rgba(255, 255, 255, 0.92);
    --text-primary: #111827;
    --text-secondary: #6b7280;
    
    /* BRAND ACCENT (Pink) */
    --accent: #ec4899;
    --accent-gradient: linear-gradient(135deg, #f472b6 0%, #ec4899 100%);
    --accent-glow: rgba(236, 72, 153, 0.15);
    --accent-light: rgba(236, 72, 153, 0.08);
    
    --border: rgba(0, 0, 0, 0.08);
    --shadow-light: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-float: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    
    --ai-bubble-bg: #f3f4f6;
    --user-bubble-bg: var(--accent);

    --input-bg: #ffffff;
    --input-border: rgba(0, 0, 0, 0.1);
    --shadow-light-hover: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.dark {
    /* DARK THEME — Clean dark grays + pink accent (like Claude/GPT aesthetic) */
    --bg-body: #171717;
    --bg-sidebar: #1e1e1e;
    --bg-card: #262626;
    --bg-glass: rgba(30, 30, 30, 0.92);
    --text-primary: #f5f5f5;
    --text-secondary: #a3a3a3;
    
    --accent: #f472b6;
    --accent-gradient: linear-gradient(135deg, #f472b6 0%, #ec4899 100%);
    --accent-glow: rgba(244, 114, 182, 0.2);
    --accent-light: rgba(244, 114, 182, 0.08);
    
    --border: rgba(255, 255, 255, 0.06);
    --shadow-light: 0 1px 3px rgba(0, 0, 0, 0.3);
    
    --ai-bubble-bg: #262626;
    --user-bubble-bg: #303030;

    --input-bg: #262626;
    --input-border: rgba(255, 255, 255, 0.08);
    --shadow-light-hover: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* --- GLOBAL & ANIMATIONS --- */
body {
    font-family: var(--font-main);
    background-color: var(--bg-body);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    display: flex;
    transition: background-color 0.5s ease;
}

h1, h2, h3, h4, h5 { font-family: var(--font-header); font-weight: 800; color: var(--text-primary); }

/* --- Dark Mode Visibility Fixes --- */
.dark .dropdown-item {
    color: var(--text-primary) !important; /* Ensure dropdown text is visible in dark mode */
}
.dark .dropdown-item:hover {
    color: var(--accent) !important; /* Keep accent color on hover */
}
.dark .text-secondary {
    color: var(--text-secondary) !important; /* Use dark theme secondary color */
}
.dark .text-muted {
    color: rgba(255, 255, 255, 0.5) !important; /* A lighter muted color for dark theme */
}
.dark #settings-email {
    background: rgba(255, 255, 255, 0.06) !important;
    color: var(--text-primary) !important;
    font-weight: 600;
}
.dark .bg-light {
    background: rgba(255, 255, 255, 0.06) !important;
}
/* End Dark Mode Visibility Fixes */


::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(150, 150, 150, 0.25); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(150, 150, 150, 0.5); }

/* --- FLUID BACKGROUND --- */
.blob-container { 
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
    z-index: -1; overflow: hidden; pointer-events: none; 
}

.blob { 
    position: absolute; 
    border-radius: 50%; 
    filter: blur(120px); 
    opacity: 0.25; 
    mix-blend-mode: multiply; 
    animation: drift 20s infinite ease-in-out alternate;
}
.dark .blob { mix-blend-mode: screen; opacity: 0.06; filter: blur(140px); }

.blob-1 { width: 500px; height: 500px; background: #fbcfe8; bottom: -100px; left: -100px; animation-duration: 25s; }
.blob-2 { width: 450px; height: 450px; background: #f5d0fe; top: -50px; right: -50px; animation-duration: 28s; animation-delay: -5s; }
.blob-3 { width: 350px; height: 350px; background: #f472b6; top: 40%; left: 40%; opacity: 0.15; animation-duration: 35s; animation-delay: -10s; }

@keyframes drift {
    0% { transform: translate(0, 0) scale(1) rotate(0deg); border-radius: 50%; }
    100% { transform: translate(0, 0) scale(1) rotate(0deg); border-radius: 50%; }
}

/* --- SIDEBAR --- */
#sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 50;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
}

#sidebar.collapsed {
    width: 0;
    opacity: 0;
    overflow: hidden;
    border-right: none;
}

.logo-area {
    padding: 1.8rem 1.5rem 1.5rem;
    font-family: var(--font-header);
    font-weight: 800;
    font-size: 1.5rem;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}
.logo-area sup { font-size: 0.5em; font-weight: 600; top: -0.6em; position: relative; color: var(--text-secondary); opacity: 0.8; }

.new-chat-btn {
    margin: 0 1rem 1rem;
    padding: 0.8rem 1.2rem;
    background: rgba(255,255,255,0.5);
    border: 2px solid var(--accent);
    border-radius: 1rem;
    color: var(--accent);
    font-weight: 700;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s;
    box-shadow: 0 4px 10px rgba(0,0,0,0.03);
    white-space: nowrap;
}
.new-chat-btn:hover { background: var(--accent); color: white; transform: translateY(-2px); box-shadow: 0 6px 15px var(--accent-glow); }
.dark .new-chat-btn { background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.12); color: var(--text-primary); }
.dark .new-chat-btn:hover { background: var(--accent); color: white; border-color: var(--accent); }

.history-search-wrap {
    margin: 0 1rem 0.9rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 0.75rem 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.history-search-wrap i {
    color: var(--text-secondary);
    opacity: 0.8;
}

.history-search-wrap input {
    width: 100%;
    border: none;
    background: transparent;
    outline: none;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.history-search-wrap input::placeholder {
    color: var(--text-secondary);
    opacity: 0.8;
}

.history-list { flex: 1; overflow-y: auto; padding: 0 1rem; }

.history-empty {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-align: center;
    padding: 1rem;
    opacity: 0.8;
}

.chat-item {
    padding: 0.8rem 1rem;
    margin-bottom: 0.5rem;
    border-radius: 1rem;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--text-secondary);
    transition: all 0.2s;
    border: 1px solid transparent;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-item:hover { background: var(--accent-light); opacity: 1; color: var(--accent); }
.chat-item.active { background: var(--bg-card); font-weight: 700; color: var(--text-primary); border-color: var(--border); box-shadow: 0 2px 8px rgba(0,0,0,0.03); }
.chat-item .delete-icon { opacity: 0; color: #dc3545; transition: 0.2s; }
.chat-item:hover .delete-icon { opacity: 1; }

/* --- WORKSPACE & CHAT --- */
#workspace { flex: 1; display: flex; position: relative; overflow: hidden; }

/* Resizing Logic */
#workspace.resizing { user-select: none; cursor: col-resize; }
#workspace.resizing #chat-pane { pointer-events: none; }
#workspace.resizing #canvas-pane { pointer-events: none; transition: none; } 

#chat-pane { flex: 1; display: flex; flex-direction: column; position: relative; min-width: 300px; }

.top-nav {
    padding: 0.85rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}

.top-upgrade-btn {
    border: 1px solid var(--accent);
    background: var(--accent-light);
    color: var(--accent);
    border-radius: 999px;
    padding: 0.25rem 0.7rem;
    font-size: 0.72rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: 0.02em;
    box-shadow: var(--shadow-light);
    transition: all 0.2s ease;
}

.top-upgrade-btn:hover {
    background: var(--accent);
    color: white;
    transform: translateY(-1px);
}

.model-pill {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 0.35rem 1rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--accent);
    box-shadow: var(--shadow-light);
    backdrop-filter: blur(10px);
}

/* Wallet/Credits Display */
.credit-wallet {
    display: none; align-items: center; gap: 0.5rem;
    background: var(--accent-light); color: var(--accent);
    padding: 0.35rem 1rem; border-radius: 999px;
    font-size: 0.85rem; font-weight: 700; border: 1px solid var(--accent);
    cursor: pointer; transition: 0.2s;
}
.credit-wallet:hover { background: var(--accent); color: white; }

#chat-stream { flex: 1; overflow-y: auto; padding: 1rem 2rem; scroll-behavior: smooth; }

/* Drag-Drop Overlay */
#drag-drop-overlay {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 50;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(6px);
    align-items: center;
    justify-content: center;
}
#drag-drop-overlay.show { display: flex; }

.drag-drop-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 2.5rem 3.5rem;
    border: 2px dashed var(--accent);
    border-radius: 1.5rem;
    color: var(--accent);
}
.drag-drop-content i { font-size: 2.5rem; }
.drag-drop-content span { font-size: 1rem; font-weight: 700; }

/* PDF File Preview in Attachment */
#preview-file-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-card);
    border-radius: 0.6rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
    border: 1px solid var(--border);
    max-width: 180px;
}
#preview-file-info i { color: #ef4444; font-size: 1.2rem; flex-shrink: 0; }
#preview-file-info span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Messages - Expanded horizontally */
.message {
    max-width: clamp(600px, 90%, 1100px); /* Adjust max-width for wider chat area */
    margin: 0 auto 1.5rem auto;
    display: flex;
    gap: 1rem;
    animation: popIn 0.3s ease-out;
}
@keyframes popIn { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

.avatar {
    width: 2.5rem; height: 2.5rem; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 1rem; flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}
.avatar.ai { background: var(--ai-bubble-bg); color: var(--accent); border: 1px solid var(--border); }
.avatar.user { background: var(--user-bubble-bg); color: white; }

.msg-content {
    padding: 1rem 1.25rem;
    border-radius: 1.2rem;
    line-height: 1.6;
    font-size: 1rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    max-width: 100%;
}

.response-meta {
    margin-top: 0.75rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--text-secondary);
    opacity: 0.75;
}

.message.ai .msg-content { background-color: var(--ai-bubble-bg); color: var(--text-primary); border-top-left-radius: 0.2rem; }
.message.user .msg-content { background-color: var(--user-bubble-bg); color: white; border-top-right-radius: 0.2rem; }
.dark .message.user .msg-content { color: var(--text-primary); }

/* Code Block Styles (Revised for clean line numbers and left-alignment) */
.msg-content pre { 
    background: #2d2d2d; 
    border-radius: 0.8rem; 
    padding: 0; /* Important: Remove default padding from pre */
    color: #f8f8f2; 
    overflow-x: auto; 
    margin: 1rem 0; 
    border: 1px solid rgba(255,255,255,0.1);
    position: relative; /* For code copy button positioning */
}

.msg-content pre code {
    display: block; /* Ensure it behaves like a block and takes full width */
    padding: 0; /* Remove default padding from code tag */
    font-family: var(--font-code); 
    font-size: 0.9em; 
    /* white-space: pre; removed, handled by .line-content */
}

/* Individual line wrapper inside the <code> block for line numbers */
.msg-content pre code .code-line-wrapper {
    display: grid;
    grid-template-columns: auto 1fr; /* Auto for numbers, 1fr for code */
    gap: 0.75rem; /* Space between number and code */
    line-height: 1.5;
    padding: 0 1rem; /* Padding for the entire line to match message bubble */
    min-height: 1.5em; /* Ensure empty lines have height */
    box-sizing: border-box; /* Include padding in element's total width and and height */
    text-align: left; /* Ensure the grid container is left-aligned */
}

.msg-content pre code .line-number {
    text-align: right;
    color: rgba(255,255,255,0.3); /* Softer color for numbers */
    user-select: none;
    padding: 0; /* No padding */
    margin: 0; /* No margin */
    min-width: 2em; /* Give numbers a minimum width to prevent collapse */
    flex-shrink: 0; /* Prevent shrinking on small code lines */
}

.msg-content pre code .line-content {
    white-space: pre-wrap; /* Allow long lines to wrap while preserving original formatting */
    word-break: break-all; /* Break words to prevent overflow where necessary */
    padding: 0 !important; /* Force no padding from highlight.js or other styles */
    margin: 0 !important; /* Force no margin */
    text-align: left; /* Explicitly left-align */
    /* Ensure no padding/margin on hljs spans directly within line-content */
    /* The '&' syntax is SCSS, if this is pure CSS, we need to explicitly list selectors */
    .hljs-comment, .hljs-keyword, .hljs-string, .hljs-number, .hljs-title, .hljs-attr, .hljs-tag, .hljs-name {
        padding: 0 !important;
        margin: 0 !important;
    }
}


/* Code Copy Button */
.code-copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(255,255,255,0.1);
    color: #f8f8f2;
    border: none;
    padding: 0.4rem 0.6rem;
    border-radius: 0.5rem;
    font-size: 0.8rem;
    cursor: pointer;
    opacity: 0; /* Hidden by default */
    transition: opacity 0.2s ease, background 0.2s ease;
    z-index: 1; /* Ensure button is above code content */
}
.msg-content pre:hover .code-copy-btn {
    opacity: 1; /* Show on hover of the pre block */
}
.code-copy-btn:hover {
    background: rgba(255,255,255,0.2);
}
.code-copy-btn.copied {
    background: #28a745; /* Green when copied */
    color: white;
}


.msg-content img {
    max-width: 100%;
    border-radius: 0.8rem;
    margin-top: 0.5rem;
}

.msg-content video {
    max-width: 100%;
    border-radius: 0.8rem;
    margin-top: 0.5rem;
    box-shadow: var(--shadow-light);
}

/* Action Buttons (General Message Actions) */
.msg-actions {
    display: flex; justify-content: flex-end; gap: 8px;
    margin-top: 8px; padding-top: 8px; border-top: 1px solid rgba(0,0,0,0.05);
    flex-wrap: wrap;
}
.dark .msg-actions { border-top-color: rgba(255,255,255,0.1); }

.action-btn {
    background: transparent; border: 1px solid transparent; border-radius: 6px;
    color: var(--text-secondary); padding: 4px 8px; font-size: 0.8rem;
    cursor: pointer; transition: all 0.2s; display: flex; align-items: center; gap: 4px;
}
.action-btn:hover { background: var(--accent-light); color: var(--accent); }

/* Typing Indicator */
.typing-bubble {
    background: var(--ai-bubble-bg);
    padding: 0.8rem 1.2rem;
    border-radius: 1.2rem;
    border-top-left-radius: 0.2rem;
    display: inline-flex;
    gap: 4px;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.typing-line {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text-secondary);
}
.typing-dots {
    display: inline-flex;
    gap: 4px;
    margin-left: 0.35rem;
    align-items: center;
}
.typing-dot {
    width: 6px; height: 6px; background: var(--accent); border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}
.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes bounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }

/* --- INPUT AREA --- */
.input-container {
    max-width: 850px;
    margin: 0 auto;
    padding: 1rem 1.5rem;
    width: 100%;
    position: relative;
}

.chat-input-wrapper {
    background: var(--input-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--input-border);
    border-radius: 2rem;
    padding: 0.75rem;
    display: flex;
    align-items: flex-end;
    box-shadow: var(--shadow-light);
    transition: all 0.3s ease;
    gap: 0.45rem;
    position: relative;
}
/* Enhanced input box highlighting */
.chat-input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

/* Renamed from #image-mode-badge to #mode-badge for generic use */
#mode-badge {
    display: none; align-items: center;
    background: var(--accent-light); color: var(--accent);
    padding: 0.4rem 0.8rem; border-radius: 999px;
    font-size: 0.8rem; font-weight: 700;
    white-space: nowrap; margin-bottom: 0.2rem;
    border: 1px solid var(--accent);
}
#mode-badge.active { display: flex; }
#mode-badge .close-mode { margin-left: 0.5rem; cursor: pointer; opacity: 0.6; transition: opacity 0.2s; }
#mode-badge .close-mode:hover { opacity: 1; }


textarea {
    flex: 1; border: none; background: transparent;
    resize: none; padding: 0.6rem 0.5rem; outline: none;
    color: var(--text-primary); max-height: 150px;
    font-size: 1rem; font-family: var(--bs-body-font-family);
}

.tool-btn {
    background: transparent; border: none; color: var(--text-secondary);
    padding: 0.6rem; border-radius: 50%; transition: 0.2s;
    cursor: pointer; opacity: 0.7; flex-shrink: 0;
}
.tool-btn:hover { background: var(--accent-light); color: var(--accent); opacity: 1; }

.mode-selector-btn {
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-primary);
    border-radius: 1rem;
    padding: 0.35rem 1.65rem 0.35rem 0.7rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.08rem;
    min-width: 96px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    box-shadow: var(--shadow-light);
    position: relative;
}

.mode-selector-btn:hover {
    transform: translateY(-1px);
    border-color: var(--accent);
    box-shadow: var(--shadow-light-hover);
}

.mode-selector-label {
    font-size: 0.76rem;
    font-weight: 800;
    line-height: 1;
}

.mode-selector-summary {
    font-size: 0.58rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--text-secondary);
    opacity: 0.8;
}

.mode-selector-btn i {
    position: absolute;
    right: 0.65rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.62rem;
    color: var(--text-secondary);
}

.chat-input-wrapper .mode-dropdown {
    right: 3.9rem;
    left: auto;
    width: 200px;
    bottom: 110%;
}

.custom-dropdown .dropdown-item-custom small {
    display: block;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.65rem;
}

.custom-dropdown .dropdown-item-custom.active {
    background: var(--accent-light);
    color: var(--accent);
}

.custom-dropdown .dropdown-item-custom.active i {
    color: var(--accent);
}

.custom-dropdown .dropdown-item-custom.active small {
    color: var(--accent);
}

.send-btn {
    background: var(--accent-gradient);
    color: white; border: none; border-radius: 50%;
    width: 2.5rem; height: 2.5rem; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    transition: 0.3s; box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}
.send-btn:hover { transform: scale(1.1); box-shadow: 0 6px 15px var(--accent-glow); }
.dark .send-btn { color: white; }

/* Attachment Preview */
#attachment-preview {
    position: absolute;
    bottom: 100%;
    left: 20px;
    margin-bottom: 10px;
    background: var(--bg-card);
    padding: 8px;
    border-radius: 12px;
    box-shadow: var(--shadow-light);
    border: 1px solid var(--border);
    display: none;
    animation: popIn 0.2s ease-out;
}
#attachment-preview.show { display: block; }
#attachment-preview img {
    height: 60px;
    width: auto;
    border-radius: 8px;
    display: block;
}
#attachment-preview .remove-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--text-primary);
    color: var(--bg-body);
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Scroll to bottom button styles */
#scroll-to-bottom-btn {
    position: absolute;
    bottom: 110px; /* Adjust based on input container height */
    right: 35px; /* Adjust as needed */
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background-color: var(--accent);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out, transform 0.2s ease;
    z-index: 10;
}
#scroll-to-bottom-btn.show {
    opacity: 1;
    visibility: visible;
}
#scroll-to-bottom-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px var(--accent-glow);
}


/* --- DRAG HANDLE (Resizer) --- */
#resizer {
    width: 12px;
    margin-left: -6px; margin-right: -6px;
    cursor: col-resize;
    background: transparent;
    z-index: 60;
    display: none;
    position: relative;
    flex-shrink: 0;
}
#resizer::after {
    content: ''; position: absolute;
    top: 0; bottom: 0; left: 5px;
    width: 2px; background: transparent;
    transition: background 0.2s;
}
#resizer:hover::after, #workspace.resizing #resizer::after {
    background: var(--accent);
}

/* --- CANVAS PANE --- */
#canvas-pane {
    width: 0;
    background: var(--bg-body);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: width 0.5s cubic-bezier(0.19, 1, 0.22, 1);
    overflow: hidden;
    box-shadow: -5px 0 30px rgba(0,0,0,0.05);
    z-index: 40;
    min-width: 0;
}
#canvas-pane.open { width: 55%; }

.canvas-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
    background: var(--bg-card); backdrop-filter: blur(10px);
}

iframe#preview-frame { flex: 1; border: none; background: white; width: 100%; height: 100%; }

/* --- UI COMPONENTS --- */
.preview-btn {
    display: inline-flex; align-items: center; gap: 0.5rem;
    padding: 0.5rem 1.2rem; margin-top: 0.8rem;
    background: var(--accent-light);
    border: none;
    border-radius: 0.8rem; font-size: 0.9rem; font-weight: 700;
    color: var(--accent); cursor: pointer;
    transition: all 0.2s; 
}
.preview-btn:hover { 
    background: var(--accent); 
    color: white; transform: translateY(-2px); 
}
.dark .preview-btn:hover { color: white; }

/* Tools Dropdown */
.custom-dropdown {
    position: absolute; bottom: 110%; left: 1rem;
    background: var(--bg-card); backdrop-filter: blur(20px);
    border: 1px solid var(--border); border-radius: 1rem;
    width: 200px; padding: 0.35rem; z-index: 100;
    display: none; flex-direction: column;
    box-shadow: var(--shadow-light-hover);
    animation: popUp 0.2s ease-out;
}
@keyframes popUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.custom-dropdown.show { display: flex; }

.dropdown-item-custom {
    padding: 0.55rem 0.85rem; border-radius: 0.6rem;
    color: var(--text-primary); text-decoration: none;
    display: flex; align-items: center; gap: 0.65rem;
    cursor: pointer; font-weight: 600; font-size: 0.88rem; transition: 0.15s;
}
.dropdown-item-custom i { color: var(--text-secondary); font-size: 0.95rem; width: 1.1rem; text-align: center; }
.dropdown-item-custom:hover { background: var(--accent-light); color: var(--accent); }
.dropdown-item-custom:hover i { color: var(--accent); }

/* User Menu */
.user-menu-area { padding: 1.5rem; border-top: 1px solid var(--border); }
.user-chip {
    display: flex; align-items: center; gap: 1rem;
    padding: 0.8rem; border-radius: 1.2rem;
    cursor: pointer; transition: 0.2s;
    border: 1px solid transparent; background: rgba(255,255,255,0.5);
}
.user-chip:hover { background: var(--bg-card); border-color: var(--border); box-shadow: var(--shadow-light); }
.dark .user-chip { background: rgba(255,255,255,0.05); }

/* Welcome Screen */
.hero-title {
    font-family: var(--font-header); font-weight: 800; font-size: 2.5rem;
    color: var(--text-primary); margin-bottom: 1rem;
}

.suggestion-card {
    background: var(--bg-card); border: 1px solid var(--border);
    padding: 1rem 1.5rem; border-radius: 1.5rem;
    font-weight: 600; color: var(--text-secondary); cursor: pointer;
    transition: all 0.2s; box-shadow: var(--shadow-light);
}
.suggestion-card:hover { transform: translateY(-3px); color: var(--accent); box-shadow: var(--shadow-light-hover); }

/* Pricing Cards */
.pricing-card {
    border: 1px solid var(--border); background: var(--bg-glass);
    border-radius: 1.5rem; padding: 2rem; text-align: center; transition: all 0.3s;
    height: 100%; display: flex; flex-direction: column; justify-content: space-between;
}
.pricing-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-light-hover); border-color: var(--accent); }

/* Highlighted Pro Card */
.pricing-card.featured { 
    border: 2px solid var(--accent); 
    background: linear-gradient(180deg, var(--bg-card) 0%, var(--accent-light) 100%); 
}

@keyframes pulse-bg {
    0% { background-color: #ef4444; }
    50% { background-color: #dc2626; }
    100% { background-color: #ef4444; }
}
.fest-banner {
    animation: pulse-bg 2s infinite;
}

.upgrade-btn {
    background: var(--accent-gradient); color: white; border: none; border-radius: 999px;
    padding: 12px 24px; font-weight: 700; width: 100%; margin-top: auto;
    transition: all 0.3s ease; box-shadow: 0 4px 15px var(--accent-glow);
}
.upgrade-btn:hover { transform: translateY(-2px) scale(1.02); box-shadow: 0 8px 25px var(--accent-glow); color: white; }
.upgrade-btn.disabled-plan { background: #6c757d !important; color: white !important; cursor: default !important; transform: none !important; box-shadow: none !important; opacity: 0.8; }

/* --- Toast Styles (REVISED) --- */
.toast {
    /* Reset Bootstrap's default max-width for better horizontal flow */
    max-width: none; 
    width: auto;     
    display: block; /* Ensure it doesn't get weird flex behaviors from parent container */
    
    background-color: var(--bg-card); /* Use card background for consistency */
    border: 1px solid var(--border);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 0.75rem;
    box-shadow: var(--shadow-light-hover);
}

.toast .d-flex {
    /* This inner d-flex wraps the toast-body and btn-close */
    align-items: center; /* Vertically center content and button */
    justify-content: space-between; /* Push button to end */
    padding: 0.75rem 1rem; /* Padding for the entire toast content area */
}

.toast-body {
    /* Text styling */
    font-weight: 700;
    padding: 0; /* Remove padding here, it's on the .d-flex container now */
    margin-right: 1rem; /* Space before close button */
    word-break: break-word; /* Allow long words to break */
    flex-grow: 1; /* Allow text to take available space */
    color: var(--text-primary); /* Default text color */
}

/* Specific toast types - backgrounds and text colors */
.toast.toast-success { 
    background-color: var(--accent-light); 
    border-color: var(--accent); 
}
.toast.toast-success .toast-body { 
    color: var(--accent); /* Light theme specific accent color */
}
.dark .toast.toast-success { 
    background-color: rgba(244, 114, 182, 0.15); /* Darker background for dark mode success */
    border-color: #f472b6; 
}
.dark .toast.toast-success .toast-body { 
    color: #f472b6; /* Dark mode specific accent color */
}

.toast.toast-error { 
    background-color: rgba(220, 53, 69, 0.15); /* Light red background */
    border-color: #dc3545; /* Red border */
}
.toast.toast-error .toast-body { 
    color: #dc3545; /* Light theme specific red color */
}
.dark .toast.toast-error { 
    background-color: rgba(220, 53, 69, 0.15); /* Same dark mode background */
    border-color: #dc3545; 
}
.dark .toast.toast-error .toast-body { 
    color: #f8a1a8; /* Lighter red for dark mode */
}

.toast.toast-info { 
    background-color: var(--bg-card); /* Info toasts use general card background */
    border-color: var(--border); 
}
.toast.toast-info .toast-body { 
    color: var(--text-primary); /* Info toasts use primary text color */
}
.dark .toast.toast-info { 
    background-color: var(--bg-card); 
    border-color: var(--border); 
}
.dark .toast.toast-info .toast-body { 
    color: var(--text-primary); 
}

/* Close button styling */
.toast .btn-close {
    /* Override Bootstrap's default btn-close-white to ensure visibility */
    background-image: var(--bs-btn-close-bg); /* Use Bootstrap's variable for background SVG */
    opacity: 0.7;
    transition: opacity 0.2s;
    filter: none; /* Remove any previous filter, let default Bootstrap/SVG handle color */
}
.dark .toast .btn-close {
    filter: invert(1) grayscale(1) brightness(1.5); /* Invert for dark theme, make it brighter */
}
.toast .btn-close:hover {
    opacity: 1;
}

/* Toast container for positioning */
.toast-container {
    margin-top: 1rem; /* Space from top */
    min-width: 250px; /* Ensure minimum width for a decent toast size */
    max-width: 80%; /* Limit overall width */
}


/* Quota Banner */
.quota-banner {
    background-color: rgba(255, 107, 107, 0.1);
    color: #ff6b6b;
    padding: 8px 12px;
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    border: 1px solid rgba(255, 107, 107, 0.2);
    animation: slideDown 0.3s ease forwards;
}
.quota-banner.d-none { display: none !important; }

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Mobile */
@media (max-width: 768px) {
    #sidebar { position: fixed; height: 100%; transform: translateX(-100%); width: 280px; }
    #sidebar.open { transform: translateX(0); }
    #canvas-pane.open { position: fixed; width: 100%; height: 100%; z-index: 60; top: 0; right: 0; }
    .hero-title { font-size: 2rem; }
    #resizer { display: none !important; }

    #scroll-to-bottom-btn {
        right: 15px; /* Adjust for smaller screens */
        bottom: 90px;
    }
    .message {
        max-width: 95%; /* Make messages take more width on small screens */
    }
}
