:root {
    --primary-text-color: #2c3e50;
    --secondary-text-color: #7f8c8d;
    --accent-color: #8e44ad;
    --danger-color: #c0392b;
    --success-color: #27ae60;
    --user-bubble-bg: linear-gradient(135deg, #8e44ad, #9b59b6);
    --font-family: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --surface-glass: rgba(255, 255, 255, 0.5);
    --border-glass: 1px solid rgba(255, 255, 255, 0.2);
}

* { box-sizing: border-box; }

body {
    font-family: var(--font-family);
    background: linear-gradient(120deg, #a1c4fd 0%, #c2e9fb 100%);
    margin: 0;
    color: var(--primary-text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    min-height: 100vh;
}

#app-container {
    width: 100%;
    max-width: 1200px;
    height: calc(100vh - 40px);
    max-height: 1600px;
    background: var(--surface-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 24px;
    border: var(--border-glass);
    box-shadow: 0 8px 32px rgba(31, 38, 135, 0.15);
}

.header {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    /* MODIFIED: Reduced vertical padding from 16px to 10px */
    padding: 10px 24px; 
    border-bottom: var(--border-glass);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    transition: padding 0.2s ease, font-size 0.2s ease;
}
.header-left { 
    display: flex; 
    align-items: center; 
    /* MODIFIED: Reduced the gap between the icon and title */
    gap: 12px; 
}
.header-right {
    display: flex;
    align-items: center; /* Vertically centers the items */
    gap: 16px;           /* Creates space between the text and the dropdown */
}

/* NEW: Hide the main app container by default to prevent flash of content before auth check */
#app-container {
    visibility: hidden;
}

.footer-contact {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 24px;
    font-size: 0.8rem;
    color: var(--secondary-text-color);
    background-color: rgba(255, 255, 255, 0.2);
    border-top: var(--border-glass);
}

.debug-mode-container {
    display: flex;
    align-items: center;
    gap: 6px;
}

.debug-mode-container label {
    font-size: 0.8rem;
    cursor: pointer;
    user-select: none;
}
.debug-mode-container input[type="checkbox"] {
    cursor: pointer;
}
.header-icon { 
    /* MODIFIED: Made the icon slightly smaller */
    font-size: 24px; 
    transition: font-size 0.2s ease; 
}

/* === START: UPDATED STYLES FOR CUSTOM HEADER === */
.header-title .title-line {
    display: flex;
    align-items: center;
    /* MODIFIED: Reduced the gap between title and badge */
    gap: 8px;
}
.header-title h1 {
    margin: 0;
    /* MODIFIED: Reduced the main title font size */
    font-size: 22px; 
    font-weight: 600;
    color: #2c3e50;
    transition: font-size 0.2s ease;
}
.version-badge {
    background-color: #e9ecef;
    color: #868e96;
    /* MODIFIED: Adjusted padding for the smaller font */
    padding: 2px 8px; 
    border-radius: 12px;
    /* MODIFIED: Made the badge text smaller */
    font-size: 12px; 
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
}

/* Styling for the subtitle paragraph */
.header-title p {
    margin: 4px 0 0 0; /* Adds a little space above the subtitle */
    font-size: 14px;
    color: #868e96; /* Muted text color, matching the badge */
}

/* --- START: NEW STYLES FOR HEADER CONTROLS --- */
#bot-selector {
    background-color: rgba(255, 255, 255, 0.3);
    border: var(--border-glass);
    border-radius: 8px;
    padding: 6px 12px;
    font-family: var(--font-family);
    font-size: 14px;
    font-weight: 500;
    color: var(--primary-text-color);
    cursor: pointer;
    transition: background-color 0.2s ease;
}
#bot-selector:hover {
     background-color: rgba(255, 255, 255, 0.5);
}
#bot-selector:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--accent-color);
}
/* --- END: NEW STYLES FOR HEADER CONTROLS --- */

/* NEW: Wrapper for chat area to correctly position scroll buttons */
#chat-view-wrapper {
    position: relative; /* Anchor for scroll controls */
    flex: 1 1 auto;     /* Takes the place of chat-container in the flex layout */
    display: flex;      /* To make chat-container fill it */
    flex-direction: column; /* Stack banner and chat vertically */
    overflow: hidden;   /* Ensures content doesn't spill out */
}

/* --- START: NEW STYLES FOR PRIVACY BANNER --- */
#privacy-banner {
    padding: 10px 16px;
    background-color: rgba(44, 62, 80, 0.1); /* A neutral, dark-ish color */
    border-bottom: 1px solid rgba(44, 62, 80, 0.2);
    color: #2c3e50; /* Primary text color */
    font-size: 14px;
    font-weight: 500;
    display: flex; /* Use flex to align icon and text */
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-shrink: 0;
}
/* --- END: NEW STYLES FOR PRIVACY BANNER --- */

#chat-container { 
    flex: 1 1 auto;
    overflow-y: auto; 
    padding: 24px; 
    display: flex; 
    flex-direction: column;
}
#chat-output { display: flex; flex-direction: column; gap: 25px; }

