:root {
    --bg-color: #131314;
    --sidebar-bg: #1e1f20;
    --text-color: #e3e3e3;
    --input-bg: #1e1f20;
    --user-msg-bg: #282a2c;
    --ai-msg-bg: transparent;
    --accent-color: #a8c7fa;
}

* {
    box-sizing: border-box;
}

html, body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-weight: 400;
    font-optical-sizing: auto;
    height: var(--app-height, 100dvh);
    margin: 0;
    padding: 0;
}

/* Main Layout Container */
.app-container {
    display: flex;
    height: var(--app-height, 100dvh);
    width: 100%;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    background-color: var(--sidebar-bg);
    width: 290px;
    min-width: 290px;
    height: 100%;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #444;
    transition: margin-left 0.3s ease;
    position: relative;
    z-index: 100;
    flex-shrink: 0;
}

.sidebar.collapsed {
    margin-left: -290px;
}

/* Sidebar footer user section */
.sidebar-username {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

.sidebar-overlay.active {
    display: block;
}

/* Main Content Area */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-width: 0;
    position: relative;
}

/* Header */
.header {
    height: 56px;
    min-height: 56px;
    flex-shrink: 0;
    background: rgba(19, 19, 20, 0.95);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    padding: 0 12px;
    z-index: 10;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

/* Chat Container - This is the scrollable area */
.chat-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    overscroll-behavior: contain;
}

.chat-container-inner {
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Scroll-to-bottom FAB */
.scroll-to-bottom-btn {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(8px);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: var(--sidebar-bg, #1e1e1e);
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s, background 0.2s;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.scroll-to-bottom-btn.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

.scroll-to-bottom-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

/* Message Styles */
.message {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    border-radius: 12px;
    width: 100%;
}

.message.user {
    background-color: var(--user-msg-bg);
}

.message.assistant {
    background-color: var(--ai-msg-bg);
}

.message-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 2px;
}

.message-content {
    flex: 1;
    min-width: 0;
    line-height: 1.7;
    word-wrap: break-word;
    overflow-wrap: break-word;
    font-size: var(--chat-font-size, 16px);
}

.message-content h1 { font-size: 1.75em; margin: 0.6em 0 0.4em; }
.message-content h2 { font-size: 1.5em; margin: 0.5em 0 0.35em; }
.message-content h3 { font-size: 1.3em; margin: 0.45em 0 0.3em; }
.message-content h4 { font-size: 1.15em; margin: 0.4em 0 0.25em; }
.message-content h5 { font-size: 1.05em; margin: 0.35em 0 0.2em; }
.message-content h6 { font-size: 1em; margin: 0.3em 0 0.2em; }

.message-content p {
    margin: 0 0 1em 0;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content ul,
.message-content ol {
    margin: 0.5em 0;
    padding-left: 1.5em;
}

.message-content li {
    margin-bottom: 0.3em;
}

/* Attachments in messages */
.attachments-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
}

.attachment-img {
    max-width: 100%;
    max-height: 400px;
    width: auto;
    height: auto;
    border-radius: 12px;
    object-fit: contain;
    cursor: pointer;
    transition: transform 0.2s;
    display: block;
}

.attachment-img:hover {
    transform: scale(1.02);
}

.attachment-file {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--input-bg);
    border-radius: 8px;
    color: var(--text-color);
    text-decoration: none;
    font-size: 14px;
    border: 1px solid #444;
}

.attachment-file:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--accent-color);
}

/* Input Area - Fixed at bottom */
.input-area {
    padding: 16px;
    background-color: var(--bg-color);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
}

.input-area-inner {
    max-width: 900px;
    margin: 0 auto;
}

.input-group-custom {
    background-color: var(--input-bg);
    border-radius: 28px;
    padding: 8px 16px;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    overflow: hidden;
}

.input-group-custom > .btn-icon,
.input-group-custom > label.btn-icon {
    padding: 4px 8px;
}

.input-group-custom textarea {
    background: transparent;
    border: none;
    color: var(--text-color);
    resize: none;
    flex: 1;
    min-width: 0;
    outline: none;
    max-height: 150px;
    min-height: 24px;
    line-height: 1.5;
    padding: 4px 0;
    font-size: var(--chat-font-size, 15px);
    font-family: inherit;
}

.input-group-custom textarea::placeholder {
    color: #888;
}

/* Search input placeholder */
#search-chats::placeholder {
    color: #888;
    opacity: 1;
}

/* File Preview */
#file-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.file-preview-item {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 12px;
    overflow: hidden;
    background: var(--input-bg);
    border: 1px solid #444;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.file-preview-item img {
    width: 100%;
    height: 60px;
    object-fit: cover;
}

.file-preview-item .pdf-icon {
    font-size: 28px;
    color: #e74c3c;
    margin-bottom: 4px;
}

.file-preview-item .file-name {
    font-size: 10px;
    text-align: center;
    padding: 2px 4px;
    color: #999;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-preview-item .file-remove-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    color: #fff;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.2s;
}

.file-preview-item:hover .file-remove-btn {
    opacity: 1;
}

.file-remove-btn:hover {
    background: #e74c3c;
}

/* Buttons */
.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-icon:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Chat History Item */
.chat-history-item {
    padding: 7px 14px;
    cursor: pointer;
    border-radius: 10px;
    margin: 2px 10px;
    font-weight: bold;
    color: var(--text-color);
    text-decoration: none;
    display: block;
    transition: background 0.2s;
    font-size: 13px;
}

.chat-history-item:hover,
.chat-history-item.active {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
}

/* Chat title text with tooltip */
.chat-title-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

/* Chat actions dropdown menu */
.chat-actions-menu {
    flex-shrink: 0;
    line-height: 1;
}

.chat-menu-trigger {
    font-size: 0.85em;
    cursor: pointer;
    opacity: 0.5;
    padding: 2px 4px;
    border-radius: 4px;
    transition: opacity 0.2s, background 0.2s;
}

.chat-history-item:hover .chat-menu-trigger,
.chat-history-item.active .chat-menu-trigger {
    opacity: 0.8;
}

.chat-menu-trigger:hover {
    opacity: 1 !important;
    background: rgba(255, 255, 255, 0.1);
}

.chat-actions-menu .dropdown-menu {
    min-width: 140px;
    font-size: 13px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.chat-actions-menu .dropdown-item {
    padding: 6px 14px;
    font-size: 13px;
}

.chat-actions-menu .dropdown-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.chat-actions-menu .dropdown-item.text-danger:hover {
    background-color: rgba(220, 53, 69, 0.15);
}

/* Model Selector */
.model-selector {
    background: #1e1f20;
    border: 1px solid #444;
    color: var(--text-color);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
}

.model-selector option {
    background-color: var(--bg-color);
}

.image-config-select {
    max-width: 90px;
}

.header-selects {
    display: flex;
    align-items: center;
    gap: 8px;
}

#mobile-settings-btn {
    display: none;
}

.mobile-settings-backdrop {
    display: none;
}

/* Welcome Message */
#welcome-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

#welcome-message h2 {
    color: #888;
    font-weight: 400;
    font-size: 1.5rem;
}

/* Mode-switch chips under input */
#mode-chips {
    display: flex;
    gap: 8px;
    margin-top: 4px;
    flex-wrap: wrap;
    justify-content: center;
}

.mode-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 11px;
    border-radius: 8px;
    font-size: 12px;
    font-family: inherit;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
    background: transparent;
    border: 1px solid #6c757d;
    color: var(--text-color);
    opacity: 0.6;
}

.mode-chip:hover {
    background: rgba(255, 255, 255, 0.1);
    opacity: 0.85;
}

.sidebar-image-chip {
    width: 100%;
    justify-content: center;
}

/* Folder items in sidebar */
.folder-item {
    padding: 7px 14px;
    cursor: pointer;
    border-radius: 10px;
    margin: 2px 10px;
    font-weight: bold;
    display: block;
    transition: background 0.2s;
    font-size: 13px;
}

.folder-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
}

.folder-item .folder-icon {
    margin-right: 6px;
    opacity: 0.7;
}

.folder-item .folder-count {
    font-size: 11px;
    opacity: 0.5;
    margin-left: 4px;
}

.folder-item .chat-menu-trigger {
    opacity: 0.5;
    font-size: 14px;
    padding: 2px 4px;
    border-radius: 4px;
    transition: opacity 0.2s, background 0.2s;
}

.folder-item:hover .chat-menu-trigger {
    opacity: 0.8;
}

.folder-back-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    margin: 2px 10px 6px;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    border-radius: 10px;
    transition: background 0.2s;
    opacity: 0.8;
}

.folder-back-header:hover {
    background-color: rgba(255, 255, 255, 0.1);
    opacity: 1;
}

.folder-back-header i {
    font-size: 14px;
}

.folder-divider {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin: 4px 14px;
}

.move-submenu {
    max-height: 200px;
    overflow-y: auto;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #666;
}

/* Code blocks */
.code-block-wrapper {
    position: relative;
    margin: 1em 0;
    border-radius: 8px;
    overflow: hidden;
    background-color: #2b2b2b;
}

.code-block-wrapper pre {
    margin: 0;
    border-radius: 0;
}

.code-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 8px 4px 14px;
    background: rgba(255, 255, 255, 0.06);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    min-height: 32px;
}

.code-block-lang {
    font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', Consolas, monospace;
    font-size: 11px;
    color: #888;
    text-transform: lowercase;
    letter-spacing: 0.3px;
}

.code-copy-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: #888;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 13px;
}

.code-copy-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ccc;
}

.code-copy-btn.copied {
    color: #4caf50;
}

pre {
    background-color: #2b2b2b;
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1em 0;
}

code {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
}

:not(pre) > code {
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
}

/* Tables in message content */
.table-responsive-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 1em 0;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.message-content table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875em;
    white-space: nowrap;
}

.message-content th,
.message-content td {
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-align: left;
}

.message-content th {
    background: rgba(255, 255, 255, 0.06);
    font-weight: 600;
    position: sticky;
    top: 0;
}

.message-content tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

.message-content tbody tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Drag and Drop */
.main-content.drag-over::after {
    content: 'Rilascia i file qui';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(168, 199, 250, 0.1);
    border: 3px dashed var(--accent-color);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--accent-color);
    z-index: 1000;
    pointer-events: none;
    backdrop-filter: blur(4px);
}

/* Toast Notifications */
.toast-notification {
    position: fixed;
    bottom: 120px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #333;
    color: #fff;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 2000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.toast-notification.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Loading spinner */
.spinner-border-sm {
    width: 1rem;
    height: 1rem;
}

/* Message Actions */
.message-actions {
    display: flex;
    gap: 4px;
    margin-top: 8px;
}

.action-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #888;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
    border-color: rgba(255, 255, 255, 0.2);
}