.message-wrapper { 
    position: relative; 
    display: flex; 
    /* MODIFIED: Changed to column layout */
    flex-direction: column;
    /* MODIFIED: Adjusted gap for vertical spacing */
    gap: 8px; 
    max-width: 95%; 
    /* align-items will be set per-sender type */
    transition: opacity 0.3s ease;
}
.message-wrapper-user { 
    align-self: flex-end; 
    /* MODIFIED: Align user items to the right */
    align-items: flex-end; 
}
.message-wrapper-bot { 
    align-self: flex-start; 
    /* MODIFIED: Align bot items to the left */
    align-items: flex-start; 
}

/* NEW: Styles for system messages */
.system-message {
    align-self: center;
    background-color: #e9ecef;
    color: #6c757d;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-style: italic;
}

/* NEW: Styles for the message header (avatar + model name) */
.message-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* NEW: Styles for the model name text */
.model-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--secondary-text-color);
}

.avatar {
    width: 32px; height: 32px; /* MODIFIED: Made avatar smaller */
    border-radius: 50%; flex-shrink: 0;
    background-color: white; display: flex; align-items: center; justify-content: center;
    font-weight: 600; box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: background-color 0.3s ease, color 0.3s ease, opacity 0.3s ease;
    font-size: 14px; /* MODIFIED: Smaller font in avatar */
}
.avatar.bot { color: var(--accent-color); }
.avatar.user { background: var(--accent-color); color: white; }

.message {
    padding: 12px 18px; border-radius: 20px; 
    line-height: 1.8;
    font-size: 15px;
    box-shadow: 0 4px 15px rgba(44, 62, 80, 0.1);
    word-wrap: break-word; 
    white-space: pre-wrap;
    transition: background-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease, background 0.3s ease;
    /* NEW: Ensure message bubble takes up available width in its container */
    width: 100%; 
}

/* MODIFIED: Changed rounded corner to be on top */
.message.bot { background: white; color: var(--primary-text-color); border-top-left-radius: 5px; }
.message.user { background: var(--user-bubble-bg); color: white; border-top-right-radius: 5px; }
    
.message.bot .blinking-cursor {
    display: inline-block;
    background-color: var(--primary-text-color);
    width: 8px;
    height: 1em;
    animation: blink 1s step-end infinite;
    vertical-align: text-bottom;
}

@keyframes blink {
    from, to { background-color: transparent }
    50% { background-color: var(--primary-text-color); }
}
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
.spinner {
    animation: spin 1s linear infinite;
}

.copy-button {
    position: absolute; bottom: 5px; opacity: 0; visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    background: rgba(255, 255, 255, 0.6); border: var(--border-glass);
    border-radius: 50%; width: 32px; height: 32px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: var(--primary-text-color); padding: 0; font-size: 12px; font-weight: 600;
    z-index: 10; /* Higher than scroll buttons to ensure they appear on top */
}
.message-wrapper:hover .copy-button { opacity: 1; visibility: visible; }
.message-wrapper.show-controls .copy-button { opacity: 1; visibility: visible; }
.copy-button:hover { background: rgba(255, 255, 255, 0.9); }
.message-wrapper-bot .copy-button { left: 100%; margin-left: 4px; }
.message-wrapper-user .copy-button { right: 100%; margin-right: 4px; }

.copy-raw-button {
    position: absolute; bottom: 43px; opacity: 0; visibility: hidden; /* Positioned above the regular copy button */
    transition: opacity 0.2s ease, visibility 0.2s ease;
    background: rgba(255, 255, 255, 0.6); border: var(--border-glass);
    border-radius: 50%; width: 32px; height: 32px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: var(--primary-text-color); padding: 0; font-size: 12px; font-weight: 600;
    z-index: 10; /* Higher than scroll buttons to ensure they appear on top */
}
.message-wrapper:hover .copy-raw-button { opacity: 1; visibility: visible; }
.message-wrapper.show-controls .copy-raw-button { opacity: 1; visibility: visible; }
.copy-raw-button:hover { background: rgba(255, 255, 255, 0.9); }
.message-wrapper-bot .copy-raw-button { left: 100%; margin-left: 4px; } /* Same horizontal position as copy button */
.message-wrapper-user .copy-raw-button { right: 100%; margin-right: 4px; } /* Same horizontal position as copy button */

#input-area { 
    position: relative; /* Add for positioning context of mention popup */
    display: flex; flex-direction: column; padding: 10px 24px 16px 24px; flex-shrink: 0; gap: 12px;
    border-top: var(--border-glass);
    background: rgba(255,255,255,0.2);
}

.main-input-container {
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    border: var(--border-glass); border-radius: 12px; padding: 4px 6px; 
    display: flex; align-items: center; box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
}
#message-input { 
    flex: 1; border: none; background: none; resize: none;
    padding: 8px 10px; font-size: 16px; font-family: var(--font-family);
    color: var(--primary-text-color);
}
#message-input:focus { outline: none; }
#message-input:disabled {
    background-color: rgba(0,0,0,0.04);
    cursor: not-allowed;
}
#message-input::placeholder { color: var(--secondary-text-color); }

#send-button {
    background: var(--accent-color);
    color: white;
    cursor: pointer;
    display: flex;
    justify-content: center; align-items: center; transition: all 0.2s ease;
}
#send-button:hover { transform: scale(1.1); }
#send-button:disabled { background: #bdc3c7; cursor: not-allowed; transform: scale(1); }