.action-btn.edit-btn:hover {
    color: var(--accent-color);
    border-color: var(--accent-color);
}

.action-btn.retry-btn:hover {
    color: #4caf50;
    border-color: #4caf50;
}

.action-btn.delete-btn:hover {
    color: #f44336;
    border-color: #f44336;
}

.action-btn.copy-btn:hover {
    color: #2196f3;
    border-color: #2196f3;
}

.action-btn.copy-btn.copied {
    color: #4caf50;
    border-color: #4caf50;
}

/* Reasoning Toggle (collapsible) */
.reasoning-container {
    margin-bottom: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.02);
}

.reasoning-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    user-select: none;
    font-size: 13px;
    color: #999;
    transition: background 0.15s, color 0.15s;
}

.reasoning-toggle:hover {
    background: rgba(255, 255, 255, 0.04);
    color: #bbb;
}

.reasoning-toggle-icon {
    display: inline-flex;
    transition: transform 0.2s ease;
    font-size: 11px;
}

.reasoning-container.open .reasoning-toggle-icon {
    transform: rotate(90deg);
}

.reasoning-toggle-label {
    font-weight: 500;
}

.reasoning-content {
    display: none;
    padding: 0 12px 10px 12px;
    font-size: 0.8125em;
    line-height: 1.6;
    color: #aaa;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    max-height: 400px;
    overflow-y: auto;
}

.reasoning-container.open .reasoning-content {
    display: block;
}

.reasoning-content p {
    margin: 0 0 0.6em 0;
}

.reasoning-content p:last-child {
    margin-bottom: 0;
}

/* Streaming cursor blink */
.streaming-cursor::after {
    content: '▋';
    animation: cursor-blink 0.8s step-end infinite;
    color: var(--accent-color);
    margin-left: 1px;
}

@keyframes cursor-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Model Badge */
.model-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', Consolas, monospace;
    font-size: 11px;
    color: #777;
    letter-spacing: 0.3px;
}

.model-badge i {
    font-size: 10px;
    opacity: 0.7;
}

.cost-badge {
    opacity: 0.8;
    font-size: 11px;
    margin-left: 6px;
    padding-left: 7px;
    border-left: 1px solid rgba(255, 255, 255, 0.12);
    position: relative;
    cursor: default;
}

.cost-tooltip {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #1e1e1e;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 11px;
    font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', Consolas, monospace;
    color: #ccc;
    white-space: nowrap;
    z-index: 100;
    pointer-events: none;
    line-height: 1.5;
}

.cost-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #1e1e1e;
}

.cost-badge:hover .cost-tooltip,
.chat-cost-badge:hover .cost-tooltip {
    display: block;
}

.chat-cost-badge .cost-tooltip {
    bottom: auto;
    top: calc(100% + 8px);
}

.chat-cost-badge .cost-tooltip::after {
    top: auto;
    bottom: 100%;
    border-top-color: transparent;
    border-bottom-color: #1e1e1e;
}

.interrupted-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 6px;
    padding: 3px 9px;
    background: rgba(255, 193, 7, 0.08);
    border: 1px solid rgba(255, 193, 7, 0.2);
    border-radius: 12px;
    font-size: 11px;
    color: #d4a017;
    letter-spacing: 0.2px;
}

.interrupted-badge i {
    font-size: 10px;
}

.chat-cost-badge {
    font-size: 0.7rem;
    font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', Consolas, monospace;
    color: #777;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 3px 10px;
    border-radius: 12px;
    white-space: nowrap;
    position: relative;
    cursor: default;
}

/* Edit Mode */
.message.editing {
    background: rgba(168, 199, 250, 0.05);
    border: 1px solid rgba(168, 199, 250, 0.2);
}

.edit-container {
    margin-top: 12px;
}

.edit-textarea {
    width: 100%;
    min-height: 80px;
    max-height: 300px;
    padding: 12px;
    background: var(--input-bg);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: var(--text-color);
    font-family: inherit;
    font-size: 14px;
    line-height: 1.6;
    resize: none;
    outline: none;
    transition: border-color 0.2s;
}

.edit-textarea:focus {
    border-color: var(--accent-color);
}

.edit-buttons {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    justify-content: flex-end;
}

.edit-buttons .btn {
    padding: 6px 14px;
    font-size: 13px;
    border-radius: 6px;
}

.edit-buttons .btn-primary {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: #000;
}

.edit-buttons .btn-primary:hover {
    background: #89b4f8;
    border-color: #89b4f8;
}

.edit-buttons .btn-outline-secondary {
    border-color: #555;
    color: #aaa;
}

.edit-buttons .btn-outline-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
}

/* Fade out animation for deleted messages */
.message.fade-out {
    opacity: 0;
    transform: translateX(-20px);
    transition: all 0.3s ease;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        transform: translateX(-100%);
        margin-left: 0;
        transition: transform 0.3s ease;
        z-index: 200;
    }

    .sidebar.show-mobile {
        transform: translateX(0);
    }

    .sidebar.collapsed {
        transform: translateX(-100%);
        margin-left: 0;
    }

    .chat-container {
        padding: 16px;
    }

    .message {
        gap: 10px;
        padding: 12px;
    }

    .message-icon {
        display: none;
    }

    .attachment-img {
        max-height: 300px;
    }

    .input-area {
        padding: 12px;
    }

    .input-group-custom {
        padding: 6px 12px;
    }

    .header {
        z-index: 20;
    }

    #mobile-settings-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .header-selects {
        display: none;
        position: fixed;
        top: 56px;
        left: 0;
        right: 0;
        background: var(--bg-color);
        padding: 16px;
        flex-direction: column;
        gap: 12px;
        z-index: 16;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    }

    .header-selects.open {
        display: flex;
    }

    .header-selects .model-selector {
        max-width: 100%;
        width: 100%;
        font-size: 14px;
        padding: 10px 12px;
    }

    .header-selects .image-config-select {
        max-width: 100%;
        width: 100%;
    }

    .mobile-settings-backdrop {
        display: none;
        position: fixed;
        top: 56px;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 15;
    }

    .mobile-settings-backdrop.open {
        display: block;
    }

    .chat-cost-badge {
        font-size: 0.6rem;
        padding: 2px 6px;
    }

    .file-preview-item {
        width: 60px;
        height: 60px;
    }

    .file-preview-item img {
        height: 40px;
    }

    .file-preview-item .pdf-icon {
        font-size: 22px;
    }

    /* Message actions always visible on mobile (no hover) */
    .message-actions {
        opacity: 1;
    }

    .action-btn {
        padding: 6px 10px;
    }

    .edit-buttons {
        flex-wrap: wrap;
    }
}

/* Extra small devices */
@media (max-width: 480px) {
    .header {
        height: 50px;
        min-height: 50px;
    }

    .header-selects {
        top: 50px;
    }

    .mobile-settings-backdrop {
        top: 50px;
    }

    .chat-container {
        padding: 12px;
        gap: 1rem;
    }

    .message {
        padding: 10px;
        gap: 8px;
    }

    .attachment-img {
        max-height: 250px;
    }
}

/* ========== VOICE RECORDING STYLES ========== */

/* Microphone Button */
#mic-btn {
    position: relative;
    transition: all 0.3s ease;
}

#mic-btn i {
    transition: color 0.3s ease;
}

#mic-btn.recording {
    background: rgba(239, 68, 68, 0.2);
    animation: pulse-recording 1.5s ease-in-out infinite;
}

#mic-btn.recording i {
    color: #ef4444;
}

#mic-btn.processing {
    opacity: 0.6;
    pointer-events: none;
}

@keyframes pulse-recording {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }
    50% {
        box-shadow: 0 0 0 12px rgba(239, 68, 68, 0);
    }
}

/* Recording Timer */
.mic-timer {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 20px;
    padding: 4px 12px;
    min-width: 60px;
}

#mic-timer-text {
    font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', Consolas, monospace;
    font-size: 13px;
    font-weight: 500;
    color: #ef4444;
    letter-spacing: 0.5px;
}

/* Timer warning when < 30 seconds */
.mic-timer.warning {
    background: rgba(245, 158, 11, 0.15);
    border-color: rgba(245, 158, 11, 0.3);
    animation: timer-warning 0.5s ease-in-out infinite;
}

.mic-timer.warning #mic-timer-text {
    color: #f59e0b;
}

@keyframes timer-warning {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* ========== TEXT-TO-SPEECH STYLES ========== */

/* Speaker Button in message actions */
.action-btn.speak-btn:hover {
    color: #8b5cf6;
    border-color: #8b5cf6;
}

.action-btn.speak-btn.speaking {
    color: #8b5cf6;
    border-color: #8b5cf6;
    background: rgba(139, 92, 246, 0.1);
    animation: speaking-pulse 1s ease-in-out infinite;
}

@keyframes speaking-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Recording overlay indicator (optional visual feedback) */
.recording-indicator {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(239, 68, 68, 0.9);
    color: white;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 1000;
    animation: slideDown 0.3s ease;
}

.recording-indicator::before {
    content: '';
    width: 10px;
    height: 10px;
    background: white;
    border-radius: 50%;
    animation: blink 1s ease-in-out infinite;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ========== FOLLOW-UP QUESTION CHIPS ========== */

.followup-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 1rem 0 48px;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.followup-container.visible {
    opacity: 1;
    transform: translateY(0);
}

.followup-chip {
    background: rgba(168, 199, 250, 0.06);
    border: 1px solid rgba(168, 199, 250, 0.18);
    color: var(--accent-color);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: calc(var(--chat-font-size, 16px) - 3px);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    line-height: 1.4;
    text-align: left;
}

.followup-chip:hover {
    background: rgba(168, 199, 250, 0.14);
    border-color: rgba(168, 199, 250, 0.35);
    transform: translateY(-1px);
}

.followup-chip:active {
    transform: translateY(0);
}

/* Mobile adjustments for follow-up chips */
@media (max-width: 768px) {
    .followup-container {
        padding-left: 12px;
    }
    
    .followup-chip {
        font-size: 12px;
        padding: 6px 12px;
    }
}

@media (max-width: 480px) {
    .followup-container {
        padding-left: 10px;
    }
}

/* Mobile adjustments for voice features */
@media (max-width: 768px) {
    .mic-timer {
        padding: 3px 8px;
        min-width: 50px;
    }
    
    #mic-timer-text {
        font-size: 11px;
    }
    
    .recording-indicator {
        top: 60px;
        font-size: 12px;
        padding: 6px 14px;
    }
}

/* ========== LIGHT THEME ========== */

[data-theme="light"] {
    --bg-color: #f5f5f5;
    --sidebar-bg: #ffffff;
    --text-color: #1a1a1a;
    --input-bg: #ffffff;
    --user-msg-bg: #e3e7ed;
    --ai-msg-bg: transparent;
    --accent-color: #1a73e8;
}

[data-theme="light"] .sidebar {
    border-right-color: #ddd;
}

[data-theme="light"] #search-chats {
    background-color: #f0f0f0 !important;
    color: var(--text-color) !important;
    border-color: #ddd !important;
}