.bottom-controls { display: flex; align-items: center; gap: 10px; justify-content: center; }
.control-button {
    background: rgba(255, 255, 255, 0.3); border: var(--border-glass);
    color: var(--secondary-text-color); cursor: pointer;
    width: 36px; height: 36px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s ease;
}
.control-button:hover:not(:disabled) { background: rgba(255, 255, 255, 0.6); color: var(--primary-text-color); }
.control-button:disabled { color: #b2bec3; cursor: not-allowed; }

/* NEW: Highlight upload button during upload */
.control-button.is-uploading {
    color: #e67e22; /* A bright orange */
    background: rgba(230, 126, 34, 0.15); /* A faint orange glow */
}

/* --- START: NEW STYLES FOR TERMINATE BUTTON --- */
.control-button.stop-button {
    background-color: var(--danger-color);
    color: white;
}
.control-button.stop-button:hover {
    background-color: #a93226; /* A darker shade of --danger-color */
}
/* --- END: NEW STYLES FOR TERMINATE BUTTON --- */

#attachment-previews { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

/* NEW: Styles for when attachments are "staged" to be sent with the next message */
#attachment-previews.is-staged .attachment-tag {
    background: rgba(142, 68, 173, 0.2); /* Light purple background */
    color: #5d2177; /* Darker purple text */
    font-weight: 500;
    box-shadow: 0 0 0 2px rgba(142, 68, 173, 0.4); /* A subtle glow */
}

.attachment-tag { 
    background: rgba(255, 255, 255, 0.5); border: var(--border-glass);
    color: var(--accent-color); padding: 5px 12px; border-radius: 15px; font-size: 13px;
    display: flex; align-items: center; gap: 8px; backdrop-filter: blur(5px);
    /* NEW: Add transition for smooth color changes */
    transition: background-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease, font-weight 0.3s ease;
}
.remove-attachment { cursor: pointer; font-weight: bold; }

/* NEW: Disable remove button during upload */
#attachment-previews.uploading .remove-attachment {
    pointer-events: none;
    cursor: not-allowed;
    opacity: 0.5;
}

/* --- NEW: Styles for quote preview --- */
#quote-preview {
    background: rgba(108, 117, 125, 0.15); /* Grey background like attachments */
    border: 1px solid rgba(108, 117, 125, 0.3); /* Grey border */
    color: #6c757d; /* Grey text */
    padding: 5px 12px; /* Same as attachment tags */
    border-radius: 15px; /* Same as attachment tags */
    font-size: 13px; /* Same as attachment tags */
    display: flex; 
    align-items: center; 
    gap: 8px; /* Same as attachment tags */
    backdrop-filter: blur(5px);
    margin-bottom: 8px;
    transition: background-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
}

.quote-header {
    font-weight: 500;
    white-space: nowrap;
}

#clear-quote-btn {
    cursor: pointer;
    font-weight: bold;
    background: none;
    border: none;
    color: inherit; /* Use the same grey color as parent */
    font-size: inherit;
    padding: 0;
    line-height: 1;
}

#clear-quote-btn:hover {
    opacity: 0.7;
}

.quote-text {
    font-style: italic;
    flex: 1;
}

.quote-text::before {
    content: '"';
}

.quote-text::after {
    content: '"';
}
/* --- END: Styles for quote preview --- */

#modal-backdrop {
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.3); z-index: 999;
}
#settings-modal {
    display: none; position: fixed; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.7); backdrop-filter: blur(20px);
    padding: 25px; border-radius: 16px; box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    border: var(--border-glass); z-index: 1000; width: 90%; max-width: 420px;
    box-sizing: border-box; flex-direction: column; gap: 20px;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; }
.modal-header h2 { margin: 0; font-size: 20px; font-weight: 600; }
#modal-close-button {
    background: rgba(0,0,0,0.1); border: none; border-radius: 50%;
    width: 32px; height: 32px; font-size: 20px; line-height: 32px;
    text-align: center; cursor: pointer; color: var(--secondary-text-color);
}
.control-group { display: flex; flex-direction: column; gap: 8px; }
.control-group-header { display: flex; justify-content: space-between; align-items: center; }
.control-group label { font-size: 14px; font-weight: 500; }

/* --- START: UPDATED SLIDER STYLES --- */
/* NEW: Styles for privacy mode checkbox in settings */
.privacy-mode-setting {
    display: flex;
    align-items: center;
    flex-direction: row; /* Override .control-group's column direction */
    gap: 12px;
}
.privacy-mode-setting input[type="checkbox"] {
    width: 18px; height: 18px; cursor: pointer; accent-color: var(--accent-color);
    margin: 0;
}
.privacy-mode-setting label {
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* NEW: Styles for print-friendly button in settings */
.print-friendly-setting {
    display: flex;
    align-items: center;
    flex-direction: row;
    gap: 12px;
}

#print-friendly-button {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--accent-color);
    background: rgba(142, 68, 173, 0.1);
    color: var(--accent-color);
    border-radius: 8px;
    cursor: pointer;
    font-family: var(--font-family);
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
}

#print-friendly-button:hover {
    background: rgba(142, 68, 173, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(142, 68, 173, 0.2);
}

#print-friendly-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

#memory-slider, #temperature-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    background: rgba(0,0,0,0.1);
    border-radius: 5px;
    outline: none;
    cursor: pointer;
}