[data-theme="light"] .sidebar-footer-user {
    border-top-color: #ddd !important;
}

[data-theme="light"] .header {
    background: rgba(245, 245, 245, 0.95);
    border-bottom-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .header-selects {
    border-bottom-color: rgba(0, 0, 0, 0.08);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .scroll-to-bottom-btn {
    background: #f5f5f5;
    border-color: rgba(0, 0, 0, 0.12);
    color: rgba(0, 0, 0, 0.6);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .scroll-to-bottom-btn:hover {
    background: #e8e8e8;
    color: rgba(0, 0, 0, 0.8);
}

[data-theme="light"] .input-area {
    border-top-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .input-group-custom {
    border: 1px solid #ddd;
}

[data-theme="light"] .input-group-custom textarea::placeholder {
    color: #999;
}

[data-theme="light"] #search-chats::placeholder {
    color: #999;
}

[data-theme="light"] .attachment-file {
    border-color: #ddd;
    background: #fff;
}

[data-theme="light"] .attachment-file:hover {
    background: rgba(0, 0, 0, 0.04);
    color: var(--accent-color);
}

[data-theme="light"] .file-preview-item {
    border-color: #ddd;
    background: #fff;
}

[data-theme="light"] .btn-icon {
    color: #555;
}

[data-theme="light"] .btn-icon:hover {
    background-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .chat-history-item:hover,
[data-theme="light"] .chat-history-item.active {
    background-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .folder-item:hover {
    background-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .folder-back-header:hover {
    background-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .folder-divider {
    border-top-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .model-selector {
    background: #fff;
    border-color: #ddd;
    color: var(--text-color);
}

[data-theme="light"] .model-selector option {
    background-color: #fff;
}

[data-theme="light"] #welcome-message h2 {
    color: #999;
}

[data-theme="light"] .mode-chip {
    border-color: #adb5bd;
    color: var(--text-color);
}

[data-theme="light"] .mode-chip:hover {
    background: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] ::-webkit-scrollbar-thumb {
    background: #ccc;
}

[data-theme="light"] ::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

[data-theme="light"] .code-block-wrapper {
    background-color: #f0f0f0;
}

[data-theme="light"] .code-block-header {
    background: rgba(0, 0, 0, 0.04);
    border-bottom-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .code-block-lang {
    color: #666;
}

[data-theme="light"] .code-copy-btn {
    color: #666;
}

[data-theme="light"] .code-copy-btn:hover {
    background: rgba(0, 0, 0, 0.08);
    color: #333;
}

[data-theme="light"] pre {
    background-color: #f0f0f0;
}

[data-theme="light"] :not(pre) > code {
    background: rgba(0, 0, 0, 0.07);
}

[data-theme="light"] .table-responsive-wrapper {
    border-color: rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .message-content th,
[data-theme="light"] .message-content td {
    border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .message-content th {
    background: rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .message-content tbody tr:nth-child(even) {
    background: rgba(0, 0, 0, 0.02);
}

[data-theme="light"] .message-content tbody tr:hover {
    background: rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .main-content.drag-over::after {
    background: rgba(26, 115, 232, 0.08);
    border-color: var(--accent-color);
    color: var(--accent-color);
}

[data-theme="light"] .toast-notification {
    background: #333;
    color: #fff;
}

[data-theme="light"] .action-btn {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.1);
    color: #666;
}

[data-theme="light"] .action-btn:hover {
    background: rgba(0, 0, 0, 0.06);
    color: var(--text-color);
    border-color: rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .reasoning-container {
    border-color: rgba(0, 0, 0, 0.1);
    background: rgba(0, 0, 0, 0.02);
}

[data-theme="light"] .reasoning-toggle {
    color: #666;
}

[data-theme="light"] .reasoning-toggle:hover {
    background: rgba(0, 0, 0, 0.04);
    color: #444;
}

[data-theme="light"] .reasoning-content {
    color: #555;
    border-top-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .model-badge {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.1);
    color: #888;
}

[data-theme="light"] .cost-badge {
    border-left-color: rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .cost-tooltip {
    background: #fff;
    border-color: rgba(0, 0, 0, 0.12);
    color: #555;
}

[data-theme="light"] .cost-tooltip::after {
    border-top-color: #fff;
}

[data-theme="light"] .chat-cost-badge .cost-tooltip::after {
    border-top-color: transparent;
    border-bottom-color: #fff;
}

[data-theme="light"] .interrupted-badge {
    background: rgba(255, 193, 7, 0.1);
    border-color: rgba(255, 193, 7, 0.25);
    color: #b8860b;
}

[data-theme="light"] .chat-cost-badge {
    color: #888;
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .message.editing {
    background: rgba(26, 115, 232, 0.05);
    border-color: rgba(26, 115, 232, 0.2);
}

[data-theme="light"] .edit-textarea {
    border-color: rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .edit-textarea:focus {
    border-color: var(--accent-color);
}

[data-theme="light"] .edit-buttons .btn-outline-secondary {
    border-color: #aaa;
    color: #555;
}

[data-theme="light"] .edit-buttons .btn-outline-secondary:hover {
    background: rgba(0, 0, 0, 0.06);
    color: var(--text-color);
}

[data-theme="light"] .followup-chip {
    background: rgba(26, 115, 232, 0.06);
    border-color: rgba(26, 115, 232, 0.2);
}

[data-theme="light"] .followup-chip:hover {
    background: rgba(26, 115, 232, 0.12);
    border-color: rgba(26, 115, 232, 0.35);
}

[data-theme="light"] .streaming-cursor::after {
    color: var(--accent-color);
}

/* ========== IMAGE GENERATION ========== */

/* New Image button in sidebar */
.new-image-btn {
    width: 42px;
    height: 38px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.1rem;
}

/* Chat type icon in sidebar list */
.chat-type-icon {
    font-size: 0.75em;
    opacity: 0.6;
    vertical-align: middle;
}
.chat-type-icon.chat-type-image {
    color: #a78bfa;
}
[data-theme="light"] .chat-type-icon.chat-type-image {
    color: #7c3aed;
}

/* Generated images grid */
.generated-images-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 10px;
}

/* Generated image container with download overlay */
.generated-image-container {
    position: relative;
    display: inline-block;
    border-radius: 12px;
    overflow: hidden;
    max-width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
}
[data-theme="light"] .generated-image-container {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.08);
}

.generated-image {
    display: block;
    max-width: 100%;
    max-height: 512px;
    border-radius: 12px;
    object-fit: contain;
}

.generated-image-download {
    position: absolute;
    bottom: 10px;
    right: 10px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    opacity: 0;
    transition: opacity 0.2s ease, background 0.2s ease;
    font-size: 1rem;
    backdrop-filter: blur(4px);
}
.generated-image-container:hover .generated-image-download {
    opacity: 1;
}
.generated-image-download:hover {
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
}

/* Image generation loading spinner */
.image-generating {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 0;
    color: #aaa;
    font-size: 0.95rem;
}
[data-theme="light"] .image-generating {
    color: #777;
}

.image-generating-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: img-spin 0.8s linear infinite;
    flex-shrink: 0;
}
[data-theme="light"] .image-generating-spinner {
    border-color: rgba(0, 0, 0, 0.08);
    border-top-color: var(--accent-color);
}

@keyframes img-spin {
    to { transform: rotate(360deg); }
}

/* ── Agent mode toggle button ───────────────────────────────────────────── */
#agent-mode-btn {
    transition: color 0.2s, background 0.2s;
}

#agent-mode-btn.agent-mode-active {
    color: #7c9ef8;
    background: rgba(124, 158, 248, 0.12);
    border-radius: 8px;
}

[data-theme="light"] #agent-mode-btn.agent-mode-active {
    color: #2952cc;
    background: rgba(41, 82, 204, 0.10);
}

/* ── Tool status indicator (shown during orchestration) ─────────────────── */
.tools-status {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.tool-status-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #999;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    padding: 4px 10px;
}

.tool-status-spinner {
    display: inline-block;
    width: 10px;
    height: 10px;
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-top-color: #7c9ef8;
    border-radius: 50%;
    animation: tool-spin 0.8s linear infinite;
}

@keyframes tool-spin {
    to { transform: rotate(360deg); }
}

/* ── Thinking indicator (pre-stream / inter-tool feedback) ──────────────── */
.thinking-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #999;
    padding: 2px 0 6px 0;
    transition: opacity 0.25s ease;
}

.thinking-indicator-text {
    white-space: nowrap;
}

.thinking-dots {
    display: inline-flex;
    gap: 3px;
}

.thinking-dots span {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--accent-color);
    opacity: 0.3;
    animation: thinking-dot 1.4s ease-in-out infinite;
}

.thinking-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.thinking-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes thinking-dot {
    0%, 80%, 100% { opacity: 0.3; transform: scale(1); }
    40% { opacity: 1; transform: scale(1.3); }
}

[data-theme="light"] .thinking-indicator {
    color: #666;
}

/* ── Tools context / Fonti section ──────────────────────────────────────── */
.tools-context-container {
    margin-bottom: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.02);
}

.tools-context-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    user-select: none;
    font-size: 13px;
    color: #999;
    transition: background 0.15s, color 0.15s;
}

.tools-context-toggle:hover {
    background: rgba(255, 255, 255, 0.04);
    color: #bbb;
}

.tools-context-toggle-icon {
    display: inline-flex;
    transition: transform 0.2s ease;
    font-size: 11px;
}

.tools-context-container.open .tools-context-toggle-icon {
    transform: rotate(90deg);
}

.tools-context-content {
    display: none;
    padding: 6px 12px 10px 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.tools-context-container.open .tools-context-content {
    display: block;
}

.tool-sources-list {
    margin: 0;
    padding: 0 0 0 4px;
    list-style: none;
}

.tool-source-item {
    display: flex;
    align-items: baseline;
    gap: 6px;
    font-size: 12px;
    color: #aaa;
    padding: 3px 0;
}

.tool-source-item a {
    color: #7c9ef8;
    text-decoration: none;
}

.tool-source-item a:hover {
    text-decoration: underline;
}

.tool-source-meta {
    color: #666;
    font-style: italic;
}

.tool-source-error {
    color: #e07070;
}

/* Light theme overrides */
[data-theme="light"] .tool-status-item {
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.1);
    color: #666;
}

[data-theme="light"] .tool-status-spinner {
    border-color: rgba(0, 0, 0, 0.1);
    border-top-color: #4a6cf7;
}

[data-theme="light"] .tools-context-container {
    border-color: rgba(0, 0, 0, 0.1);
    background: rgba(0, 0, 0, 0.02);
}

[data-theme="light"] .tools-context-toggle {
    color: #666;
}

[data-theme="light"] .tools-context-toggle:hover {
    background: rgba(0, 0, 0, 0.04);
    color: #444;
}

[data-theme="light"] .tools-context-content {
    border-top-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .tool-source-item {
    color: #555;
}

[data-theme="light"] .tool-source-item a {
    color: #2952cc;
}

/* ========== PRIVACY MODE ========== */

/* Sidebar privacy toggle button */
#privacy-toggle-btn {
    transition: all 0.2s ease;
}

#privacy-toggle-btn.privacy-active {
    color: #7c9ef8;
    background: rgba(124, 158, 248, 0.15);
    border-color: rgba(124, 158, 248, 0.4);
}

[data-theme="light"] #privacy-toggle-btn.privacy-active {
    color: #2952cc;
    background: rgba(41, 82, 204, 0.12);
    border-color: rgba(41, 82, 204, 0.4);
}

/* Header lock button for current chat */
#chat-privacy-btn {
    transition: all 0.2s ease;
    font-size: 0.85rem;
}

#chat-privacy-btn .bi-lock-fill {
    color: #7c9ef8;
}

#chat-privacy-btn .bi-unlock {
    color: #888;
}

/* Privacy PIN modal overlay */
.privacy-pin-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.privacy-pin-modal {
    background: var(--sidebar-bg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 24px;
    width: 320px;
    max-width: 90vw;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.privacy-pin-header {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-color);
}

.privacy-pin-header i {
    color: var(--accent-color);
    font-size: 1.2rem;
}

.privacy-pin-input {
    width: 100%;
    background: var(--bg-color);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    padding: 12px 16px;
    color: var(--text-color);
    font-size: 1.2rem;
    letter-spacing: 8px;
    text-align: center;
    outline: none;
    transition: border-color 0.2s;
    font-family: 'SF Mono', 'Fira Code', Consolas, monospace;
    -webkit-text-security: disc;
    text-security: disc;
}

.privacy-pin-input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(168, 199, 250, 0.2);
}

.privacy-pin-error {
    color: #ff6b7a;
    font-size: 0.85rem;
    margin-top: 8px;
    text-align: center;
}

.privacy-pin-buttons {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    justify-content: flex-end;
}

.privacy-pin-buttons .btn-save {
    padding: 6px 16px;
    font-size: 13px;
    background: var(--accent-color);
    border: none;
    color: #131314;
    font-weight: 600;
    border-radius: 8px;
}

.privacy-pin-buttons .btn-save:hover {
    background: #8ab4f8;
}