#memory-slider::-webkit-slider-thumb, #temperature-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--accent-color);
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

#memory-slider::-moz-range-thumb, #temperature-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--accent-color);
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    cursor: pointer;
}

#memory-value-display, #temperature-value-display {
    font-size: 14px;
    font-weight: 600;
    color: var(--accent-color);
}
/* --- END: UPDATED SLIDER STYLES --- */

#settings-ok-button {
    width: 100%;
    padding: 12px;
    margin-top: 10px;
    border: none;
    background: var(--accent-color);
    color: white;
    font-family: var(--font-family);
    font-size: 16px;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s ease;
}
#settings-ok-button:hover {
    transform: scale(1.02);
}

/* --- NEW STYLES FOR OUT-OF-MEMORY MESSAGES --- */
.message-wrapper.out-of-memory .message {
    background: #e9ecef; /* A light, neutral grey */
    color: #6c757d;      /* A muted text color */
    box-shadow: 0 2px 8px rgba(0,0,0,0.05); /* Softer shadow */
}
/* Ensure user bubble gradient is fully overridden */
.message-wrapper.out-of-memory .message.user {
    background: #e9ecef;
}
.message-wrapper.out-of-memory .avatar {
    background: #adb5bd; /* Grey out the avatar */
    color: #f8f9fa;
    opacity: 0.8;
}
/* --- END OF NEW STYLES --- */

/* --- Improved Styles for Chatbot Rendered Markdown --- */
.message .rendered-markdown {
    white-space: normal;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
}

/* === START: REFINED TABLE STYLES === */
.message .rendered-markdown table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.0em 0;
    font-size: 0.95em;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08); /* Softer, more modern shadow */
    border-radius: 15px; /* More pronounced rounding */
    overflow: hidden; /* Crucial for border-radius to apply to child elements */
    border: 1px solid #dee2e6; /* A single, clean border around the table */
}

.message .rendered-markdown th,
.message .rendered-markdown td {
    /* Increased padding to make cells less crowded */
    padding: 16px 20px; 
    text-align: left;
    vertical-align: middle; /* Good practice for cell content */
    /* Add a right border to all cells... */
    border-right: 1px solid #dee2e6;
    /* ...and a bottom border to all cells */
    border-bottom: 1px solid #dee2e6;
}

/* ...then remove the right border from the last cell in each row */
.message .rendered-markdown th:last-child,
.message .rendered-markdown td:last-child {
    border-right: 0;
}

.message .rendered-markdown thead th {
    background-color: #f8f9fa; /* A very light grey for the header */
    color: #212529; /* Darker text for better contrast */
    font-weight: 600;
    /* A stronger bottom border to separate header from body */
    border-bottom: 2px solid #ced4da;
}

.message .rendered-markdown tbody tr {
    background-color: #ffffff;
    transition: background-color 0.2s ease;
}
/* Zebra-striping for readability */
.message .rendered-markdown tbody tr:nth-of-type(even) {
    background-color: #f8f9fa; /* Match header for consistency */
}
/* A subtle hover effect */
.message .rendered-markdown tbody tr:hover {
    background-color: #e9ecef;
}
/* Remove the bottom border from the very last row to avoid a double border with the table's main border */
.message .rendered-markdown tbody tr:last-of-type td {
    border-bottom: 0;
}

/* NEW: Styles for block content (like lists) inside table cells */
.message .rendered-markdown td ul,
.message .rendered-markdown td ol {
    margin: 0; /* Remove vertical margins */
    padding-left: 20px; /* Adjust indentation */
}
.message .rendered-markdown td p {
    margin: 0 0 0.5em 0; /* Remove top margin, add some bottom margin */
}
.message .rendered-markdown td p:last-child {
    margin-bottom: 0; /* No margin for the last paragraph in a cell */
}
/* === END: REFINED TABLE STYLES === */

/* NEW: Wrapper for tables to allow horizontal scrolling */
.table-wrapper {
    overflow-x: auto;
}

/* ... rest of your markdown styles ... */
.message .rendered-markdown h1,
.message .rendered-markdown h2,
.message .rendered-markdown h3,
.message .rendered-markdown h4,
.message .rendered-markdown h5,
.message .rendered-markdown h6 {
    color: #000080;
    line-height: 1.3;
    font-weight: 600;
    margin-top: 3.0em;
    margin-bottom: 1.0em; 
}
.message .rendered-markdown h1 { font-size: 1.5em; }
.message .rendered-markdown h2 { font-size: 1.4em; }
.message .rendered-markdown h3 { font-size: 1.2em; }
.message .rendered-markdown p {
    margin-top: 1em;
    margin-bottom: 1em;
}
.message .rendered-markdown ul,
.message .rendered-markdown ol {
    margin-bottom: 1em;
    padding-left: 25px;
    margin-top: 1em;
}
.message .rendered-markdown h1 + ul, .message .rendered-markdown h1 + ol,
.message .rendered-markdown h2 + ul, .message .rendered-markdown h2 + ol,
.message .rendered-markdown h3 + ul, .message .rendered-markdown h3 + ol {
    margin-top: 0.8em;
}
.message .rendered-markdown li {
    margin-bottom: 0.8em;
    padding-left: 5px;
}
.message .rendered-markdown ul ul,
.message .rendered-markdown ol ul,
.message .rendered-markdown ul ol,
.message .rendered-markdown ol ol {
    margin-top: 0.5em;
    padding-left: 25px;
}
.message .rendered-markdown strong {
    color: #2c3e50;
}
.message .rendered-markdown > *:first-child {
    margin-top: 0;
}
.message .rendered-markdown > *:last-child {
    margin-bottom: 1.0em;
}
.message .rendered-markdown .code-container {
    position: relative;
    margin: 1em 0;
}
.message .rendered-markdown .code-container pre {
    background-color: #282c34;
    color: #abb2bf;
    padding: 2.5em 1em 1em 1em;
    border-radius: 8px;
    white-space: pre-wrap;
    word-wrap: break-word;
    margin: 0;
    max-height: 500px; /* Limit height */
    overflow-y: auto;  /* Add scroll for overflow */
}
.message .rendered-markdown .code-container pre code.hljs {
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 0.9em;
    padding: 0;
}
.message .rendered-markdown .code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #21252b;
    padding: 0.5em 1em;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    border-bottom: 1px solid #3a404a;
}
.message .rendered-markdown .code-header-buttons {
    display: flex;
    gap: 8px;
}
.message .rendered-markdown .language-name {
    color: #9da5b4;
    font-size: 0.8em;
    font-family: sans-serif;
    text-transform: lowercase;
}
.message .rendered-markdown .copy-code-button {
    background-color: transparent;
    color: #9da5b4;
    border: 1px solid #5c6370;
    border-radius: 5px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 0.8em;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: color 0.2s, background-color 0.2s;
}
.message .rendered-markdown .copy-code-button:hover {
    background-color: #3a404a;
    color: #dbe0e9;
}
.message .rendered-markdown .copy-code-button:active {
    background-color: #4b515c;
}

/* --- START: NEW STYLES FOR INLINE HTML PREVIEW --- */
/* NEW: Wrapper for the entire preview component */
.message .rendered-markdown .html-preview-wrapper {
    border: 1px solid #dee2e6;
    border-radius: 8px;
    margin-top: 1em;
    background-color: #f8f9fa; /* A light background for the wrapper */
    overflow: hidden; /* To contain the border-radius */
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

/* NEW: Header for the preview frame */
.message .rendered-markdown .html-preview-header {
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--secondary-text-color);
    background-color: #e9ecef; /* Slightly darker than the wrapper bg */
    border-bottom: 1px solid #dee2e6;
}

.message .rendered-markdown .html-inline-preview {
    width: 100%;
    height: 300px;
    max-height: 500px; /* Allow resizing up to this height */
    border: none; /* Border is now on the wrapper */
    border-radius: 0; /* Radius is now on the wrapper */
    margin-top: 0; /* Margin is now on the wrapper */
    background-color: white;
    resize: vertical; /* Allow user to resize it vertically */
    overflow: auto;
    display: block; /* To remove any default iframe spacing */
}
/* --- END: NEW STYLES FOR INLINE HTML PREVIEW --- */

/* --- START: NEW STYLES FOR DELETE FUNCTIONALITY --- */
#delete-selection-controls {
    gap: 12px;
    width: 100%;
}
#confirm-delete-selected-btn {
    flex-grow: 1;
    background: var(--danger-color);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 25px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
#confirm-delete-selected-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(192, 57, 43, 0.3);
}
#confirm-delete-selected-btn:disabled {
    background: #e74c3c80;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}
#cancel-delete-selected-btn {
    flex-grow: 1;
    background: rgba(255, 255, 255, 0.6);
    color: var(--primary-text-color);
    border: var(--border-glass);
    padding: 12px;
    border-radius: 25px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
}
#cancel-delete-selected-btn:hover {
    background: white;
}

/* --- START: REVISED STYLES FOR SELECTION MODE --- */
body.selection-mode-active .message-wrapper[data-message-id] {
    cursor: pointer;
    border-radius: 12px;
    transition: background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
    padding: 4px; /* Add some padding to make the selection outline look good */
    margin-top: 4px;
    margin-bottom: 4px;
}

body.selection-mode-active .message-wrapper[data-message-id]:hover {
    background-color: rgba(142, 68, 173, 0.05); /* A very light purple hover */
}

body.selection-mode-active .message-wrapper.is-selected {
    background-color: rgba(142, 68, 173, 0.15); /* A darker purple for selected */
    box-shadow: 0 0 0 2px var(--accent-color);
}

body.selection-mode-active .copy-button {
    display: none;
}
/* --- END: REVISED STYLES FOR SELECTION MODE --- */