[data-theme="light"] .privacy-pin-buttons .btn-save {
    color: #fff;
}

/* Delete Folder modal */
.delete-folder-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.15s ease;
}

.delete-folder-modal {
    background: var(--sidebar-bg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 24px;
    width: 340px;
    max-width: 90vw;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.delete-folder-header {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-color);
}

.delete-folder-header i {
    color: #ff6b7a;
    font-size: 1.2rem;
}

.delete-folder-text {
    font-size: 0.9rem;
    opacity: 0.75;
    margin-bottom: 20px;
    line-height: 1.4;
}

.delete-folder-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.delete-folder-buttons .btn {
    width: 100%;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 10px;
    transition: background 0.2s, opacity 0.2s;
}

.delete-folder-btn-cancel {
    border-color: rgba(255, 255, 255, 0.15) !important;
    color: var(--text-color) !important;
}

.delete-folder-btn-cancel:hover {
    background: rgba(255, 255, 255, 0.08) !important;
}

.delete-folder-btn-move {
    background: #2e7d32 !important;
    border: none !important;
    color: #fff !important;
}

.delete-folder-btn-move:hover {
    background: #388e3c !important;
}

.delete-folder-btn-delete {
    background: #c62828 !important;
    border: none !important;
    color: #fff !important;
}

.delete-folder-btn-delete:hover {
    background: #d32f2f !important;
}

[data-theme="light"] .delete-folder-modal {
    border-color: rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .delete-folder-btn-cancel {
    border-color: #ccc !important;
}

[data-theme="light"] .delete-folder-btn-cancel:hover {
    background: rgba(0, 0, 0, 0.05) !important;
}

/* Create Folder modal input */
.create-folder-input {
    width: 100%;
    background: var(--bg-color);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    padding: 10px 14px;
    color: var(--text-color);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
    margin-bottom: 16px;
}

.create-folder-input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(168, 199, 250, 0.2);
}

.delete-folder-btn-confirm {
    background: var(--accent-color) !important;
    border: none !important;
    color: #131314 !important;
    font-weight: 600 !important;
}

.delete-folder-btn-confirm:hover {
    background: #8ab4f8 !important;
}

[data-theme="light"] .delete-folder-btn-confirm {
    color: #fff !important;
}

[data-theme="light"] .create-folder-input {
    background: #f5f5f5;
    border-color: #ccc;
}

[data-theme="light"] .create-folder-input:focus {
    border-color: var(--accent-color);
}

/* Move to Folder modal list */
.move-folder-list {
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.move-folder-list::-webkit-scrollbar {
    width: 6px;
}

.move-folder-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.move-folder-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-color);
    transition: background 0.15s;
}