/* --- START: NEW STYLES FOR CONSULT FUNCTIONALITY --- */
#consult-modal-backdrop {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(5px);
    z-index: 1040;
}
#consult-modal {
    display: none;
    flex-direction: column;
    gap: 16px;
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 480px;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(20px);
    border-radius: 16px;
    padding: 24px;
    border: var(--border-glass);
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    z-index: 1050;
}
.consult-modal-body {
    display: flex;
    flex-direction: column;
    gap: 24px;
}
.consult-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--secondary-text-color);
    margin-bottom: 8px;
}
#consult-bot-selector {
    width: 100%;
    background-color: rgba(255, 255, 255, 0.3);
    border: var(--border-glass);
    border-radius: 8px;
    padding: 8px 12px;
    font-family: var(--font-family);
    font-size: 14px;
    font-weight: 500;
    color: var(--primary-text-color);
    cursor: pointer;
}
.consult-modal-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.consult-modal-option {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    border-radius: 12px;
    border: var(--border-glass);
    background: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
    text-align: left;
    color: var(--primary-text-color);
}
.consult-modal-option:hover {
    background: rgba(255, 255, 255, 0.8);
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
}
.consult-modal-option:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    box-shadow: none;
}
.consult-modal-option:disabled:hover {
    background: rgba(255, 255, 255, 0.4); /* Prevent hover effect */
    box-shadow: none;
}

/* NEW: Styles for the highlighted consult option */
.consult-modal-option.highlighted-option {
    background-color: #fffbe6; /* Light yellow background */
    border-color: #f4b400; /* A gold/yellow border */
}

.consult-modal-option.highlighted-option:hover:not(:disabled) {
    background-color: #fff8d9; /* Slightly darker yellow on hover */
    box-shadow: 0 4px 15px rgba(244, 180, 0, 0.15);
}

.consult-modal-option.highlighted-option:disabled {
    background-color: #fffbe6;
    opacity: 0.6;
    cursor: not-allowed;
    box-shadow: none;
}
.consult-modal-option .icon {
    color: var(--accent-color);
    background: rgba(142, 68, 173, 0.1);
    font-size: 24px;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

.consult-modal-option .text-content {
    display: flex;
    flex-direction: column;
}

.consult-modal-option .text-content span {
    font-weight: 500;
}

.consult-modal-option .text-content small {
    font-size: 13px;
    color: var(--secondary-text-color);
}

#consult-selection-controls {
    gap: 12px;
    width: 100%;
}
#confirm-consult-selection-btn {
    flex-grow: 1;
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 25px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}
#confirm-consult-selection-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(142, 68, 173, 0.3);
}
#confirm-consult-selection-btn:disabled {
    background: #9b59b680;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}
#cancel-consult-selection-btn {
    flex-grow: 1;
    background: rgba(255, 255, 255, 0.6);
    color: var(--primary-text-color);
    border: var(--border-glass);
    padding: 12px;
    border-radius: 25px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
}
#cancel-consult-selection-btn:hover {
    background: white;
}

/* --- START: NEW STYLES FOR AUTHENTICATION --- */
#auth-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 1100; /* High z-index to cover everything */
    display: flex; /* Use flex to center the auth box */
    justify-content: center;
    align-items: center;
    flex-direction: column;
    text-align: center;
    visibility: visible; /* Ensure overlay is visible by default */
}

.auth-box {
    background: rgba(255, 255, 255, 0.7);
    padding: 40px;
    border-radius: 20px;
    border: var(--border-glass);
    box-shadow: 0 8px 32px rgba(31, 38, 135, 0.15);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    width: 90%;
    max-width: 400px;
}

.divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: var(--secondary-text-color);
    font-size: 12px;
    width: 100%;
    margin: 8px 0;
}
.divider::before, .divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid #ccc;
}
.divider:not(:empty)::before {
    margin-right: .5em;
}
.divider:not(:empty)::after {
    margin-left: .5em;
}

#email-auth-form {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 12px;
}

.input-group {
    width: 100%;
    position: relative;
}

/* NEW: Icon styling for input fields */
.input-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #95a5a6;
    transition: color 0.2s ease;
    pointer-events: none;
}

#email-input, #password-input {
    width: 100%;
    padding: 12px 16px 12px 45px; /* Increased left padding for icon */
    font-family: var(--font-family);
    font-size: 15px;
    border: 1px solid #ccc;
    border-radius: 8px;
    background-color: rgba(255, 255, 255, 0.8);
    transition: border-color 0.2s, box-shadow 0.2s;
    color: var(--primary-text-color);
}

/* NEW: Change icon color when input is focused */
.input-group:focus-within .input-icon {
    color: var(--accent-color);
}

#email-input:focus, #password-input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(142, 68, 173, 0.25); /* Made shadow slightly larger */
}

#email-auth-btn {
    background-image: var(--user-bubble-bg);
    background-size: 150% 150%;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 24px;
    font-family: var(--font-family);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.2s ease, background-position 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.auth-box h1 {
    margin: 0 0 8px 0;
    font-size: 28px;
    font-weight: 600;
}

.auth-box p {
    margin: -10px 0 16px 0;
    color: var(--secondary-text-color);
}

#google-signin-btn {
    background-color: #4285F4;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 24px;
    font-family: var(--font-family);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#google-signin-btn:hover {
    background-color: #357ae8;
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.auth-error {
    color: var(--danger-color);
    font-size: 14px;
    margin-top: 10px;
}

#email-auth-btn:hover:not(:disabled) {
    background-position: right center;
    box-shadow: 0 6px 20px rgba(142, 68, 173, 0.25);
    transform: translateY(-2px);
}

#email-auth-btn:disabled {
    background-image: none;
    background-color: #bdc3c7;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.auth-switch {
    margin-top: 16px;
    font-size: 14px;
    color: var(--secondary-text-color);
}

.link-button {
    background: none;
    border: none;
    color: var(--accent-color);
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    font-size: 14px;
    font-family: var(--font-family);
}

.link-button:hover {
    text-decoration: underline;
}

/* NEW: Center the content within the auth box */
#auth-content {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Spinner for authentication loading state */
#auth-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-left-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* The @keyframes spin is already defined earlier in the file */

#user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

#user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.5);
}

#user-display-name { font-weight: 500; }
/* --- END: NEW STYLES FOR AUTHENTICATION --- */

/* --- END: NEW STYLES FOR CONSULT FUNCTIONALITY --- */

/* --- START: NEW STYLES FOR CONSULTATION BANNER --- */
#consultation-banner {
    display: none; /* Hidden by default */
    padding: 10px 16px;
    background-color: rgba(142, 68, 173, 0.1);
    border-bottom: 1px solid rgba(142, 68, 173, 0.2);
    color: var(--accent-color);
    font-size: 14px;
    font-weight: 500;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

/* NEW: Mobile return to main chat button - hidden by default */
#mobile-return-main-btn {
    display: none !important; /* Hidden by default on desktop */
}

/* This is for the banner button */
#return-to-main-chat-btn {
    background-color: var(--accent-color);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-family: var(--font-family);
    font-weight: 500;
    transition: background-color 0.2s ease;
}
/* This is for the banner button's hover state */
#return-to-main-chat-btn:hover {
    background-color: #732d91; /* Darker accent */
}

#history-modal-backdrop {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(5px);
    z-index: 1060; /* Higher than other modals */
}

#history-modal {
    display: none;
    flex-direction: column;
    gap: 16px;
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 80vw;
    max-width: 800px;
    background-color: #F8F9FA;
    border-radius: 16px;
    padding: 24px;
    border: 1px solid #dee2e6; /* Add a subtle border to complement the shadow */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    z-index: 1070;
}

.switch-chat-modal-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 8px;
}

/* NEW: Wrapper for each chat option row */
.switch-chat-option-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.switch-chat-option {
    background-color: #E9F1FF;
    color: #212529;
    width: 100%;
    border: none;
    text-align: left;
    padding: 12px 16px;
    border-radius: 8px;
    flex-grow: 1;
    display: flex;
    align-items: center;
    font-family: var(--font-family);
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.switch-chat-option:hover:not(:disabled) {
    background-color: #D4E3FF;
}

/* NEW: Style for the chat title to handle long names */
.chat-option-title {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* NEW: Style for the date */
.chat-option-date {
    font-size: 12px;
    color: var(--secondary-text-color);
    flex-shrink: 0; /* Prevent date from shrinking */
    text-align: right;
    width: 90px;
}

/* NEW: Edit/Delete button styles */
.edit-chat-button, .delete-chat-button {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    background: transparent;
    border: 1px solid transparent;
    color: var(--secondary-text-color);
    transition: all 0.2s ease;
}

.edit-chat-button:hover {
    background-color: rgba(142, 68, 173, 0.1); /* accent color transparent */
    color: var(--accent-color);
}

.delete-chat-button:hover {
    background-color: rgba(192, 57, 43, 0.1); /* danger color transparent */
    color: var(--danger-color);
}

/* NEW: Styles for the inline editing form */
.edit-chat-form {
    display: none; /* Hidden by default */
    flex-grow: 1;
    align-items: center;
    gap: 8px;
}

.edit-chat-input {
    flex-grow: 1;
    padding: 6px 10px;
    border: 1px solid var(--accent-color);
    border-radius: 6px;
    font-family: var(--font-family);
    font-size: 14px;
    font-weight: 500;
}
.edit-chat-input:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(142, 68, 173, 0.2);
}

.edit-chat-save-btn, .edit-chat-cancel-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    width: 28px;
    height: 28px;
}
.edit-chat-save-btn { color: var(--success-color); }
.edit-chat-cancel-btn { color: var(--danger-color); }

.edit-chat-save-btn:hover { background-color: rgba(39, 174, 96, 0.1); }
.edit-chat-cancel-btn:hover { background-color: rgba(192, 57, 43, 0.1); }

/* When editing, hide the original button */
.switch-chat-option-wrapper.is-editing .switch-chat-option {
    display: none;
}
/* When editing, show the form */
.switch-chat-option-wrapper.is-editing .edit-chat-form {
    display: flex;
}