.move-folder-option:hover {
    background: rgba(255, 255, 255, 0.08);
}

.move-folder-option i {
    opacity: 0.7;
    font-size: 14px;
}

.move-folder-option + .move-folder-option {
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.move-folder-empty {
    padding: 16px;
    text-align: center;
    font-size: 13px;
    opacity: 0.5;
}

[data-theme="light"] .move-folder-list {
    border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .move-folder-option:hover {
    background: rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .move-folder-option + .move-folder-option {
    border-top-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .move-folder-list::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
}

/* Private chat indicator in sidebar */
.chat-private-icon {
    font-size: 0.7em;
    opacity: 0.5;
    margin-left: 4px;
}

/* Privacy mode banner in sidebar */
.privacy-mode-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 12px;
    margin: 0 10px 4px;
    background: rgba(124, 158, 248, 0.1);
    border: 1px solid rgba(124, 158, 248, 0.2);
    border-radius: 8px;
    font-size: 12px;
    color: #7c9ef8;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.privacy-mode-banner:hover {
    background: rgba(124, 158, 248, 0.2);
}

.privacy-mode-close {
    margin-left: auto;
    font-size: 10px;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.privacy-mode-banner:hover .privacy-mode-close {
    opacity: 1;
}

[data-theme="light"] .privacy-mode-banner {
    background: rgba(41, 82, 204, 0.08);
    border-color: rgba(41, 82, 204, 0.2);
    color: #2952cc;
}

[data-theme="light"] .privacy-mode-banner:hover {
    background: rgba(41, 82, 204, 0.15);
}

/* Light theme overrides for privacy */
[data-theme="light"] .privacy-pin-modal {
    border-color: rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .privacy-pin-input {
    background: #f5f5f5;
    border-color: #ccc;
}

[data-theme="light"] .privacy-pin-input:focus {
    border-color: var(--accent-color);
}

[data-theme="light"] .privacy-pin-error {
    color: #dc3545;
}

/* ========== SAVED PROMPTS SELECTOR ========== */

#prompt-btn {
    position: relative;
    transition: color 0.2s, background 0.2s;
}

#prompt-btn.prompt-btn-active {
    color: #7c9ef8;
    background: rgba(124, 158, 248, 0.12);
    border-radius: 8px;
}

[data-theme="light"] #prompt-btn.prompt-btn-active {
    color: #2952cc;
    background: rgba(41, 82, 204, 0.10);
}

.prompt-badge {
    position: absolute;
    top: 2px;
    right: 0;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    background: var(--accent-color);
    color: #131314;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
}

.prompts-dropdown {
    position: absolute;
    top: 56px;
    right: 12px;
    width: 340px;
    max-width: calc(100vw - 24px);
    background: var(--sidebar-bg);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    z-index: 50;
    max-height: 400px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: promptDropdownIn 0.15s ease;
}

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

.prompts-dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-color);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.prompts-token-estimate {
    font-size: 11px;
    font-weight: 500;
    color: #888;
    font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', Consolas, monospace;
}

.prompts-dropdown-list {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.prompt-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    user-select: none;
}

.prompt-option:last-child {
    border-bottom: none;
}

.prompt-option:hover {
    background: rgba(255, 255, 255, 0.06);
}

.prompt-option.selected {
    background: rgba(168, 199, 250, 0.08);
}

.prompt-option input[type="checkbox"] {
    accent-color: var(--accent-color);
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    cursor: pointer;
}

.prompt-option-name {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-color);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.prompt-option-tokens {
    font-size: 11px;
    color: #888;
    flex-shrink: 0;
    font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', Consolas, monospace;
}

.prompts-dropdown-empty {
    padding: 20px 14px;
    text-align: center;
    font-size: 13px;
    color: #888;
    line-height: 1.6;
}

.prompts-dropdown-footer {
    padding: 8px 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.prompts-manage-link {
    font-size: 12px;
    color: #888;
    text-decoration: none;
    transition: color 0.15s;
}

.prompts-manage-link:hover {
    color: var(--accent-color);
}

@media (max-width: 768px) {
    .prompts-dropdown {
        right: 8px;
        left: 8px;
        width: auto;
    }
}

@media (max-width: 480px) {
    .prompts-dropdown {
        top: 50px;
    }
}

/* Light theme */
[data-theme="light"] .prompts-dropdown {
    border-color: rgba(0, 0, 0, 0.12);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .prompts-dropdown-header {
    border-bottom-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .prompt-option:hover {
    background: rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .prompt-option.selected {
    background: rgba(26, 115, 232, 0.06);
}

[data-theme="light"] .prompt-option {
    border-bottom-color: rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .prompts-dropdown-footer {
    border-top-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .prompt-badge {
    color: #fff;
}