.switch-chat-option.active {
    background-color: #C2D8FF;
    color: #212529;
    border: none;
    cursor: not-allowed;
}
@media (max-width: 900px) {
    body { 
        padding: 0; 
        /* On mobile, we don't want to center the container, we want it to fill the screen. */
        display: block;
    }
    #app-container { 
        height: 100vh; /* Fallback for older browsers */
        height: 100dvh;
        border-radius: 0;
        max-height: none;
        border: none;
        box-shadow: none;
    }
    
    .header { padding: 8px 16px; flex-wrap: wrap; gap: 8px; }
    .header-left { min-width: 200px; }
    .header-right { flex-grow: 1; }
    #bot-selector { width: 100%; }
    .header-icon { font-size: 24px; }
    .header-title h1 { font-size: 18px; }
    .header-title p { display: none; }
    
    /* NEW: Hide user display name on mobile, only show avatar */
    #user-display-name {
        display: none;
    }

    .footer-contact {
        display: none;
    }

    #input-area { padding-left: 16px; padding-right: 16px; }

    /* NEW: Hide consultation banner on mobile to save space */
    #consultation-banner {
        display: none !important;
    }

    /* NEW: Show mobile return button on mobile when in consultation */
    body.mobile-consultation #mobile-return-main-btn {
        display: flex !important;
    }

    /* NEW: Adjust scroll controls position on mobile to avoid overlap */
    #scroll-controls {
        right: 8px; /* Even closer to edge on mobile (was 20px) */
        bottom: 80px; /* Move higher to avoid input area */
    }

    /* Copy buttons are now vertically aligned, so no mobile-specific margins needed */

    /* --- START: RESPONSIVE STYLES FOR DELETE FUNCTIONALITY --- */
    body.selection-mode-active .message-wrapper-bot {
        margin-left: 30px;
        margin-right: 0;
    }
    body.selection-mode-active .message-wrapper-user {
        margin-right: 30px;
        margin-left: 0;
    }
    body.selection-mode-active .message-wrapper-bot .message-checkbox {
        left: -40px;
    }
    body.selection-mode-active .message-wrapper-user .message-checkbox {
        right: -40px;
    }
}

/* --- NEW: Styles for Load More Button --- */
.load-more-button {
    width: 100%;
    text-align: center;
    padding: 12px 16px;
    border-radius: 8px;
    background-color: rgba(0,0,0,0.05);
    color: var(--secondary-text-color);
    border: 1px solid rgba(0,0,0,0.1);
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s ease;
}
.load-more-button:hover:not(:disabled) {
    background-color: rgba(0,0,0,0.1);
}

/* --- START: NEW STYLES FOR SCROLL BUTTONS --- */
#scroll-controls {
    position: absolute;
    bottom: 20px;
    right: 16px; /* Moved much closer to the scrollbar (was 80px) */
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 5; /* Ensure it's above chat bubbles but below modals */
    transition: opacity 0.2s ease; /* Add transition for smooth hide/show */
}

/* NEW: Hide scroll controls when copy buttons might be visible */
#chat-container:hover #scroll-controls {
    opacity: 0.3; /* Make them semi-transparent when hovering over chat */
}

.scroll-btn {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border: var(--border-glass);
    color: var(--primary-text-color);
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: none; /* Controlled by JS, use 'flex' to show */
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transition: all 0.2s ease;
    opacity: 0.8;
}

/* NEW: Class to make the scroll buttons visible */
.scroll-btn.visible {
    display: flex;
}

.scroll-btn:hover {
    opacity: 1;
    transform: scale(1.1);
    background: white;
}
/* --- END: NEW STYLES FOR SCROLL BUTTONS --- */

/* --- START: NEW STYLES FOR @-MENTION POPUP --- */
#mention-popup {
    display: none; /* Hidden by default */
    position: absolute;
    bottom: 100%; /* Position it right above the parent */
    left: 24px; /* Align with input area padding */
    right: 24px;
    margin-bottom: 8px; /* Space between popup and input area */
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: var(--border-glass);
    border-radius: 12px;
    box-shadow: 0 -8px 24px rgba(0,0,0,0.1);
    z-index: 10;
    max-height: 200px;
    overflow-y: auto;
}

.mention-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border-bottom: var(--border-glass);
}

.mention-item:last-child {
    border-bottom: none;
}

.mention-item:hover {
    background-color: rgba(0,0,0,0.05);
}

.mention-item .model-hint {
    margin-left: auto;
    font-size: 13px;
    color: var(--secondary-text-color);
}
/* --- END: NEW STYLES FOR @-MENTION POPUP --- */

/* --- START: NEW STYLES FOR CUSTOM CONTEXT MENU --- */
#custom-context-menu {
    display: none;
    position: fixed;
    z-index: 2000;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: var(--border-glass);
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    padding: 6px 0;
    min-width: 160px;
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 14px;
    color: var(--primary-text-color);
    transition: background-color 0.2s ease;
}

.context-menu-item:hover {
    background-color: rgba(0,0,0,0.05);
}

.context-menu-item svg {
    width: 16px;
    height: 16px;
    stroke-width: 2;
    color: var(--secondary-text-color);
}
/* --- END: NEW STYLES FOR CUSTOM CONTEXT MENU --- */

/* --- NEW: Styles for Custom Confirmation Modal --- */
.confirmation-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2100; /* Ensure it's on top of everything */
}

.confirmation-modal-content {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
    text-align: center;
    max-width: 320px;
    width: 90%;
}

.confirmation-modal-content p {
    margin: 0 0 20px 0;
    font-size: 16px;
    color: var(--primary-text-color);
    line-height: 1.5;
}

.confirmation-modal-buttons {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.confirmation-modal-buttons button {
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.confirmation-modal-buttons .confirm-btn {
    background-color: var(--danger-color);
    color: white;
}
.confirmation-modal-buttons .confirm-btn:hover {
    background-color: #a93226;
    transform: translateY(-2px);
}

.confirmation-modal-buttons .cancel-btn {
    background-color: #ecf0f1;
    color: var(--secondary-text-color);
}
.confirmation-modal-buttons .cancel-btn:hover {
    background-color: #bdc3c7;
}